From 7915ffb8ffcf218eff92927a23893dc8aa01830c Mon Sep 17 00:00:00 2001 From: Xin LI Date: Wed, 21 Apr 2010 17:53:10 +0000 Subject: Flattern tree. --- ABOUT-NLS | 716 +++ AUTHORS | 86 + COPYING | 340 ++ ChangeLog | 7511 ++++++++++++++++++++++++++++++++ INSTALL | 229 + NEWS | 904 ++++ README | 147 + README-alpha | 3 + THANKS | 463 ++ THANKS-to-translators | 36 + TODO | 171 + contrib/gnu-sort/ABOUT-NLS | 716 --- contrib/gnu-sort/AUTHORS | 86 - contrib/gnu-sort/COPYING | 340 -- contrib/gnu-sort/ChangeLog | 7511 -------------------------------- contrib/gnu-sort/INSTALL | 229 - contrib/gnu-sort/NEWS | 904 ---- contrib/gnu-sort/README | 147 - contrib/gnu-sort/README-alpha | 3 - contrib/gnu-sort/THANKS | 463 -- contrib/gnu-sort/THANKS-to-translators | 36 - contrib/gnu-sort/TODO | 171 - contrib/gnu-sort/lib/__fpending.c | 30 - contrib/gnu-sort/lib/__fpending.h | 17 - contrib/gnu-sort/lib/argmatch.c | 278 -- contrib/gnu-sort/lib/argmatch.h | 112 - contrib/gnu-sort/lib/closeout.c | 93 - contrib/gnu-sort/lib/closeout.h | 33 - contrib/gnu-sort/lib/dup-safer.c | 59 - contrib/gnu-sort/lib/error.c | 306 -- contrib/gnu-sort/lib/error.h | 66 - contrib/gnu-sort/lib/exit.h | 32 - contrib/gnu-sort/lib/exitfail.c | 27 - contrib/gnu-sort/lib/exitfail.h | 20 - contrib/gnu-sort/lib/fopen-safer.c | 72 - contrib/gnu-sort/lib/getopt.c | 1068 ----- contrib/gnu-sort/lib/getopt.h | 180 - contrib/gnu-sort/lib/getopt1.c | 188 - contrib/gnu-sort/lib/gettext.h | 68 - contrib/gnu-sort/lib/hard-locale.c | 75 - contrib/gnu-sort/lib/hard-locale.h | 26 - contrib/gnu-sort/lib/human.c | 485 --- contrib/gnu-sort/lib/human.h | 88 - contrib/gnu-sort/lib/inttostr.c | 49 - contrib/gnu-sort/lib/inttostr.h | 47 - contrib/gnu-sort/lib/long-options.c | 91 - contrib/gnu-sort/lib/long-options.h | 26 - contrib/gnu-sort/lib/memcoll.c | 85 - contrib/gnu-sort/lib/memcoll.h | 28 - contrib/gnu-sort/lib/pathmax.h | 54 - contrib/gnu-sort/lib/physmem.c | 307 -- contrib/gnu-sort/lib/physmem.h | 27 - contrib/gnu-sort/lib/posixver.c | 59 - contrib/gnu-sort/lib/posixver.h | 1 - contrib/gnu-sort/lib/quote.c | 41 - contrib/gnu-sort/lib/quote.h | 22 - contrib/gnu-sort/lib/quotearg.c | 673 --- contrib/gnu-sort/lib/quotearg.h | 137 - contrib/gnu-sort/lib/stat-macros.h | 255 -- contrib/gnu-sort/lib/stdio-safer.h | 23 - contrib/gnu-sort/lib/strnlen.c | 48 - contrib/gnu-sort/lib/timespec.h | 71 - contrib/gnu-sort/lib/umaxtostr.c | 3 - contrib/gnu-sort/lib/unistd-safer.h | 21 - contrib/gnu-sort/lib/version-etc.c | 176 - contrib/gnu-sort/lib/version-etc.h | 37 - contrib/gnu-sort/lib/xalloc-die.c | 45 - contrib/gnu-sort/lib/xalloc.h | 90 - contrib/gnu-sort/lib/xmalloc.c | 221 - contrib/gnu-sort/lib/xmemcoll.c | 59 - contrib/gnu-sort/lib/xmemcoll.h | 2 - contrib/gnu-sort/lib/xstrtol.c | 291 -- contrib/gnu-sort/lib/xstrtol.h | 89 - contrib/gnu-sort/lib/xstrtoul.c | 6 - contrib/gnu-sort/lib/xstrtoumax.c | 33 - contrib/gnu-sort/man/sort.1 | 113 - contrib/gnu-sort/src/sort.c | 2554 ----------- contrib/gnu-sort/src/system.h | 831 ---- lib/__fpending.c | 30 + lib/__fpending.h | 17 + lib/argmatch.c | 278 ++ lib/argmatch.h | 112 + lib/closeout.c | 93 + lib/closeout.h | 33 + lib/dup-safer.c | 59 + lib/error.c | 306 ++ lib/error.h | 66 + lib/exit.h | 32 + lib/exitfail.c | 27 + lib/exitfail.h | 20 + lib/fopen-safer.c | 72 + lib/getopt.c | 1068 +++++ lib/getopt.h | 180 + lib/getopt1.c | 188 + lib/gettext.h | 68 + lib/hard-locale.c | 75 + lib/hard-locale.h | 26 + lib/human.c | 485 +++ lib/human.h | 88 + lib/inttostr.c | 49 + lib/inttostr.h | 47 + lib/long-options.c | 91 + lib/long-options.h | 26 + lib/memcoll.c | 85 + lib/memcoll.h | 28 + lib/pathmax.h | 54 + lib/physmem.c | 307 ++ lib/physmem.h | 27 + lib/posixver.c | 59 + lib/posixver.h | 1 + lib/quote.c | 41 + lib/quote.h | 22 + lib/quotearg.c | 673 +++ lib/quotearg.h | 137 + lib/stat-macros.h | 255 ++ lib/stdio-safer.h | 23 + lib/strnlen.c | 48 + lib/timespec.h | 71 + lib/umaxtostr.c | 3 + lib/unistd-safer.h | 21 + lib/version-etc.c | 176 + lib/version-etc.h | 37 + lib/xalloc-die.c | 45 + lib/xalloc.h | 90 + lib/xmalloc.c | 221 + lib/xmemcoll.c | 59 + lib/xmemcoll.h | 2 + lib/xstrtol.c | 291 ++ lib/xstrtol.h | 89 + lib/xstrtoul.c | 6 + lib/xstrtoumax.c | 33 + man/sort.1 | 113 + src/sort.c | 2554 +++++++++++ src/system.h | 831 ++++ 134 files changed, 20544 insertions(+), 20544 deletions(-) create mode 100644 ABOUT-NLS create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 NEWS create mode 100644 README create mode 100644 README-alpha create mode 100644 THANKS create mode 100644 THANKS-to-translators create mode 100644 TODO delete mode 100644 contrib/gnu-sort/ABOUT-NLS delete mode 100644 contrib/gnu-sort/AUTHORS delete mode 100644 contrib/gnu-sort/COPYING delete mode 100644 contrib/gnu-sort/ChangeLog delete mode 100644 contrib/gnu-sort/INSTALL delete mode 100644 contrib/gnu-sort/NEWS delete mode 100644 contrib/gnu-sort/README delete mode 100644 contrib/gnu-sort/README-alpha delete mode 100644 contrib/gnu-sort/THANKS delete mode 100644 contrib/gnu-sort/THANKS-to-translators delete mode 100644 contrib/gnu-sort/TODO delete mode 100644 contrib/gnu-sort/lib/__fpending.c delete mode 100644 contrib/gnu-sort/lib/__fpending.h delete mode 100644 contrib/gnu-sort/lib/argmatch.c delete mode 100644 contrib/gnu-sort/lib/argmatch.h delete mode 100644 contrib/gnu-sort/lib/closeout.c delete mode 100644 contrib/gnu-sort/lib/closeout.h delete mode 100644 contrib/gnu-sort/lib/dup-safer.c delete mode 100644 contrib/gnu-sort/lib/error.c delete mode 100644 contrib/gnu-sort/lib/error.h delete mode 100644 contrib/gnu-sort/lib/exit.h delete mode 100644 contrib/gnu-sort/lib/exitfail.c delete mode 100644 contrib/gnu-sort/lib/exitfail.h delete mode 100644 contrib/gnu-sort/lib/fopen-safer.c delete mode 100644 contrib/gnu-sort/lib/getopt.c delete mode 100644 contrib/gnu-sort/lib/getopt.h delete mode 100644 contrib/gnu-sort/lib/getopt1.c delete mode 100644 contrib/gnu-sort/lib/gettext.h delete mode 100644 contrib/gnu-sort/lib/hard-locale.c delete mode 100644 contrib/gnu-sort/lib/hard-locale.h delete mode 100644 contrib/gnu-sort/lib/human.c delete mode 100644 contrib/gnu-sort/lib/human.h delete mode 100644 contrib/gnu-sort/lib/inttostr.c delete mode 100644 contrib/gnu-sort/lib/inttostr.h delete mode 100644 contrib/gnu-sort/lib/long-options.c delete mode 100644 contrib/gnu-sort/lib/long-options.h delete mode 100644 contrib/gnu-sort/lib/memcoll.c delete mode 100644 contrib/gnu-sort/lib/memcoll.h delete mode 100644 contrib/gnu-sort/lib/pathmax.h delete mode 100644 contrib/gnu-sort/lib/physmem.c delete mode 100644 contrib/gnu-sort/lib/physmem.h delete mode 100644 contrib/gnu-sort/lib/posixver.c delete mode 100644 contrib/gnu-sort/lib/posixver.h delete mode 100644 contrib/gnu-sort/lib/quote.c delete mode 100644 contrib/gnu-sort/lib/quote.h delete mode 100644 contrib/gnu-sort/lib/quotearg.c delete mode 100644 contrib/gnu-sort/lib/quotearg.h delete mode 100644 contrib/gnu-sort/lib/stat-macros.h delete mode 100644 contrib/gnu-sort/lib/stdio-safer.h delete mode 100644 contrib/gnu-sort/lib/strnlen.c delete mode 100644 contrib/gnu-sort/lib/timespec.h delete mode 100644 contrib/gnu-sort/lib/umaxtostr.c delete mode 100644 contrib/gnu-sort/lib/unistd-safer.h delete mode 100644 contrib/gnu-sort/lib/version-etc.c delete mode 100644 contrib/gnu-sort/lib/version-etc.h delete mode 100644 contrib/gnu-sort/lib/xalloc-die.c delete mode 100644 contrib/gnu-sort/lib/xalloc.h delete mode 100644 contrib/gnu-sort/lib/xmalloc.c delete mode 100644 contrib/gnu-sort/lib/xmemcoll.c delete mode 100644 contrib/gnu-sort/lib/xmemcoll.h delete mode 100644 contrib/gnu-sort/lib/xstrtol.c delete mode 100644 contrib/gnu-sort/lib/xstrtol.h delete mode 100644 contrib/gnu-sort/lib/xstrtoul.c delete mode 100644 contrib/gnu-sort/lib/xstrtoumax.c delete mode 100644 contrib/gnu-sort/man/sort.1 delete mode 100644 contrib/gnu-sort/src/sort.c delete mode 100644 contrib/gnu-sort/src/system.h create mode 100644 lib/__fpending.c create mode 100644 lib/__fpending.h create mode 100644 lib/argmatch.c create mode 100644 lib/argmatch.h create mode 100644 lib/closeout.c create mode 100644 lib/closeout.h create mode 100644 lib/dup-safer.c create mode 100644 lib/error.c create mode 100644 lib/error.h create mode 100644 lib/exit.h create mode 100644 lib/exitfail.c create mode 100644 lib/exitfail.h create mode 100644 lib/fopen-safer.c create mode 100644 lib/getopt.c create mode 100644 lib/getopt.h create mode 100644 lib/getopt1.c create mode 100644 lib/gettext.h create mode 100644 lib/hard-locale.c create mode 100644 lib/hard-locale.h create mode 100644 lib/human.c create mode 100644 lib/human.h create mode 100644 lib/inttostr.c create mode 100644 lib/inttostr.h create mode 100644 lib/long-options.c create mode 100644 lib/long-options.h create mode 100644 lib/memcoll.c create mode 100644 lib/memcoll.h create mode 100644 lib/pathmax.h create mode 100644 lib/physmem.c create mode 100644 lib/physmem.h create mode 100644 lib/posixver.c create mode 100644 lib/posixver.h create mode 100644 lib/quote.c create mode 100644 lib/quote.h create mode 100644 lib/quotearg.c create mode 100644 lib/quotearg.h create mode 100644 lib/stat-macros.h create mode 100644 lib/stdio-safer.h create mode 100644 lib/strnlen.c create mode 100644 lib/timespec.h create mode 100644 lib/umaxtostr.c create mode 100644 lib/unistd-safer.h create mode 100644 lib/version-etc.c create mode 100644 lib/version-etc.h create mode 100644 lib/xalloc-die.c create mode 100644 lib/xalloc.h create mode 100644 lib/xmalloc.c create mode 100644 lib/xmemcoll.c create mode 100644 lib/xmemcoll.h create mode 100644 lib/xstrtol.c create mode 100644 lib/xstrtol.h create mode 100644 lib/xstrtoul.c create mode 100644 lib/xstrtoumax.c create mode 100644 man/sort.1 create mode 100644 src/sort.c create mode 100644 src/system.h diff --git a/ABOUT-NLS b/ABOUT-NLS new file mode 100644 index 000000000000..8ffb46736877 --- /dev/null +++ b/ABOUT-NLS @@ -0,0 +1,716 @@ +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 December +2003. 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 am az be bg ca cs da de el en en_GB eo es + +-------------------------------------------+ + a2ps | [] [] [] [] | + aegis | () | + ant-phone | () | + anubis | | + ap-utils | | + bash | [] [] [] [] | + batchelor | | + bfd | [] [] | + binutils | [] [] | + bison | [] [] [] | + bluez-pin | [] [] | + clisp | | + clisp | [] [] [] | + coreutils | [] [] [] [] | + cpio | [] [] [] | + darkstat | [] () [] | + diffutils | [] [] [] [] [] [] [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] | + error | [] [] [] [] [] | + fetchmail | [] () [] [] [] [] | + fileutils | [] [] [] | + findutils | [] [] [] [] [] [] [] | + flex | [] [] [] [] | + fslint | | + gas | [] | + gawk | [] [] [] [] | + gbiff | [] | + gcal | [] | + gcc | [] [] | + gettext | [] [] [] [] [] | + gettext-examples | [] [] [] | + gettext-runtime | [] [] [] [] [] | + gettext-tools | [] [] [] | + gimp-print | [] [] [] [] [] | + gliv | | + glunarclock | [] [] | + gnubiff | [] | + gnucash | [] () [] [] | + gnucash-glossary | [] () [] | + gnupg | [] () [] [] [] [] | + gpe-aerial | [] | + gpe-beam | [] [] | + gpe-calendar | [] [] | + gpe-clock | [] [] | + gpe-conf | [] [] | + gpe-contacts | [] [] | + gpe-edit | [] | + gpe-go | [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] | + gpe-sketchbook | [] [] | + gpe-su | [] [] | + gpe-taskmanager | [] [] | + gpe-timesheet | [] | + gpe-today | [] [] | + gpe-todo | [] [] | + gphoto2 | [] [] [] [] | + gprof | [] [] [] | + gpsdrive | () () () | + gramadoir | [] | + grep | [] [] [] [] [] [] | + gretl | [] | + gtick | () | + hello | [] [] [] [] [] [] | + id-utils | [] [] | + indent | [] [] [] [] | + jpilot | [] [] [] | + jtag | | + jwhois | [] | + kbd | [] [] [] [] [] | + latrine | () | + ld | [] [] | + libc | [] [] [] [] [] [] | + libgpewidget | [] [] | + libiconv | [] [] [] [] [] | + lifelines | [] () | + lilypond | [] | + lingoteach | | + lingoteach_lessons | () () | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailutils | [] [] | + make | [] [] [] | + man-db | [] () [] [] () | + minicom | [] [] [] | + mysecretdiary | [] [] [] | + nano | [] () [] [] [] | + nano_1_0 | [] () [] [] [] | + opcodes | [] | + parted | [] [] [] [] [] | + ptx | [] [] [] [] [] | + python | | + radius | [] | + recode | [] [] [] [] [] [] [] | + rpm | [] [] | + screem | | + scrollkeeper | [] [] [] [] [] [] | + sed | [] [] [] [] [] | + sh-utils | [] [] [] | + shared-mime-info | | + sharutils | [] [] [] [] [] [] | + silky | () | + skencil | [] () [] | + sketch | [] () [] | + soundtracker | [] [] [] | + sp | [] | + tar | [] [] [] [] | + texinfo | [] [] [] | + textutils | [] [] [] [] | + tin | () () | + tuxpaint | [] [] [] [] [] [] [] | + util-linux | [] [] [] [] [] | + vorbis-tools | [] [] [] [] | + wastesedge | () | + wdiff | [] [] [] [] | + wget | [] [] [] [] [] [] | + xchat | [] [] [] [] | + xfree86_xkb_xml | [] | + xpad | [] | + +-------------------------------------------+ + am az be bg ca cs da de el en en_GB eo es + 0 0 8 3 37 38 56 73 15 1 5 12 64 + + et fa fi fr ga gl he hr hu id is it ja + +----------------------------------------+ + a2ps | [] [] [] () | + aegis | | + ant-phone | | + anubis | [] | + ap-utils | [] | + bash | [] [] | + batchelor | [] | + bfd | [] | + binutils | [] [] | + bison | [] [] [] [] | + bluez-pin | [] [] [] [] [] | + clisp | | + clisp | [] | + coreutils | [] [] [] [] [] [] | + cpio | [] [] [] | + darkstat | () [] [] [] | + diffutils | [] [] [] [] [] [] [] | + e2fsprogs | | + enscript | [] [] | + error | [] [] [] [] | + fetchmail | [] | + fileutils | [] [] [] [] [] [] | + findutils | [] [] [] [] [] [] [] [] [] [] | + flex | [] [] | + fslint | | + gas | [] | + gawk | [] [] [] | + gbiff | | + gcal | [] | + gcc | [] | + gettext | [] [] | + gettext-examples | [] [] | + gettext-runtime | [] [] [] [] | + gettext-tools | [] [] | + gimp-print | [] [] | + gliv | () | + glunarclock | [] [] [] [] | + gnubiff | | + gnucash | () [] | + gnucash-glossary | [] | + gnupg | [] [] [] [] [] [] [] | + gpe-aerial | [] | + gpe-beam | [] | + gpe-calendar | [] [] [] | + gpe-clock | [] | + gpe-conf | [] | + gpe-contacts | [] [] | + gpe-edit | [] [] | + gpe-go | [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] [] | + gpe-sketchbook | [] | + gpe-su | [] | + gpe-taskmanager | [] | + gpe-timesheet | [] [] [] | + gpe-today | [] [] | + gpe-todo | [] [] | + gphoto2 | [] [] [] | + gprof | [] [] | + gpsdrive | () [] () () | + gramadoir | [] | + grep | [] [] [] [] [] [] [] [] [] [] [] | + gretl | [] | + gtick | [] [] | + hello | [] [] [] [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] [] | + indent | [] [] [] [] [] [] [] [] [] | + jpilot | [] () | + jtag | | + jwhois | [] [] [] [] | + kbd | [] | + latrine | | + ld | [] | + libc | [] [] [] [] [] | + libgpewidget | [] [] [] [] | + libiconv | [] [] [] [] [] [] [] [] [] | + lifelines | () | + lilypond | [] | + lingoteach | [] [] | + lingoteach_lessons | | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailutils | | + make | [] [] [] [] [] | + man-db | () () | + minicom | [] [] [] [] | + mysecretdiary | [] [] | + nano | [] [] [] [] | + nano_1_0 | [] [] [] [] | + opcodes | [] | + parted | [] [] [] | + ptx | [] [] [] [] [] [] [] | + python | | + radius | [] | + recode | [] [] [] [] [] [] | + rpm | | + screem | | + scrollkeeper | [] | + sed | [] [] [] [] [] [] [] [] [] | + sh-utils | [] [] [] [] [] [] [] | + shared-mime-info | [] | + sharutils | [] [] [] [] [] | + silky | [] () | + skencil | [] | + sketch | [] | + soundtracker | [] [] [] [] | + sp | [] () | + tar | [] [] [] [] [] [] [] [] [] | + texinfo | [] [] [] [] | + textutils | [] [] [] [] [] | + tin | [] () | + tuxpaint | [] [] [] [] [] [] [] [] | + util-linux | [] [] [] [] () [] | + vorbis-tools | [] | + wastesedge | () | + wdiff | [] [] [] [] [] [] | + wget | [] [] [] [] [] [] [] | + xchat | [] [] [] | + xfree86_xkb_xml | | + xpad | [] | + +----------------------------------------+ + et fa fi fr ga gl he hr hu id is it ja + 21 1 25 86 24 24 8 10 38 31 1 23 32 + + ko lg lt lv ms nb nl nn no pl pt pt_BR ro + +-------------------------------------------+ + a2ps | () [] [] () () [] [] | + aegis | () () | + ant-phone | [] [] | + anubis | [] [] [] [] [] | + ap-utils | [] () [] | + bash | [] [] | + batchelor | [] | + bfd | [] | + binutils | | + bison | [] [] [] [] | + bluez-pin | [] [] [] | + clisp | | + clisp | [] | + coreutils | [] | + cpio | [] [] [] [] [] | + darkstat | [] [] [] [] | + diffutils | [] [] [] [] | + e2fsprogs | [] | + enscript | [] [] [] | + error | [] [] [] | + fetchmail | [] [] () | + fileutils | [] [] | + findutils | [] [] [] [] [] | + flex | [] [] [] [] | + fslint | [] [] | + gas | | + gawk | [] [] [] | + gbiff | [] [] | + gcal | | + gcc | | + gettext | [] [] [] | + gettext-examples | [] [] | + gettext-runtime | [] [] [] | + gettext-tools | [] [] [] | + gimp-print | [] | + gliv | [] [] [] | + glunarclock | [] [] [] | + gnubiff | | + gnucash | [] [] () | + gnucash-glossary | [] [] | + gnupg | [] | + gpe-aerial | [] [] [] | + gpe-beam | [] [] [] | + gpe-calendar | [] [] [] | + gpe-clock | [] [] [] | + gpe-conf | [] [] [] | + gpe-contacts | [] [] [] | + gpe-edit | [] [] [] | + gpe-go | [] [] | + gpe-login | [] [] [] | + gpe-ownerinfo | [] [] [] | + gpe-sketchbook | [] [] [] | + gpe-su | [] [] [] | + gpe-taskmanager | [] [] [] | + gpe-timesheet | [] [] [] | + gpe-today | [] [] [] | + gpe-todo | [] [] [] | + gphoto2 | [] | + gprof | [] [] | + gpsdrive | () () () [] | + gramadoir | [] | + grep | [] [] [] [] | + gretl | | + gtick | [] [] | + hello | [] [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] | + indent | [] [] [] | + jpilot | () () | + jtag | | + jwhois | [] [] [] [] | + kbd | [] [] [] | + latrine | [] | + ld | | + libc | [] [] [] [] [] | + libgpewidget | [] [] [] | + libiconv | [] [] [] [] | + lifelines | | + lilypond | | + lingoteach | | + lingoteach_lessons | | + lynx | [] [] | + m4 | [] [] [] [] | + mailutils | [] [] | + make | [] [] [] [] | + man-db | [] | + minicom | [] [] [] | + mysecretdiary | [] [] [] | + nano | [] [] [] [] | + nano_1_0 | [] [] [] [] [] | + opcodes | [] [] | + parted | [] [] [] [] | + ptx | [] [] [] [] [] [] [] | + python | | + radius | [] | + recode | [] [] [] | + rpm | [] [] | + screem | | + scrollkeeper | [] [] [] [] | + sed | [] [] [] | + sh-utils | [] | + shared-mime-info | [] | + sharutils | [] | + silky | | + skencil | [] [] | + sketch | [] [] | + soundtracker | | + sp | | + tar | [] [] [] [] [] [] | + texinfo | [] [] [] | + textutils | [] [] | + tin | | + tuxpaint | [] [] [] [] [] [] [] [] [] | + util-linux | [] [] | + vorbis-tools | [] [] | + wastesedge | | + wdiff | [] [] [] [] | + wget | [] [] | + xchat | [] [] | + xfree86_xkb_xml | [] | + xpad | [] [] | + +-------------------------------------------+ + ko lg lt lv ms nb nl nn no pl pt pt_BR ro + 12 0 1 2 12 10 60 4 4 38 25 35 76 + + ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW + +-------------------------------------------+ + a2ps | [] [] [] [] [] | 16 + aegis | () | 0 + ant-phone | | 2 + anubis | [] [] [] | 9 + ap-utils | () | 3 + bash | [] | 9 + batchelor | | 2 + bfd | [] [] | 6 + binutils | [] [] [] | 7 + bison | [] [] [] | 14 + bluez-pin | [] [] [] | 13 + clisp | | 0 + clisp | | 5 + coreutils | [] [] [] [] [] | 16 + cpio | [] [] [] | 14 + darkstat | [] [] [] () () | 12 + diffutils | [] [] [] [] | 22 + e2fsprogs | [] [] | 5 + enscript | [] [] [] | 12 + error | [] [] [] | 15 + fetchmail | [] [] [] | 11 + fileutils | [] [] [] [] [] [] | 17 + findutils | [] [] [] [] [] [] [] | 29 + flex | [] [] [] | 13 + fslint | | 2 + gas | [] | 3 + gawk | [] [] | 12 + gbiff | | 3 + gcal | [] [] | 4 + gcc | [] | 4 + gettext | [] [] [] [] [] [] | 16 + gettext-examples | [] [] [] [] | 11 + gettext-runtime | [] [] [] [] [] [] [] [] [] | 21 + gettext-tools | [] [] [] [] [] [] | 14 + gimp-print | [] [] | 10 + gliv | | 3 + glunarclock | [] [] [] [] | 13 + gnubiff | | 1 + gnucash | [] [] [] | 9 + gnucash-glossary | [] [] [] | 8 + gnupg | [] [] [] [] | 17 + gpe-aerial | [] [] | 7 + gpe-beam | [] [] | 8 + gpe-calendar | [] [] [] [] [] | 13 + gpe-clock | [] [] [] [] | 10 + gpe-conf | [] [] [] | 9 + gpe-contacts | [] [] [] [] | 11 + gpe-edit | [] [] [] [] [] [] | 12 + gpe-go | [] | 5 + gpe-login | [] [] [] [] [] [] | 13 + gpe-ownerinfo | [] [] [] [] [] | 13 + gpe-sketchbook | [] [] [] | 9 + gpe-su | [] [] [] [] | 10 + gpe-taskmanager | [] [] [] [] | 10 + gpe-timesheet | [] [] [] [] [] | 12 + gpe-today | [] [] [] [] [] [] | 13 + gpe-todo | [] [] [] [] [] | 12 + gphoto2 | [] [] [] | 11 + gprof | [] [] | 9 + gpsdrive | [] [] | 4 + gramadoir | | 3 + grep | [] [] [] [] [] | 26 + gretl | | 2 + gtick | [] | 5 + hello | [] [] [] [] [] | 33 + id-utils | [] [] [] | 12 + indent | [] [] [] [] [] | 21 + jpilot | [] [] [] [] [] | 9 + jtag | [] | 1 + jwhois | () () [] [] | 11 + kbd | [] [] | 11 + latrine | | 1 + ld | [] [] | 5 + libc | [] [] [] [] | 20 + libgpewidget | [] [] [] [] | 13 + libiconv | [] [] [] [] [] [] [] [] [] | 27 + lifelines | [] | 2 + lilypond | [] | 3 + lingoteach | | 2 + lingoteach_lessons | () | 0 + lynx | [] [] [] [] | 14 + m4 | [] [] [] | 15 + mailutils | [] | 5 + make | [] [] [] [] | 16 + man-db | [] | 5 + minicom | [] | 11 + mysecretdiary | [] [] | 10 + nano | [] [] [] [] [] | 17 + nano_1_0 | [] [] [] [] | 17 + opcodes | [] [] | 6 + parted | [] [] [] | 15 + ptx | [] [] [] | 22 + python | | 0 + radius | [] | 4 + recode | [] [] [] [] | 20 + rpm | [] [] [] | 7 + screem | [] [] | 2 + scrollkeeper | [] [] [] [] | 15 + sed | [] [] [] [] [] [] | 23 + sh-utils | [] [] [] | 14 + shared-mime-info | [] [] | 4 + sharutils | [] [] [] [] [] | 17 + silky | () | 2 + skencil | [] | 6 + sketch | [] | 6 + soundtracker | [] [] | 9 + sp | [] | 3 + tar | [] [] [] [] [] | 24 + texinfo | [] [] [] [] | 14 + textutils | [] [] [] [] [] | 16 + tin | | 1 + tuxpaint | [] [] [] [] [] | 29 + util-linux | [] [] [] | 15 + vorbis-tools | [] | 8 + wastesedge | | 0 + wdiff | [] [] [] [] | 18 + wget | [] [] [] [] [] [] [] [] | 23 + xchat | [] [] [] [] [] | 14 + xfree86_xkb_xml | [] [] [] [] [] [] | 8 + xpad | | 4 + +-------------------------------------------+ + 51 teams ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW + 120 domains 59 42 16 25 81 0 56 12 1 10 21 22 1260 + + 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 December 2003 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 +the 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/AUTHORS b/AUTHORS new file mode 100644 index 000000000000..4e8a5d49efaa --- /dev/null +++ b/AUTHORS @@ -0,0 +1,86 @@ +Here are the names of the programs in this package, +each followed by the name(s) of its author(s). + +basename: FIXME unknown +cat: Torbjorn Granlund and Richard M. Stallman +chgrp: David MacKenzie +chmod: David MacKenzie +chown: David MacKenzie +chroot: Roland McGrath +cksum: Q. Frank Xia +comm: Richard Stallman and David MacKenzie +cp: Torbjorn Granlund, David MacKenzie, and Jim Meyering +csplit: Stuart Kemp and David MacKenzie +cut: David Ihnat, David MacKenzie, and Jim Meyering +date: David MacKenzie +dd: Paul Rubin, David MacKenzie, and Stuart Kemp +df: Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert +dircolors: H. Peter Anvin +dirname: David MacKenzie and Jim Meyering +du: Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert +echo: FIXME unknown +env: Richard Mlynarik and David MacKenzie +expand: David MacKenzie +expr: Mike Parker +factor: Paul Rubin +false: no one +fmt: Ross Paterson +fold: David MacKenzie +head: David MacKenzie +hostid: Jim Meyering +hostname: Jim Meyering +id: Arnold Robbins and David MacKenzie +install: David MacKenzie +join: Mike Haertel +kill: Paul Eggert +link: Michael Stone +ln: Mike Parker and David MacKenzie +logname: FIXME: unknown +ls: Richard Stallman and David MacKenzie +md5sum: Ulrich Drepper and Scott Miller +mkdir: David MacKenzie +mkfifo: David MacKenzie +mknod: David MacKenzie +mv: Mike Parker, David MacKenzie, and Jim Meyering +nice: David MacKenzie +nl: Scott Bartram and David MacKenzie +od: Jim Meyering +paste: David M. Ihnat and David MacKenzie +pathchk: David MacKenzie and Jim Meyering +pinky: Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi +pr: Pete TerMaat and Roland Huebner +printenv: David MacKenzie and Richard Mlynarik +printf: David MacKenzie +ptx: François Pinard +pwd: Jim Meyering +rm: Paul Rubin, David MacKenzie, Richard Stallman, and Jim Meyering +rmdir: David MacKenzie +seq: Ulrich Drepper +shred: Colin Plumb +sleep: Jim Meyering and Paul Eggert +sort: Mike Haertel and Paul Eggert +split: Torbjorn Granlund and Richard M. Stallman +stat: Michael Meskes +stty: David MacKenzie +su: David MacKenzie +sum: Kayvan Aghaiepour and David MacKenzie +sync: Jim Meyering +tac: Jay Lepreau and David MacKenzie +tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering +tee: Mike Parker, Richard M. Stallman, and David MacKenzie +test: FIXME: ksb and mjb +touch: Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, and Randy Smith +tr: Jim Meyering +true: no one +tsort: Mark Kettenis +tty: David MacKenzie +uname: David MacKenzie +unexpand: David MacKenzie +uniq: Richard Stallman and David MacKenzie +unlink: Michael Stone +uptime: Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi +users: Joseph Arceneaux and David MacKenzie +wc: Paul Rubin and David MacKenzie +who: Joseph Arceneaux, David MacKenzie, and Michael Stone +whoami: Richard Mlynarik +yes: David MacKenzie diff --git a/COPYING b/COPYING new file mode 100644 index 000000000000..d60c31a97a54 --- /dev/null +++ b/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/ChangeLog b/ChangeLog new file mode 100644 index 000000000000..c0276553d191 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,7511 @@ +2004-08-11 Paul Eggert + + * tests/install/basic-1: Test for the -d regression. + +2004-08-11 Dmitry V. Levin + + * src/install.c (main): Fix -d regression introduced with + --target-directory support at 2004-06-25. + +2004-08-11 Paul Eggert + + * src/copy.c (copy_internal): When preserving links, unlink + a destination with link count greater than one. This is so + that commands like "cp -a" don't get confused when copying into + a destination that already contains many hard links. Problem + reported by Tim Waugh in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-08/msg00053.html + +2004-08-10 Paul Eggert + + Convert all files to UTF-8. + * tests/fmt/basic (8-bit-pfx): Use UTF-8, not Latin-1. + * tests/sort/Test.pm (16a): Likewise. + * tests/uniq/Test.pm (8): Likewise. + * tests/misc/printf-hex: Use ASCII, not Latin-1. + + * NEWS: Document "sort -o -" and "tee -" POSIX-conformance fixes. + * src/shred.c (usage): "-" is an operand, not an option. + * src/sort.c (die, xfopen, mergefps, first_same_file, merge): + A null file arg means standard output. + (main): "-o -" means to write to a file named "-", + not to standard output. + * src/tee.c (usage, tee): "tee -" writes to standard output, not + to a file named "-". + +2004-08-10 Dmitry V. Levin + + * src/install.c (change_timestamps): Fix int->bool conversion + bugs introduced on 2004-07-29. + +2004-08-09 Paul Eggert + + * src/shred.c (wipename): Work even if the directory is writeable + and not readable. Prefer write access, since this should work + better with fdatasync. + + * src/csplit.c (xalloc_die): New function. + (main): Remove now-obsolete initialization of xalloc_fail_func. + + * src/md5sum.c: Adjust to sha->sha1 renaming. + +2004-08-08 Dmitry V. Levin + + Minor code cleanup. + * src/readlink.c (canonicalize_fname): Remove unneeded proxy function. + (can_mode): Make variable local. + +2004-08-07 Paul Eggert + + * src/system.h (O_BINARY) [!O_BINARY && defined O_BINARY]: + Do not define, to avoid annoying compiler messages on QNX 6.3. + Problem reported by Johan in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-08/msg00050.html + +2004-08-04 Paul Eggert + + * src/system.h (PRIdMAX, PRIoMAX, PRIuMAX, PRIxMAX): + Define to a concatenation of string literals, not to an expression; + needed for concatenation contexts. + (INTMAX_MAX, INTMAX_MIN): New macros. + + * src/stat.c (print_stat): Don't assume st_ino / st_dev fits in + unsigned long; this isn't true for st_ino on Solaris 9. + +2004-08-03 Paul Eggert + + * src/uname.c: Do not depend on HAVE_SYSCTL when deciding + whether to include files. Include if + HAVE_SYS_PARAM_H (not HAVE_SYSCTL). + (main) [defined __POWERPC__]: Add a kludge to work around a + Mac OS X bug, so that uname -p defaults to "powerpc" if + sysctl ((int[]) {CTL_HW, HW_MACHINE_ARCH}, 2, buffer, &bufsize, 0, 0) + fails. Problem reported by Petter Reinholdtsen in: + http://lists.gnu.org/archive/html/bug-gnu-utils/2003-02/msg00201.html + + * src/uniq.c (hard_LC_COLLATE, ignore_case, different, check_file, + main): Use bool for booleans. + (writeline, check_file): Use uintmax_t for line counts. + (check_file): Check for and report line number overflow, + when that matters. + * src/wc.c (iswspace, wc): Use to_uchar rather than a cast. + (print_lines, print_words, print_chars, print_bytes, print_linelength, + have_read_stdin, wc, wc_file, main): + Use bool for booleans. + (exit_status): Remove. + (wc, wc_file): Return bool status. All callers changed. + * src/who.c (scan_entries): 0 -> STDIN_FILENO. + * src/whoami.c (main): Print uids using unsigned long int, not + unsigned int. + + * src/unexpand.c: Int cleanup and minor reorganization to be more + like src/expand.c. + Include quote.h, xstrndup.h. + (TAB_STOP_SENTINEL): Increase from INT_MAX to INTMAX_MAX. + (convert_entire_line, have_read_stdin, parse_tabstops, next_file, + unexpand, main): + Use bool for booleans. + (tab_size, tab_list, add_tabstop, validate_tabstops, unexpand): + Use uintmax_t for column counts. + (first_free_tab, validate_tabstops, unexpand): Use size_t for sizes. + (add_tabstop, parse_tabstops, main): Don't reserve UINTMAX_MAX + as a tab stop. + (parse_tabstops): Don't use ISBLANK on possibly-signed char. + Detect overflow in tab stop string. + (next_file, main): Use EXIT_FAILURE/EXIT_SUCCESS instead of 1/0. + (unexpand): Concatenate input files the same way expand does. + + * src/touch.c (no_create, use_ref, posix_date, amtime_now, + touch, main): Use bool for booleans. + (main): Avoid integer overflow when given more than INT_MAX + options. + * src/tsort.c (struct item, n_strings): Use size_t for sizes. + (have_read_stdin, count_items, scan_zeros, detect_loop, + recurse_tree, walk_tree, tsort, main): + Use bool for booleans. + (exit_status): Remove. + (tsort): Return a success flag instead of storing into a global. + (main): Use it. + * src/tty.c (silent, main): Use bool for booleans. + (main): 0 -> STDIN_FILENO. + * src/uname.c (print_element): Use bool for booleans. + + * src/test.c (TRUE, FALSE, SHELL_BOOLEAN, TRUTH_OR, TRUTH_AND): + Remove. All uses replaced by C99 boolean primitives. + (TEST_TRUE, TEST_FALSE): New constants, for readability. + (test_unop, binop, unary_operator, binary_operator, two_arguments, + three_arguments, posixtest, expr, term, and, or, is_int, age_of, + one_argument, main): Use bool for booleans. + (advance, unary_advance): Now inline procedures rather than a macros. + (is_int): Renamed from isint, to avoid namespace clash with ctype.h. + (term, and, or): When it's easy, loop instead of recursing. + (term): Avoid integer overflow if there are INT_MAX-3 args (!). + (binary_operator, unary_operator): Simplify by systematically rewriting + true==FOO to FOO (where FOO is a boolean). + (unary_operator): Don't consider a file to be a regular file + merely because its mode&S_IFMT is zero. Just use S_ISREG. + Remove unnecessary casts. Remove ifdefs for things like + S_ISSOCK that are no longer needed, since stat-macros.h always + defines them now. + + * src/tac-pipe.c (buf_init_from_stdin, find_bol, tac_mem): + Use bool for booleans. + (buf_init_from_stdin, buf_free, find_bol, print_line): + Use size_t for sizes. + * src/tac.c (separator_ends_record, tac_seekable, tac_file, + tac_stdin, tac_stdin_to_mem, main): Use bool for booleans. + (match_length, G_buffer_size, tac_seekable, main): Use size_t for sizes. + (tac_seekable): Use ptrdiff_t for pointer subtraction. + Report an error if the result is out of range. + (tac_seekable, main): Check for integer overflow in buffer size + calculations. + (main): Remove unnecessary casts. + + * src/su.c (run_shell): Pass a new n_additional_args arg, so that + the callee doesn't have to count 'em. All callers changed. + Don't allocate more space for the arg vector than we'll need. + Use memcpy to copy the args rather than rolling our own loop. + Use size_t for sizes. + (fast_startup, simulate_login, change_environment, log_su, + correct_password, restricted_shell, main): Use bool for booleans. + (longopts): Don't assume change_environment is an int. + Use NULL, not 0, for pointers. + (xsetenv): New function, replacing xputenv and concat. + All callers changed. + (elements): Remove; no longer needed. + (log_su, correct_passwd, main): Prefer !x to x==NULL. + (log_su): 2 -> STDERR_FILENO. + (modify_environment, main): Don't assume that getenv's returned value + has an indefinite lifetime. + (modify_environment): Allocate a larger environ. + (main): Remove an impossible 'case 0'; if it happens now, it'll + get diagnosed. Don't assume getpwnam results outlive endpwent. + Check for null or empty pw_name, pw_dir and for null pw_passwd. + + * src/stty.c (VA_START): Remove. All callers now use va_start. + (_POSIX_VDISABLE): Remove unnecessary cast. + (struct control_info, visible): Use cc_t for control chars. + (struct control_info): Use size_t for sizes. + (recover_mode, set_mode, display_speed, display_window_size, + valid_options, main, display_changed): + Use bool for booleans. + (integer_arg): Return unsigned long int, not long int. + Accept new max arg; all callers changed, to specify a maximum + value for integer parameters instead of silently overflowing. + (wrap): Do not overrun the stack buffer if the output contains + more than 1024 bytes. Instead, malloc a buffer. + (main): Remove a "what is this?!?" FIXME. Nobody knows what it is. + Remove unnecessary casts. + (set_control_char): Allow int values only up to cc_t range. + (screen_columns): Don't reject INT_MAX. + (display_changed, display_all, display_speed, recover_mode): + Don't assume cc_t fits in int. + + * src/remove.h: Add copyright notice. + (struct rm_options): Use bool for booleans. + * src/rmdir.c (empty_paths, ignore_fail_on_non_empty, verbose, + errno_rmdir_non_empty, remove_parents, main): Likewise. + * src/sum.c (have_read_stdin, bsd_sum_file, sysv_sum_file, + main): Likewise. + (main): Don't dump core if invoked with argv[0]==NULL. + * src/tee.c (tee, append, ignore_interrupts, main, tee): + Use bool for booleans. + (tee): Use ssize_t for read returns. + + * src/ptx.c: Add a FIXME mentioning that there are many + unchecked integer overflows in this file. + (gnu_extensions, auto_reference, input_reference, right_reference, + ignore_case, initialize_regex, fix_output_parameters, + output_one_roff_line, output_one_text_line, output_one_dumb_line, main): + Use bool for booleans. + (SKIP_SOMETHING, compare_words, digest_break_file, + find_occurs_in_text, fix_output_parameters): + Use to_uchar instead of a caset. + (print_field): Rewrite to avoid cast. + + * src/printf.c (posixly_correct): Use bool for booleans. + (verify, main): Use EXIT_FAILURE/EXIT_SUCCESS instead of 1/0. + (STRTOX): Rewrite to avoid casts. + (print_esc_char): Arg is char, not int. + * src/readlink.c (canonicalize): Remove. All uses now merely inspect + can_mode. + (no_newline, verbose): Use bool for booleans. + (can_mode): Now of type int; use -1 to denote otherwise-uninitialized. + * src/shred.c (struct Options, main): Use bool for booleans. + (isaac_seed_data, fillpattern, wipefile): Rewrite to avoid casts. + * src/split.c (cwrite, bytes_split, lines_split, line_bytes_split): + Use bool for booleans. + * src/stat.c (G_fail): Remove. + (print_statfs): Print various gotta-be-nonnegative values using + unsigned long int, not long int or int. + (do_statfs, do_stat): Return a boolean success flag. + (do_stat, main): Use bool for booleans. + + * src/pr.c: Add a FIXME mentioning that there are many + unchecked integer overflows in this file. + (TRUE, FALSE): Remove. All uses replaced by true and false. + (struct COLUMN, read_line, print_page, print_stored, open_file, + skip_to_page, init_fps, parallel_files, align_empty_cols, + empty_line, FF_only, explicit_columns, extremities, keep_FF, + print_a_FF, print_a_header, use_form_feed, have_read_stdin, + print_across_flag, storing_columns, balance_columns, + truncate_lines, join_lines, untabify_input, failed_opens, + numbered_lines, skip_count, use_esc_sequence, use_cntrl_prefix, + double_space, ignore_failed_opens, use_col_separator, + pad_vertically, last_line, main, init_parameters, skip_read, + read_line, print_stored): + Use bool for booleans. + (struct COLUMN, char_to_clump, store_char, print_char): + Use char for chars. + (clump_buff, print_clump): Use char[], not int[], for an array whose + elements are always chars. + (first_last_page, main, getoptarg, balance, add_line_number, + char_to_uclump): Remove unnecessary casts. + (init_parameters): Allocate chars, not ints, for clump_buff. + (print_char): Use to_uchar before invoking ISPRINT. + (char_to_clump): Convert to unsigned char before invoking ISPRINT. + + * src/nohup.c (main): Use bool for booleans. + * src/paste.c (paste_parallel, paste_serial, main): Likewise. + * src/pathchk.c (validate-path, main, portable_chars_only): Likewise. + (portable_chars_only): Use to_uchar rather than a cast. + * src/printenv.c (main): Use bool for booleans. + Do not assume that the environ has at most one matching entry + for each option (integer overflow was possible otherwise). + + * src/od.c (FMT_BYTES_ALLOCATED): Now an enum, not a decimal + constant. Do not assume PRIdMAX etc. are strings of length 3 or + less. + (struct tspec): Use it. fmt_string is now an array, not + a pointer, as there's little point to the indirection here. + (struct tspec, flag_dump_strings, + traditional, flag_pseudo_start, limit_bytes_to_format, + abbreviate_duplicate_blocks, have_read_stdin, simple_strtoul, + decode_one_format, open_next_file, check_and_close, + decode_format_string, skip, write_block, read_char, read_block, + parse_old_offset, dump, dump_strings, main): + Use bool for booleans. + (struct tspec): Use void *, not char *, for generic pointers. + (bytes_to_oct_digits, bytes_to_signed_dec_digits, + bytes_to_unsigned_dec_digits, bytes_to_hex_digits): + Use char, not unsigned int, since char suffices. + (print_s_char, print_char, print_s_short, print_short, + print_int, print_long, print_long_long, print_float, + print_double, print_long_double): Rewrite to avoid casts. + These now take void * arguments, instead of char *. + Use the same body for all functions, except for the choice + of type. Assume C89 to simplify handling of signed char. + (dump_hexl_mode_trailer, print_named_ascii, print_ascii): + Rewrite to avoid casts. + (print_named_ascii, print_ascii): Now takes void *, not char *. + (decode_one_format): Use int for printf field widths, not + unsigned int. Pass void * to subsidiary printers, + not char *. Simplify handling of floating-point formats + by factoring out common code dealing with precision and field width. + (decode_format_string): Avoid need for temporary copy of + each decoded struct tspec. + (get_lcm): Remove unnecessary cast. + (main): Fix bug where more than INT_MAX failed decodes were ignored. + +2004-08-02 Paul Eggert + + * src/nl.c (TRUE, FALSE): Remove; all uses changed to true, false. + (enum number_format): Remove. + (FORMAT_RIGHT_NOLZ, FORMAT_RIGHT_LZ, FORMAT_LEFT): Now strings, + not enum values. + (DEFAULT_SECTION_DELIMITERS): Now an array constant, not a macro. + (section_del): Now const. + (print_fmt): Remove. + (starting_line_number, page_incr, blank_join, line_no, + print_lineno, proc_text, main): + Use intmax_t for line numbers. + (reset_numbers, have_read_stdin, build_type_arg, nl_file, main): + Use bool for booleans. + (lineno_format): Now a string, not an enum value. + (build_print_fmt): Remove. All calls removed. This work is + now done within print_lineno. + (build_type_arg): Use size_t for sizes. + (print_lineno): Check for line number overflow. + (proc_text, main): Remove unnecessary cast. + + * src/ln.c (symbolic_link, interactive, remove_existing_files, + verbose, hard_dir_link, dereference_dest_dir_symlinks, + do_link, main): Use bool for booleans. + + * src/ls.c (struct fileinfo, file_interesting, + extract_dirs_from_files, color_symlink_as_referent, + FILE_OR_LINK_MODE, sort_reverse, print_owner, print_group, + numeric_ids, print_block_size, dired, print_with_color, + check_symlink_color, print_inode, recursive, immediate_dirs, + all_files, really_all_files, qmark_funny_chars, + print_dir_name, format_needs_stat, format_needs_type, visit_dir, + main, decode_switches, parse_ls_color, print_dir, file_interesting, + gobble_file, make_link_path, basename_is_dot_or_dotdot, + extract_dirs_from_files, print_long_format): + Use bool for booleans. + (dir_defaulted): Remove; no longer needed. + (main): Use int to count files, since it suffices for argv. + Rewrite to avoid need for dir_defaulted. + (main, print_dir, gobble_file, get_link_name, + xstrcoll): + Set exit status to EXIT_SUCCES/EXIT_FAILURE rather than 0/1. + (decode_switches): Put back check for ws.ws_col <= SIZE_MAX. + Remove unnecessary cast to int. Use int instead of unsigned + int to count from 0 to 1. + (get_funky_string, print_type_indicator): Use char for bytes, not int. + (make_link_path): Use NULL for null pointers. + (quote_name): Use to_uchar instead of cast. + + * src/id.c (use_name, main, print_user, xgetgroups, print_group_list, + print_full_info): Use bool for booleans. + (problems): Remove, replacing with.... + (ok): New var (inverted from old sense). + (print_user, print_group, print_full_info): + Print uids/gids with %lu, not %u. + (xgetgroups): Don't run out of memory if getgroups or getugroups + returns -1. + * src/setuidgid.c (main): Print uids/gids with %lu, not %ld. + + * src/factor.c (wheel_tab): Use unsigned char instead of unsigned + int, since it suffices. + (factor, print_factors): Use size_t for sizes. + (print_factors, do_stdin, main): Use bool for booleans. + * src/fold.c (TAB_WIDTH): New macro; use it instead of "8". + (fold_file, main): Use bool for booleans. + (fold_file, main): Use size_t for sizes. + (main): Allow -w options up to SIZE_MAX - TAB_WIDTH - 1, instead + of prohibiting widths greater than INT_MAX. + * src/head.c (presume_input_pipe, print_headers, have_read_stdin, + write_header, elide_tail_bytes_pipe, elide_tail_bytes_file, + elide_tail_lines_pipe, elide_tail_lines_seekable, + elide_tail_lines_file, head_bytes, head_lines, head, head_file, + string_to_integer, main): + Use bool for booleans. + (main): Rewrite to avoid cast. + + * src/csplit.c (struct line): Use size_t for sizes. + (main): Remove unnecessary cast. + * src/cut.c (cut_fields): Use to_uchar rather than a cast. + * src/cut.c (cut_file, main): Use bool for booleans. + * src/date.c (show_date, rfc_format, batch_convert, main): Likewise. + * src/env.c (main): Likewise. + * src/expr.c (nextarg): Likewise. + * src/env.c (main): Remove unused and nonstandard envp arg. + + * src/fmt.c (COST, MAXWORDS): Add a comment describing some of + fmt's arbitrary limits. + (TRUE, FALSE): Remove; all uses changed to (true, false). + (main): Use bool for booleans. + Limit maximum width to MAXCHARS / 2. Use xstrtoul, not xstrtol, + to parse width. + (copy_rest): Remove unnecessary cast. + (get_prefix): Rewrite to avoid cast. + (check_punctuation): Use char *, not unsigned char *; C89 requires + this. Avoid off-by-one buffer read overrun when line is empty. + (flush_paragraph): Don't assume wptr-parabuf is <= INT_MAX. + Remove unnecessary casts. + * tests/fmt/basic (wide-1, wide-2, bad-suffix): Adjust to above + changes. + + * src/expand.c (convert_entire_line, have_read_stdin, parse_tabstops, + next_file, expand, main): + Use bool for booleans. + (tab_size, tab_list, add_tabstop, parse_tabstops, validate_tabstops, + expand, main): + Use uintmax_t for column counts. + (add_tabstop): Don't reserve -1 (now UINTMAX_MAX) as a special value. + All callers changed. + (parse_tabstops): Don't pass a negative char to isblank. + Avoid memory leak with large tab stops. + (validate_tabstops, expand): Don't assume number of tab stops is + <= INT_MAX. + (next_file, main): Use EXIT_SUCCESS/EXIT_FAILURE rather than 0/1 when + storing values into exit_status. + (expand): Use same pattern as unexpand for reading chars. + Report an error when input line is too long, instead of silently + screwing up. Do not mishandle tab stops when backspacing left + over start of line. + + * src/dircolors.c (have_read_stdin, append_quoted, + dc_parse_stream, dc_parse_file, main): Use bool for booleans. + (dc_parse_stream): Use enum for state, rather than int. + Use ssize_t to store getline result. + + * src/dd.c (translation_needed, parse_integer, scanargs, + apply_translations, char_is_saved, swab_buffer, skip_via_lseek): + Use bool for booleans. + (translate_buffer): Use to_uchar rather than a cast. + (swab_buffer, copy_simple, copy_with_unblock): + Use size_t for sizes. + + * src/seq.c (equal_width, valid_format, main): Use bool for booleans. + * src/sleep.c (apply_suffix): Likewise. + * src/tail.c (struct File_spec, reopen_inaccessible_files, count_lines, + forever, from_start, print_headers, have_read_stdin, valid_file_spec, + write_header, file_lines, pipe_lines, pipe_bytes, recheck, + tail_forever, tail_bytes, tail_lines, tail, tail_file, + parse_obsolescent_option, parse_options, main): Likewise. + * src/sleep.c (apply_suffix): Invert sense of result. + Use int (not unsigned int) for multiplier, as this generates better + code with some compilers. Simplify code a bit. + * src/tail.c (struct File_spec, max_n_unchanged_stats_between_opens, + parse_options): Use uintmax_t, not unsigned int or unsigned long int, + for state counters. + (tail_bytes, tail_lines): Redo test of return value (-1, 0, 1) to + make it a bit clearer. + + * src/hostname.c: Include "xgethostname.h". + (xgethostname): Remove decl; xgethostname.h has it. + (sethostname) [!defined(HAVE_SETHOSTNAME) && defined(HAVE_SYSINFO) + && defined (HAVE_SYS_SYSTEMINFO_H) && defined(HAVE_LIMITS_H)]: Use + prototypes rather than K&R form. Assume any negative value from + sysinfo denotes failure, not just -1. + (main): Simplify use of sethostname. + + * src/pinky.c (include_idle, include_heading, include_fullname, + include_project, include_plan, include_home_and_shell, do_short_format, + include_where, main): Use bool for booleans. + (count_ampersands, create_fullname, scan_entries, short_pinky): + Use size_t for sizes. + (create_fullname): Check for overflow in size calculations. + (idle_string): Don't assume that the number of idle days + is less than 10**8 and/or INT_MAX/(24*60*60). + (main): No need to pass a non-NULL last arg to getopt_long. + * src/uptime.c (print_uptime, uptime): Use size_t for sizes. + (print_uptime): Remove unused local variable. + (main): No need to pass a non-NULL last arg to getopt_long. + * src/users.c (list_entries_users, users): Use size_t for sizes. + (list_entries_users): Use char for bytes. + (main): No need to pass a non-NULL last arg to getopt_long. + * src/who.c (do_lookup, short_list, short_output, include_idle, + include_heading, include_mesg, include_exit, need_boottime, + need_deadprocs, need_login, need_initspawn, need_clockchange, + need_runlevel, need_users, my_line_only, main): Use bool for booleans. + (print_runlevel): Use unsigned char for bytes. + (list_entries_who, scan_entries, who): Use size_t for sizes. + (main): No need to pass a non-NULL last arg to getopt_long. + + * src/install.c (isdir): Remove decl. + (install_file_to_path): Rely on make_path to fail if the destination + is not a directory, by passing preserve_existing==true to it. + Hence we no longer need to call isdir. + Free dest_dir immediately when it's no longer needed, rather than + waiting until the end of the function. + (copy_file): Don't bother calling isdir, as copy will do the + right thing if the destination is a directory. + + * src/du.c (fts_debug, opt_all, apparent_size, opt_count_all, + print_grand_total, opt_separate_dirs, hash_ins, process_file, main): + Use bool for booleans. + (max_depth): Now size_t, not int, to avoid an arbitrary limit + of INT_MAX on depth. + (G_fail): Remove: no longer needed, now that the relevant + functions return bool. + (process_file): Use return value to signal success rather than + setting a global. Remove first_call static var; not needed, since + we can look at n_alloc. Use size_t for depths. Remove FIXME + about size_t casts, as it's now fixed. Use xnrealloc rather + than the obsolescent XREALLOC. Don't bother to check whether + reallocation is needed unless level > prev_level. + (du_files): Invert sense of result, for consistency with + other coreutils code. All callers changed. + (main): Allow --max-depth values up to SIZE_MAX. + + * src/df.c (inode_format, show_all_fs, show_local_fs, + show_listed_fs, posix_format, require_sync, print_type, + selected_fstype, excluded_fstype, show_dev, show_point, main): + Use bool for booleans. + (df_readable, show_dev): Use UINTMAX_MAX instead of -1. + (show_dev, show_point, main): + Use EXIT_SUCCESS/EXIT_FAILURE instead of 0/1. + Don't assume disk name lengths are <= INT_MAX. + Rewrite pct calculation to avoid cast. + (show_point): Don't assume resolved length is <= SSIZE_MAX. + + * src/cut.c (hash_int) [!defined UINTPTR_MAX]: Use size_t + instead of uintptr_t. + * src/shred.c (UINT_MAX_32_BITS): Remove. + (word32): Remove. All uses changed to uint32_t. + (isaac_seed_data): Remove unnecessary cast. + * src/system.h (ptr_align): Use size_t; in practice, this is just as + good as uintptr_t in checking for alignments, and has fewer + configuration hassles. + + * src/Makefile.am (localedir.h): Make it readonly; this + undoes part of the 2004-07-27 patch. + +2004-07-30 Paul Eggert + + * src/sort.c (UCHAR): Remove; all uses changed to to_uchar. + (IS_THOUSANDS_SEP): Use bool when appropriate. + (numcompare, main): Use char, not int, when the value is always a char. + (numcompare): Remove "register"; compilers are smart enough these days. + * src/system.h (errno, CHAR_BIT): Remove decls; + no longer needed now we assume C89 or better. + Include before , as it's the + Autoconf-recommended pattern. + (to_uchar): New inline function, moved here from tr.c. + Use full names for int types, e.g. "long int" rather than "long". + * src/tr.c (to_uchar): Remove; now in system.h. + (is_char_class_member): Use bool when appropriate. + + * src/mkdir.c (create_parents, main): Use bool when appropriate. + (main): Use EXIT_SUCCESS/EXIT_FAILURE instead of 0/1. + +2004-07-29 Paul Eggert + + * src/mkfifo.c (main): Use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1. + + * src/chmod.c (recurse, force_silent, process_file, process_files, + main): Use bool when appropriate. + * src/cksum.c (cksum, main): Likewise. + * src/comm.c (hard_LC_COLLATE, only_file_1, only_file_2, both, + compare_files, main): Likewise. + + * src/copy.h (struct cp_options): Likewise. + * src/copy.c (copy_internal, is_ancestor, copy_dir, copy_reg, + same_file_ok, seen_file, copy_internal, valid_options, copy): Likewise. + * src/cp-hash.h (remember_created): Likewise. + * src/cp-hash.c (remember_created): Likewise. + * src/cp.c (struct dir_attr, flag_path, remove_trailing_slashes, + re_protect, make_path_private, target_directory_operand, do_copy, + cp_option_init, decode_preserve_arg, main): Likewise. + * src/install.c (isdir, change_timestamps, change_attributes, + copy_file, install_file_to_path, install_file_in_dir, + install_file_in_file, strip_files, dir_arg, cp_option_init, main, + change_attributes, change_timestamps): Likewise. + * src/mv.c (remove_trailing_slashes, rm_option_init, + cp_option_init, do_move, movefile, main): Likewise. + * src/remove.c (right_justify), full_filename_, AD_pop_and_chdir, + AD_push, prompt, remove_dir): Likewise. + * src/rm.c (rm_option_init, main): Likewise. + + * src/remove.c (top_dir, pop_dir, full_filename_): + Use size_t for sizes. + * src/cp.c (target_directory_operand): Do not clear *NEW_DST if stat + succeeds. It's not necessary in that case, as *NEW_DST is always + false already. + (do_copy): Rewrite slightly to avoid need for "unreachable" comment. + (main): Use EXIT_SUCCESS, EXIT_FAILURE instead of 0, 1. + * src/rm.c (main): Likewise. + + md5sum, sha1sum integer cleanups. + + * src/checksum.h: Don't include config.h, sys/types.h, stdio.h: + not needed. + (ALG_UNSPECIFIED): Remove. + (ALG_MDT): Don't make it equal to CHAR_MAX + 1; this isn't necessary. + * src/md5.c: Don't include any files other than checksum.h. + * src/sha1sum.c: Likewise. + * src/md5sum.c (OPENOPTS, have_read_stdin, status_only, warn, + bsd_split_3, split_3, hex_digits, digest_file, digest_check, main): + Use bool when appropriate. + (digest_check): Increase limit of number of input lines to + UINTMAX_MAX from INT_MAX. Diagnose any overflows of this counter. + Use ngettext instead of hard-to-i18nize hardcoded stuff for plurals. + +2004-07-28 Paul Eggert + + * src/cat.c (exit_status): Remove. Now done by passing a boolean + 'ok' flag around. + (simple_cat, cat): Return true if successful. All callers changed. + (simple_cat, cat, main): Use bool for booleans. + (simple_cat): Use size_t for sizes. + (cat, main): Use the same names for parameters that we use for + long options, to avoid confusion. This inverts the sense of the + show_tabs (formerly output_tabs) and number_nonblank + (formerly numbers_at_empty_lines) variables. + (main): Don't mess up (due to integer overflow) if we are given + INT_MAX - INT_MIN + 1 options. + [O_BINARY]: Don't invoke isatty unless the other options require it. + (main): When deciding whether to use simple_cat, don't worry + about binary option; it's irrelevant. + + * src/dcgen: Remove comments, trailing white space, and empty + lines from the output strings, to save space. + Use a narrower type like 'unsigned char' for line lengths, if + that will do. + Make the output variables static, not extern. + + * src/chgrp.c (parse_group): Require base 10 when parsing + groups as integers. + (main): int -> bool when appropriate. + * src/chown.c (main): Likewise. + * src/chown-core.c: Include inttostr.h. + (UINT_MAX_DECIMAL_DIGITS, uint_to_string): Remove. + (gid_to_name, uid_to_name): Use imaxtostr/umaxtostr + instead of uint_to_string). + (describe_change): Instead of an int flag, use a char * + auxiliary; this avoids the need for casts. + Assume free (NULL) works. + (change_file_owner): Return true/false, not 0/-1, since + we don't set errno. All callers changed. + Use bool when appropriate. + (chown_files): Likewise. + * src/chown-core.h (chown_files): Likewise. + + * tests/chown/basic: Test for proper handling of uids like + "010", which must be parsed as decimal. + + * tests/misc/pwd: Don't assume that Perl's getpwd agrees with our + pwd when there are multiple names for the working directory + (which can happen with an automounter, sigh). + + * src/Makefile.am ($(SCRIPTS)): Don't depend on Makefile; + this causes Solaris 8 'make' to refuse to build "groups". + (localedir.h): Don't depend on Makefile: this causes Solaris + 8 'make' to build localedir.h unnecessarily. The dependence + on Makefile is ineffective anyway, since $(localedir) might + change even if Makefile hasn't. + + * src/remove.c (remove_dir): If we can't save the state of the + working directory, pretend we started from "/", not ".". + This avoids a bug on hosts like Solaris that don't let you + remove the working directory. + +2004-07-27 Paul Eggert + + * src/printf.c (strtiomax, strtoumax): Declare if not already + declared: this fixes a portability bug with Solaris 8 + GCC. + (STRTOX): Parenthesize use of macro arg as expression. + (vstrtoimax, vstrtoumax, vstrtold): Remove now-unnecessary + parentheses. + * configure.ac: Check for declaration of strtoumax, for + src/printf.c. + + * src/Makefile.am (cp_LDADD, ginstall_LDADD, mv_LDADD, + pathchk_LDADD, rm_LDADD, test_LDADD): New vars, for eaccess. + + * tests/readlink/can-e: Don't assume that we can remove the + working directory: this isn't possible under Solaris 8, say. + * tests/readlink/can-f: Likewise. + * tests/readlink/can-m: Likewise. + + * src/copy.c (copy_internal): find_backup_file_name no longer + returns NULL, so don't bother to check for this. + * src/cp.c (do_copy): Likewise. + * src/ln.c (do_link): Likewise. + +2004-07-25 Paul Eggert + + * src/nice.c (GET_NICE_VALUE): Renamed from GET_PRIORITY. + All uses changed. + (NZERO): New macro, if system doesn't define it already. + (usage): Distinguish priorities from nice values. + Don't assume NZERO is 20. + (main): Use bool instead of int where appropriate. + If user specifies an adjustment out of range, always truncate it + to an inrange value instead of sometimes giving an error message + and sometimes not. + Do not assume that -1 is an error return from "nice" or + "getpriority", as it might be the current nice value minus NZERO. + If nice/setpriority fails with errno == EPERM, go ahead and run + the command anyway; POSIX requires this. + + * src/pathchk.c: Include euidaccess.h. + (dir_ok): Use euidaccess, not access. + * src/test.c (R_OK, W_OK, X_OK, FOK): Remove; system.h defines them. + (eaccess): Remove. All users changed to use euidaccess instead. + +2004-07-24 Paul Eggert + + * src/uptime.c (print_uptime) [defined BOOT_MSG]: + Don't assume ut_line is null-terminated. + * src/who.c (print_line): New arguments USERLEN and LINELEN, + since USER and LINE might not be null terminated. All callers + changed. + +2004-07-23 Paul Eggert + + Fix bug with "tail -f" reported by Rob Holland in + . + Also, remove the undocumented and unsupported-since-2000 + --max-consecutive-size-changes options. Fix another related bug: + "tail" got confused if stdin, stdout, or stderr were closed. + Also, use output buffering even with "tail -f". + + * NEWS: Document this, plus yesterday's patch. + * doc/coreutils.texi (tail invocation): "size has remained the same" + -> "file has not changed", which is more accurate for fifos. + * src/tail.c: Include fcntl-safer.h. + (COPY_TO_EOF): Set to UINTMAX_MAX, not OFF_T_MAX (which was wrong). + (COPY_A_BUFFER): New macro. + (struct File_spec): New members mtime, mode, blocking. + Remove member n_consecutive_size_changes. + (DEFAULT_MAX_N_CONSECUTIVE_SIZE_CHANGES, + max_n_consecutive_size_changes_between_opens, + MAX_CONSECUTIVE_SIZE_CHANGES_OPTION): Remove. + (long_options, tail_forever, parse_options): + Remove (non-)support for --max-consecutive-size-changes. + (record_open_fd): New function. + (recheck, tail_file): Use it. Don't assume that stdin is open. + (dump_remainder): Add support for new COPY_A_BUFFER special value. + Treat errno==EAGAIN like EOF, since it might be a nonblocking read. + (recheck): New arg BLOCKING, specifying whether to use blocking reads. + All uses changed. + (n_live_files): Remove, replacing with... + (any_live_files): New function. All uses changed. + (tail_forever): Use nonblocking I/O unless we know that blocking I/O + is safe; this avoids some hangs when reading from a fifo. + Avoid invoking fstat or sleep when using blocking I/O. + Do not check for changes to size if the file is not a regular file, + as the size is undefined in that case. + Check for changes to mtime or mode, too; this works for non-regular + files. + (tail_forever, main): Redo fflush strategy to work even when input + is nonblocking. Don't use unbuffered output; just flush when needed. + +2004-07-22 Paul Eggert + + * src/tail.c (main): Ignore -f if no file operand is specified + and standard input is a pipe. + * doc/coreutils.texi (tail invocation): Do not ignore -f for + all pipes, just for when standard input is a pipe and no + file operand is specified. + * tests/tail/Test.pm: Reinstate f-1 test, since we now pass. + Add a new commented-out f-2 test, which we still fail. + (test_vector): All f-* tests are special cases, not just f-1. + +2004-07-12 Paul Eggert + + * src/uptime.c: Include c-strtod.h. + (print_uptime): Use c_strtod instead of setlocale and sscanf. + Use long int rather than int to count days (for 64-bit hosts), + and check for arithmetic overflow when converting double to time_t. + +2004-07-11 Paul Eggert + + * src/printf.c (vstrtold): Renamed from vstrtod. + Now returns long double. All uses changed. + (print_direc): Use "L" length modifier when printing floating point + numbers, since we're now printing long double. + +2004-07-06 Paul Eggert + + * Version 5.3.0. + + printf cleanup, to avoid undefined behavior, to add support for + formats that Bash supports, and to support wide integers like + Bash does. + + * NEWS: Document this. + * src/printf.c (UNSPECIFIED): Remove. All uses now replaced by + booleans, so that we don't reserve any values for precision or + width (like Bash). + (STRTOX): Use prototype, not K&R-style definition. + (vstrtoimax): Renamed from xstrtol (to avoid confusion with xstrtol + in ../lib), with type change to intmax_t. + All uses changed. + (vstrtoumax): Renamed from xstrtoul, with type change to uintmax_t. + All uses changed. + (vstrtod): Renamed from xstrtod. All uses changed. + (print_direc): Use boolean arg instead of special value to indicate + a missing precision or width. LENGTH no longer includes + length modifiers or conversion character. New arg CONVERSION + now specifies conversion character. + Use intmax_t-width formatting for integers (like Bash). + Add support for C99 %a, %A, %F (like Bash). + Add support for field width with %c (POSIX requires this). + Add a FIXME for lack of support for field width and precision + for %b. + Add support for '\'', '0' flags. + Check for invalid combinations of flags, field width, precision, + and conversion, to prevent use of undefined behavior. + Allow multiple length modifiers, for formats like "%lld" (like Bash). + Add support for C99 'j', 't', 'z' length modifiers (like Bash). + In error message, output entire invalid conversion specification, + instead of merely outputting % followed by the conversion char. + * tests/misc/printf: Add tests for the above. + +2004-04-03 Dmitry V. Levin + + Change "readlink -f" to be more compatible with prior implementations. + Add more canonicalize options, -e and -m. + Add comprehensive tests for all readlink modes. + + * m4/canonicalize.m4 (AC_FUNC_CANONICALIZE_FILE_NAME): + Do not add canonicalize.c here. + + * src/readlink.c (longopts): Add new options. + (usage): Document them. + (canonicalize_fname): New proxy function. + (main): Handle new options. + * doc/coreutils.texi (readlink invocation): Document new + "readlink -f" behaviour and new canonicalize options, -e and -m. + + * configure.ac (AC_CONFIG_FILES): Add tests/readlink/Makefile. + * tests/Makefile.am (SUBDIRS): Add readlink. + * tests/readlink/Makefile.am: New file. + * tests/readlink/{rl-1,can-e,can-f,can-m}: New readlink tests. + * tests/misc/Makefile.am (TESTS): Remove basic readlink test. + * tests/misc/readlink: Remove file. + +2004-07-04 Jim Meyering + + * src/copy.c (copy_internal): Add a FIXME comment. + +2004-07-02 Paul Eggert + + * src/copy.c (copy_dir): Assume path_concat returns non-NULL. + * src/cp.c (do_copy): Likewise. + * src/mv.c (movefile): Likewise. + + * src/cp.c (make_path_private): 2nd arg is now size_t, not int, + to avoid problem when path_concat dir name is longer than 2 GiB (!). + + * src/nohup.c (main): Don't pass NULL first argument to path_concat. + This cleans up the semantics a bit, as we no longer try to open the + same file twice. + +2004-07-01 Paul Eggert + + * NEWS: Add short names -t and -T for --target-directory + and --no-target-directory options, respectively. + + * src/cp.c (NO_TARGET_DIRECTORY_OPTION, TARGET_DIRECTORY_OPTION): + Remove. All uses changed to 'T' and 't', respectively. + * src/install.c, src/ln.c, src/mv.c: Likewise. + + * src/cp.c (long_opts, usage, do_copy, main): Add -t and -T as + aliases for --target-directory and --no-target-directory, + respectively. + * src/install.c (long_options, main, usage): Likewise. + * src/ln.c, src/mv.c: Likewise. + +2004-07-01 Jim Meyering + + * Makefile.maint (sc_file_system): New target. + (syntax-check-rules): Add it. + .x-sc_file_system: New file. + * Makefile.am (EXTRA_DIST): Add it. + + * man/sync.x: Use "file system" rather than "filesystem". + * man/stat.x, man/df.x: Likewise. + +2004-06-30 Paul Eggert + + * src/df.c (usage, main): Output "file system" rather than + "filesystem". + * src/du.c (usage): Likewise. + * src/shred.c (usage): Likewise. + * src/stat.c (usage): Likewise. + * src/stat.c (long_options, usage): Rename "--filesystem" to + "--file-system". But keep the old name around, for compatibility + reasons. + +2004-06-29 Paul Eggert + + Add support for --no-target-directory option. + + * NEWS: Document it. + * doc/coreutils.texi (Common options, Target directory, cp + invocation, install invocation, mv invocation, ln invocation): + Likewise. + (link invocation): Explain how to rewrite link using ln now + that we have --no-target-directory. + (ln invocation): Explain that --no-target-directory subsumes + --no-dereference. + (unlink invocation): Modify wording to match new wording in + link invocation. + + * src/cp.c (NO_TARGET_DIRECTORY_OPTION): New constant. + (long_opts, usage, do_copy, main): Add support for + --no-target-directory, + * src/install.c (NO_TARGET_DIRECTORY_OPTION, long_options, main, + usage): Likewise. + * src/ln.c (NO_TARGET_DIRECTORY_OPTION, long_options, usage, + main): Likewise. + * src/mv.c (NO_TARGET_DIRECTORY_OPTION, long_options, usage, + main): Likewise. + * src/mv.c (enum): Sort values. + +2004-06-29 Jim Meyering + + Don't let verbose-mode output from a subshell obscure actual differences. + * tests/rm/inaccessible: Turn off command-echoing just before + invoking subshell, then turn it back on if VERBOSE=yes afterward. + +2004-06-25 Paul Eggert + + Add support for 'install --target-directory', an option + that has been documented for years but not implemented (!). + * doc/coreutils.texi (install invocation): Document + --target-directory in synopsis, too. + * src/install.c (TARGET_DIRECTORY_OPTION): New var. + (long_options, main, usage): Add --target-directory. + (target_directory_operand): New function, stolen from mv.c. + (main): Use it. Check for -d and --target-directory. + Alter wording of diagnostics to match other programs. + +2004-06-28 Jim Meyering + + * src/cp.c (usage): Fix copy+paste error in description of + --target-directory: s/move/copy/. From Paul Jarc. + +2004-06-27 Paul Eggert + + Use more-consistent rules among cp, ln, and mv when dealing with + last operands that are (or look like) directories. + + * src/cp.c (target_directory_operand): New, nearly-common function, + It reports an error if the destination appears to be a directory + (e.g., because it has a trailing slash) but is not. + * src/ln.c, src/mv.c: Likewise. + * src/cp.c (do_copy): Use it. + * src/ln.c (main): Likewise. + * src/mv.c (main): Likewise. + + * src/cp.c (do_copy): Don't assume argc is positive. + Don't bother to lstat dest, since copy() will do that for us. + Use "const" to avoid the need for cast. + + * src/cp.c (do_copy): Don't output a usage message because of file + problems (e.g., an operand is not a directory). Use it only for + syntax. Standardize on "target %s is not a directory" for the + diagnostic. + * src/ln.c (main): Likewise. + * src/mv.c (main): Likewise. + + * src/cp.c (do_copy): Remove test for trailing slash, since + target_directory_operand now does this. + * src/ln.c (main): Likewise. + * src/mv.c (movefile): Likewise. + + * src/cp.c (main): Reject multiple target directories. + Check whether a specified target is a directory when parsing the + options, using stat. This gives more-accurate diagnostics. + * src/ln.c (main): Likewise. + + * src/ln.c (isdir): Remove decl; no longer needed. + * src/mv.c (isdir, lstat): Likewise. + + * src/ln.c (do_link): New arg dest_is_dir. All uses changed. + Don't check the destination ourself; rely on dest_is_dir. + This way we can avoid lstatting the destination in the + usual case, and in the worst case we lstat 1, not 3 times. + Don't bother to unlink unless link failed; this saves a syscall. + Remove unnecessary backup_succeeded flag; + it was identical to "dest_backup != NULL". + + * src/ln.c (main): Use int to count to argc, not unsigned int. + This handles negative operand counts. + * src/mv.c (main): Likewise. + + * src/mv.c (do_move): Don't call hash_init; expect the caller to + do it, for consistency with cp.c and ln.c. All callers changed. + (movefile): dest_is_dir parameter is now bool, not int. + (main): Standardize on "missing destination file operand after %s" + for the diagnostic, for consistency with cp.c. + + * tests/mv/diag: Don't assume "mv --target=nonexistentdir" + will complain about the arg count. + Adjust to new (briefer) diagnostics. + * tests/cp/fail-perm: Add a test to verify that we get the new + diagnostic when failing to copy through a symlink-to-inaccessible-dir. + +2004-06-27 Paul Eggert + + Fix a bug: formerly, if d/x was a directory and x a file, "ln x + d/" incorrectly created a link d/x/x. It also saves some system + calls. + + * NEWS: Document the fix. + + * src/ln.c (main): Don't append basename to dest if this + results in an existing directory name. + * tests/ln/misc: See whether a trailing slash is followed too far. + +2004-06-26 Jim Meyering + + * src/printf.c (main): When given no arguments, print the standard + "missing operand\nTry printf --help..." message -- to be consistent. + +2004-06-26 Jim Meyering + + * src/mknod.c (main): Add \n at the end of message output via fprintf. + +2004-06-25 Jim Meyering + + * tests/ln/misc: Add test for ln subscript error. + +2004-06-23 Paul Eggert + + * src/ln.c (do_link): Remove unnecessary call to lstat. + (main): Avoid subscript error when the destination is "". + +2004-06-23 Jim Meyering + + * tests/*: Replace all occurrences of `(exit N); exit' with + `(exit N); exit N'. Otherwise, those many tests could exit with + improper exit status when exiting via e.g., a trapped interrupt. + Thanks to a report from Bob Proulx. + +2004-06-22 Paul Eggert + + * src/who.c (idle_string, print_user): New arg boottime, + specifying the most recent boot time. All uses changed. + (idle_string) Consider a line to be "old" if it hasn't been used + since the last boot time. Watch out for overflow when computing + times, and for times in the future. + (idle_string): Record latest boot time. + +2004-06-22 Jim Meyering + + * src/test.c (usage): Correct description of `-t FD'. The file + descriptor, FD, is no longer optional. Reported by Ton Nijkes. + +2004-06-21 Paul Eggert + + The 2004-06-19 fix for who and pinky was incomplete, as ctime + has undefined behavior if the year precedes -999 or follows 9999. + Since we have to stop using ctime anyway, we might as well use + strftime and fix the FIXME, and support internationalized dates. + + * NEWS: Document the new behavior. + * src/who.c: Include "hard-locale.h". + (time_format, time_format_width): New vars. + (time_string, print_line): Use them. + (main): Set them. + (time_string): Use localtime + strftime instead of + ctime, to avoid problems with years before -999 or after 9999. + * src/pinky.c: Likewise. + +2004-06-21 Paul Eggert + + Fix bug: GNU 'ls' didn't count columns correctly if user or group + names contained multibyte characters where the column count + differed from the byte count. This patch also corrects + some comments. + + * src/ls.c (format_user_or_group): New function, which counts + columns correctly. + (format_user, format_group): Use it. + (format_user_or_group_width): New function, which counts columns + correctly. + (format_user_width, format_group_width): Use it. + +2004-06-21 Jim Meyering + + * tests/priv-check: Quote "$PATH" in PATH=$PATH. + Suggestion from Andreas Schwab. + + * tests/priv-check: When running as root, be sure to propagate + PATH through to the process we exec as non-root. + Reported by michael@aplatform.com. + + * src/mknod.c (main): Don't segfault when calculating the + expected number of operands for `mknod NAME'. + +2004-06-20 Jim Meyering + + * src/dd.c (input_seek_errno): Declare file-scoped variable as static. + +2004-06-20 Paul Eggert + + * src/basename.c (main): + Standardize on the diagnostics given when someone gives + too few operands ("missing operand after `xxx'") or + too many operands ("extra operand `xxx'"). + Include "quote.h" and/or "error.h" if it wasn't already being included. + * src/chgrp.c (main): Likewise. + * src/chmod.c (main): Likewise. + * src/chown.c (main): Likewise. + * src/chroot.c (main): Likewise. + * src/comm.c (main): Likewise. + * src/cp.c (do_copy): Likewise. + * src/csplit.c (main): Likewise. + * src/date.c (main): Likewise. + * src/dircolors.c (main): Likewise. + * src/dirname.c (main): Likewise. + * src/du.c (main): Likewise. + * src/expr.c (main): Likewise. + * src/hostid.c (main): Likewise. + * src/hostname.c (main): Likewise. + * src/id.c (main): Likewise. + * src/install.c (main): Likewise. + * src/join.c (add_file_name, main): Likewise. + * src/link.c (main): Likewise. + * src/ln.c (main): Likewise. + * src/logname.c (main): Likewise. + * src/md5sum.c (main): Likewise. + * src/mkdir.c (main): Likewise. + * src/mkfifo.c (main): Likewise. + * src/mknod.c (main): Likewise. + * src/mv.c (main): Likewise. + * src/nohup.c (main): Likewise. + * src/od.c (main): Likewise. + * src/pathchk.c (main): Likewise. + * src/ptx.c (main): Likewise. + * src/readlink.c (main): Likewise. + * src/rm.c (main): Likewise. + * src/rmdir.c (main): Likewise. + * src/seq.c (main): Likewise. + * src/setuidgid.c (main): Likewise. + * src/shred.c (main): Likewise. + * src/sleep.c (main): Likewise. + * src/sort.c (main): Likewise. + * src/split.c (main): Likewise. + * src/stat.c (main): Likewise. + * src/test.c (beyond, main): Likewise. + * src/touch.c (main): Likewise. + * src/tr.c (main): Likewise. + * src/tsort.c (main): Likewise. + * src/tty.c (main): Likewise. + * src/uname.c (main): Likewise. + * src/uniq.c (main): Likewise. + * src/unlink.c (main): Likewise. + * src/uptime.c (main): Likewise. + * src/users.c (main): Likewise. + * src/who.c (main): Likewise. + * src/whoami.c (main): Likewise. + + * tests/basename/basic: Adjust to new diagnostics. + * tests/du/files0-from: Likewise. + * tests/expr/basic: Likewise. + * tests/mv/diag: Likewise. + * tests/tsort/basic-1: Likewise. + +2004-06-20 Jim Meyering + + * src/ln.c: Remove declaration of yesno. + Instead, include yesno.h. + * src/copy.c: Likewise. + + * src/remove.c: Remove declaration of yesno. + Instead, include yesno.h. + (top_dir): Remove now-unnecessary cast of obstack_base. + (pop_dir): Likewise. + (full_filename_): Likewise. + +2004-06-19 Paul Eggert + + Don't dump core if ctime returns NULL; this is possible on + hosts with 64-bit time_t and 32-bit int. + * src/who.c: Include "inttostr.h". + (time_string): If ctime fails, print the raw time as an integer + instead of dumping core. + * src/pinky.c: Likewise, as follows: + Include "inttostr.h". + (time_string): New function, copied from who.c. + (print_entry): Use it. + +2004-06-19 Paul Eggert + + * src/who.c (print_line): Don't truncate user names at 8 bytes. + Problem reported by Guido Leenders in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-06/msg00056.html + * NEWS: document this. + +2004-06-19 Jim Meyering + + * src/system.h (case_GETOPT_VERSION_CHAR): Switch back to + using GNU_PACKAGE (from PACKAGE) once again. This restores + `GNU' to the parenthesized package name in --version output. + Before, the first argument from AC_INIT, `GNU coreutils', would + be propagated to the PACKAGE variable. Now, `GNU ' is trimmed. + Reported by Richard Stallman. + +2004-06-17 Jim Meyering + + * src/tr.c (to_uchar): Rename function from `uchar'. The latter + would clash with a typedef in Tru64's . From Albert Chin. + +2004-06-15 Paul Eggert + + * NEWS: Remove more special cases for POSIXLY_CORRECT when POSIX + allows the GNU behavior. "--" is now supported by chroot, hostid, + hosname, pwd, sync, yes. + * doc/coreutils.texi (yes invocation, false invocation, + true invocation): Document this. + * src/chroot.c (main): Handle "--". + * src/hostid.c (main): Likewise. + * src/hostname.c (main): Likewise. + * src/pwd.c (main): Likewise. + * src/sync.c (main): Likewise. + * src/yes.c (main): Likewise. + * src/true.c (main): Recognize --help and --version even if + POSIXLY_CORRECT is set. + * src/yes.c (main): Likewise. + +2004-06-09 Paul Eggert + + * NEWS: Remove special cases for POSIXLY_CORRECT when POSIX allows + the GNU behavior. + * doc/coreutils.texi (pr invocation, unlink invocation): Document this. + * src/ls.c (decode_switches): Pay attention to TABSIZE even if + POSIXLY_CORRECT is set. POSIX reserves upper-case environment + variables to the implementation, so it's OK for ls to depend on + TABSIZE. + * src/pr.c: Include "hard-locale.h". + (main): When in a non-POSIX locale, ignore POSIXLY_CORRECT, since + POSIX specifies the behavior only in the POSIX locale. + * src/printf.c (print_esc): Support \x, \u, \U even if POSIXLY_CORRECT, + since POSIX says the behavior is unspecified here. + * src/tail.c (parse_obsolescent_option): Support multiple file operands + even if POSIXLY_CORRECT, since POSIX does not require a diagnostic. + * src/printf.c (main): Recognize --help, --version even if + POSIXLY_CORRECT. POSIX does not specify any options, but it + does not prohibit options either, so "printf" is like "expr" here. + * src/unlink.c (main): Likewise. + * tests/misc/printf: Adjust to the new semantics for \x if + POSIXLY_CORRECT. + +2004-06-14 Jim Meyering + + * tests/misc/pwd: New test, for fix of 2004-04-19. + * tests/misc/Makefile.am (TESTS): Add pwd. + (BUILD_SRC_DIR): Define BUILD_SRC_DIR. + + * src/copy.c: Remove declaration of euidaccess. + Instead, include "euidaccess.h". + +2004-06-13 Paul Eggert + + * src/who.c (PIDSTR_DECL_AND_INIT): Don't assume pid_t fits in int. + (UT_ID) [!HAVE_STRUCT_XTMP_UT_ID]: Remove bogus comment, + as (sizeof "??") reliably returns 3. + (print_line): Guard against idle and pid being too long + (which is possible when printing headers). + (print_user): Allocate enough bytes for idlestr. Use IDLESTR_LEN. + Avoid unnecessary cast of sizeof to int. + (make_id_equals_comment): Do not assume that UT_ID returns + a string; it might return a non-null-terminated array. + Use strncat instead. It's not very often where strncat is + exactly what you want, but this is one of those rare cases. + +2004-06-11 Paul Eggert + + * src/who.c (list_entries_who): Don't output a trailing space. + +2004-06-09 Jim Meyering + + * src/touch.c (usage): Improve wording in description of the + --time=WORD option. Reported by Dan Jacobson. + + * src/chown-core.c (change_file_owner): Change names of parameters + old_uid and old_gid to required_uid and required_gid respectively. + + * src/chmod.c (mode_changed): Return false, not 0, now that the + function returns `bool'. + +2004-06-08 Paul Eggert + + Adjust chmod and chown to be similar if -c or -v are given. In + particular, a no-op chown is no longer reported as a change; this + reverts to previous behavior. Also, fix both commands so that -v + report failures even if the failure is not due to the chmod or + chown syscalls. + + * src/chmod.c (CH_NOT_APPLIED): New constant. + (describe_change): Handle it. + (process_file): Use it, if a symlink wasn't changed. + (mode_changed): Return bool, not int. Accept new argument + NEW_MODE; all callers changed. This lets us avoid statting the + file unless the new mode has unusual bits. + (process_file): Return -1 on error. With -v, report all errors + verbosely, not just some. + + * src/chown-core.c (change_file_owner): Return -1 on error, not + 1 sometimes and -1 on others. Our caller ORs together our results, + and (-1 | 1) == 0 on ones-complement hosts. + With -v report all errors verbosely, not just some. + Fix bug when chopt->root_dev_ino && !chopt->affect_symlink_referent: + file_stats wasn't set properly in that case. + + * tests/chgrp/basic: Adjust to above changes. + +2004-05-20 Paul Eggert + + * tests/chgrp/basic: Test that chgrp -h does not fail on + symlinks, even on hosts where that's not supported. + Test that if -R is specified without -H or L, -h is assumed. + Test that chown() is not optimized away. + +2004-05-18 Paul Eggert + + Several fixes to chgrp and chown for compatibility with POSIX and BSD: + + Check for incompatible options. When -R and --dereference are + both used, then either -H or -L must also be used. When -R and -h + are both used, then -P must be in effect. + + -H, -L, and -P have no effect unless -R is also specified. + If -P and -R are both specified, -h is assumed. + + Do not optimize away the chown() system call when the file's owner + and group already have the desired value. This optimization was + incorrect, as it failed to updated the last-changed time and reset + special permission bits, as POSIX requires. + + Do not report an error if the owner or group of a + recursively-encountered symbolic link cannot be updated because + the file system does not support it. + + * NEWS: Document the above. + + * src/chgrp.c (main): Check for incompatible options. -R --dereference + requires either -H or -L, and -R -h requires -P. If -H, specify + FTS_PHYSICAL as well as FTS_COMFOLLOW; this is faster. Make this + file as much like chown.c as possible. + * src/chown.c (main): Likewise. + + * src/chown-core.c (change_file_owner): Use ent->fts_statp only if + needed. Chown a directory only after chowning its children; this + avoids problems if the new directory ownership doesn't permit + access to the children. Dereference symlinks before doing + ROOT_DEV_INO_CHECK, not after, so that we catch symlinks to /. + Do not optimize away the chown() system call when the file's owner + and group already have the desired value. POSIX does not permit + this optimization. Rely on chown and lchown to do the right + thing with symlinks and/or -1 arguments, now that we have wrappers + to do this. Use ENOTSUPP not ENOSYS, and ignore all ENOTSUPP + errors, not just command-line errors. + (chown_files): Pass FTS_NOSTAT to xfts_open if we don't need file status. + + * src/system.h (ENOTSUP): Remove. + + * tests/chgrp/basic: Use chown --from to discover whether the + group changed, since chgrp now changes unconditionally. This + complicates the sed script a bit. Do not specify --dereference, + since it's the default (and we want to test this). Adjust output + to match the fact that chgrp no longer optimizes the case of + changing a file's group to the same value as before. + * tests/chgrp/posix-H: Do not attempt to combine -h and -H; these + options are incompatible, and their behavior is undefined with POSIX. + (changed, not_changed): Adjust to match the fact that -h is no longer + specified. Sort names. + * tests/chown/deref: Adjust error-diagnostic spelling to match new + behavior. + +2004-06-07 Paul Eggert + + * src/uname.c (main): Fix typo introduced on 2003-05-10 that + prevented a diagnostic of any operands. + +2004-06-08 Jim Meyering + + * src/shred.c (direct_mode): Turn it on/off with directio, too. + +2004-06-07 Jim Meyering + + Enable direct-mode I/O (bypassing the buffer cache), if possible. + Prompted by a suggestion from Kalle Olavi Niemitalo + in http://bugs.debian.org/207035. + * src/shred.c (direct_mode): New function. + (do_wipefd): Turn on direct-mode I/O. + (dopass): If a file's first write fails with EINVAL, + turn off direct-mode I/O and retry the write. + +2004-06-05 Paul Eggert + + * src/tr.c (main): "tr -d a b" is now a fatal error even if + POSIXLY_CORRECT is set. The POSIX SYNOPSIS does not allow this + option combination. + +2004-06-04 Paul Eggert + + * src/shred.c (dopass): Don't subtract 1 from the offset after + a write error. Problem reported by Jon Peatfield in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-06/msg00020.html + +2004-06-02 Paul Eggert + + Fix bug reported by Buciuman Adrian in + + where 'dd' created a file that was too large. The bug was that dd + assumed that the input file offset does not advance after a failed + read; but POSIX says that the input file offset is undefined after + a failed read. + + * src/dd.c (MAX_BLOCKSIZE): New macro. + (input_seekable, input_seek_errno, input_offset, + input_offset_overflow): New vars. + (scanargs): Reject block sizes greater than MAX_BLOCKSIZE. + (advance_input_offset): New function. + (skip_via_lseek): Set errno to zero when reporting our failure, + so that we don't report based on garbage errno. + (skip): If fdesc is standard input, advance the input offset. + Do not quit if reading, and if noerror was specified; + POSIX seems to require this. + If read fails on output file, report the earlier lseek failure + instead; this fixes a FIXME in dd_copy. + (advance_input_after_read_error): New function. + (dd_copy): Use it, instead of assuming that failed reads + do not advance the file pointer. Advance input offset + after nonfailed reads. Advance only a partial block if + the previous read (before the failed read) succeeded, and + do not generate an output block of zeros in this case. + (main): Determine initial input offset, seekability of input, + and error if it wasn't seekable. + +2004-06-02 Jim Meyering + + rm (without -f) could hang unnecessarily when attempting to + remove a symlink to a file on an off-line NFS-mounted partition. + Reported by David Howells in https://bugzilla.redhat.com/124699. + * src/remove.c (write_protected_non_symlink): New function. + Don't invoke euidaccess on symlinks. + (prompt): Use write_protected_non_symlink rather than using + euidaccess directly, being careful not to call lstat twice for a file. + + Fix a bug in how the --output-delimiter=D option works with + abutting byte or character ranges. Reported by David Krider in + http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00132.html + * src/cut.c (print_kth): Remove special case for open-ended range. + (set_fields): Record the range start index for an interval even + when it abuts another interval on its low side. + Also record the range start index of the longest right-open-interval. + * tests/cut/Test.pm: Add tests of --output-delimiter=S with + abutting and overlapping byte ranges. + +2004-06-01 Paul Eggert + + Some POSIX-conformance cleanups for tr. + + * src/tr.c (posix_pedantic): Remove; no longer needed since + we need to test this in just one place now. + (usage): Mention -C. + (unquote): Note that \055, \n, etc are escaped. + Do not worry about POSIXLY_CORRECT when warning about ambiguous + escape sequences. + \ at end of string stands for itself. + Do not diagnose invalid backslash escapes: POSIX says the behavior + is unspecified in this case, so we don't need to diagnose it. + (main): Add support for -C (currently an alias for -c). + Do not diagnose 'tr [:upper:] [:upper:], as POSIX does not require + a diagnostic here. + * tests/tr/Test.pm: New tests bs-055, bs-at-end, repeat-Compl. + Fix comment for range-a-a. + +2004-05-25 Paul Eggert + + Improve the efficiency (and in one case, correctness) of code + that reads symlinks. + + * src/copy.c (copy_internal): Don't use alloca, as it can mess up + royally if the link length is long (e.g., GNU/Hurd). Use + xreadlink instead, it's safer. Don't bother to read the link if + it's the wrong size. Add a FIXME because this area is a bit murky + and undocumented. + * src/ls.c (get_link_name): Update use of xreadlink. + * src/readlink.c (main): Likewise. + * src/stat.c (print_stat): Likewise. + +2004-06-01 Jim Meyering + + * src/env.c (main): Prefer the notation `STREQ (a, b)' + over `!strcmp (a, b)'. + * src/sort.c (main, sort_buffer_size): Prefer the notation + `STREQ (a, b)' over `strcmp (a, b) == 0'. + * src/date.c (batch_convert): Likewise. + * src/expr.c (nextarg): Likewise. + * src/su.c (correct_password, restricted_shell, main): Likewise. + * src/ptx.c (swallow_file_in_memory, main): Likewise. + * src/test.c (binary_operator, and, or, main): Likewise. + +2004-05-13 Paul Eggert + + * NEWS: echo compatibility cleanup. + * doc/coreutils.texi (echo invocation): Document the changes. + * src/echo.c (V9_ECHO): Remove; always enabled. + (DEFAULT_ECHO_TO_XPG): Renamed from V9_DEFAULT, so that + we use the same naming convention as bash. Now an enum, + not a macro. + (usage): Reword to mention -e/-E more accurately. + Mention \0NNN (the POSIX syntax) rather than \NNN (nonstandard). + (hextobin): New function. + (main): Use bool rather than int for local vars when appropriate. + Do not allow options if POSIXLY_CORRECT, unless we are using + BSD semantics and the first argument is "-n". + Don't pass unnecessary extra arg to parse_long_options. + do_v9 now defaults to DEFAULT_ECHO_TO_XPG, not to allow_options. + Do not look for options if !allow_options. + Use size_t rather than int when appropriate. + Open-code option test rather than using strrchr. + Use faster test for "-". + Avoid redundant argc test. + Add support for \x, for Bash compatibility. + Use e.g. '\a' rather than '\007', for portability to EBCDIC hosts. + When '\c' is encountered, stop printing immediately, as POSIX + requires. + Add support for \xhh syntax. + Add support for \0ooo syntax; POSIX requires this. + +2004-06-01 Jim Meyering + + * Use automake-1.8b. Regenerate dependent files. + +2004-05-31 Jim Meyering + + * tests/Makefile.am.in (TESTS_ENVIRONMENT): Define PATH to include + the build src/ directory -- at the front. + ($(srcdir)/$x-tests): Depend on Makefile.am. + Use $x as the program name, except when it would be `test' (test is + the sole program tested via mk-script that is also a shell built-in). + In that case, use the old ../../src/$x. + +2004-05-30 Jim Meyering + + Work around HPUX /bin/cc compiler bug that is exposed, now that + sets are arrays of type `bool'. More details here: + http://lists.gnu.org/archive/html/bug-gnulib/2004-05/msg00094.html + FIXME: verify that the above URL points to the right message + + * src/tr.c (card_of_complement): Use cleaner `sizeof in_set' + rather than `N_CHARS * sizeof(in_set[0])'. Using HPUX's /bin/cc + (aC++/ANSI C B3910B A.05.55 [Dec 04 2003]) on an ia64-hp-hpux11.22 + system, those two expressions are not the same (256 vs. 1024). + The effect of this problem was that `tr -c x y' would fail: + tr: when not truncating set1, string2 must be non-empty + (set_initialize): Remove unnecessary initialization of the `in_set' + buffer; that initialization triggered the same compiler bug as above. + +2004-05-29 Paul Eggert + + tr cleanup, mostly having to do with integer type ranges. + Remove all casts. + + * tests/tr/Test.pm: Add a few tests for the below. Alas, most of + the test cases wouldn't be portable, or would take too much CPU + time, or both. + + * src/tr.c (N_CHARS, N_CHAR_CLASSES): Now an enum, not a macro. + This is safe since the code already assumes N_CHARS fits in int. + (Filter): Remove: we want to prototype everything. + (ORD, CHR): Remove. All uses removed. Some replaced with: + (uchar): New function. All places where a char must be converted + to an unsigned char are now done this way, not by ad-hoc methods. + (count): New type. Use it whenever counts or states are needed. + (BEGIN_STATE): Increase from INT_MAX - 1 (which was bogus, anyway, + since we used it in an unsigned int context) to UINTMAX_MAX - 1. + (REPEAT_COUNT_MAXIMUM): New macro. Use it in place of BEGIN_STATE + whenever appropriate. + (NOT_A_CHAR): Remove global macro; now a local enum. + (UL_LOWER, UL_UPPER, UL_NONE): No longer specify values, since + the rest of the code no longer depends on them. + (class_ok): Remove; all uses changed to use inline comparisons. + (RE_NO_TYPE): Remove; wasn't used or needed. + (struct List_element): normal_char and equiv_code are now unsigned + char, not int. + first_char, last_char, and the_repeated_char are now unsigned char, + not unsigned int. repeat_count is now count, not size_t. + All uses changed. + (struct Spec_list): state is now count, not unsigned int. + lengthis now count, not size_t. + n_indefinite_repeats is now size_t, not int. + has_equiv_class, has_char_class, and has_restricted_char_class + are now bool, not int. All uses changed. + (struct E_string): s is now char *, not unsigned char *. + escaped is now bool *, not int *. All uses changed. + (ES_MATCH): Remove macro, replacing with: + (es_match): New inline function. All uses changed. + (squeeze_repeats, complement, posix_pedantic, truncate_set1, + translating): Now bool, not int. + (io_buf): Now char array, not unsigned char. + (SET_TYPE): Remove. All uses replaced with bool. + (is_equiv_class_member, unquote, append_range, append_char_class, + append_equiv_class, find_closing_delim, star_digits_closebracket, + build_spec_list, parse_str, homogeneous_spec_list): + Now returns bool, not int. All uses changed. + (is_equiv_class_member): Now inline. + (is_equiv_class_member, is_char_class_member, make_printable_str, + append_normal_char, append_range, append_repeated_char, + get_s2_spec_stats): + Args are now of proper integer type. + (unquote, look_up_char_class, make_printable_str, + append_equiv_class, build_spec_list, squeeze_filter): + Avoid unsigned char *p; gently convert *p to unsigned char instead. + (unquote, get_spec_stats): Do not jump past declarations and then + use them; C doesn't allow this in portable programs. + (make_printable_str): Check for overflow in size calculations. + (xmemdup): Remove. All uses rewritten. + (find_bracketed_repeat): Args are now of proper pointer-to-integer + type. Do not reject [c*0]. Use xstrtoumax, not xstrtoul. + (find_bracketed_repeat, star_digits_closebracket): Check that the + digits are not escaped. + (build_spec_list): Don't bother to copy opnd_str; not needed. + (build_spec_list, get_next): Simplify internal logic a bit. + (card_of_complement): Fix bug due to char overflow. + (get_spec_stats): Don't assume len fits into int. + Check for integer overflow. Use abort() rather than assert(0). + (string2_extend): Fix subscript error: is_char_class_member (..., 255) + was being invoked. + (squeeze_filter): READER is never null now; simplify code. + READER arg now has a simpler type. Remove unnecessary casts. + (squeeze_filter, main): Calls to fwrite improperly checked result + against zero, rather than against requested size. + (plain_read): New function. + (read_and_delete, read_and_xlate): + Remove unused filter arg, and don't worry about hit_eof. + Simplify by using plain_read. + (set_initialize): Args are bool and bool *, not int and SET_TYPE *. + (main): Always pass a non-null procedure to squeeze_filter. + Rewrite so that class_ok isn't needed. + +2004-05-29 Paul Eggert + + * src/shred.c (dosync): Ignore EBADF errors, as IRIX 6.5 + fdatasync reports EBADF when syncing (unwritable) directories. + Problem reported by Albert Chin-A-Young in: + http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00165.html + +2004-05-29 Jim Meyering + + * tests/chown/deref: Fix typo: use ls -ldo, not ls -ldg. + Patch from Albert Chin. + + * src/ptx.c (text_buffer_maxend): Remove declaration of unused variable. + + * src/remove.c (push_dir): Merge declaration and adjacent assignment + into a single statement. + +2004-05-28 Jim Meyering + + * src/remove.c (AD_mark_helper): Eliminate an unnecessary comparison. + +2004-05-22 Jim Meyering + + rm -r would get a failed assertion when run from an inaccessible + directory and with two or more command line arguments including an + absolute-named directory followed by a relative-named directory. + + * src/remove.h (struct rm_options) [require_restore_cwd]: New member. + * src/remove.c (struct cwd_state): Define. + (AD_pop_and_chdir): Redesign interface so that a restore_cwd failure + can be detected by the caller. Instead of returning a malloc'd + directory name, communicate it to caller via a new parameter, and + return an indication of whether restore_cwd failed. Update caller. + Eliminate an unnecessary call to AC_stack_top. + (remove_dir): Change type of cwd_state parameter to `struct cwd_state' + so we can now communicate to caller whether/how functions like + restore_cwd have failed. Update caller. + (rm_1): Fail if we've failed to restore the working directory + and the name of the next file to remove is `.'-relative. + (rm): Fail if the require_restore_cwd flag is true and we've + failed to restore the working directory. + * src/mv.c (rm_option_init): Initialize new member, + x->require_restore_cwd. + * src/rm.c (rm_option_init): Likewise. + +2004-05-21 Jim Meyering + + * tests/rm/inaccessible: New test for the above fix. + * tests/rm/Makefile.am (TESTS): Add inaccessible. + + * src/remove.c (rm): Use free rather than XFREE. + (remove_dir): Use xmalloc, not XMALLOC. + (ds_init): Likewise. + +2004-05-20 Jim Meyering + + * Makefile.maint (sc_unmarked_diagnostics): Now that the unmarked + diagnostics in shred.c have been fixed, don't exempt shred.c from + this check. + + * src/shred.c: Use translatable diagnostics, e.g. + change "%s: remove" to _("%s: failed to remove") and + change "%s: close" to _("%s: failed to close"). + +2004-05-17 Paul Eggert + + * src/shred.c (names): Bring back lower-case letters, "_", and + ".". But continue to omit +, =, %, @, #, as they're either + shell metacharacters (for some shells) or are not in some + character sets, or (in the case of '%') must be a + metacharacter somewhere. + +2004-05-16 Paul Eggert + + * src/cut.c (cut_fields): Adjust to new signature of getndelim2. + +2004-05-17 Jim Meyering + + * src/shred.c (incname): Decrement `len' only once per loop iteration. + + chgrp and chown now dereference symlinks by default, per POSIX. + Reported by Michal Politowski as http://bugs.debian.org/249177. + + * src/chown-core.c (chopt_init): Affect each symlink referent by default. + * src/chown.c (usage): Update to reflect this. + * src/chgrp.c (usage): Likewise. + * NEWS: Describe the change. + Adapt tests accordingly. + * tests/chgrp/basic: Use -h where necessary to retain semantics. + * tests/chgrp/deref: Likewise. + * tests/chgrp/posix-H: Likewise. + +2004-05-15 Paul Eggert + + In shred, check for errors from fdatasync more carefully. If + fdatasync fails with errno==EINVAL, it means this implementation + does not support synchronized I/O for this file. Do not report + this as an error, as (for example) AIX 5.2 fdatasync reports it + for raw disk devices. Problem reported by Albert Chin in + . + + Check for write errors, though: the old code ignored them. + Improve error checking in a few other cases, too (e.g., close of a + directory). + + Also, change several 'int' values to 'bool', so that the error + checking is a bit clearer. Similarly, change unsigned values + to size_t where appropriate. + + * src/shred.c: Include "dirname.h". + (datasync) [!HAVE_FDATASYNC]: Remove. + (dosync): New function. + (dopass): Use it. Return 1 on write error, -1 on other error. + All callers changed. Report write error if dosync does. + (do_wipefd, wipefd, wipename, wipefile): Return bool (true/false), + not int (0/-1). All callers changed. Return false if there's a + write error. + (incname): Return bool (true/false), not int (0/1). Accept + size_t length, not unsigned. All callers changed. Do not + bother checking for non-digits; it can't happen. Replace + recursion with iteration. + (wipename): Use dir_name, base_name, etc. instead of assuming + Unix file names. Use size_t for length, not unsigned. + Report error if unlink or close fails. + (wipename, main): Use bool for booleans. + + (names): Use only digits and uppercase letters, for greater + portability. + +2004-05-16 Jim Meyering + + * tests/chown/deref: New test for the yesterday's change. + * tests/chown/Makefile.am (TESTS): Add deref. + +2004-05-15 Jim Meyering + + chown --dereference did nothing when the owner/group of a + symlink matched the desired owner/group. Reported by David Malone. + Also reported in 1999 as http://bugs.debian.org/39642. + + * src/chown-core.c (change_file_owner): When --dereference has + been specified, and when processing a symlink, stat it to get the + owner and group of the referent. + +2004-05-14 Jim Meyering + + * man/pwd.x, man/echo.x, man/printf.x: Fix typo: + s/supercede/supersede/ reported by Andrew Fabbro. + +2004-05-13 Paul Eggert + + Improve performance of `sort -m' on large files, at the cost of + making some contrived examples unsafe. POSIX allows this + optimization. Performance problem reported by Jonathan Baker in + . + + * src/sort.c (first_same_file): Do not treat input pipes + differently from other files. + * doc/coreutils.texi (sort invocation): Document that "sort -m -o F" + might write F before reading all the input. + * NEWS: Likewise. + +2004-05-12 Paul Eggert + + * src/od.c (print_ascii, dump_strings): Use e.g. '\a' rather than + '\007', for portability to EBCDIC hosts. + * src/printf.c (print_esc_char): Likewise. + * src/tr.c (unquote, make_printable_str): Likewise. + +2004-05-12 Jim Meyering + + * src/remove.c (AD_pop_and_chdir): Move lstat-`.' into if-block + where the result is used. This avoids one unnecessary lstat call + per command line argument. + +2004-05-12 Paul Eggert + + Don't assume that "make -C" works; Solaris "make" doesn't have -C. + + * src/Makefile.am (all_programs.list): New rule, copied from + man/Makefile.am and tests/Makefile.am, except that we use the + system tr rather than ./tr and we don't use tr -s. + * tests/Makefile.am (all_programs): Use it. + * man/Makefile.am (all_programs): Likewise. Renamed from programs, + for consistency. All uses changed. + +2004-05-11 Jim Meyering + + * tests/rm/unread3: New test, for the above fix and today's + lib/save-cwd.c improvement. + * tests/rm/Makefile.am (TESTS): Add unread3. + + * src/rm.c: Don't include "save-cwd.h". It's no longer used. + +2004-05-10 Jim Meyering + + * tests/install/trap: New file. Test for bug fix of 2004-04-18. + * tests/install/Makefile.am (TESTS): Add trap. + + * src/remove.c (AD_push): Don't use errno in diagnostic about + `changed dev/ino'. + + Remove these generated files from CVS. + * tests/cut/cut-tests, tests/date/date-tests, tests/join/join-tests: + * tests/ls/ls-tests, tests/pr/pr-tests, tests/tac/tac-tests: + * tests/tail/tail-tests, tests/test/test-tests, tests/tr/range-tests: + * tests/tr/tr-tests, tests/wc/wc-tests: + +2004-05-09 Jim Meyering + + * src/tr.c (unquote): Use xcalloc rather than xmalloc and + a loop initializing the just-allocated memory to zero. + +2004-05-08 Jim Meyering + + * tests/rm/no-give-up: New file; check for today's fix. + * tests/rm/Makefile.am (TESTS): Add no-give-up. + +2004-05-08 Paul Eggert + + Fix bug where "rm" gave up too easily, reported by Dan Jacobsen in + . + + * src/remove.c (remove_entry): Check for errno values like ENOENT + that show the file cannot be directory, instead of for errno + values like EPERM that show the file might be a directory. This + is necessary because, when a single unlink() call has multiple + reasons to fail, it can set errno to any of those reasons; it's + only the rare errno value like ENOENT that excludes all the other + possible reasons to fail even when the file is a directory. + (remove_cwd_entries): Don't attempt chdir if the file is known + to not be a directory. + (remove_dir): Use the same method that remove_cwd_entries uses + (for some reason they differed). Don't assert that saved_errno + must be EPERM; it might be just about anything. + +2004-05-06 Jim Meyering + + * src/id.c (xgetgroups): Use xnmalloc, rather than xmalloc. + Don't add `1' to the buffer size (it was to protect against malloc + implementations that fail to allocate a buffer of size zero). + That is no longer necessary, since we use a malloc wrapper + on such systems. + + * src/wc.c (get_input_fstatus): Use xnmalloc, rather than xmalloc. + * src/head.c (elide_tail_bytes_pipe): Likewise. + * src/df.c (main): Likewise. + * src/shred.c (do_wipefd): Likewise. + * src/users.c (list_entries_users): Likewise. + * src/tail.c (main): Likewise. + * src/md5sum.c (main): Likewise. + +2004-04-29 Paul Eggert + + * src/df.c (show_disk, show_point): If several filesystems are + mounted on the same mount point, prefer the last one, not the first. + Problem reported by Christian Jones in + . + (show_disk): Remove unused statp arg. Return bool, not int. + (show_point): Rewrite to avoid gotos. Use the same algorithm + for lofs and dummies for each pass through the mount table, + rather than subtly different algorithms (which are probably + inadvertent). + +2004-05-03 Jim Meyering + + * Makefile.am (EXTRA_DIST): Add m4/ChangeLog, now that we no longer + have m4/Makefile*. + +2004-05-01 Jim Meyering + + When chown or chgrp is modifying the referent of a symlink, + use the chown(2) function, if possible. + * src/chown-core.c (change_file_owner): Don't hard-code the + open/fchown/close kludge here. Use `chown' instead. + The chown function works just fine on conforming systems. + Other systems now go through the new chown wrapper that + resorts to the old kludge. + + * src/chown-core.c (change_file_owner): Add a comment. + +2004-04-27 Jim Meyering + + * src/ptx.c: Make over 40 global extern variables `static'. + (syntax_table, re_syntax_table): Remove declarations of two unused + variables (they were exposed by the above change). + + * src/du.c (G_fail, opt_nul_terminate_output): Declare `static'. + * src/ln.c (backup_type): Likewise. + + * src/remove.c (rm): Add `extern' keyword. + * src/cp-hash.c (forget_created, remember_created) + (src_to_dest_lookup, remember_copied, hash_init, forget_all): Likewise. + * src/copy.c (dest_info_init, src_info_init, copy): Likewise. + * src/chown-core.c (chopt_init, chopt_free, gid_to_name) + (uid_to_name, chown_files): Likewise. + + * src/Makefile.am (sc_tight_scope): New rule. + * Makefile.maint (sc_tight_scope): New rule. + (syntax-check-rules): Add it. + +2004-04-26 Jim Meyering + + * Use automake-1.8.4. Regenerate dependent files. + + * src/sort.c (limfield): Make a comment clearer. + +2004-04-25 Paul Eggert + + Fix POSIX-conformance bug: "sort -k 3,3.5b" is supposed to skip + leading blanks when computing the location of the field end; + it is not supposed to skip trailing blanks. Solaris 8 "sort" + does conform to POSIX. Also fix the documentation to clarify + this and related issues. + + * doc/coreutils.texi (sort invocation): Mention -k earlier, so + that the options are in alphabetical order. Describe how -b works + more-accurately; this involves fixing some examples, too. Mention + what happens if the start field falls after an end field or after + a line end. Warn about using -k without -b, -g, -M, -n, or -t. + Add an example of how to sort IPv4 addresses and Apache Common + Log Format dates. Remove a duplicate example. + (Putting the tools together): Use separate options rather + than agglomerating them. + * src/sort.c (limfield): Use skipeblanks, not skipsblanks, to + decode whether to skip leading blanks. + (trailing_blanks): Remove. + (fillbuf, getmonth, keycompare): Don't trim trailing blanks. + + * tests/pr/Test.pm: Fix typo in env_default comment. + * tests/sort/Test.pm: Likewise. + (18c, 18d): Reverse the order of output lines, so that the + test cases conform to POSIX. + +2004-04-22 Paul Eggert + + More signal-handling cleanup for ls.c. Do not allow signals to + happen between arbitrary output bytes, as the + restore-default-color sequence can bollix up multibyte chars or + color-change sequences in the ordinary output. Instead, process + signals only between printing a file name and changing the color + back to non_filename_text color. That way, if the signal handler + changes the color (to the default), 'ls' will change it back when + 'ls' continues (after being suspended). + + Also, do not bother with signal-handling unless stdout is a + controlling terminal; this lets stdio buffer better when "ls + --color" is piped or sent to a file. + + * src/ls.c (sigprocmask, sigset_t) [!defined SA_NOCLDSTOP]: New macros. + Do not include "full-write.h"; no longer needed. + (tcgetpgrp) [! HAVE_TCGETPGRP]: New macro. + (put_indicator_direct): Remove. All callers changed to use + put_indicator. + (caught_signals, interrupt_signal, stop_signal_count): New vars. + (restore_default_color): Don't bother checking for put_indicator + failure. + (sighandler): Don't handle SIGTSTP; that's another handler now. + Simply set interrupt_signal to the signal, then exit. + (stophandler, process_signals): New functions. + (main): Don't output any color changes until _after_ the signal + handlers are set up. This fixes a race condition where 'ls' + could be interrupted while initializing colors, and leaving the + terminal in an undesirable state. + Don't mess with signal-handling if standard output is not a + controlling terminal. + When exiting, restore the default color, then restore the + default signal handling, then act on any signals that weren't + acted on yet. + Do not print //DIRED// etc. in colors; this avoids the need + to catch signals when printing them. + (print_name_with_quoting): Process signals just before switching + color back to non_filename_text. + +2004-04-23 Jim Meyering + + Avoid segfault on systems for which SIZE_MAX != (size_t) -1. + * src/ls.c (quote_name): Use SIZE_MAX, not -1, in calls + of quotearg_buffer. Patch by Mikulas Patocka. + +2004-04-18 Paul Eggert + + tee ignored SIGPIPE, but POSIX doesn't allow this. + + * src/tee.c (main): Do not ignore SIGPIPE, as POSIX 1003.1-2001 + does not allow this. This undoes the 1996-10-24 patch. + +2004-04-18 Paul Eggert + + Signal-handling cleanup for coreutils. Here are the highlights: + + - csplit sometimes failed to remove files when interrupted. + - csplit didn't clean up if two signals arrived nearly simultaneously. + - install -s would infloop on System V if SIGCHLD was ignored. + - ls could incorrectly restore color if multiple signals + arrived nearly simultaneously. + + * src/csplit.c (sigprocmask, sigset_t) [!defined SA_NOCLDSTOP]: + Define. + (filename_space, prefix, suffix, digits, files_created, remove_files): + Now volatile. + (caught_signals): New var. + (cleanup): Block signals while deleting all files. + (cleanup_fatal, handle_line_error, regexp_error): + Mark with ATTRIBUTE_NORETURN. + (create_output_file, close_output_file, interrupt_handler): + Block signals while changing the number of output files, + to fix some race conditions. + (delete_all_files): Do nothing if remove_files is zero. + Clear files_created. + (main): Don't mess with signals until after argument processing + is done. + + * src/csplit.c (main): Rewrite signal-catching code to make it + similar to other coreutils programs. When processing signals, + block all signals that we catch, but do not block signals that we + don't catch. Avoid problems with unsigned int warnings. + * src/ls.c (main): Likewise. + * src/sort.c (main): Likewise. + + * src/csplit.c (interrupt_handler): + Use void, not (obsolete) RETSIGTYPE. + * src/shred.c (sigill_handler, isaac_seed_machdep): Likewise. + + * src/csplit.c (interrupt_handler) [defined SA_NOCLDSTOP]: + Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent. + * src/ls.c (sighandler) [defined SA_NOCLDSTOP]: Likewise. + * src/sort.c (sighandler) [defined SA_NOCLDSTOP]: Likewise. + * src/nohup.c (main) [!defined _POSIX_SOURCE]: Likewise, except + for SIG_IGN. + * src/tee.c (main) [!defined _POSIX_SOURCE]: Likewise. + + * src/install.c: Include . + (main) [defined SIGCHLD]: Set SIGCHLD handler to the default, if -s is + given, since System V fork+wait does not work if SIGCHLD is ignored. + + * src/ls.c (sighandler) [!defined SA_NOCLDSTOP]: Reset signal + handler to self, not to SIG_IGN, since SIGTSTP can be received + more than once. + (main): Use SA_RESTART, as that is simpler than checking for EINTR + failures all over the place. + +2004-04-20 Jim Meyering + + * src/remove.c (is_empty_dir): Clarify comment. + + * man/help2man: Accept new option: --program-name=NAME, so that we + can override the one in --version output. This is needed solely + so that test.1 doesn't refer to `[' as the program name. + Reported by Benjamin Cutler as http://bugs.debian.org/205251. + * man/Makefile.am (.x.1): Use help2man's new --program-name option. + + * src/pwd.c: Don't include pathmax.h; system.h already does it. + + * src/cut.c (cut_fields): Free buffer upon getndelim2 failure. + +2004-04-19 Jim Meyering + + * src/shred.c (isaac_seed_start) [AVOID_USED_UNINITIALIZED_WARNINGS]: + Initialize a buffer to avoid warnings from tools like valgrind. + + * Makefile.maint (sc_trailing_blank): New rule. + (syntax-check-rules): Add it. + * .x-sc_trailing_blank: New file. + + Make pwd work even if the resulting name is so long that getcwd fails. + * src/pwd.c: (path_free, path_init, path_prepend): New functions. + (nth_parent, find_dir_entry, robust_getcwd): New functions. + (main): First try getcwd, then, upon failure, robust_getcwd. + +2004-04-18 Jim Meyering + + * src/who.c (print_user): Use xrealloc here, rather than + unchecked realloc. Remove anachronistic casts. + + * src/remove.c (full_filename_): Don't leak upon failed realloc. + + * src/system.h (readdir_ignoring_dot_and_dotdot): New inline function, + from remove.c. + * src/remove.c (readdir_ignoring_dotdirs): Move function to system.h, + renaming it. Update uses. + +2004-04-17 Jim Meyering + + * configure.ac: Depend on automake-1.8.3. + + * src/join.c (add_file_name): Declare function to be `static'. + (string_to_join_field): Likewise. + * src/remove.c (ds_init, ds_free): Likewise. + + * Makefile.maint (sc_prohibit_jm_in_m4): New rule. + (syntax-check-rules): Add to the list. + +2004-04-13 Paul Eggert + + Use page-aligned buffers whenever we bother to do I/O using buffer + sizes that are tailored for the files. + + * src/cat.c: Include getpagesize.h. + * src/copy.c: Likewise. + * src/shred.c: Likewise. + * src/split.c: Likewise. + * src/cat.c (main): Align I/O buffers to page boundaries. + * src/copy.c (copy_reg): Likewise. + * src/shred.c (dopass): Likewise. + * src/split.c (main): Likewise. + * src/dd.c (ROUND_UP_OFFSET, PTR_ALIGN): Remove. + All uses replaced by ptr_align. + * src/od.c (gcd, lcm): Remove; now in system.h. + * src/system.h (gcd, lcm, ptr_align): New functions, moved from od.c. + +2004-04-14 Jim Meyering + + Remove m4/Makefile.am: it's no longer needed, with newer automake + * configure.ac (AC_CONFIG_FILES): Remove m4/Makefile.in from the list. + * Makefile.am (SUBDIRS): Remove `m4' from the list. + +2004-04-13 Jim Meyering + + * configure.ac: Change `jm_' in AC_DEFINE'd names to `gl_'. + +2004-03-27 Paul Eggert + + * NEWS: cp -pu and mv -u (when copying) now take the destination + file system time stamp resolution into account. + * doc/coreutils.texi (mv invocation): Document this. + (cp invocation): Document -u (it was missing!) with new behavior. + + * src/copy.c: Include "utimecmp.h". + (copy_internal): Compare time stamps using utimecmp rather than + MTIME_CMP. + +2004-04-09 Jim Meyering + + * Makefile.maint (.re-list): New rule/file, to replace + hard-coded list of header file names. + (sc_system_h_headers): Use the new file. + Don't look for sys2.h anymore. + + * src/system.h: Include new "stat-macros.h" rather than hard-coding + all of its macro definitions -- the list was slightly out of date. + Suggestion from Dmitry V. Levin. + +2004-04-08 Paul Eggert + + * NEWS: Remove noctty flag from dd. Suggested by Philippe Troin. + * doc/coreutils.texi (dd invocation): Likewise. + * src/shred.c (O_NOCTTY): Remove redundant decl. + * src/dd.c (flags, usage): Remove noctty flag. + (main): Always use O_NOCTTY when opening files. + +2004-04-08 Jim Meyering + + * src/dd.c (dd_copy): Mark two diagnostics for translations. + (set_fd_flags): Undo part of today's change: it's a little + cleaner -- and more efficient in the common case -- to go + ahead and OR in the -1 when fcntl fails. + + * Makefile.maint (sc_dd_max_sym_length): New target. + (syntax-check-rules): Add it. + + * src/md5sum.c (PROGRAM_NAME) [algorithm == ALG_SHA1]: + Correct spelling: s/shasum/sha1sum. Reported by Jesse Kornblum. + + * src/dd.c (set_fd_flags): Don't OR in -1 when fcntl fails. + Rename parameter, flags, to avoid shadowing global. + (LONGEST_SYMBOL): Tweak comment. + +2004-04-07 Paul Eggert + + * NEWS: New dd conv= symbols nocreat, excl, fdatasync, fsync, + and new dd options iflag= and oflag=. + * src/dd.c (usage): Likewise. + * src/Makefile.am (dd_LDADD, shred_LDADD): Add fdatasync's lib. + * src/dd.c (fdatasync) [!HAVE_FDATASYNC]: New macro. + (C_NOCREAT, C_EXCL, C_FDATASYNC, C_FSYNC): New macros. + (input_flags, output_flags): New vars. + (LONGEST_SYMBOL): New macro. + (struct symbol_value): Renamed from struct conversion. Members + symbol and value renamed from convname and conversion. The + symbol value is now an array instead of a pointer; this saves + a bit of space and time in practice. All uses changed. + (conversions): Add nocreat, excl, fdatasync, fsync. Now const. + (flags): New constant array. + (iflag_error_msgid, oflag_error_msgid): New constants. + (parse_symbols): Renamed from parse_conversion and generalized + to handle either conversion or flag symbols. + (scanargs): Adjust uses of parse_symbols accodingly. Add + support for iflag= and oflag=. Reject attempts to use + both excl and nocreat. + (set_fd_flags): New function. + (dd_copy): Just return X rather than calling quit (X), since our + caller invokes quit with the returned value. Add support for + fdatasync and fsync. + (main): Add support for iflag=, oflag=, and new conv= symbols. + * src/system.h (O_DIRECT, O_DSYNC, O_NDELAY, O_NOFOLLOW, + O_RSYNC, O_SYNC): Define to 0 if not already defined. + + * NEWS: Remove duplicate mention of BLOCKSIZE. + +2004-04-02 Andreas Schwab + + * src/stty.c: Add support for IUTF8 input flag. + +2004-04-06 Jim Meyering + + * src/system.h (makedev) [mkdev && !makedev]: Define in terms of mkdev. + Interix spells it `mkdev'. Reported by Mark Funkenhauser. + +2004-04-04 Jim Meyering + + A specified format is no longer automatically newline terminated. + If you want a newline at the end of your format, use `\n'. + * src/stat.c (print_it): Don't print a newline at the end of + every format. + (do_statfs): Add a newline at end of each default format string. + +2004-03-30 Paul Eggert + + * src/nohup.c (main): Adjust to new calling convention + for set_cloexec_flag. + +2004-03-31 Jim Meyering + + * tests/Fetish.pm (run_tests): Remove `.orig' file. + Remove debugging diagnostic. + + Specifying an invalid --width=N (-w) or --gap-size=N (-g) + would not elicit an error. + * src/ptx.c: Include "xstrtol.h" and "quotearg.h". + (main): Don't use atoi. Use xstrtoul instead. + +2004-03-30 Jim Meyering + + * Makefile.maint (sc_prohibit_atoi_atof): New rule. + (syntax-check-rules): Add it. + * .x-sc_prohibit_atoi_atof: New file. + +2004-03-29 Jim Meyering + + * tests/du/files0-from: Use new OUT_SUBST directive, so that this + test is not sensitive to system-dependent block size differences. + Prompted by a report of Solaris 8 differences from Paul Eggert. + + * tests/Fetish.pm: Accept new directives: OUT_SUBST, ERR_SUBST. + Rename `%tmp' to `%actual'. Reverse order of last two args to + _compare_files (to $actual, $expected) so as to match declaration. + +2004-03-28 Paul Eggert + + Fix some gotchas encountered when porting to Solaris 8, using + the Forte 6u2 compiler. + + * src/hostname.c [HAVE_SETHOSTNAME && !defined sethostname]: + Declare sethostname, since no Solaris header does it. + * src/who.c: Include "vasprintf.h", for asprintf. + +2004-03-28 Jim Meyering + + Minor optimization: + * src/du.c (process_file): Don't record dev/inode for directories. + + Under some circumstances, without -c, du would mistakenly count the + space of hard-linked files, not just the first one it encountered. + Reported by Anthony Thyssen. + * src/du.c (du_files): Don't ever clear the set of `seen' dev/inodes. + + * src/du.c: Rename global `print_totals' to `print_grand_total'. + + * src/du.c (main): Rearrange filtering loop to be a tiny bit + more efficient. + + * src/chown-core.c: Don't include savedir.h -- no longer needed. + * src/chmod.c: Likewise. + +2004-03-25 Jim Meyering + + * src/du.c (main): Remove now-unused declaration of `i'. + +2004-03-24 Paul Eggert + + * src/du.c (main): Filter out file names of length zero before + invoking fts, so that they don't cause fatal errors. + +2004-03-25 Jim Meyering + + * tests/du/files0-from (zero-len): Add a test for the above. + +2004-02-25 Paul Eggert + + * NEWS: New environment var BLOCKSIZE. + * lib/human.c (humblock): Support BLOCKSIZE as well as BLOCK_SIZE. + * tests/envvar-check: Test for it. Factor the code to simplify it. + +2004-03-23 Paul Eggert + + * NEWS: Shorten the du --files0-from announcement, and say + "NUL-terminated" rather than "NUL-separated". + * src/du.c (EXPECTED_BYTES_PER_FILE_NAME, DEFAULT_PROJECTED_N_FILES): + Remove: not used. + (usage): Say "NUL-terminated", not "NUL-separated". + (main): Check for I/O error when istream is closed. + Allow --files0-from=F even if F is empty; this specifies no files. + (du_files): Now that we allow the list of files to be empty, + handle that case. + * tests/du/files0-from: Adjust to above changes to src/du.c. + +2004-03-24 Jim Meyering + + * tests/tail-2/assert: Avoid race condition that could cause + spurious failure. Based on a patch from Andreas Schwab. + +2004-03-23 Jim Meyering + + * src/du.c (main): Free the hash table, too. + +2004-03-22 Jim Meyering + + * man/Makefile.am (.x.1): Remove --info-page= option, reverting + the change of 2004-01-22. I can no longer reproduce the problem + that prompted that change, and `info coreutils pr' would display the + `printing text' section of the manual, not the one on `pr invocation'. + + * tests/du/files0-from (nul-1, nul-2): Adjust expected diagnostics + to match corrected output. + + * src/du.c: Include "readtokens0.h" rather than "readtokens.h". + (main): Use readtoken0 functions rather than readtokens. + Don't use errno when diagnosing readtokens0 failure. + Fix off-by-one error in the token number reported in a diagnostic. + (du_files): Return bool, rather than int. + (main): Call readtokens0_free. + +2004-03-21 Jim Meyering + + * src/remove.c (ds_free): Plug a small leak. + + * tests/Fetish.pm: Fix typo in comment. + +2004-03-07 Jim Meyering + + * NEWS: du accepts a new option --files0-from=FILE, where FILE + contains a list of NUL-separated file names. + + * src/du.c: Include "readtokens.h". + (usage): Describe the new option, and adjust the `Usage': + with this option, no FILE may be specified on the command line. + (main): Handle the new option. + + * tests/du/files0-from: New tests, for the above. + * tests/du/Makefile.am (TESTS): Add files0-from. + + * src/factor.c (do_stdin): Reflect changes in use of readtoken. + * src/tsort.c (tsort): Likewise. + +2004-02-29 Paul Eggert + + * NEWS: Add support for a new notation @N to get_date to represent + the time stamp with numeric value N. Improve support for + fractional time stamps. date's -d and -f options now accept them. + Likewise for touch -t. date has a new option --iso-8601=ns. + + * doc/coreutils.texi (touch invocation): + Describe use of fractional seconds. + (date invocation, Options for date): Likewise. + * doc/getdate.texi (General date syntax, Time of day items): Likewise. + * doc/coreutils.texi (date invocation): Mention effect of LC_TIME. + (Options for date): Describe new --iso-8601=ns option. + + * doc/getdate.texi: Add copyright notice. Change getdate to + get_date when talking about the function name. + (Seconds since the Epoch): New section, containing the time_t + info moved from Date input formats section, along with new + info about the @ syntax. Mention negative time stamps, + fractional time stamps, and leap seconds. + (General date syntax): Modernize examples a bit to reflect new + features. + (General date syntax, Relative items in date strings): + Use ' rather than " to quote formats. + (Time of day items): Add an example with fractional seconds. + Describe fractional-second syntax. + + * src/Makefile.am (touch_LDADD): New macro, since `touch' now + needs clock_gettime. + + * src/date.c (enum Time_spec): New enum TIME_SPEC_NS. + (time_spec_string, time_spec, show_date): Support it. + (usage): Remove description of -ITIMESPEC, as it's obsolete and + confusing. Mention --iso-8601=ns. + (batch_convert): getline returns ssize_t, not int. + + * src/touch.c (newtime): Now an array of two timespecs, one + for access and one for modification. + (ref_stats): Remove. + (get_reldate): Use get_date's parameter profile. + (touch, main): Adjust to above changes. + (main): Work even if tm_year == INT_MAX (so long as long int is wider). + Use gettime instead of gettimeofday, for new get_date signature. + + * tests/date/Test.pm (test_vector): New tests epoch, ns-10, ns-max32, + ns-relative. + +2004-03-15 Jim Meyering + + * Makefile.maint (alpha beta major): `Make' the emit_upload_commands + target before updating $(prev_version_file). + + * tests/misc/date-sec: New file, to test for just-fixed bug in date. + See today's change in lib/getdate.y. + * tests/misc/Makefile.am (TESTS): Add date-sec. + +2004-03-14 Jim Meyering + + * announce-gen (print_changelog_deltas): Use `.sig' suffix for + signature files, not `.asc'. Reported by angico@yahoo.com. + +2004-03-13 Jim Meyering + + * src/cp.c (do_copy): Tweak wording in a diagnostic. + Suggestion from Karl Berry. + Include "quoatearg.h". + (do_copy): Use quotearg_colon (not quote) for diagnostics + that begin with `"%s:'. + + * src/nl.c (usage): Specify that nl uses _basic_ regular expressions. + Suggestion from Dan Jacobson. + +2004-03-12 Jim Meyering + + * Version 5.2.1. + + Sometimes, when source and destination partition are different, + mv mistakenly fails to preserve a hard link. Reported by IIDA Yosiaki. + + * src/copy.c: When moving a set of N hard-linked files between + partitions, via two or more command line arguments where the + command line argument containing the Nth link contains no other + link to that same file, mv would mistakenly copy the file, rather + than hard-linking it to the other(s). That happens because when the + final link is processed, its link count has been reduced to 1 since + the other links have been `copied' to the destination partition + and the source links have been removed. + (copy_internal): When in move mode, use the source dev/inode + pair to look up destination name even when st_nlink == 1. + * src/cp-hash.c (src_to_dest_lookup): New function. + * src/cp-hash.h (src_to_dest_lookup): Add prototype. + * tests/mv/part-hardlink: New file. Test for the above fix. + * tests/mv/Makefile.am (TESTS): Add part-hardlink. + + * announce-gen: Sync with autoconf. + + * tests/ls/time-1: Exit 77 (not 1) if we can't set up for the test. + This was triggered on a Linux-2.2.19 system using a file system + NFS-mounted from some sort of Sun. + +2004-03-11 Jim Meyering + + * Use automake-1.8.3. Regenerate dependent files. + +2004-03-10 Jim Meyering + + * tests/du/deref-args: Also convert sizes in the 70-79 kB range, + so that this test works with SELinux-enabled systems. + Based on a patch from Tim Waugh. + + `join -1 x' would give a misleading diagnostic + * src/join.c (string_to_join_field): Report that a non-numeric field + number is invalid, rather than `so large that it is not representable'. + * tests/join/Test.pm (invalid-j): New partial test for the above fix. + +2004-03-06 Jim Meyering + + cp --sparse=always sparse-image-file.img /dev/hda1 could + produce an invalid copy on the destination device. + + * src/copy.c (copy_reg): Even with --sparse=always, try to + make `holes' only if the destination is a regular file. + Reported by Szakacsits Szabolcs. + +2004-03-03 Paul Eggert + + * src/nohup.c (main): Don't invoke set_cloexec_flag with + a file descriptor of -1. + +2004-03-02 Dmitry V. Levin + + * src/nohup.c: Include "cloexec.h". + (main): Set the copy of stderr to close on exec. + +2004-03-01 Paul Eggert + + * configure.ac: Include when checking for strsignal, + sys_siglist, and friends. Problem reported by Tony Leneis in + . + +2004-02-25 Paul Eggert + + * tests/du/deref-args, tests/du/exclude, tests/du/slash: + * tests/du/trailing-slash: Run envvar-check in case BLOCK_SIZE + etc. are set. + +2004-02-23 Paul Eggert + + * NEWS: Document how chown's USER.GROUP argument is now parsed. + +2004-02-23 Jim Meyering + + * src/seq.c (usage): Remove stray space after \n in --help output. + +2004-02-22 Jim Meyering + + * src/du.c (usage): Separate -H and --si. Say that the meaning + of -H will soon change to that of --dereference-args (-D). + +2004-02-21 Jim Meyering + + * src/comm.c (usage): Tell what comm does when there are no options. + Reword in terms of FILE1 and FILE2 rather than `left file' and + `right file'. Suggestion from Dan Jacobson. + +2004-02-15 Paul Eggert + + Fix some POSIX-conformance bugs in expr. + + * NEWS: document the following changes to src/expr.c. + * doc/coreutils.texi (expr invocation): Likewise. + Document what forms integers may take, and say "integer" + consistently instead of "number". Warn about operands + that "expr" can misinterpret, and how to work around the + problem. + * src/expr.c (eval, eval7, eval6, eval5, eval4, eval3, eval2, eval1): + Accept a bool argument specifying whether to evaluate the + expression. This is to allow short-circuit evaluation. All + callers changed. + (null): Report that a string is zero even if it has + a form like "-0" or "00". + (eval1, eval): Use short-circuit evaluation for | and &. + (eval): Return 0 if both arguments are null or zero, instead + of returning the first argument. + * tests/expr/basic: Add some tests for the above. + +2004-02-17 Jim Meyering + + * Version 5.2.0. + + `make check' from a build inside a chroot environment would fail + * tests/help-version: Specify an argument (`/') for df, in the + unusual event that there is no valid entry in /etc/mtab. + Likewise for id: add the -u option, so we don't get spurious + failures when there are no user or group names. + Patch by Tim Waugh. + + * src/sort.c (usage) [-u]: Add punctuation so that the description in + the help2man-generated (line-joined) man page is more readable. + Reported by Tim Waugh. + [-T]: Add a semicolon, for the same reason. + +2004-02-15 Jim Meyering + + * Makefile.am (dist-hook): Qualify target with $(srcdir)/ prefix. + +2004-02-11 Jim Meyering + + * tests/Makefile.am.in ($(srcdir)/Makefile.am): Use more portable + $(srcdir)/../Makefile.am.in, rather than $<. + Suggestion from Michael Elizabeth Chastain. + +2004-02-10 Jim Meyering + + * config/install-sh: Make this script executable. + * Makefile.am (dist-hook): New target, to ensure that config/install-sh + is executable. Otherwise, on systems that lack a suitable install + binary, `make install' would fail, because of the way this script + is invoked (without `$SHELL ' prefix). + Reported by Bob Proulx. + +2004-02-08 Jim Meyering + + * Version 5.1.3. + + * tests/rm/rm5: Avoid triggering a bug in OSF/Tru64's sed + that would cause an unwarranted test failure. + * tests/rm/rm3: Likewise. + +2004-02-07 Jim Meyering + + Remove xstat function pointer member. The way it was used was not + portable, since some systems (OSF V5.1, Solaris 2.5.1) provide static + inline `stat' and `lstat' functions, thus making the tests of + `xstat == lstat' in copy.c always fail. + * src/copy.h (struct cp_options) [xstat]: Remove member. + (XSTAT): New macro. + * src/copy.c (copy_dir): Set `.dereference' member, not .xstat. + (copy_internal): Use `XSTAT (x, ...)' in place of `*(x->xstat) (...)'. + Use `x->dereference == DEREF_NEVER' in place of `x->xstat == lstat'. + (valid_options): Remove now-obsolete FIXME comments. + + * src/cp.c (re_protect): Use `XSTAT (x, ...)' in place of + `*(x->xstat) (...)'. + (do_copy): Declare/use local xstat rather than x->xstat. + (main): Remove code that set x.xstat. + * src/mv.c (cp_option_init): Don't initialize xstat member. + * src/install.c (cp_option_init): Likewise. + + * Makefile.cfg (gnu_ftp_host-alpha, etc.): Un-factor .gnu.org suffix, + so that emit_upload_commands can use these variables, too. + +2004-02-06 Jim Meyering + + * tests/rm/deep-1: Remove `du' stack space test. + Apparently, `ulimit -s N' isn't portable enough. + This test will be restored (with a guard against losing ulimit) + in its own file later. + + * tests/rm/deep-1 (deep): Remove progress-style diagnostics, + since this test doesn't take long enough to merit them. + Run du on $tmp (the containing dir), not $deep, the full path to leaf. + + * Makefile.maint (signatures): Remove definition. + Now, automake's gnupload handles this. + (%.sig: %): Remove now-unused rule. + (rel-files): Use automake's $(DIST_ARCHIVES), rather than + `$(distdir).tar.bz2 $(distdir).tar.gz'. + (emit-upload-commands): Adjust to use gnupload. + +2004-02-05 Jim Meyering + + * src/system.h (ST_TIME_CMP_NS, ST_TIME_CMP): Remove definitions. + (ATIME_CMP, CTIME_CMP, MTIME_CMP, TIMESPEC_NS): Likewise. + Now, those are all defined in timespec.h. + Include timespec.h. + + * src/date.c: Don't include timespec.h, now that system.h does it. + +2004-02-02 Paul Eggert + + Don't dump core if localtime returns NULL (possible on + hosts with 64-bit time_t and 32-bit int). + * src/date.c: Include "inttostr.h". + (batch_convert, main): + If time conversion fails, exit with nonzero status. + (show_date): Return int to report conversion failure. + Print the time as an int if localtime fails. + * src/uptime.c: Print "??" if the current clock can't + be converted by localtime. This won't happen until the year + 2*31 + 1900, but we don't want to dump core even if the current + clock has the wrong value. + + * src/stat.c: Include "inttostr.h". + (human_time): Print the date/time as a number of seconds since the + epoch if it can't be converted by localtime. This is better than + just saying "invalid", and is consistent with what "ls" does. + Don't dump core if the year has more than 48 digits; this isn't + possible on any contemporary host, but we might as well do it right. + +2004-01-31 Paul Eggert + + * src/stat.c (human_time): Accept time rather than + pointer-to-const-time parameter, for clarity. All callers changed. + +2004-02-02 Jim Meyering + + * src/stat.c (do_stat): Remove extra trailing newline from + default formats. Reported by Nelson H. F. Beebe. + + Print actual fractional seconds in time stamps, not just `.00000000'. + * src/stat.c (human_time): Add and use new parameter, t_ns. + (print_stat): Update callers. + * src/ls.c (TIMESPEC_NS): Remove definition. + * src/system.h (TIMESPEC_NS): Define here, instead, now that stat.c + also uses this macro. + Nelson H. F. Beebe noticed that ls --full-time printed nonzero + fractional seconds for files on an XFS file system, but that stat's + fractional seconds were always zero. + +2004-01-28 Paul Eggert + + * src/seq.c (print_numbers): Use 'double' for loop index, not + 'int', to avoid problems with integer overflow. On almost all + machines 'double' works in every case where 'int' works, and + it works on other cases besides. + +2004-01-27 Jim Meyering + + * src/seq.c (usage): Mention that if INCREMENT is omitted, + it defaults to 1, even when FIRST is larger than LAST. + Reword so as not to exclude the possibility that INCREMENT be zero. + +2004-01-25 Jim Meyering + + * Version 5.1.2. + + * Makefile.maint (signatures): Comment out definition. + +2004-01-23 Jim Meyering + + * Makefile.maint (header_regexp): Add exitfail. + + * man/Makefile.am (EXTRA_DIST): Add help2man. + Reported by Nelson H. F. Beebe. + + * man/Makefile.am (.x.1): Prefix help2man invocation with `$(PERL) --' + so it works on systems with Perl installed somewhere other than in + /usr/bin. + + * src/paste.c (paste_parallel): Declare local, chr, to be of type + `int', not `char', since it must hold EOF. This bug would make + paste infloop on some systems. Test failures reported by + Nelson H. F. Beebe and Christian Krackowizer. + +2004-01-22 Jim Meyering + + * tests/rmdir/fail-perm: New file. Test for just-fixed rmdir bug. + * tests/rmdir/Makefile.am (TESTS): Add fail-perm. + + * man/help2man: Fix it so using --info-page='coreutils PROG' works. + * man/Makefile.am (.x.1): Invoke our own (tweaked) copy of help2man. + Use --info-page='coreutils PROG' option. + Now, readlink.1 refers the user to `info coreutils readlink' + rather than to `info readlink'. Reported by Matt Swift. + +2004-01-21 Paul Eggert + + Exit status cleanup. + + * src/basename.c (usage): Use EXIT_SUCCESS, not 0, for clarity. + * src/cat.c, src/chgrp.c, src/chmod.c, src/chown.c, src/chroot.c, + * src/cksum.c, src/comm.c, src/cp.c, src/csplit.c, src/cut.c, + * src/date.c, src/dd.c, src/df.c, src/dircolors.c, src/dirname.c, + * src/du.c, src/echo.c, src/env.c, src/expand.c, src/expr.c, + * src/factor.c, src/fmt.c, src/fold.c, src/head.c, src/hostid.c, + * src/hostname.c, src/id.c, src/install.c, src/join.c, src/kill.c, + * src/link.c, src/ln.c, src/logname.c, src/ls.c, src/md5sum.c, + * src/mkdir.c, src/mkfifo.c, src/mknod.c, src/mv.c, src/nice.c, + * src/nl.c, src/nohup.c, src/od.c, src/paste.c, src/pathchk.c, + * src/pinky.c, src/pr.c, src/printenv.c, src/printf.c, src/pwd.c, + * src/rm.c, src/rmdir.c, src/seq.c, src/setuidgid.c, src/shred.c, + * src/sleep.c, src/sort.c, src/split.c, src/stat.c, src/stty.c, + * src/su.c, src/sum.c, src/sync.c, src/tac.c, src/tail.c, src/tee.c, + * src/test.c, src/touch.c, src/tr.c, src/tsort.c, src/tty.c, + * src/uname.c, src/unexpand.c, src/uniq.c, src/unlink.c, src/uptime.c, + * src/users.c, src/wc.c, src/who.c, src/whoami.c, src/yes.c: Likewise. + + * src/cat.c (usage): Don't bother normalizing exit status + since the arg is already the correct exit status now. + * src/cksum.c, src/comm.c, src/csplit.c, src/cut.c, + * src/dircolors.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/split.c, src/sum.c, src/tac.c, src/tail.c, src/tr.c, + * src/tsort.c, unexpand.c, src/src/uniq.c, src/src/wc.c: Likewise. + + * src/chown.c (main): Removed unused local 'fail'. + + * src/chroot.c (CHROOT_FOUND_BUT_CANNOT_INVOKE, CHROOT_FAILURE): + Remove. + + * src/chroot.c (main): Initialize exit_failure to EXIT_FAIL. + * src/env.c, src/nice.c, src/su.c: Likewise. + * src/nohup.c (main): Likewise, to NOHUP_FAILURE. + * src/setuidgid.c (main): Likewise, to SETUIDGID_FAILURE. + * src/expr.c (main): Use initialize_exit_failure rather than + setting exit_failure directly; this optimizes away redundant + assignments. + * src/printenv.c, src/sort.c, src/test.c, src/tty.c: Likewise. + + * src/chroot.c (main): Exit with status 1 rather than 127 + if chroot itself fails, as per documentation. + + * src/chroot.c (main): Use EXIT_ENOENT and EXIT_CANNOT_INVOKE + rather than roll-your-own symbols or integers. + * src/env.c (main): Likewise. + * src/nohup.c (main): Likewise. + * src/su.c (run_shell): Likewise. + + * src/cp.c (exit_status): Remove static var.... + (main): Making it local here instead. Use =, not |=, to set it. + + * src/cut.c (FATAL_ERROR, main): Exit with status EXIT_FAILURE, + not 2, on errors. + * src/date.c (batch_convert, main): Likewise. + * src/dd.c (dd_copy): Likewise. + * src/pr.c (first_last_page, main, getoptarg): Likewise. + * src/tr.c (main): Likewise. + * src/date.c (main): Don't assume EXIT_FAILURE == 1, as + POSIX doesn't require it. + * src/dd.c (write_output, skip, dd_copy): Likewise. + * src/df.c (main): Likewise. + * src/id.c (main): Likewise. + * src/install.c (main): Likewise. + * src/ln.c (main): Likewise. + * src/ls.c (main): Likewise. + * src/mv.c (main): Likewise. + * src/shred.c (main): Likewise. + + * src/env.c (main): Exit with status 1, not 2, on errors detected + by env proper. + * src/hostname.c (main): Likewise. + * src/nl.c (main): Likewise. + * src/stty.c (main): Likewise. + + * src/expr.c (EXPR_FAILURE): Renamed from EXPR_ERROR, for + consistency with the other programs' naming conventions. + All uses changed. + + * src/factor.c (main): Do not report a usage error simply + because stdin has bad numbers. + + * src/id.c (problems): Now a boolean int, not a counter, + so that we don't have to worry about int overflow. All uses changed. + * src/touch.c (err): Likewise. + + * src/md5sum.c (main): Use int, not size_t, to store boolean int. + + * src/mkfifo.c (main): Exit with status 1, not 4, if not implemented. + * src/mknod.c: Likewise. + + * src/nice.c (main): Exit with status EXIT_FAIL, not EXIT_FAILURE, + on error; this is in case EXIT_FAILURE is unusual. + * src/su.c (main): Likewise. + + * src/nohup.c (NOHUP_FOUND_BUT_CANNOT_INVOKE): Remove; all uses + changed to EXIT_CANNOT_INVOKE. + + * src/printenv.c (PRINTENV_FAILURE): New constant. + (main): Exit with status PRINTENV_FAILURE, not EXIT_FAILURE, on + command-line syntax problems. + + * src/rmdir.c (remove_parents): Don't set 'fail' to a negative number. + (main): Avoid integer overflow when seeing whether errors occurred. + + * src/seq.c (print_numbers): Now returns void, not (zero) int. + All callers changed. + (main): Remove unused local variable 'errs'. Always exit successfully + if we reach the end. + + * src/setuidgid.c (SETUIDGID_FAILURE): Renamed from FAIL_STATUS, + for consistency with other programs here. All uses changed. + (main): Use 'error' to exit rather than invoking 'exit' here. + + * src/sort.c: Don't include . + (SORT_OUT_OF_ORDER, SORT_FAILURE): Now enums, not macros. + (usage): Don't use 'assert'. + (main): Remove redundant assignment to exit_failure. + + * src/system.h (EXIT_FAIL, EXIT_CANNOT_INVOKE, EXIT_ENOENT): + New enum values. + (initialize_exit_failure): New inline function. + Include exitfail.h here, since we refer to exit_failure. + All callers changed to not include exitfail.h. + + * src/tty.c (TTY_FAILURE, TTY_WRITE_ERROR): New enum values; + substitute them for the corresponding integer constants. + + * tests/help-version (expected_failure_status_date): Remove, as + 'date' is now normal. + (expected_failure_status_nohup): New var. + +2004-01-21 Jim Meyering + + * tests/touch/relative: Remove `command' syntax. + Thanks to Nelson H. F. Beebe and Paul Eggert. + + * tests/touch/relative: Test only year/month/day, not hours/min/sec, + so as to avoid problems with systems using TAI clocks. + Although it's no longer necessary, set TZ=UTC0 also for the + initial touch command. Reported by Paul Jarc here: + http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/1504 + +2004-01-20 Diego Biurrun + + * src/dircolors.hin: Add .mov to the list of media files. + +2004-01-19 Paul Eggert + + * tests/touch/relative: Use TZ=UTC0, not TZ=utc (which isn't + portable). Problem reported by Christian Krackowizer. Also, use + +0000 rather than +0 to specify a time zone, as the documentation + requires four digits. + +2004-01-19 Jim Meyering + + * tests/mv/hard-4: Run envvar-check in case SIMPLE_BACKUP_SUFFIX is set. + * tests/mv/backup-is-src: Likewise. + Problem reported by Peter Horst + +2004-01-17 Jim Meyering + + * announce-gen (print_changelog_deltas): Use .sig suffix, not .asc. + + * Version 5.1.1. + +2003-12-15 Paul Eggert + + * NEWS, doc/coreutils.texi: touch -r and -d can now both be specified, + with -r specifying the origin for -d. + * src/touch.c (flexible_date): Remove static var. + (get_reldate): New function. + (main): Use it, to implement this new behavior. + +2004-01-16 Jim Meyering + + * tests/touch/relative: New test for the above. + * tests/touch/Makefile.am (TESTS): Add relative. + +2004-01-13 Jim Meyering + + * src/system.h: Include contents of sys2.h. + * src/sys2.h: Remove file. + * src/Makefile.am (noinst_HEADERS): Remove sys2.h. + + * Use automake-1.8.2. Regenerate dependent files. + + * Update to gettext-0.13.1. + * configure.ac: Use gettext-0.13.1. + * .x-sc_space_tab: Add m4/po.m4 to the list of exceptions. + +2004-01-12 Jim Meyering + + * Makefile.maint (%.sig): Use .sig suffix rather than .asc. + + * Makefile.maint (po-check): Ensure that cvsu works before using it. + Reported by Alexandre Duret-Lutz. + + * src/tail.c (main): Warn about following stdin only when it's a tty. + + * configure.ac: Use gl_DEFAULT_POSIX2_VERSION. + +2004-01-10 Jim Meyering + + * tests/misc/stat-fmt: Use backticks, not `$()' notation. + +2004-01-09 Jim Meyering + + * configure.ac: Quote underquoted `jm_DUMMY_1' to avoid new warning. + +2004-01-08 Jim Meyering + + * src/stat.c (human_fstype): Use %lx, not %x format for `unsigned long'. + From Andreas Schwab. + + * tests/Makefile.am (TESTS_ENVIRONMENT): Remove `/vg' (prerelease test + remnant) from PATH component. That would cause tests in this directory + not to run the just-built binaries, but rather whatever happened + to be in one's PATH. Reported by Christian Krackowizer. + +2004-01-04 Jim Meyering + + * src/csplit.c (new_control_record): Use x2nrealloc + rather than xrealloc. + + * src/cp.c (re_protect): Use ASSIGN_STRDUPA rather than + alloca and strcpy. + (make_path_private): Likewise. + +2004-01-03 Jim Meyering + + * src/paste.c: Use `bool' (not int) as the type for a few + global variables. + (collapse_escapes): Rewrite to set globals rather than modifying + its parameter. + Use size_t (not int) for all counters and related index variables. + (paste_parallel): Remove needless complexity of + using xrealloc in the loop; just allocate the buffers up front. + Free the two temporary buffers. + Move declarations of locals `down' into scope where used. + (paste_serial): Remove `register' attributes. + (main): Simplify delim-related code. + Free `delims', now that it's malloc'd. + +2004-01-02 Jim Meyering + + * src/chroot.c: Include "quote.h". + (CHROOT_FOUND_BUT_CANNOT_INVOKE, CHROOT_FAILURE): Define. + (main): Exit with status of 127, not 1, for too-few-args, + chroot failure, or chdir failure. + Give a better diagnostic upon execvp failure. + + * src/du.c (usage): Mention that, with its current meaning, + -H is deprecated. + + * src/tail.c (main): Warn about following stdin when it's a tty. + Fail when following by name but no names are specified. + +2003-12-30 Jim Meyering + + * src/fold.c (main): Use memcpy, not strcpy. + + * src/copy.c (copy_internal): Use ASSIGN_STRDUPA rather than + alloca and strcpy. + +2003-12-28 Jim Meyering + + * src/unexpand.c (n_tabs_allocated): New global. + (add_tabstop): Use x2nrealloc rather than xrealloc. + * src/expand.c: Likewise. + + * tests/misc/expand: New file. + * tests/misc/Makefile.am (TESTS): Add expand. + + * src/sort.c (add_temp_dir): Use x2nrealloc rather than xrealloc. + (fillbuf): Use x2nrealloc rather than xrealloc. + (sort): Use xnmalloc rather than xmalloc. + (main): Likewise. + +2003-12-27 Jim Meyering + + * src/tee.c (tee): Use xnmalloc rather than xmalloc. + +2003-12-29 Paul Eggert + + * NEWS: Remove support for join -j1 FIELD, -j2 FIELD, and -o LIST1 + LIST2 in POSIX 1003.1-2001 hosts, as required by POSIX. + + * doc/coreutils.texi (join invocation): Remove documentation + accordingly. Document that -t makes all separators significant. + + * src/join.c: Include posixver.h. + (obsolete_usage): New var. + (longopts): Put obsolete options first. + (OBSOLETE_LONG_OPTIONS): New constant. + (get_option, add_file_name): New functions. + (main): Use them to support new behavior. + (usage): Remove documentation for -j1 FIELD and -j2 FIELD. + Do not mark -j FIELD as obsolescent; it is longstanding + UNIX tradition and is a valid extension to POSIX. + + * tests/join/Test.pm (tv): Avoid obsolete -o usage. + +2003-12-28 Paul Eggert + + * src/join.c (add_field_list): Don't use alloca with unbounded + size; just modify the argument, which is no longer const *. + + Various other minor cleanups, mostly to avoid the need for casts. + + (extract_field): Renamed from ADD_FIELD, as it's now a function. + + (struct field.beg): Now char *, not unsigned char const *. All + uses changed. It shouldn't be const since xmemcoll writes on its + arguments. + (extract_field): Likewise, for 2nd arg. + (keycmp): Remove now-unnecessary cast of xmemcoll args. + + (is_blank): New function, to avoid need to cast arg to unsigned char. + (extract_field): Use it. + + (xfields): Rewrite pretty much from scratch. + + (hard_LC_COLLATE): Now bool, not int. + (get_line, getseq, add_field_list): Now returns bool, not int. + (decode_field_spec, add_field_list): Return true on success (not + false), for consistency with the rest of the code. All uses changed. + + (tab): Now char, not unsigned char. This wasn't 100% necessary + but is slightly cleaner. + (prjoin): Hoist (tab ? tab : ' ') expression, to help the compiler. + + (empty_filler): Now const *. + + (make_blank): Remove; wasn't needed. Remove all calls. + (main): Don't set uni_blank.nfields; zero is fine. + +2003-12-27 Jim Meyering + + * src/join.c: Include "quote.h". + (min, max): Remove definitions. + Make a few function parameters and corresponding + locals `const'. Use bool for boolean variables. + Use size_t (not int) for all counters and related index variables. + (prjoin): Remove now-useless assertion. + (string_to_join_field): New function. + (main): Accept join fields as large as SIZE_MAX. + (keycmp): Rename `min' to MIN and max to MAX. + +2003-12-26 Jim Meyering + + fold -s didn't work on e.g., alpha-based systems. + * src/fold.c (fold_file): Adjust types (int->size_t) so that using + x2nrealloc works properly on systems with differing sizes for int + and size_t. Reported by Nelson Beebe. + + * src/fold.c: Use `bool' (not int) as the type for a few + global variables. + +2003-12-23 Paul Eggert + + * src/ls.c (length_of_file_names_and_frills): + Remove forward decl; not needed. + (print_file_name_and_frills, length_of_file_name_and_frills): + With -m, don't output spaces before inum or size. + (print_with_commas): Don't output space just before newline. + +2003-12-24 Jim Meyering + + * tests/ls/Makefile.am (TESTS): Add m-option. + * tests/ls/m-option: New file. Test for above fixes. + +2003-12-20 Jim Meyering + + * Version 5.1.0. + + * src/pr.c: Change type of global, buff_allocated, to size_t. + + * src/join.c [struct seq]: Change types of members count and alloc + from `int' to `size_t'. + + * tests/Makefile.am (root-hint): Tweak wording. + + * src/du.c: Accept new option (-0, --null) that makes it so each + output line is NUL-terminated rather than newline-terminated. + + * src/dd.c (apply_translations): Don't prohibit conv=unblock,sync. + Reported by Volker Paul. + * tests/dd/Makefile.am (TESTS): Add unblock-sync. + * tests/dd/unblock-sync: New test for the above. + +2003-12-19 Jim Meyering + + * tests/misc/nohup: Double quote back-ticked expression, + in case it ends up having an unexpected value. + + * tests/ls/no-arg: Use ls's -1 option in both runs. + + * src/du.c (fts_debug): New global. + (FTS_CROSS_CHECK, DEBUG_OPT): Define. + (main): Make fts use FTS_TIGHT_CYCLE_CHECK. + (main) [DU_DEBUG]: Accept -d option. + +2003-12-18 Jim Meyering + + * src/ls.c (format_user): Increment dired_pos via two statements, + `dired_pos += width; dired_pos++;' rather than one, + `dired_pos += width + 1;' since the latter could conceivably overflow. + (format_group): Likewise. + From Paul Eggert. + + * configure.ac: Require automake-1.8. + +2003-12-12 Jim Meyering + + * Use automake-1.8. Regenerate dependent files. + +2003-12-08 Jim Meyering + + * Makefile.maint (news-date-check): New rule. + (alpha beta major): Depend on it. + +2003-12-03 Paul Eggert + + * NEWS: ls -l (and similar options) now adjust all columns to + fit the data. Generalized from a suggestion by Leah Q for file sizes. + * src/ls.c (INODE_DIGITS, LOGIN_NAME_MAX, ID_LENGTH_MAX): Remove. + (format_user_width, format_group_width, unsigned_file_size, + format_group): New functions. + (block_size_width): Renamed from block_size_size. + (inode_number_width, nlink_width, owner_width, group_width, + author_width, major_device_number_width, minor_device_number_width, + file_size_width): New vars. + (clear_files): Initialize them. + (gobble_file): Set them. Don't ceiling block_size_width to 7. + (print_long_file): Use them. + (gobble_file): Use a new local variable 'f' to make the code + smaller and more consistent with other functions. + (format_user): Output to stdout, not to a buffer, so that we + don't have to worry about buffer overrun. Update dired_pos. + (print_long_file): Don't put owner, group, author into buffer; + just print them directly. Don't assume link counts and + major and minor numbers fit into unsigned long int. + * tests/cp/same-file, tests/mv/part-symlink: Don't assume that + 'ls' output is fixed-width. + +2003-12-02 Jim Meyering + + * src/md5sum.c: Include sha1.h (reflect renaming: sha.h -> sha1.h. + +2003-11-27 Jim Meyering + + * Use automake-1.7f. Regenerate dependent files. + +2003-11-24 Paul Eggert + + Parse floating-point operands and options in the C locale. + POSIX requires this for printf, and we might as well be + consistent elsewhere (tail, sleep, seq). + + * src/printf.c: Remove decls of strtod, strtol, strtoul; no longer + needed now that we assume C89. Include "c-strtod.h". + (xstrtod): Call c_strtod, not strtod. + * src/sleep.c: Include "c-strtod.h". + (main): Update xstrtod call to include new argument, c_strtod. + * src/seq.c (scan_double_arg): Likewise. + * src/tail.c (parse_options): Likewise. + +2003-11-24 Jim Meyering + + * tests/rm/fail-2eperm: Handle another errno variant (HPUX, EPERM). + Reported by Mark Conty. + +2003-11-22 Jim Meyering + + * Makefile.maint (sc_xalloc_h_in_src): Remove rule. Subsumed by... + (sc_system_h_headers): Do this test only if sys2.h exists. + +2003-11-20 Jim Meyering + + * tests/help-version: Ensure that the bug-reporting address is + included in the --help output for every program. + * tests/Makefile.am (TESTS_ENVIRONMENT): Add $PACKAGE_BUGREPORT. + + * src/ptx.c (usage): Output bug-reporting address. + Reported by Dan Jacobson. + +2003-11-19 Jim Meyering + + * src/join.c (usage): Mention that FILE1 and FILE2 must be sorted + on the join fields. Suggestion from Bruce Robertson. + +2003-11-18 Jim Meyering + + `od -c -w9999999' could segfault + * src/od.c (dump): Use xnmalloc/free, not alloca. + +2003-11-16 Jim Meyering + + * Use autoconf-2.59. Regenerate dependent files. + + * tests/du/hard-link: Minor tweak: use mkdir -p. + + Fix read-from-free'd-buffer error detected by valgrind. + * src/csplit.c (remove_line): Don't return a pointer to data in + a freed buffer. Instead, arrange to free the buffer on the + subsequent call. + + * tests/misc/csplit: New test for above fix. + +2003-11-11 Jim Meyering + + * src/ls.c (extract_dirs_from_files): Avoid useless copy operations. + This avoids a warning from valgrind about memcpy with overlapping + source and destination. + + * configure.ac: Require automake-1.7.8. + +2003-11-09 Jim Meyering + + * Use automake-1.7.9. Regenerate dependent files. + + * src/rm.c: Support new options: --preserve-root and --no-preserve-root. + * src/chown.c: Likewise. + + * src/chown-core.c: Include "root-dev-ino.h". + (chopt_init): Initialize new member. + (change_file_owner): Support rm's new --preserve-root option. + + * src/remove.c: Include "root-dev-ino.h". + (remove_cwd_entries): Remove now-obsolete FIXME comment. + (remove_dir): Support rm's new --preserve-root option. + + * src/chown.c: Include "root-dev-ino.h". + Add new options: --preserve-root and --no-preserve-root. + + * src/chmod.c: Include "root-dev-ino.h". + (process_file): Use newly-factored-out ROOT_DEV_INO_CHECK and + ROOT_DEV_INO_WARN macros. + (get_root_dev_ino): Remove function definition, now that it's + been moved to a separate file. + (usage): Describe new options. + + * src/mv.c (rm_option_init): Initialized new member. + + * src/remove.h: Include "dev-ino.h". + (struct rm_options): Add new member: root_dev_ino. + * src/chown-core.h: Include "dev-ino.h". + (struct Chown_option): Add new member: root_dev_ino. + +2003-11-06 Jim Meyering + + * src/paste.c (paste_parallel): Use `sizeof *var' rather than + hard-coding `sizeof FILE*'. + +2003-11-05 Dennis Smit + + * src/wc.c (main): Free `fstatus' so there is no confusion about + whether it's leaked or not. + * src/who.c (who): Likewise for `utmp_buf'. + +2003-11-05 Paul Eggert + + Fix 'cut' problems with size_t overflow and unsigned int. + More generally, resize integer variables to fit use more precisely. + * src/cut.c (ADD_RANGE_PAIR): Remove unnecessary parens. + (struct range_pair): Make members to be of type size_t, not unsigned. + (max_range_endpoint, eol_range_start): Now size_t, not unsigned. + (suppress_non_delimited, output_delimiter_specified, + have_read_stdin, print_kth, set_fields): Now bool, nt int. + (delim): Now unsigned char, not int. + (mark_printable_field, is_printable_field, is_range_start_index, + set_fields, set_fields, cut_bytes, cut_fields): + Use size_t, not unsigned, for field and byte counts. + (hash_int): Use uintptr_t, not unsigned, for pointers converted + to integers. This squeezes more info out of them. + (set_fields, cut_bytes, cut_fields, main): + Use bool, not int, for booleans. + (set_fields): Allocate zeroed byte array with xzalloc, not xcalloc. + +2003-11-05 Paul Eggert + + * man/Makefile.am (check-programs-vs-x): + Work even if $(programs) contains '$'. + Work even if 'missing=1' in environment. + Don't report an error simply because $(programs) outputs nothing. + +2003-11-05 Jim Meyering + + * Use autoconf-2.58. Regenerate dependent files. + + * src/tr.c (spec_init): Fix typo in last change. + + * src/sys2.h (case_GETOPT_VERSION_CHAR): Cast NULL to `(char *)' in + call to variadic version_etc function, so that it works even on systems + for which sizeof char* != sizeof int. + * src/true.c (main): Likewise. + * basename.c, chroot.c, cksum.c, dd.c, dirname.c, echo.c, expr.c: + * factor.c, hostid.c, hostname.c, link.c, logname.c, nice.c, nohup.c: + * pathchk.c, printenv.c, printf.c, pwd.c, setuidgid.c, sleep.c, stty.c: + * sync.c, test.c, tsort.c, unlink.c, uptime.c, users.c, whoami.c, yes.c: + Similarly, cast NULL to `(char *)' in call to variadic function, + parse_long_options, so that it works even on systems for which + sizeof char* != sizeof int. + A similar problem was reported by Harti Brandt in + http://mail.gnu.org/archive/html/bug-gnu-utils/2003-10/msg00320.html. + + * src/users.c (users): Free `utmp_buf' explicitly so that people + don't mistake this for a real leak. + Patch by Dennis Smit + + * README: Document _POSIX2_VERSION. + +2003-11-04 Jim Meyering + + * src/tac.c (memrchr): Remove #if-0'd function. + (tac_stdin_to_mem): Clean up #if-0'd code. + + * src/od.c (decode_format_string): Remove unnecessary casts. + Use more maintainable `sizeof *var'. + (main): Call decode_format_string rather than decode_one_format, + now that `spec' may be NULL. + + * src/chmod.c (AUTHORS): Add my name. + + * src/split.c (next_file_name): Use `sizeof *var' rather than + hard-coding `sizeof size_t'. + + * src/sort.c (new_key): Use xzalloc, not xcalloc (1, ...). + + * src/cut.c (ADD_RANGE_PAIR): Use x2nrealloc rather than xrealloc, + to avoid potential overflow in pointer arithmetic. + (set_fields): Use not `1', but rather `sizeof *printable_field' as + second argument to xcalloc. + * src/od.c (decode_format_string, dump_strings): Use x2nrealloc + rather than xrealloc. + * src/date.c (show_date): Likewise. + * src/join.c (ADD_FIELD, initseq, getseq): Likewise. + * src/pr.c (store_char): Likewise. + * src/fold.c (fold_file): Likewise. + + * src/copy.c (triple_hash, triple_hash_no_name): Adjust to reflect + type changes (unsigned int -> size_t) in hash.c. + * src/cp-hash.c (src_to_dest_hash): Likewise. + * src/du.c (entry_hash): Likewise. + * src/ls.c (dev_ino_hash): Likewise. + * src/cut.c (hash_int): Likewise. Declare function as static. + +2003-11-03 Jim Meyering + + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Define PACKAGE_VERSION. + * tests/misc/fold: Fail the test immediately if we're not running + the expected version of fold. + +2003-11-02 Jim Meyering + + * src/tr.c (append_normal_char, append_range, append_char_class) + (append_repeated_char, append_equiv_class, spec_init): Use `sizeof *var' + rather than `sizeof EXPLICIT_TYPE'. The former is more maintainable + and usually shorter. + * src/copy.c (copy_internal): Likewise. + * src/join.c (initseq, add_field, make_blank): Likewise. + * src/od.c (main): Likewise. + * src/cp.c (make_path_private): Likewise. + * src/tsort.c (new_item, record_relation): Likewise. + + * src/df.c (add_fs_type, add_excluded_fs_type, main): Likewise. + (main): Also remove anachronistic cast of xmalloc return value. + * src/ptx.c (alloc_and_compile_regex, main): Likewise. + (main): Also remove anachronistic cast of xmalloc return value. + * src/sort.c (inittables): Likewise. + (sort): Also Split a long line. + +2003-10-25 Jim Meyering + + * src/copy.c (triple_hash, triple_hash_no_name): Adjust to reflect + type changes (unsigned int -> size_t) in hash.c. + * src/cp-hash.c (src_to_dest_hash): Likewise. + * src/du.c (entry_hash): Likewise. + * src/ls.c (dev_ino_hash): Likewise. + * src/cut.c (hash_int): Likewise. Declare function as static. + +2003-10-21 Jim Meyering + + Don't fail when run with VERBOSE=yes. + * tests/chgrp/basic: Do `set +x' before starting the subshell + from which we invoke chgrp. Otherwise, the output from the + VERBOSE=yes-induced `set -x' would result in spurious differences. + Reported by Russel Coker via Michael Stone. + +2003-10-19 Jim Meyering + + chmod now uses fts to perform a directory traversal when -R is + specified. Before, it operated on full path names, and as such + would encounter the PATH_MAX (often 4096) limit. + + * src/chmod.c: Include "xfts.h". + (process_file): Rename from change_file_mode. + Adapt to be used with fts. + (process_files): New function. + +2003-10-18 Jim Meyering + + * tests/du/deref-args: Ensure that du -D now dereferences all + symlinks specified on the command line, not just those that + reference directories. + + * basename.c, cat.c, chroot.c, cksum.c, comm.c, cp.c, csplit.c, cut.c: + * dd.c, df.c, dirname.c, du.c, echo.c, env.c, expr.c, factor.c, head.c: + * hostid.c, hostname.c, id.c, link.c, ln.c, logname.c, ls.c, md5sum.c: + * mv.c, nice.c, nl.c, nohup.c, paste.c, pathchk.c, pinky.c, pr.c: + * printenv.c, printf.c, pwd.c, rm.c, setuidgid.c, sleep.c, sort.c: + * split.c, stty.c, sum.c, sync.c, tac.c, tail.c, tee.c, test.c: + * touch.c, tsort.c, uniq.c, unlink.c, uptime.c, users.c, wc.c: + * who.c, whoami.c, yes.c (AUTHORS): Revert the WRITTEN_BY/AUTHORS change + of 2003-09-19. Now, AUTHORS is a comma-separated list of strings. + Update the call to parse_long_options so that `AUTHORS, NULL' are the + last parameters. + * src/true.c (main): Append NULL to version_etc argument list. + * src/sys2.h (case_GETOPT_VERSION_CHAR): Likewise. + +2003-10-17 Andreas Schwab + + * tests/mk-script: Get $srcdir from first parameter instead of + hardcoding it. + (main): Update usage. + + * tests/Makefile.am.in ($(srcdir)/$x-tests): Pass $(srcdir) as + first argument of mk-script. + ($(srcdir)/Makefile.am): Likewise. Prepend $(srcdir) to target. + +2003-10-17 Jim Meyering + + * src/mv.c (usage): Tweak descriptions of -i and -f so that the + generated `man' page is more readable. Suggestion from Dan Jacobson. + + * src/chown-core.c (change_file_owner): Handle the cases in + which fts_info indicates an error with the given entry. + + * src/du.c (main): Simply assign to bit_flags. + Don't bother with bit arithmetic. + + * tests/chmod/no-x: New file. + * tests/chgrp/no-x: New file. + * tests/chmod/Makefile.am (TESTS): Add no-x. + * tests/chgrp/Makefile.am (TESTS): Likewise. + + * src/du.c: Include "xfts.h". + (du_files): Use xfts_open, rather than fts_open. + * src/chown-core.c (chown_files): Likewise. + +2003-10-16 Jim Meyering + + * src/chgrp.c (main): Simply assign to bit_flags. + Don't bother with bit arithmetic. + * src/chown.c (main): Likewise. + Rename a couple of local variables. + Remove unnecessary casts. + + * src/tail.c (start_bytes): Rename local, remainder, to avoid + gcc's warning about shadowing a global. + +2003-10-15 Jim Meyering + + chown and chgrp now accept POSIX-mandated -H, -L, -P options and + use fts to perform a directory traversal when -R is specified. + Before, they operated on full path names, and as such would + encounter the PATH_MAX (often 4096) limit. + They are more efficient. For example, before, chgrp -R would + take almost 5 seconds to change about 2000 directories and fail + (with `File name too long'), while now it succeeds on a hierarchy + of depth 20,000 in 1/10 the time. + + * src/chown.c: Include "userspec.h" and "fts_.h". + (WRITTEN_BY): Add my name. + (getpwnam, getgrnam, getgrgid): Remove declarations. + (endpwent): Remove definition. + (usage): Update. + (main): Handle new options. + Call new function, chown_files rather than change_file_owner. + + * src/chgrp.c: Include "fts_.h". + (WRITTEN_BY): Add my name. + (MAXUID, MAXGID): Remove definitions. Use GID_T_MAX instead of + the latter. + (usage): Update. + (main): Handle new options. + Call new function, chown_files rather than change_file_owner. + + Rewrite to iterate through hierarchies using fts rather than + via explicit recursion. + * src/chown-core.c: Include "fts_.h" + (change_file_owner): Rewrite to use FTS* and FTSENT* and to operate + on a single file at a time. + (chown_files): New function. + * src/chown-core.h [enum Dereference_symlink]: Remove declaration. + [struct Chown_option] (recurse, force_silent): Change type to `bool'. + [struct Chown_option] (dereference): Remove member with ambiguous name. + [struct Chown_option] (affect_symlink_referent): New member. + (chown_files): New prototype. + + * tests/chgrp/recurse: Update tests accordingly. + * tests/chgrp/posix-H: New tests for the above. + * tests/chgrp/Makefile.am (TESTS): Add posix-H. + + * src/ln.c (usage): Clarify that --directory, -d, -F probably won't + work even for superuser. Suggestion from Dan Jacobson. + +2003-10-14 Paul Eggert + + Fix some number-parsing bugs, e.g., "head -n 100k@" wasn't + properly diagnosed. + * lib/human.c, lib/xstrtoimax.c, lib/xstrtol.c, lib/xstrtol.h, + lib/xstrtoul.c, lib/xstrtoumax.c: Sync with gnulib. + * src/sort.c (parse_field_count): Handle the case where overflow + and invalid suffix char are both reported. + +2003-10-14 Jim Meyering + + * src/ls.c (decode_switches) [TIOCGWINSZ]: Comment out the + warning-inducing test, ws.ws_col <= SIZE_MAX, since it was always + true on Linux. + +2003-10-13 Paul Eggert + + Fix to avoid a denial-of-service attack if the display width is + enormous. Also, clean up the code a bit by removing duplicate code. + + * src/ls.c (init_column_info): Remove forward decl; no longer needed. + (calculate_columns): New function, that contains code that used + to be common to print_many_per_line and print_horizontal. + (print_many_per_line, print_horizontal): Use it. + (decode_switches): Set max_idx here, not in calculate_columns. + (print_current_files): Don't call init_column_info; calculate_columns + now does that. + (init_column_info): Don't allocate a lot more space than is needed + to represent the current set of files. Allocate all the new + size_t cells in one call to xnmalloc, rather than a row at a time. + +2003-10-13 Jim Meyering + + * src/ls.c (init_column_info): Add another FIXME comment. + +2003-10-13 Paul Eggert + + Fix address-arithmetic bug in 'ls', reported by Georgi Guninski. + Remove several arbitrary limits on hosts where int cannot represent + all size_t values. + + * src/ls.c (struct bin_str.len, length_of_file_name_and_frills, indent, + nfiles, files_index, tabsize, line_length, struct column_info.line_len, + struct column_info.col_arr[0], max_idx): + Now size_t, not int. + (get_funky_string): Return bool indicating success, instead of + a negative count to indicate failure. Store number of columns + through new parameter OUTPUT_COUNT; that way, they can never + go negative. Change equals_end from int to bool. All uses + changed. + (struct column_info.valid_len): Now bool, not int. All uses changed. + (dired_dump_obstack, get_funky_string, clear_files, + extract_dirs_from_files, print_current_files, + print_many_per_line, print_horizontal, init_column_info, + put_indicator, length_of_file_name_and_frills, + print_with_commas): Use size_t, not int, for local variables + that count sizes. + (decode_switches): Decode sizes using xstrtoul, not xstrtol. + Check for TIOCGWINSZ returing negative values (or values greater + than SIZE_MAX!). + (visit_dir, main, parse_ls_color, queue_directory, add_ignore_pattern, + init_column_info): + Use xmalloc and xnmalloc, not XMALLOC. + (gobble_file): Use xnrealloc, not XREALLOC. + (print_color_indicator): Remove now-unnecessary cast to size_t. + +2003-10-12 Paul Eggert + + * tests/du/no-x: Change wording of diagnostic to match latest du.c. + * tests/sort/sort-tests: Remove from CVS; assume that people + brave enough to check coreutils out from CVS can rebuild it. + +2003-10-12 Jim Meyering + + New options: --preserve-root and --no-preserve-root. + * src/chmod.c (change_file_mode): Honor new option. + (change_file_mode): Strip trailing slashes on directory + argument passed to change_dir_mode. + (get_root_dev_ino): New function. + (main): Initialize global, root_dev_ino. + + * src/copy.c (copy_internal): Don't #ifdef-out simple uses of + S_ISLNK or S_ISSOCK. The S_IS* macros are guaranteed to be defined + via system.h. + * src/chmod.c (change_file_mode): Likewise. + +2003-10-08 Jim Meyering + + * src/csplit.c (main): Remove obsolete FIXME. + +2003-10-07 Jim Meyering + + * Use automake-1.7.8. Regenerate dependent files. + +2003-09-29 Paul Eggert + + csplit cleanup. + + * doc/coreutils.texi (csplit invocation): + The regexp offset need not have a sign; POSIX requires support + for signless offets. + + Be more careful about int widths. For example, remove some + arbitrary limits by replacing 'unsigned' with 'size_t', + 'uintmax_t', etc. Use standard bool rather than a homegrown type. + * lib/Makefile.am (libfetish_a_SOURCES): Add xstrtoimax.c. + * src/csplit.c (FALSE, TRUE, boolean): Remove. All uses changed + to usage. + (struct control): offset is now intmax_t, not int. + repeat_forever is now bool, not int. + (struct cstring): len is now size_t, not unsigned int. + (struct buffer_record): bytes_alloc, bytes_used, num_lines are now + size_t, not unsigned. start_line, first_available are now + uintmax_t, not unsigned. + (hold_count, control_used): Now size_t, not unsigned. + (last_line_number, current_line, bytes_written): + Now uintmax_t, not unsigned. + (save_to_hold_area, red_input, keep_new_line, record_line_starts, + create_new_buffer, get_new_buffer, load_buffer, find_line, + process_regexp, split_file, new_control_record, extract_regexp, + get_format_width, get_format_prec, max_out): + size args, locals, and returned values are now size_t, not unsigned + or int. + (get_first_line_in_buffer, find_line, write_to_file, + handle_line_error, process_line_count, regexp_error, process_regexp, + split_file): + File line, byte, and repetition counts are now uintmax_t, not unsigned. + (check_for_offset): Don't require a sign before the offset. + Use xstrtoimax to do the real work. + (extract_regexp): Remove harmful cast of size to unsigned. + 256 -> 1< + + * src/chown-core.c (change_file_owner): Remove set-but-not-used local. + + * src/du.c (du_files): Mark diagnostic for translation. + +2003-10-04 Jim Meyering + + * src/du.c (du_files): Ignore any failure of fts_close. + Give better diagnostics for failed fts_open. + + * src/du.c (MAX_N_DESCRIPTORS): Remove now-unused definition. + + Deprecate existing use of -H (aka --si). + * src/du.c (enum) [HUMAN_SI_OPTION]: New member. + [long_options]: Use HUMAN_SI_OPTION, not 'H'. + (main): Warn that the meaning of -H will soon change to be + POSIX compliant. + +2003-10-03 Jim Meyering + + * src/du.c: Accept --no-dereference (-P). + +2003-10-02 Jim Meyering + + * tests/du/trailing-slash: Adjust for slightly different output. + + Rewrite du.c to use fts. + * src/du.c: Include "fts_.h", not ftw.h. + (opt_dereference_arguments, arg_length, suffix_length): Remove globals. + (IS_FTW_DIR_TYPE): Remove definition. + (IS_DIR_TYPE): Define. + (is_symlink_to_dir): Remove now-unnecessary function. + (process_file, du_files): Rewrite to use fts. + + * tests/du/inaccessible-cwd: Ensure that even when run from an + inaccessible directory, du can still operate on accessible + directories elsewhere. + * tests/du/Makefile.am (TESTS): Add inaccessible-cwd. + + * tests/rm/deep-1: Ensure that du can process a hierarchy + of depth 400 while using no more than 50KB of stack space. + +2003-10-01 Akim Demaille + + * announce-gen (print_news_deltas): New function, extracted from main. + (main): Make `news_file' an array. + Use '...=s' => \@var for --news and --url-directory specs. + Before there were a couple of portability problems. + +2003-09-28 Jim Meyering + + * Makefile.maint (sc_cast_of_alloca_return_value): New rule. + (syntax-check-rules): Add it. + + * src/copy.c: Remove unnecessary cast of alloca, since now it's + guaranteed to be (void *). + * src/cp.c: Likewise. + * src/join.c: Likewise. + * src/ln.c: Likewise. + * src/ls.c: Likewise. + * src/od.c: Likewise. + * src/sys2.h (ASSIGN_STRDUPA): Likewise. + +2003-09-27 Jim Meyering + + Don't exhaust virtual memory when processing large inputs. + Fix this by removing csplit's internal free-list management; + instead rely on malloc for that. + + * src/csplit.c (free_list): Remove global. + (clear_all_line_control): Remove function. + (get_new_buffer): Always use create_new_buffer to obtain a + new buffer, rather than searching free_list. + (free_buffer): Just call free. + Reported by Nikola Milutinovic. + +2003-09-26 Jim Meyering + + * man/rm.x: Also list `chattr' in SEE ALSO section. + Suggestion from Mark Hubbart. + +2003-09-25 Jim Meyering + + * configure.ac: Don't invoke AC_AIX or AC_MINIX explicitly, now + that we use gl_USE_SYSTEM_EXTENSIONS, since it AC_REQUIREs them. + + * Use autoconf-2.57d. Regenerate dependent files. + +2003-09-24 Jim Meyering + + Minor efficiency tweak. + * src/ln.c (PATH_BASENAME_CONCAT): Use memcpy rather than strcpy. + (do_link): Likewise. + +2003-09-23 Jim Meyering + + * src/paste.c (paste_serial): Save errno after input error, + to report proper errno value. + Based on a patch from Paul Eggert. + + * src/tee.c (tee): Adjust fwrite arguments so that the return + value is the number of bytes written. + +2003-09-16 Paul Eggert + + Don't assume ferror sets errno. Bug reported by Bruno Haible. + + * src/comm.c (compare_files): Save errno after input error, + to report proper errno value. + * src/fold.c (fold_file): Likewise. + * src/od.c (check_and_close, skip, read_char, read_block): Likewise. + * src/unexpand.c (unexpand): Likewise. + + * src/csplit.c (close_output_file): Don't report bogus errno value + after ferror discovers an output error. We don't know the proper + errno value, since it might have been caused by any of a whole + bunch of calls, and it might have been trashed in the meantime. + Fixing this problem will require much more extensive changes; + in the meantime just say "write error". + * src/od.c (check_and_close, dump, dump_strings): Likewise. + * src/uniq.c (check_file): Likewise. + + * src/join.c (get_line): Report error right away if I/O fails, + so that the proper errno value is used. + * src/tac.c (tac_seekable, tac_file, save_stdin): Likewise. + * src/tee.c (tee): Likewise. + * src/uniq.c (check_file): Likewise. + + * src/od.c (skip): If a read fails, don't retry it later, so + that we report the proper errno. + + * src/tac.c (tac_mem): Don't return a value; nobody uses it. + + * src/tee.c (tee): Once a write failure has occurred, don't bother + writing anything more to that stream. + + * src/uniq.c (check_file): Check for ferror (stdout) even if + ostream == stdout. + + * src/yes.c (UNROLL): Remove. + (main): Exit immediately when write failure is detected. + Simplify code by assigning to argv when argc == 1. + +2003-09-21 Paul Eggert + + * src/ptx.c: Switch encoding from Latin-1 to UTF-8. + (WRITTEN_BY): Change "Franc,ois" (actually using + c-with-cedilla in Latin-1) to "F.", so that it's ASCII, as + xgettext requires. + +2003-09-19 Jim Meyering + + `du -D symlink-to-dir' would mistakenly omit the slash in + lines like this: 24 symlink-to-dir/subdir + * src/du.c (process_file): Fix offset calculation. + Reported by Jeff Sheinberg as Debian bug #211591; + http://bugs.debian.org/205251 + + * tests/du/deref-args: New file/test for the above. + * tests/du/Makefile.am (TESTS): Add deref-args. + + * src/du.c (process_file): Remove useless disjunct. + + * src/sys2.h (case_GETOPT_VERSION_CHAR): Rename parameter, Authors, + to Written_by. + * nearly all src/*.c files (WRITTEN_BY): Rename from AUTHORS. + Begin each WRITTEN_BY string with `Written by ' and end it with `.'. + Mark each WRITTEN_BY string as translatable. + + * basename.c, cat.c, chroot.c, cksum.c, comm.c, cp.c, csplit.c, cut.c: + * dd.c, df.c, dirname.c, du.c, echo.c, env.c, expr.c, factor.c, head.c: + * hostid.c, hostname.c, id.c, link.c, ln.c, logname.c, ls.c, md5sum.c: + * mv.c, nice.c, nl.c, nohup.c, paste.c, pathchk.c, pinky.c, pr.c: + * printenv.c, printf.c, pwd.c, rm.c, setuidgid.c, sleep.c, sort.c: + * split.c, stty.c, sum.c, sync.c, tac.c, tail.c, tee.c, test.c: + * touch.c, tsort.c, uniq.c, unlink.c, uptime.c, users.c, wc.c: + * who.c, whoami.c, yes.c: Revert yesterday's changes. + Instead, a subsequent change will embed `Written by ' in + each string along with the author names. + + * src/true.c: Revert yesterday's changes. + * src/sys2.h: Likewise. + +2003-09-18 Jim Meyering + + * basename.c, cat.c, chroot.c, cksum.c, comm.c, cp.c, csplit.c, cut.c: + * dd.c, df.c, dirname.c, du.c, echo.c, env.c, expr.c, factor.c, head.c: + * hostid.c, hostname.c, id.c, link.c, ln.c, logname.c, ls.c, md5sum.c: + * mv.c, nice.c, nl.c, nohup.c, paste.c, pathchk.c, pinky.c, pr.c: + * printenv.c, printf.c, pwd.c, rm.c, setuidgid.c, sleep.c, sort.c: + * split.c, stty.c, sum.c, sync.c, tac.c, tail.c, tee.c, test.c: + * touch.c, tsort.c, uniq.c, unlink.c, uptime.c, users.c, wc.c: + * who.c, whoami.c, yes.c: Update AUTHORS definition to be a + comma-separated list of strings and/or update the call to + parse_long_options so that `AUTHORS, NULL' are the last parameters. + * src/true.c (main): Append NULL to version_etc argument list. + * src/sys2.h (case_GETOPT_VERSION_CHAR): Likewise. + + * src/sort.c (numcompare): Rename local, logb, to log_b to avoid + shadowing the math function name. Also rename loga to log_a. + +2003-09-14 Jim Meyering + + * src/factor.c (print_factors): Give a separate diagnostic + for numbers that are too large, but otherwise valid. + Reported by Dániel Varga. + +2003-09-10 Jim Meyering + + * Use automake-1.7.7. Regenerate dependent files. + + * tests/Makefile.am (all_programs): Use ../src/tr -s ' ' '\n' in place + of `fmt -1'. Using the just-built tr is a little cleaner. + Christian Krackowizer reported that HPUX 10.20 doesn't have fmt. + * man/Makefile.am (programs, check-x-vs-1): Likewise. + +2003-09-09 Jim Meyering + + * src/copy.c: Alphabetize includes. + Remove duplicate inclusion of "same.h". + +2003-09-08 Jim Meyering + + * Makefile.maint (GZIP_ENV): Remove --rsyncable. + Didn't give enough of a benefit, mainly because it's not yet + in wide enough use. + + * Version 5.0.91. + + * man/Makefile.am (programs): Use ../src, not $(srcdir)/../src. + (check-programs-vs-x): Fail if $(programs) is empty. + + * src/remove.c: Add a comment. + +2003-09-07 Jim Meyering + + * src/remove.c (D_INO, ENABLE_CYCLE_CHECK) [D_INO_IN_DIRENT]: + Don't define. These symbols are no longer used. + + * tests/misc/tty-eof: Write ^D as \cD. + Complete the change of 2003-08-02. + + * Makefile.maint (po-check): Use cvsu, so that a temporary source + file in lib/ or src/ doesn't induce an unwarranted failure. + Add a kludge to filter out the sole generated source file that + also has translatable messages: src/false.c. + +2003-09-06 Jim Meyering + + * src/tail.c (enum): Add ALLOW_MISSING_OPTION. + (parse_options): Give a diagnostic for (but still accept) the + deprecated --allow-missing option. + +2003-09-04 Paul Eggert + + Don't ignore -S if input is a pipe. Bug report by Michael McFarland in + . + + * src/sort.c (sort_buffer_size): Omit SIZE_BOUND arg. Compute the + size_bound ourselves. if an input file is a pipe and the user + specified a size, use that size instead of trying to guess the + pipe size. This has the beneficial side effect of avoiding the + overhead of default_sort_size in that case. All callers changed. + (sort): Remove static var size; now done by sort_buffer_size. + +2003-09-05 Jim Meyering + + * Use automake-1.7.6b and autoconf-2.57b. Regenerate dependent files. + + * tests/tail-2/tail-n0f: Wait .5 seconds for backgrounded process + to start, rather than just .1. Upon failure, print unexpected state. + +2003-09-04 Paul Eggert + + * src/head.c (elide_tail_lines_pipe): Don't assign 0 or + SAFE_READ_ERROR to tmp->nbytes. + * src/tail.c (pipe_lines, pipe_bytes): Likewise. + + * src/head.c (struct linebuffer): Change nbytes and nlines + from unsigned int to size_t. unsigned int is safe (after the + 2003-09-03 patch) but size_t is cleaner. + * src/tail.c (struct linebuffer, struct charbuffer): Likewise. + (pipe_bytes): Likewise for local variable 'i', which was 'int'. + + Standardize on BUFSIZ as opposed to other macro names and values. + * src/head.c (BUFSIZE): Remove. All uses changed to BUFSIZ. + * src/tail.c (BUFSIZ) [!defined BUFSIZ]: Remove. + stdio.h has always defined it, + and other code already assumes it's defined. + * src/tr.c (BUFSIZ) [!defined BUFSIZ]: Likewise. + (IO_BUF_SIZE): Remove; replace all uses with sizeof io_buf. + (io_buf): IO_BUF_SIZE -> BUFSIZ. + +2003-09-04 Paul Eggert + + * src/seq.c (step): Default to 1. + (print_numbers): Allow the output to be empty. + (main): The default step is 1, even if LAST < FIRST; + as per documentation. + * tests/seq/basic (onearg-2): Output should be empty. + +2003-09-05 Jim Meyering + + * Makefile.cfg (wget_files): Temporarily disable, until master + versions are restored to ftp.gnu.org. + + * configure.ac (AM_INIT_AUTOMAKE): Specify automake-1.7.6. + + Make seq's --width (-w) option work properly even when the + endpoint requiring the larger width is negative and smaller than + the other endpoint. + * src/seq.c (get_width_format): Include `-' in the set of bytes + allowed in a `simple' number (no decimal point, no exponent). + Reported by Patrick Mauritz. + +2003-09-02 Paul Eggert + + * NEWS: sort -t '\0' now uses a NUL tab. + sort option order no longer matters, unless POSIX requires it. + * src/sort.c (usage): Say "blanks" instead of "whitespace", + Similar fixes for many comments. + (TAB_DEFAULT): New constant, so that we can support NUL as + the field separator. + (tab): Now int, not char. Initialize to TAB_DEFAULT. + (specify_sort_size): If multiple sizes are specified, use the largest. + (begfield, limfield): Support NUL tab char. + (set_ordering): Do not let -i override -d. + (main): Report an error if incompatible -o or -t options are given. + Report an error for "-t ''". Allow "-t '\0'" to specify a NUL tab. + +2003-09-05 Jim Meyering + + * tests/sort/Test.pm [o2, nul-tab]: New tests for the above. + +2003-09-03 Andreas Schwab + + Bug report and patch here: + + * src/tail.c (pipe_lines): Don't truncate return value from safe_read. + * src/head.c (elide_tail_lines_pipe): Likewise. + +2003-09-03 Jim Meyering + + * src/du.c (AUTHORS): Remove Larry McVoy's name, since the relatively + small amount of code from him was first moved to lib/human.c, and was + subsequently rewritten entirely. + * src/df.c (AUTHORS): Likewise. + +2003-08-22 Lawrence Teo + + * src/md5sum.c (split_3): Accept the BSD format for generic + message digest modes. Currently works with BSD's MD5 and SHA1 + formats since these are the two algorithms presently used in + coreutils. Updated comments to reflect this change. + (bsd_split_3): Updated comments. + + * tests/md5sum/basic-1: New test to make sure that + `md5sum --check' doesn't accept the BSD SHA1 format (adapted + from `check-bsd' test in tests/sha1sum/basic-1). + + * tests/sha1sum/basic-1 (check-bsd2, check-bsd3): New tests for + --check exit status and BSD SHA1 format (adapted from tests + in tests/md5sum/basic-1). + +2003-08-30 Jim Meyering + + * src/ln.c (do_link): Use SAME_INODE rather than open-coding it. + + When source and destination arguments refer to the same file, reside + on a partition (e.g. VFAT) on which distinct names may refer to the + same directory entry (often due to variations in case), and when the + link count for the file is 1, mv no longer unlinks the file. Instead, + it gives the expected diagnostic that the source and destination are + the same. WARNING: this is an incomplete fix. If the file happens + to have a link count of 2 or greater, such an erroneous mv command + will still unlink it. + Although that is not possible on vfat or umsdos, it is possible on + other file system types, e.g., ntfs, and hpfs. + * src/copy.c (same_file_ok): Invoke same_name (which might still + return false for names that refer to the same directory entry) + only if the link count is 2 or more. + * tests/mv/vfat: Show how to demonstrate the above problem. + This test is not run. + * tests/mv/Makefile.am (EXTRA_DIST): Add vfat. + +2003-08-27 Jim Meyering + + * src/who.c: Change meaning of -l from --lookup to --login, per POSIX. + who's -l option has been eliciting an unconditional warning about + this impending change since sh-utils-2.0.12 (April 2002). + + * src/paste.c (paste_parallel): Don't output `EOF' (aka -1) as a `char'. + This would happen for nonempty files not ending with a newline. + Reported by Dan Jacobson. + * tests/misc/paste-no-nl: New file. Test for above-fixed bug. + * tests/misc/Makefile.am (TESTS): Add paste-no-nl. + + * src/stat.c (print_it): Avoid buffer overrun that would + occur when the user-specified format string ends with `%'. + Patch by Tommi Kyntola. + * tests/misc/stat-fmt: New file. Test for above-fixed bug. + * tests/misc/Makefile.am (TESTS): Add stat-fmt. + +2003-08-26 Jim Meyering + + Apply changes from bison. + * GNUmakefile (SHELL): Define to `sh', if necessary. + Add copyright. + * Makefile.maint (WGETFLAGS): Define to `-C off'. + Update all uses of $(WGET). + +2003-08-22 Akim Demaille + + * Makefile.cfg (local-checks-to-skip): New. + * Makefile.maint (local-check): Rename as... + (local-checks-available): this. + (local-check): New. + +2003-08-26 Akim Demaille + + * announce-gen (print_changelog_deltas): Neutralize "<#" as + "<\#" to avoid magic from Gnus when posting parts of this script. + +2003-08-25 Jim Meyering + + * src/stat.c (main): Warn about use of deprecated `-l' option. + +2003-08-22 Jim Meyering + + * src/stat.c (do_stat): For link count at end of line, use %h format, + instead of %-5h. The latter would make stat emit trailing spaces. + Reported by Dan Jacobson. + +2003-08-20 Jim Meyering + + * Makefile.am (EXTRA_DIST): Add .x-sc_space_tab .x-sc_sun_os_names + +2003-08-19 Jim Meyering + + * src/system.h: Include stdlib.h unconditionally, + as we're now assuming that part of hosted C89. + +2003-08-18 Jim Meyering + + * src/sys2.h (textdomain, bindtextdomain) [! ENABLE_NLS]: Define away, + to avoid warnings from gcc. + +2003-08-17 Jim Meyering + + Avoid unnecessary and sometimes time-consuming hostname lookups. + * src/who.c (print_user): Use strchr, not strrchr. + * src/pinky.c (print_entry): Likewise. + Patch by Michael Stone. + This fixes a typo I introduced in who-users.c on 1996-02-23. + + * Makefile.maint (makefile-check): Add 0-9 to the range of characters + disallowed between `@...@'. + +2003-08-16 Paul Eggert + + * configure.ac (fu_cv_sys_truncating_statfs): Remove; now + done by gnulib .m4 files. + (jm_DUMMY_1): Require gl_READUTMP, not jm_PREREQ_READUTMP. + * src/sys2.h (strtoull): Remove unused declaration. + +2003-08-16 Jim Meyering + + * man/Makefile.am (.x.1): Ensure that generated PROGRAM.1 files + are read-only. + + * src/tail.c (tail_lines): Fix a potential (but very hard to exercise) + race condition bug. The bug would be triggered when tailing a file + with file pointer not at beginning of file, and where the file was + truncated to have a length of less than the initial offset at just + the right moment (between the two lseek calls in this function). + + An invalid initial value for *read_pos would result in + `tail -n0 -f FILE' and `tail -c0 -f FILE' doing what amounted to a + busy-wait rather than sleeping between iterations. The bug manifests + itself only when tailing regular files that are initially nonempty. + * src/tail.c (tail_bytes): Set *read_pos to new file offset after + each xlseek call. + (tail_lines): Likewise, after lseek calls. + Reported by Nick Estes. See http://bugs.debian.org/205251 for details. + * tests/tail-2/tail-n0f: New file. Test for above fix. + * tests/tail-2/Makefile.am (TESTS): Add tail-n0f. + +2003-08-15 Jim Meyering + + * Makefile.maint (sc_space_tab): Use exclusion list in separate file. + (sc_sun_os_names): Likewise. + * .x-sc_space_tab, .x-sc_sun_os_names: New files. + + * man/help2man: Remove some SPACEs before TAB. + +2003-08-14 Paul Eggert + + * Makefile.maint (LC_ALL): Set to C. + * man/Makefile.am (ASSORT): New var. + (check-x-vs-1, programs): Use it. + * src/Makefile.am (ASSORT, check-README, ../AUTHORS): Likewise. + * tests/Makefile.am (ASSORT, all_programs): Likewise. + +2003-08-11 Jim Meyering + + fold -s -wN would infloop for N < 8 with TABs in the input. + E.g., this would not terminate: printf 'a\tb' | fold -w2 -s + * src/fold.c (fold_file): Move contents of `else'-block + out of conditional so it's used also for --spaces (-s). + * tests/misc/fold: Test for the above fix. + * tests/misc/Makefile.am (TESTS): Add fold. + +2003-08-10 Jim Meyering + + * src/nice.c [!NICE_PRIORITY]: Include after + system.h so the types from time.h and sys/time.h are available. + It appears that this is necessary for OpenBSD, NetBSD, and + Darwin 6.5 (MacOS 10.2.5). Reported by Nelson Beebe. + +2003-08-06 Paul Eggert + + * NEWS: Add support for setting file timestamps to microsecond + resolution, on hosts that support this. + * src/copy.c, src/cp.c, src/install.c, src/touch.c: Include utimens.h. + * src/copy.c (copy_internal): + Set file timestamps with utimens, not utime. + * src/cp.c (re_protect): Likewise. + * src/install.c (change_timestamps): Likewise. + * src/touch.c (newtime, touch, main): Likewise. + +2003-08-09 Jim Meyering + + * Makefile.maint (sc_sun_os_names): New rule based on a regexp + from Paul Eggert. + (syntax-check-rules): Add it. + + * src/tail.c (main): Tweak Solaris OS version number in comment. + * src/wc.c (wc): Likewise + * tests/tail-2/fflush: Likewise. + + * src/tail.c: Add new undocumented option, --presume-input-pipe. + (pipe_lines): Use memchr to skip lines, rather than an explicit loop. + +2003-08-08 Paul Eggert + + Use new gnulib 'extensions' module. + * configure.ac: Invoke gl_USE_SYSTEM_EXTENSIONS instead of + AC_GNU_SOURCE. + +2003-08-08 Paul Eggert + + * tests/du/basic: Ensure that a/b/F has at least 65 bytes too. + +2003-08-09 Jim Meyering + + * tests/misc/split-fail: Reflect that `split -a 0' is now accepted. + For tests of obsolete behavior, don't presume that unsetting + _POSIX2_VERSION is equivalent to _POSIX2_VERSION=199209. + +2003-08-07 Paul Eggert + + * doc/coreutils.texi (split invocation): + Add -d or --numeric-suffixes option to 'split'. + From a suggestion by Jesse Kornblum. + * src/split.c (suffix_alphabet): New var. + (longopts, usage, next_file_name, main): Support -d. + (next_file_name, main): Allow -a0, as POSIX requires. + (next_file_name): Don't assume ASCII-like encoding; + 'a' through 'z' are not contiguous in EBCDIC. + +2003-08-05 Paul Eggert + + Merge getline from gnulib. + * lib/getline.h, lib/getline.c, m4/getline.m4: Merge from gnulib. + * lib/getndelim2.h, lib/getndelim2.c, m4/getndelim2.m4, m4/ssize_t.m4: + New files, from gnulib. + * lib/getdelim2.c, lib/getdelim2.h: Remove. + * lib/Makefile.am (libfetish_a_SOURCES): Change getdelim2.c and + getdelim2.h to getndelim2.c and getndelim2.h. + * m4/jm-macros.m4 (jm_MACROS): Use gl_GETNDELIM2 rather than + checking for getdelim. + (jm_CHECK_ALL_TYPES): Use gt_TYPE_SSIZE_T for ssize_t rather + than rolling our own. + * src/cut.c: Include getndelim2.h rather than getdelim2.h. + (cut_fields): Invoke getndelim2 rather than getdelim2. + +2003-08-04 Jim Meyering + + * src/sort.c (main): Use unsigned int instead of int for `nsigs' + and for the indices to iterate through nsigs. + +2003-08-02 Paul Eggert + + * src/sort.c: Minor code cleanups, mostly to use more accurate + types and to remove unnecessary casts. + (min, max): Remove. All uses changed to MIN and MAX. + (hard_lc_collate, hard_LC_TIME, struct buffer.eof, struct + keyfield.skipsblanks, struct keyfield.skipeblanks, struct + keyfield.numeric, struct keyfield.general_numeric, struct + keyfield.month, struct keyfield.reverse, reverse, unique, + have_read_stdin): Now bool, not int. All uses changed. + (eolchar): Now char, not int. + (struct keyfield.ignore): Now bool const *, not int *. + (struct keyfield.translate): Now char const *, not char *. + (struct month.name): Likewise. + (blanks, nonprinting, nondictionary): Now bool[], not int[]. + (cleanup, inittables, keycompare, check, mergefps, first_same_file, + check, sort, main): Use const * pointers when possible. + (month_cmp): Rewrite to avoid casts. + (inittables): Initialize tables unconditionally, to avoid branches. + (fillbuf): Return bool, not int. All uses changed. + (fillbuf, keycompare, new_key, main): + Use SIZE_MAX rather than (size_t) -1. + (trailing_blanks): Renamed from trim_trailing_blanks. + Return the number of blanks to trim. All uses changed. + (getmonth): Use trailing_blanks rather than open code. + (keycompare): Do not cast char * to unsigned char *; not needed. + CMP_WITH_IGNORE converts args to UCHAR, so no need to convert it + ourselves. + (compare, main): Use | rather than || to avoid jumps. + Replace "diff = NONZERO (alen)" with "diff = 1", since alen must + be nonzero there. + (check, first_same_file, sort, main): + Use bool instead of int local vars when possible. + (check): Merge the old 'checkfp' and 'check' into a single function, + that returns a boolean (true if the file was ordered). + All uses changed. + (main): Use int instead of unsigned for iterating through nsigs. + Rename local var "posix_pedantic" to "posixly_correct". + +2003-08-02 Jim Meyering + + * src/nice.c [!NICE_PRIORITY]: Include before + to avoid compilation error on Ultrix. Reported by Christian Krackowizer. + + * src/cut.c (cut_fields): Don't read again after encountering an + initial EOF. E.g., `cut -f2' would do so. + * tests/misc/tty-eof: Add a test for the above fix. + + * src/sort.c (sortlines): Add description and references. + From Paul Eggert. + + * tests/Makefile.am (TESTS_ENVIRONMENT): Set PATH so that + the tests in help-version will use the just-built binaries. + Reported by Christian Krackowizer. + +2003-07-31 Paul Eggert + + * NEWS: Add --rfc-2822 option to GNU date. + * doc/coreutils.texi (Time directives, Options for date, Examples + of date): Likewise. + * src/date.c (long_options, usage, main): Likewise. + * doc/getdate.texi (General date syntax): Likewise. + * doc/coreutils.texi (Options for date): Fix a typo in format: + it's now %d not %_d. Add URLs. + +2003-08-01 Jim Meyering + + * tests/shred/remove: Ensure that $? is 0 for the final `exit 0'. + Otherwise, with at least the /bin/sh from HPUX 10.20, + the trap code would end up converting that to exit 1 and thus an + unexpected test failure. Reported by Christian Krackowizer. + +2003-07-31 Paul Eggert + + * src/ptx.c: Do not include bumpalloc.h. + (WORD_TABLE): New member alloc. + (ALLOC_NEW_WORD): Remove. + (occurs_alloc): New var. + (digest_word_file, find_occurs_in_text): Check for arithmetic + overflow when computing table size. Use xrealloc rather than + bumpalloc primitives. + +2003-07-29 Jim Meyering + + * Version 5.0.90. + + * README: When running tests as root, suggest using + sudo with NON_ROOT_USERNAME=$USER. + + * tests/Makefile.am (all_programs): Makefile is in ../src, not + $(srcdir)/../src. + +2003-07-28 Jim Meyering + + * Makefile.maint (GZIP_ENV): Try Debian/gzip's new --rsyncable option. + +2003-07-28 Paul Eggert + + * lib/stdbool.hin (_Bool): Make it signed char, instead of + an enum type, so that it's guaranteed to promote to int. + * src/sort.c (sortlines_temp): Undo previous change. + +2003-07-28 Jim Meyering + + * src/sort.c (sortlines_temp): Declare local `swap' to be `int', not + `bool'. Otherwise, at least one buggy compiler (alpha gcc-2.95.4) + would cause lines[-1 - swap] (with swap = false) to evaluate to + lines[4294967295]. + +2003-07-27 Jim Meyering + + * tests/priv-check (my_uid): Use `!', not `^' in case pattern `[!0-9]', + since /bin/sh of at least NetBSD 1.6 and OpenBSD 3.2 don't accept `^'. + + * src/remove.c (prompt) [! recursive]: Don't prompt about unwritable + directories, as required by POSIX. Reported by Karl Berry. + * tests/rm/dir-no-w: New file. Test for the above fix. + * tests/rm/Makefile.am (TESTS): Add dir-no-w. + + * tests/mk-script: Emit `$xx', not its expansion. + +2003-07-27 Paul Eggert + + This change was inspired by a similar proposal by Stepan Kasal. + * src/sort.c (mergelines, sortlines_temp): New functions. + (sortlines): Use them, to reduce the number of times that + we need to copy 'struct line' values. This improved CPU + performance by about 30% on one 18 MB test. + (sort): Don't invoke sortlines unless we have 2 or more lines. + +2003-07-26 Stepan Kasal + + * src/sort.c (sort): Don't require two `struct line's per text line, + the new sort algorithm requires just 1.5. + +2003-07-27 Jim Meyering + + * src/pathchk.c (validate_path): Use %lu, not %ld. + From Paul Eggert. + * src/cut.c (is_printable_field): Simplify bit arithmetic. + From Paul Eggert. + * src/ls.c (sort_files): Put `volatile' in the right place. + From Paul Eggert. + +2003-07-26 Jim Meyering + + Use only one bit per field/offset in array, not one `int'. + * src/cut.c (printable_field): Change type to `unsigned char'. + (mark_printable_field, is_printable_field): New functions. + Use them in place of all direct accesses of `printable_field'. + + * src/expand.c (parse_tabstops): Detect overflow properly. + * src/cut.c (set_fields): Likewise. + + * src/rm.c: Include "dirname.h". + (usage): Use base_name (program_name) in body of --help output. + This lets me... + * man/Makefile.am (.x.1): ...back out the kludge of 2003-07-22. + Idea from Brendan O'Dea, who suggested using + `program_name = basename (argv[0]);' everywhere -- + can't do that, but using base_name works just fine here. + + * src/Makefile.am (AM_INSTALLCHECK_STD_OPTIONS_EXEMPT): Exempt test. + +2003-07-24 Paul Eggert + + Fix some POSIX-compliance problems with 'test'. This makes + 'test' more compatible with Bash. + + * NEWS, doc/coreutils.texi: Document the following. + * src/test.c: Include exitfail.h. + (TEST_FAILURE): New constant, used for exit status if 'test' fails. + (test-syntax_error): Use it. + (binary_operator): Now takes bool arg specifying whether left operand + is -l ARG, so that caller determines this rather than us. + All uses changed. + (term): Use posixtest to evaluate parenthesized subexpressions. + (unary_operator, one_argument): Remove support for -t without operand. + (one_argument): Take argument from argv[pos]. + (one_argument, two_arguments, three_arguments): Advance pos. + All callers changed. + (three_arguments): Look for binary ops before "!". Then look + for parenthesized one_argument expressions, instead of trusting + expr () to do the right thing. + (posixtest): Now takes number of args. All callers changed. + Treat "( A B )" like "A B". + (main): Set exit_failure to TEST_FAILURE. Don't depend on + POSIXLY_CORRECT, as we now conform to POSIX by default. + (main) [!LBRACKET]: Do not recognize "--help" or "--verbose" unless. + * tests/test/Test.pm (test_vector): Add several tests to check + the above. Syntax errors now exit with status 2, not 1. + * man/Makefile.am (mapped_name): Use `../src/[' binary to create test.1. + +2003-07-26 Jim Meyering + + * tests/help-version: Adjust for above change in test behavior: + `[' exits with 2, not 1, and test doesn't accept --help or --version. + + * Makefile.maint (ME): Don't use trick suggested in Make manual. + It doesn't work for make-3.79.1. Reported by Christian Krackowizer. + + * Makefile.maint (sc_system_h_headers): Another syntax check. + (syntax-check-rules): Add it to the list. + + * src/pathchk.c (validate_path): Cast strlen value to `unsigned long' + so it matches `%ld' format even on 32-bit systems. + + * src/fmt.c (flush_paragraph): Cast field width to `int' to + avoid warning on 64-bit systems. + + * src/ls.c (sort_files): Make `func' volatile, so it can't be + clobbered by a `longjmp' into this function. + +2003-07-25 Jim Meyering + + * src/pathchk.c (validate_path): Use %ld format (not %d) for size_t + value. + + * tests/misc/split-fail: Disable the --line-bytes=$_4gb test, + because it'd evoke spurious failure on 64-bit systems. + +2003-07-24 Jim Meyering + + * src/dd.c (usage): Document the fact that SIGUSR1 makes dd + output its current record counts. Reported by Jurriaan. + + * tests/wc/Test.pm (test_vector): Disable the `PIPE' tests when running + `wc' with no options. This goes along with the change of 2003-07-20. + +2003-07-23 Jim Meyering + + Don't include headers already included by system.h: + * src/tr.c: Don't include errno.h. + * src/true.c: Don't include version-etc.h. + * src/test.c: Don't include limits.h or error.h. + * src/stat.c: Don't include unistd.h or time.h. + * src/readlink.c: Don't include stdlib.h, unistd.h, or limits.h. + * src/pr.c: Don't include time.h. + * src/pathchk.c: Don't include errno.h. + * src/nice.c: Don't include sys/time.h. + * src/ls.c: Don't include stdlib.h. + + * basename.c, cat.c, chroot.c, cksum.c, comm.c, csplit.c, cut.c, date.c: + * dd.c, dirname.c, echo.c, env.c, expand.c, expr.c, factor.c, fmt.c: + * fold.c, head.c, hostid.c, hostname.c, id.c, join.c, kill.c, logname.c: + * md5sum.c, nice.c, nl.c, nohup.c, od.c, paste.c, pathchk.c, pinky.c: + * pr.c, printenv.c, printf.c, ptx.c, pwd.c, seq.c, setuidgid.c, shred.c: + * sleep.c, sort.c, split.c, stat.c, stty.c, su.c, sum.c, tac.c, tail.c: + * tee.c, test.c, tr.c, true.c, tsort.c, tty.c, uname.c, unexpand.c: + * uniq.c, uptime.c, users.c, wc.c, who.c, whoami.c, yes.c: + Don't include closeout.h. + + * tests/rm/fail-2eperm: Add a check for whether $NON_ROOT_USERNAME + can access the required version of rm. + * tests/rm/Makefile.am (TESTS_ENVIRONMENT): Define PACKAGE_VERSION. + + * tests/cut/Test.pm (out-delim3a): New test. + + * man/help2man: Update to version 1.33. + + * src/expand.c (parse_tabstops): Detect overflow in tabstop sizes. + + * src/dircolors.c: Include xstrndup.h. + (xstrndup): Remove function, now that it's been factored out into + it's own file. + +2003-07-22 Paul Eggert + + * src/wc.c (wc): Fix typo in computation of file from file_x, + which caused the former to be used uninitialized if file_x was + nonzero. + +2003-07-22 Jim Meyering + + * src/cut.c (set_fields): Use xcalloc in place of xmalloc+memset. + + * man/Makefile.am (.x.1): Substitute 's,$t/$*,$*,' on output of + help2man, to avoid having `rm.td/rm' appear in rm.1. Reported by + Thomas Luzat. See http://bugs.debian.org/202413 for details. + + * src/cut.c (main) [lint]: Initialize spec_list_string to avoid warning. + + * src/hostid.c: Don't include . system.h already does that. + + * src/cut.c (set_fields): Mark all selected indices before trying to + determine range endpoints. + * tests/cut/Test.pm: New test for the above fix. + + Begin to address this comment: What if someone wants to + extract the 1,000,000-th field of some huge input file? + The first step is to rearrange things so that the values + in the printable_field array are all 0/1 rather than 0/1/2. + * src/cut.c (RANGE_START_SENTINEL): Remove. + Store range-start indices in a hash table, rather than + overloading the `printable_field' array. + (range_start_ht): New global. + (hash_int, hash_compare_ints, is_range_start_index): New functions. + (print_kth): Use is_range_start_index; don't test printable_field. + (set_fields): Detect overflow. + (set_fields): Insert each range-start index into range_start_ht. + (main): Call set_fields only once, and only after + output_delimiter_specified and (if required) range_start_ht have + been defined. + +2003-07-20 Paul Eggert + + * src/wc.c (get_input_fstatus): Fix typo: `stat' was being + invoked with a null pointer when there were no file arguments. + +2003-07-20 Jim Meyering + + * Makefile.maint (sc_changelog): Add another nit-picky check. + + * src/wc.c (write_counts): Add a comment. + (wc): Rename `file' parameter. + Set new local, `file', to be the file name, or (when it's NULL) + _("standard output") so that all uses of `file' use the proper value. + Use STREQ, not strcmp. + +2003-07-20 Paul Eggert + + wc count field widths now are heuristically adjusted depending + on the input size, if known. If only one count is printed, it + is guaranteed to be printed without leading spaces. + + Previously, wc did not align the count fields if + POSIXLY_CORRECT was set, but POSIX did not actually require + this undesirable behavior, so it has been removed. + + * NEWS: Document this. + * doc/coreutils.texi (wc invocation): Likewise. + + * src/wc.c (number_width): New var. + (posixly_correct): Remove. + (struct fstatus): New struct. + (write_counts): Output fields of width number_width. + Do not worry about POSIXLY_CORRECT. + Use null file, not empty-string file, to denote stdin, + since "" is a valid file name on some hosts. + (wc, wc_file): New arg fstatus. Use it to avoid invoking fstat + if possible. + (wc): Avoid problems if end_pos - current_pos overflows. + Do not print odd message if stdin has a read error. + (get_input_fstatus, compute_number_width): New functions. + (main): Use them to implement the new behavior. + Ignore POSIXLY_CORRECT. + + * tests/wc/Test.pm: Adjust to the new output widths. + +2003-07-19 Jim Meyering + + * tests/rm/fail-eperm: Don't create temporary directory -- + we don't use it. + + * tests/shred/remove: Don't open-code test for UID != 0. + Use priv-check's require-non-root instead. + Update to use newer framework. + + * tests/help-version (expected_failure_status_expr): Record that + expr exits with status of 3 for e.g., a write error. + + * tests/priv-check: Use `id -u' to see if we're running as root, + rather than trying go write to an write-protected file. + When running as root, ensure $NON_ROOT_USERNAME is valid. + When running as root with `require-non-root', ensure that `.' + is writable by $NON_ROOT_USERNAME, then reinvoke $0 set-user-ID + to $NON_ROOT_USERNAME. If `.' is not writable, then skip the test. + + * src/printenv.c: Include "exitfail.h". + (main): Set exit_failure rather than calling close_stdout_set_status. + * src/date.c: Likewise. + * src/sort.c: Likewise. + * src/tty.c: Likewise. + +2003-07-18 Jim Meyering + + * tests/touch/not-owner: Update to use newer framework. + + * tests/rm/fail-eperm: Use $srcdir/../priv-check, create a temporary + directory, and remove Perl-coded `you may not run as root' test. + * tests/cp/fail-perm: Use $srcdir/../priv-check, rather than + hard-coding something not quite equivalent. + Paul Jarc reported the inconsistent diagnostics. + + * src/sort.c (main): Use close_stdout via atexit. + Now `sort --version' and `sort --help' fail, as they should + when their output is redirected to /dev/full. + + * src/su.c (usage): Don't call close_stdout here. + (main): Use close_stdout via atexit. + Now `su --version > /dev/full' fails, as it should. + Somehow, the change of 2000-05-07 that purports to fix this + was not checked in. + + * tests/help-version (--help/--version vs. /dev/full): Special-case + `[' to protect it from expected_failure_status-`eval'. + + * src/uniq.c (writeline): Use a SPACE, not a TAB between the + count and the corresponding line, as required by POSIX. + Reported by Clement Wang. + * tests/uniq/Test.pm (101, 102): Update tests of -c accordingly. + + * tests/expr/basic: Add tests for when exit status is 2. + + * src/nohup.c (NOHUP_FOUND_BUT_CANNOT_INVOKE, NOHUP_FAILURE): + Use an anonymous `enum', rather than #define. + +2003-07-17 Paul Eggert + + * src/expr.c: Include "exitfail.h", "quotearg.h". + (EXPR_INVALID, EXPR_ERROR): New constants. + (nomoreargs, null, toarith, nextarg): Return bool, not int. + (syntax_error): New function, exiting with status 2. Use it + insteading of printing "syntax error" ourselves. + (main): Initialize exit_failure to EXPR_ERROR. + Exit with EXPR_INVALID on syntax error (too few arguments). + (nextarg): Use strcmp, not strcoll; strcoll might return + an undesirable 0, or might fail. + (docolon, eval4, eval3): Exit with status 3 on invalid argument type + or other such error. + (eval2): Report an error if strcoll fails in a string comparison. + * src/sort.c: Include "exitfail.h". + (main): Set exit_failure, not xalloc_exit_failure and + xmemcoll_exit_failure. + * tests/expr/basic: Invalid value exits with status 3, not 2. + +2003-07-16 Jim Meyering + + * configure.ac (AC_INIT): Use 5.0.90 as the version, rather than 5.0.2, + per GNU maintainer guidelines. The next non-beta release will be 5.1. + + This script would have caught at least two recent bugs: + those in [ and kill. + * tests/help-version: Revive this script. + It wasn't doing anything useful, since $all_programs wasn't being + defined by the invoking Makefile.am. + Reflect that nohup is no longer a script, so don't exclude it. + Add framework to handle the programs added since it was last run: + kill, stat, unlink, [, link, readlink. + Fix path-related problems deriving from the move of this script + from src/ to its present location. + * tests/Makefile.am (all_programs): Define. + (TESTS_ENVIRONMENT): Use it. + + * src/kill.c (main): Fix bug introduced on 2003-05-10 (for 5.0.1) + whereby kill would always attempt to operate on argv[0] and fail. + + * src/test.c (integer_expected_error): Improve diagnostic -- now, + it also matches the one from bash's builtin test. + (binary_operator): Add \n at end of diagnostic. + + * tests/rm/fail-2eperm: Remove setuidgid-related code. Move it to ... + * tests/priv-check: Move setuidgid-related and + NON_ROOT_USERNAME-checking code to this file. + + * README: Update section on testing as `root'. + Suggestion from Paul Jarc. + + * src/test.c (AUTHORS): Replace 3-letter usernames with the actual + names of authors that I just found in bash's builtins/test.def. + + Running `[' with no arguments would evoke a segfault. + * src/test.c (main) [LBRACKET]: Move initialization of argv to + precede potential use via test_syntax_error. + + * src/Makefile.am (AM_CPPFLAGS): Rename from `INCLUDES', to avoid + warning from automake -Wall. + +2003-07-15 Jim Meyering + + * Version 5.0.1. + + * Makefile.maint (%.asc): Remove target first, so gpg doesn't + prompt us about it. + + * announce-gen (print_changelog_deltas): Relax tests for matching + version-number line in NEWS. + Change the .sig suffix to .asc here, too. + +2003-07-14 Jim Meyering + + * Makefile.maint (%.asc): Renamed from %.sig. + Generate and use ascii-armored signatures. + Use gpg's -o option. + +2003-07-13 Jim Meyering + + * src/nohup.c (NOHUP_FAILURE, NOHUP_FOUND_BUT_CANNOT_INVOKE): Define. + (main): Use them. + + * Makefile.maint (syntax-check): Move each individual check into + its own target. + (syntax-check-rules): This is the list of syntax-check targets. + (sc_unmarked_diagnostics, sc_cast_of_argument_to_free): + (sc_cast_of_x_alloc_return_value, sc_space_tab): + (sc_error_exit_success, sc_xalloc_h_in_src): New targets. + +2003-07-12 Jim Meyering + + * configure.ac: Remove uses of OPTIONAL_BIN_ZCRIPTS and last + traces of the nohup script. + + * src/Makefile.am (bin_SCRIPTS): Remove use of just-removed + $(OPTIONAL_BIN_ZCRIPTS). + + * src/Makefile.am (localedir.h): Put the `2>&1' after the redirect + target, not before the `>'. + + * src/remove.c (remove_dir): Give a diagnostic upon failed save_cwd, + now that that function no longer calls `error'. + + * src/df.c (find_mount_point): Emit a diagnostic for each + failed syscall, rather than relying on caller to do that. + The caller couldn't do a good job, anyhow -- too many different + ways to fail (each with a different referent). + Give a diagnostic upon failed save_cwd, now that that function + no longer calls `error'. + (show_point): Don't diagnose find_mount_point's errors, now that + it handles them itself. + + * src/df.c (find_mount_point): Don't let free clobber errno upon + failed chdir. + + * src/sys2.h: Remove alloca-related block. + * src/system.h: Include here, instead. + + It appears that the `#pragma alloca' included via "system.h" is + adequate, since join.c uses alloca, yet lacked an in-file #pragma. + * src/copy.c, src/cp.c, src/df.c, src/install.c, src/ln.c: + * src/ls.c, src/mv.c, src/remove.c: Remove `#pragma alloca'. + + * src/chown-core.c (change_file_owner): Do not restore any special + permission bits (e.g., set-user-ID, set-group-ID) that are reset + by chown(2) on some systems. Suggestion and insistence :-) from + Michael Stone. + + * tests/input-tty: Also check `test -t 1'. + This is necessary on linux-2.4.21. Otherwise, the stty/basic-1 + test would block when run in the background. + +2003-07-11 Jim Meyering + + * tests/sample-test: Also fail if cat-to-create-expected-output + fails. Otherwise, if both `exp' and `out' were to end up empty + because of e.g., a full disk, they would mistakenly compare equal. + + * src/nohup.c: New file. Rewrite of nohup.sh in C. + This solves a portability problem: on at least Solaris systems, + when nohup.sh used the vendor /bin/sh, it would exit with status + of `1' rather than the required 126 or 127 upon failure to exec + the specified program. + + * src/Makefile.am (EXTRA_SCRIPTS): Remove definition. + (bin_PROGRAMS): Add nohup. + (EXTRA_DIST): Remove nohup.sh. + (all_programs): Remove use of $(EXTRA_SCRIPTS). + * src/nohup.sh: Remove file. + * man/Makefile.am (nohup.1): Depend on nohup.c, rather than nohup.sh. + + * tests/misc/nohup: Tests for the above. + * tests/misc/Makefile.am (TESTS): Add nohup. + + * src/head.c (diagnose_copy_fd_failure): New function, renamed from + the macro, COPY_FD_DIAGNOSE. + (diagnose_copy_fd_failure): Enclose diagnostic in _(...). + (head_file): Likewise. + + * src/date.c: Include "quote.h". + (batch_convert): Use the quote function rather than using literal `...' + in a diagnostic. + + * src/setuidgid.c (main): Enclose diagnostic in _(...). + * src/fmt.c (main): Likewise. + * src/mknod.c (main): Likewise. + * src/tac.c (tac_seekable): Likewise. + * src/yes.c (main): Likewise. + * src/od.c (main): Likewise. + * src/install.c (change_attributes): Likewise. + +2003-07-10 Jim Meyering + + * src/head.c (usage): Use 1024*1024 in place of 1048576. + * src/tail.c (usage): Likewise. + + * tests/rm/fail-2eperm: Now that we have setuidgid, use it in + place of the kludge in this test. Suggestion from Paul Jarc. + + * src/Makefile.am (noinst_PROGRAMS): Define to setuidgid. + * src/setuidgid.c: New program, solely for testing (not installed). + + * src/chown-core.c (change_file_owner): Don't leak file descriptors + when dereferencing symlinks. + +2003-07-09 Jim Meyering + + * tests/du/slash: New file/test for today's lib/ftw.c fix. + * tests/du/Makefile.am (TESTS): Add slash + + * src/tail.c (xlseek): Avoid warning about ``return without value + from function returning non-void''. + +2003-07-08 Jim Meyering + + * man/help2man: Update to version 1.29. + + * man/help2man: Add END handler to close STDOUT and check for errors. + +2003-06-30 Paul Eggert + + Add support for a "[" that conforms to the GNU coding standards, + i.e., that does not depend on its name. + * src/lbracket.c: New file. + * README: Add "[". + * man/Makefile.am (programs): Ignore "[", since it doesn't have + a separate man page. + * src/Makefile.am (bin_PROGRAMS): Add "[". + (__SOURCES): New var. + * src/test.c (LBRACKET): Define to 0 if not defined. + (main): Use LBRACKET rather than argv[0]. + + * src/test.c (one_argument): Do not check for -t if POSIXLY_CORRECT. + Reported by Paul Jarc and Dan Jacobson. + + * src/test.c (main): Do not recognize --help or --version if + POSIXLY_CORRECT, when invoked as "test". Handle "[ ]" correctly. + Do not bother testing that margv[margc] is non-null. + +2003-07-04 Jim Meyering + + * src/who.c (print_line): Rewrite to use asprintf, in order to be + able to avoid emitting trailing spaces. Reported by Dan Jacobson. + + * tests/misc/head-elide-tail: Add tests of head's new --lines=-N + option, and perform the +1600 invocations of head IFF the envvar + RUN_EXPENSIVE_TESTS is set. + +2003-07-03 Jim Meyering + + * src/cp.c (do_copy): Give a better diagnostic when failing due + to nonexistent destination directory. Reported by Dmitry Rutsky. + See http://bugs.debian.org/199730 for details. + +2003-06-27 Jim Meyering + + split's --verbose option did nothing [broken in 4.5.10 and 5.0] + * src/split.c (longopts): Use `1', not `0' as the value for + for &verbose. Reported by Keith Thompson. + + Test for the above fix. + * tests/misc/split-a: Also use --verbose and compare stderr + output with what we'd expect. + +2003-06-20 Jim Meyering + + * src/copy.c (copy_internal) [HAVE_STRUCT_STAT_ST_AUTHOR]: + Use `error_t' (rather than int) as type for local `err'. + From Alfred M. Szmidt. + +2003-06-19 Marcus Brinkmann + + * src/copy.c (copy_internal) [HAVE_STRUCT_STAT_ST_AUTHOR]: + Fix author preservation code. + +2003-06-19 Jim Meyering + + * src/ln.c (ENABLE_HARD_LINK_TO_SYMLINK_WARNING): Define to 0. + (do_link): Don't warn about hard link to symlink. + +2003-06-18 Jim Meyering + + * src/cut.c: Include "getdelim2.h", not "getstr.h". + Reflect renaming: getstr -> getdelim2. + + * src/comm.c, src/join.c, src/nl.c, src/uniq.c: Reflect renaming: + readline -> readlinebuffer. + +2003-06-09 John David Anglin + + * src/readlink.c: Include before system.h (because + the latter includes ). Required on Ultrix 4.3. + +2003-06-17 Jim Meyering + + * src/system.h (initialize_main): Define. + Use it in every `main'. Applied via this: + p='initialize_main (&argc, &argv);' + perl -ni -e '/program_name.=.argv.0/ and print " '"$p"'\n"; print' \ + $(grep -l program_name.=.argv.0 *.c) + test.c uses margc/margv, so I made the change manually for that file. + Based on a patch from Bernard Giroud. + +2003-06-09 John David Anglin + + Fix for build failure on Ultrix 4.3. + * src/stat.c: Include sys/statvfs.h in preference to sys/vfs.h. + Include sys/param.h and sys/mount.h on ultrix. + +2003-06-16 Jim Meyering + + * src/touch.c (O_NDELAY, O_NONBLOCK, O_NOCTTY, EISDIR): Remove + definitions. + * src/system.h (O_NDELAY, O_NONBLOCK, O_NOCTTY, EISDIR): Define + them here instead, but with one change: define EISDIR to -1, not 0. + + * src/cat.c (cat): Remove `#ifndef ENOSYS', now that it's + guaranteed to be defined. + * src/system.h (ENOSYS, ENOTSUP): Define to -1 if not defined. + + * README: Mention the CVS repository. + Encourage addition of test cases. + +2003-06-12 Jim Meyering + + * src/touch.c (touch): Call close only if necessary. + From Bruno Haible. + + * src/wc.c (usage): Correct wording: wc prints counts in the order + `newline, word, byte'. Reported by Keith M. Briggs. + * man/wc.x: Fix it here, too. And change `lines' to `newlines'. + +2003-06-10 Jim Meyering + + * tests/date/Test.pm: Add a test for the new format, e.g., May-23-2003. + +2003-06-07 Jim Meyering + + * Makefile.maint (syntax-check): Add commented-out (over-aggressive) + rule. + +2003-06-06 Jim Meyering + + * src/extract-magic (main): Avoid newer 3-arg form of open, + so this script works also with e.g., perl5.005_03. + Patch by John David Anglin. + +2003-06-04 Paul Eggert + + * src/system.h: Include unconditionally. + +2003-06-04 Jim Meyering + + * man/Makefile.am (check-programs-vs-x): Rename target + from check-programs-vs-1. Adjust rule to check for the + primary (.x) file, not the generated one (.1). + +2003-06-03 Tim Mooney + + * man/kill.x: New file. + * man/Makefile.am (dist_man_MANS): Add kill.1. + (kill.1): New rule. + +2003-06-04 Jim Meyering + + Ensure that the .x file for a new program is never forgotten again. + * man/Makefile.am (programs): Define. + (check-programs-vs-1): New phony target. + (check-local): Depend on it. + +2003-06-03 Jim Meyering + + Avoid unnecessary copying of environment. + * src/env.c (main): Rather than clearing the environment and -- + unless told to ignore environment -- copying all settings from + the saved, original environment, clear the environment only when + that is requested. Suggested by Jens Elkner. + +2003-06-02 Jim Meyering + + * src/system.h: Always include , since we assume C89. + Include without checking for HAVE_LIMITS_H. + + * src/test.c [!TEST_STANDALONE]: Remove #if-0'd block. + (STREQ, S_IXUGO): Remove redundant (in system.h) definitions. + +2003-06-01 Jim Meyering + + Avoid a race condition in `tail -f' described by Ken Raeburn in + http://mail.gnu.org/archive/html/bug-textutils/2003-05/msg00007.html + * src/tail.c (file_lines): Add new parameter, *read_pos, and set it. + (pipe_lines, pipe_bytes, start_bytes, start_lines): Likewise. + (tail_bytes, tail_lines, tail): Likewise. + (tail_file): Use the new `read_pos' value as the size, + rather than stats.st_size from the fstat call. + +2003-05-28 Jim Meyering + + * src/extract-magic: Allow expansion of `$file' in the here- + document corresponding to the comment at the top of fs.h. + +2003-05-26 Jim Meyering + + * src/stat.c: Fix portability problem on FreeBSD5.0: don't include + on systems without HAVE_STRUCT_STATVFS_F_BASETYPE. + Use #if/#elif/... cascade so we get only one set of include files. + Reported by Nelson Beebe. + +2003-05-24 Jim Meyering + + * src/md5sum.c (split_3): Accept the BSD format only when in MD5 mode. + * tests/sha1sum/basic-1: Make sure `sha1sum --check' doesn't + accept the BSD format. + +2003-03-28 Joe Orton + + * src/md5sum.c (bsd_split_3): New function. + (split_3): Detect checksums from BSD 'md5' command and handle them + using bsd_split_3. + + * tests/md5sum/basic-1: New tests for --check exit status, and for + BSD-style checksum files. + +2003-05-21 Jim Meyering + + * src/head.c (elide_tail_lines_pipe): Fix a thinko. + This sort of thing is why it'd be *Really Good* to factor + out the common code used here and in tail.c. + +2003-05-14 Jim Meyering + + * src/head.c (usage): Document new feature: --bytes=-N and --lines=-N. + + * tests/du/slink: Skip this test if `.' is on an XFS file system. + + * tests/du/fd-leak: New file. Test for the bug in du that + was fixed by the 2003-05-12 change to lib/ftw.c. + * tests/du/Makefile.am (TESTS): Add fd-leak. + + * src/head.c (AUTHORS): Enclose string in N_(...), now that it + includes a translatable word, `and'. + + * src/dd.c (usage): Don't use `,' as the thousands separator + in e.g. 1,000,000 and 1,048,576. Instead, do this: + `SIZE may be ..., MB 1000*1000, M 1024*1024 and so on...' + * src/df.c (usage): Likewise. + * src/du.c (usage): Likewise. + * src/ls.c (usage): Likewise. + + * Makefile.maint (syntax-check): Add another check. + +2003-05-13 Paul Eggert + + Fix uniq to conform to POSIX, which requires that "uniq -d -u" + must output nothing. Problem reported by Josh Hyman. + + * src/uniq.c (enum output_mode, mode): Remove, replacing with: + (output_unique, output_first_repeated, output_later_repeated): + New vars. All uses of "mode" changed to use these variables, + which are not mutually exclusive as "mode" was. + (writeline): New arg "match", used to control whether to + obey output_first_repeated or output_later_repeated. + All callers changed. + (check_file, main): Adjust to above changes. + + * tests/uniq/Test.pm: Test that 'uniq -d -u' outputs nothing. + +2003-05-14 Jim Meyering + + * tests/rm/rm3: Use tr's \n notation rather than \012. + This package can afford to do that, since its tests are guaranteed use + GNU tr, which has accepted the more modern notation for 10 years. + * tests/rm/rm5: Likewise. + * tests/cp/same-file: Likewise. + * tests/stty/row-col-1: Likewise. + * tests/stty/basic-1: Likewise. + * tests/rm/deep-1: Likewise. + * tests/mv/part-symlink: Likewise. + * tests/mkdir/perm: Likewise. + * tests/misc/nice: Likewise. + +2003-05-13 Jim Meyering + + * src/copy.c (struct F_triple) [name]: Remove const attribute. + (triple_free): Don't apply cast to argument of free. + (seen_file): Add cast here instead. + + * src/cp-hash.c (struct Src_to_dest) [name]: Remove const attribute. + (src_to_dest_free): Don't apply cast to argument of free. + + * src/sort.c (zaptemp): Don't apply cast to argument of free. + * src/pr.c (init_fps, init_store_cols): Likewise. + * src/join.c (delseq, freeline): Likewise. + * src/expr.c (OLD): Likewise. + * src/sort.c (sort): Likewise. + * src/head.c (elide_tail_lines_pipe): Likewise. + + * src/tail.c: Include "quote.h". + Use quote in diagnostics. Change many error format strings + from just `%s' to e.g., `error reading %s'. + (pipe_lines): Change type of parameter, n_lines, to uintmax_t. + Rewrite newline-counting loop to use memchr. + + * src/head.c (elide_tail_lines_pipe): Use `if', not assert. + Now that assert is no longer used, don't include . + +2003-05-12 Jim Meyering + + * src/head.c: Include . + (AUTHORS): Add my name. + (elide_tail_lines_pipe): New function. + +2003-05-10 Jim Meyering + + * Makefile.maint (syntax-check): Check for `error (EXIT_SUCCESS,'. + + * src/readlink.c (main): Set program_name before first use. + Remove that (redundant) first use. + Don't exit successfully just because --verbose was specified. + Pass 0, not EXIT_SUCCESS, as first argument to error; when that + parameter is 0, error does not exit. + + * src/uname.c (main): When failing due to too many arguments, also say + that, rather than just "Try `uname --help' for more information.". + * src/comm.c (main): Likewise, but for too few arguments. + * src/logname.c: Include error.h. + (main): Say why we're failing. + + * src/uniq.c (main): Don't segfault when argc < optind. + * src/who.c (main): Handle argc < optind. + * src/df.c (main): Likewise. + * src/install.c (main): Likewise. + * src/mv.c (main): Likewise. + * src/pwd.c (main): Likewise. + * src/tty.c (main): Likewise. + * src/chroot.c (main): Likewise. + * src/hostname.c: Likewise. + * src/du.c (main): Likewise. + * src/expand.c (main): Likewise. + * src/env.c (main): Likewise. + * src/unexpand.c (main): Likewise. + * src/printenv.c (main): Likewise. + * src/sync.c (main): Handle argc == 0. + * src/expr.c (main): Likewise. + * src/printf.c (main): Likewise. + * src/basename.c (main): Likewise. + * src/ln.c (main): Test for `missing argument' before computing n_files. + * src/tail.c (main): Test for the case of no arguments before + computing n_files. + + * src/kill.c (send_signals): Don't check command line arguments here. + (main): Check them here instead. Handle argc < optind. + + * src/logname.c (main): Use error, rather than fprintf, for the sake + of consistency. + + * src/rm.c (main): Don't overrun array bound if argc is 0. + +2003-05-09 Jim Meyering + + * src/sort.c (main): Don't overrun array bound if argc is 0. + That would happen when invoked via: execl ("/usr/bin/sort", NULL); + Reported by Wartan Hachaturow. + +2003-05-07 Jim Meyering + + Implement support so that `head --lines=-N' works on seekable files. + * src/head.c (enum Copy_fd_status): Define. + (COPY_FD_DIAGNOSE): New macro. + (elide_tail_lines_seekable): New funtion. + (elide_tail_lines_file): Call it here. + +2003-05-06 Jim Meyering + + * src/sys2.h (CHAR_BIT): Remove duplicate definition. + +2003-05-04 Jim Meyering + + * tests/head/Test.pm: Remove tests of --bytes=-N; using that framework + caused the addition of thousands of small files to the tar archive. + * tests/misc/head-elide-tail: New file. Add them here instead. + * tests/misc/Makefile.am (TESTS): Add head-elide-tail. + +2003-05-04 Paul Eggert + + * src/remove.c (HAVE_WORKING_READDIR): Define to 0 if not defined. + (IF_READDIR_NEEDS_REWINDDIR): Remove. + (remove_cwd_entries): Rewrite to avoid IF_READDIR_NEEDS_REWINDDIR, + which was a bit weird because it couldn't be emulated by a function. + +2003-05-03 Jim Meyering + + Extend head to accept --lines=-N (--bytes=-N) and to print all + but the N lines (bytes) at the end of the file. + * src/head.c: Include full-write.h, full-read.h, inttostr.h, quote.h. + Use quote() in diagnostics, rather than literal `' marks. + (copy_fd, elide_tail_bytes_pipe, elide_tail_bytes_file): + New functions. + (elide_tail_lines_pipe, elide_tail_lines_file): New functions. + (head_file): Reorganize so as to call head from only one place. + (main): Likewise, for head_file. + Handle new, undocumented option, --presume-input-pipe. + Handle negative line and byte counts. + * tests/head/Test.pm: Add lots of tests to exercise --bytes=-N. + + * tests/du/8gb: Skip test if the file system of `.' doesn't support + sparse files -- otherwise it'd create a file of size 8GB. + +2003-05-02 Jim Meyering + + * src/fmt.c (usage): Don't mention obsolescent -WIDTH option. + Instead explain about `-' and standard input. + (main): Give a proper diagnostic for e.g., `fmt -c -72'. + Reported by Keith Thompson. + * tests/fmt/basic: Add test for the above fix. + + * src/fmt.c: Include "quote.h". + Use quote() in diagnostics, rather than literal `' marks. + (main): Exit nonzero when unable to open an input file. + * tests/fmt/basic: Add test for the above fix. + + * src/fmt.c (main): Diagnose invalid suffix on obsolescent width + specifications like `-72x'. + * tests/fmt/basic: Add test for the above fix. + + Work around nasty readdir bug on Darwin6.5. + * src/remove.c (IF_READDIR_NEEDS_REWINDDIR): Define. + [! HAVE_WORKING_READDIR] (remove_cwd_entries): If readdir has just + returned NULL and there has been at least one successful unlink or + rmdir call since the opendir or previous rewinddir, then call + rewinddir and reiterate the loop. + + Factor out common code. + * src/remove.c (readdir_ignoring_dotdirs): New function. + (is_empty_dir): Use it here. + (remove_cwd_entries): Use it here. + +2003-05-01 Jim Meyering + + * tests/rm/r-3: Create 500 rather than just 300 files. + There's a bug in Darwin6.5's readdir that shows up only with + 338 or more files. + Fix a bug in this test: `cd $pwd' (not to `..'), now that $tmp + has two components. + + * src/tail.c: + Change type of n_units, n_bytes, n_lines to be `uintmax_t'. + (dump_remainder): Move two declarations `down' into the scope + where they are used. + (xlseek): Return the resulting offset. + (file_lines): Rename parameter, file_length, to end_pos. + (pipe_lines): Don't coerce safe_read return value to `int'. + Adapt tests accordingly. + (pipe_bytes) [struct charbuffer] (nbytes): Change type from `int' + to `unsigned int'. + Change type of `total_bytes' from `int' to `size_t', + since the former wouldn't always be wide enough. + Don't coerce safe_read return value to `int', + and adapt tests accordingly. + Now that testing for a read error no longer involves + using `tmp', handle that case *after* freeing `tmp'. + (start_bytes): Clean up. + (tail_bytes): Now that `n_bytes' may be larger than + OFF_T_MAX, test for that condition and, if it's true, don't + use lseek optimizations. + (parse_options): Don't fail just because N_UNITS is larger than + the maximum size of a file -- tail may be applied to an input + stream (e.g., a pipe) with more data than that. + + * Makefile.maint (syntax-check): Rename from alloc-check. + Also check for SPACE-TAB sequences. + Also check for malloc/calloc/realloc casts. + +2003-05-01 Jim Meyering + + * src/tail.c (start_lines): Rewrite to use memchr. Clean up. + +2003-04-28 Jim Meyering + + * tests/misc/tty-eof: Send two tokens, not just one, so we don't + make the now-more-picky tsort fail. + +2003-04-24 Jim Meyering + + * src/tsort.c (tsort): Remove unnecessary test of have_read_stdin. + (main): Minor syntactic clean-up. + + * src/tsort.c (tsort): Fail if the input contains an odd number of + tokens. Reported by junkio@cox.net. + + * tests/tsort/basic-1: Test for the above fix. + +2003-04-21 Jim Meyering + + * tests/misc/printf: Add tests for the printf fixes below. + + * Makefile.cfg (cvs_files): Add $(srcdir)/config/depcomp to the list. + +2003-04-20 Paul Eggert + + Fix printf POSIX compatibility bug reported by Ben Harris in + . + * doc/coreutils.texi (printf invocation): It's \NNN in the format, + \0NNN in the %b operand. + * src/printf.c (usage): Likewise. + (print_esc): New arg OCTAL0 to specify whether \0NNN or \NNN + is desired. All uses changed. Behave like Bash printf if %b + operand uses \NNN where the initial N is not 0. + +2003-04-17 Jim Meyering + + * src/stty.c: Remove uses of PROTOTYPE macro. + +2003-04-15 Jim Meyering + + * Makefile.maint: Remove (or replace-with-TAB(s) to retain alignment) + each sequence of spaces before a TAB character. + +2003-04-13 Jim Meyering + + * src/remove.c (is_empty_dir): Don't closedir (NULL). + +2003-04-12 Jim Meyering + + Giving nl an invalid STYLE argument (in --header-numbering=STYLE (-h), + --body-numbering=STYLE (-b), or --footer-numbering=STYLE (-f)) or + FORMAT (--number-format=FORMAT (-n)) would not give a useful diagnostic. + * src/nl.c (main): Fix those problems and remove literal quote marks + (e.g., "`%s'") from format string; instead use "%s" in each format + string and `quote (optarg)' as the corresponding argument. + Also, diagnose all invalid command line options before failing. + + * src/nl.c (proc_text): Fix a bug that would make nl output extra + newlines in some cases. Details here: http://bugs.debian.org/177256. + This bug was introduced on 2001-11-10 for textutils-2.0.17. + * tests/misc/nl: Add test for the above-fixed bug. + + * tests/misc/readlink: New file. Test the --canonicalize option. + * tests/misc/Makefile.am (TESTS): Add readlink. + +2003-04-11 Jim Meyering + + Clean up. + * src/chown.c, src/cp.c, src/dircolors.hin, src/du.c, src/ln.c: + * src/mkfifo.c, src/ptx.c, src/spline.c, src/stty.c, src/tail.c: + * src/test.c, src/unexpand.c: Remove (or replace-with-TAB(s) to + retain alignment) each sequence of spaces before a TAB character. + + * src/ls.c: Include unconditionally. + + * Makefile.maint (xalloc-check): Rename from header-check. + + * src/yes.c: Include error.h after system.h, not before. + + Clean up. + * src/copy.c, src/cp-hash.c, src/cp.c, src/csplit.c, src/cut.c: + * src/date.c, src/df.c, src/du.c, src/expand.c, src/expr.c, src/id.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/su.c, src/tail.c, src/tee.c: + * src/tr.c: * src/unexpand.c, src/users.c: + Remove anachronistic casts of xmalloc, xrealloc, and xcalloc + return values and of xrealloc's first argument. + Fix the former with this: + perl -pi -e 's/\([^(]*?\*\) *(x(m|c|re)alloc)\b/$1/' + +2003-04-10 Jim Meyering + + * src/stty.c (wrapf): Declare with format attribute. + + The S_MAGIC_... names shouldn't be maintained in two places (prior + to this change, one would have to keep stat.c and fs.h in sync). + This change makes it so those names and the corresponding + hexadecimal constants all reside in stat.c. fs.h is now generated. + * src/Makefile.am (fs.h): New rule to generate fs.h from stat.c. + (BUILT_SOURCES): Add fs.h, now that it's generated. + (EXTRA_DIST): Add extract-magic. + * src/extract-magic: New script to extract fs.h definitions from stat.c. + * src/stat.c (human_fstype) [__linux__]: Append each hex constant from + fs.h in a comment after the corresponding `case S_MAGIC_...:' statement. + + * tests/tail-2/big-4gb: Skip this test (don't fail) if creating a + file with nominal length > 4GB fails. Reported by Michael Deutschmann. + + * man/unexpand.x: Add `SEE ALSO' reference to expand. + * man/expand.x: Add `SEE ALSO' reference to unexpand. + Suggestion from Dan Jacobson. + +2003-04-10 Maciej W. Rozycki + + * src/fs.h (S_MAGIC_DEVPTS): New magic for Linux's devpts. + * src/stat.c (human_fstype): Handle Linux's devpts. + +2003-04-09 Paul Eggert + + * src/split.c (line_bytes_split): Arg is of type size_t, since + that's all that is supported for now. + (main): Check for overflow in obsolescent line count option. + +2003-04-09 Jim Meyering + + * tests/misc/split-fail: Add a new test for the above fix. + + * src/split.c (bytes_split): Use size_t temporary (rather than + uintmax_t original) in remaining computations. From Paul Eggert. + + Handle command line option arguments larger than 2^31. + This allows e.g., splitting into files of size 2GB and larger, + and running split --lines=N with N=2^31 or more. + But for --line-bytes=N, the restriction that N <= SIZE_MAX + remains (for now), due to the way it is implemented. + + * src/split.c: Include "inttostr.h". + (bytes_split, lines_split, line_bytes_split, main): + Use uintmax_t, not size_t, for file sizes. + (main): Give a better diagnostic for option arguments == 0. + Use umaxtostr to print file sizes. + Reported by Luke Hassell. + +2003-04-08 Jim Meyering + + * src/rm.c (usage): Mention that --directory (-d) works only + on some systems. Suggestion from Samuel Tardieu. + + * tests/basename/basic: Run $PERL to see if it is available, + rather than testing its value. + * tests/sum/sysv, tests/tsort/basic-1, tests/unexpand/basic-1: + * tests/basename/basic, tests/dd/skip-seek, tests/dircolors/simple: + * tests/expr/basic, tests/factor/basic, tests/fmt/basic: + * tests/ls-2/tests, tests/md5sum/basic-1, tests/md5sum/newline-1: + * tests/misc/sort, tests/misc/tty-eof, tests/mv/i-1: + * tests/rm/empty-name, tests/rm/fail-eperm, tests/rm/unreadable: + * tests/seq/basic, tests/sha1sum/basic-1, tests/sha1sum/sample-vec: + * tests/sum/basic-1, tests/seq/basic: Likewise. + + * tests/misc/Makefile.am (TESTS): Add split-fail. + * tests/misc/split-fail: New file. + + * src/split.c: Rename local variables: nchars -> n_bytes. + (lines_split): Rename local, nlines -> n_lines. + (main): Rename local variable: s/accum/n_units/. + (main): Use STDIN_FILENO, not literal `0'. + +2003-04-07 Jim Meyering + + * src/stat.c: Add #include directives for Ultrix 4.4. + Based on a suggested change from Bert Deknuydt. + +2003-04-06 Jim Meyering + + * Makefile.maint (makefile-check): New rule. + (local-check): Add it. + +2003-04-05 Jim Meyering + + * Makefile.am (nearly all of them): + Use $(VAR) rather than @VAR@, now that we can rely on automake to + emit a definition for each substituted variable. + * tests/Makefile.am.in: Likewise. + + * tests/rm/rm5: Add a comment explaining why this test fails when + using Tru64's broken sed. + * tests/rm/rm3: Likewise. + + Make `kill -t' output signal descriptions (not `?') on Tru64. + * src/kill.c (sys_siglist): Also check for __sys_siglist. + Patch by Tony Leneis. + * configure.ac: Also check for declaration of __sys_siglist. + Required for Tru64 4.0D, 4.0F, and 5.1. + Reported by Tony Leneis. + +2003-04-04 Jim Meyering + + * src/Makefile.am (PERL): Remove unnecessary definition. + + Because of inappropriate (but POSIX-mandated) behavior of rename, + `mv a b' would not remove `a' in some unusual cases. Work around + this by unlinking `a' when necessary. + + * src/copy.c (same_file_ok): Add an output parameter. + Set it in the offending case. + (copy_internal): When necessary, unlink SRC_PATH and inform caller. + Reported by Ed Avis. + * tests/mv/hard-4: New test for the above. + * tests/mv/Makefile.am (TESTS): Add hard-4. + + Clean up rules for automatically generated sources: + * src/Makefile.am (dircolors.h, wheel-size.h, wheel.h, false.c): + Make each generated file be read-only. + Add each file name to BUILT_SOURCES separately. + (MAINTAINERCLEANFILES): Set to $(BUILT_SOURCES). + + Put LOCALEDIR macro definition in new file: localedir.h. + * src/Makefile.am (DEFS): Remove definition. + (localedir.h): New rule. + (BUILT_SOURCES, DISTCLEANFILES): Add localedir.h. + * src/system.h: Include "localedir.h". + +2003-04-02 Jim Meyering + + * Version 5.0. + + * tests/misc/Makefile.am (TESTS): Add false. + + * Makefile.maint (TMPDIR): Make sure it's defined. + (my-distcheck): Build in $(TMPDIR), not `.'. + + * src/Makefile.am (false.c): Change all occurrences of + `(EXIT_SUCCESS)' to `(EXIT_FAILURE)' so that false exits + unsuccessfully also with --help. Reported by Paul Jarc, + * tests/misc/false: New test for the above. + +2003-03-30 Jim Meyering + + * NEWS: Note the location of older NEWS files. + + * src/remove.c (is_empty_dir): Don't let a failing closedir + clobber errno. Spotted by Arnold Robbins. + + * src/env.c: Fix typo in comment. From Arnold Robbins. + +2003-03-29 Jim Meyering + + * Version 4.5.12. + + * README: Note to expect build problems for stat.c on Ultrix 4.3. + Note that there are some harmless test failures when running + `make check' as root on some systems. + +2003-03-28 Jim Meyering + + * tests/stty/row-col-1: Skip this test if stty can't get window size. + This happens when connecting to sparc-solaris5.7 via ssh from within + emacs. Reported by Karl Berry. + + * tests/du/basic: Use seq, not `yes' to generate 4KB of data. + Otherwise, on systems (DJGPP) that emulate pipes using files, + this test would never complete, waiting for `yes' to terminate. + * tests/du/slink: As above, use seq, not `yes' to generate link target. + * tests/rm/hash: As above, use seq, not `yes' to generate dir name. + Reported by Rich Dawe. + +2003-03-27 Jim Meyering + + * src/id.c: Remove Arnold Robbins' obsolete e-mail address + from `written by...' comment, at his request. + +2003-03-24 Paul Eggert + + Fix buffer overrun problem reported by TAKAI Kousuke, along + with some other POSIX incompatibilities. + + * src/printf.c (print_esc): Do not treat \x specially if + POSIXLY_CORRECT. Avoid buffer overrun if the format ends + in backslash. Treat incomplete escape sequences as strings + of characters, as POSIX requires. + (print_formatted): Allow multiple flags. Avoid buffer overrun + if the format is incomplete. + +2003-03-24 Jim Meyering + + * tests/misc/printf: Add tests for the above fixes and changes. + +2003-03-26 Jim Meyering + + * src/copy.h (struct cp_options): Add a comment. + +2003-03-23 Jim Meyering + + * README: Describe problem with 64-bit mode on HPUX 11.x, + with patch for /usr/include/inttypes.h. + * TODO: Plan to add an autoconf test to work around the bug. + +2003-03-22 Jim Meyering + + * src/stat.c: Don't include . + That is already done via system.h. Otherwise, the multiple + inclusion would evoke redefinition warnings from Cray's /bin/cc, + aka Cray Standard C Version 4.0.3 (057126) Mar 22 2003 22:02:28. + (human_fstype): Factor some directives `up', out of this function. + Cast away `const' to avoid error from Cray's /bin/cc. + +2003-03-20 Jim Meyering + + * announce-gen (print_changelog_deltas): Ensure that a newline + precedes each row of `*'s. + +2003-03-20 Jim Meyering + + * Version 4.5.11. + + * src/seq.c (valid_format): Also accept ` ' and `'' as valid + format flag characters. + Do not require that a field width be specified. + Do not fail when given a field width of `0'. + Reported by Dan Jacobson. + * tests/seq/basic: Add new tests for the above-fixed bug. + + * src/Makefile.am (all-local): Append $(EXEEXT) to use of `su' + (install-root): Likewise. + (install-exec-local): Likewise. + Based on a patch from Richard Dawe. + +2003-03-19 Jim Meyering + + * man/Makefile.am (.x.1): Use $(LN_S) instead of 'ln -s', + because the DJGPP 2.03 port of 'ln -s' doesn't work. + Include $(EXEEXT) in program names. + Since $(LN_S) may degenerate to `cp -p', be careful + to invoke it from the destination directory. + Mostly from Richard Dawe. + * configure.ac: Use AC_PROG_LN_S. + + * tests/mv/part-symlink: Unset CDPATH. Otherwise, having the + CDPATH shell variable set could cause this test to fail. + Reported by Karl Berry. + +2003-03-18 Jim Meyering + + * src/fmt.c [struct Word] (paren, period, punct, final): Change the + type of each member from bool :1 to unsigned int :1. + AIX 5.1's xlc could not compile the former. + Patch by Petter Reinholdtsen. Also reported by Mike Jetzer. + +2003-03-17 Richard Dawe + + * configure.ac: Include $(EXEEXT) in OPTIONAL_BIN_PROGS' + program names, since automake only adds $(EXEEXT) to programs + in its *_PROGRAMS. + +2003-03-16 Jim Meyering + + * src/remove.c (rm): Put two local variables in static storage, + so they can't be clobbered by the potential longjmp. + +2003-03-15 Jim Meyering + + * Makefile.cfg (gnu_rel_host): Fix code to match the comment + so that a version number with a two-digit component can still count + as an alpha release. Reported by Richard A Downing. + (gnu_rel_host): Define in terms of $(RELEASE_TYPE) instead. + +2003-03-14 Jim Meyering + + * src/ansi2knr.c: Remove no-longer-used file. + * src/ansi2knr.1: Likewise. + + * Makefile.maint (prev_version_file): Don't use ?= for this particular + assignment, since it causes trouble with old versions of GNU make + (e.g. 3.76.1). The other uses of `?=' are inoffensive. Details here. + http://mail.gnu.org/archive/html/bug-coreutils/2003-03/msg00028.html + Patch from Alexandre Duret-Lutz. + + * Use patched automake-1.7.3. Regenerate Makefile.in files in + subdirectories so that each includes a definition of ACLOCAL_M4. + + * announce-gen (main): Label the compressed source URLs. + + * Version 4.5.10. + + * tests/du/slink: Relax the test for the `local'ness of a file system, + so that now it works also for tmpfs. + + * tests/du/hard-link: Transform output from first du, so that this + test doesn't fail on file systems like tmpfs that order directory + entries differently. + +2003-03-13 Jim Meyering + + * tests/du/8gb: Work around what appears to be an NFS failure that + would make this test fail on some systems. + +2003-03-11 Jim Meyering + + * tests/du/basic: Make the test file exactly 4k bytes long. + + * src/split.c (longopts): Don't hard-code `2' here. + Instead, just specify `&verbose', and ... + (main): ... remove the `case 2:' block for --verbose. + + * tests/du/basic: Make the test file larger than 64 bytes, so that + we don't immediately disqualify file systems (e.g., NetApp) on which + smaller files take up zero disk blocks. Reported by Vin Shelton. + +2003-03-10 Jim Meyering + + Don't segfault for a negative field width or precision in format string. + Note that this is just a stopgap fix. The longer term solution may + involve adapting bash's builtins/printf.def. + + * src/printf.c: (UNSPECIFIED): Define. + (print_direc): Use the special value, UNSPECIFIED, to indicate + that field_width or precision has not been specified. + (print_formatted): Fail if field_width or precision is the + special value, UNSPECIFIED. + Reported by Oliver Kiddle + + * src/sys2.h (INT_MIN): Define, if necessary. + * tests/misc/printf: Add a test for the above-fixed bug. + +2003-03-09 Jim Meyering + + * src/remove.c (AD_stack_pop): Cast sizeof... to int before + changing its sign. This avoids a warning from gcc on 64-bit systems. + Reported by Bob Proulx. + (pop_dir): Reverse order of sign change and cast, to be consistent + with the above. + +2003-03-08 Jim Meyering + + * tests/Makefile.am (evar-check): Check for POSIXLY_CORRECT not as a + shell variable, but only in the environment. With /bin/sh->bash, the + shell variable is set to `y', and that would cause a spurious warning. + Reported by Bob Proulx. + + * tests/Makefile.am (check-root): Remove touch/fifo. + It doesn't appear to have to be run as root. + + * tests/rm/fail-2eperm: Rather than simply using the first non-root + user name, make sure that the selected user name has a usable shell. + Reported by Paul Jarc. + + Before, when using shred on a device, one had to specify --exact, + or be careful to choose a size that would not be rounded up and + exceed the maximum value; that could result in a failure of + the final write. + * src/shred.c (do_wipefd): --exact is now the default for non-regular + files. Suggestion from Ben Elliston. + (usage): Say it. + + * tests/misc/tty-eof: Require at least version 1.11 of Expect.pm. + Old versions of Expect.pm (e.g., 1.07) lack the log_user function. + Patch by Bob Proulx. + + * src/Makefile.am (check-misc): Check for use of `defined' in + #define directives. + Change to $(srcdir) before running grep. + + * src/sleep.c: Remove now-unused #include and #define directives. + + * src/du.c (process_file): If a file's size is not being counted + e.g., because it's a hard link to a file we've already counted, + then don't print a line for it. + + * tests/du/hard-link: New test for the above-fixed bug. + * tests/du/Makefile.am (TESTS): Add hard-link. + + `du -S' didn't work + * src/du.c: Revert most of the `reorganization' change of 2003-02-20, + and make the two-array approach work. + + * tests/du/basic: Correct/add tests for the above fix. + Set LC_ALL, etc., now that we use sort. + Check the block/size of a small file, too. + Correct expected results for simple dir1/dir2/file case. + Add another test of du -S. + +2003-03-07 John David Anglin + + Avoid build failure with gcc on hppa1.1-hp-hpux10.20 (see GCC PR + middle-end/9986). As one of GCC's optimizations, it transforms a + fputs_unlocked call to a fputc_unlocked call when the string is + one character long. However, hpux doesn't have fputc_unlocked. + + * expr.c (usage): Use putchar, not fputs, to output a single character. + * ls.c (dired_dump_obstack): Likewise. + * ptx.c (output_one_tex_line, output_one_dumb_line): Likewise. + * stat.c (print_it): Likewise. + +2003-03-07 Jim Meyering + + * src/cp.c: Remove everything associated with mmap-stack.c. + This reverts the two changes of 2003-02-21. + * src/du.c: Remove everything associated with mmap-stack.c. + This reverts the change of 2003-02-19. + +2003-03-06 Jim Meyering + + * tests/cp/same-file: Unset CDPATH. Otherwise, having the + CDPATH shell variable set could cause this test to fail. + Reported by Karl Berry. + +2003-03-05 Jim Meyering + + * Version 4.5.9. + + * src/printf.c (print_esc): Remove pointless comparison of unsigned + integer with zero, to avoid a warning from Intel's ecc. + Reported by Nelson Beebe. + + * src/du.c (process_file): Sizes must all be of type uintmax_t. + Otherwise, for files or totals that are too big, numbers would + be truncated. Patch mostly by Michael Stone. + Reported by Ingo Saitz as Debian bug #183210. + + * tests/du/8gb: New test for the above-fixed bug. + * tests/du/Makefile.am (TESTS): Add 8gb. + + * src/du.c (MAX_N_DESCRIPTORS): Use 3 * UTILS_OPEN_MAX / 4 + rather than UTILS_OPEN_MAX - 10. + +2003-03-04 Jim Meyering + + * README: Refer new feature discussion to bug-coreutils@gnu.org, + rather than bug-gnu-utils, now that the former is better known. + Suggestion from Göran Uddeborg. + + * src/stat.c (usage): Capitalize consistently. + Reported by Göran Uddeborg. + + * Makefile.maint (rel-files): Include $(signatures), so that + those files are also copied into $(release_archive_dir). + + * src/df.c (find_mount_point): Call error here, now that restore_cwd + no longer does it. + * src/remove.c (AD_pop_and_chdir): Likewise. + + * tests/Makefile.am (check-root): Add fail-2eperm. + +2003-03-03 Jim Meyering + + * src/remove.c (remove_cwd_entries): Include the full filename of + the offending file, not just the basename. + + * tests/misc/tty-eof: Set $ME properly. + + * Makefile.maint (THIS_VERSION_REGEXP, PREV_VERSION_REGEXP): + Remove now-unused variables. + (tag-prev-version, prev-cvs-tag): Likewise. + + * src/remove.c (remove_cwd_entries) [!ROOT_CAN_UNLINK_DIRS]: Give an + accurate diagnostic when failing to remove a file owned by some other + user. Reported by Ivo Timmermans via Michael Stone. + This fixes Debian bug# 178471. + + * tests/rm/Makefile.am (TESTS): Add fail-2eperm. + * tests/rm/fail-2eperm: New test, for the above-fixed bug. + Based on a report from Ivo Timmermans. + +2003-03-02 Jim Meyering + + * src/copy.c (copy_internal) [un_backup]: When recovering from a + failure to create a hard link, do not remove the entry associating + the source dev/ino with the destination file name. + * tests/mv/Makefile.am (TESTS): Add hard-3. + * tests/mv/hard-3: New test, for the above-fixed bug. + Inspired by a report from Iida Yosiaki. + +2003-03-01 Jim Meyering + + * src/df.c (print_header): Don't embed spaces in a separate `Type' + header string. Instead, put `Filesystem' and `Type' headers in the + same string, so translators can use horizontal space as needed. + Reported by Jean Charles Delepine. + +2003-02-28 Jim Meyering + + * src/copy.c (copy_internal): When link fails because of an + existing destination file, unlink that file and try again. + Reported by Iida Yosiaki. + + * tests/mv/Makefile.am (TESTS): Add hard-2. + * tests/mv/hard-2: New test for the above-fixed bug. + Based on a test case from Iida Yosiaki. + +2003-02-26 Jim Meyering + + * tests/du/basic: Don't test du's -b option here. Directory byte + counts are smaller (512 rather than 4096) on at least OSF/1 5.1 + and IBM AIX 4.2. Reported by Nelson Beebe. + +2003-02-25 Jim Meyering + + * Makefile.maint (announcement): Now that ChangeLog entries + are output by announce-gen, don't do it here. + * announce-gen (print_changelog_deltas): New function. + (main): Use it. + +2003-02-22 Jim Meyering + + * announce-gen: New option: --release-type=TYPE + * Makefile.maint (beta, major): New targets. Remove `release'. + Put them all together on a line. + Pass the release type (via RELEASE_TYPE envvar) to the MAKE + invocation of `announcement'. + (announcement): Invoke announce-gen with --release-type=$RELEASE_TYPE. + + * announce-gen: New option: --news=NEWS_FILE. + Extract NEWS entries here, not via rules in Makefile.maint. + * Makefile.maint (announcement): Now that NEWS entries are + extracted by announce-gen, don't do it here. + (news-r1, news-r2): Remove now-unused definitions. + +2003-02-21 Jim Meyering + + * Version 4.5.8. + + Merge in changes from autoconf's version of this file. + * Makefile.maint (www-gnu): Define. + (standards.texi-url_prefix): Use $(www-gnu). + (make-stds.texi-url_prefix): Likewise. + + * src/cp.c: Include "mmap-stack.h". + (main): Invoke `run' through a macro that (when possible) runs it + with a large, mmap'd stack. + + * src/cp.c (run): New function, preparing for the above. + Exit from this function, not from main + (main): Call run. + + * src/du.c: New option: --apparent-size. + (enum) [APPARENT_SIZE_OPTION]: New member. + (long_options): Add it. + (usage): Describe it. + (main): Handle it. + ['b']: Set apparent_size. + David Eisner reported that the behavior of --bytes had changed. + Paul Eggert proposed the use of a new option, --apparent-size. + + * src/du.c (apparent_size): New global. + (print_only_size): Reflect the fact that we're printing byte counts, + not ST_NBLOCKSIZE-byte-block counts. + (print_size): Call print_only_size rather than duplicating its code. + (process_file): Accumulate byte counts, rather than block counts. + + * src/du.c (process_file): Always reset size_to_propagate_to_parent + for --separate-dirs (-S). + +2003-02-20 Jim Meyering + + * Use automake-1.7.3. Regenerate dependent files. + + * src/stat.c (print_stat): New format: %B (to print ST_NBLOCKSIZE). + This makes %b (number of ST_NBLOCKSIZE-byte blocks) more useful. + (usage) [%B]: Describe it. + [%b]: Refer to %B. + + * src/du.c (process_file): Reorganize the code to use only + one `sum' array, and change how -S works back to the way it was + before 2003-01-31. Patch by Bruno Haible. + + * tests/du/basic: New test. + * tests/du/Makefile.am (TESTS): Add basic. + + * tests/envvar-check: Add checks for the following: + BLOCK_SIZE, DU_BLOCK_SIZE, DF_BLOCK_SIZE, LS_BLOCK_SIZE. + + * tests/Makefile.am: Rename phony target envvar-check to evar-check + so as not to conflict with the distributed file by the same name. + + * src/du.c (process_file): Set info->skip before any possible return. + + Report correct usage for directories, not 0. + * src/du.c (process_file): Return for `file_type == FTW_DPRE' + _before_ recording the dev/ino of a directory. + Reported by Bruno Haible. + + Now, df always displays the device file name corresponding to the + listed mount point under `Filesystem'. Before, for an unmounted + block- or character-special file argument, it would display the + command-line argument instead. + * src/df.c (show_disk): Return a value indicating whether + there was a match. Don't try to find a mount point here. + (show_entry): If show_disk doesn't find a match, call show_point. + +2003-02-19 Jim Meyering + + * src/du.c: Include "mmap-stack.h". + (du_files): Add prototype with ATTRIBUTE_NORETURN. + Exit from this function, not from... + (main): ...here. + Instead, if possible, invoke du_files through a macro that + runs it with a large, mmap'd stack. + + * src/join.c (usage): Change wording in --help output: + use FILENUM instead of `SIDE' and say what FILENUM means. + Reported by Bernhard Gabler. + + * src/df.c (print_header): Rather than using a hard-coded literal + string of spaces matching the length of the English `...Type' header, + output the right number of spaces to match the selected translation. + Reported by Yann Dirson and Jean Charles Delepine as Debian bug 131113. + + * src/split.c (bytes_split): Remove unnecessary `else' after break. + (lines_split): Likewise. and correct misleading indentation. + + * src/split.c: Include "full-read.h". + (bytes_split, lines_split, line_bytes_split): Use full_read, + not safe_read. The way split was using the latter, a short read + could cause split to terminate before EOF. + + * tests/misc/tty-eof: Test all programs that can read stdin, + requiring no arguments and that write to standard output. + + * tests/misc/tty-eof: New file. Renamed from ... + * tests/misc/cat-tty-eof: Remove file. Rename to tty-eof. + * tests/misc/Makefile.am (TESTS): Reflect renaming. + +2003-02-18 Jim Meyering + + cksum would perform an extra read after encountering EOF + * src/cksum.c (cksum): Exit the loop upon EOF, too. + Patch by Michael Bacarella. + + Test for the bug fixed today in cksum, md5sum, and sha1sum. + * tests/misc/cat-tty-eof: Generalize, clean-up, and test for + cat, cksum, md5sum, and sha1sum all in the same loop. + +2003-02-14 Jim Meyering + + * src/remove.c: Include "euidaccess.h". + Remove declaration of euidaccess. + +2003-02-12 Jim Meyering + + * src/pathchk.c (portable_chars_only): Remove unnecessary `const' + in cast to avoid warning from icc. Reported by Alexandre Duret-Lutz. + +2003-02-10 Jim Meyering + + * src/test.c: Don't include group-member.h. + Include euidaccess.h. + (eaccess): Rewrite function to set the real uid and gid temporarily + to the effective uid and gid, then invoke 'access', and then set the + real uid and gid back. On systems that lack setreuid or setregid, + fall back on the kludges in euidaccess. Before, it would not work + for e.g., files with ACLs, files that were marked immutable, + or on file systems mounted read-only. Nelson Beebe raised the issue. + Paul Eggert suggested the new implementation. + +2003-02-09 Jim Meyering + + * src/test.c (test_stat): Remove function. It's job is done (only + when necessary) by the wrapper in lib/stat.c. Adjust all uses. + +2003-02-08 Jim Meyering + + * Version 4.5.7. + + * tests/mv/part-symlink: Don't assume that the file owner username + length is less than 9 in ls output: instead, omit that field + altogether. Reported by, and suggested fix from, Ferdinand. + + * tests/du/restore-wd: New test for just-fixed bug in ftw.c. + * tests/du/Makefile.am (TESTS): Add restore-wd. + + * src/rm.c: Correct now-invalid comment about cycle-detection. + +2003-02-06 Jim Meyering + + * NEWS: Add entries from old/*/NEWS + from fileutils-4.1 through 4.1.11 and + from sh-utils-2.0 through 2.0.15. Suggestion from Karl Berry. + + * Version 4.5.6. + + * src/du.c (process_file): Don't return early for excluded files + or for files whose dev/inode we've already seen. + +2003-02-05 Jim Meyering + + * tests/du/exclude: New file. + * tests/du/Makefile.am (TESTS): Add exclude. + +2003-02-04 Dmitry V. Levin + + * src/who.c (print_boottime, print_deadprocs, print_runlevel): + Fix memory allocation arithmetic. + +2003-02-04 Jim Meyering + + `df /dev/block-or-char-device-file--not-mounted' now reports + the name of the file system on which the file resides, usually `/'. + Before, it would leave the `Mounted on' field blank. + * src/df.c (show_disk): Move function to precede find_mount_point. + (show_disk): Add parameter: STATP. + If we don't find a matching device name, then resort to calling + find_mount_point. Reported by Bob Proulx. + +2003-02-03 Andreas Schwab + + * tests/rm/cycle: Require non-root. + * tests/rm/isatty: Likewise. + +2003-02-02 Jim Meyering + + * Version 4.5.5. + + * man/Makefile.am (check-x-vs-1): Use @PATH_SEPARATOR@, not `:'. + + Ensure that there are no offending uses of `:'. + * Makefile.maint (makefile_path_separator_check): New rule. + (local-check): Add it to the list. + +2003-02-01 Jim Meyering + + * src/du.c (MAX_N_DESCRIPTORS): Define. + + * src/stat.c (G_fail): New global. + (human_time): Diagnose failed localtime, not failed nstrftime. + (main): Fail if G_fail is set. + +2003-01-31 Richard Dawe + + * tests/basename/Makefile.am: Use @PATH_SEPARATOR@ instead of + hard-coding the path-separator. Also double-quote the new PATH, + to avoid problems when the path-separator is a semi-colon or when + `pwd` contains e.g. a space. + * tests/chgrp/Makefile.am: Likewise. + * tests/chmod/Makefile.am: Likewise. + * tests/chown/Makefile.am: Likewise. + * tests/cp/Makefile.am: Likewise. + * tests/dd/Makefile.am: Likewise. + * tests/dircolors/Makefile.am: Likewise. + * tests/du/Makefile.am: Likewise. + * tests/expr/Makefile.am: Likewise. + * tests/factor/Makefile.am: Likewise. + * tests/fmt/Makefile.am: Likewise. + * tests/install/Makefile.am: Likewise. + * tests/ln/Makefile.am: Likewise. + * tests/ls/Makefile.am: Likewise. + * tests/ls-2/Makefile.am: Likewise. + * tests/md5sum/Makefile.am: Likewise. + * tests/misc/Makefile.am: Likewise. + * tests/mkdir/Makefile.am: Likewise. + * tests/mv/Makefile.am: Likewise. + * tests/od/Makefile.am: Likewise. + * tests/rm/Makefile.am: Likewise. + * tests/rmdir/Makefile.am: Likewise. + * tests/seq/Makefile.am: Likewise. + * tests/sha1sum/Makefile.am: Likewise. + * tests/shred/Makefile.am: Likewise. + * tests/stty/Makefile.am: Likewise. + * tests/sum/Makefile.am: Likewise. + * tests/tail-2/Makefile.am: Likewise. + * tests/touch/Makefile.am: Likewise. + * tests/tsort/Makefile.am: Likewise. + * tests/unexpand/Makefile.am: Likewise. + +2003-01-31 Jim Meyering + + * src/stat.c: Include "file-type.h" + (print_human_type): Remove function. + (human_access): Rename from print_human_access. Return a string. + (human_time): Rename from print_human_time. Return a string. + (print_stat): Arrange so that field width and an alignment specifier + are honored for the %A, %F, %x, %y, and %z formats. + [%F]: Use file_type; this gives slightly different file type strings, + e.g., `directory' instead of `Directory' and `regular file' or + `regular empty file' instead of `Regular file'. + Prompted by a report from Richard Dawe that the uses of + S_IFSOCK and S_IFIFO in print_human_time were not portable + to systems using e.g., DJGPP. + +2003-01-31 Richard Dawe + + * src/stat.c (print_stat): Use S_ISLNK rather than an explicit + test using S_IFMT and S_IFLNK. S_IFLNK may not be defined. + +2003-01-31 Jim Meyering + + * src/du.c (main): Upon processing an invalid option or an invalid + --exclude-from or --max-depth option argument, don't exit right away, + in case there are others. Rather record the failure and exit after + processing other options. + + * GNUmakefile (TAR_OPTIONS): Set and export, in order to make + tar archive easier to reproduce. + + Rewrite to perform directory traversal using nftw. + + * src/du.c: Include "dirname.h", "ftw.h", and "quotearg.h". + (AUTHORS): Add self. + (opt_one_file_system): Move global into `main'. + (path, xstat, exit_status): Remove declarations. + (arg_length, suffix_length): New globals. + (G_fail): New global, sort of like the old `exit_status'. + (IS_FTW_DIR_TYPE): Define. + (print_only_size): New function. + (process_file): New function. + (str_init, ensure_space, str_copyc, str_concatc): Remove functions. + (str_trunc, pop_dir, count_entry): Likewise. + (du_files): Rewrite to use nftw. + +2003-01-30 Jim Meyering + + * tests/du/trailing-slash: Ensure that du/ftw follows a command-line + symlink-to-directory with -L, even without the trailing slash. + +2003-01-27 Jim Meyering + + * src/Makefile.am (check-misc): Check for st_blocks, too. + + * src/stat.c (print_stat): Use ST_NBLOCKS rather than `->st_blocks'. + Reported by Richard Dawe. + +2003-01-27 Andreas Schwab + + * src/ls.c (quote_name): Add fourth parameter, width, into which to + store the screen columns, and return the number of bytes instead. + (print_dir): Pass NULL as fourth parameter of quote_name. + (print_name_with_quoting): Likewise. + (length_of_file_name_and_frills): Get the width from the fourth + parameter of quote_name instead of return value. + +2003-01-27 Jim Meyering + + * src/ls.c (decode_switches): If `dired' is set without + `format == long_format', then silently reset dired. This doesn't + change the behavior of ls (all prior uses of dired were protected + by `&& format == long_format'), and lets us... + (DIRED_INDENT): ... remove the `format == long_format' conjunct. + (PUSH_CURRENT_DIRED_POS): Likewise. + (main): Likewise. + +2003-01-22 Jim Meyering + + * tests/du/no-x: New test, for functionality added to lib/ftw.c. + * tests/du/Makefile.am (TESTS): Add no-x. + +2003-01-21 Jim Meyering + + * src/remove.c (remove_entry) [ROOT_CAN_UNLINK_DIRS + && HAVE_STRUCT_DIRENT_D_TYPE]: If a file has d_type == DT_UNKNOWN + it may still be a directory -- or not (e.g., with FreeBSD on an + NFS-mounted file system), so resort to calling lstat to find out. + Based on a patch by Michael van Elst. + + * tests/cp/same-file: Don't assume that the file owner username + length is less than 9 in ls output: instead, omit that field + altogether. Reported by, and suggested fix from, Ferdinand. + +2003-01-20 Jim Meyering + + * tests/date/Test.pm (wide-fmt): New test to demonstrate that + large format widths no longer cause strftime to infloop. + + * Makefile.maint (mail_gpg_sign_cookie): Remove now-unused definition. + +2003-01-19 Jim Meyering + + * src/readlink.c: Include "canonicalize.h". + +2003-01-18 Jim Meyering + + * src/ls.c (Dereference_symlink) [DEREF_COMMAND_LINE_SYMLINK_TO_DIR]: + New member. + (enum) [DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_OPTION]: New member. + (long_options): Add option --dereference-command-line-symlink-to-dir. + (main): Make DEREF_COMMAND_LINE_SYMLINK_TO_DIR be the default, + rather than DEREF_COMMAND_LINE_ARGUMENTS, when none of the + -d, -F, -l options is specified. + (decode_switches): Handle --dereference-command-line-symlink-to-dir. + (gobble_file): Honor DEREF_COMMAND_LINE_SYMLINK_TO_DIR. + Change --dereference-command-line (-H) to dereference *all* + command line arguments, including broken symlinks. + +2003-01-15 Paul Eggert + + Change ls -H back to the way it was yesterday, since this is + compatible with FreeBSD and the POSIX spec is confusing + and somewhat contradictory. + + * src/ls.c (DEREF_COMMAND_LINE_ARGUMENTS): Change name back + from DEREF_COMMAND_LINE_SYMLINK_TO_DIR, updating all uses. + (long_options): Change the long option name back. + (usage): Change the usage back. + (gobble_file): When -H is specified, dereference a top-level + arg even if it points to a non-directory. + +2003-01-15 Jim Meyering + + * src/ls.c (gobble_file): Fall back on using lstat when required: + when --dereference (-L) is not specified, and + - when operating on a dangling symlink + - when operating on command-line-symlink-to-directories + This fixes numerous problems. Here are examples: + - `ls dangling-symlink' would fail with `no such file...' + Now it prints `dangling-symlink'. + - `ls -i symlink' would mistakenly print the inode of the referent. + Now it prints the inode of the symlink. Likewise for --size (-s). + Based on a patch from Michael Stone. + Reported by Deepak Goel as Debian bug #173793. + + Rename ls's --dereference-command-line (-H) + option to --dereference-command-line-symlink-to-dir. + * src/ls.c [enum Dereference_symlink] + (DEREF_COMMAND_LINE_SYMLINK_TO_DIR): Rename from + DEREF_COMMAND_LINE_ARGUMENTS. Update all uses. + (long_options): Rename the long option. + (usage): Say that --dereference-... changes how ls treats + only symlinks to directories specified on the command line. + +2003-01-14 Jim Meyering + + * tests/ls/dangle: New file/test, for the above fix. + * tests/ls/inode: Another new file/test, for the above fix. + * tests/ls/Makefile.am (TESTS): Add dangle and inode. + + * src/ls.c (gobble_file): Fix a bug introduced in 4.5.4 that made it + so that ls --color would no longer highlight the names of files with + the execute bit set when not specified on the command line. + Patch by Michael Stone. Reported by Stephen Depooter as + Debian bug 175135. + + * tests/ls-2/tests (color-exe): New test, for the above fix. + +2003-01-13 Jim Meyering + + * tests/shred/exact: Also test for just fixed bug with --zero. + + * src/shred.c (long_opts): --zero does not require an argument. + Patch by Michael Stone. Reported by Roland Turner as Debian bug 172019. + +2003-01-12 Jim Meyering + + * Makefile.maint (cvs-update): Skip any file with local modifications. + + * src/unexpand.c (usage): Document --first-only and mention that + --tabs=N (-t) enables --all (-a). Reported by wiregauze@yahoo.com. + +2002-12-01 Dmitry V. Levin + + * src/df.c: Include "canonicalize.h". + Use canonicalize_file_name unconditionally. + +2003-01-09 Jim Meyering + + * README: Add readlink. + +2002-11-30 Dmitry V. Levin + + * src/df.c: Include "xgetcwd.h". + * src/pwd.c: Likewise. + +2002-11-30 Dmitry V. Levin + + * src/shred.c: Remove declaration of xstrdup. + We already get it via xalloc.h which is included via system.h. + +2002-08-27 Dmitry V. Levin + + New program: readlink. + + * src/Makefile.am (bin_PROGRAMS): Add readlink. + * src/readlink.c: New file. + + * man/readlink.x: New file. + * man/Makefile.am (dist_man_MANS): Add readlink.1. + (readlink.1): New rule. + +2003-01-09 Jim Meyering + + When selecting ranges of byte offsets (as opposed to ranges of fields) + and when --output-delimiter=STRING is specified, output STRING between + ranges of selected bytes. + * src/cut.c (RANGE_START_SENTINEL): Define. + (output_delimiter_specified): New global. + (print_kth): Add parameter. Adjust all callers. + (set_fields): Mark each range-start index with RANGE_START_SENTINEL. + (cut_bytes): When requested, output STRING between ranges of + selected bytes. + (main): Make a diagnostic a little clearer. + Based on a patch from Jan Nieuwenhuizen. + + * tests/cut/Test.pm: New tests for the above. + + * src/cut.c (set_fields): Make code agree with comment: + Don't merge abutting ranges like 4- and 2-3. This makes no + difference currently, but is required to support an upcoming change. + +2003-01-07 Jim Meyering + + * src/cut.c (set_fields): Fix typo in comment. + + * tests/touch/not-owner: New test, mostly extracted from fail-diag. + * tests/touch/Makefile.am (TESTS): Add not-owner. + * tests/touch/fail-diag: Remove the test for non-owner diagnostic. + Now, this tests only the nonexistent-directory diagnostic. + Suggestion from Michael Stone. + + * tests/touch/fail-diag: Fix typo: s/ld/ls/. + +2003-01-04 Jim Meyering + + * src/copy.h: Remove use of PARAMS. + * src/remove.h: Likewise. + * src/chown-core.h: Likewise. + + rm could be tricked into mistakenly reporting a cycle. + * src/remove.c: [cycle_check_state]: New global. + (remove_cwd_entries): Adapt to new semantics of cycle_check. + (rm): Call cycle_check_init and cycle_check_free for each file. + * tests/rm/cycle (rm): New test, for the above fix. + * tests/rm/Makefile.am (TESTS): Add cycle. + + When rm detects a cycle, don't abort the entire command, + but rather just the affected command line argument. + * src/remove.c: Include + (struct dirstack_state) [current_arg_jumpbuf]: New member. + (remove_cwd_entries): Call longjmp if we detect a cycle. + (rm): Call setjmp here. + + * src/remove.c (cycle_check, is_power_of_two): Remove functions. + Instead, include cycle-check.h and use it. + + * src/remove.h (struct dev_ino): Remove declaration. + + * src/remove.c (remove_cwd_entries): Fix typos in comment. + + Don't include trailing /. in diagnostics about directories. + * src/remove.c (full_filename_): When FILENAME is just `.' + and there is a nonempty directory-name part, don't append `/.'. + * tests/rm/unread2: Remove trailing /. from diagnostic. + * tests/rm/rm2: Likewise. + + * src/remove.c (struct dirstack_state): Define. + To be used in place of these file-scoped globals ... + (dir_stack, len_stack, Active_dir): Remove globals. + (ds_init, ds_free): New functions. + (full_filename): Define. + (full_filename_): Rename from full_filename. + + Begin to make AD_* functions more generic. + * src/remove.c (AD_push_initial): Don't set status to RM_OK here. + (AD_push): Likewise. + (AD_INIT_OTHER_MEMBERS): Define. + (remove_dir): Define the `status' member manually after each + call to AD_push or AD_push_initial. + + * src/Makefile.am (check-misc): New rule, to ensure that no more + S_IS* macro definitions sneak into the code. + (check): Depend on check-misc. + + * src/remove.c [S_ISLNK]: Don't define. It's already defined in sys2.h. + * src/du.c (count_entry) [S_ISLNK]: Don't define. + * src/shred.c [S_ISLNK, S_ISFIFO, S_ISSOCK]: Don't define. + +2003-01-03 Jim Meyering + + * src/true.c: Add copyright. + (AUTHORS): I suppose I've written it. + + * src/Makefile.am (false.c): Make the generated file be read-only. + +2003-01-04 Jim Meyering + + * src/ls.c: Include "dev-ino.h". + [struct dev_ino]: Remove declaration. + +2003-01-02 Jim Meyering + + * src/cp.c (do_copy): Tweak diagnostic to be consistent with the one + from mv: s/missing file arguments/missing file argument/. + With --target-directory=DIR, cp and mv work with a single file argument. + Reported by Karl Berry. + + * tests/rm/isatty: Enable this test. + +2002-12-31 Jim Meyering + + * src/remove.c (AD_push_initial): Don't set status to RM_OK here. + (AD_push): Likewise. + (AD_INIT_OTHER_MEMBERS): Define. + (remove_dir): Define the `status' member manually after each + call to AD_push or AD_push_initial. + + * src/ls.c [struct dev_ino]: Remove definition. + Include "dev-ino.h" instead. + +2002-12-28 Jim Meyering + + * tests/du/Makefile.am (TESTS): Add no-deref. + * tests/du/no-deref: New script. + +2002-12-23 Jim Meyering + + * src/remove.c (remove_cwd_entries): Fix typo in comment. + +2002-12-21 Jim Meyering + + * announce-gen: Generate MML-formatted announcement. + This makes it a *lot* harder to send stale MD5/SHA1 signatures. + +2002-12-20 Jim Meyering + + * src/touch.c (touch): Change the wording of a diagnostic so + that it makes sense both when the file exists and when it doesn't. + Suggestion from Michael Stone. + +2002-12-18 Jim Meyering + + * src/stty.c (valid_options): Declare to be static. + +2002-12-15 Jim Meyering + + * Makefile.cfg: Remove rules related to generating m4/jm-glibc-io.m4. + + * src/chmod.c, src/copy.c, src/copy.h, src/cp-hash.h, src/csplit.c: + * src/date.c, src/expr.c, src/fmt.c, src/id.c, src/install.c: + * src/ls.c, src/od.c, src/pathchk.c, src/pr.c, src/remove.c: + * src/shred.c, src/sort.c, src/stat.c, src/stty.c, src/sum.c: + * src/tee.c, src/test.c: Remove all uses of `PARAMS'. + + * src/remove.c (PARAMS): Remove definition. + * src/sys2.h: Likewise. + + * src/ls.c, src/stat.c, src/date.c: Remove declaration of nstrftime. + Include strftime.h instead. + +2002-12-14 Jim Meyering + + * Makefile.cfg ($(url_dir_list)): Use .../coreutils, not .../fetish. + + * src/system.h [! HAVE_DECL_MEMRCHR]: Declare memrchr. + This is necessary at least for Irix6.5 when using c89. + Reported by Nelson Beebe. + + * tests/misc/Makefile.am (TESTS): Add cat-tty-eof. + + * tests/misc/cat-tty-eof: New test. + + * src/mknod.c (usage): Specify how major and minor mode numbers + are interpreted. Report forwarded by Kristin E Thomas. + * src/mknod.c: Remove now-redundant usage-specifying comment. + +2002-12-13 Jim Meyering + + * Version 4.5.4. + + * tests/du/trailing-slash: Allow for a directory of size `0'. + That happens at least on file systems of type tmpfs on linux-2.4.18. + + * announce-gen: New script to begin replacing the commands + associated with the rule here... + * Makefile.maint (announcement): Invoke announce-gen. + * Makefile.am (EXTRA_DIST): Add announce-gen. + + * tests/cp/preserve-2: New file/test, for latest fix. + * tests/cp/Makefile.am (TESTS): Add preserve-2. + +2002-12-11 TAKAI Kousuke + + Fix a bug whereby cp would fail to parse an option like + --preserve=mode,ownership. + * src/cp.c (decode_preserve_arg): Advance `comma' to + point the character following the comma. + +2002-12-11 Jim Meyering + + * src/pathchk.c (NEED_PATHCONF_WRAPPER): Undefine before defining, + in case it's already defined. + +2002-12-09 Jim Meyering + + * tests/touch/fail-diag: Don't get a test failure if /no exists. + Instead, evoke a framework failure if /no-$$ exists. + Reported by Michael Stone. + +2002-12-08 Jim Meyering + + * src/du.c (lstat) [! LSTAT_FOLLOWS_SLASHED_SYMLINK]: + Define to rpl_lstat, so that even on systems like Solaris 5.8, + du honors (per POSIX) the trailing slash on an argument referring + to a symlink-to-directory. + +2002-12-06 Jim Meyering + + * Use autoconf-2.57. Regenerate dependent files. + * Use automake-1.7.2. Regenerate dependent files. + + * src/ls.c (gobble_file): Also stat the file if it's a + regular file and --indicator-style=classify (aka -F). + Thanks to Ed Santiago for opening my eyes. + + * tests/ls/file-type: New file. Test for the above. + A test to contrast ls -F and ls --indicator-style=file-type. + * tests/ls/Makefile.am (TESTS): Add file-type. + +2002-12-04 Jim Meyering + + * tests/ls/follow-slink: Make sure the symlink was created. + Richard Dawe reported that `ln -s link link' succeeds, but creates + no file on systems running some version of the DJGPP libc. + +2002-12-03 Jim Meyering + + * src/Makefile.am (AUTOMAKE_OPTIONS): Remove definition (to ansi2knr) + since this package no longer panders to K&R compilers. + +2002-12-02 Jim Meyering + + * tests/du/slink: Skip this test if `.' is on a non-local file system. + + * tests/Fetish.pm (_at_replace): Do the substitution only if there's + something to replace. + +2002-12-01 Jim Meyering + + * src/stat.c: Don't include or . + That's already done via system.h. + * src/dircolors.c: Don't include . + +2002-11-30 Jim Meyering + + * ls.c (gobble_file): Remove the block of code that caused + `ls --color -F symlink-to-dir' to list the files in + `symlink-to-dir/.'. Now, it prints `symlink-to-dir@', (just + like `ls -F symlink-to-dir') but with the addition of highlighting. + Similarly, `ls --color -dF symlink-to-dir' would print + `symlink-to-dir/'; now it prints `symlink-to-dir@'. + Reported by Jeff Sheinberg as Debian bug #168203. + * tests/ls-2/tests (sl-F-color, sl-dF-color): New tests for the above. + + ls is now more efficient: with certain options, it no longer needs + to stat each directory entry on systems with valid dirent.d_type. + * src/ls.c (print_dir): Add DT_LNK and DT_REG. + (main): Make --recursive set format_needs_type, not format_needs_stat. + (gobble_file): Remove a FIXME comment, now that it's fixed. + +2002-11-24 Jim Meyering + + * src/du.c (du_files): Don't strip any trailing slash. + Rewrite so that `/' is no longer represented internally as + the empty string. + (count_entry): When appending a file name component, + account for the fact that the current path may end in `/'. + François Pinard reported that `du symlink-to-dir/' was not + equivalent to `du symlink-to-dir/.'. Now it is. + * tests/du/trailing-slash: New file/test, for the above fix. + * tests/du/Makefile.am (TESTS): Add trailing-slash. + +2002-11-23 Jim Meyering + + * src/tac.c (output): Declare some local variables to be of type size_t, + rather than `int' to avoid warnings from gcc. + +2002-11-21 Paul Eggert + + * src/ls.c (decode_switches): Use case-sensitive matching to + decode the QUOTING_STYLE environment variable. This is more + consistent with the documentation, and with --quoting-style. + +2002-11-21 Martin Buck + + * tests/sum/sysv: Export LC_ALL=C, to avoid failure when + run in a UTF locale. Report and suggested fix by Bruno Haible. + * tests/fmt/basic: Likewise. + +2002-11-17 Jim Meyering + + * configure.ac: Update via autoupdate. + Add `AM_GNU_GETTEXT_VERSION(0.11.5)'. + + * src/mv.c (movefile): Don't remove trailing slashes from SOURCE. + Reported by Hans Ginzel. + +2002-11-15 Jim Meyering + + * Makefile.cfg (gnu_rel_host): Define. + (url_dir_list): Choose from (alpha|ftp).gnu.org depending + on whether $(VERSION) looks like a major release number. + + * Makefile.maint (mail_gpg_sign_cookie): Backslash-escape `#'. + (release): Rename from `alpha'. + (alpha): Depend on release. + + * Makefile.maint (signatures): Define with ?=, so it's easy to override. + +2002-11-14 Jim Meyering + + * Makefile.maint (mail_gpg_sign_cookie): Make optional. + (announcement): Use the new variable. + + * Makefile.maint: Sync with Bison, i.e.: + (po-check): Scan .l and .y files instead of the + .c and the .h files that they generate. This fixes the bug + reported by Tim Van Holder in: + + Look for N_ as well as for _. Try to avoid matching #define for + N_ and _. + From Paul Eggert. + +2002-11-12 Jim Meyering + + * src/ls.c (HAVE_SYMLINKS): Remove unnecessary macro definition. + Replace sole use with equivalent `#ifdef S_ISLNK'. + Inconsistency reported by Dmitry V. Levin. + +2002-11-11 Jim Meyering + + * src/stat.c (usage): Transform --help items output via s/ - / /, + so that help2man produces properly formatted man pages. + Reported by Herbert Xu as Debian bug #168400. + +2002-11-10 Jim Meyering + + * src/ls.c (sighandler): Handle SIGTSTP specially. + Based on suggestions from Solar Designer and Dmitry V. Levin. + Add comments. + + * Makefile.cfg (cvs_files): Define. From autoconf. + (local_updates): Likewise. + + * src/ls.c (restore_default_color_handler, sigtstp_handler): + Remove functions. + (sighandler): New function, based on the one in sort.c. + (main): Use sigaction, if possible; otherwise signal. + Handle these signals: + SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, SIGTSTP. + Don't register our handler if the signal is already being ignored. + + * src/dd.c (interrupt_handler): Use raise, rather than kill+getpid. + * src/csplit.c (interrupt_handler): Likewise. + * src/sort.c (sighandler): Likewise. + (main): Declare `i' and `nsigs' to be unsigned, not int. + +2002-11-09 Jim Meyering + + ls --color: restore terminal text color upon signal. + * src/ls.c: Include "full-write.h" and . + (restore_default_color, restore_default_color_handler): New functions. + (sigtstp_handler, put_indicator_direct): New functions. + (main) [print_with_color]: Register signal handlers. + Patch mostly by Solar Designer and Stanislav Ievlev. + + Update from autoconf. + * Makefile.maint (AMTAR): Remove definition. + (update, cvs-update, po-update, do-po-update): New rules. + (wget-update): Update (thus renaming to cvs-update). + (automake_repo): Use anoncvs@sources.redhat.com. + +2002-11-06 Jim Meyering + + * tests/misc/Makefile.am (TESTS): Add printf-hex. + + * tests/misc/printf: Be careful to test the code in this package, + not the shell built-in function. + + * src/printf.c (print_esc): A hexadecimal escape sequence has + at most two hex. digits, not three. Reported by Padraig Brady. + (usage): Update description. + * tests/misc/printf-hex: New file/test, for the above fix. + +2002-10-07 Paul Eggert + + Add support for locale-specific size indications (e.g., + thousands-separators) and for explicit size suffixes on output. + + * doc/coreutils.texi (Block size): Say that: + This affects display format as well as block size. + Fractional block counts are rounded up. + ls file size blocksize defaults to 1. + A block size spec preceded by ' generates thousands separators. + A suffix without a preceding integer generates suffixes. + (tail invocation): 32k -> 32 KiB. + (What information is listed): ls -h is now equivalent to + ls --block-size=human, and ls -H is now equivalent to + ls --block-size=si. Displayed file size is now always affected by + --block-size. + + * lib/inttostr.c, lib/inttostr.h, lib/imaxtostr.c, lib/offtostr.c, + lib/umaxtostr.c: New files, taken from GNU tar. + + * lib/Makefile.am (libfetish_a_SOURCES): Add imaxtostr.c, offtostr.c, + umaxtostr.c. + (EXTRA_DIST): Add inttostr.c. + + * lib/human.c, lib/human.h: Rewrite to support locale-specific + notations like thousands separators. + Specify what includer of include.h must include beforehand. + (human_group_digits, human_suppress_point_zero, human_autoscale, + human_base_1024, human_SI, human_B): New enum values. + (human_readable): Rename from human_readable_inexact; put the + options before the sizes. All uses changed. The old human_readable + function has been removed; use inttostr.h instead. + (human_options): Renamed from human_block_size, with new signature + that allows block sizes up to UINTMAX_MAX. All callers changed. + + * m4/prereq.m4 (jm_PREREQ_HUMAN): Check for locale.h, localeconv, + AC_HEADER_STDBOOL. No need to check for limits.h since it's in + freestanding C89. No need to check for stdlib.h or string.h since + autoconf does this now. + + * src/cksum.c (cksum): Use primitives from inttostr.h, not + human.h, to print large numbers simply. + * src/csplit.c (handle_line_error, parse_patterns): Likewise. + * src/dd.c (print_stats, main): Likewise. + * src/df.c (print_header): Likewise. + * src/factor.c (print_factors): Likewise. + * src/ls.c (print_long_format, print_file_name_and_frills): Likewise. + * src/shred.c (dopass): Likewise. + * src/sort.c (checkfp): Likewise. + * src/sum.c (bsd_sum_file, sysv_sym_file): Likewise. + * src/tail.c (xlseek): Likewise. + * src/wc.c (write_counts, wc): Likewise. + + * src/df.c (human_output_opts): New var. + (output_block_size): Now uintmax_t, not int, to handle larger + block sizes. All uses changed. + * src/du.c: Likewise. + * src/ls.c: Likewise. + + * src/df.c (print_header): In the header line, prefer SI to human + representation if it's shorter; if neither is shorter, try to + intuit what the user would prefer. + + * src/expr.c (inttostr): Remove; use new imaxtostr library + function instead. + + * src/ls.c (file_output_block_size): New var, to distinguish + file sizes from other sizes. + (decode_switches): Set it. + + * src/shred.c (OUTPUT_BLOCK_SIZE): remove. + (dopass): When printing progress, use floor for what has been done + so far (since we should be conservative there), and ceiling for + what needs to be done (since that's what other programs use). + +2002-10-19 Jim Meyering + + * src/pinky.c (print_heading): Align TTY and Name headings. + Reported by Karl Eichwalder. + +2002-10-18 Jim Meyering + + * src/split.c (cwrite): Change type of `bytes' parameter to size_t + Remove now-useless cast. + (stdread): Remove function. + (bytes_split): Use size_t instead of int. + Use safe_read, not stdread. + (lines_split): Likewise. + Use memchr rather than a `while' loop. + (line_bytes_split): Use size_t instead of int. + Use safe_read, not stdread. + (main): Add some FIXME comments to remind me to remove casts. + + * src/system.h (ST_BLKSIZE): Correct comment describing how to + reproduce HPUX-11 cat failure. From Petter Reinholdtsen. + +2002-10-17 Jim Meyering + + Fix a problem that could make e.g., `cat' misbehave on systems which + give invalid (unreasonably large) values for stat.st_blksize. + * src/system.h (ST_BLKSIZE): Ensure that the result is in [1..4MB]. + Reported by Petter Reinholdtsen. + +2002-10-14 Jim Meyering + + Specifying a printf conversion specifer as nl's separator string + could cause nl to segfault. + * src/nl.c (build_print_fmt): Don't include separator string + in the printf format; it might contain `%'. + Use a better bound on the length of the print_fmt buffer. + (print_lineno): Print the separator here instead. + Reported by Doug Coleman. + + * tests/misc/nl: New file/tests, including a test for the above. + * tests/misc/Makefile.am (TESTS): Add nl. + + * tests/misc/split-l: New test, to make sure `split --lines=N' works. + * tests/misc/Makefile.am (TESTS): Add split-l. + +2002-10-13 Jim Meyering + + * Version 4.5.3. + + * src/du.c (usage): Tweak description of --dereference-args/-D. + + * src/du.c (count_entry): Also save cwd when dereferencing (via + --dereference-args, -D) a command-line argument. + Reported by Michal Svec. Based on a patch by Andreas Schwab. + + * src/Makefile.am (../AUTHORS): New target/rule. + +2002-10-12 Jim Meyering + + * src/paste.c (paste_parallel): Declare local, `delims_saved', to be + of type size_t, since that's the way it's used and avoids a warning. + + * src/csplit.c (struct cstring) [len]: Declare to be unsigned int, + since that's how it's always used and avoids a new warning from gcc. + (read_input): Adapt to new safe_read ABI. + + * src/cut.c (cut_fields): Add a temporary size_t variable, n_bytes, + to avoid warnings. + + * src/pinky.c (print_long_entry): fread returns size_t. + Declare local `bytes' accordingly, to avoid warning. + + tail -c +N would perform an extra read after encountering EOF + [this change is analogous (bytes vs. lines) to the one of 2002-01-27] + * src/tail.c (start_bytes): Detect EOF, inform caller. + (tail_bytes): Upon EOF in start_bytes, return immediately. + (file_lines): Reorganize to use memrchr rather than an explicit loop. + Adapt to new safe_read ABI. + +2002-10-11 Jim Meyering + + * tests/du/deref: New file/test, for the above fix. + * tests/du/Makefile.am (TESTS): Add deref. + +2002-10-10 Jim Meyering + + * tests/ln/Makefile.am (TESTS): Add target-1. + * tests/ln/target-1: New file/test, for the fix on 2002-10-08. + +2002-10-09 Jim Meyering + + * tests/cp/backup-is-src: Ensure that certain environment variables + are not set (e.g., SIMPLE_BACKUP_SUFFIX). Reported by Duncan Roe. + + * tests/tail-2/big-4gb: Mark this as an expensive test; it would + consume 4GB of disk space on systems without support for sparse files. + Fix a logic error that'd make it `cat err' even though dd didn't fail. + + * src/dircolors.hin (.jar): Fix typo: s/;3$/;31/. + Patch by steven@magelico.net, forwarded by Michael Stone. + + * tests/ls/dired: Ensure that ls produces English messages. + Patch by Alexey Vyskubov, forwarded by Michael Stone. + +2002-10-08 Dmitry V. Levin + + * src/ln.c (main): Fix target_directory parsing when n_files == 1. + +2002-10-08 Jim Meyering + + * tests/tail-2/big-4gb: Use double quotes around diagnostic. + Fix syntax in test: use =, not ==. + Reported by Bob Proulx. + Change all the rest like this: grep -lR "testing framework'" .\ + |xargs perl -pi -e 's/'\''(\$0: failure in testing framework)'\''/"$1"/' + + * src/sum.c (sysv_sum_file): Adapt to new safe_read ABI. + * src/tr.c (squeeze_filter, read_and_delete, read_and_xlate): Likewise. + * src/tac.c (save_stdin, tac_stdin_to_mem): Likewise. + * src/wc.c (wc): Likewise. + +2002-10-07 Paul Eggert + + * src/cat.c (cat): + Don't advance the write pointer past the end of the write buffer. + * src/sort.c (begfield, limfield): Likewise. + +2002-10-07 Jim Meyering + + * src/cat.c (simple_cat, cat): Adapt to new safe_read ABI. + * src/head.c (head_bytes, head_lines): Likewise. + +2002-10-06 Jim Meyering + + * src/dd.c (scanargs): Ensure that specified block sizes (specified + via ibs=N, obs=N, and bs=N) are no larger than SSIZE_MAX. + (skip, dd_copy): Adapt to new safe_read ABI. + + * Makefile.maint (signatures): Define. + (%.sig): New rule. + (announcement): Depend on $(signatures). + + * Makefile.maint (announcement): Output all URLs for detached + signatures, not just the last one from the previous loop. + +2002-10-05 Jim Meyering + + * Version 4.5.2. + + * src/remove.c (remove_entry) [ROOT_CAN_UNLINK_DIRS]: With `rm -i DIR', + don't recurse into directory, DIR. Prompted by a report from + Leonardo Milano. + + * tests/rm/i-no-r: New file/test, for the above fix. + * tests/rm/Makefile.am (TESTS): Add i-no-r. + + * tests/tail-2/big-4gb: New file/test, for the fix of 2002-09-27. + * tests/tail-2/Makefile.am (TESTS): Add big-4gb. + +2002-10-03 Jim Meyering + + * src/rm.c (AUTHORS): Mark translatable string with `N_ (...)'. + * src/df.c (AUTHORS): Likewise. + * src/du.c (AUTHORS): Likewise. + * src/tail.c (AUTHORS): Likewise. + * src/touch.c (AUTHORS): Likewise. + +2002-10-02 Jim Meyering + + * Makefile.am (SUBDIRS): Remove `old'. + (EXTRA_DIST): List the files in old/. + * configure.ac (AC_CONFIG_FILES): Remove old/* names. + Suggestion from Akim Demaille. + +2002-10-01 Jim Meyering + + * src/sys2.h (SSIZE_MAX): Define. + +2002-09-30 Jim Meyering + + * src/csplit.c: Don't include stdlib.h here. It's already included + via system.h. + +2002-09-29 Jim Meyering + + * src/tr.c (find_bracketed_repeat): Rearrange pointer/integer + expression to avoid bogus warning from gcc. + + * src/cat.c (simple_cat): Use a temporary to avoid bogus warnings. + (cat): Declare insize and outsize to be of type size_t, not int. + Rearrange pointer/integer expressions to avoid bogus warnings. + (main): Declare insize and outsize to be of type size_t, not int. + + * src/tail.c (parse_options): Give a sensible diagnostic for + an invalid byte or line count. Reported by Mikko Tuumanen. + + * src/touch.c (main): Split a long line. + + * tests/du/Makefile.am (TESTS): Add slink. + * tests/du/slink: New test for system.h change of 2002-08-31. + + In move mode, always first try to rename. Before, upon failure to + rename a directory, this code would never attempt to rename any + other file in that directory, but would thenceforth always copy. + On some systems (e.g., NetApp's OnTap-6.4), renaming a directory + may fail with EXDEV, yet renaming files within that directory to + a newly-created destination directory succeeds. + * src/copy.c (copy_internal): Remove local, move_mode; + use x->move_mode instead. Based on a patch from Tom Haynes. + +2002-09-28 Jim Meyering + + * src/split.c (FAIL_ONLY_ONE_WAY): New macro. + Factor out some duplication. + (main): Use it. + [case 'a']: Use strtoul rather than strtol to avoid compiler warnings. + + * src/sort.c (begfield, limfield): Rearrange comparisons to avoid + compiler warnings. + (fillbuf, keycompare): Cast literal `-1' to size_t in comparisons, + to avoid compiler warnings. + + * src/shred.c (dopass): Use a uintmax_t temporary to avoid bogus + compiler warnings. + + Fix things so `mkdir -p' can create very deep directories, e.g., + mkdir -p $(perl -e 'print "a/" x 40000') now works. + * src/mkdir.c (main): For --parents (-p), call make_path with the + entire directory name, so we don't ever require that file operations + like stat or chmod be performed on the entire command line argument. + * makepath.c (make_path): Restore umask *before* creating the final + component. + +2002-09-27 Andreas Schwab + + * src/tail.c (tail_bytes): Change type of bytes_remaining to off_t + to avoid overflow. Reported by Hans Lermen. + +2002-09-26 Jim Meyering + + * src/install.c (get_ids): Use strtoul, not strtol. Remove some casts. + +2002-09-25 Jim Meyering + + * src/test.c (eaccess): Change type of local `euid' from int to uid_t + and add a cast, to avoid a warning about `signed and unsigned type in + conditional expression'. + +2002-09-22 Jim Meyering + + * src/rmdir.c: Include "dirname.h", for declaration of + strip_trailing_slashes. + + * src/stat.c (PRIdMAX, PRIuMAX): Remove definitions. + Now they're defined through system.h. + + * src/cp-hash.c, src/dd.c, src/df.c, src/du.c, src/ls.c, + * src/stat.c, src/wc.c: Remove all inclusions of inttypes.h, + since it's already included from sys2.h via system.h. + + * Use automake-1.6f. Regenerate dependent files. + + * src/Makefile.am (PERL): Remove duplicate definition. + + fmt's -s, -t, -c options didn't work properly for long lines. + Since get_line may end up calling put_paragraph (for long lines), + be sure to set global, `other_indent', before it is used there. + + * src/fmt.c (set_other_indent): New function, factored out of... + (get_paragraph): ... here. Call it. + (get_line): Call set_other_indent before calling flush_paragraph, + which calls fmt_paragraph, which in turn calls put_paragraph, + which uses other_indent. + + * tests/fmt/Makefile.am (TESTS): Add long-line. + * tests/fmt/long-line: New file/test, for the above fix. + +2002-09-21 Jim Meyering + + * src/od.c: No longer include deprecated . + It was required solely for now-removed reference to BITSPERBYTE. + * src/install.c: Likewise. + Suggestion from Bruno Haible. + +2002-09-06 Andreas Schwab + + `rmdir -p dir-specified-with-trailing-slash/' would fail. + * src/rmdir.c (remove_parents): Strip trailing slashes. + +2002-09-20 Jim Meyering + + * tests/rmdir/t-slash: New file/test, for the above fix. + * tests/rmdir/Makefile.am (TESTS): Add t-slash. + + * Makefile.maint (announcement): Arrange to gpg-sign the message. + Add a URL for each detached signature file. + +2002-09-07 Bruno Haible + + * configure.ac: Add need-ngettext to AM_GNU_GETTEXT invocation. + +2002-09-18 Jim Meyering + + `od -t x8' used the wrong (`l'-prefixed) printf format. + Likewise for the o8 and u8 formats. + * src/od.c (ISPEC_TO_FORMAT): Define macro. + (decode_one_format): Use PRIdMAX, PRIoMAX, etc. for LONG_LONG. + Reported by Arun Sharma. + +2002-09-17 Jim Meyering + + * src/sys2.h (PRIdMAX, PRIoMAX, PRIuMAX, PRIxMAX): Define if necessary. + From gettext's intl/loadmsgcat.c. + + * tests/od/x8: New file/test, for the above fix. + * tests/od/Makefile.am (TESTS): Add x8. + +2002-09-15 Jim Meyering + + * Use autoconf-2.54. Regenerate dependent files. + + * src/csplit.c (get_format_width): Add cast to avoid + warning about `signed and unsigned type in conditional expression'. + +2002-09-14 Jim Meyering + + * src/who.c (print_user): Change type of local to size_t + to avoid warnings about `comparison between signed and unsigned'. + * src/ptx.c (generate_all_output): Likewise. + + * src/dd.c (main, skip): Add casts to avoid warnings about + `comparison between signed and unsigned'. + + * src/id.c (print_full_info, print_group_list): Add casts to avoid + warnings about `signed and unsigned type in conditional expression'. + + * src/md5sum.c: Change type of global, digest_hex_bytes, to size_t + to avoid warnings about `comparison between signed and unsigned'. + (split_3): Change parameter names to be readable and add comment. + Clean up the test for whether a line may be ignored. + +2002-09-13 Jim Meyering + + * src/printf.c (main): Handle leading command line argument of `--'. + Reported by Raul: DervishD + * tests/misc/printf: New file: test for the above. + * tests/misc/Makefile.am (TESTS): Add printf. + + * src/date.c (usage): Explain that %S's range of [0..60] is required -- + rather than 0..59 -- to accommodate the occasional positive leap second. + Reported by Richard Neill. + +2002-09-12 Jim Meyering + + * src/Makefile.am (nanosec_libs): Define. + (sleep_LDADD, tail_LDADD): Use it here. + + Factor nanosleep-related code into ../lib/xnanosleep.c. + * src/sleep.c: Include xnanosleep.h. + Factor out fenv.h-related code. + (timespec_subtract): Remove function. + (main): Remove code that deals with computing start and stop times + as well as the loop around nanosleep. Now that's in xnanosleep.c. + + Allow S (in --sleep-interval=S) to be a floating point value. + * src/tail.c: Include xnanosleep.h and xstrtod.h. + Move declaration of global variable, sleep_interval, to ... + (main): ...here. + (usage): Update description of --sleep-interval option. + (tail_forever): New parameter, sleep_interval. Update caller. + Use xnanosleep, rather than sleep. + (parse_options): New parameter, sleep_interval. Update caller. + Use xstrtod, now that we accept floating point values. + Prompted by a patch from Augey Mikus. + +2002-09-06 Jim Meyering + + * src/remove.c (prompt): Change comment to give a better note to + translators. From Michael Piefel. + +2002-09-02 Jim Meyering + + * README: A good problem report/patch includes diffs against + the most recent test release. + + * src/pathchk.c (NEED_PATHCONF_WRAPPER): Define. + (pathconf_wrapper): Define only if NEED_PATHCONF_WRAPPER is set. + + * src/kill.c (print_table_row): Use an unsigned type for widths + to avoid warning about comparison between signed and unsigned. + (list_signals): Likewise. + + * src/od.c (skip): Add a cast to avoid warning about comparison + between signed and unsigned. + * src/install.c (get_ids): Likewise. Also rearrange range-checking + comparisons to make them more readable. + +2002-09-01 Jim Meyering + + * Version 4.5.1. + +2002-08-31 Jim Meyering + + Symlinks were always reported as using 0 blocks. + * src/system.h (ST_NBLOCKS): Don't depend on file type. + This reverts the change of 2000-01-30. + Based on a report and patch from Neil Brown via Michael Stone. + This fixes Debian Bug#156358. + + * Most files: Change `exit (0)' to `exit (EXIT_SUCCESS)', + `exit (1)' to `exit (EXIT_FAILURE)', and + `usage (1)' to `usage (EXIT_FAILURE)'. + + * chgrp.c, chmod.c, chown.c, chroot.c, cp.c, date.c, dd.c, du.c, + * hostname.c, id.c, install.c, ln.c, mkdir.c, mkfifo.c, mknod.c, + * nice.c, pinky.c, printf.c, pwd.c, shred.c, sleep.c, stty.c, + * su.c, tac-pipe.c, tail.c, tee.c, touch.c, uname.c, uptime.c, + * users.c, who.c: Change `error (1, ...' to `error (EXIT_FAILURE, ...'. + But don't change `error (0, ...' to `error (EXIT_SUCCESS, ...', since + error never exits successfully. + +2002-08-29 Jim Meyering + + * src/remove.c (remove_cwd_entries): Use closedir (not CLOSEDIR) + when ignoring any return value. + + * src/remove.c (remove_cwd_entries): Detect and diagnose readdir + failures. On some systems (at least EMC Celerra and Solaris5.8), + this appears to be necessary. + (is_empty_dir): Likewise. Also, always close directory handle. + * src/ls.c (print_dir): Likewise. + (print_dir): Rename local variable: reading -> dirp. + Reported by Mike Coleman. + +2002-08-28 Jim Meyering + + * src/remove.c (remove_cwd_entries): Use CLOSEDIR, not closedir. + Give a diagnostic and fail if closedir fails. + +2002-08-26 Jim Meyering + + * Makefile.am (THANKS-to-translators): New rule. + (EXTRA_DIST): Add both THANKS-to-translators and THANKStt.in. + * THANKStt.in: New file. + + * src/cat.c (close_stdout_wrapper): New, kludgey, function and + file-scoped global. + (main): Register it with atexit. + Close STDOUT_FILENO, to avoid a problem when writing to + /dev/audio on at least Solaris 5.7 and 5.8 systems. + Reported by Shing-Shong Shei. + +2002-08-25 Jim Meyering + + * src/cat.c (main): Close STDIN_FILENO rather than a literal `0'. + * src/tac.c (main): Likewise. + * src/tail.c (main): Likewise. + * src/tee.c (main): Likewise. + * src/tr.c (main): Likewise. + * src/wc.c (main): Likewise. + +2002-08-20 Jim Meyering + + * tests/mv/setup: Rewrite not to use `: ${VAR=not_set}' paradigm. + +2002-08-10 Paul Eggert + + * src/nohup.sh: Don't use "exec --"; it's not portable and + shouldn't be needed. + +2002-08-09 Jim Meyering + + * src/pr.c (main): Don't ignore -COLUMN if it's the last option. + (usage): Clarify help text for the -COLUMN option. + Patch by Padraig Brady. + * tests/pr/Test.pm [col-last]: New test for the above. + + * configure.ac: Start with version 4.5.1, chosen so that it's larger + than the latest version numbers of the component packages. + + * man/Makefile.am (check-x-vs-1): Set and export PATH so we use + programs in ../src. + +2002-08-08 Jim Meyering + + * src/date.c: Guard inclusion of with + `#if HAVE_LANGINFO_CODESET', not `#if HAVE_LANGINFO_H'. + * src/sort.c: Likewise. + Patch by GOTO Masanori. + +2002-08-05 Paul Eggert + + Fix some minor time-related bugs with POSIX time arguments. + Some valid time stamps were being rejected (notably -1, and + time stamps before 1900 on 64-bit hosts). And some invalid + time stamps were being accepted, e.g. September 31. + + * src/date.c (main): Adjust to posixtime signature change. + * src/touch.c (main): Likewise. Remove unnecessary initialization. + Use localtime, not posixtm, to warn about obsolete "touch". + +2002-08-05 Jim Meyering + + * tests/misc/Makefile.am (TESTS): Add nice and pathchk1. + +2002-08-04 Jim Meyering + + * src/Makefile.am (check-README): New target/rule. + (check): Depend on it. + + * configure.ac (AC_CONFIG_FILES): Add old/Makefile and old/*/Makefile. + +2002-08-03 Jim Meyering + + * Makefile.am (SUBDIRS): Add old. + * old/: New directory, containing legacy ChangeLog* and NEWS files + from the fileutils, sh-utils, and textutils packages. + + * src/Makefile.am (AM_INSTALLCHECK_STD_OPTIONS_EXEMPT): Set to false. + +2002-08-02 Paul Eggert + + * NEWS, doc/coreutils.texi: uniq now obeys LC_COLLATE. + + * src/uniq.c: Include hard-locale.h, xmemcoll.h. + (hard_LC_COLLATE): New var. + (different): Args are now char *, not const char *. + Use xmemcoll instead of memcmp to compare lines, so that + LC_COLLATE has effect. However, use memcmp if it is an + easy locale. + (check_file): Do not include newline in comparison, so that + xmemcoll has a byte to stomp on temporarily. + (main): Set hard_LC_COLLATE. + +2002-07-29 Jim Meyering + + * Makefile.am (SUBDIRS): Remove djgpp, for now. + +2002-07-20 Jim Meyering + + * Makefile.am (false.c): Convert only the final EXIT_SUCCESS + into EXIT_FAILURE. Otherwise, false --help and false --version + would fail. + +2002-07-08 Jim Meyering + + * src/Makefile.am (uninstall-local): Search for @GNU_PACKAGE@, + rather than the hard-coded `sh-utils'. + +2002-07-01 Jim Meyering + + * configure.ac: Merge the three files from fileutils, + textutils, and sh-utils. + * Makefile.am: Likewise. + * src/Makefile.am: Likewise. diff --git a/INSTALL b/INSTALL new file mode 100644 index 000000000000..54caf7c190f2 --- /dev/null +++ b/INSTALL @@ -0,0 +1,229 @@ +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software +Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +will cause the specified gcc to be used as the C compiler (unless it is +overridden in the site shell script). + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/NEWS b/NEWS new file mode 100644 index 000000000000..31f459bd70de --- /dev/null +++ b/NEWS @@ -0,0 +1,904 @@ +GNU coreutils NEWS -*- outline -*- + +* Major changes in release 5.3.0 (2004-03-17) [unstable] + +** Bug fixes + + rm (without -f) no longer hangs when attempting to remove a symlink + to a file on an off-line NFS-mounted partition. + + cut's --output-delimiter=D option works with abutting byte ranges. + + rm no longer gets a failed assertion under some unusual conditions. + + Several fixes to chgrp and chown for compatibility with POSIX and BSD: + + Do not affect symbolic links by default. + Now, operate on whatever a symbolic points to, instead. + To get the old behavior, use --no-dereference (-h). + + --dereference now works, even when the specified owner + and/or group match those of an affected symlink. + + Check for incompatible options. When -R and --dereference are + both used, then either -H or -L must also be used. When -R and -h + are both used, then -P must be in effect. + + -H, -L, and -P have no effect unless -R is also specified. + If -P and -R are both specified, -h is assumed. + + Do not optimize away the chown() system call when the file's owner + and group already have the desired value. This optimization was + incorrect, as it failed to update the last-changed time and reset + special permission bits, as POSIX requires. + + Do not report an error if the owner or group of a + recursively-encountered symbolic link cannot be updated because + the file system does not support it. + + md5sum and sha1sum now report an error when given so many input + lines that their line counter overflows, instead of silently + reporting incorrect results. + + rm no longer requires read access to the current directory. + + "sort -o -" now writes to a file named "-" instead of to standard + output; POSIX requires this. + + tail -f no longer mishandles pipes and fifos. With no operands, + tail now ignores -f if standard input is a pipe, as POSIX requires. + + For some types of errors (e.g., read-only file system, I/O error) + when first encountering a directory, `rm -r' would mistakenly fail + to remove files under that directory. + + If d/x is a directory and x a file, "ln x d/" now reports an error + instead of incorrectly creating a link to d/x/x. + + Fixes for "nice": + + If it fails to lower the nice value due to lack of permissions, + it goes ahead and runs the command anyway, as POSIX requires. + + It no longer incorrectly reports an error if the current nice + value happens to be -1. + + It no longer assumes that nice values range from -20 through 19. + + It now consistently adjusts out-of-range nice values to the + closest values in range; formerly it sometimes reported an error. + + ptx now diagnoses invalid values for its --width=N (-w) + and --gap-size=N (-g) options. + + tee now exits when it gets a SIGPIPE signal, as POSIX requires. + To get tee's old behavior, use the shell command "(trap '' PIPE; tee)". + Also, "tee -" now writes to standard output instead of to a file named "-". + + ls no longer segfaults on systems for which SIZE_MAX != (size_t) -1 + + echo now conforms to POSIX better. It supports the \0ooo syntax for + octal escapes, and \c now terminates printing immediately. If + POSIXLY_CORRECT is set and the first argument is not "-n", echo now + outputs all option-like arguments instead of treating them as options. + + printf has several changes: + + It now uses 'intmax_t' (not 'long int') to format integers, so it + can now format 64-bit integers on most modern hosts. + + On modern hosts it now supports the C99-inspired %a, %A, %F conversion + specs, the "'" and "0" flags, and the ll, j, t, and z length modifiers + (this is compatible with recent Bash versions). + + The printf command now rejects invalid conversion specifications + like %#d, instead of relying on undefined behavior in the underlying + printf function. + + who now prints user names in full instead of truncating them after 8 bytes. + +** New features + + For efficiency, `sort -m' no longer copies input to a temporary file + merely because the input happens to come from a pipe. As a result, + some relatively-contrived examples like `cat F | sort -m -o F - G' + are no longer safe, as `sort' might start writing F before `cat' is + done reading it. This problem cannot occur unless `-m' is used. + + When outside the default POSIX locale, the 'who' and 'pinky' + commands now output time stamps like "2004-06-21 13:09" instead of + the traditional "Jun 21 13:09". + + pwd now works even when run from a working directory whose name + is longer than PATH_MAX. + + cp, install, ln, and mv have a new --no-target-directory (-T) option, + and -t is now a short name for their --target-directory option. + + cp -pu and mv -u (when copying) now don't bother to update the + destination if the resulting time stamp would be no newer than the + preexisting time stamp. This saves work in the common case when + copying or moving multiple times to the same destination in a file + system with a coarse time stamp resolution. + + dd has new conversions for the conv= option: + + nocreat do not create the output file + excl fail if the output file already exists + fdatasync physically write output file data before finishing + fsync likewise, but also write metadata + + dd has new iflag= and oflag= options with the following flags: + + append append mode (makes sense for output file only) + direct use direct I/O for data + dsync use synchronized I/O for data + sync likewise, but also for metadata + nonblock use non-blocking I/O + nofollow do not follow symlinks + + stty now provides support (iutf8) for setting UTF-8 input mode. + + With stat, a specified format is no longer automatically newline terminated. + If you want a newline at the end of your output, append `\n' to the format + string. + + 'df', 'du', and 'ls' now take the default block size from the + BLOCKSIZE environment variable if the BLOCK_SIZE, DF_BLOCK_SIZE, + DU_BLOCK_SIZE, and LS_BLOCK_SIZE environment variables are not set. + Unlike the other variables, though, BLOCKSIZE does not affect + values like 'ls -l' sizes that are normally displayed as bytes. + This new behavior is for compatibility with BSD. + + du accepts a new option --files0-from=FILE, where FILE contains a + list of NUL-terminated file names. + + `date -d' and `touch -d' now accept integer counts of seconds since + 1970 when prefixed by `@'. For example, `@321' represents + 1970-01-01 00:05:21 UTC. + + `date -d', `date -f' and `touch -d' now handle fractional time + stamps like 2004-02-27 14:19:13.489392193. + + `date' has a new option --iso-8601=ns that outputs + nanosecond-resolution time stamps. + + echo -e '\xHH' now outputs a byte whose hexadecimal value is HH, + for compatibility with bash. + + In the following cases POSIX allows the default GNU behavior, + so when POSIXLY_CORRECT is set: + + false, printf, true, unlink, and yes all support --help and --option. + ls supports TABSIZE. + pr no longer depends on LC_TIME for the date format in non-POSIX locales. + printf supports \u, \U, \x. + tail supports two or more files when using the obsolete option syntax. + + The usual `--' operand is now supported by chroot, hostid, hostname, + pwd, sync, and yes. + + The stat option --filesystem has been renamed to --file-system, for + consistency with POSIX "file system" and with cp and du --one-file-system. + +** Removed features + + tail's undocumented --max-consecutive-size-changes option has been removed. + +* Major changes in release 5.2.1 (2004-03-12) [stable] + +** Bug fixes + + mv could mistakenly fail to preserve hard links when moving two + or more arguments between partitions. + + `cp --sparse=always F /dev/hdx' no longer tries to use lseek to create + holes in the destination. + + nohup now sets the close-on-exec flag for its copy of the stderr file + descriptor. This avoids some nohup-induced hangs. For example, before + this change, if you ran `ssh localhost', then `nohup sleep 600 /dev/null takes about one hour + on a 1.6 GHz Athlon 2000 XP. Now it can output 2^53-1 numbers before + misbehaving. + +* Major changes in release 5.1.2 (2004-01-25): + +** Bug fixes + + rmdir -p exits with status 1 on error; formerly it sometimes exited + with status 0 when given more than one argument. + + nohup now always exits with status 127 when it finds an error, + as POSIX requires; formerly it sometimes exited with status 1. + + Several programs (including cut, date, dd, env, hostname, nl, pr, + stty, and tr) now always exit with status 1 when they find an error; + formerly they sometimes exited with status 2. + + factor no longer reports a usage error if stdin has the wrong format. + + paste no longer infloops on ppc systems (bug introduced in 5.1.1) + + +* Major changes in release 5.1.1 (2004-01-17): + +** Configuration option + + You can select the default level of POSIX conformance at configure-time, + e.g., by ./configure DEFAULT_POSIX2_VERSION=199209 + +** Bug fixes + + fold -s works once again on systems with differing sizes for int + and size_t (bug introduced in 5.1.0) + +** New features + + touch -r now specifies the origin for any relative times in the -d + operand, if both options are given. For example, "touch -r FOO -d + '-5 seconds' BAR" sets BAR's modification time to be five seconds + before FOO's. + + join: The obsolete options "-j1 FIELD", "-j2 FIELD", and + "-o LIST1 LIST2..." are no longer supported on POSIX 1003.1-2001 systems. + Portable scripts should use "-1 FIELD", "-2 FIELD", and + "-o LIST1,LIST2..." respectively. If join was compiled on a + POSIX 1003.1-2001 system, you may enable the old behavior + by setting _POSIX2_VERSION=199209 in your environment. + + +* Major changes in release 5.1.0 (2003-12-21): + +** New features + + chgrp, chmod, and chown can now process (with -R) hierarchies of virtually + unlimited depth. Before, they would fail to operate on any file they + encountered with a relative name of length PATH_MAX (often 4096) or longer. + + chgrp, chmod, chown, and rm accept the new options: + --preserve-root, --no-preserve-root (default) + + chgrp and chown now accept POSIX-mandated -L, -H, and -P options + + du can now process hierarchies of virtually unlimited depth. + Before, du was limited by the user's stack size and it would get a + stack overflow error (often a segmentation fault) when applied to + a hierarchy of depth around 30,000 or larger. + + du works even when run from an inaccessible directory + + du -D now dereferences all symlinks specified on the command line, + not just the ones that reference directories + + du now accepts -P (--no-dereference), for compatibility with du + of NetBSD and for consistency with e.g., chown and chgrp + + du's -H option will soon have the meaning required by POSIX + (--dereference-args, aka -D) rather then the current meaning of --si. + Now, using -H elicits a warning to that effect. + + When given -l and similar options, ls now adjusts the output column + widths to fit the data, so that output lines are shorter and have + columns that line up better. This may adversely affect shell + scripts that expect fixed-width columns, but such shell scripts were + not portable anyway, even with old GNU ls where the columns became + ragged when a datum was too wide. + + du accepts a new option, -0/--null, to make it produce NUL-terminated + output lines + +** Bug fixes + + printf, seq, tail, and sleep now parse floating-point operands + and options in the C locale. POSIX requires this for printf. + + od -c -w9999999 no longer segfaults + + csplit no longer reads from freed memory (dumping core on some systems) + + csplit would mistakenly exhaust virtual memory in some cases + + ls --width=N (for very large N) is no longer subject to an address + arithmetic bug that could result in bounds violations. + + ls --width=N (with -x or -C) no longer allocates more space + (potentially much more) than necessary for a given directory. + + dd `unblock' and `sync' may now be combined (e.g., dd conv=unblock,sync) + +* Major changes in release 5.0.91 (2003-09-08): + +** New features + + date accepts a new option --rfc-2822, an alias for --rfc-822. + + split accepts a new option -d or --numeric-suffixes. + + cp, install, mv, and touch now preserve microsecond resolution on + file timestamps, on platforms that have the 'utimes' system call. + Unfortunately there is no system call yet to preserve file + timestamps to their full nanosecond resolution; microsecond + resolution is the best we can do right now. + + sort now supports the zero byte (NUL) as a field separator; use -t '\0'. + The -t '' option, which formerly had no effect, is now an error. + + sort option order no longer matters for the options -S, -d, -i, -o, and -t. + Stronger options override weaker, and incompatible options are diagnosed. + + `sha1sum --check' now accepts the BSD format for SHA1 message digests + in addition to the BSD format for MD5 ones. + + who -l now means `who --login', not `who --lookup', per POSIX. + who's -l option has been eliciting an unconditional warning about + this impending change since sh-utils-2.0.12 (April 2002). + +** Bug fixes + + Mistakenly renaming a file onto itself, e.g., via `mv B b' when `B' is + the same directory entry as `b' no longer destroys the directory entry + referenced by both `b' and `B'. Note that this would happen only on + file systems like VFAT where two different names may refer to the same + directory entry, usually due to lower->upper case mapping of file names. + Now, the above can happen only on file systems that perform name mapping and + that support hard links (stat.st_nlink > 1). This mitigates the problem + in two ways: few file systems appear to be affected (hpfs and ntfs are), + when the bug is triggered, mv no longer removes the last hard link to a file. + *** ATTENTION ***: if you know how to distinguish the following two cases + without writing to the file system in question, please let me know: + 1) B and b refer to the same directory entry on a file system like NTFS + (B may well have a link count larger than 1) + 2) B and b are hard links to the same file + + stat no longer overruns a buffer for format strings ending in `%' + + fold -s -wN would infloop for N < 8 with TABs in the input. + E.g., this would not terminate: printf 'a\t' | fold -w2 -s + + `split -a0', although of questionable utility, is accepted once again. + + `df DIR' used to hang under some conditions on OSF/1 5.1. Now it doesn't. + + seq's --width (-w) option now works properly even when the endpoint + requiring the larger width is negative and smaller than the other endpoint. + + seq's default step is 1, even if LAST < FIRST. + + paste no longer mistakenly outputs 0xFF bytes for a nonempty input file + without a trailing newline. + + `tail -n0 -f FILE' and `tail -c0 -f FILE' no longer perform what amounted + to a busy wait, rather than sleeping between iterations. + + tail's long-undocumented --allow-missing option now elicits a warning + + +* Major changes in release 5.0.90 (2003-07-29): + +** New features + + sort is now up to 30% more CPU-efficient in some cases + + `test' is now more compatible with Bash and POSIX: + + `test -t', `test --help', and `test --version' now silently exit + with status 0. To test whether standard output is a terminal, use + `test -t 1'. To get help and version info for `test', use + `[ --help' and `[ --version'. + + `test' now exits with status 2 (not 1) if there is an error. + + wc count field widths now are heuristically adjusted depending on the input + size, if known. If only one count is printed, it is guaranteed to + be printed without leading spaces. + + Previously, wc did not align the count fields if POSIXLY_CORRECT was set, + but POSIX did not actually require this undesirable behavior, so it + has been removed. + +** Bug fixes + + kill no longer tries to operate on argv[0] (introduced in 5.0.1) + Why wasn't this noticed? Although many tests use kill, none of + them made an effort to avoid using the shell's built-in kill. + + `[' invoked with no arguments no longer evokes a segfault + + rm without --recursive (aka -r or -R) no longer prompts regarding + unwritable directories, as required by POSIX. + + uniq -c now uses a SPACE, not a TAB between the count and the + corresponding line, as required by POSIX. + + expr now exits with status 2 if the expression is syntactically valid, + and with status 3 if an error occurred. POSIX requires this. + + expr now reports trouble if string comparison fails due to a collation error. + + split now generates suffixes properly on EBCDIC hosts. + + split -a0 now works, as POSIX requires. + + `sort --version' and `sort --help' fail, as they should + when their output is redirected to /dev/full. + + `su --version > /dev/full' now fails, as it should. + +** Fewer arbitrary limitations + + cut requires 97% less memory when very large field numbers or + byte offsets are specified. + + +* Major changes in release 5.0.1 (2003-07-15): + +** New programs +- new program: `[' (much like `test') + +** New features +- head now accepts --lines=-N (--bytes=-N) to print all but the + N lines (bytes) at the end of the file +- md5sum --check now accepts the output of the BSD md5sum program, e.g., + MD5 (f) = d41d8cd98f00b204e9800998ecf8427e +- date -d DATE can now parse a DATE string like May-23-2003 +- chown: `.' is no longer recognized as a separator in the OWNER:GROUP + specifier on POSIX 1003.1-2001 systems. If chown *was not* compiled + on such a system, then it still accepts `.', by default. If chown + was compiled on a POSIX 1003.1-2001 system, then you may enable the + old behavior by setting _POSIX2_VERSION=199209 in your environment. +- chown no longer tries to preserve set-user-ID and set-group-ID bits; + on some systems, the chown syscall resets those bits, and previous + versions of the chown command would call chmod to restore the original, + pre-chown(2) settings, but that behavior is problematic. + 1) There was a window whereby a malicious user, M, could subvert a + chown command run by some other user and operating on files in a + directory where M has write access. + 2) Before (and even now, on systems with chown(2) that doesn't reset + those bits), an unwary admin. could use chown unwittingly to create e.g., + a set-user-ID root copy of /bin/sh. + +** Bug fixes +- chown --dereference no longer leaks a file descriptor per symlink processed +- `du /' once again prints the `/' on the last line +- split's --verbose option works once again [broken in 4.5.10 and 5.0] +- tail -f is no longer subject to a race condition that could make it + delay displaying the last part of a file that had stopped growing. That + bug could also make tail -f give an unwarranted `file truncated' warning. +- du no longer runs out of file descriptors unnecessarily +- df and `readlink --canonicalize' no longer corrupt the heap on + non-glibc, non-solaris systems +- `env -u UNSET_VARIABLE' no longer dumps core on non-glibc systems +- readlink's --canonicalize option now works on systems like Solaris that + lack the canonicalize_file_name function but do have resolvepath. +- mv now removes `a' in this example on all systems: touch a; ln a b; mv a b + This behavior is contrary to POSIX (which requires that the mv command do + nothing and exit successfully), but I suspect POSIX will change. +- date's %r format directive now honors locale settings +- date's `-' (no-pad) format flag now affects the space-padded-by-default + conversion specifiers, %e, %k, %l +- fmt now diagnoses invalid obsolescent width specifications like `-72x' +- fmt now exits nonzero when unable to open an input file +- tsort now fails when given an odd number of input tokens, + as required by POSIX. Before, it would act as if the final token + appeared one additional time. + +** Fewer arbitrary limitations +- tail's byte and line counts are no longer limited to OFF_T_MAX. + Now the limit is UINTMAX_MAX (usually 2^64). +- split can now handle --bytes=N and --lines=N with N=2^31 or more. + +** Portability +- `kill -t' now prints signal descriptions (rather than `?') on systems + like Tru64 with __sys_siglist but no strsignal function. +- stat.c now compiles on Ultrix systems +- sleep now works on AIX systems that lack support for clock_gettime +- rm now works around Darwin6.5's broken readdir function + Before `rm -rf DIR' would fail to remove all files in DIR + if there were more than 338. + +* Major changes in release 5.0 (2003-04-02): +- false --help now exits nonzero + +[4.5.12] +* printf no longer treats \x specially when POSIXLY_CORRECT is set +* printf avoids buffer overrun with format ending in a backslash and +* printf avoids buffer overrun with incomplete conversion specifier +* printf accepts multiple flags in a single conversion specifier + +[4.5.11] +* seq no longer requires that a field width be specified +* seq no longer fails when given a field width of `0' +* seq now accepts ` ' and `'' as valid format flag characters +* df now shows a HOSTNAME: prefix for each remote-mounted file system on AIX 5.1 +* portability tweaks for HP-UX, AIX 5.1, DJGPP + +[4.5.10] +* printf no longer segfaults for a negative field width or precision +* shred now always enables --exact for non-regular files +* du no longer lists hard-linked files more than once +* du no longer dumps core on some systems due to `infinite' recursion + via nftw's use of the buggy replacement function in getcwd.c +* portability patches for a few vendor compilers and 64-bit systems +* du -S *really* now works like it did before the change in 4.5.5 + +[4.5.9] +* du no longer truncates file sizes or sums to fit in 32-bit size_t +* work around Linux kernel bug in getcwd (fixed in 2.4.21-pre4), so that pwd + now fails if the name of the working directory is so long that getcwd + truncates it. Before it would print the truncated name and exit successfully. +* `df /some/mount-point' no longer hangs on a GNU libc system when another + hard-mounted NFS file system (preceding /some/mount-point in /proc/mounts) + is inaccessible. +* rm -rf now gives an accurate diagnostic when failing to remove a file + under certain unusual conditions +* mv and `cp --preserve=links' now preserve multiple hard links even under + certain unusual conditions where they used to fail + +[4.5.8] +* du -S once again works like it did before the change in 4.5.5 +* stat accepts a new file format, %B, for the size of each block reported by %b +* du accepts new option: --apparent-size +* du --bytes (-b) works the same way it did in fileutils-3.16 and before +* du reports proper sizes for directories (not zero) (broken in 4.5.6 or 4.5.7) +* df now always displays under `Filesystem', the device file name + corresponding to the listed mount point. Before, for a block- or character- + special file command line argument, df would display that argument. E.g., + `df /dev/hda' would list `/dev/hda' as the `Filesystem', rather than say + /dev/hda3 (the device on which `/' is mounted), as it does now. +* test now works properly when invoked from a set user ID or set group ID + context and when testing access to files subject to alternate protection + mechanisms. For example, without this change, a set-UID program that invoked + `test -w F' (to see if F is writable) could mistakenly report that it *was* + writable, even though F was on a read-only file system, or F had an ACL + prohibiting write access, or F was marked as immutable. + +[4.5.7] +* du would fail with more than one DIR argument when any but the last did not + contain a slash (due to a bug in ftw.c) + +[4.5.6] +* du no longer segfaults on Solaris systems (fixed heap-corrupting bug in ftw.c) +* du --exclude=FILE works once again (this was broken by the rewrite for 4.5.5) +* du no longer gets a failed assertion for certain hierarchy lay-outs + involving hard-linked directories +* `who -r' no longer segfaults when using non-C-locale messages +* df now displays a mount point (usually `/') for non-mounted + character-special and block files + +[4.5.5] +* ls --dired produces correct byte offset for file names containing + nonprintable characters in a multibyte locale +* du has been rewritten to use a variant of GNU libc's ftw.c +* du now counts the space associated with a directory's directory entry, + even if it cannot list or chdir into that subdirectory. +* du -S now includes the st_size of each entry corresponding to a subdirectory +* rm on FreeBSD can once again remove directories from NFS-mounted file systems +* ls has a new option --dereference-command-line-symlink-to-dir, which + corresponds to the new default behavior when none of -d, -l -F, -H, -L + has been specified. +* ls dangling-symlink now prints `dangling-symlink'. + Before, it would fail with `no such file or directory'. +* ls -s symlink-to-non-dir and ls -i symlink-to-non-dir now print + attributes of `symlink', rather than attributes of their referents. +* Fix a bug introduced in 4.5.4 that made it so that ls --color would no + longer highlight the names of files with the execute bit set when not + specified on the command line. +* shred's --zero (-z) option no longer gobbles up any following argument. + Before, `shred --zero file' would produce `shred: missing file argument', + and worse, `shred --zero f1 f2 ...' would appear to work, but would leave + the first file untouched. +* readlink: new program +* cut: new feature: when used to select ranges of byte offsets (as opposed + to ranges of fields) and when --output-delimiter=STRING is specified, + output STRING between ranges of selected bytes. +* rm -r can no longer be tricked into mistakenly reporting a cycle. +* when rm detects a directory cycle, it no longer aborts the entire command, + but rather merely stops processing the affected command line argument. + +[4.5.4] +* cp no longer fails to parse options like this: --preserve=mode,ownership +* `ls --color -F symlink-to-dir' works properly +* ls is much more efficient on directories with valid dirent.d_type. +* stty supports all baud rates defined in linux-2.4.19. +* `du symlink-to-dir/' would improperly remove the trailing slash +* `du ""' would evoke a bounds violation. +* In the unlikely event that running `du /' resulted in `stat ("/", ...)' + failing, du would give a diagnostic about `' (empty string) rather than `/'. +* printf: a hexadecimal escape sequence has at most two hex. digits, not three. +* The following features have been added to the --block-size option + and similar environment variables of df, du, and ls. + - A leading "'" generates numbers with thousands separators. + For example: + $ ls -l --block-size="'1" file + -rw-rw-r-- 1 eggert src 47,483,707 Sep 24 23:40 file + - A size suffix without a leading integer generates a suffix in the output. + For example: + $ ls -l --block-size="K" + -rw-rw-r-- 1 eggert src 46371K Sep 24 23:40 file +* ls's --block-size option now affects file sizes in all cases, not + just for --block-size=human-readable and --block-size=si. Fractional + sizes are now always rounded up, for consistency with df and du. +* df now displays the block size using powers of 1000 if the requested + block size seems to be a multiple of a power of 1000. +* nl no longer gets a segfault when run like this `yes|nl -s%n' + +[4.5.3] +* du --dereference-args (-D) no longer fails in certain cases +* `ln --target-dir=DIR' no longer fails when given a single argument + +[4.5.2] +* `rm -i dir' (without --recursive (-r)) no longer recurses into dir +* `tail -c N FILE' now works with files of size >= 4GB +* `mkdir -p' can now create very deep (e.g. 40,000-component) directories +* rmdir -p dir-with-trailing-slash/ no longer fails +* printf now honors the `--' command line delimiter +* od's 8-byte formats x8, o8, and u8 now work +* tail now accepts fractional seconds for its --sleep-interval=S (-s) option + +[4.5.1] +* du and ls now report sizes of symbolic links (before they'd always report 0) +* uniq now obeys the LC_COLLATE locale, as per POSIX 1003.1-2001 TC1. + +======================================================================== +Here are the NEWS entries made from fileutils-4.1 until the +point at which the packages merged to form the coreutils: + +[4.1.11] +* `rm symlink-to-unwritable' doesn't prompt [introduced in 4.1.10] +[4.1.10] +* rm once again gives a reasonable diagnostic when failing to remove a file + owned by someone else in a sticky directory [introduced in 4.1.9] +* df now rounds all quantities up, as per POSIX. +* New ls time style: long-iso, which generates YYYY-MM-DD HH:MM. +* Any time style can be preceded by "posix-"; this causes "ls" to + use traditional timestamp format when in the POSIX locale. +* The default time style is now posix-long-iso instead of posix-iso. + Set TIME_STYLE="posix-iso" to revert to the behavior of 4.1.1 thru 4.1.9. +* `rm dangling-symlink' doesn't prompt [introduced in 4.1.9] +* stat: remove support for --secure/-s option and related %S and %C format specs +* stat: rename --link/-l to --dereference/-L. + The old options will continue to work for a while. +[4.1.9] +* rm can now remove very deep hierarchies, in spite of any limit on stack size +* new programs: link, unlink, and stat +* New ls option: --author (for the Hurd). +* `touch -c no-such-file' no longer fails, per POSIX +[4.1.8] +* mv no longer mistakenly creates links to preexisting destination files + that aren't moved +[4.1.7] +* rm: close a hole that would allow a running rm process to be subverted +[4.1.6] +* New cp option: --copy-contents. +* cp -r is now equivalent to cp -R. Use cp -R -L --copy-contents to get the + traditional (and rarely desirable) cp -r behavior. +* ls now accepts --time-style=+FORMAT, where +FORMAT works like date's format +* The obsolete usage `touch [-acm] MMDDhhmm[YY] FILE...' is no longer + supported on systems conforming to POSIX 1003.1-2001. Use touch -t instead. +* cp and inter-partition mv no longer give a misleading diagnostic in some + unusual cases +[4.1.5] +* cp -r no longer preserves symlinks +* The block size notation is now compatible with SI and with IEC 60027-2. + For example, --block-size=1MB now means --block-size=1000000, + whereas --block-size=1MiB now means --block-size=1048576. + A missing `B' (e.g. `1M') has the same meaning as before. + A trailing `B' now means decimal, not binary; this is a silent change. + The nonstandard `D' suffix (e.g. `1MD') is now obsolescent. +* -H or --si now outputs the trailing 'B', for consistency with the above. +* Programs now output trailing 'K' (not 'k') to mean 1024, as per IEC 60027-2. +* New df, du short option -B is short for --block-size. +* You can omit an integer `1' before a block size suffix, + e.g. `df -BG' is equivalent to `df -B 1G' and to `df --block-size=1G'. +* The following options are now obsolescent, as their names are + incompatible with IEC 60027-2: + df, du: -m or --megabytes (use -BM or --block-size=1M) + df, du, ls: --kilobytes (use --block-size=1K) +[4.1.4] +* df --local no longer lists smbfs file systems whose name starts with // +* dd now detects the Linux/tape/lseek bug at run time and warns about it. +[4.1.3] +* ls -R once again outputs a blank line between per-directory groups of files. + This was broken by the cycle-detection change in 4.1.1. +* dd once again uses `lseek' on character devices like /dev/mem and /dev/kmem. + On systems with the linux kernel (at least up to 2.4.16), dd must still + resort to emulating `skip=N' behavior using reads on tape devices, because + lseek has no effect, yet appears to succeed. This may be a kernel bug. +[4.1.2] +* cp no longer fails when two or more source files are the same; + now it just gives a warning and doesn't copy the file the second time. + E.g., cp a a d/ produces this: + cp: warning: source file `a' specified more than once +* chmod would set the wrong bit when given symbolic mode strings like + these: g=o, o=g, o=u. E.g., `chmod a=,o=w,ug=o f' would give a mode + of --w-r---w- rather than --w--w--w-. +[4.1.1] +* mv (likewise for cp), now fails rather than silently clobbering one of + the source files in the following example: + rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c +* ls -R detects directory cycles, per POSIX. It warns and doesn't infloop. +* cp's -P option now means the same as --no-dereference, per POSIX. + Use --parents to get the old meaning. +* When copying with the -H and -L options, cp can preserve logical + links between source files with --preserve=links +* cp accepts new options: + --preserve[={mode,ownership,timestamps,links,all}] + --no-preserve={mode,ownership,timestamps,links,all} +* cp's -p and --preserve options remain unchanged and are equivalent + to `--preserve=mode,ownership,timestamps' +* mv and cp accept a new option: --reply={yes,no,query}; provides a consistent + mechanism to control whether one is prompted about certain existing + destination files. Note that cp's and mv's -f options don't have the + same meaning: cp's -f option no longer merely turns off `-i'. +* remove portability limitations (e.g., PATH_MAX on the Hurd, fixes for + 64-bit systems) +* mv now prompts before overwriting an existing, unwritable destination file + when stdin is a tty, unless --force (-f) is specified, as per POSIX. +* mv: fix the bug whereby `mv -uf source dest' would delete source, + even though it's older than dest. +* chown's --from=CURRENT_OWNER:CURRENT_GROUP option now works +* cp now ensures that the set-user-ID and set-group-ID bits are cleared for + the destination file when when copying and not preserving permissions. +* `ln -f --backup k k' gives a clearer diagnostic +* ls no longer truncates user names or group names that are longer + than 8 characters. +* ls's new --dereference-command-line option causes it to dereference + symbolic links on the command-line only. It is the default unless + one of the -d, -F, or -l options are given. +* ls -H now means the same as ls --dereference-command-line, as per POSIX. +* ls -g now acts like ls -l, except it does not display owner, as per POSIX. +* ls -n now implies -l, as per POSIX. +* ls can now display dates and times in one of four time styles: + + - The `full-iso' time style gives full ISO-style time stamps like + `2001-05-14 23:45:56.477817180 -0700'. + - The 'iso' time style gives ISO-style time stamps like '2001-05-14 ' + and '05-14 23:45'. + - The 'locale' time style gives locale-dependent time stamps like + 'touko 14 2001' and 'touko 14 23:45' (in a Finnish locale). + - The 'posix-iso' time style gives traditional POSIX-locale + time stamps like 'May 14 2001' and 'May 14 23:45' unless the user + specifies a non-POSIX locale, in which case it uses ISO-style dates. + This is the default. + + You can specify a time style with an option like --time-style='iso' + or with an environment variable like TIME_STYLE='iso'. GNU Emacs 21 + and later can parse ISO dates, but older Emacs versions cannot, so + if you are using an older version of Emacs outside the default POSIX + locale, you may need to set TIME_STYLE="locale". + +* --full-time is now an alias for "-l --time-style=full-iso". + + +======================================================================== +Here are the NEWS entries made from sh-utils-2.0 until the +point at which the packages merged to form the coreutils: + + [2.0.15] +* date no longer accepts e.g., September 31 in the MMDDhhmm syntax +* fix a bug in this package's .m4 files and in configure.ac + [2.0.14] +* nohup's behavior is changed as follows, to conform to POSIX 1003.1-2001: + - nohup no longer adjusts scheduling priority; use "nice" for that. + - nohup now redirects stderr to stdout, if stderr is not a terminal. + - nohup exit status is now 126 if command was found but not invoked, + 127 if nohup failed or if command was not found. + [2.0.13] +* uname and uptime work better on *BSD systems +* pathchk now exits nonzero for a path with a directory component + that specifies a non-directory + [2.0.12] +* kill: new program +* who accepts new options: --all (-a), --boot (-b), --dead (-d), --login, + --process (-p), --runlevel (-r), --short (-s), --time (-t), --users (-u). + The -u option now produces POSIX-specified results and is the same as + the long option `--users'. --idle is no longer the same as -u. +* The following changes apply on systems conforming to POSIX 1003.1-2001, + and are required by the new POSIX standard: + - `date -I' is no longer supported. Instead, use `date --iso-8601'. + - `nice -NUM' is no longer supported. Instead, use `nice -n NUM'. +* New 'uname' options -i or --hardware-platform, and -o or --operating-system. + 'uname -a' now outputs -i and -o information at the end. + New uname option --kernel-version is an alias for -v. + Uname option --release has been renamed to --kernel-release, + and --sysname has been renamed to --kernel-name; + the old options will work for a while, but are no longer documented. +* 'expr' now uses the LC_COLLATE locale for string comparison, as per POSIX. +* 'expr' now requires '+' rather than 'quote' to quote tokens; + this removes an incompatibility with POSIX. +* date -d 'last friday' would print a date/time that was one hour off + (e.g., 23:00 on *thursday* rather than 00:00 of the preceding friday) + when run such that the current time and the target date/time fall on + opposite sides of a daylight savings time transition. + This problem arose only with relative date strings like `last monday'. + It was not a problem with strings that include absolute dates. +* factor is twice as fast, for large numbers + [2.0.11] +* setting the date now works properly, even when using -u +* `date -f - < /dev/null' no longer dumps core +* some DOS/Windows portability changes + [2.0j] +* `date -d DATE' now parses certain relative DATEs correctly + [2.0i] +* fixed a bug introduced in 2.0h that made many programs fail with a + `write error' when invoked with the --version option + [2.0h] +* all programs fail when printing --help or --version output to a full device +* printf exits nonzero upon write failure +* yes now detects and terminates upon write failure +* date --rfc-822 now always emits day and month names from the `C' locale +* portability tweaks for Solaris8, Ultrix, and DOS + [2.0g] +* date now handles two-digit years with leading zeros correctly. +* printf interprets unicode, \uNNNN \UNNNNNNNN, on systems with the + required support; from Bruno Haible. +* stty's rprnt attribute now works on HPUX 10.20 +* seq's --equal-width option works more portably + [2.0f] +* fix build problems with ut_name vs. ut_user + [2.0e] +* stty: fix long-standing bug that caused test failures on at least HPUX + systems when COLUMNS was set to zero +* still more portability fixes +* unified lib/: now that directory and most of the configuration framework + is common between fileutils, textutils, and sh-utils + [2.0d] +* fix portability problem with sleep vs lib/strtod.c's requirement for -lm + [2.0c] +* fix portability problems with nanosleep.c and with the new code in sleep.c + [2.0b] +* Regenerate lib/Makefile.in so that nanosleep.c is distributed. + [2.0a] +* sleep accepts floating point arguments on command line +* sleep's clock continues counting down when sleep is suspended +* when a suspended sleep process is resumed, it continues sleeping if + there is any time remaining +* who once again prints whatever host information it has, even without --lookup + +======================================================================== +For older NEWS entries for the fileutils, textutils, and sh-utils +packages, see ./old/*/NEWS. + + This package began as the union of the following: + textutils-2.1, fileutils-4.1.11, sh-utils-2.0.15. diff --git a/README b/README new file mode 100644 index 000000000000..df35be461021 --- /dev/null +++ b/README @@ -0,0 +1,147 @@ +These are the GNU core utilities. This package is the union of +the GNU fileutils, sh-utils, and textutils packages. + +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: + + [ basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd + df dir dircolors dirname du echo env expand expr factor false fmt fold + ginstall groups head hostid hostname id join kill link ln logname ls + md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr + printenv printf ptx pwd readlink rm rmdir seq sha1sum shred sleep sort + split stat stty su sum sync tac tail tee test touch tr true tsort tty + uname unexpand uniq unlink uptime users vdir wc who whoami yes + +See the file NEWS for a list of major changes in the current release. + +See the file INSTALL for compilation and installation instructions. + +These programs are intended to conform to POSIX (with BSD and other +extensions), like the rest of the GNU system. By default they conform +to older POSIX (1003.2-1992), and therefore support obsolete usages +like "head -10" and "chown owner.group file". This default is +overridden at build-time by the value of 's _POSIX2_VERSION +macro, and this in turn can be overridden at runtime as described in +the documentation under "Standards conformance". + +The ls, dir, and vdir commands are all separate executables instead of +one program that checks argv[0] because people often rename these +programs to things like gls, gnuls, l, etc. Renaming a program +file shouldn't affect how it operates, so that people can get the +behavior they want with whatever name they want. + +Special thanks to Paul Eggert, Brian Matthews, Bruce Evans, Karl Berry, +Kaveh Ghazi, and François Pinard for help with debugging and porting +these programs. Many thanks to all of the people who have taken the +time to submit problem reports and fixes. All contributed changes are +attributed in the ChangeLog file. + +And thanks to the following people who have provided accounts for +portability testing on many different types of systems: Bob Proulx, +Christian Robert, François Pinard, Greg McGary, Harlan Stenn, +Joel N. Weber, Mark D. Roth, Matt Schalit, Nelson H. F. Beebe, +Réjean Payette, Sam Tardieu. + +Thanks to Michael Stone for inflicting test releases of the fileutils +on Debian's unstable distribution, and to all the kind folks who used +that distribution and found and reported bugs. + +Note that each man page is now automatically generated from a template +and from the corresponding --help usage message. Patches to the template +files (man/*.x) are welcome. However, the authoritative documentation +is in texinfo form in the doc directory. + +If you run the tests on a SunOS4.1.4 system, expect the ctime-part of +the ls `time-1' test to fail. I believe that is due to a bug in the +way Sun implemented link(2) and chmod(2). + +*************************************** +Last-minute notes, before coreutils-5.0 +--------------------------------------- + +A known problem exists when compiling on HPUX on both hppa and ia64 +in 64-bit mode (i.e. +DD64) on all known HPUX 11.x versions. This +is not due to a bug in the package but instead due to a bug in the +system header file which breaks things in 64-bit mode. The default +compilation mode is 32-bit and the software compiles fine using the +default mode. To build this software in 64-bit mode you will need +to fix the system /usr/include/inttypes.h header file. After +correcting that file the software also compiles fine in 64-bit mode. +Here is one possible patch to correct the problem. + +--- /usr/include/inttypes.h.orig Thu May 30 01:00:00 1996 ++++ /usr/include/inttypes.h Sun Mar 23 00:20:36 2003 +@@ -489 +489 @@ +-#ifndef __STDC_32_MODE__ ++#ifndef __LP64__ + +If you run the tests as root, note that a few of them create files +and/or run programs as a non-root user, `nobody' by default. +If you want to use some other non-root username, specify it via +the NON_ROOT_USERNAME environment variable. Depending on the +permissions with which the working directories have been created, +using `nobody' may fail, because that user won't have the required +read and write access to the build and test directories. +I find that it is best to unpack and build as a non-privileged +user, and then to run the following command as that user in order +to run the privilege-requiring tests: + + sudo env NON_ROOT_USERNAME=$USER make check + +If you can run the tests as root, please do so and report any +problems. We get much less test coverage in that mode, and it's +arguably more important that these tools work well when run by +root than when run by less privileged users. + +*************************************** + +There are pretty many tests, but nowhere near as many as we need. +Additions and corrections are very welcome. + +If you see a problem that you've already reported, feel free to re-report +it -- it won't bother me to get a reminder. Besides, the more messages I +get regarding a particular problem the sooner it'll be fixed -- usually. +If you sent a complete patch and, after a couple weeks you haven't +received any acknowledgement, please ping us. A complete patch includes +a well-written ChangeLog entry, unified (diff -u format) diffs relative +to the most recent test release (or, better, relative to the latest +sources in the CVS repository), an explanation for why the patch is +necessary or useful, and if at all possible, enough information to +reproduce whatever problem prompted it. Plus, you'll earn lots of +karma if you include a test case to exercise any bug(s) you fix. +Instructions for checking out the latest source via CVS are here: + + http://savannah.gnu.org/cvs/?group=coreutils + + +If your patch adds a new feature, please try to get some sort of consensus +that it is a worthwhile change. One way to do that is to send mail to +bug-coreutils@gnu.org including as much description and justification +as you can. Based on the feedback that generates, you may be able to +convince us that it's worth adding. + + +WARNING: If you modify files like configure.in, m4/*.m4, aclocal.m4, +or any Makefile.am, then don't be surprised if what gets regenerated no +longer works. To make things work, you'll have to be using appropriate +versions of automake and autoconf. As for what versions are `appropriate', +use the versions of + + * autoconf specified via AC_PREREQ in m4/jm-macros.m4 + * automake specified via AM_INIT_AUTOMAKE in configure.ac + +Usually it's fine to use versions that are newer than those specified. + +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 Coding Standards, +http://www.gnu.org/prep/standards_toc.html. + +Mail suggestions and bug reports for these programs to +the address on the last line of --help output. diff --git a/README-alpha b/README-alpha new file mode 100644 index 000000000000..e57d64948dfe --- /dev/null +++ b/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/THANKS b/THANKS new file mode 100644 index 000000000000..44b7b020f4d1 --- /dev/null +++ b/THANKS @@ -0,0 +1,463 @@ +These people have contributed to the GNU coreutils (formerly, the 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 send a note to +the bug-report mailing list (as seen on last line of e.g., cp --help). + +??? kytek@cybercomm.net +A Costa agcosta@gis.net +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 Chin-A-Young china@thewrittenword.com +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 +Alexey Vyskubov alexey@pippuri.mawhrin.net +Alfred M. Szmidt ams@kemisten.nu +Andi Kleen freitag@alancoxonachip.com +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 +Andrei Gaponenko andr@triumf.ca +Andres Soolo andres@soolo.matti.ee +Andrew Burgess aab@cichlid.com +Andrew Dalke dalke@bioreason.com +Andrew Fabbro andrew@fabbro.org +Andrew Pham andpha@us.ibm.com +Andrew Tridgell tridge@samba.org +Andrey Borzenkov arvidjaar@mail.ru +Andries Brouwer Andries.Brouwer@cwi.nl +Andy Longton alongton@metamark.com +Anthony Thyssen anthony@griffith.edu.au +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 +Arnold Robbins arnold@skeeve.com +Arthur Pool pool@commerce.uq.edu.au +Arun Sharma arun.sharma@intel.com +Arvind Autar Autar022@planet.nl +Augey Mikus mikus@dqc.org +Austin Donnelly Austin.Donnelly@cl.cam.ac.uk +Axel Kittenberger Anshil@gmx.net +Bauke Jan Douma bjdouma@xs4all.nl +Ben Elliston bje@air.net.au +Ben Harris bjh21@netbsd.org +Benjamin Cutler cutlerbc@simla.colostate.edu +Bengt Martensson bengt@mathematik.uni-Bremen.de +Bernard Giroud bernard.giroud@creditlyonnais.ch +Bernd Leibing bernd.leibing@rz.uni-ulm.de +Bernd Melchers melchers@cis.fu-berlin.de +Bernhard Baehr bernhard.baehr@gmx.de +Bernhard Gabler bernhard@uni-koblenz.de +Bernhard Rosenkraenzer bero@redhat.de +Bert Deknuydt Bert.Deknuydt@esat.kuleuven.ac.be +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 +Bruce Korb bkorb@veritas.com +Bruce Robertson brucer@theodolite.dyndns.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 Lesniewski ctl@mit.edu +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 +Clement Wang clem.wang@overture.com +Colin Plumb colin@nyx.net +Colin Watson cjw44@riva.ucam.org +Collin Rogowski collin@rogowski.de +Cray-Cyber Project http://www.cray-cyber.org +Dale Scheetz dwarf@polaris.net +Dan Hagerty hag@gnu.ai.it.edu +Dan Jacobson http://www.geocities.com/jidani +Dan Pascu dan@services.iiruc.ro +Daniel Bergstrom noa@melody.se +Dániel Varga danielv@axelero.hu +Danny Levinson danny.levinson@overture.com +Darren Salt ds@youmustbejoking.demon.co.uk +Dave Beckett dajobe@dajobe.org +David Dyck dcd@tc.fluke.COM +David Eisner cradle@umd.edu +David Flynn dav@chess.plus.com +David Godfrey dave@delta.demon.co.uk +David Luyer david_luyer@pacific.net.au +David Malone dwmalone@cnri.dit.ie +Deepak Goel deego@gnufans.org +Dennis Henriksen opus@flamingo.osrl.dk +Dennis Smit ds@nerds-incorporated.org +Derek Clegg dclegg@next.com +Dick Streefland dick_streefland@tasking.com +Dirk Lattermann dlatt@t-online.de +Dirk-Jan Faber djfaber@snow.nl +Dmitry Rutsky rutsky@school.ioffe.rssi.ru +Dmitry V. Levin ldv@altlinux.org +Don Parsons dparsons@synapse.kent.edu +Donni Erpel donald@appc11.gsi.de +Doug Coleman coleman@iarc1.ece.utexas.edu +Doug McLaren dougmc@comco.com +Dragos Harabor dharabor@us.oracle.com +Duncan Roe duncanr@optimation.com.au +Ed Avis ed@membled.com +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 +Ferdinand fw@scenic.mine.nu +Fletcher Mattox fletcher@cs.utexas.edu +Florin Iucha fiucha@hsys.mic.ro +François Pinard pinard@iro.umontreal.ca +Frank Adler fadler@allesklar.de +Frank T Lofaro ftlofaro@snooks.Egr.UNLV.EDU +Fred Fish fnf@ninemoons.com +Frédéric L. W. Meunier 0@pervalidus.net +Frederik Eaton frederik@caltech.edu +Gabor Z. Papp gzp@gzp.org.hu +Gaël Quéri gqueri@mail.dotcom.fr +Galen Hazelwood galenh@micron.net +Gary Anderson ganderson@clark.net +Gary V. Vaughan gary@gnu.org +Gaute Hvoslef Kvalnes gaute@verdsveven.com +Geoff Collyer geoff at collyer.net +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 +Göran Uddeborg goeran@uddeborg.pp.se +GOTO Masanori gotom@debian.or.jp +Greg Louis glouis@dynamicro.on.ca +Greg McGary gkm@gnu.org +Greg Schafer gschafer@zip.com.au +Greg Troxel gdt@bbn.com +Greg Wooledge gawooledge@sherwin.com +Gregory Leblanc gleblanc@cu-portland.edu +Guido Leenders guido.leenders@invantive.com +H. J. Lu hjl@valinux.com +Hans Ginzel hans@matfyz.cz +Hans Lermen lermen@fgan.de +Hans Verkuil hans@wyst.hobby.nl +Harry Liu rliu@lek.ugcs.caltech.edu +Harti Brandt brandt@fokus.fraunhofer.de +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 +Iida Yosiaki iida@gnu.org +Ingo Saitz ingo@debian.org +Ivo Timmermans ivo@debian.org +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 +Jean Charles Delepine delepine@u-picardie.fr +Jeff Moore jbm@mordor.com +Jeff Sheinberg jeff@bsrd.net +Jens Elkner elkner@imsgroup.de +Jens Schmidt jms@jsds.hamburg.com +Jerome Abela abela@hsc.fr +Jérôme Zago bug-coreutils-ml@agt-the-walker.net +Jesse Kornblum kornblum@usna.edu +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@manyfish.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 +Jon Peatfield J.S.Peatfield@damtp.cam.ac.uk +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 +Jurriaan thunder7@xs4all.nl +jvogel jvogel@linkny.com +Kai Henningsen kai@debian.org +Kai-Uwe Rommel rommel@informatik.tu-muenchen.de +Kalle Olavi Niemitalo kon@iki.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 M. Briggs keith.briggs@bt.com +Keith Owens kaos@audio.apana.org.au +Keith Thompson kst@cts.com +Ken Pizzini kenp@halcyon.com +Kristin E Thomas kristint@us.ibm.com +Kjetil Torgrim Homme kjetilho@ifi.uio.no +Kristoffer Rose kris@diku.dk +Larry McVoy lm@sgi.com +Lars Hecking lhecking@nmrc.ucc.ie +Leah Q eequor@earthlink.net +Lehti Rami rammer@cs.tut.fi +Leonard N. Zubkoff lnz@dandelion.com +Leonardo Milano lmilano@udel.edu +Lorne Baker lbaker@nitro.avint.net +Luke Hassell lukehassell@yahoo.com +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 Haber mh+debian-bugs@zugschlus.de +Marc Olzheim marcolz@stack.nl +Marco Franzen Marco.Franzen@Thyron.com +Marcus Brinkmann http://www.marcus-brinkmann.de +Marcus Daniels marcus@ee.pdx.edu +Mark A. Thomas thommark@access.digex.net +Mark Conty Mark_Conty@cargill.com +Mark D. Roth roth@uiuc.edu +Mark Funkenhauser mfunkenhauser@rogers.com +Mark Harris mark@monitor.designacc.com +Mark Hewitt mhewitt@armature.com +Mark Hounschell markh@compro.net +Mark Hubbart discord@mac.com +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 Buck martin.buck@ascom.ch +Martin Gallant martyg@goodbit.net +Martin Hippe martin.hippe@schlund.de +Martin Michlmayr tbm@cyrius.com +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 +Matt Swift swift@alum.mit.edu +Matthew Arnison maffew@cat.org.au +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 +Matthias Urlichs smurf@noris.de +Matti Aarnio matti.aarnio@zmailer.org +Mattias Wadenstein maswan@acc.umu.se +Meelis Roos mroos@tartu.cyber.ee +Michael michael@aplatform.com +Michael ??? michael@roka.net +Michael Bacarella mbac@netgraft.com> +Michael Deutschmann michael@talamasca.ocis.net +Michael Elizabeth Chastain mec.gnu@mindspring.com +Michael Gaughen mgaughen@polyserve.com +Michael Hasselberg mikelh@zonta.ping.de +Michael Hohn hohn@math.utah.edu +Michael J. Croghan mcroghan@usatoday.com +Michael McFarland sidlon@yahoo.com +Michael Piefel piefel@informatik.hu-berlin.de +Michael Steffens michael.steffens@s.netic.de +Michael Stone mstone@debian.org +Michael Stutz stutz@dsl.org +Michael van Elst mlelstv@dev.de.cw.net +Michael Veksler mveksler@techunix.technion.ac.il +Michail Litvak mci@owl.openwall.com +Michal Politowski mpol@charybda.icm.edu.pl +Michal Svec msvec@suse.cz +Michel Robitaille robitail@IRO.UMontreal.CA +Michiel Bacchiani bacchian@raven.bu.edu +Mike Castle dalgoda@ix.netcom.com +Mike Coleman mkc@mathdogs.com +Mike Jetzer mjetzer@mke.catalystwms.com +Mikko Tuumanen m@sorvankyla.yok.utu.fi +Mikulas Patocka mikulas@artax.karlin.mff.cuni.cz +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 +Neil Brown neilb@cse.unsw.edu.au +Nelson H. F. Beebe beebe@math.utah.edu +Nick Estes debian@nickstoys.com +Nick Lawes nlawes@silverplatter.com +Niklas Edmundsson nikke@acc.umu.se +Nikola Milutinovic Nikola.Milutinovic@ev.co.yu +Noah Friedman friedman@splode.com +Noel Cragg noel@red-bean.com +Olatunji Oluwabukunmi Ruwase tjruwase@stanford.edu +Olav Morkrid olav@funcom.com +Ole Laursen olau@hardworking.dk +Oliver Kiddle okiddle@yahoo.co.uk +Ørn E. Hansen oehansen@daimi.aau.dk +Oskar Liljeblad osk@hem.passagen.se +Patrick Mauritz oxygene@studentenbude.ath.cx +Paul Eggert eggert@twinsun.com +Paul Jarc prj@po.cwru.edu +Paul Nevai nevai@ops.mps.ohio-state.edu +Paul Sauer paul@alexa.com +Paul Slootman paul@debian.org +Paul Worrall paul@basilisk.uklinux.net +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 Horst peter@ointment.org +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 +Phillip Jones mouse@datastacks.com +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 +Raúl Núñez de Arenas Coronado raul@pleyades.net +Reuben Thomas rrt@sc3d.org +Richard A Downing richard.downing@bcs.org.uk +Richard Braakman dark@xs4all.nl +Richard Dawe rich@phekda.freeserve.co.uk +Richard J. Rauenzahn rrauenza@hairball.cup.hp.com +Richard Neill rn214@hermes.cam.ac.uk +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 +Robert Millan zeratul2@wanadoo.es +Rogier Wolff R.E.Wolff@BitWizard.nl +Roland Huebner ro-huebner@gmx.de +Roland Turner raz.tah.bet@raz.cx +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 +Samuel Tardieu sam@rfc1149.net +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 +Shing-Shong Shei shei@cs.indiana.edu +Soeren Sonnenburg sonnenburg@informatik.hu-berlin.de +Solar Designer solar@owl.openwall.com +Stanislav Ievlev inger@altlinux.ru +Stéphane Chazelas Stephane_CHAZELAS@yahoo.fr +Stephen Depooter sbdep@myrealbox.com +Stephen Eglen eglen@pcg.wustl.edu +Stephen Gildea gildea@stop.mail-abuse.org +Stephen Smoogen smooge@mindspring.com +Steve McConnel steve@acadcomp.sil.org +Steven G. Johnson stevenj@alum.mit.edu +Steven Mocking ufo@quicknet.nl +Steven P Watson steven@magelico.net +Stuart Kemp skemp@peter.bmc.com +Szakacsits Szabolcs szaka@sienet.hu +Tadayoshi Funaba tadf@kt.rim.or.jp +TAKAI Kousuke takai@vlsi.kuee.kyoto-u.ac.jp +Theodore Ts'o tytso@rsts-11.mit.edu +Thomas Bushnell thomas@gnu.ai.mit.edu +Thomas Goerlich thomas@schnappmatik.de +Thomas Luzat thomas@luzat.com +Thomas Quinot thomas@Cuivre.FR.EU.ORG +Tim J. Robbins tjr@FreeBSD.org +Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu +Tim Smithers mouse@dmouse.com.au +Tim Waugh twaugh@redhat +Todd A. Jacobs tjacobs@codegnome.org +Tom Haynes thomas@netapp.com +Tom Quinn trq@dionysos.thphys.ox.ac.uk +Tommi Kyntola tkyntola@cc.hut.fi +Ton Hospel thospel@mail.dma.be +Ton Nijkes ton@murphy.nl +Tony Kocurko akocurko@mun.ca +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 +Volker Paul vpaul@dohle.com +Wartan Hachaturow wart@tepkom.ru +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 +wiregauze wiregauze@yahoo.com +Wojciech Purczynski cliph@isec.pl +Wolfram Kleff kleff@cs.uni-bonn.de +Won-kyu Park wkpark@chem.skku.ac.kr +Yann Dirson dirson@debian.org +Zvi Har'El rl@math.technion.ac.il diff --git a/THANKS-to-translators b/THANKS-to-translators new file mode 100644 index 000000000000..c84ff647b57e --- /dev/null +++ b/THANKS-to-translators @@ -0,0 +1,36 @@ +The following teams have translated the many diagnostics of this +package into many different languages. Thank you! + +--- +http://www.iro.umontreal.ca/contrib/po/HTML/team-af.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-be.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-ca.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-cs.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-da.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-de.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-el.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-es.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-et.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-fi.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-fr.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-ga.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-gl.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-hu.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-it.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-ja.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-ko.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-lg.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-ms.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-nb.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-nl.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-no.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-pl.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-pt.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-pt_BR.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-ru.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-sk.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-sl.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-sv.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-tr.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-zh_CN.html +http://www.iro.umontreal.ca/contrib/po/HTML/team-zh_TW.html diff --git a/TODO b/TODO new file mode 100644 index 000000000000..82a74bf6dca8 --- /dev/null +++ b/TODO @@ -0,0 +1,171 @@ +restore djgpp, eventually +merge TODO lists +add unit tests for lib/*.c + +strip: add an option to specify the program used to strip binaries. + suggestion from Karl Berry + +doc/coreutils.texi: + Address this comment: FIXME: mv's behavior in this case is system-dependent + Better still: fix the code so it's *not* system-dependent. + +implement --target-directory=DIR for install (per texinfo documentation) + +ls: add --format=FORMAT option that controls how each line is printed. + +cp --no-preserve=X should not attempt to preserve attribute X + reported by Andreas Schwab + +copy.c: Address the FIXME-maybe comment in copy_internal. +And once that's done, add an exclusion so that `cp --link' +no longer incurs the overhead of saving src. dev/ino and dest. filename +in the hash table. + +See if we can be consistent about where --verbose sends its output: + These all send --verbose output to stdout: + head, tail, rm, cp, mv, ln, chmod, chown, chgrp, install, ln + These send it to stderr: + shred mkdir split + readlink is different + +Write an autoconf test to work around build failure in HPUX's 64-bit mode. +See notes in README -- and remove them once there's a work-around. + +Integrate use of sendfile, suggested here: + http://mail.gnu.org/archive/html/bug-fileutils/2003-03/msg00030.html +I don't plan to do that, since a few tests demonstrate no significant benefit. + +Should printf '\0123' print "\n3"? + per report from TAKAI Kousuke on Mar 27 + http://mail.gnu.org/archive/html/bug-coreutils/2003-03/index.html + +printf: consider adapting builtins/printf.def from bash + +df: add `--total' option, suggested here http://bugs.debian.org/186007 + +seq: give better diagnostics for invalid formats: + e.g. no or too many % directives +seq: consider allowing format string to contain no %-directives + +m4: rename all macros that start with AC_ to start with another prefix + +resolve RH report on cp -a forwarded by Tim Waugh + +Martin Michlmayr's patch to provide ls with `--sort directory' option + +tail: don't use xlseek; it *exits*. + Instead, maybe use a macro and return nonzero. + +add mktemp? Suggested by Nelson Beebe + +df: alignment problem of `Used' heading with e.g., -mP + reported by Karl Berry + +tr: support nontrivial equivalence classes, e.g. [=e=] with LC_COLLATE=fr_FR + +fix tail -f to work with named pipes; reported by Ian D. Allen + $ mkfifo j; tail -f j & sleep 1; echo x > j + ./tail: j: file truncated + ./tail: j: cannot seek to offset 0: Illegal seek + +lib/strftime.c: Since %N is the only format that we need but that + glibc's strftime doesn't support, consider using a wrapper that + would expand /%(-_)?\d*N/ to the desired string and then pass the + resulting string to glibc's strftime. + +sort: Compress temporary files when doing large external sort/merges. + This improves performance when you can compress/uncompress faster than + you can read/write, which is common in these days of fast CPUs. + suggestion from Charles Randall on 2001-08-10 + +sort: Add an ordering option -R that causes 'sort' to sort according + to a random permutation of the correct sort order. Also, add an + option --random-seed=SEED that causes 'sort' to use an arbitrary + string SEED to select which permutations to use, in a deterministic + manner: that is, if you sort a permutation of the same input file + with the same --random-seed=SEED option twice, you'll get the same + output. The default SEED is chosen at random, and contains enough + information to ensure that the output permutation is random. + suggestion from Feth AREZKI, Stephan Kasal, and Paul Eggert on 2003-07-17 + +unexpand: [http://www.opengroup.org/onlinepubs/007908799/xcu/unexpand.html] + printf 'x\t \t y\n'|unexpand -t 8,9 should print its input, unmodified. + printf 'x\t \t y\n'|unexpand -t 5,8 should print "x\ty\n" + +Let GNU su use the `wheel' group if appropriate. + (there are a couple patches, already) + +sort: Investigate better sorting algorithms; see Knuth vol. 3. + + We tried list merge sort, but it was about 50% slower than the + recursive algorithm currently used by sortlines, and it used more + comparisons. We're not sure why this was, as the theory suggests it + should do fewer comparisons, so perhaps this should be revisited. + List merge sort was implemented in the style of Knuth algorithm + 5.2.4L, with the optimization suggested by exercise 5.2.4-22. The + test case was 140,213,394 bytes, 426,4424 lines, text taken from the + GCC 3.3 distribution, sort.c compiled with GCC 2.95.4 and running on + Debian 3.0r1 GNU/Linux, 2.4GHz Pentium 4, single pass with no + temporary files and plenty of RAM. + + Since comparisons seem to be the bottleneck, perhaps the best + algorithm to try next should be merge insertion. See Knuth section + 5.3.1, who credits Lester Ford, Jr. and Selmer Johnson, American + Mathematical Monthly 66 (1959), 387-389. + +cp --recursive: perform dir traversals in source and dest hierarchy rather + than forming full file names. The latter (current) approach fails + unnecessarily when the names become very long. + +tail --p is now ambiguous + +Remove suspicious uses of alloca (ones that may allocate more than + about 4k) + +Adapt these contribution guidelines for coreutils: + http://sources.redhat.com/automake/contribute.html + + +Changes expected to go in, post-5.2.1: +====================================== + + wc: add an option, --files0-from [as for du] to make it read NUL-delimited + file name arguments from a file. + + dd patch from Olivier Delhomme + + Apply Andreas Gruenbacher's ACL and xattr changes + + Apply Bruno Haible's hostname changes + + test/mv/*: clean up $other_partition_tmpdir in all cases + + ls: when both -l and --dereference-command-line-symlink-to-dir are + specified, consider whether to let the latter select whether to + dereference command line symlinks to directories. Since -l has + an implicit --NO-dereference-command-line-symlink-to-dir meaning. + Pointed out by Karl Berry. + + A more efficient version of factor, and possibly one that + accepts inputs of size 2^64 and larger. + + Re-add a separate test for du's stack space usage (like the one removed + from tests/rm/deep-1). + + dd: consider adding an option to suppress `bytes/block read/written' + output to stderr. Suggested here: + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=165045 + + Pending copyright papers: + ------------------------ + ls --color: Ed Avis' patch to suppress escape sequences for + non-highlighted files + + getpwnam from Bruce Korb + + pb (progress bar) from Miika Pekkarinen + + Look into improving the performance of md5sum. + `openssl md5' is consistently about 30% faster than md5sum on an idle + AMD 2000-XP system with plenty of RAM and a 261 MB input file. + openssl's md5 implementation is in assembly, generated by a perl script. diff --git a/contrib/gnu-sort/ABOUT-NLS b/contrib/gnu-sort/ABOUT-NLS deleted file mode 100644 index 8ffb46736877..000000000000 --- a/contrib/gnu-sort/ABOUT-NLS +++ /dev/null @@ -1,716 +0,0 @@ -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 December -2003. 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 am az be bg ca cs da de el en en_GB eo es - +-------------------------------------------+ - a2ps | [] [] [] [] | - aegis | () | - ant-phone | () | - anubis | | - ap-utils | | - bash | [] [] [] [] | - batchelor | | - bfd | [] [] | - binutils | [] [] | - bison | [] [] [] | - bluez-pin | [] [] | - clisp | | - clisp | [] [] [] | - coreutils | [] [] [] [] | - cpio | [] [] [] | - darkstat | [] () [] | - diffutils | [] [] [] [] [] [] [] | - e2fsprogs | [] [] | - enscript | [] [] [] [] | - error | [] [] [] [] [] | - fetchmail | [] () [] [] [] [] | - fileutils | [] [] [] | - findutils | [] [] [] [] [] [] [] | - flex | [] [] [] [] | - fslint | | - gas | [] | - gawk | [] [] [] [] | - gbiff | [] | - gcal | [] | - gcc | [] [] | - gettext | [] [] [] [] [] | - gettext-examples | [] [] [] | - gettext-runtime | [] [] [] [] [] | - gettext-tools | [] [] [] | - gimp-print | [] [] [] [] [] | - gliv | | - glunarclock | [] [] | - gnubiff | [] | - gnucash | [] () [] [] | - gnucash-glossary | [] () [] | - gnupg | [] () [] [] [] [] | - gpe-aerial | [] | - gpe-beam | [] [] | - gpe-calendar | [] [] | - gpe-clock | [] [] | - gpe-conf | [] [] | - gpe-contacts | [] [] | - gpe-edit | [] | - gpe-go | [] | - gpe-login | [] [] | - gpe-ownerinfo | [] [] | - gpe-sketchbook | [] [] | - gpe-su | [] [] | - gpe-taskmanager | [] [] | - gpe-timesheet | [] | - gpe-today | [] [] | - gpe-todo | [] [] | - gphoto2 | [] [] [] [] | - gprof | [] [] [] | - gpsdrive | () () () | - gramadoir | [] | - grep | [] [] [] [] [] [] | - gretl | [] | - gtick | () | - hello | [] [] [] [] [] [] | - id-utils | [] [] | - indent | [] [] [] [] | - jpilot | [] [] [] | - jtag | | - jwhois | [] | - kbd | [] [] [] [] [] | - latrine | () | - ld | [] [] | - libc | [] [] [] [] [] [] | - libgpewidget | [] [] | - libiconv | [] [] [] [] [] | - lifelines | [] () | - lilypond | [] | - lingoteach | | - lingoteach_lessons | () () | - lynx | [] [] [] [] | - m4 | [] [] [] [] | - mailutils | [] [] | - make | [] [] [] | - man-db | [] () [] [] () | - minicom | [] [] [] | - mysecretdiary | [] [] [] | - nano | [] () [] [] [] | - nano_1_0 | [] () [] [] [] | - opcodes | [] | - parted | [] [] [] [] [] | - ptx | [] [] [] [] [] | - python | | - radius | [] | - recode | [] [] [] [] [] [] [] | - rpm | [] [] | - screem | | - scrollkeeper | [] [] [] [] [] [] | - sed | [] [] [] [] [] | - sh-utils | [] [] [] | - shared-mime-info | | - sharutils | [] [] [] [] [] [] | - silky | () | - skencil | [] () [] | - sketch | [] () [] | - soundtracker | [] [] [] | - sp | [] | - tar | [] [] [] [] | - texinfo | [] [] [] | - textutils | [] [] [] [] | - tin | () () | - tuxpaint | [] [] [] [] [] [] [] | - util-linux | [] [] [] [] [] | - vorbis-tools | [] [] [] [] | - wastesedge | () | - wdiff | [] [] [] [] | - wget | [] [] [] [] [] [] | - xchat | [] [] [] [] | - xfree86_xkb_xml | [] | - xpad | [] | - +-------------------------------------------+ - am az be bg ca cs da de el en en_GB eo es - 0 0 8 3 37 38 56 73 15 1 5 12 64 - - et fa fi fr ga gl he hr hu id is it ja - +----------------------------------------+ - a2ps | [] [] [] () | - aegis | | - ant-phone | | - anubis | [] | - ap-utils | [] | - bash | [] [] | - batchelor | [] | - bfd | [] | - binutils | [] [] | - bison | [] [] [] [] | - bluez-pin | [] [] [] [] [] | - clisp | | - clisp | [] | - coreutils | [] [] [] [] [] [] | - cpio | [] [] [] | - darkstat | () [] [] [] | - diffutils | [] [] [] [] [] [] [] | - e2fsprogs | | - enscript | [] [] | - error | [] [] [] [] | - fetchmail | [] | - fileutils | [] [] [] [] [] [] | - findutils | [] [] [] [] [] [] [] [] [] [] | - flex | [] [] | - fslint | | - gas | [] | - gawk | [] [] [] | - gbiff | | - gcal | [] | - gcc | [] | - gettext | [] [] | - gettext-examples | [] [] | - gettext-runtime | [] [] [] [] | - gettext-tools | [] [] | - gimp-print | [] [] | - gliv | () | - glunarclock | [] [] [] [] | - gnubiff | | - gnucash | () [] | - gnucash-glossary | [] | - gnupg | [] [] [] [] [] [] [] | - gpe-aerial | [] | - gpe-beam | [] | - gpe-calendar | [] [] [] | - gpe-clock | [] | - gpe-conf | [] | - gpe-contacts | [] [] | - gpe-edit | [] [] | - gpe-go | [] | - gpe-login | [] [] | - gpe-ownerinfo | [] [] [] | - gpe-sketchbook | [] | - gpe-su | [] | - gpe-taskmanager | [] | - gpe-timesheet | [] [] [] | - gpe-today | [] [] | - gpe-todo | [] [] | - gphoto2 | [] [] [] | - gprof | [] [] | - gpsdrive | () [] () () | - gramadoir | [] | - grep | [] [] [] [] [] [] [] [] [] [] [] | - gretl | [] | - gtick | [] [] | - hello | [] [] [] [] [] [] [] [] [] [] [] [] | - id-utils | [] [] [] [] | - indent | [] [] [] [] [] [] [] [] [] | - jpilot | [] () | - jtag | | - jwhois | [] [] [] [] | - kbd | [] | - latrine | | - ld | [] | - libc | [] [] [] [] [] | - libgpewidget | [] [] [] [] | - libiconv | [] [] [] [] [] [] [] [] [] | - lifelines | () | - lilypond | [] | - lingoteach | [] [] | - lingoteach_lessons | | - lynx | [] [] [] [] | - m4 | [] [] [] [] | - mailutils | | - make | [] [] [] [] [] | - man-db | () () | - minicom | [] [] [] [] | - mysecretdiary | [] [] | - nano | [] [] [] [] | - nano_1_0 | [] [] [] [] | - opcodes | [] | - parted | [] [] [] | - ptx | [] [] [] [] [] [] [] | - python | | - radius | [] | - recode | [] [] [] [] [] [] | - rpm | | - screem | | - scrollkeeper | [] | - sed | [] [] [] [] [] [] [] [] [] | - sh-utils | [] [] [] [] [] [] [] | - shared-mime-info | [] | - sharutils | [] [] [] [] [] | - silky | [] () | - skencil | [] | - sketch | [] | - soundtracker | [] [] [] [] | - sp | [] () | - tar | [] [] [] [] [] [] [] [] [] | - texinfo | [] [] [] [] | - textutils | [] [] [] [] [] | - tin | [] () | - tuxpaint | [] [] [] [] [] [] [] [] | - util-linux | [] [] [] [] () [] | - vorbis-tools | [] | - wastesedge | () | - wdiff | [] [] [] [] [] [] | - wget | [] [] [] [] [] [] [] | - xchat | [] [] [] | - xfree86_xkb_xml | | - xpad | [] | - +----------------------------------------+ - et fa fi fr ga gl he hr hu id is it ja - 21 1 25 86 24 24 8 10 38 31 1 23 32 - - ko lg lt lv ms nb nl nn no pl pt pt_BR ro - +-------------------------------------------+ - a2ps | () [] [] () () [] [] | - aegis | () () | - ant-phone | [] [] | - anubis | [] [] [] [] [] | - ap-utils | [] () [] | - bash | [] [] | - batchelor | [] | - bfd | [] | - binutils | | - bison | [] [] [] [] | - bluez-pin | [] [] [] | - clisp | | - clisp | [] | - coreutils | [] | - cpio | [] [] [] [] [] | - darkstat | [] [] [] [] | - diffutils | [] [] [] [] | - e2fsprogs | [] | - enscript | [] [] [] | - error | [] [] [] | - fetchmail | [] [] () | - fileutils | [] [] | - findutils | [] [] [] [] [] | - flex | [] [] [] [] | - fslint | [] [] | - gas | | - gawk | [] [] [] | - gbiff | [] [] | - gcal | | - gcc | | - gettext | [] [] [] | - gettext-examples | [] [] | - gettext-runtime | [] [] [] | - gettext-tools | [] [] [] | - gimp-print | [] | - gliv | [] [] [] | - glunarclock | [] [] [] | - gnubiff | | - gnucash | [] [] () | - gnucash-glossary | [] [] | - gnupg | [] | - gpe-aerial | [] [] [] | - gpe-beam | [] [] [] | - gpe-calendar | [] [] [] | - gpe-clock | [] [] [] | - gpe-conf | [] [] [] | - gpe-contacts | [] [] [] | - gpe-edit | [] [] [] | - gpe-go | [] [] | - gpe-login | [] [] [] | - gpe-ownerinfo | [] [] [] | - gpe-sketchbook | [] [] [] | - gpe-su | [] [] [] | - gpe-taskmanager | [] [] [] | - gpe-timesheet | [] [] [] | - gpe-today | [] [] [] | - gpe-todo | [] [] [] | - gphoto2 | [] | - gprof | [] [] | - gpsdrive | () () () [] | - gramadoir | [] | - grep | [] [] [] [] | - gretl | | - gtick | [] [] | - hello | [] [] [] [] [] [] [] [] [] [] | - id-utils | [] [] [] | - indent | [] [] [] | - jpilot | () () | - jtag | | - jwhois | [] [] [] [] | - kbd | [] [] [] | - latrine | [] | - ld | | - libc | [] [] [] [] [] | - libgpewidget | [] [] [] | - libiconv | [] [] [] [] | - lifelines | | - lilypond | | - lingoteach | | - lingoteach_lessons | | - lynx | [] [] | - m4 | [] [] [] [] | - mailutils | [] [] | - make | [] [] [] [] | - man-db | [] | - minicom | [] [] [] | - mysecretdiary | [] [] [] | - nano | [] [] [] [] | - nano_1_0 | [] [] [] [] [] | - opcodes | [] [] | - parted | [] [] [] [] | - ptx | [] [] [] [] [] [] [] | - python | | - radius | [] | - recode | [] [] [] | - rpm | [] [] | - screem | | - scrollkeeper | [] [] [] [] | - sed | [] [] [] | - sh-utils | [] | - shared-mime-info | [] | - sharutils | [] | - silky | | - skencil | [] [] | - sketch | [] [] | - soundtracker | | - sp | | - tar | [] [] [] [] [] [] | - texinfo | [] [] [] | - textutils | [] [] | - tin | | - tuxpaint | [] [] [] [] [] [] [] [] [] | - util-linux | [] [] | - vorbis-tools | [] [] | - wastesedge | | - wdiff | [] [] [] [] | - wget | [] [] | - xchat | [] [] | - xfree86_xkb_xml | [] | - xpad | [] [] | - +-------------------------------------------+ - ko lg lt lv ms nb nl nn no pl pt pt_BR ro - 12 0 1 2 12 10 60 4 4 38 25 35 76 - - ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW - +-------------------------------------------+ - a2ps | [] [] [] [] [] | 16 - aegis | () | 0 - ant-phone | | 2 - anubis | [] [] [] | 9 - ap-utils | () | 3 - bash | [] | 9 - batchelor | | 2 - bfd | [] [] | 6 - binutils | [] [] [] | 7 - bison | [] [] [] | 14 - bluez-pin | [] [] [] | 13 - clisp | | 0 - clisp | | 5 - coreutils | [] [] [] [] [] | 16 - cpio | [] [] [] | 14 - darkstat | [] [] [] () () | 12 - diffutils | [] [] [] [] | 22 - e2fsprogs | [] [] | 5 - enscript | [] [] [] | 12 - error | [] [] [] | 15 - fetchmail | [] [] [] | 11 - fileutils | [] [] [] [] [] [] | 17 - findutils | [] [] [] [] [] [] [] | 29 - flex | [] [] [] | 13 - fslint | | 2 - gas | [] | 3 - gawk | [] [] | 12 - gbiff | | 3 - gcal | [] [] | 4 - gcc | [] | 4 - gettext | [] [] [] [] [] [] | 16 - gettext-examples | [] [] [] [] | 11 - gettext-runtime | [] [] [] [] [] [] [] [] [] | 21 - gettext-tools | [] [] [] [] [] [] | 14 - gimp-print | [] [] | 10 - gliv | | 3 - glunarclock | [] [] [] [] | 13 - gnubiff | | 1 - gnucash | [] [] [] | 9 - gnucash-glossary | [] [] [] | 8 - gnupg | [] [] [] [] | 17 - gpe-aerial | [] [] | 7 - gpe-beam | [] [] | 8 - gpe-calendar | [] [] [] [] [] | 13 - gpe-clock | [] [] [] [] | 10 - gpe-conf | [] [] [] | 9 - gpe-contacts | [] [] [] [] | 11 - gpe-edit | [] [] [] [] [] [] | 12 - gpe-go | [] | 5 - gpe-login | [] [] [] [] [] [] | 13 - gpe-ownerinfo | [] [] [] [] [] | 13 - gpe-sketchbook | [] [] [] | 9 - gpe-su | [] [] [] [] | 10 - gpe-taskmanager | [] [] [] [] | 10 - gpe-timesheet | [] [] [] [] [] | 12 - gpe-today | [] [] [] [] [] [] | 13 - gpe-todo | [] [] [] [] [] | 12 - gphoto2 | [] [] [] | 11 - gprof | [] [] | 9 - gpsdrive | [] [] | 4 - gramadoir | | 3 - grep | [] [] [] [] [] | 26 - gretl | | 2 - gtick | [] | 5 - hello | [] [] [] [] [] | 33 - id-utils | [] [] [] | 12 - indent | [] [] [] [] [] | 21 - jpilot | [] [] [] [] [] | 9 - jtag | [] | 1 - jwhois | () () [] [] | 11 - kbd | [] [] | 11 - latrine | | 1 - ld | [] [] | 5 - libc | [] [] [] [] | 20 - libgpewidget | [] [] [] [] | 13 - libiconv | [] [] [] [] [] [] [] [] [] | 27 - lifelines | [] | 2 - lilypond | [] | 3 - lingoteach | | 2 - lingoteach_lessons | () | 0 - lynx | [] [] [] [] | 14 - m4 | [] [] [] | 15 - mailutils | [] | 5 - make | [] [] [] [] | 16 - man-db | [] | 5 - minicom | [] | 11 - mysecretdiary | [] [] | 10 - nano | [] [] [] [] [] | 17 - nano_1_0 | [] [] [] [] | 17 - opcodes | [] [] | 6 - parted | [] [] [] | 15 - ptx | [] [] [] | 22 - python | | 0 - radius | [] | 4 - recode | [] [] [] [] | 20 - rpm | [] [] [] | 7 - screem | [] [] | 2 - scrollkeeper | [] [] [] [] | 15 - sed | [] [] [] [] [] [] | 23 - sh-utils | [] [] [] | 14 - shared-mime-info | [] [] | 4 - sharutils | [] [] [] [] [] | 17 - silky | () | 2 - skencil | [] | 6 - sketch | [] | 6 - soundtracker | [] [] | 9 - sp | [] | 3 - tar | [] [] [] [] [] | 24 - texinfo | [] [] [] [] | 14 - textutils | [] [] [] [] [] | 16 - tin | | 1 - tuxpaint | [] [] [] [] [] | 29 - util-linux | [] [] [] | 15 - vorbis-tools | [] | 8 - wastesedge | | 0 - wdiff | [] [] [] [] | 18 - wget | [] [] [] [] [] [] [] [] | 23 - xchat | [] [] [] [] [] | 14 - xfree86_xkb_xml | [] [] [] [] [] [] | 8 - xpad | | 4 - +-------------------------------------------+ - 51 teams ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW - 120 domains 59 42 16 25 81 0 56 12 1 10 21 22 1260 - - 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 December 2003 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 -the 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 deleted file mode 100644 index 4e8a5d49efaa..000000000000 --- a/contrib/gnu-sort/AUTHORS +++ /dev/null @@ -1,86 +0,0 @@ -Here are the names of the programs in this package, -each followed by the name(s) of its author(s). - -basename: FIXME unknown -cat: Torbjorn Granlund and Richard M. Stallman -chgrp: David MacKenzie -chmod: David MacKenzie -chown: David MacKenzie -chroot: Roland McGrath -cksum: Q. Frank Xia -comm: Richard Stallman and David MacKenzie -cp: Torbjorn Granlund, David MacKenzie, and Jim Meyering -csplit: Stuart Kemp and David MacKenzie -cut: David Ihnat, David MacKenzie, and Jim Meyering -date: David MacKenzie -dd: Paul Rubin, David MacKenzie, and Stuart Kemp -df: Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert -dircolors: H. Peter Anvin -dirname: David MacKenzie and Jim Meyering -du: Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert -echo: FIXME unknown -env: Richard Mlynarik and David MacKenzie -expand: David MacKenzie -expr: Mike Parker -factor: Paul Rubin -false: no one -fmt: Ross Paterson -fold: David MacKenzie -head: David MacKenzie -hostid: Jim Meyering -hostname: Jim Meyering -id: Arnold Robbins and David MacKenzie -install: David MacKenzie -join: Mike Haertel -kill: Paul Eggert -link: Michael Stone -ln: Mike Parker and David MacKenzie -logname: FIXME: unknown -ls: Richard Stallman and David MacKenzie -md5sum: Ulrich Drepper and Scott Miller -mkdir: David MacKenzie -mkfifo: David MacKenzie -mknod: David MacKenzie -mv: Mike Parker, David MacKenzie, and Jim Meyering -nice: David MacKenzie -nl: Scott Bartram and David MacKenzie -od: Jim Meyering -paste: David M. Ihnat and David MacKenzie -pathchk: David MacKenzie and Jim Meyering -pinky: Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi -pr: Pete TerMaat and Roland Huebner -printenv: David MacKenzie and Richard Mlynarik -printf: David MacKenzie -ptx: François Pinard -pwd: Jim Meyering -rm: Paul Rubin, David MacKenzie, Richard Stallman, and Jim Meyering -rmdir: David MacKenzie -seq: Ulrich Drepper -shred: Colin Plumb -sleep: Jim Meyering and Paul Eggert -sort: Mike Haertel and Paul Eggert -split: Torbjorn Granlund and Richard M. Stallman -stat: Michael Meskes -stty: David MacKenzie -su: David MacKenzie -sum: Kayvan Aghaiepour and David MacKenzie -sync: Jim Meyering -tac: Jay Lepreau and David MacKenzie -tail: Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering -tee: Mike Parker, Richard M. Stallman, and David MacKenzie -test: FIXME: ksb and mjb -touch: Paul Rubin, Arnold Robbins, Jim Kingdon, David MacKenzie, and Randy Smith -tr: Jim Meyering -true: no one -tsort: Mark Kettenis -tty: David MacKenzie -uname: David MacKenzie -unexpand: David MacKenzie -uniq: Richard Stallman and David MacKenzie -unlink: Michael Stone -uptime: Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi -users: Joseph Arceneaux and David MacKenzie -wc: Paul Rubin and David MacKenzie -who: Joseph Arceneaux, David MacKenzie, and Michael Stone -whoami: Richard Mlynarik -yes: David MacKenzie diff --git a/contrib/gnu-sort/COPYING b/contrib/gnu-sort/COPYING deleted file mode 100644 index d60c31a97a54..000000000000 --- a/contrib/gnu-sort/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - 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 deleted file mode 100644 index c0276553d191..000000000000 --- a/contrib/gnu-sort/ChangeLog +++ /dev/null @@ -1,7511 +0,0 @@ -2004-08-11 Paul Eggert - - * tests/install/basic-1: Test for the -d regression. - -2004-08-11 Dmitry V. Levin - - * src/install.c (main): Fix -d regression introduced with - --target-directory support at 2004-06-25. - -2004-08-11 Paul Eggert - - * src/copy.c (copy_internal): When preserving links, unlink - a destination with link count greater than one. This is so - that commands like "cp -a" don't get confused when copying into - a destination that already contains many hard links. Problem - reported by Tim Waugh in: - http://lists.gnu.org/archive/html/bug-coreutils/2004-08/msg00053.html - -2004-08-10 Paul Eggert - - Convert all files to UTF-8. - * tests/fmt/basic (8-bit-pfx): Use UTF-8, not Latin-1. - * tests/sort/Test.pm (16a): Likewise. - * tests/uniq/Test.pm (8): Likewise. - * tests/misc/printf-hex: Use ASCII, not Latin-1. - - * NEWS: Document "sort -o -" and "tee -" POSIX-conformance fixes. - * src/shred.c (usage): "-" is an operand, not an option. - * src/sort.c (die, xfopen, mergefps, first_same_file, merge): - A null file arg means standard output. - (main): "-o -" means to write to a file named "-", - not to standard output. - * src/tee.c (usage, tee): "tee -" writes to standard output, not - to a file named "-". - -2004-08-10 Dmitry V. Levin - - * src/install.c (change_timestamps): Fix int->bool conversion - bugs introduced on 2004-07-29. - -2004-08-09 Paul Eggert - - * src/shred.c (wipename): Work even if the directory is writeable - and not readable. Prefer write access, since this should work - better with fdatasync. - - * src/csplit.c (xalloc_die): New function. - (main): Remove now-obsolete initialization of xalloc_fail_func. - - * src/md5sum.c: Adjust to sha->sha1 renaming. - -2004-08-08 Dmitry V. Levin - - Minor code cleanup. - * src/readlink.c (canonicalize_fname): Remove unneeded proxy function. - (can_mode): Make variable local. - -2004-08-07 Paul Eggert - - * src/system.h (O_BINARY) [!O_BINARY && defined O_BINARY]: - Do not define, to avoid annoying compiler messages on QNX 6.3. - Problem reported by Johan in: - http://lists.gnu.org/archive/html/bug-coreutils/2004-08/msg00050.html - -2004-08-04 Paul Eggert - - * src/system.h (PRIdMAX, PRIoMAX, PRIuMAX, PRIxMAX): - Define to a concatenation of string literals, not to an expression; - needed for concatenation contexts. - (INTMAX_MAX, INTMAX_MIN): New macros. - - * src/stat.c (print_stat): Don't assume st_ino / st_dev fits in - unsigned long; this isn't true for st_ino on Solaris 9. - -2004-08-03 Paul Eggert - - * src/uname.c: Do not depend on HAVE_SYSCTL when deciding - whether to include files. Include if - HAVE_SYS_PARAM_H (not HAVE_SYSCTL). - (main) [defined __POWERPC__]: Add a kludge to work around a - Mac OS X bug, so that uname -p defaults to "powerpc" if - sysctl ((int[]) {CTL_HW, HW_MACHINE_ARCH}, 2, buffer, &bufsize, 0, 0) - fails. Problem reported by Petter Reinholdtsen in: - http://lists.gnu.org/archive/html/bug-gnu-utils/2003-02/msg00201.html - - * src/uniq.c (hard_LC_COLLATE, ignore_case, different, check_file, - main): Use bool for booleans. - (writeline, check_file): Use uintmax_t for line counts. - (check_file): Check for and report line number overflow, - when that matters. - * src/wc.c (iswspace, wc): Use to_uchar rather than a cast. - (print_lines, print_words, print_chars, print_bytes, print_linelength, - have_read_stdin, wc, wc_file, main): - Use bool for booleans. - (exit_status): Remove. - (wc, wc_file): Return bool status. All callers changed. - * src/who.c (scan_entries): 0 -> STDIN_FILENO. - * src/whoami.c (main): Print uids using unsigned long int, not - unsigned int. - - * src/unexpand.c: Int cleanup and minor reorganization to be more - like src/expand.c. - Include quote.h, xstrndup.h. - (TAB_STOP_SENTINEL): Increase from INT_MAX to INTMAX_MAX. - (convert_entire_line, have_read_stdin, parse_tabstops, next_file, - unexpand, main): - Use bool for booleans. - (tab_size, tab_list, add_tabstop, validate_tabstops, unexpand): - Use uintmax_t for column counts. - (first_free_tab, validate_tabstops, unexpand): Use size_t for sizes. - (add_tabstop, parse_tabstops, main): Don't reserve UINTMAX_MAX - as a tab stop. - (parse_tabstops): Don't use ISBLANK on possibly-signed char. - Detect overflow in tab stop string. - (next_file, main): Use EXIT_FAILURE/EXIT_SUCCESS instead of 1/0. - (unexpand): Concatenate input files the same way expand does. - - * src/touch.c (no_create, use_ref, posix_date, amtime_now, - touch, main): Use bool for booleans. - (main): Avoid integer overflow when given more than INT_MAX - options. - * src/tsort.c (struct item, n_strings): Use size_t for sizes. - (have_read_stdin, count_items, scan_zeros, detect_loop, - recurse_tree, walk_tree, tsort, main): - Use bool for booleans. - (exit_status): Remove. - (tsort): Return a success flag instead of storing into a global. - (main): Use it. - * src/tty.c (silent, main): Use bool for booleans. - (main): 0 -> STDIN_FILENO. - * src/uname.c (print_element): Use bool for booleans. - - * src/test.c (TRUE, FALSE, SHELL_BOOLEAN, TRUTH_OR, TRUTH_AND): - Remove. All uses replaced by C99 boolean primitives. - (TEST_TRUE, TEST_FALSE): New constants, for readability. - (test_unop, binop, unary_operator, binary_operator, two_arguments, - three_arguments, posixtest, expr, term, and, or, is_int, age_of, - one_argument, main): Use bool for booleans. - (advance, unary_advance): Now inline procedures rather than a macros. - (is_int): Renamed from isint, to avoid namespace clash with ctype.h. - (term, and, or): When it's easy, loop instead of recursing. - (term): Avoid integer overflow if there are INT_MAX-3 args (!). - (binary_operator, unary_operator): Simplify by systematically rewriting - true==FOO to FOO (where FOO is a boolean). - (unary_operator): Don't consider a file to be a regular file - merely because its mode&S_IFMT is zero. Just use S_ISREG. - Remove unnecessary casts. Remove ifdefs for things like - S_ISSOCK that are no longer needed, since stat-macros.h always - defines them now. - - * src/tac-pipe.c (buf_init_from_stdin, find_bol, tac_mem): - Use bool for booleans. - (buf_init_from_stdin, buf_free, find_bol, print_line): - Use size_t for sizes. - * src/tac.c (separator_ends_record, tac_seekable, tac_file, - tac_stdin, tac_stdin_to_mem, main): Use bool for booleans. - (match_length, G_buffer_size, tac_seekable, main): Use size_t for sizes. - (tac_seekable): Use ptrdiff_t for pointer subtraction. - Report an error if the result is out of range. - (tac_seekable, main): Check for integer overflow in buffer size - calculations. - (main): Remove unnecessary casts. - - * src/su.c (run_shell): Pass a new n_additional_args arg, so that - the callee doesn't have to count 'em. All callers changed. - Don't allocate more space for the arg vector than we'll need. - Use memcpy to copy the args rather than rolling our own loop. - Use size_t for sizes. - (fast_startup, simulate_login, change_environment, log_su, - correct_password, restricted_shell, main): Use bool for booleans. - (longopts): Don't assume change_environment is an int. - Use NULL, not 0, for pointers. - (xsetenv): New function, replacing xputenv and concat. - All callers changed. - (elements): Remove; no longer needed. - (log_su, correct_passwd, main): Prefer !x to x==NULL. - (log_su): 2 -> STDERR_FILENO. - (modify_environment, main): Don't assume that getenv's returned value - has an indefinite lifetime. - (modify_environment): Allocate a larger environ. - (main): Remove an impossible 'case 0'; if it happens now, it'll - get diagnosed. Don't assume getpwnam results outlive endpwent. - Check for null or empty pw_name, pw_dir and for null pw_passwd. - - * src/stty.c (VA_START): Remove. All callers now use va_start. - (_POSIX_VDISABLE): Remove unnecessary cast. - (struct control_info, visible): Use cc_t for control chars. - (struct control_info): Use size_t for sizes. - (recover_mode, set_mode, display_speed, display_window_size, - valid_options, main, display_changed): - Use bool for booleans. - (integer_arg): Return unsigned long int, not long int. - Accept new max arg; all callers changed, to specify a maximum - value for integer parameters instead of silently overflowing. - (wrap): Do not overrun the stack buffer if the output contains - more than 1024 bytes. Instead, malloc a buffer. - (main): Remove a "what is this?!?" FIXME. Nobody knows what it is. - Remove unnecessary casts. - (set_control_char): Allow int values only up to cc_t range. - (screen_columns): Don't reject INT_MAX. - (display_changed, display_all, display_speed, recover_mode): - Don't assume cc_t fits in int. - - * src/remove.h: Add copyright notice. - (struct rm_options): Use bool for booleans. - * src/rmdir.c (empty_paths, ignore_fail_on_non_empty, verbose, - errno_rmdir_non_empty, remove_parents, main): Likewise. - * src/sum.c (have_read_stdin, bsd_sum_file, sysv_sum_file, - main): Likewise. - (main): Don't dump core if invoked with argv[0]==NULL. - * src/tee.c (tee, append, ignore_interrupts, main, tee): - Use bool for booleans. - (tee): Use ssize_t for read returns. - - * src/ptx.c: Add a FIXME mentioning that there are many - unchecked integer overflows in this file. - (gnu_extensions, auto_reference, input_reference, right_reference, - ignore_case, initialize_regex, fix_output_parameters, - output_one_roff_line, output_one_text_line, output_one_dumb_line, main): - Use bool for booleans. - (SKIP_SOMETHING, compare_words, digest_break_file, - find_occurs_in_text, fix_output_parameters): - Use to_uchar instead of a caset. - (print_field): Rewrite to avoid cast. - - * src/printf.c (posixly_correct): Use bool for booleans. - (verify, main): Use EXIT_FAILURE/EXIT_SUCCESS instead of 1/0. - (STRTOX): Rewrite to avoid casts. - (print_esc_char): Arg is char, not int. - * src/readlink.c (canonicalize): Remove. All uses now merely inspect - can_mode. - (no_newline, verbose): Use bool for booleans. - (can_mode): Now of type int; use -1 to denote otherwise-uninitialized. - * src/shred.c (struct Options, main): Use bool for booleans. - (isaac_seed_data, fillpattern, wipefile): Rewrite to avoid casts. - * src/split.c (cwrite, bytes_split, lines_split, line_bytes_split): - Use bool for booleans. - * src/stat.c (G_fail): Remove. - (print_statfs): Print various gotta-be-nonnegative values using - unsigned long int, not long int or int. - (do_statfs, do_stat): Return a boolean success flag. - (do_stat, main): Use bool for booleans. - - * src/pr.c: Add a FIXME mentioning that there are many - unchecked integer overflows in this file. - (TRUE, FALSE): Remove. All uses replaced by true and false. - (struct COLUMN, read_line, print_page, print_stored, open_file, - skip_to_page, init_fps, parallel_files, align_empty_cols, - empty_line, FF_only, explicit_columns, extremities, keep_FF, - print_a_FF, print_a_header, use_form_feed, have_read_stdin, - print_across_flag, storing_columns, balance_columns, - truncate_lines, join_lines, untabify_input, failed_opens, - numbered_lines, skip_count, use_esc_sequence, use_cntrl_prefix, - double_space, ignore_failed_opens, use_col_separator, - pad_vertically, last_line, main, init_parameters, skip_read, - read_line, print_stored): - Use bool for booleans. - (struct COLUMN, char_to_clump, store_char, print_char): - Use char for chars. - (clump_buff, print_clump): Use char[], not int[], for an array whose - elements are always chars. - (first_last_page, main, getoptarg, balance, add_line_number, - char_to_uclump): Remove unnecessary casts. - (init_parameters): Allocate chars, not ints, for clump_buff. - (print_char): Use to_uchar before invoking ISPRINT. - (char_to_clump): Convert to unsigned char before invoking ISPRINT. - - * src/nohup.c (main): Use bool for booleans. - * src/paste.c (paste_parallel, paste_serial, main): Likewise. - * src/pathchk.c (validate-path, main, portable_chars_only): Likewise. - (portable_chars_only): Use to_uchar rather than a cast. - * src/printenv.c (main): Use bool for booleans. - Do not assume that the environ has at most one matching entry - for each option (integer overflow was possible otherwise). - - * src/od.c (FMT_BYTES_ALLOCATED): Now an enum, not a decimal - constant. Do not assume PRIdMAX etc. are strings of length 3 or - less. - (struct tspec): Use it. fmt_string is now an array, not - a pointer, as there's little point to the indirection here. - (struct tspec, flag_dump_strings, - traditional, flag_pseudo_start, limit_bytes_to_format, - abbreviate_duplicate_blocks, have_read_stdin, simple_strtoul, - decode_one_format, open_next_file, check_and_close, - decode_format_string, skip, write_block, read_char, read_block, - parse_old_offset, dump, dump_strings, main): - Use bool for booleans. - (struct tspec): Use void *, not char *, for generic pointers. - (bytes_to_oct_digits, bytes_to_signed_dec_digits, - bytes_to_unsigned_dec_digits, bytes_to_hex_digits): - Use char, not unsigned int, since char suffices. - (print_s_char, print_char, print_s_short, print_short, - print_int, print_long, print_long_long, print_float, - print_double, print_long_double): Rewrite to avoid casts. - These now take void * arguments, instead of char *. - Use the same body for all functions, except for the choice - of type. Assume C89 to simplify handling of signed char. - (dump_hexl_mode_trailer, print_named_ascii, print_ascii): - Rewrite to avoid casts. - (print_named_ascii, print_ascii): Now takes void *, not char *. - (decode_one_format): Use int for printf field widths, not - unsigned int. Pass void * to subsidiary printers, - not char *. Simplify handling of floating-point formats - by factoring out common code dealing with precision and field width. - (decode_format_string): Avoid need for temporary copy of - each decoded struct tspec. - (get_lcm): Remove unnecessary cast. - (main): Fix bug where more than INT_MAX failed decodes were ignored. - -2004-08-02 Paul Eggert - - * src/nl.c (TRUE, FALSE): Remove; all uses changed to true, false. - (enum number_format): Remove. - (FORMAT_RIGHT_NOLZ, FORMAT_RIGHT_LZ, FORMAT_LEFT): Now strings, - not enum values. - (DEFAULT_SECTION_DELIMITERS): Now an array constant, not a macro. - (section_del): Now const. - (print_fmt): Remove. - (starting_line_number, page_incr, blank_join, line_no, - print_lineno, proc_text, main): - Use intmax_t for line numbers. - (reset_numbers, have_read_stdin, build_type_arg, nl_file, main): - Use bool for booleans. - (lineno_format): Now a string, not an enum value. - (build_print_fmt): Remove. All calls removed. This work is - now done within print_lineno. - (build_type_arg): Use size_t for sizes. - (print_lineno): Check for line number overflow. - (proc_text, main): Remove unnecessary cast. - - * src/ln.c (symbolic_link, interactive, remove_existing_files, - verbose, hard_dir_link, dereference_dest_dir_symlinks, - do_link, main): Use bool for booleans. - - * src/ls.c (struct fileinfo, file_interesting, - extract_dirs_from_files, color_symlink_as_referent, - FILE_OR_LINK_MODE, sort_reverse, print_owner, print_group, - numeric_ids, print_block_size, dired, print_with_color, - check_symlink_color, print_inode, recursive, immediate_dirs, - all_files, really_all_files, qmark_funny_chars, - print_dir_name, format_needs_stat, format_needs_type, visit_dir, - main, decode_switches, parse_ls_color, print_dir, file_interesting, - gobble_file, make_link_path, basename_is_dot_or_dotdot, - extract_dirs_from_files, print_long_format): - Use bool for booleans. - (dir_defaulted): Remove; no longer needed. - (main): Use int to count files, since it suffices for argv. - Rewrite to avoid need for dir_defaulted. - (main, print_dir, gobble_file, get_link_name, - xstrcoll): - Set exit status to EXIT_SUCCES/EXIT_FAILURE rather than 0/1. - (decode_switches): Put back check for ws.ws_col <= SIZE_MAX. - Remove unnecessary cast to int. Use int instead of unsigned - int to count from 0 to 1. - (get_funky_string, print_type_indicator): Use char for bytes, not int. - (make_link_path): Use NULL for null pointers. - (quote_name): Use to_uchar instead of cast. - - * src/id.c (use_name, main, print_user, xgetgroups, print_group_list, - print_full_info): Use bool for booleans. - (problems): Remove, replacing with.... - (ok): New var (inverted from old sense). - (print_user, print_group, print_full_info): - Print uids/gids with %lu, not %u. - (xgetgroups): Don't run out of memory if getgroups or getugroups - returns -1. - * src/setuidgid.c (main): Print uids/gids with %lu, not %ld. - - * src/factor.c (wheel_tab): Use unsigned char instead of unsigned - int, since it suffices. - (factor, print_factors): Use size_t for sizes. - (print_factors, do_stdin, main): Use bool for booleans. - * src/fold.c (TAB_WIDTH): New macro; use it instead of "8". - (fold_file, main): Use bool for booleans. - (fold_file, main): Use size_t for sizes. - (main): Allow -w options up to SIZE_MAX - TAB_WIDTH - 1, instead - of prohibiting widths greater than INT_MAX. - * src/head.c (presume_input_pipe, print_headers, have_read_stdin, - write_header, elide_tail_bytes_pipe, elide_tail_bytes_file, - elide_tail_lines_pipe, elide_tail_lines_seekable, - elide_tail_lines_file, head_bytes, head_lines, head, head_file, - string_to_integer, main): - Use bool for booleans. - (main): Rewrite to avoid cast. - - * src/csplit.c (struct line): Use size_t for sizes. - (main): Remove unnecessary cast. - * src/cut.c (cut_fields): Use to_uchar rather than a cast. - * src/cut.c (cut_file, main): Use bool for booleans. - * src/date.c (show_date, rfc_format, batch_convert, main): Likewise. - * src/env.c (main): Likewise. - * src/expr.c (nextarg): Likewise. - * src/env.c (main): Remove unused and nonstandard envp arg. - - * src/fmt.c (COST, MAXWORDS): Add a comment describing some of - fmt's arbitrary limits. - (TRUE, FALSE): Remove; all uses changed to (true, false). - (main): Use bool for booleans. - Limit maximum width to MAXCHARS / 2. Use xstrtoul, not xstrtol, - to parse width. - (copy_rest): Remove unnecessary cast. - (get_prefix): Rewrite to avoid cast. - (check_punctuation): Use char *, not unsigned char *; C89 requires - this. Avoid off-by-one buffer read overrun when line is empty. - (flush_paragraph): Don't assume wptr-parabuf is <= INT_MAX. - Remove unnecessary casts. - * tests/fmt/basic (wide-1, wide-2, bad-suffix): Adjust to above - changes. - - * src/expand.c (convert_entire_line, have_read_stdin, parse_tabstops, - next_file, expand, main): - Use bool for booleans. - (tab_size, tab_list, add_tabstop, parse_tabstops, validate_tabstops, - expand, main): - Use uintmax_t for column counts. - (add_tabstop): Don't reserve -1 (now UINTMAX_MAX) as a special value. - All callers changed. - (parse_tabstops): Don't pass a negative char to isblank. - Avoid memory leak with large tab stops. - (validate_tabstops, expand): Don't assume number of tab stops is - <= INT_MAX. - (next_file, main): Use EXIT_SUCCESS/EXIT_FAILURE rather than 0/1 when - storing values into exit_status. - (expand): Use same pattern as unexpand for reading chars. - Report an error when input line is too long, instead of silently - screwing up. Do not mishandle tab stops when backspacing left - over start of line. - - * src/dircolors.c (have_read_stdin, append_quoted, - dc_parse_stream, dc_parse_file, main): Use bool for booleans. - (dc_parse_stream): Use enum for state, rather than int. - Use ssize_t to store getline result. - - * src/dd.c (translation_needed, parse_integer, scanargs, - apply_translations, char_is_saved, swab_buffer, skip_via_lseek): - Use bool for booleans. - (translate_buffer): Use to_uchar rather than a cast. - (swab_buffer, copy_simple, copy_with_unblock): - Use size_t for sizes. - - * src/seq.c (equal_width, valid_format, main): Use bool for booleans. - * src/sleep.c (apply_suffix): Likewise. - * src/tail.c (struct File_spec, reopen_inaccessible_files, count_lines, - forever, from_start, print_headers, have_read_stdin, valid_file_spec, - write_header, file_lines, pipe_lines, pipe_bytes, recheck, - tail_forever, tail_bytes, tail_lines, tail, tail_file, - parse_obsolescent_option, parse_options, main): Likewise. - * src/sleep.c (apply_suffix): Invert sense of result. - Use int (not unsigned int) for multiplier, as this generates better - code with some compilers. Simplify code a bit. - * src/tail.c (struct File_spec, max_n_unchanged_stats_between_opens, - parse_options): Use uintmax_t, not unsigned int or unsigned long int, - for state counters. - (tail_bytes, tail_lines): Redo test of return value (-1, 0, 1) to - make it a bit clearer. - - * src/hostname.c: Include "xgethostname.h". - (xgethostname): Remove decl; xgethostname.h has it. - (sethostname) [!defined(HAVE_SETHOSTNAME) && defined(HAVE_SYSINFO) - && defined (HAVE_SYS_SYSTEMINFO_H) && defined(HAVE_LIMITS_H)]: Use - prototypes rather than K&R form. Assume any negative value from - sysinfo denotes failure, not just -1. - (main): Simplify use of sethostname. - - * src/pinky.c (include_idle, include_heading, include_fullname, - include_project, include_plan, include_home_and_shell, do_short_format, - include_where, main): Use bool for booleans. - (count_ampersands, create_fullname, scan_entries, short_pinky): - Use size_t for sizes. - (create_fullname): Check for overflow in size calculations. - (idle_string): Don't assume that the number of idle days - is less than 10**8 and/or INT_MAX/(24*60*60). - (main): No need to pass a non-NULL last arg to getopt_long. - * src/uptime.c (print_uptime, uptime): Use size_t for sizes. - (print_uptime): Remove unused local variable. - (main): No need to pass a non-NULL last arg to getopt_long. - * src/users.c (list_entries_users, users): Use size_t for sizes. - (list_entries_users): Use char for bytes. - (main): No need to pass a non-NULL last arg to getopt_long. - * src/who.c (do_lookup, short_list, short_output, include_idle, - include_heading, include_mesg, include_exit, need_boottime, - need_deadprocs, need_login, need_initspawn, need_clockchange, - need_runlevel, need_users, my_line_only, main): Use bool for booleans. - (print_runlevel): Use unsigned char for bytes. - (list_entries_who, scan_entries, who): Use size_t for sizes. - (main): No need to pass a non-NULL last arg to getopt_long. - - * src/install.c (isdir): Remove decl. - (install_file_to_path): Rely on make_path to fail if the destination - is not a directory, by passing preserve_existing==true to it. - Hence we no longer need to call isdir. - Free dest_dir immediately when it's no longer needed, rather than - waiting until the end of the function. - (copy_file): Don't bother calling isdir, as copy will do the - right thing if the destination is a directory. - - * src/du.c (fts_debug, opt_all, apparent_size, opt_count_all, - print_grand_total, opt_separate_dirs, hash_ins, process_file, main): - Use bool for booleans. - (max_depth): Now size_t, not int, to avoid an arbitrary limit - of INT_MAX on depth. - (G_fail): Remove: no longer needed, now that the relevant - functions return bool. - (process_file): Use return value to signal success rather than - setting a global. Remove first_call static var; not needed, since - we can look at n_alloc. Use size_t for depths. Remove FIXME - about size_t casts, as it's now fixed. Use xnrealloc rather - than the obsolescent XREALLOC. Don't bother to check whether - reallocation is needed unless level > prev_level. - (du_files): Invert sense of result, for consistency with - other coreutils code. All callers changed. - (main): Allow --max-depth values up to SIZE_MAX. - - * src/df.c (inode_format, show_all_fs, show_local_fs, - show_listed_fs, posix_format, require_sync, print_type, - selected_fstype, excluded_fstype, show_dev, show_point, main): - Use bool for booleans. - (df_readable, show_dev): Use UINTMAX_MAX instead of -1. - (show_dev, show_point, main): - Use EXIT_SUCCESS/EXIT_FAILURE instead of 0/1. - Don't assume disk name lengths are <= INT_MAX. - Rewrite pct calculation to avoid cast. - (show_point): Don't assume resolved length is <= SSIZE_MAX. - - * src/cut.c (hash_int) [!defined UINTPTR_MAX]: Use size_t - instead of uintptr_t. - * src/shred.c (UINT_MAX_32_BITS): Remove. - (word32): Remove. All uses changed to uint32_t. - (isaac_seed_data): Remove unnecessary cast. - * src/system.h (ptr_align): Use size_t; in practice, this is just as - good as uintptr_t in checking for alignments, and has fewer - configuration hassles. - - * src/Makefile.am (localedir.h): Make it readonly; this - undoes part of the 2004-07-27 patch. - -2004-07-30 Paul Eggert - - * src/sort.c (UCHAR): Remove; all uses changed to to_uchar. - (IS_THOUSANDS_SEP): Use bool when appropriate. - (numcompare, main): Use char, not int, when the value is always a char. - (numcompare): Remove "register"; compilers are smart enough these days. - * src/system.h (errno, CHAR_BIT): Remove decls; - no longer needed now we assume C89 or better. - Include before , as it's the - Autoconf-recommended pattern. - (to_uchar): New inline function, moved here from tr.c. - Use full names for int types, e.g. "long int" rather than "long". - * src/tr.c (to_uchar): Remove; now in system.h. - (is_char_class_member): Use bool when appropriate. - - * src/mkdir.c (create_parents, main): Use bool when appropriate. - (main): Use EXIT_SUCCESS/EXIT_FAILURE instead of 0/1. - -2004-07-29 Paul Eggert - - * src/mkfifo.c (main): Use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1. - - * src/chmod.c (recurse, force_silent, process_file, process_files, - main): Use bool when appropriate. - * src/cksum.c (cksum, main): Likewise. - * src/comm.c (hard_LC_COLLATE, only_file_1, only_file_2, both, - compare_files, main): Likewise. - - * src/copy.h (struct cp_options): Likewise. - * src/copy.c (copy_internal, is_ancestor, copy_dir, copy_reg, - same_file_ok, seen_file, copy_internal, valid_options, copy): Likewise. - * src/cp-hash.h (remember_created): Likewise. - * src/cp-hash.c (remember_created): Likewise. - * src/cp.c (struct dir_attr, flag_path, remove_trailing_slashes, - re_protect, make_path_private, target_directory_operand, do_copy, - cp_option_init, decode_preserve_arg, main): Likewise. - * src/install.c (isdir, change_timestamps, change_attributes, - copy_file, install_file_to_path, install_file_in_dir, - install_file_in_file, strip_files, dir_arg, cp_option_init, main, - change_attributes, change_timestamps): Likewise. - * src/mv.c (remove_trailing_slashes, rm_option_init, - cp_option_init, do_move, movefile, main): Likewise. - * src/remove.c (right_justify), full_filename_, AD_pop_and_chdir, - AD_push, prompt, remove_dir): Likewise. - * src/rm.c (rm_option_init, main): Likewise. - - * src/remove.c (top_dir, pop_dir, full_filename_): - Use size_t for sizes. - * src/cp.c (target_directory_operand): Do not clear *NEW_DST if stat - succeeds. It's not necessary in that case, as *NEW_DST is always - false already. - (do_copy): Rewrite slightly to avoid need for "unreachable" comment. - (main): Use EXIT_SUCCESS, EXIT_FAILURE instead of 0, 1. - * src/rm.c (main): Likewise. - - md5sum, sha1sum integer cleanups. - - * src/checksum.h: Don't include config.h, sys/types.h, stdio.h: - not needed. - (ALG_UNSPECIFIED): Remove. - (ALG_MDT): Don't make it equal to CHAR_MAX + 1; this isn't necessary. - * src/md5.c: Don't include any files other than checksum.h. - * src/sha1sum.c: Likewise. - * src/md5sum.c (OPENOPTS, have_read_stdin, status_only, warn, - bsd_split_3, split_3, hex_digits, digest_file, digest_check, main): - Use bool when appropriate. - (digest_check): Increase limit of number of input lines to - UINTMAX_MAX from INT_MAX. Diagnose any overflows of this counter. - Use ngettext instead of hard-to-i18nize hardcoded stuff for plurals. - -2004-07-28 Paul Eggert - - * src/cat.c (exit_status): Remove. Now done by passing a boolean - 'ok' flag around. - (simple_cat, cat): Return true if successful. All callers changed. - (simple_cat, cat, main): Use bool for booleans. - (simple_cat): Use size_t for sizes. - (cat, main): Use the same names for parameters that we use for - long options, to avoid confusion. This inverts the sense of the - show_tabs (formerly output_tabs) and number_nonblank - (formerly numbers_at_empty_lines) variables. - (main): Don't mess up (due to integer overflow) if we are given - INT_MAX - INT_MIN + 1 options. - [O_BINARY]: Don't invoke isatty unless the other options require it. - (main): When deciding whether to use simple_cat, don't worry - about binary option; it's irrelevant. - - * src/dcgen: Remove comments, trailing white space, and empty - lines from the output strings, to save space. - Use a narrower type like 'unsigned char' for line lengths, if - that will do. - Make the output variables static, not extern. - - * src/chgrp.c (parse_group): Require base 10 when parsing - groups as integers. - (main): int -> bool when appropriate. - * src/chown.c (main): Likewise. - * src/chown-core.c: Include inttostr.h. - (UINT_MAX_DECIMAL_DIGITS, uint_to_string): Remove. - (gid_to_name, uid_to_name): Use imaxtostr/umaxtostr - instead of uint_to_string). - (describe_change): Instead of an int flag, use a char * - auxiliary; this avoids the need for casts. - Assume free (NULL) works. - (change_file_owner): Return true/false, not 0/-1, since - we don't set errno. All callers changed. - Use bool when appropriate. - (chown_files): Likewise. - * src/chown-core.h (chown_files): Likewise. - - * tests/chown/basic: Test for proper handling of uids like - "010", which must be parsed as decimal. - - * tests/misc/pwd: Don't assume that Perl's getpwd agrees with our - pwd when there are multiple names for the working directory - (which can happen with an automounter, sigh). - - * src/Makefile.am ($(SCRIPTS)): Don't depend on Makefile; - this causes Solaris 8 'make' to refuse to build "groups". - (localedir.h): Don't depend on Makefile: this causes Solaris - 8 'make' to build localedir.h unnecessarily. The dependence - on Makefile is ineffective anyway, since $(localedir) might - change even if Makefile hasn't. - - * src/remove.c (remove_dir): If we can't save the state of the - working directory, pretend we started from "/", not ".". - This avoids a bug on hosts like Solaris that don't let you - remove the working directory. - -2004-07-27 Paul Eggert - - * src/printf.c (strtiomax, strtoumax): Declare if not already - declared: this fixes a portability bug with Solaris 8 + GCC. - (STRTOX): Parenthesize use of macro arg as expression. - (vstrtoimax, vstrtoumax, vstrtold): Remove now-unnecessary - parentheses. - * configure.ac: Check for declaration of strtoumax, for - src/printf.c. - - * src/Makefile.am (cp_LDADD, ginstall_LDADD, mv_LDADD, - pathchk_LDADD, rm_LDADD, test_LDADD): New vars, for eaccess. - - * tests/readlink/can-e: Don't assume that we can remove the - working directory: this isn't possible under Solaris 8, say. - * tests/readlink/can-f: Likewise. - * tests/readlink/can-m: Likewise. - - * src/copy.c (copy_internal): find_backup_file_name no longer - returns NULL, so don't bother to check for this. - * src/cp.c (do_copy): Likewise. - * src/ln.c (do_link): Likewise. - -2004-07-25 Paul Eggert - - * src/nice.c (GET_NICE_VALUE): Renamed from GET_PRIORITY. - All uses changed. - (NZERO): New macro, if system doesn't define it already. - (usage): Distinguish priorities from nice values. - Don't assume NZERO is 20. - (main): Use bool instead of int where appropriate. - If user specifies an adjustment out of range, always truncate it - to an inrange value instead of sometimes giving an error message - and sometimes not. - Do not assume that -1 is an error return from "nice" or - "getpriority", as it might be the current nice value minus NZERO. - If nice/setpriority fails with errno == EPERM, go ahead and run - the command anyway; POSIX requires this. - - * src/pathchk.c: Include euidaccess.h. - (dir_ok): Use euidaccess, not access. - * src/test.c (R_OK, W_OK, X_OK, FOK): Remove; system.h defines them. - (eaccess): Remove. All users changed to use euidaccess instead. - -2004-07-24 Paul Eggert - - * src/uptime.c (print_uptime) [defined BOOT_MSG]: - Don't assume ut_line is null-terminated. - * src/who.c (print_line): New arguments USERLEN and LINELEN, - since USER and LINE might not be null terminated. All callers - changed. - -2004-07-23 Paul Eggert - - Fix bug with "tail -f" reported by Rob Holland in - . - Also, remove the undocumented and unsupported-since-2000 - --max-consecutive-size-changes options. Fix another related bug: - "tail" got confused if stdin, stdout, or stderr were closed. - Also, use output buffering even with "tail -f". - - * NEWS: Document this, plus yesterday's patch. - * doc/coreutils.texi (tail invocation): "size has remained the same" - -> "file has not changed", which is more accurate for fifos. - * src/tail.c: Include fcntl-safer.h. - (COPY_TO_EOF): Set to UINTMAX_MAX, not OFF_T_MAX (which was wrong). - (COPY_A_BUFFER): New macro. - (struct File_spec): New members mtime, mode, blocking. - Remove member n_consecutive_size_changes. - (DEFAULT_MAX_N_CONSECUTIVE_SIZE_CHANGES, - max_n_consecutive_size_changes_between_opens, - MAX_CONSECUTIVE_SIZE_CHANGES_OPTION): Remove. - (long_options, tail_forever, parse_options): - Remove (non-)support for --max-consecutive-size-changes. - (record_open_fd): New function. - (recheck, tail_file): Use it. Don't assume that stdin is open. - (dump_remainder): Add support for new COPY_A_BUFFER special value. - Treat errno==EAGAIN like EOF, since it might be a nonblocking read. - (recheck): New arg BLOCKING, specifying whether to use blocking reads. - All uses changed. - (n_live_files): Remove, replacing with... - (any_live_files): New function. All uses changed. - (tail_forever): Use nonblocking I/O unless we know that blocking I/O - is safe; this avoids some hangs when reading from a fifo. - Avoid invoking fstat or sleep when using blocking I/O. - Do not check for changes to size if the file is not a regular file, - as the size is undefined in that case. - Check for changes to mtime or mode, too; this works for non-regular - files. - (tail_forever, main): Redo fflush strategy to work even when input - is nonblocking. Don't use unbuffered output; just flush when needed. - -2004-07-22 Paul Eggert - - * src/tail.c (main): Ignore -f if no file operand is specified - and standard input is a pipe. - * doc/coreutils.texi (tail invocation): Do not ignore -f for - all pipes, just for when standard input is a pipe and no - file operand is specified. - * tests/tail/Test.pm: Reinstate f-1 test, since we now pass. - Add a new commented-out f-2 test, which we still fail. - (test_vector): All f-* tests are special cases, not just f-1. - -2004-07-12 Paul Eggert - - * src/uptime.c: Include c-strtod.h. - (print_uptime): Use c_strtod instead of setlocale and sscanf. - Use long int rather than int to count days (for 64-bit hosts), - and check for arithmetic overflow when converting double to time_t. - -2004-07-11 Paul Eggert - - * src/printf.c (vstrtold): Renamed from vstrtod. - Now returns long double. All uses changed. - (print_direc): Use "L" length modifier when printing floating point - numbers, since we're now printing long double. - -2004-07-06 Paul Eggert - - * Version 5.3.0. - - printf cleanup, to avoid undefined behavior, to add support for - formats that Bash supports, and to support wide integers like - Bash does. - - * NEWS: Document this. - * src/printf.c (UNSPECIFIED): Remove. All uses now replaced by - booleans, so that we don't reserve any values for precision or - width (like Bash). - (STRTOX): Use prototype, not K&R-style definition. - (vstrtoimax): Renamed from xstrtol (to avoid confusion with xstrtol - in ../lib), with type change to intmax_t. - All uses changed. - (vstrtoumax): Renamed from xstrtoul, with type change to uintmax_t. - All uses changed. - (vstrtod): Renamed from xstrtod. All uses changed. - (print_direc): Use boolean arg instead of special value to indicate - a missing precision or width. LENGTH no longer includes - length modifiers or conversion character. New arg CONVERSION - now specifies conversion character. - Use intmax_t-width formatting for integers (like Bash). - Add support for C99 %a, %A, %F (like Bash). - Add support for field width with %c (POSIX requires this). - Add a FIXME for lack of support for field width and precision - for %b. - Add support for '\'', '0' flags. - Check for invalid combinations of flags, field width, precision, - and conversion, to prevent use of undefined behavior. - Allow multiple length modifiers, for formats like "%lld" (like Bash). - Add support for C99 'j', 't', 'z' length modifiers (like Bash). - In error message, output entire invalid conversion specification, - instead of merely outputting % followed by the conversion char. - * tests/misc/printf: Add tests for the above. - -2004-04-03 Dmitry V. Levin - - Change "readlink -f" to be more compatible with prior implementations. - Add more canonicalize options, -e and -m. - Add comprehensive tests for all readlink modes. - - * m4/canonicalize.m4 (AC_FUNC_CANONICALIZE_FILE_NAME): - Do not add canonicalize.c here. - - * src/readlink.c (longopts): Add new options. - (usage): Document them. - (canonicalize_fname): New proxy function. - (main): Handle new options. - * doc/coreutils.texi (readlink invocation): Document new - "readlink -f" behaviour and new canonicalize options, -e and -m. - - * configure.ac (AC_CONFIG_FILES): Add tests/readlink/Makefile. - * tests/Makefile.am (SUBDIRS): Add readlink. - * tests/readlink/Makefile.am: New file. - * tests/readlink/{rl-1,can-e,can-f,can-m}: New readlink tests. - * tests/misc/Makefile.am (TESTS): Remove basic readlink test. - * tests/misc/readlink: Remove file. - -2004-07-04 Jim Meyering - - * src/copy.c (copy_internal): Add a FIXME comment. - -2004-07-02 Paul Eggert - - * src/copy.c (copy_dir): Assume path_concat returns non-NULL. - * src/cp.c (do_copy): Likewise. - * src/mv.c (movefile): Likewise. - - * src/cp.c (make_path_private): 2nd arg is now size_t, not int, - to avoid problem when path_concat dir name is longer than 2 GiB (!). - - * src/nohup.c (main): Don't pass NULL first argument to path_concat. - This cleans up the semantics a bit, as we no longer try to open the - same file twice. - -2004-07-01 Paul Eggert - - * NEWS: Add short names -t and -T for --target-directory - and --no-target-directory options, respectively. - - * src/cp.c (NO_TARGET_DIRECTORY_OPTION, TARGET_DIRECTORY_OPTION): - Remove. All uses changed to 'T' and 't', respectively. - * src/install.c, src/ln.c, src/mv.c: Likewise. - - * src/cp.c (long_opts, usage, do_copy, main): Add -t and -T as - aliases for --target-directory and --no-target-directory, - respectively. - * src/install.c (long_options, main, usage): Likewise. - * src/ln.c, src/mv.c: Likewise. - -2004-07-01 Jim Meyering - - * Makefile.maint (sc_file_system): New target. - (syntax-check-rules): Add it. - .x-sc_file_system: New file. - * Makefile.am (EXTRA_DIST): Add it. - - * man/sync.x: Use "file system" rather than "filesystem". - * man/stat.x, man/df.x: Likewise. - -2004-06-30 Paul Eggert - - * src/df.c (usage, main): Output "file system" rather than - "filesystem". - * src/du.c (usage): Likewise. - * src/shred.c (usage): Likewise. - * src/stat.c (usage): Likewise. - * src/stat.c (long_options, usage): Rename "--filesystem" to - "--file-system". But keep the old name around, for compatibility - reasons. - -2004-06-29 Paul Eggert - - Add support for --no-target-directory option. - - * NEWS: Document it. - * doc/coreutils.texi (Common options, Target directory, cp - invocation, install invocation, mv invocation, ln invocation): - Likewise. - (link invocation): Explain how to rewrite link using ln now - that we have --no-target-directory. - (ln invocation): Explain that --no-target-directory subsumes - --no-dereference. - (unlink invocation): Modify wording to match new wording in - link invocation. - - * src/cp.c (NO_TARGET_DIRECTORY_OPTION): New constant. - (long_opts, usage, do_copy, main): Add support for - --no-target-directory, - * src/install.c (NO_TARGET_DIRECTORY_OPTION, long_options, main, - usage): Likewise. - * src/ln.c (NO_TARGET_DIRECTORY_OPTION, long_options, usage, - main): Likewise. - * src/mv.c (NO_TARGET_DIRECTORY_OPTION, long_options, usage, - main): Likewise. - * src/mv.c (enum): Sort values. - -2004-06-29 Jim Meyering - - Don't let verbose-mode output from a subshell obscure actual differences. - * tests/rm/inaccessible: Turn off command-echoing just before - invoking subshell, then turn it back on if VERBOSE=yes afterward. - -2004-06-25 Paul Eggert - - Add support for 'install --target-directory', an option - that has been documented for years but not implemented (!). - * doc/coreutils.texi (install invocation): Document - --target-directory in synopsis, too. - * src/install.c (TARGET_DIRECTORY_OPTION): New var. - (long_options, main, usage): Add --target-directory. - (target_directory_operand): New function, stolen from mv.c. - (main): Use it. Check for -d and --target-directory. - Alter wording of diagnostics to match other programs. - -2004-06-28 Jim Meyering - - * src/cp.c (usage): Fix copy+paste error in description of - --target-directory: s/move/copy/. From Paul Jarc. - -2004-06-27 Paul Eggert - - Use more-consistent rules among cp, ln, and mv when dealing with - last operands that are (or look like) directories. - - * src/cp.c (target_directory_operand): New, nearly-common function, - It reports an error if the destination appears to be a directory - (e.g., because it has a trailing slash) but is not. - * src/ln.c, src/mv.c: Likewise. - * src/cp.c (do_copy): Use it. - * src/ln.c (main): Likewise. - * src/mv.c (main): Likewise. - - * src/cp.c (do_copy): Don't assume argc is positive. - Don't bother to lstat dest, since copy() will do that for us. - Use "const" to avoid the need for cast. - - * src/cp.c (do_copy): Don't output a usage message because of file - problems (e.g., an operand is not a directory). Use it only for - syntax. Standardize on "target %s is not a directory" for the - diagnostic. - * src/ln.c (main): Likewise. - * src/mv.c (main): Likewise. - - * src/cp.c (do_copy): Remove test for trailing slash, since - target_directory_operand now does this. - * src/ln.c (main): Likewise. - * src/mv.c (movefile): Likewise. - - * src/cp.c (main): Reject multiple target directories. - Check whether a specified target is a directory when parsing the - options, using stat. This gives more-accurate diagnostics. - * src/ln.c (main): Likewise. - - * src/ln.c (isdir): Remove decl; no longer needed. - * src/mv.c (isdir, lstat): Likewise. - - * src/ln.c (do_link): New arg dest_is_dir. All uses changed. - Don't check the destination ourself; rely on dest_is_dir. - This way we can avoid lstatting the destination in the - usual case, and in the worst case we lstat 1, not 3 times. - Don't bother to unlink unless link failed; this saves a syscall. - Remove unnecessary backup_succeeded flag; - it was identical to "dest_backup != NULL". - - * src/ln.c (main): Use int to count to argc, not unsigned int. - This handles negative operand counts. - * src/mv.c (main): Likewise. - - * src/mv.c (do_move): Don't call hash_init; expect the caller to - do it, for consistency with cp.c and ln.c. All callers changed. - (movefile): dest_is_dir parameter is now bool, not int. - (main): Standardize on "missing destination file operand after %s" - for the diagnostic, for consistency with cp.c. - - * tests/mv/diag: Don't assume "mv --target=nonexistentdir" - will complain about the arg count. - Adjust to new (briefer) diagnostics. - * tests/cp/fail-perm: Add a test to verify that we get the new - diagnostic when failing to copy through a symlink-to-inaccessible-dir. - -2004-06-27 Paul Eggert - - Fix a bug: formerly, if d/x was a directory and x a file, "ln x - d/" incorrectly created a link d/x/x. It also saves some system - calls. - - * NEWS: Document the fix. - - * src/ln.c (main): Don't append basename to dest if this - results in an existing directory name. - * tests/ln/misc: See whether a trailing slash is followed too far. - -2004-06-26 Jim Meyering - - * src/printf.c (main): When given no arguments, print the standard - "missing operand\nTry printf --help..." message -- to be consistent. - -2004-06-26 Jim Meyering - - * src/mknod.c (main): Add \n at the end of message output via fprintf. - -2004-06-25 Jim Meyering - - * tests/ln/misc: Add test for ln subscript error. - -2004-06-23 Paul Eggert - - * src/ln.c (do_link): Remove unnecessary call to lstat. - (main): Avoid subscript error when the destination is "". - -2004-06-23 Jim Meyering - - * tests/*: Replace all occurrences of `(exit N); exit' with - `(exit N); exit N'. Otherwise, those many tests could exit with - improper exit status when exiting via e.g., a trapped interrupt. - Thanks to a report from Bob Proulx. - -2004-06-22 Paul Eggert - - * src/who.c (idle_string, print_user): New arg boottime, - specifying the most recent boot time. All uses changed. - (idle_string) Consider a line to be "old" if it hasn't been used - since the last boot time. Watch out for overflow when computing - times, and for times in the future. - (idle_string): Record latest boot time. - -2004-06-22 Jim Meyering - - * src/test.c (usage): Correct description of `-t FD'. The file - descriptor, FD, is no longer optional. Reported by Ton Nijkes. - -2004-06-21 Paul Eggert - - The 2004-06-19 fix for who and pinky was incomplete, as ctime - has undefined behavior if the year precedes -999 or follows 9999. - Since we have to stop using ctime anyway, we might as well use - strftime and fix the FIXME, and support internationalized dates. - - * NEWS: Document the new behavior. - * src/who.c: Include "hard-locale.h". - (time_format, time_format_width): New vars. - (time_string, print_line): Use them. - (main): Set them. - (time_string): Use localtime + strftime instead of - ctime, to avoid problems with years before -999 or after 9999. - * src/pinky.c: Likewise. - -2004-06-21 Paul Eggert - - Fix bug: GNU 'ls' didn't count columns correctly if user or group - names contained multibyte characters where the column count - differed from the byte count. This patch also corrects - some comments. - - * src/ls.c (format_user_or_group): New function, which counts - columns correctly. - (format_user, format_group): Use it. - (format_user_or_group_width): New function, which counts columns - correctly. - (format_user_width, format_group_width): Use it. - -2004-06-21 Jim Meyering - - * tests/priv-check: Quote "$PATH" in PATH=$PATH. - Suggestion from Andreas Schwab. - - * tests/priv-check: When running as root, be sure to propagate - PATH through to the process we exec as non-root. - Reported by michael@aplatform.com. - - * src/mknod.c (main): Don't segfault when calculating the - expected number of operands for `mknod NAME'. - -2004-06-20 Jim Meyering - - * src/dd.c (input_seek_errno): Declare file-scoped variable as static. - -2004-06-20 Paul Eggert - - * src/basename.c (main): - Standardize on the diagnostics given when someone gives - too few operands ("missing operand after `xxx'") or - too many operands ("extra operand `xxx'"). - Include "quote.h" and/or "error.h" if it wasn't already being included. - * src/chgrp.c (main): Likewise. - * src/chmod.c (main): Likewise. - * src/chown.c (main): Likewise. - * src/chroot.c (main): Likewise. - * src/comm.c (main): Likewise. - * src/cp.c (do_copy): Likewise. - * src/csplit.c (main): Likewise. - * src/date.c (main): Likewise. - * src/dircolors.c (main): Likewise. - * src/dirname.c (main): Likewise. - * src/du.c (main): Likewise. - * src/expr.c (main): Likewise. - * src/hostid.c (main): Likewise. - * src/hostname.c (main): Likewise. - * src/id.c (main): Likewise. - * src/install.c (main): Likewise. - * src/join.c (add_file_name, main): Likewise. - * src/link.c (main): Likewise. - * src/ln.c (main): Likewise. - * src/logname.c (main): Likewise. - * src/md5sum.c (main): Likewise. - * src/mkdir.c (main): Likewise. - * src/mkfifo.c (main): Likewise. - * src/mknod.c (main): Likewise. - * src/mv.c (main): Likewise. - * src/nohup.c (main): Likewise. - * src/od.c (main): Likewise. - * src/pathchk.c (main): Likewise. - * src/ptx.c (main): Likewise. - * src/readlink.c (main): Likewise. - * src/rm.c (main): Likewise. - * src/rmdir.c (main): Likewise. - * src/seq.c (main): Likewise. - * src/setuidgid.c (main): Likewise. - * src/shred.c (main): Likewise. - * src/sleep.c (main): Likewise. - * src/sort.c (main): Likewise. - * src/split.c (main): Likewise. - * src/stat.c (main): Likewise. - * src/test.c (beyond, main): Likewise. - * src/touch.c (main): Likewise. - * src/tr.c (main): Likewise. - * src/tsort.c (main): Likewise. - * src/tty.c (main): Likewise. - * src/uname.c (main): Likewise. - * src/uniq.c (main): Likewise. - * src/unlink.c (main): Likewise. - * src/uptime.c (main): Likewise. - * src/users.c (main): Likewise. - * src/who.c (main): Likewise. - * src/whoami.c (main): Likewise. - - * tests/basename/basic: Adjust to new diagnostics. - * tests/du/files0-from: Likewise. - * tests/expr/basic: Likewise. - * tests/mv/diag: Likewise. - * tests/tsort/basic-1: Likewise. - -2004-06-20 Jim Meyering - - * src/ln.c: Remove declaration of yesno. - Instead, include yesno.h. - * src/copy.c: Likewise. - - * src/remove.c: Remove declaration of yesno. - Instead, include yesno.h. - (top_dir): Remove now-unnecessary cast of obstack_base. - (pop_dir): Likewise. - (full_filename_): Likewise. - -2004-06-19 Paul Eggert - - Don't dump core if ctime returns NULL; this is possible on - hosts with 64-bit time_t and 32-bit int. - * src/who.c: Include "inttostr.h". - (time_string): If ctime fails, print the raw time as an integer - instead of dumping core. - * src/pinky.c: Likewise, as follows: - Include "inttostr.h". - (time_string): New function, copied from who.c. - (print_entry): Use it. - -2004-06-19 Paul Eggert - - * src/who.c (print_line): Don't truncate user names at 8 bytes. - Problem reported by Guido Leenders in: - http://lists.gnu.org/archive/html/bug-coreutils/2004-06/msg00056.html - * NEWS: document this. - -2004-06-19 Jim Meyering - - * src/system.h (case_GETOPT_VERSION_CHAR): Switch back to - using GNU_PACKAGE (from PACKAGE) once again. This restores - `GNU' to the parenthesized package name in --version output. - Before, the first argument from AC_INIT, `GNU coreutils', would - be propagated to the PACKAGE variable. Now, `GNU ' is trimmed. - Reported by Richard Stallman. - -2004-06-17 Jim Meyering - - * src/tr.c (to_uchar): Rename function from `uchar'. The latter - would clash with a typedef in Tru64's . From Albert Chin. - -2004-06-15 Paul Eggert - - * NEWS: Remove more special cases for POSIXLY_CORRECT when POSIX - allows the GNU behavior. "--" is now supported by chroot, hostid, - hosname, pwd, sync, yes. - * doc/coreutils.texi (yes invocation, false invocation, - true invocation): Document this. - * src/chroot.c (main): Handle "--". - * src/hostid.c (main): Likewise. - * src/hostname.c (main): Likewise. - * src/pwd.c (main): Likewise. - * src/sync.c (main): Likewise. - * src/yes.c (main): Likewise. - * src/true.c (main): Recognize --help and --version even if - POSIXLY_CORRECT is set. - * src/yes.c (main): Likewise. - -2004-06-09 Paul Eggert - - * NEWS: Remove special cases for POSIXLY_CORRECT when POSIX allows - the GNU behavior. - * doc/coreutils.texi (pr invocation, unlink invocation): Document this. - * src/ls.c (decode_switches): Pay attention to TABSIZE even if - POSIXLY_CORRECT is set. POSIX reserves upper-case environment - variables to the implementation, so it's OK for ls to depend on - TABSIZE. - * src/pr.c: Include "hard-locale.h". - (main): When in a non-POSIX locale, ignore POSIXLY_CORRECT, since - POSIX specifies the behavior only in the POSIX locale. - * src/printf.c (print_esc): Support \x, \u, \U even if POSIXLY_CORRECT, - since POSIX says the behavior is unspecified here. - * src/tail.c (parse_obsolescent_option): Support multiple file operands - even if POSIXLY_CORRECT, since POSIX does not require a diagnostic. - * src/printf.c (main): Recognize --help, --version even if - POSIXLY_CORRECT. POSIX does not specify any options, but it - does not prohibit options either, so "printf" is like "expr" here. - * src/unlink.c (main): Likewise. - * tests/misc/printf: Adjust to the new semantics for \x if - POSIXLY_CORRECT. - -2004-06-14 Jim Meyering - - * tests/misc/pwd: New test, for fix of 2004-04-19. - * tests/misc/Makefile.am (TESTS): Add pwd. - (BUILD_SRC_DIR): Define BUILD_SRC_DIR. - - * src/copy.c: Remove declaration of euidaccess. - Instead, include "euidaccess.h". - -2004-06-13 Paul Eggert - - * src/who.c (PIDSTR_DECL_AND_INIT): Don't assume pid_t fits in int. - (UT_ID) [!HAVE_STRUCT_XTMP_UT_ID]: Remove bogus comment, - as (sizeof "??") reliably returns 3. - (print_line): Guard against idle and pid being too long - (which is possible when printing headers). - (print_user): Allocate enough bytes for idlestr. Use IDLESTR_LEN. - Avoid unnecessary cast of sizeof to int. - (make_id_equals_comment): Do not assume that UT_ID returns - a string; it might return a non-null-terminated array. - Use strncat instead. It's not very often where strncat is - exactly what you want, but this is one of those rare cases. - -2004-06-11 Paul Eggert - - * src/who.c (list_entries_who): Don't output a trailing space. - -2004-06-09 Jim Meyering - - * src/touch.c (usage): Improve wording in description of the - --time=WORD option. Reported by Dan Jacobson. - - * src/chown-core.c (change_file_owner): Change names of parameters - old_uid and old_gid to required_uid and required_gid respectively. - - * src/chmod.c (mode_changed): Return false, not 0, now that the - function returns `bool'. - -2004-06-08 Paul Eggert - - Adjust chmod and chown to be similar if -c or -v are given. In - particular, a no-op chown is no longer reported as a change; this - reverts to previous behavior. Also, fix both commands so that -v - report failures even if the failure is not due to the chmod or - chown syscalls. - - * src/chmod.c (CH_NOT_APPLIED): New constant. - (describe_change): Handle it. - (process_file): Use it, if a symlink wasn't changed. - (mode_changed): Return bool, not int. Accept new argument - NEW_MODE; all callers changed. This lets us avoid statting the - file unless the new mode has unusual bits. - (process_file): Return -1 on error. With -v, report all errors - verbosely, not just some. - - * src/chown-core.c (change_file_owner): Return -1 on error, not - 1 sometimes and -1 on others. Our caller ORs together our results, - and (-1 | 1) == 0 on ones-complement hosts. - With -v report all errors verbosely, not just some. - Fix bug when chopt->root_dev_ino && !chopt->affect_symlink_referent: - file_stats wasn't set properly in that case. - - * tests/chgrp/basic: Adjust to above changes. - -2004-05-20 Paul Eggert - - * tests/chgrp/basic: Test that chgrp -h does not fail on - symlinks, even on hosts where that's not supported. - Test that if -R is specified without -H or L, -h is assumed. - Test that chown() is not optimized away. - -2004-05-18 Paul Eggert - - Several fixes to chgrp and chown for compatibility with POSIX and BSD: - - Check for incompatible options. When -R and --dereference are - both used, then either -H or -L must also be used. When -R and -h - are both used, then -P must be in effect. - - -H, -L, and -P have no effect unless -R is also specified. - If -P and -R are both specified, -h is assumed. - - Do not optimize away the chown() system call when the file's owner - and group already have the desired value. This optimization was - incorrect, as it failed to updated the last-changed time and reset - special permission bits, as POSIX requires. - - Do not report an error if the owner or group of a - recursively-encountered symbolic link cannot be updated because - the file system does not support it. - - * NEWS: Document the above. - - * src/chgrp.c (main): Check for incompatible options. -R --dereference - requires either -H or -L, and -R -h requires -P. If -H, specify - FTS_PHYSICAL as well as FTS_COMFOLLOW; this is faster. Make this - file as much like chown.c as possible. - * src/chown.c (main): Likewise. - - * src/chown-core.c (change_file_owner): Use ent->fts_statp only if - needed. Chown a directory only after chowning its children; this - avoids problems if the new directory ownership doesn't permit - access to the children. Dereference symlinks before doing - ROOT_DEV_INO_CHECK, not after, so that we catch symlinks to /. - Do not optimize away the chown() system call when the file's owner - and group already have the desired value. POSIX does not permit - this optimization. Rely on chown and lchown to do the right - thing with symlinks and/or -1 arguments, now that we have wrappers - to do this. Use ENOTSUPP not ENOSYS, and ignore all ENOTSUPP - errors, not just command-line errors. - (chown_files): Pass FTS_NOSTAT to xfts_open if we don't need file status. - - * src/system.h (ENOTSUP): Remove. - - * tests/chgrp/basic: Use chown --from to discover whether the - group changed, since chgrp now changes unconditionally. This - complicates the sed script a bit. Do not specify --dereference, - since it's the default (and we want to test this). Adjust output - to match the fact that chgrp no longer optimizes the case of - changing a file's group to the same value as before. - * tests/chgrp/posix-H: Do not attempt to combine -h and -H; these - options are incompatible, and their behavior is undefined with POSIX. - (changed, not_changed): Adjust to match the fact that -h is no longer - specified. Sort names. - * tests/chown/deref: Adjust error-diagnostic spelling to match new - behavior. - -2004-06-07 Paul Eggert - - * src/uname.c (main): Fix typo introduced on 2003-05-10 that - prevented a diagnostic of any operands. - -2004-06-08 Jim Meyering - - * src/shred.c (direct_mode): Turn it on/off with directio, too. - -2004-06-07 Jim Meyering - - Enable direct-mode I/O (bypassing the buffer cache), if possible. - Prompted by a suggestion from Kalle Olavi Niemitalo - in http://bugs.debian.org/207035. - * src/shred.c (direct_mode): New function. - (do_wipefd): Turn on direct-mode I/O. - (dopass): If a file's first write fails with EINVAL, - turn off direct-mode I/O and retry the write. - -2004-06-05 Paul Eggert - - * src/tr.c (main): "tr -d a b" is now a fatal error even if - POSIXLY_CORRECT is set. The POSIX SYNOPSIS does not allow this - option combination. - -2004-06-04 Paul Eggert - - * src/shred.c (dopass): Don't subtract 1 from the offset after - a write error. Problem reported by Jon Peatfield in: - http://lists.gnu.org/archive/html/bug-coreutils/2004-06/msg00020.html - -2004-06-02 Paul Eggert - - Fix bug reported by Buciuman Adrian in - - where 'dd' created a file that was too large. The bug was that dd - assumed that the input file offset does not advance after a failed - read; but POSIX says that the input file offset is undefined after - a failed read. - - * src/dd.c (MAX_BLOCKSIZE): New macro. - (input_seekable, input_seek_errno, input_offset, - input_offset_overflow): New vars. - (scanargs): Reject block sizes greater than MAX_BLOCKSIZE. - (advance_input_offset): New function. - (skip_via_lseek): Set errno to zero when reporting our failure, - so that we don't report based on garbage errno. - (skip): If fdesc is standard input, advance the input offset. - Do not quit if reading, and if noerror was specified; - POSIX seems to require this. - If read fails on output file, report the earlier lseek failure - instead; this fixes a FIXME in dd_copy. - (advance_input_after_read_error): New function. - (dd_copy): Use it, instead of assuming that failed reads - do not advance the file pointer. Advance input offset - after nonfailed reads. Advance only a partial block if - the previous read (before the failed read) succeeded, and - do not generate an output block of zeros in this case. - (main): Determine initial input offset, seekability of input, - and error if it wasn't seekable. - -2004-06-02 Jim Meyering - - rm (without -f) could hang unnecessarily when attempting to - remove a symlink to a file on an off-line NFS-mounted partition. - Reported by David Howells in https://bugzilla.redhat.com/124699. - * src/remove.c (write_protected_non_symlink): New function. - Don't invoke euidaccess on symlinks. - (prompt): Use write_protected_non_symlink rather than using - euidaccess directly, being careful not to call lstat twice for a file. - - Fix a bug in how the --output-delimiter=D option works with - abutting byte or character ranges. Reported by David Krider in - http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00132.html - * src/cut.c (print_kth): Remove special case for open-ended range. - (set_fields): Record the range start index for an interval even - when it abuts another interval on its low side. - Also record the range start index of the longest right-open-interval. - * tests/cut/Test.pm: Add tests of --output-delimiter=S with - abutting and overlapping byte ranges. - -2004-06-01 Paul Eggert - - Some POSIX-conformance cleanups for tr. - - * src/tr.c (posix_pedantic): Remove; no longer needed since - we need to test this in just one place now. - (usage): Mention -C. - (unquote): Note that \055, \n, etc are escaped. - Do not worry about POSIXLY_CORRECT when warning about ambiguous - escape sequences. - \ at end of string stands for itself. - Do not diagnose invalid backslash escapes: POSIX says the behavior - is unspecified in this case, so we don't need to diagnose it. - (main): Add support for -C (currently an alias for -c). - Do not diagnose 'tr [:upper:] [:upper:], as POSIX does not require - a diagnostic here. - * tests/tr/Test.pm: New tests bs-055, bs-at-end, repeat-Compl. - Fix comment for range-a-a. - -2004-05-25 Paul Eggert - - Improve the efficiency (and in one case, correctness) of code - that reads symlinks. - - * src/copy.c (copy_internal): Don't use alloca, as it can mess up - royally if the link length is long (e.g., GNU/Hurd). Use - xreadlink instead, it's safer. Don't bother to read the link if - it's the wrong size. Add a FIXME because this area is a bit murky - and undocumented. - * src/ls.c (get_link_name): Update use of xreadlink. - * src/readlink.c (main): Likewise. - * src/stat.c (print_stat): Likewise. - -2004-06-01 Jim Meyering - - * src/env.c (main): Prefer the notation `STREQ (a, b)' - over `!strcmp (a, b)'. - * src/sort.c (main, sort_buffer_size): Prefer the notation - `STREQ (a, b)' over `strcmp (a, b) == 0'. - * src/date.c (batch_convert): Likewise. - * src/expr.c (nextarg): Likewise. - * src/su.c (correct_password, restricted_shell, main): Likewise. - * src/ptx.c (swallow_file_in_memory, main): Likewise. - * src/test.c (binary_operator, and, or, main): Likewise. - -2004-05-13 Paul Eggert - - * NEWS: echo compatibility cleanup. - * doc/coreutils.texi (echo invocation): Document the changes. - * src/echo.c (V9_ECHO): Remove; always enabled. - (DEFAULT_ECHO_TO_XPG): Renamed from V9_DEFAULT, so that - we use the same naming convention as bash. Now an enum, - not a macro. - (usage): Reword to mention -e/-E more accurately. - Mention \0NNN (the POSIX syntax) rather than \NNN (nonstandard). - (hextobin): New function. - (main): Use bool rather than int for local vars when appropriate. - Do not allow options if POSIXLY_CORRECT, unless we are using - BSD semantics and the first argument is "-n". - Don't pass unnecessary extra arg to parse_long_options. - do_v9 now defaults to DEFAULT_ECHO_TO_XPG, not to allow_options. - Do not look for options if !allow_options. - Use size_t rather than int when appropriate. - Open-code option test rather than using strrchr. - Use faster test for "-". - Avoid redundant argc test. - Add support for \x, for Bash compatibility. - Use e.g. '\a' rather than '\007', for portability to EBCDIC hosts. - When '\c' is encountered, stop printing immediately, as POSIX - requires. - Add support for \xhh syntax. - Add support for \0ooo syntax; POSIX requires this. - -2004-06-01 Jim Meyering - - * Use automake-1.8b. Regenerate dependent files. - -2004-05-31 Jim Meyering - - * tests/Makefile.am.in (TESTS_ENVIRONMENT): Define PATH to include - the build src/ directory -- at the front. - ($(srcdir)/$x-tests): Depend on Makefile.am. - Use $x as the program name, except when it would be `test' (test is - the sole program tested via mk-script that is also a shell built-in). - In that case, use the old ../../src/$x. - -2004-05-30 Jim Meyering - - Work around HPUX /bin/cc compiler bug that is exposed, now that - sets are arrays of type `bool'. More details here: - http://lists.gnu.org/archive/html/bug-gnulib/2004-05/msg00094.html - FIXME: verify that the above URL points to the right message - - * src/tr.c (card_of_complement): Use cleaner `sizeof in_set' - rather than `N_CHARS * sizeof(in_set[0])'. Using HPUX's /bin/cc - (aC++/ANSI C B3910B A.05.55 [Dec 04 2003]) on an ia64-hp-hpux11.22 - system, those two expressions are not the same (256 vs. 1024). - The effect of this problem was that `tr -c x y' would fail: - tr: when not truncating set1, string2 must be non-empty - (set_initialize): Remove unnecessary initialization of the `in_set' - buffer; that initialization triggered the same compiler bug as above. - -2004-05-29 Paul Eggert - - tr cleanup, mostly having to do with integer type ranges. - Remove all casts. - - * tests/tr/Test.pm: Add a few tests for the below. Alas, most of - the test cases wouldn't be portable, or would take too much CPU - time, or both. - - * src/tr.c (N_CHARS, N_CHAR_CLASSES): Now an enum, not a macro. - This is safe since the code already assumes N_CHARS fits in int. - (Filter): Remove: we want to prototype everything. - (ORD, CHR): Remove. All uses removed. Some replaced with: - (uchar): New function. All places where a char must be converted - to an unsigned char are now done this way, not by ad-hoc methods. - (count): New type. Use it whenever counts or states are needed. - (BEGIN_STATE): Increase from INT_MAX - 1 (which was bogus, anyway, - since we used it in an unsigned int context) to UINTMAX_MAX - 1. - (REPEAT_COUNT_MAXIMUM): New macro. Use it in place of BEGIN_STATE - whenever appropriate. - (NOT_A_CHAR): Remove global macro; now a local enum. - (UL_LOWER, UL_UPPER, UL_NONE): No longer specify values, since - the rest of the code no longer depends on them. - (class_ok): Remove; all uses changed to use inline comparisons. - (RE_NO_TYPE): Remove; wasn't used or needed. - (struct List_element): normal_char and equiv_code are now unsigned - char, not int. - first_char, last_char, and the_repeated_char are now unsigned char, - not unsigned int. repeat_count is now count, not size_t. - All uses changed. - (struct Spec_list): state is now count, not unsigned int. - lengthis now count, not size_t. - n_indefinite_repeats is now size_t, not int. - has_equiv_class, has_char_class, and has_restricted_char_class - are now bool, not int. All uses changed. - (struct E_string): s is now char *, not unsigned char *. - escaped is now bool *, not int *. All uses changed. - (ES_MATCH): Remove macro, replacing with: - (es_match): New inline function. All uses changed. - (squeeze_repeats, complement, posix_pedantic, truncate_set1, - translating): Now bool, not int. - (io_buf): Now char array, not unsigned char. - (SET_TYPE): Remove. All uses replaced with bool. - (is_equiv_class_member, unquote, append_range, append_char_class, - append_equiv_class, find_closing_delim, star_digits_closebracket, - build_spec_list, parse_str, homogeneous_spec_list): - Now returns bool, not int. All uses changed. - (is_equiv_class_member): Now inline. - (is_equiv_class_member, is_char_class_member, make_printable_str, - append_normal_char, append_range, append_repeated_char, - get_s2_spec_stats): - Args are now of proper integer type. - (unquote, look_up_char_class, make_printable_str, - append_equiv_class, build_spec_list, squeeze_filter): - Avoid unsigned char *p; gently convert *p to unsigned char instead. - (unquote, get_spec_stats): Do not jump past declarations and then - use them; C doesn't allow this in portable programs. - (make_printable_str): Check for overflow in size calculations. - (xmemdup): Remove. All uses rewritten. - (find_bracketed_repeat): Args are now of proper pointer-to-integer - type. Do not reject [c*0]. Use xstrtoumax, not xstrtoul. - (find_bracketed_repeat, star_digits_closebracket): Check that the - digits are not escaped. - (build_spec_list): Don't bother to copy opnd_str; not needed. - (build_spec_list, get_next): Simplify internal logic a bit. - (card_of_complement): Fix bug due to char overflow. - (get_spec_stats): Don't assume len fits into int. - Check for integer overflow. Use abort() rather than assert(0). - (string2_extend): Fix subscript error: is_char_class_member (..., 255) - was being invoked. - (squeeze_filter): READER is never null now; simplify code. - READER arg now has a simpler type. Remove unnecessary casts. - (squeeze_filter, main): Calls to fwrite improperly checked result - against zero, rather than against requested size. - (plain_read): New function. - (read_and_delete, read_and_xlate): - Remove unused filter arg, and don't worry about hit_eof. - Simplify by using plain_read. - (set_initialize): Args are bool and bool *, not int and SET_TYPE *. - (main): Always pass a non-null procedure to squeeze_filter. - Rewrite so that class_ok isn't needed. - -2004-05-29 Paul Eggert - - * src/shred.c (dosync): Ignore EBADF errors, as IRIX 6.5 - fdatasync reports EBADF when syncing (unwritable) directories. - Problem reported by Albert Chin-A-Young in: - http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00165.html - -2004-05-29 Jim Meyering - - * tests/chown/deref: Fix typo: use ls -ldo, not ls -ldg. - Patch from Albert Chin. - - * src/ptx.c (text_buffer_maxend): Remove declaration of unused variable. - - * src/remove.c (push_dir): Merge declaration and adjacent assignment - into a single statement. - -2004-05-28 Jim Meyering - - * src/remove.c (AD_mark_helper): Eliminate an unnecessary comparison. - -2004-05-22 Jim Meyering - - rm -r would get a failed assertion when run from an inaccessible - directory and with two or more command line arguments including an - absolute-named directory followed by a relative-named directory. - - * src/remove.h (struct rm_options) [require_restore_cwd]: New member. - * src/remove.c (struct cwd_state): Define. - (AD_pop_and_chdir): Redesign interface so that a restore_cwd failure - can be detected by the caller. Instead of returning a malloc'd - directory name, communicate it to caller via a new parameter, and - return an indication of whether restore_cwd failed. Update caller. - Eliminate an unnecessary call to AC_stack_top. - (remove_dir): Change type of cwd_state parameter to `struct cwd_state' - so we can now communicate to caller whether/how functions like - restore_cwd have failed. Update caller. - (rm_1): Fail if we've failed to restore the working directory - and the name of the next file to remove is `.'-relative. - (rm): Fail if the require_restore_cwd flag is true and we've - failed to restore the working directory. - * src/mv.c (rm_option_init): Initialize new member, - x->require_restore_cwd. - * src/rm.c (rm_option_init): Likewise. - -2004-05-21 Jim Meyering - - * tests/rm/inaccessible: New test for the above fix. - * tests/rm/Makefile.am (TESTS): Add inaccessible. - - * src/remove.c (rm): Use free rather than XFREE. - (remove_dir): Use xmalloc, not XMALLOC. - (ds_init): Likewise. - -2004-05-20 Jim Meyering - - * Makefile.maint (sc_unmarked_diagnostics): Now that the unmarked - diagnostics in shred.c have been fixed, don't exempt shred.c from - this check. - - * src/shred.c: Use translatable diagnostics, e.g. - change "%s: remove" to _("%s: failed to remove") and - change "%s: close" to _("%s: failed to close"). - -2004-05-17 Paul Eggert - - * src/shred.c (names): Bring back lower-case letters, "_", and - ".". But continue to omit +, =, %, @, #, as they're either - shell metacharacters (for some shells) or are not in some - character sets, or (in the case of '%') must be a - metacharacter somewhere. - -2004-05-16 Paul Eggert - - * src/cut.c (cut_fields): Adjust to new signature of getndelim2. - -2004-05-17 Jim Meyering - - * src/shred.c (incname): Decrement `len' only once per loop iteration. - - chgrp and chown now dereference symlinks by default, per POSIX. - Reported by Michal Politowski as http://bugs.debian.org/249177. - - * src/chown-core.c (chopt_init): Affect each symlink referent by default. - * src/chown.c (usage): Update to reflect this. - * src/chgrp.c (usage): Likewise. - * NEWS: Describe the change. - Adapt tests accordingly. - * tests/chgrp/basic: Use -h where necessary to retain semantics. - * tests/chgrp/deref: Likewise. - * tests/chgrp/posix-H: Likewise. - -2004-05-15 Paul Eggert - - In shred, check for errors from fdatasync more carefully. If - fdatasync fails with errno==EINVAL, it means this implementation - does not support synchronized I/O for this file. Do not report - this as an error, as (for example) AIX 5.2 fdatasync reports it - for raw disk devices. Problem reported by Albert Chin in - . - - Check for write errors, though: the old code ignored them. - Improve error checking in a few other cases, too (e.g., close of a - directory). - - Also, change several 'int' values to 'bool', so that the error - checking is a bit clearer. Similarly, change unsigned values - to size_t where appropriate. - - * src/shred.c: Include "dirname.h". - (datasync) [!HAVE_FDATASYNC]: Remove. - (dosync): New function. - (dopass): Use it. Return 1 on write error, -1 on other error. - All callers changed. Report write error if dosync does. - (do_wipefd, wipefd, wipename, wipefile): Return bool (true/false), - not int (0/-1). All callers changed. Return false if there's a - write error. - (incname): Return bool (true/false), not int (0/1). Accept - size_t length, not unsigned. All callers changed. Do not - bother checking for non-digits; it can't happen. Replace - recursion with iteration. - (wipename): Use dir_name, base_name, etc. instead of assuming - Unix file names. Use size_t for length, not unsigned. - Report error if unlink or close fails. - (wipename, main): Use bool for booleans. - - (names): Use only digits and uppercase letters, for greater - portability. - -2004-05-16 Jim Meyering - - * tests/chown/deref: New test for the yesterday's change. - * tests/chown/Makefile.am (TESTS): Add deref. - -2004-05-15 Jim Meyering - - chown --dereference did nothing when the owner/group of a - symlink matched the desired owner/group. Reported by David Malone. - Also reported in 1999 as http://bugs.debian.org/39642. - - * src/chown-core.c (change_file_owner): When --dereference has - been specified, and when processing a symlink, stat it to get the - owner and group of the referent. - -2004-05-14 Jim Meyering - - * man/pwd.x, man/echo.x, man/printf.x: Fix typo: - s/supercede/supersede/ reported by Andrew Fabbro. - -2004-05-13 Paul Eggert - - Improve performance of `sort -m' on large files, at the cost of - making some contrived examples unsafe. POSIX allows this - optimization. Performance problem reported by Jonathan Baker in - . - - * src/sort.c (first_same_file): Do not treat input pipes - differently from other files. - * doc/coreutils.texi (sort invocation): Document that "sort -m -o F" - might write F before reading all the input. - * NEWS: Likewise. - -2004-05-12 Paul Eggert - - * src/od.c (print_ascii, dump_strings): Use e.g. '\a' rather than - '\007', for portability to EBCDIC hosts. - * src/printf.c (print_esc_char): Likewise. - * src/tr.c (unquote, make_printable_str): Likewise. - -2004-05-12 Jim Meyering - - * src/remove.c (AD_pop_and_chdir): Move lstat-`.' into if-block - where the result is used. This avoids one unnecessary lstat call - per command line argument. - -2004-05-12 Paul Eggert - - Don't assume that "make -C" works; Solaris "make" doesn't have -C. - - * src/Makefile.am (all_programs.list): New rule, copied from - man/Makefile.am and tests/Makefile.am, except that we use the - system tr rather than ./tr and we don't use tr -s. - * tests/Makefile.am (all_programs): Use it. - * man/Makefile.am (all_programs): Likewise. Renamed from programs, - for consistency. All uses changed. - -2004-05-11 Jim Meyering - - * tests/rm/unread3: New test, for the above fix and today's - lib/save-cwd.c improvement. - * tests/rm/Makefile.am (TESTS): Add unread3. - - * src/rm.c: Don't include "save-cwd.h". It's no longer used. - -2004-05-10 Jim Meyering - - * tests/install/trap: New file. Test for bug fix of 2004-04-18. - * tests/install/Makefile.am (TESTS): Add trap. - - * src/remove.c (AD_push): Don't use errno in diagnostic about - `changed dev/ino'. - - Remove these generated files from CVS. - * tests/cut/cut-tests, tests/date/date-tests, tests/join/join-tests: - * tests/ls/ls-tests, tests/pr/pr-tests, tests/tac/tac-tests: - * tests/tail/tail-tests, tests/test/test-tests, tests/tr/range-tests: - * tests/tr/tr-tests, tests/wc/wc-tests: - -2004-05-09 Jim Meyering - - * src/tr.c (unquote): Use xcalloc rather than xmalloc and - a loop initializing the just-allocated memory to zero. - -2004-05-08 Jim Meyering - - * tests/rm/no-give-up: New file; check for today's fix. - * tests/rm/Makefile.am (TESTS): Add no-give-up. - -2004-05-08 Paul Eggert - - Fix bug where "rm" gave up too easily, reported by Dan Jacobsen in - . - - * src/remove.c (remove_entry): Check for errno values like ENOENT - that show the file cannot be directory, instead of for errno - values like EPERM that show the file might be a directory. This - is necessary because, when a single unlink() call has multiple - reasons to fail, it can set errno to any of those reasons; it's - only the rare errno value like ENOENT that excludes all the other - possible reasons to fail even when the file is a directory. - (remove_cwd_entries): Don't attempt chdir if the file is known - to not be a directory. - (remove_dir): Use the same method that remove_cwd_entries uses - (for some reason they differed). Don't assert that saved_errno - must be EPERM; it might be just about anything. - -2004-05-06 Jim Meyering - - * src/id.c (xgetgroups): Use xnmalloc, rather than xmalloc. - Don't add `1' to the buffer size (it was to protect against malloc - implementations that fail to allocate a buffer of size zero). - That is no longer necessary, since we use a malloc wrapper - on such systems. - - * src/wc.c (get_input_fstatus): Use xnmalloc, rather than xmalloc. - * src/head.c (elide_tail_bytes_pipe): Likewise. - * src/df.c (main): Likewise. - * src/shred.c (do_wipefd): Likewise. - * src/users.c (list_entries_users): Likewise. - * src/tail.c (main): Likewise. - * src/md5sum.c (main): Likewise. - -2004-04-29 Paul Eggert - - * src/df.c (show_disk, show_point): If several filesystems are - mounted on the same mount point, prefer the last one, not the first. - Problem reported by Christian Jones in - . - (show_disk): Remove unused statp arg. Return bool, not int. - (show_point): Rewrite to avoid gotos. Use the same algorithm - for lofs and dummies for each pass through the mount table, - rather than subtly different algorithms (which are probably - inadvertent). - -2004-05-03 Jim Meyering - - * Makefile.am (EXTRA_DIST): Add m4/ChangeLog, now that we no longer - have m4/Makefile*. - -2004-05-01 Jim Meyering - - When chown or chgrp is modifying the referent of a symlink, - use the chown(2) function, if possible. - * src/chown-core.c (change_file_owner): Don't hard-code the - open/fchown/close kludge here. Use `chown' instead. - The chown function works just fine on conforming systems. - Other systems now go through the new chown wrapper that - resorts to the old kludge. - - * src/chown-core.c (change_file_owner): Add a comment. - -2004-04-27 Jim Meyering - - * src/ptx.c: Make over 40 global extern variables `static'. - (syntax_table, re_syntax_table): Remove declarations of two unused - variables (they were exposed by the above change). - - * src/du.c (G_fail, opt_nul_terminate_output): Declare `static'. - * src/ln.c (backup_type): Likewise. - - * src/remove.c (rm): Add `extern' keyword. - * src/cp-hash.c (forget_created, remember_created) - (src_to_dest_lookup, remember_copied, hash_init, forget_all): Likewise. - * src/copy.c (dest_info_init, src_info_init, copy): Likewise. - * src/chown-core.c (chopt_init, chopt_free, gid_to_name) - (uid_to_name, chown_files): Likewise. - - * src/Makefile.am (sc_tight_scope): New rule. - * Makefile.maint (sc_tight_scope): New rule. - (syntax-check-rules): Add it. - -2004-04-26 Jim Meyering - - * Use automake-1.8.4. Regenerate dependent files. - - * src/sort.c (limfield): Make a comment clearer. - -2004-04-25 Paul Eggert - - Fix POSIX-conformance bug: "sort -k 3,3.5b" is supposed to skip - leading blanks when computing the location of the field end; - it is not supposed to skip trailing blanks. Solaris 8 "sort" - does conform to POSIX. Also fix the documentation to clarify - this and related issues. - - * doc/coreutils.texi (sort invocation): Mention -k earlier, so - that the options are in alphabetical order. Describe how -b works - more-accurately; this involves fixing some examples, too. Mention - what happens if the start field falls after an end field or after - a line end. Warn about using -k without -b, -g, -M, -n, or -t. - Add an example of how to sort IPv4 addresses and Apache Common - Log Format dates. Remove a duplicate example. - (Putting the tools together): Use separate options rather - than agglomerating them. - * src/sort.c (limfield): Use skipeblanks, not skipsblanks, to - decode whether to skip leading blanks. - (trailing_blanks): Remove. - (fillbuf, getmonth, keycompare): Don't trim trailing blanks. - - * tests/pr/Test.pm: Fix typo in env_default comment. - * tests/sort/Test.pm: Likewise. - (18c, 18d): Reverse the order of output lines, so that the - test cases conform to POSIX. - -2004-04-22 Paul Eggert - - More signal-handling cleanup for ls.c. Do not allow signals to - happen between arbitrary output bytes, as the - restore-default-color sequence can bollix up multibyte chars or - color-change sequences in the ordinary output. Instead, process - signals only between printing a file name and changing the color - back to non_filename_text color. That way, if the signal handler - changes the color (to the default), 'ls' will change it back when - 'ls' continues (after being suspended). - - Also, do not bother with signal-handling unless stdout is a - controlling terminal; this lets stdio buffer better when "ls - --color" is piped or sent to a file. - - * src/ls.c (sigprocmask, sigset_t) [!defined SA_NOCLDSTOP]: New macros. - Do not include "full-write.h"; no longer needed. - (tcgetpgrp) [! HAVE_TCGETPGRP]: New macro. - (put_indicator_direct): Remove. All callers changed to use - put_indicator. - (caught_signals, interrupt_signal, stop_signal_count): New vars. - (restore_default_color): Don't bother checking for put_indicator - failure. - (sighandler): Don't handle SIGTSTP; that's another handler now. - Simply set interrupt_signal to the signal, then exit. - (stophandler, process_signals): New functions. - (main): Don't output any color changes until _after_ the signal - handlers are set up. This fixes a race condition where 'ls' - could be interrupted while initializing colors, and leaving the - terminal in an undesirable state. - Don't mess with signal-handling if standard output is not a - controlling terminal. - When exiting, restore the default color, then restore the - default signal handling, then act on any signals that weren't - acted on yet. - Do not print //DIRED// etc. in colors; this avoids the need - to catch signals when printing them. - (print_name_with_quoting): Process signals just before switching - color back to non_filename_text. - -2004-04-23 Jim Meyering - - Avoid segfault on systems for which SIZE_MAX != (size_t) -1. - * src/ls.c (quote_name): Use SIZE_MAX, not -1, in calls - of quotearg_buffer. Patch by Mikulas Patocka. - -2004-04-18 Paul Eggert - - tee ignored SIGPIPE, but POSIX doesn't allow this. - - * src/tee.c (main): Do not ignore SIGPIPE, as POSIX 1003.1-2001 - does not allow this. This undoes the 1996-10-24 patch. - -2004-04-18 Paul Eggert - - Signal-handling cleanup for coreutils. Here are the highlights: - - - csplit sometimes failed to remove files when interrupted. - - csplit didn't clean up if two signals arrived nearly simultaneously. - - install -s would infloop on System V if SIGCHLD was ignored. - - ls could incorrectly restore color if multiple signals - arrived nearly simultaneously. - - * src/csplit.c (sigprocmask, sigset_t) [!defined SA_NOCLDSTOP]: - Define. - (filename_space, prefix, suffix, digits, files_created, remove_files): - Now volatile. - (caught_signals): New var. - (cleanup): Block signals while deleting all files. - (cleanup_fatal, handle_line_error, regexp_error): - Mark with ATTRIBUTE_NORETURN. - (create_output_file, close_output_file, interrupt_handler): - Block signals while changing the number of output files, - to fix some race conditions. - (delete_all_files): Do nothing if remove_files is zero. - Clear files_created. - (main): Don't mess with signals until after argument processing - is done. - - * src/csplit.c (main): Rewrite signal-catching code to make it - similar to other coreutils programs. When processing signals, - block all signals that we catch, but do not block signals that we - don't catch. Avoid problems with unsigned int warnings. - * src/ls.c (main): Likewise. - * src/sort.c (main): Likewise. - - * src/csplit.c (interrupt_handler): - Use void, not (obsolete) RETSIGTYPE. - * src/shred.c (sigill_handler, isaac_seed_machdep): Likewise. - - * src/csplit.c (interrupt_handler) [defined SA_NOCLDSTOP]: - Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent. - * src/ls.c (sighandler) [defined SA_NOCLDSTOP]: Likewise. - * src/sort.c (sighandler) [defined SA_NOCLDSTOP]: Likewise. - * src/nohup.c (main) [!defined _POSIX_SOURCE]: Likewise, except - for SIG_IGN. - * src/tee.c (main) [!defined _POSIX_SOURCE]: Likewise. - - * src/install.c: Include . - (main) [defined SIGCHLD]: Set SIGCHLD handler to the default, if -s is - given, since System V fork+wait does not work if SIGCHLD is ignored. - - * src/ls.c (sighandler) [!defined SA_NOCLDSTOP]: Reset signal - handler to self, not to SIG_IGN, since SIGTSTP can be received - more than once. - (main): Use SA_RESTART, as that is simpler than checking for EINTR - failures all over the place. - -2004-04-20 Jim Meyering - - * src/remove.c (is_empty_dir): Clarify comment. - - * man/help2man: Accept new option: --program-name=NAME, so that we - can override the one in --version output. This is needed solely - so that test.1 doesn't refer to `[' as the program name. - Reported by Benjamin Cutler as http://bugs.debian.org/205251. - * man/Makefile.am (.x.1): Use help2man's new --program-name option. - - * src/pwd.c: Don't include pathmax.h; system.h already does it. - - * src/cut.c (cut_fields): Free buffer upon getndelim2 failure. - -2004-04-19 Jim Meyering - - * src/shred.c (isaac_seed_start) [AVOID_USED_UNINITIALIZED_WARNINGS]: - Initialize a buffer to avoid warnings from tools like valgrind. - - * Makefile.maint (sc_trailing_blank): New rule. - (syntax-check-rules): Add it. - * .x-sc_trailing_blank: New file. - - Make pwd work even if the resulting name is so long that getcwd fails. - * src/pwd.c: (path_free, path_init, path_prepend): New functions. - (nth_parent, find_dir_entry, robust_getcwd): New functions. - (main): First try getcwd, then, upon failure, robust_getcwd. - -2004-04-18 Jim Meyering - - * src/who.c (print_user): Use xrealloc here, rather than - unchecked realloc. Remove anachronistic casts. - - * src/remove.c (full_filename_): Don't leak upon failed realloc. - - * src/system.h (readdir_ignoring_dot_and_dotdot): New inline function, - from remove.c. - * src/remove.c (readdir_ignoring_dotdirs): Move function to system.h, - renaming it. Update uses. - -2004-04-17 Jim Meyering - - * configure.ac: Depend on automake-1.8.3. - - * src/join.c (add_file_name): Declare function to be `static'. - (string_to_join_field): Likewise. - * src/remove.c (ds_init, ds_free): Likewise. - - * Makefile.maint (sc_prohibit_jm_in_m4): New rule. - (syntax-check-rules): Add to the list. - -2004-04-13 Paul Eggert - - Use page-aligned buffers whenever we bother to do I/O using buffer - sizes that are tailored for the files. - - * src/cat.c: Include getpagesize.h. - * src/copy.c: Likewise. - * src/shred.c: Likewise. - * src/split.c: Likewise. - * src/cat.c (main): Align I/O buffers to page boundaries. - * src/copy.c (copy_reg): Likewise. - * src/shred.c (dopass): Likewise. - * src/split.c (main): Likewise. - * src/dd.c (ROUND_UP_OFFSET, PTR_ALIGN): Remove. - All uses replaced by ptr_align. - * src/od.c (gcd, lcm): Remove; now in system.h. - * src/system.h (gcd, lcm, ptr_align): New functions, moved from od.c. - -2004-04-14 Jim Meyering - - Remove m4/Makefile.am: it's no longer needed, with newer automake - * configure.ac (AC_CONFIG_FILES): Remove m4/Makefile.in from the list. - * Makefile.am (SUBDIRS): Remove `m4' from the list. - -2004-04-13 Jim Meyering - - * configure.ac: Change `jm_' in AC_DEFINE'd names to `gl_'. - -2004-03-27 Paul Eggert - - * NEWS: cp -pu and mv -u (when copying) now take the destination - file system time stamp resolution into account. - * doc/coreutils.texi (mv invocation): Document this. - (cp invocation): Document -u (it was missing!) with new behavior. - - * src/copy.c: Include "utimecmp.h". - (copy_internal): Compare time stamps using utimecmp rather than - MTIME_CMP. - -2004-04-09 Jim Meyering - - * Makefile.maint (.re-list): New rule/file, to replace - hard-coded list of header file names. - (sc_system_h_headers): Use the new file. - Don't look for sys2.h anymore. - - * src/system.h: Include new "stat-macros.h" rather than hard-coding - all of its macro definitions -- the list was slightly out of date. - Suggestion from Dmitry V. Levin. - -2004-04-08 Paul Eggert - - * NEWS: Remove noctty flag from dd. Suggested by Philippe Troin. - * doc/coreutils.texi (dd invocation): Likewise. - * src/shred.c (O_NOCTTY): Remove redundant decl. - * src/dd.c (flags, usage): Remove noctty flag. - (main): Always use O_NOCTTY when opening files. - -2004-04-08 Jim Meyering - - * src/dd.c (dd_copy): Mark two diagnostics for translations. - (set_fd_flags): Undo part of today's change: it's a little - cleaner -- and more efficient in the common case -- to go - ahead and OR in the -1 when fcntl fails. - - * Makefile.maint (sc_dd_max_sym_length): New target. - (syntax-check-rules): Add it. - - * src/md5sum.c (PROGRAM_NAME) [algorithm == ALG_SHA1]: - Correct spelling: s/shasum/sha1sum. Reported by Jesse Kornblum. - - * src/dd.c (set_fd_flags): Don't OR in -1 when fcntl fails. - Rename parameter, flags, to avoid shadowing global. - (LONGEST_SYMBOL): Tweak comment. - -2004-04-07 Paul Eggert - - * NEWS: New dd conv= symbols nocreat, excl, fdatasync, fsync, - and new dd options iflag= and oflag=. - * src/dd.c (usage): Likewise. - * src/Makefile.am (dd_LDADD, shred_LDADD): Add fdatasync's lib. - * src/dd.c (fdatasync) [!HAVE_FDATASYNC]: New macro. - (C_NOCREAT, C_EXCL, C_FDATASYNC, C_FSYNC): New macros. - (input_flags, output_flags): New vars. - (LONGEST_SYMBOL): New macro. - (struct symbol_value): Renamed from struct conversion. Members - symbol and value renamed from convname and conversion. The - symbol value is now an array instead of a pointer; this saves - a bit of space and time in practice. All uses changed. - (conversions): Add nocreat, excl, fdatasync, fsync. Now const. - (flags): New constant array. - (iflag_error_msgid, oflag_error_msgid): New constants. - (parse_symbols): Renamed from parse_conversion and generalized - to handle either conversion or flag symbols. - (scanargs): Adjust uses of parse_symbols accodingly. Add - support for iflag= and oflag=. Reject attempts to use - both excl and nocreat. - (set_fd_flags): New function. - (dd_copy): Just return X rather than calling quit (X), since our - caller invokes quit with the returned value. Add support for - fdatasync and fsync. - (main): Add support for iflag=, oflag=, and new conv= symbols. - * src/system.h (O_DIRECT, O_DSYNC, O_NDELAY, O_NOFOLLOW, - O_RSYNC, O_SYNC): Define to 0 if not already defined. - - * NEWS: Remove duplicate mention of BLOCKSIZE. - -2004-04-02 Andreas Schwab - - * src/stty.c: Add support for IUTF8 input flag. - -2004-04-06 Jim Meyering - - * src/system.h (makedev) [mkdev && !makedev]: Define in terms of mkdev. - Interix spells it `mkdev'. Reported by Mark Funkenhauser. - -2004-04-04 Jim Meyering - - A specified format is no longer automatically newline terminated. - If you want a newline at the end of your format, use `\n'. - * src/stat.c (print_it): Don't print a newline at the end of - every format. - (do_statfs): Add a newline at end of each default format string. - -2004-03-30 Paul Eggert - - * src/nohup.c (main): Adjust to new calling convention - for set_cloexec_flag. - -2004-03-31 Jim Meyering - - * tests/Fetish.pm (run_tests): Remove `.orig' file. - Remove debugging diagnostic. - - Specifying an invalid --width=N (-w) or --gap-size=N (-g) - would not elicit an error. - * src/ptx.c: Include "xstrtol.h" and "quotearg.h". - (main): Don't use atoi. Use xstrtoul instead. - -2004-03-30 Jim Meyering - - * Makefile.maint (sc_prohibit_atoi_atof): New rule. - (syntax-check-rules): Add it. - * .x-sc_prohibit_atoi_atof: New file. - -2004-03-29 Jim Meyering - - * tests/du/files0-from: Use new OUT_SUBST directive, so that this - test is not sensitive to system-dependent block size differences. - Prompted by a report of Solaris 8 differences from Paul Eggert. - - * tests/Fetish.pm: Accept new directives: OUT_SUBST, ERR_SUBST. - Rename `%tmp' to `%actual'. Reverse order of last two args to - _compare_files (to $actual, $expected) so as to match declaration. - -2004-03-28 Paul Eggert - - Fix some gotchas encountered when porting to Solaris 8, using - the Forte 6u2 compiler. - - * src/hostname.c [HAVE_SETHOSTNAME && !defined sethostname]: - Declare sethostname, since no Solaris header does it. - * src/who.c: Include "vasprintf.h", for asprintf. - -2004-03-28 Jim Meyering - - Minor optimization: - * src/du.c (process_file): Don't record dev/inode for directories. - - Under some circumstances, without -c, du would mistakenly count the - space of hard-linked files, not just the first one it encountered. - Reported by Anthony Thyssen. - * src/du.c (du_files): Don't ever clear the set of `seen' dev/inodes. - - * src/du.c: Rename global `print_totals' to `print_grand_total'. - - * src/du.c (main): Rearrange filtering loop to be a tiny bit - more efficient. - - * src/chown-core.c: Don't include savedir.h -- no longer needed. - * src/chmod.c: Likewise. - -2004-03-25 Jim Meyering - - * src/du.c (main): Remove now-unused declaration of `i'. - -2004-03-24 Paul Eggert - - * src/du.c (main): Filter out file names of length zero before - invoking fts, so that they don't cause fatal errors. - -2004-03-25 Jim Meyering - - * tests/du/files0-from (zero-len): Add a test for the above. - -2004-02-25 Paul Eggert - - * NEWS: New environment var BLOCKSIZE. - * lib/human.c (humblock): Support BLOCKSIZE as well as BLOCK_SIZE. - * tests/envvar-check: Test for it. Factor the code to simplify it. - -2004-03-23 Paul Eggert - - * NEWS: Shorten the du --files0-from announcement, and say - "NUL-terminated" rather than "NUL-separated". - * src/du.c (EXPECTED_BYTES_PER_FILE_NAME, DEFAULT_PROJECTED_N_FILES): - Remove: not used. - (usage): Say "NUL-terminated", not "NUL-separated". - (main): Check for I/O error when istream is closed. - Allow --files0-from=F even if F is empty; this specifies no files. - (du_files): Now that we allow the list of files to be empty, - handle that case. - * tests/du/files0-from: Adjust to above changes to src/du.c. - -2004-03-24 Jim Meyering - - * tests/tail-2/assert: Avoid race condition that could cause - spurious failure. Based on a patch from Andreas Schwab. - -2004-03-23 Jim Meyering - - * src/du.c (main): Free the hash table, too. - -2004-03-22 Jim Meyering - - * man/Makefile.am (.x.1): Remove --info-page= option, reverting - the change of 2004-01-22. I can no longer reproduce the problem - that prompted that change, and `info coreutils pr' would display the - `printing text' section of the manual, not the one on `pr invocation'. - - * tests/du/files0-from (nul-1, nul-2): Adjust expected diagnostics - to match corrected output. - - * src/du.c: Include "readtokens0.h" rather than "readtokens.h". - (main): Use readtoken0 functions rather than readtokens. - Don't use errno when diagnosing readtokens0 failure. - Fix off-by-one error in the token number reported in a diagnostic. - (du_files): Return bool, rather than int. - (main): Call readtokens0_free. - -2004-03-21 Jim Meyering - - * src/remove.c (ds_free): Plug a small leak. - - * tests/Fetish.pm: Fix typo in comment. - -2004-03-07 Jim Meyering - - * NEWS: du accepts a new option --files0-from=FILE, where FILE - contains a list of NUL-separated file names. - - * src/du.c: Include "readtokens.h". - (usage): Describe the new option, and adjust the `Usage': - with this option, no FILE may be specified on the command line. - (main): Handle the new option. - - * tests/du/files0-from: New tests, for the above. - * tests/du/Makefile.am (TESTS): Add files0-from. - - * src/factor.c (do_stdin): Reflect changes in use of readtoken. - * src/tsort.c (tsort): Likewise. - -2004-02-29 Paul Eggert - - * NEWS: Add support for a new notation @N to get_date to represent - the time stamp with numeric value N. Improve support for - fractional time stamps. date's -d and -f options now accept them. - Likewise for touch -t. date has a new option --iso-8601=ns. - - * doc/coreutils.texi (touch invocation): - Describe use of fractional seconds. - (date invocation, Options for date): Likewise. - * doc/getdate.texi (General date syntax, Time of day items): Likewise. - * doc/coreutils.texi (date invocation): Mention effect of LC_TIME. - (Options for date): Describe new --iso-8601=ns option. - - * doc/getdate.texi: Add copyright notice. Change getdate to - get_date when talking about the function name. - (Seconds since the Epoch): New section, containing the time_t - info moved from Date input formats section, along with new - info about the @ syntax. Mention negative time stamps, - fractional time stamps, and leap seconds. - (General date syntax): Modernize examples a bit to reflect new - features. - (General date syntax, Relative items in date strings): - Use ' rather than " to quote formats. - (Time of day items): Add an example with fractional seconds. - Describe fractional-second syntax. - - * src/Makefile.am (touch_LDADD): New macro, since `touch' now - needs clock_gettime. - - * src/date.c (enum Time_spec): New enum TIME_SPEC_NS. - (time_spec_string, time_spec, show_date): Support it. - (usage): Remove description of -ITIMESPEC, as it's obsolete and - confusing. Mention --iso-8601=ns. - (batch_convert): getline returns ssize_t, not int. - - * src/touch.c (newtime): Now an array of two timespecs, one - for access and one for modification. - (ref_stats): Remove. - (get_reldate): Use get_date's parameter profile. - (touch, main): Adjust to above changes. - (main): Work even if tm_year == INT_MAX (so long as long int is wider). - Use gettime instead of gettimeofday, for new get_date signature. - - * tests/date/Test.pm (test_vector): New tests epoch, ns-10, ns-max32, - ns-relative. - -2004-03-15 Jim Meyering - - * Makefile.maint (alpha beta major): `Make' the emit_upload_commands - target before updating $(prev_version_file). - - * tests/misc/date-sec: New file, to test for just-fixed bug in date. - See today's change in lib/getdate.y. - * tests/misc/Makefile.am (TESTS): Add date-sec. - -2004-03-14 Jim Meyering - - * announce-gen (print_changelog_deltas): Use `.sig' suffix for - signature files, not `.asc'. Reported by angico@yahoo.com. - -2004-03-13 Jim Meyering - - * src/cp.c (do_copy): Tweak wording in a diagnostic. - Suggestion from Karl Berry. - Include "quoatearg.h". - (do_copy): Use quotearg_colon (not quote) for diagnostics - that begin with `"%s:'. - - * src/nl.c (usage): Specify that nl uses _basic_ regular expressions. - Suggestion from Dan Jacobson. - -2004-03-12 Jim Meyering - - * Version 5.2.1. - - Sometimes, when source and destination partition are different, - mv mistakenly fails to preserve a hard link. Reported by IIDA Yosiaki. - - * src/copy.c: When moving a set of N hard-linked files between - partitions, via two or more command line arguments where the - command line argument containing the Nth link contains no other - link to that same file, mv would mistakenly copy the file, rather - than hard-linking it to the other(s). That happens because when the - final link is processed, its link count has been reduced to 1 since - the other links have been `copied' to the destination partition - and the source links have been removed. - (copy_internal): When in move mode, use the source dev/inode - pair to look up destination name even when st_nlink == 1. - * src/cp-hash.c (src_to_dest_lookup): New function. - * src/cp-hash.h (src_to_dest_lookup): Add prototype. - * tests/mv/part-hardlink: New file. Test for the above fix. - * tests/mv/Makefile.am (TESTS): Add part-hardlink. - - * announce-gen: Sync with autoconf. - - * tests/ls/time-1: Exit 77 (not 1) if we can't set up for the test. - This was triggered on a Linux-2.2.19 system using a file system - NFS-mounted from some sort of Sun. - -2004-03-11 Jim Meyering - - * Use automake-1.8.3. Regenerate dependent files. - -2004-03-10 Jim Meyering - - * tests/du/deref-args: Also convert sizes in the 70-79 kB range, - so that this test works with SELinux-enabled systems. - Based on a patch from Tim Waugh. - - `join -1 x' would give a misleading diagnostic - * src/join.c (string_to_join_field): Report that a non-numeric field - number is invalid, rather than `so large that it is not representable'. - * tests/join/Test.pm (invalid-j): New partial test for the above fix. - -2004-03-06 Jim Meyering - - cp --sparse=always sparse-image-file.img /dev/hda1 could - produce an invalid copy on the destination device. - - * src/copy.c (copy_reg): Even with --sparse=always, try to - make `holes' only if the destination is a regular file. - Reported by Szakacsits Szabolcs. - -2004-03-03 Paul Eggert - - * src/nohup.c (main): Don't invoke set_cloexec_flag with - a file descriptor of -1. - -2004-03-02 Dmitry V. Levin - - * src/nohup.c: Include "cloexec.h". - (main): Set the copy of stderr to close on exec. - -2004-03-01 Paul Eggert - - * configure.ac: Include when checking for strsignal, - sys_siglist, and friends. Problem reported by Tony Leneis in - . - -2004-02-25 Paul Eggert - - * tests/du/deref-args, tests/du/exclude, tests/du/slash: - * tests/du/trailing-slash: Run envvar-check in case BLOCK_SIZE - etc. are set. - -2004-02-23 Paul Eggert - - * NEWS: Document how chown's USER.GROUP argument is now parsed. - -2004-02-23 Jim Meyering - - * src/seq.c (usage): Remove stray space after \n in --help output. - -2004-02-22 Jim Meyering - - * src/du.c (usage): Separate -H and --si. Say that the meaning - of -H will soon change to that of --dereference-args (-D). - -2004-02-21 Jim Meyering - - * src/comm.c (usage): Tell what comm does when there are no options. - Reword in terms of FILE1 and FILE2 rather than `left file' and - `right file'. Suggestion from Dan Jacobson. - -2004-02-15 Paul Eggert - - Fix some POSIX-conformance bugs in expr. - - * NEWS: document the following changes to src/expr.c. - * doc/coreutils.texi (expr invocation): Likewise. - Document what forms integers may take, and say "integer" - consistently instead of "number". Warn about operands - that "expr" can misinterpret, and how to work around the - problem. - * src/expr.c (eval, eval7, eval6, eval5, eval4, eval3, eval2, eval1): - Accept a bool argument specifying whether to evaluate the - expression. This is to allow short-circuit evaluation. All - callers changed. - (null): Report that a string is zero even if it has - a form like "-0" or "00". - (eval1, eval): Use short-circuit evaluation for | and &. - (eval): Return 0 if both arguments are null or zero, instead - of returning the first argument. - * tests/expr/basic: Add some tests for the above. - -2004-02-17 Jim Meyering - - * Version 5.2.0. - - `make check' from a build inside a chroot environment would fail - * tests/help-version: Specify an argument (`/') for df, in the - unusual event that there is no valid entry in /etc/mtab. - Likewise for id: add the -u option, so we don't get spurious - failures when there are no user or group names. - Patch by Tim Waugh. - - * src/sort.c (usage) [-u]: Add punctuation so that the description in - the help2man-generated (line-joined) man page is more readable. - Reported by Tim Waugh. - [-T]: Add a semicolon, for the same reason. - -2004-02-15 Jim Meyering - - * Makefile.am (dist-hook): Qualify target with $(srcdir)/ prefix. - -2004-02-11 Jim Meyering - - * tests/Makefile.am.in ($(srcdir)/Makefile.am): Use more portable - $(srcdir)/../Makefile.am.in, rather than $<. - Suggestion from Michael Elizabeth Chastain. - -2004-02-10 Jim Meyering - - * config/install-sh: Make this script executable. - * Makefile.am (dist-hook): New target, to ensure that config/install-sh - is executable. Otherwise, on systems that lack a suitable install - binary, `make install' would fail, because of the way this script - is invoked (without `$SHELL ' prefix). - Reported by Bob Proulx. - -2004-02-08 Jim Meyering - - * Version 5.1.3. - - * tests/rm/rm5: Avoid triggering a bug in OSF/Tru64's sed - that would cause an unwarranted test failure. - * tests/rm/rm3: Likewise. - -2004-02-07 Jim Meyering - - Remove xstat function pointer member. The way it was used was not - portable, since some systems (OSF V5.1, Solaris 2.5.1) provide static - inline `stat' and `lstat' functions, thus making the tests of - `xstat == lstat' in copy.c always fail. - * src/copy.h (struct cp_options) [xstat]: Remove member. - (XSTAT): New macro. - * src/copy.c (copy_dir): Set `.dereference' member, not .xstat. - (copy_internal): Use `XSTAT (x, ...)' in place of `*(x->xstat) (...)'. - Use `x->dereference == DEREF_NEVER' in place of `x->xstat == lstat'. - (valid_options): Remove now-obsolete FIXME comments. - - * src/cp.c (re_protect): Use `XSTAT (x, ...)' in place of - `*(x->xstat) (...)'. - (do_copy): Declare/use local xstat rather than x->xstat. - (main): Remove code that set x.xstat. - * src/mv.c (cp_option_init): Don't initialize xstat member. - * src/install.c (cp_option_init): Likewise. - - * Makefile.cfg (gnu_ftp_host-alpha, etc.): Un-factor .gnu.org suffix, - so that emit_upload_commands can use these variables, too. - -2004-02-06 Jim Meyering - - * tests/rm/deep-1: Remove `du' stack space test. - Apparently, `ulimit -s N' isn't portable enough. - This test will be restored (with a guard against losing ulimit) - in its own file later. - - * tests/rm/deep-1 (deep): Remove progress-style diagnostics, - since this test doesn't take long enough to merit them. - Run du on $tmp (the containing dir), not $deep, the full path to leaf. - - * Makefile.maint (signatures): Remove definition. - Now, automake's gnupload handles this. - (%.sig: %): Remove now-unused rule. - (rel-files): Use automake's $(DIST_ARCHIVES), rather than - `$(distdir).tar.bz2 $(distdir).tar.gz'. - (emit-upload-commands): Adjust to use gnupload. - -2004-02-05 Jim Meyering - - * src/system.h (ST_TIME_CMP_NS, ST_TIME_CMP): Remove definitions. - (ATIME_CMP, CTIME_CMP, MTIME_CMP, TIMESPEC_NS): Likewise. - Now, those are all defined in timespec.h. - Include timespec.h. - - * src/date.c: Don't include timespec.h, now that system.h does it. - -2004-02-02 Paul Eggert - - Don't dump core if localtime returns NULL (possible on - hosts with 64-bit time_t and 32-bit int). - * src/date.c: Include "inttostr.h". - (batch_convert, main): - If time conversion fails, exit with nonzero status. - (show_date): Return int to report conversion failure. - Print the time as an int if localtime fails. - * src/uptime.c: Print "??" if the current clock can't - be converted by localtime. This won't happen until the year - 2*31 + 1900, but we don't want to dump core even if the current - clock has the wrong value. - - * src/stat.c: Include "inttostr.h". - (human_time): Print the date/time as a number of seconds since the - epoch if it can't be converted by localtime. This is better than - just saying "invalid", and is consistent with what "ls" does. - Don't dump core if the year has more than 48 digits; this isn't - possible on any contemporary host, but we might as well do it right. - -2004-01-31 Paul Eggert - - * src/stat.c (human_time): Accept time rather than - pointer-to-const-time parameter, for clarity. All callers changed. - -2004-02-02 Jim Meyering - - * src/stat.c (do_stat): Remove extra trailing newline from - default formats. Reported by Nelson H. F. Beebe. - - Print actual fractional seconds in time stamps, not just `.00000000'. - * src/stat.c (human_time): Add and use new parameter, t_ns. - (print_stat): Update callers. - * src/ls.c (TIMESPEC_NS): Remove definition. - * src/system.h (TIMESPEC_NS): Define here, instead, now that stat.c - also uses this macro. - Nelson H. F. Beebe noticed that ls --full-time printed nonzero - fractional seconds for files on an XFS file system, but that stat's - fractional seconds were always zero. - -2004-01-28 Paul Eggert - - * src/seq.c (print_numbers): Use 'double' for loop index, not - 'int', to avoid problems with integer overflow. On almost all - machines 'double' works in every case where 'int' works, and - it works on other cases besides. - -2004-01-27 Jim Meyering - - * src/seq.c (usage): Mention that if INCREMENT is omitted, - it defaults to 1, even when FIRST is larger than LAST. - Reword so as not to exclude the possibility that INCREMENT be zero. - -2004-01-25 Jim Meyering - - * Version 5.1.2. - - * Makefile.maint (signatures): Comment out definition. - -2004-01-23 Jim Meyering - - * Makefile.maint (header_regexp): Add exitfail. - - * man/Makefile.am (EXTRA_DIST): Add help2man. - Reported by Nelson H. F. Beebe. - - * man/Makefile.am (.x.1): Prefix help2man invocation with `$(PERL) --' - so it works on systems with Perl installed somewhere other than in - /usr/bin. - - * src/paste.c (paste_parallel): Declare local, chr, to be of type - `int', not `char', since it must hold EOF. This bug would make - paste infloop on some systems. Test failures reported by - Nelson H. F. Beebe and Christian Krackowizer. - -2004-01-22 Jim Meyering - - * tests/rmdir/fail-perm: New file. Test for just-fixed rmdir bug. - * tests/rmdir/Makefile.am (TESTS): Add fail-perm. - - * man/help2man: Fix it so using --info-page='coreutils PROG' works. - * man/Makefile.am (.x.1): Invoke our own (tweaked) copy of help2man. - Use --info-page='coreutils PROG' option. - Now, readlink.1 refers the user to `info coreutils readlink' - rather than to `info readlink'. Reported by Matt Swift. - -2004-01-21 Paul Eggert - - Exit status cleanup. - - * src/basename.c (usage): Use EXIT_SUCCESS, not 0, for clarity. - * src/cat.c, src/chgrp.c, src/chmod.c, src/chown.c, src/chroot.c, - * src/cksum.c, src/comm.c, src/cp.c, src/csplit.c, src/cut.c, - * src/date.c, src/dd.c, src/df.c, src/dircolors.c, src/dirname.c, - * src/du.c, src/echo.c, src/env.c, src/expand.c, src/expr.c, - * src/factor.c, src/fmt.c, src/fold.c, src/head.c, src/hostid.c, - * src/hostname.c, src/id.c, src/install.c, src/join.c, src/kill.c, - * src/link.c, src/ln.c, src/logname.c, src/ls.c, src/md5sum.c, - * src/mkdir.c, src/mkfifo.c, src/mknod.c, src/mv.c, src/nice.c, - * src/nl.c, src/nohup.c, src/od.c, src/paste.c, src/pathchk.c, - * src/pinky.c, src/pr.c, src/printenv.c, src/printf.c, src/pwd.c, - * src/rm.c, src/rmdir.c, src/seq.c, src/setuidgid.c, src/shred.c, - * src/sleep.c, src/sort.c, src/split.c, src/stat.c, src/stty.c, - * src/su.c, src/sum.c, src/sync.c, src/tac.c, src/tail.c, src/tee.c, - * src/test.c, src/touch.c, src/tr.c, src/tsort.c, src/tty.c, - * src/uname.c, src/unexpand.c, src/uniq.c, src/unlink.c, src/uptime.c, - * src/users.c, src/wc.c, src/who.c, src/whoami.c, src/yes.c: Likewise. - - * src/cat.c (usage): Don't bother normalizing exit status - since the arg is already the correct exit status now. - * src/cksum.c, src/comm.c, src/csplit.c, src/cut.c, - * src/dircolors.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/split.c, src/sum.c, src/tac.c, src/tail.c, src/tr.c, - * src/tsort.c, unexpand.c, src/src/uniq.c, src/src/wc.c: Likewise. - - * src/chown.c (main): Removed unused local 'fail'. - - * src/chroot.c (CHROOT_FOUND_BUT_CANNOT_INVOKE, CHROOT_FAILURE): - Remove. - - * src/chroot.c (main): Initialize exit_failure to EXIT_FAIL. - * src/env.c, src/nice.c, src/su.c: Likewise. - * src/nohup.c (main): Likewise, to NOHUP_FAILURE. - * src/setuidgid.c (main): Likewise, to SETUIDGID_FAILURE. - * src/expr.c (main): Use initialize_exit_failure rather than - setting exit_failure directly; this optimizes away redundant - assignments. - * src/printenv.c, src/sort.c, src/test.c, src/tty.c: Likewise. - - * src/chroot.c (main): Exit with status 1 rather than 127 - if chroot itself fails, as per documentation. - - * src/chroot.c (main): Use EXIT_ENOENT and EXIT_CANNOT_INVOKE - rather than roll-your-own symbols or integers. - * src/env.c (main): Likewise. - * src/nohup.c (main): Likewise. - * src/su.c (run_shell): Likewise. - - * src/cp.c (exit_status): Remove static var.... - (main): Making it local here instead. Use =, not |=, to set it. - - * src/cut.c (FATAL_ERROR, main): Exit with status EXIT_FAILURE, - not 2, on errors. - * src/date.c (batch_convert, main): Likewise. - * src/dd.c (dd_copy): Likewise. - * src/pr.c (first_last_page, main, getoptarg): Likewise. - * src/tr.c (main): Likewise. - * src/date.c (main): Don't assume EXIT_FAILURE == 1, as - POSIX doesn't require it. - * src/dd.c (write_output, skip, dd_copy): Likewise. - * src/df.c (main): Likewise. - * src/id.c (main): Likewise. - * src/install.c (main): Likewise. - * src/ln.c (main): Likewise. - * src/ls.c (main): Likewise. - * src/mv.c (main): Likewise. - * src/shred.c (main): Likewise. - - * src/env.c (main): Exit with status 1, not 2, on errors detected - by env proper. - * src/hostname.c (main): Likewise. - * src/nl.c (main): Likewise. - * src/stty.c (main): Likewise. - - * src/expr.c (EXPR_FAILURE): Renamed from EXPR_ERROR, for - consistency with the other programs' naming conventions. - All uses changed. - - * src/factor.c (main): Do not report a usage error simply - because stdin has bad numbers. - - * src/id.c (problems): Now a boolean int, not a counter, - so that we don't have to worry about int overflow. All uses changed. - * src/touch.c (err): Likewise. - - * src/md5sum.c (main): Use int, not size_t, to store boolean int. - - * src/mkfifo.c (main): Exit with status 1, not 4, if not implemented. - * src/mknod.c: Likewise. - - * src/nice.c (main): Exit with status EXIT_FAIL, not EXIT_FAILURE, - on error; this is in case EXIT_FAILURE is unusual. - * src/su.c (main): Likewise. - - * src/nohup.c (NOHUP_FOUND_BUT_CANNOT_INVOKE): Remove; all uses - changed to EXIT_CANNOT_INVOKE. - - * src/printenv.c (PRINTENV_FAILURE): New constant. - (main): Exit with status PRINTENV_FAILURE, not EXIT_FAILURE, on - command-line syntax problems. - - * src/rmdir.c (remove_parents): Don't set 'fail' to a negative number. - (main): Avoid integer overflow when seeing whether errors occurred. - - * src/seq.c (print_numbers): Now returns void, not (zero) int. - All callers changed. - (main): Remove unused local variable 'errs'. Always exit successfully - if we reach the end. - - * src/setuidgid.c (SETUIDGID_FAILURE): Renamed from FAIL_STATUS, - for consistency with other programs here. All uses changed. - (main): Use 'error' to exit rather than invoking 'exit' here. - - * src/sort.c: Don't include . - (SORT_OUT_OF_ORDER, SORT_FAILURE): Now enums, not macros. - (usage): Don't use 'assert'. - (main): Remove redundant assignment to exit_failure. - - * src/system.h (EXIT_FAIL, EXIT_CANNOT_INVOKE, EXIT_ENOENT): - New enum values. - (initialize_exit_failure): New inline function. - Include exitfail.h here, since we refer to exit_failure. - All callers changed to not include exitfail.h. - - * src/tty.c (TTY_FAILURE, TTY_WRITE_ERROR): New enum values; - substitute them for the corresponding integer constants. - - * tests/help-version (expected_failure_status_date): Remove, as - 'date' is now normal. - (expected_failure_status_nohup): New var. - -2004-01-21 Jim Meyering - - * tests/touch/relative: Remove `command' syntax. - Thanks to Nelson H. F. Beebe and Paul Eggert. - - * tests/touch/relative: Test only year/month/day, not hours/min/sec, - so as to avoid problems with systems using TAI clocks. - Although it's no longer necessary, set TZ=UTC0 also for the - initial touch command. Reported by Paul Jarc here: - http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/1504 - -2004-01-20 Diego Biurrun - - * src/dircolors.hin: Add .mov to the list of media files. - -2004-01-19 Paul Eggert - - * tests/touch/relative: Use TZ=UTC0, not TZ=utc (which isn't - portable). Problem reported by Christian Krackowizer. Also, use - +0000 rather than +0 to specify a time zone, as the documentation - requires four digits. - -2004-01-19 Jim Meyering - - * tests/mv/hard-4: Run envvar-check in case SIMPLE_BACKUP_SUFFIX is set. - * tests/mv/backup-is-src: Likewise. - Problem reported by Peter Horst - -2004-01-17 Jim Meyering - - * announce-gen (print_changelog_deltas): Use .sig suffix, not .asc. - - * Version 5.1.1. - -2003-12-15 Paul Eggert - - * NEWS, doc/coreutils.texi: touch -r and -d can now both be specified, - with -r specifying the origin for -d. - * src/touch.c (flexible_date): Remove static var. - (get_reldate): New function. - (main): Use it, to implement this new behavior. - -2004-01-16 Jim Meyering - - * tests/touch/relative: New test for the above. - * tests/touch/Makefile.am (TESTS): Add relative. - -2004-01-13 Jim Meyering - - * src/system.h: Include contents of sys2.h. - * src/sys2.h: Remove file. - * src/Makefile.am (noinst_HEADERS): Remove sys2.h. - - * Use automake-1.8.2. Regenerate dependent files. - - * Update to gettext-0.13.1. - * configure.ac: Use gettext-0.13.1. - * .x-sc_space_tab: Add m4/po.m4 to the list of exceptions. - -2004-01-12 Jim Meyering - - * Makefile.maint (%.sig): Use .sig suffix rather than .asc. - - * Makefile.maint (po-check): Ensure that cvsu works before using it. - Reported by Alexandre Duret-Lutz. - - * src/tail.c (main): Warn about following stdin only when it's a tty. - - * configure.ac: Use gl_DEFAULT_POSIX2_VERSION. - -2004-01-10 Jim Meyering - - * tests/misc/stat-fmt: Use backticks, not `$()' notation. - -2004-01-09 Jim Meyering - - * configure.ac: Quote underquoted `jm_DUMMY_1' to avoid new warning. - -2004-01-08 Jim Meyering - - * src/stat.c (human_fstype): Use %lx, not %x format for `unsigned long'. - From Andreas Schwab. - - * tests/Makefile.am (TESTS_ENVIRONMENT): Remove `/vg' (prerelease test - remnant) from PATH component. That would cause tests in this directory - not to run the just-built binaries, but rather whatever happened - to be in one's PATH. Reported by Christian Krackowizer. - -2004-01-04 Jim Meyering - - * src/csplit.c (new_control_record): Use x2nrealloc - rather than xrealloc. - - * src/cp.c (re_protect): Use ASSIGN_STRDUPA rather than - alloca and strcpy. - (make_path_private): Likewise. - -2004-01-03 Jim Meyering - - * src/paste.c: Use `bool' (not int) as the type for a few - global variables. - (collapse_escapes): Rewrite to set globals rather than modifying - its parameter. - Use size_t (not int) for all counters and related index variables. - (paste_parallel): Remove needless complexity of - using xrealloc in the loop; just allocate the buffers up front. - Free the two temporary buffers. - Move declarations of locals `down' into scope where used. - (paste_serial): Remove `register' attributes. - (main): Simplify delim-related code. - Free `delims', now that it's malloc'd. - -2004-01-02 Jim Meyering - - * src/chroot.c: Include "quote.h". - (CHROOT_FOUND_BUT_CANNOT_INVOKE, CHROOT_FAILURE): Define. - (main): Exit with status of 127, not 1, for too-few-args, - chroot failure, or chdir failure. - Give a better diagnostic upon execvp failure. - - * src/du.c (usage): Mention that, with its current meaning, - -H is deprecated. - - * src/tail.c (main): Warn about following stdin when it's a tty. - Fail when following by name but no names are specified. - -2003-12-30 Jim Meyering - - * src/fold.c (main): Use memcpy, not strcpy. - - * src/copy.c (copy_internal): Use ASSIGN_STRDUPA rather than - alloca and strcpy. - -2003-12-28 Jim Meyering - - * src/unexpand.c (n_tabs_allocated): New global. - (add_tabstop): Use x2nrealloc rather than xrealloc. - * src/expand.c: Likewise. - - * tests/misc/expand: New file. - * tests/misc/Makefile.am (TESTS): Add expand. - - * src/sort.c (add_temp_dir): Use x2nrealloc rather than xrealloc. - (fillbuf): Use x2nrealloc rather than xrealloc. - (sort): Use xnmalloc rather than xmalloc. - (main): Likewise. - -2003-12-27 Jim Meyering - - * src/tee.c (tee): Use xnmalloc rather than xmalloc. - -2003-12-29 Paul Eggert - - * NEWS: Remove support for join -j1 FIELD, -j2 FIELD, and -o LIST1 - LIST2 in POSIX 1003.1-2001 hosts, as required by POSIX. - - * doc/coreutils.texi (join invocation): Remove documentation - accordingly. Document that -t makes all separators significant. - - * src/join.c: Include posixver.h. - (obsolete_usage): New var. - (longopts): Put obsolete options first. - (OBSOLETE_LONG_OPTIONS): New constant. - (get_option, add_file_name): New functions. - (main): Use them to support new behavior. - (usage): Remove documentation for -j1 FIELD and -j2 FIELD. - Do not mark -j FIELD as obsolescent; it is longstanding - UNIX tradition and is a valid extension to POSIX. - - * tests/join/Test.pm (tv): Avoid obsolete -o usage. - -2003-12-28 Paul Eggert - - * src/join.c (add_field_list): Don't use alloca with unbounded - size; just modify the argument, which is no longer const *. - - Various other minor cleanups, mostly to avoid the need for casts. - - (extract_field): Renamed from ADD_FIELD, as it's now a function. - - (struct field.beg): Now char *, not unsigned char const *. All - uses changed. It shouldn't be const since xmemcoll writes on its - arguments. - (extract_field): Likewise, for 2nd arg. - (keycmp): Remove now-unnecessary cast of xmemcoll args. - - (is_blank): New function, to avoid need to cast arg to unsigned char. - (extract_field): Use it. - - (xfields): Rewrite pretty much from scratch. - - (hard_LC_COLLATE): Now bool, not int. - (get_line, getseq, add_field_list): Now returns bool, not int. - (decode_field_spec, add_field_list): Return true on success (not - false), for consistency with the rest of the code. All uses changed. - - (tab): Now char, not unsigned char. This wasn't 100% necessary - but is slightly cleaner. - (prjoin): Hoist (tab ? tab : ' ') expression, to help the compiler. - - (empty_filler): Now const *. - - (make_blank): Remove; wasn't needed. Remove all calls. - (main): Don't set uni_blank.nfields; zero is fine. - -2003-12-27 Jim Meyering - - * src/join.c: Include "quote.h". - (min, max): Remove definitions. - Make a few function parameters and corresponding - locals `const'. Use bool for boolean variables. - Use size_t (not int) for all counters and related index variables. - (prjoin): Remove now-useless assertion. - (string_to_join_field): New function. - (main): Accept join fields as large as SIZE_MAX. - (keycmp): Rename `min' to MIN and max to MAX. - -2003-12-26 Jim Meyering - - fold -s didn't work on e.g., alpha-based systems. - * src/fold.c (fold_file): Adjust types (int->size_t) so that using - x2nrealloc works properly on systems with differing sizes for int - and size_t. Reported by Nelson Beebe. - - * src/fold.c: Use `bool' (not int) as the type for a few - global variables. - -2003-12-23 Paul Eggert - - * src/ls.c (length_of_file_names_and_frills): - Remove forward decl; not needed. - (print_file_name_and_frills, length_of_file_name_and_frills): - With -m, don't output spaces before inum or size. - (print_with_commas): Don't output space just before newline. - -2003-12-24 Jim Meyering - - * tests/ls/Makefile.am (TESTS): Add m-option. - * tests/ls/m-option: New file. Test for above fixes. - -2003-12-20 Jim Meyering - - * Version 5.1.0. - - * src/pr.c: Change type of global, buff_allocated, to size_t. - - * src/join.c [struct seq]: Change types of members count and alloc - from `int' to `size_t'. - - * tests/Makefile.am (root-hint): Tweak wording. - - * src/du.c: Accept new option (-0, --null) that makes it so each - output line is NUL-terminated rather than newline-terminated. - - * src/dd.c (apply_translations): Don't prohibit conv=unblock,sync. - Reported by Volker Paul. - * tests/dd/Makefile.am (TESTS): Add unblock-sync. - * tests/dd/unblock-sync: New test for the above. - -2003-12-19 Jim Meyering - - * tests/misc/nohup: Double quote back-ticked expression, - in case it ends up having an unexpected value. - - * tests/ls/no-arg: Use ls's -1 option in both runs. - - * src/du.c (fts_debug): New global. - (FTS_CROSS_CHECK, DEBUG_OPT): Define. - (main): Make fts use FTS_TIGHT_CYCLE_CHECK. - (main) [DU_DEBUG]: Accept -d option. - -2003-12-18 Jim Meyering - - * src/ls.c (format_user): Increment dired_pos via two statements, - `dired_pos += width; dired_pos++;' rather than one, - `dired_pos += width + 1;' since the latter could conceivably overflow. - (format_group): Likewise. - From Paul Eggert. - - * configure.ac: Require automake-1.8. - -2003-12-12 Jim Meyering - - * Use automake-1.8. Regenerate dependent files. - -2003-12-08 Jim Meyering - - * Makefile.maint (news-date-check): New rule. - (alpha beta major): Depend on it. - -2003-12-03 Paul Eggert - - * NEWS: ls -l (and similar options) now adjust all columns to - fit the data. Generalized from a suggestion by Leah Q for file sizes. - * src/ls.c (INODE_DIGITS, LOGIN_NAME_MAX, ID_LENGTH_MAX): Remove. - (format_user_width, format_group_width, unsigned_file_size, - format_group): New functions. - (block_size_width): Renamed from block_size_size. - (inode_number_width, nlink_width, owner_width, group_width, - author_width, major_device_number_width, minor_device_number_width, - file_size_width): New vars. - (clear_files): Initialize them. - (gobble_file): Set them. Don't ceiling block_size_width to 7. - (print_long_file): Use them. - (gobble_file): Use a new local variable 'f' to make the code - smaller and more consistent with other functions. - (format_user): Output to stdout, not to a buffer, so that we - don't have to worry about buffer overrun. Update dired_pos. - (print_long_file): Don't put owner, group, author into buffer; - just print them directly. Don't assume link counts and - major and minor numbers fit into unsigned long int. - * tests/cp/same-file, tests/mv/part-symlink: Don't assume that - 'ls' output is fixed-width. - -2003-12-02 Jim Meyering - - * src/md5sum.c: Include sha1.h (reflect renaming: sha.h -> sha1.h. - -2003-11-27 Jim Meyering - - * Use automake-1.7f. Regenerate dependent files. - -2003-11-24 Paul Eggert - - Parse floating-point operands and options in the C locale. - POSIX requires this for printf, and we might as well be - consistent elsewhere (tail, sleep, seq). - - * src/printf.c: Remove decls of strtod, strtol, strtoul; no longer - needed now that we assume C89. Include "c-strtod.h". - (xstrtod): Call c_strtod, not strtod. - * src/sleep.c: Include "c-strtod.h". - (main): Update xstrtod call to include new argument, c_strtod. - * src/seq.c (scan_double_arg): Likewise. - * src/tail.c (parse_options): Likewise. - -2003-11-24 Jim Meyering - - * tests/rm/fail-2eperm: Handle another errno variant (HPUX, EPERM). - Reported by Mark Conty. - -2003-11-22 Jim Meyering - - * Makefile.maint (sc_xalloc_h_in_src): Remove rule. Subsumed by... - (sc_system_h_headers): Do this test only if sys2.h exists. - -2003-11-20 Jim Meyering - - * tests/help-version: Ensure that the bug-reporting address is - included in the --help output for every program. - * tests/Makefile.am (TESTS_ENVIRONMENT): Add $PACKAGE_BUGREPORT. - - * src/ptx.c (usage): Output bug-reporting address. - Reported by Dan Jacobson. - -2003-11-19 Jim Meyering - - * src/join.c (usage): Mention that FILE1 and FILE2 must be sorted - on the join fields. Suggestion from Bruce Robertson. - -2003-11-18 Jim Meyering - - `od -c -w9999999' could segfault - * src/od.c (dump): Use xnmalloc/free, not alloca. - -2003-11-16 Jim Meyering - - * Use autoconf-2.59. Regenerate dependent files. - - * tests/du/hard-link: Minor tweak: use mkdir -p. - - Fix read-from-free'd-buffer error detected by valgrind. - * src/csplit.c (remove_line): Don't return a pointer to data in - a freed buffer. Instead, arrange to free the buffer on the - subsequent call. - - * tests/misc/csplit: New test for above fix. - -2003-11-11 Jim Meyering - - * src/ls.c (extract_dirs_from_files): Avoid useless copy operations. - This avoids a warning from valgrind about memcpy with overlapping - source and destination. - - * configure.ac: Require automake-1.7.8. - -2003-11-09 Jim Meyering - - * Use automake-1.7.9. Regenerate dependent files. - - * src/rm.c: Support new options: --preserve-root and --no-preserve-root. - * src/chown.c: Likewise. - - * src/chown-core.c: Include "root-dev-ino.h". - (chopt_init): Initialize new member. - (change_file_owner): Support rm's new --preserve-root option. - - * src/remove.c: Include "root-dev-ino.h". - (remove_cwd_entries): Remove now-obsolete FIXME comment. - (remove_dir): Support rm's new --preserve-root option. - - * src/chown.c: Include "root-dev-ino.h". - Add new options: --preserve-root and --no-preserve-root. - - * src/chmod.c: Include "root-dev-ino.h". - (process_file): Use newly-factored-out ROOT_DEV_INO_CHECK and - ROOT_DEV_INO_WARN macros. - (get_root_dev_ino): Remove function definition, now that it's - been moved to a separate file. - (usage): Describe new options. - - * src/mv.c (rm_option_init): Initialized new member. - - * src/remove.h: Include "dev-ino.h". - (struct rm_options): Add new member: root_dev_ino. - * src/chown-core.h: Include "dev-ino.h". - (struct Chown_option): Add new member: root_dev_ino. - -2003-11-06 Jim Meyering - - * src/paste.c (paste_parallel): Use `sizeof *var' rather than - hard-coding `sizeof FILE*'. - -2003-11-05 Dennis Smit - - * src/wc.c (main): Free `fstatus' so there is no confusion about - whether it's leaked or not. - * src/who.c (who): Likewise for `utmp_buf'. - -2003-11-05 Paul Eggert - - Fix 'cut' problems with size_t overflow and unsigned int. - More generally, resize integer variables to fit use more precisely. - * src/cut.c (ADD_RANGE_PAIR): Remove unnecessary parens. - (struct range_pair): Make members to be of type size_t, not unsigned. - (max_range_endpoint, eol_range_start): Now size_t, not unsigned. - (suppress_non_delimited, output_delimiter_specified, - have_read_stdin, print_kth, set_fields): Now bool, nt int. - (delim): Now unsigned char, not int. - (mark_printable_field, is_printable_field, is_range_start_index, - set_fields, set_fields, cut_bytes, cut_fields): - Use size_t, not unsigned, for field and byte counts. - (hash_int): Use uintptr_t, not unsigned, for pointers converted - to integers. This squeezes more info out of them. - (set_fields, cut_bytes, cut_fields, main): - Use bool, not int, for booleans. - (set_fields): Allocate zeroed byte array with xzalloc, not xcalloc. - -2003-11-05 Paul Eggert - - * man/Makefile.am (check-programs-vs-x): - Work even if $(programs) contains '$'. - Work even if 'missing=1' in environment. - Don't report an error simply because $(programs) outputs nothing. - -2003-11-05 Jim Meyering - - * Use autoconf-2.58. Regenerate dependent files. - - * src/tr.c (spec_init): Fix typo in last change. - - * src/sys2.h (case_GETOPT_VERSION_CHAR): Cast NULL to `(char *)' in - call to variadic version_etc function, so that it works even on systems - for which sizeof char* != sizeof int. - * src/true.c (main): Likewise. - * basename.c, chroot.c, cksum.c, dd.c, dirname.c, echo.c, expr.c: - * factor.c, hostid.c, hostname.c, link.c, logname.c, nice.c, nohup.c: - * pathchk.c, printenv.c, printf.c, pwd.c, setuidgid.c, sleep.c, stty.c: - * sync.c, test.c, tsort.c, unlink.c, uptime.c, users.c, whoami.c, yes.c: - Similarly, cast NULL to `(char *)' in call to variadic function, - parse_long_options, so that it works even on systems for which - sizeof char* != sizeof int. - A similar problem was reported by Harti Brandt in - http://mail.gnu.org/archive/html/bug-gnu-utils/2003-10/msg00320.html. - - * src/users.c (users): Free `utmp_buf' explicitly so that people - don't mistake this for a real leak. - Patch by Dennis Smit - - * README: Document _POSIX2_VERSION. - -2003-11-04 Jim Meyering - - * src/tac.c (memrchr): Remove #if-0'd function. - (tac_stdin_to_mem): Clean up #if-0'd code. - - * src/od.c (decode_format_string): Remove unnecessary casts. - Use more maintainable `sizeof *var'. - (main): Call decode_format_string rather than decode_one_format, - now that `spec' may be NULL. - - * src/chmod.c (AUTHORS): Add my name. - - * src/split.c (next_file_name): Use `sizeof *var' rather than - hard-coding `sizeof size_t'. - - * src/sort.c (new_key): Use xzalloc, not xcalloc (1, ...). - - * src/cut.c (ADD_RANGE_PAIR): Use x2nrealloc rather than xrealloc, - to avoid potential overflow in pointer arithmetic. - (set_fields): Use not `1', but rather `sizeof *printable_field' as - second argument to xcalloc. - * src/od.c (decode_format_string, dump_strings): Use x2nrealloc - rather than xrealloc. - * src/date.c (show_date): Likewise. - * src/join.c (ADD_FIELD, initseq, getseq): Likewise. - * src/pr.c (store_char): Likewise. - * src/fold.c (fold_file): Likewise. - - * src/copy.c (triple_hash, triple_hash_no_name): Adjust to reflect - type changes (unsigned int -> size_t) in hash.c. - * src/cp-hash.c (src_to_dest_hash): Likewise. - * src/du.c (entry_hash): Likewise. - * src/ls.c (dev_ino_hash): Likewise. - * src/cut.c (hash_int): Likewise. Declare function as static. - -2003-11-03 Jim Meyering - - * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Define PACKAGE_VERSION. - * tests/misc/fold: Fail the test immediately if we're not running - the expected version of fold. - -2003-11-02 Jim Meyering - - * src/tr.c (append_normal_char, append_range, append_char_class) - (append_repeated_char, append_equiv_class, spec_init): Use `sizeof *var' - rather than `sizeof EXPLICIT_TYPE'. The former is more maintainable - and usually shorter. - * src/copy.c (copy_internal): Likewise. - * src/join.c (initseq, add_field, make_blank): Likewise. - * src/od.c (main): Likewise. - * src/cp.c (make_path_private): Likewise. - * src/tsort.c (new_item, record_relation): Likewise. - - * src/df.c (add_fs_type, add_excluded_fs_type, main): Likewise. - (main): Also remove anachronistic cast of xmalloc return value. - * src/ptx.c (alloc_and_compile_regex, main): Likewise. - (main): Also remove anachronistic cast of xmalloc return value. - * src/sort.c (inittables): Likewise. - (sort): Also Split a long line. - -2003-10-25 Jim Meyering - - * src/copy.c (triple_hash, triple_hash_no_name): Adjust to reflect - type changes (unsigned int -> size_t) in hash.c. - * src/cp-hash.c (src_to_dest_hash): Likewise. - * src/du.c (entry_hash): Likewise. - * src/ls.c (dev_ino_hash): Likewise. - * src/cut.c (hash_int): Likewise. Declare function as static. - -2003-10-21 Jim Meyering - - Don't fail when run with VERBOSE=yes. - * tests/chgrp/basic: Do `set +x' before starting the subshell - from which we invoke chgrp. Otherwise, the output from the - VERBOSE=yes-induced `set -x' would result in spurious differences. - Reported by Russel Coker via Michael Stone. - -2003-10-19 Jim Meyering - - chmod now uses fts to perform a directory traversal when -R is - specified. Before, it operated on full path names, and as such - would encounter the PATH_MAX (often 4096) limit. - - * src/chmod.c: Include "xfts.h". - (process_file): Rename from change_file_mode. - Adapt to be used with fts. - (process_files): New function. - -2003-10-18 Jim Meyering - - * tests/du/deref-args: Ensure that du -D now dereferences all - symlinks specified on the command line, not just those that - reference directories. - - * basename.c, cat.c, chroot.c, cksum.c, comm.c, cp.c, csplit.c, cut.c: - * dd.c, df.c, dirname.c, du.c, echo.c, env.c, expr.c, factor.c, head.c: - * hostid.c, hostname.c, id.c, link.c, ln.c, logname.c, ls.c, md5sum.c: - * mv.c, nice.c, nl.c, nohup.c, paste.c, pathchk.c, pinky.c, pr.c: - * printenv.c, printf.c, pwd.c, rm.c, setuidgid.c, sleep.c, sort.c: - * split.c, stty.c, sum.c, sync.c, tac.c, tail.c, tee.c, test.c: - * touch.c, tsort.c, uniq.c, unlink.c, uptime.c, users.c, wc.c: - * who.c, whoami.c, yes.c (AUTHORS): Revert the WRITTEN_BY/AUTHORS change - of 2003-09-19. Now, AUTHORS is a comma-separated list of strings. - Update the call to parse_long_options so that `AUTHORS, NULL' are the - last parameters. - * src/true.c (main): Append NULL to version_etc argument list. - * src/sys2.h (case_GETOPT_VERSION_CHAR): Likewise. - -2003-10-17 Andreas Schwab - - * tests/mk-script: Get $srcdir from first parameter instead of - hardcoding it. - (main): Update usage. - - * tests/Makefile.am.in ($(srcdir)/$x-tests): Pass $(srcdir) as - first argument of mk-script. - ($(srcdir)/Makefile.am): Likewise. Prepend $(srcdir) to target. - -2003-10-17 Jim Meyering - - * src/mv.c (usage): Tweak descriptions of -i and -f so that the - generated `man' page is more readable. Suggestion from Dan Jacobson. - - * src/chown-core.c (change_file_owner): Handle the cases in - which fts_info indicates an error with the given entry. - - * src/du.c (main): Simply assign to bit_flags. - Don't bother with bit arithmetic. - - * tests/chmod/no-x: New file. - * tests/chgrp/no-x: New file. - * tests/chmod/Makefile.am (TESTS): Add no-x. - * tests/chgrp/Makefile.am (TESTS): Likewise. - - * src/du.c: Include "xfts.h". - (du_files): Use xfts_open, rather than fts_open. - * src/chown-core.c (chown_files): Likewise. - -2003-10-16 Jim Meyering - - * src/chgrp.c (main): Simply assign to bit_flags. - Don't bother with bit arithmetic. - * src/chown.c (main): Likewise. - Rename a couple of local variables. - Remove unnecessary casts. - - * src/tail.c (start_bytes): Rename local, remainder, to avoid - gcc's warning about shadowing a global. - -2003-10-15 Jim Meyering - - chown and chgrp now accept POSIX-mandated -H, -L, -P options and - use fts to perform a directory traversal when -R is specified. - Before, they operated on full path names, and as such would - encounter the PATH_MAX (often 4096) limit. - They are more efficient. For example, before, chgrp -R would - take almost 5 seconds to change about 2000 directories and fail - (with `File name too long'), while now it succeeds on a hierarchy - of depth 20,000 in 1/10 the time. - - * src/chown.c: Include "userspec.h" and "fts_.h". - (WRITTEN_BY): Add my name. - (getpwnam, getgrnam, getgrgid): Remove declarations. - (endpwent): Remove definition. - (usage): Update. - (main): Handle new options. - Call new function, chown_files rather than change_file_owner. - - * src/chgrp.c: Include "fts_.h". - (WRITTEN_BY): Add my name. - (MAXUID, MAXGID): Remove definitions. Use GID_T_MAX instead of - the latter. - (usage): Update. - (main): Handle new options. - Call new function, chown_files rather than change_file_owner. - - Rewrite to iterate through hierarchies using fts rather than - via explicit recursion. - * src/chown-core.c: Include "fts_.h" - (change_file_owner): Rewrite to use FTS* and FTSENT* and to operate - on a single file at a time. - (chown_files): New function. - * src/chown-core.h [enum Dereference_symlink]: Remove declaration. - [struct Chown_option] (recurse, force_silent): Change type to `bool'. - [struct Chown_option] (dereference): Remove member with ambiguous name. - [struct Chown_option] (affect_symlink_referent): New member. - (chown_files): New prototype. - - * tests/chgrp/recurse: Update tests accordingly. - * tests/chgrp/posix-H: New tests for the above. - * tests/chgrp/Makefile.am (TESTS): Add posix-H. - - * src/ln.c (usage): Clarify that --directory, -d, -F probably won't - work even for superuser. Suggestion from Dan Jacobson. - -2003-10-14 Paul Eggert - - Fix some number-parsing bugs, e.g., "head -n 100k@" wasn't - properly diagnosed. - * lib/human.c, lib/xstrtoimax.c, lib/xstrtol.c, lib/xstrtol.h, - lib/xstrtoul.c, lib/xstrtoumax.c: Sync with gnulib. - * src/sort.c (parse_field_count): Handle the case where overflow - and invalid suffix char are both reported. - -2003-10-14 Jim Meyering - - * src/ls.c (decode_switches) [TIOCGWINSZ]: Comment out the - warning-inducing test, ws.ws_col <= SIZE_MAX, since it was always - true on Linux. - -2003-10-13 Paul Eggert - - Fix to avoid a denial-of-service attack if the display width is - enormous. Also, clean up the code a bit by removing duplicate code. - - * src/ls.c (init_column_info): Remove forward decl; no longer needed. - (calculate_columns): New function, that contains code that used - to be common to print_many_per_line and print_horizontal. - (print_many_per_line, print_horizontal): Use it. - (decode_switches): Set max_idx here, not in calculate_columns. - (print_current_files): Don't call init_column_info; calculate_columns - now does that. - (init_column_info): Don't allocate a lot more space than is needed - to represent the current set of files. Allocate all the new - size_t cells in one call to xnmalloc, rather than a row at a time. - -2003-10-13 Jim Meyering - - * src/ls.c (init_column_info): Add another FIXME comment. - -2003-10-13 Paul Eggert - - Fix address-arithmetic bug in 'ls', reported by Georgi Guninski. - Remove several arbitrary limits on hosts where int cannot represent - all size_t values. - - * src/ls.c (struct bin_str.len, length_of_file_name_and_frills, indent, - nfiles, files_index, tabsize, line_length, struct column_info.line_len, - struct column_info.col_arr[0], max_idx): - Now size_t, not int. - (get_funky_string): Return bool indicating success, instead of - a negative count to indicate failure. Store number of columns - through new parameter OUTPUT_COUNT; that way, they can never - go negative. Change equals_end from int to bool. All uses - changed. - (struct column_info.valid_len): Now bool, not int. All uses changed. - (dired_dump_obstack, get_funky_string, clear_files, - extract_dirs_from_files, print_current_files, - print_many_per_line, print_horizontal, init_column_info, - put_indicator, length_of_file_name_and_frills, - print_with_commas): Use size_t, not int, for local variables - that count sizes. - (decode_switches): Decode sizes using xstrtoul, not xstrtol. - Check for TIOCGWINSZ returing negative values (or values greater - than SIZE_MAX!). - (visit_dir, main, parse_ls_color, queue_directory, add_ignore_pattern, - init_column_info): - Use xmalloc and xnmalloc, not XMALLOC. - (gobble_file): Use xnrealloc, not XREALLOC. - (print_color_indicator): Remove now-unnecessary cast to size_t. - -2003-10-12 Paul Eggert - - * tests/du/no-x: Change wording of diagnostic to match latest du.c. - * tests/sort/sort-tests: Remove from CVS; assume that people - brave enough to check coreutils out from CVS can rebuild it. - -2003-10-12 Jim Meyering - - New options: --preserve-root and --no-preserve-root. - * src/chmod.c (change_file_mode): Honor new option. - (change_file_mode): Strip trailing slashes on directory - argument passed to change_dir_mode. - (get_root_dev_ino): New function. - (main): Initialize global, root_dev_ino. - - * src/copy.c (copy_internal): Don't #ifdef-out simple uses of - S_ISLNK or S_ISSOCK. The S_IS* macros are guaranteed to be defined - via system.h. - * src/chmod.c (change_file_mode): Likewise. - -2003-10-08 Jim Meyering - - * src/csplit.c (main): Remove obsolete FIXME. - -2003-10-07 Jim Meyering - - * Use automake-1.7.8. Regenerate dependent files. - -2003-09-29 Paul Eggert - - csplit cleanup. - - * doc/coreutils.texi (csplit invocation): - The regexp offset need not have a sign; POSIX requires support - for signless offets. - - Be more careful about int widths. For example, remove some - arbitrary limits by replacing 'unsigned' with 'size_t', - 'uintmax_t', etc. Use standard bool rather than a homegrown type. - * lib/Makefile.am (libfetish_a_SOURCES): Add xstrtoimax.c. - * src/csplit.c (FALSE, TRUE, boolean): Remove. All uses changed - to usage. - (struct control): offset is now intmax_t, not int. - repeat_forever is now bool, not int. - (struct cstring): len is now size_t, not unsigned int. - (struct buffer_record): bytes_alloc, bytes_used, num_lines are now - size_t, not unsigned. start_line, first_available are now - uintmax_t, not unsigned. - (hold_count, control_used): Now size_t, not unsigned. - (last_line_number, current_line, bytes_written): - Now uintmax_t, not unsigned. - (save_to_hold_area, red_input, keep_new_line, record_line_starts, - create_new_buffer, get_new_buffer, load_buffer, find_line, - process_regexp, split_file, new_control_record, extract_regexp, - get_format_width, get_format_prec, max_out): - size args, locals, and returned values are now size_t, not unsigned - or int. - (get_first_line_in_buffer, find_line, write_to_file, - handle_line_error, process_line_count, regexp_error, process_regexp, - split_file): - File line, byte, and repetition counts are now uintmax_t, not unsigned. - (check_for_offset): Don't require a sign before the offset. - Use xstrtoimax to do the real work. - (extract_regexp): Remove harmful cast of size to unsigned. - 256 -> 1< - - * src/chown-core.c (change_file_owner): Remove set-but-not-used local. - - * src/du.c (du_files): Mark diagnostic for translation. - -2003-10-04 Jim Meyering - - * src/du.c (du_files): Ignore any failure of fts_close. - Give better diagnostics for failed fts_open. - - * src/du.c (MAX_N_DESCRIPTORS): Remove now-unused definition. - - Deprecate existing use of -H (aka --si). - * src/du.c (enum) [HUMAN_SI_OPTION]: New member. - [long_options]: Use HUMAN_SI_OPTION, not 'H'. - (main): Warn that the meaning of -H will soon change to be - POSIX compliant. - -2003-10-03 Jim Meyering - - * src/du.c: Accept --no-dereference (-P). - -2003-10-02 Jim Meyering - - * tests/du/trailing-slash: Adjust for slightly different output. - - Rewrite du.c to use fts. - * src/du.c: Include "fts_.h", not ftw.h. - (opt_dereference_arguments, arg_length, suffix_length): Remove globals. - (IS_FTW_DIR_TYPE): Remove definition. - (IS_DIR_TYPE): Define. - (is_symlink_to_dir): Remove now-unnecessary function. - (process_file, du_files): Rewrite to use fts. - - * tests/du/inaccessible-cwd: Ensure that even when run from an - inaccessible directory, du can still operate on accessible - directories elsewhere. - * tests/du/Makefile.am (TESTS): Add inaccessible-cwd. - - * tests/rm/deep-1: Ensure that du can process a hierarchy - of depth 400 while using no more than 50KB of stack space. - -2003-10-01 Akim Demaille - - * announce-gen (print_news_deltas): New function, extracted from main. - (main): Make `news_file' an array. - Use '...=s' => \@var for --news and --url-directory specs. - Before there were a couple of portability problems. - -2003-09-28 Jim Meyering - - * Makefile.maint (sc_cast_of_alloca_return_value): New rule. - (syntax-check-rules): Add it. - - * src/copy.c: Remove unnecessary cast of alloca, since now it's - guaranteed to be (void *). - * src/cp.c: Likewise. - * src/join.c: Likewise. - * src/ln.c: Likewise. - * src/ls.c: Likewise. - * src/od.c: Likewise. - * src/sys2.h (ASSIGN_STRDUPA): Likewise. - -2003-09-27 Jim Meyering - - Don't exhaust virtual memory when processing large inputs. - Fix this by removing csplit's internal free-list management; - instead rely on malloc for that. - - * src/csplit.c (free_list): Remove global. - (clear_all_line_control): Remove function. - (get_new_buffer): Always use create_new_buffer to obtain a - new buffer, rather than searching free_list. - (free_buffer): Just call free. - Reported by Nikola Milutinovic. - -2003-09-26 Jim Meyering - - * man/rm.x: Also list `chattr' in SEE ALSO section. - Suggestion from Mark Hubbart. - -2003-09-25 Jim Meyering - - * configure.ac: Don't invoke AC_AIX or AC_MINIX explicitly, now - that we use gl_USE_SYSTEM_EXTENSIONS, since it AC_REQUIREs them. - - * Use autoconf-2.57d. Regenerate dependent files. - -2003-09-24 Jim Meyering - - Minor efficiency tweak. - * src/ln.c (PATH_BASENAME_CONCAT): Use memcpy rather than strcpy. - (do_link): Likewise. - -2003-09-23 Jim Meyering - - * src/paste.c (paste_serial): Save errno after input error, - to report proper errno value. - Based on a patch from Paul Eggert. - - * src/tee.c (tee): Adjust fwrite arguments so that the return - value is the number of bytes written. - -2003-09-16 Paul Eggert - - Don't assume ferror sets errno. Bug reported by Bruno Haible. - - * src/comm.c (compare_files): Save errno after input error, - to report proper errno value. - * src/fold.c (fold_file): Likewise. - * src/od.c (check_and_close, skip, read_char, read_block): Likewise. - * src/unexpand.c (unexpand): Likewise. - - * src/csplit.c (close_output_file): Don't report bogus errno value - after ferror discovers an output error. We don't know the proper - errno value, since it might have been caused by any of a whole - bunch of calls, and it might have been trashed in the meantime. - Fixing this problem will require much more extensive changes; - in the meantime just say "write error". - * src/od.c (check_and_close, dump, dump_strings): Likewise. - * src/uniq.c (check_file): Likewise. - - * src/join.c (get_line): Report error right away if I/O fails, - so that the proper errno value is used. - * src/tac.c (tac_seekable, tac_file, save_stdin): Likewise. - * src/tee.c (tee): Likewise. - * src/uniq.c (check_file): Likewise. - - * src/od.c (skip): If a read fails, don't retry it later, so - that we report the proper errno. - - * src/tac.c (tac_mem): Don't return a value; nobody uses it. - - * src/tee.c (tee): Once a write failure has occurred, don't bother - writing anything more to that stream. - - * src/uniq.c (check_file): Check for ferror (stdout) even if - ostream == stdout. - - * src/yes.c (UNROLL): Remove. - (main): Exit immediately when write failure is detected. - Simplify code by assigning to argv when argc == 1. - -2003-09-21 Paul Eggert - - * src/ptx.c: Switch encoding from Latin-1 to UTF-8. - (WRITTEN_BY): Change "Franc,ois" (actually using - c-with-cedilla in Latin-1) to "F.", so that it's ASCII, as - xgettext requires. - -2003-09-19 Jim Meyering - - `du -D symlink-to-dir' would mistakenly omit the slash in - lines like this: 24 symlink-to-dir/subdir - * src/du.c (process_file): Fix offset calculation. - Reported by Jeff Sheinberg as Debian bug #211591; - http://bugs.debian.org/205251 - - * tests/du/deref-args: New file/test for the above. - * tests/du/Makefile.am (TESTS): Add deref-args. - - * src/du.c (process_file): Remove useless disjunct. - - * src/sys2.h (case_GETOPT_VERSION_CHAR): Rename parameter, Authors, - to Written_by. - * nearly all src/*.c files (WRITTEN_BY): Rename from AUTHORS. - Begin each WRITTEN_BY string with `Written by ' and end it with `.'. - Mark each WRITTEN_BY string as translatable. - - * basename.c, cat.c, chroot.c, cksum.c, comm.c, cp.c, csplit.c, cut.c: - * dd.c, df.c, dirname.c, du.c, echo.c, env.c, expr.c, factor.c, head.c: - * hostid.c, hostname.c, id.c, link.c, ln.c, logname.c, ls.c, md5sum.c: - * mv.c, nice.c, nl.c, nohup.c, paste.c, pathchk.c, pinky.c, pr.c: - * printenv.c, printf.c, pwd.c, rm.c, setuidgid.c, sleep.c, sort.c: - * split.c, stty.c, sum.c, sync.c, tac.c, tail.c, tee.c, test.c: - * touch.c, tsort.c, uniq.c, unlink.c, uptime.c, users.c, wc.c: - * who.c, whoami.c, yes.c: Revert yesterday's changes. - Instead, a subsequent change will embed `Written by ' in - each string along with the author names. - - * src/true.c: Revert yesterday's changes. - * src/sys2.h: Likewise. - -2003-09-18 Jim Meyering - - * basename.c, cat.c, chroot.c, cksum.c, comm.c, cp.c, csplit.c, cut.c: - * dd.c, df.c, dirname.c, du.c, echo.c, env.c, expr.c, factor.c, head.c: - * hostid.c, hostname.c, id.c, link.c, ln.c, logname.c, ls.c, md5sum.c: - * mv.c, nice.c, nl.c, nohup.c, paste.c, pathchk.c, pinky.c, pr.c: - * printenv.c, printf.c, pwd.c, rm.c, setuidgid.c, sleep.c, sort.c: - * split.c, stty.c, sum.c, sync.c, tac.c, tail.c, tee.c, test.c: - * touch.c, tsort.c, uniq.c, unlink.c, uptime.c, users.c, wc.c: - * who.c, whoami.c, yes.c: Update AUTHORS definition to be a - comma-separated list of strings and/or update the call to - parse_long_options so that `AUTHORS, NULL' are the last parameters. - * src/true.c (main): Append NULL to version_etc argument list. - * src/sys2.h (case_GETOPT_VERSION_CHAR): Likewise. - - * src/sort.c (numcompare): Rename local, logb, to log_b to avoid - shadowing the math function name. Also rename loga to log_a. - -2003-09-14 Jim Meyering - - * src/factor.c (print_factors): Give a separate diagnostic - for numbers that are too large, but otherwise valid. - Reported by Dániel Varga. - -2003-09-10 Jim Meyering - - * Use automake-1.7.7. Regenerate dependent files. - - * tests/Makefile.am (all_programs): Use ../src/tr -s ' ' '\n' in place - of `fmt -1'. Using the just-built tr is a little cleaner. - Christian Krackowizer reported that HPUX 10.20 doesn't have fmt. - * man/Makefile.am (programs, check-x-vs-1): Likewise. - -2003-09-09 Jim Meyering - - * src/copy.c: Alphabetize includes. - Remove duplicate inclusion of "same.h". - -2003-09-08 Jim Meyering - - * Makefile.maint (GZIP_ENV): Remove --rsyncable. - Didn't give enough of a benefit, mainly because it's not yet - in wide enough use. - - * Version 5.0.91. - - * man/Makefile.am (programs): Use ../src, not $(srcdir)/../src. - (check-programs-vs-x): Fail if $(programs) is empty. - - * src/remove.c: Add a comment. - -2003-09-07 Jim Meyering - - * src/remove.c (D_INO, ENABLE_CYCLE_CHECK) [D_INO_IN_DIRENT]: - Don't define. These symbols are no longer used. - - * tests/misc/tty-eof: Write ^D as \cD. - Complete the change of 2003-08-02. - - * Makefile.maint (po-check): Use cvsu, so that a temporary source - file in lib/ or src/ doesn't induce an unwarranted failure. - Add a kludge to filter out the sole generated source file that - also has translatable messages: src/false.c. - -2003-09-06 Jim Meyering - - * src/tail.c (enum): Add ALLOW_MISSING_OPTION. - (parse_options): Give a diagnostic for (but still accept) the - deprecated --allow-missing option. - -2003-09-04 Paul Eggert - - Don't ignore -S if input is a pipe. Bug report by Michael McFarland in - . - - * src/sort.c (sort_buffer_size): Omit SIZE_BOUND arg. Compute the - size_bound ourselves. if an input file is a pipe and the user - specified a size, use that size instead of trying to guess the - pipe size. This has the beneficial side effect of avoiding the - overhead of default_sort_size in that case. All callers changed. - (sort): Remove static var size; now done by sort_buffer_size. - -2003-09-05 Jim Meyering - - * Use automake-1.7.6b and autoconf-2.57b. Regenerate dependent files. - - * tests/tail-2/tail-n0f: Wait .5 seconds for backgrounded process - to start, rather than just .1. Upon failure, print unexpected state. - -2003-09-04 Paul Eggert - - * src/head.c (elide_tail_lines_pipe): Don't assign 0 or - SAFE_READ_ERROR to tmp->nbytes. - * src/tail.c (pipe_lines, pipe_bytes): Likewise. - - * src/head.c (struct linebuffer): Change nbytes and nlines - from unsigned int to size_t. unsigned int is safe (after the - 2003-09-03 patch) but size_t is cleaner. - * src/tail.c (struct linebuffer, struct charbuffer): Likewise. - (pipe_bytes): Likewise for local variable 'i', which was 'int'. - - Standardize on BUFSIZ as opposed to other macro names and values. - * src/head.c (BUFSIZE): Remove. All uses changed to BUFSIZ. - * src/tail.c (BUFSIZ) [!defined BUFSIZ]: Remove. - stdio.h has always defined it, - and other code already assumes it's defined. - * src/tr.c (BUFSIZ) [!defined BUFSIZ]: Likewise. - (IO_BUF_SIZE): Remove; replace all uses with sizeof io_buf. - (io_buf): IO_BUF_SIZE -> BUFSIZ. - -2003-09-04 Paul Eggert - - * src/seq.c (step): Default to 1. - (print_numbers): Allow the output to be empty. - (main): The default step is 1, even if LAST < FIRST; - as per documentation. - * tests/seq/basic (onearg-2): Output should be empty. - -2003-09-05 Jim Meyering - - * Makefile.cfg (wget_files): Temporarily disable, until master - versions are restored to ftp.gnu.org. - - * configure.ac (AM_INIT_AUTOMAKE): Specify automake-1.7.6. - - Make seq's --width (-w) option work properly even when the - endpoint requiring the larger width is negative and smaller than - the other endpoint. - * src/seq.c (get_width_format): Include `-' in the set of bytes - allowed in a `simple' number (no decimal point, no exponent). - Reported by Patrick Mauritz. - -2003-09-02 Paul Eggert - - * NEWS: sort -t '\0' now uses a NUL tab. - sort option order no longer matters, unless POSIX requires it. - * src/sort.c (usage): Say "blanks" instead of "whitespace", - Similar fixes for many comments. - (TAB_DEFAULT): New constant, so that we can support NUL as - the field separator. - (tab): Now int, not char. Initialize to TAB_DEFAULT. - (specify_sort_size): If multiple sizes are specified, use the largest. - (begfield, limfield): Support NUL tab char. - (set_ordering): Do not let -i override -d. - (main): Report an error if incompatible -o or -t options are given. - Report an error for "-t ''". Allow "-t '\0'" to specify a NUL tab. - -2003-09-05 Jim Meyering - - * tests/sort/Test.pm [o2, nul-tab]: New tests for the above. - -2003-09-03 Andreas Schwab - - Bug report and patch here: - - * src/tail.c (pipe_lines): Don't truncate return value from safe_read. - * src/head.c (elide_tail_lines_pipe): Likewise. - -2003-09-03 Jim Meyering - - * src/du.c (AUTHORS): Remove Larry McVoy's name, since the relatively - small amount of code from him was first moved to lib/human.c, and was - subsequently rewritten entirely. - * src/df.c (AUTHORS): Likewise. - -2003-08-22 Lawrence Teo - - * src/md5sum.c (split_3): Accept the BSD format for generic - message digest modes. Currently works with BSD's MD5 and SHA1 - formats since these are the two algorithms presently used in - coreutils. Updated comments to reflect this change. - (bsd_split_3): Updated comments. - - * tests/md5sum/basic-1: New test to make sure that - `md5sum --check' doesn't accept the BSD SHA1 format (adapted - from `check-bsd' test in tests/sha1sum/basic-1). - - * tests/sha1sum/basic-1 (check-bsd2, check-bsd3): New tests for - --check exit status and BSD SHA1 format (adapted from tests - in tests/md5sum/basic-1). - -2003-08-30 Jim Meyering - - * src/ln.c (do_link): Use SAME_INODE rather than open-coding it. - - When source and destination arguments refer to the same file, reside - on a partition (e.g. VFAT) on which distinct names may refer to the - same directory entry (often due to variations in case), and when the - link count for the file is 1, mv no longer unlinks the file. Instead, - it gives the expected diagnostic that the source and destination are - the same. WARNING: this is an incomplete fix. If the file happens - to have a link count of 2 or greater, such an erroneous mv command - will still unlink it. - Although that is not possible on vfat or umsdos, it is possible on - other file system types, e.g., ntfs, and hpfs. - * src/copy.c (same_file_ok): Invoke same_name (which might still - return false for names that refer to the same directory entry) - only if the link count is 2 or more. - * tests/mv/vfat: Show how to demonstrate the above problem. - This test is not run. - * tests/mv/Makefile.am (EXTRA_DIST): Add vfat. - -2003-08-27 Jim Meyering - - * src/who.c: Change meaning of -l from --lookup to --login, per POSIX. - who's -l option has been eliciting an unconditional warning about - this impending change since sh-utils-2.0.12 (April 2002). - - * src/paste.c (paste_parallel): Don't output `EOF' (aka -1) as a `char'. - This would happen for nonempty files not ending with a newline. - Reported by Dan Jacobson. - * tests/misc/paste-no-nl: New file. Test for above-fixed bug. - * tests/misc/Makefile.am (TESTS): Add paste-no-nl. - - * src/stat.c (print_it): Avoid buffer overrun that would - occur when the user-specified format string ends with `%'. - Patch by Tommi Kyntola. - * tests/misc/stat-fmt: New file. Test for above-fixed bug. - * tests/misc/Makefile.am (TESTS): Add stat-fmt. - -2003-08-26 Jim Meyering - - Apply changes from bison. - * GNUmakefile (SHELL): Define to `sh', if necessary. - Add copyright. - * Makefile.maint (WGETFLAGS): Define to `-C off'. - Update all uses of $(WGET). - -2003-08-22 Akim Demaille - - * Makefile.cfg (local-checks-to-skip): New. - * Makefile.maint (local-check): Rename as... - (local-checks-available): this. - (local-check): New. - -2003-08-26 Akim Demaille - - * announce-gen (print_changelog_deltas): Neutralize "<#" as - "<\#" to avoid magic from Gnus when posting parts of this script. - -2003-08-25 Jim Meyering - - * src/stat.c (main): Warn about use of deprecated `-l' option. - -2003-08-22 Jim Meyering - - * src/stat.c (do_stat): For link count at end of line, use %h format, - instead of %-5h. The latter would make stat emit trailing spaces. - Reported by Dan Jacobson. - -2003-08-20 Jim Meyering - - * Makefile.am (EXTRA_DIST): Add .x-sc_space_tab .x-sc_sun_os_names - -2003-08-19 Jim Meyering - - * src/system.h: Include stdlib.h unconditionally, - as we're now assuming that part of hosted C89. - -2003-08-18 Jim Meyering - - * src/sys2.h (textdomain, bindtextdomain) [! ENABLE_NLS]: Define away, - to avoid warnings from gcc. - -2003-08-17 Jim Meyering - - Avoid unnecessary and sometimes time-consuming hostname lookups. - * src/who.c (print_user): Use strchr, not strrchr. - * src/pinky.c (print_entry): Likewise. - Patch by Michael Stone. - This fixes a typo I introduced in who-users.c on 1996-02-23. - - * Makefile.maint (makefile-check): Add 0-9 to the range of characters - disallowed between `@...@'. - -2003-08-16 Paul Eggert - - * configure.ac (fu_cv_sys_truncating_statfs): Remove; now - done by gnulib .m4 files. - (jm_DUMMY_1): Require gl_READUTMP, not jm_PREREQ_READUTMP. - * src/sys2.h (strtoull): Remove unused declaration. - -2003-08-16 Jim Meyering - - * man/Makefile.am (.x.1): Ensure that generated PROGRAM.1 files - are read-only. - - * src/tail.c (tail_lines): Fix a potential (but very hard to exercise) - race condition bug. The bug would be triggered when tailing a file - with file pointer not at beginning of file, and where the file was - truncated to have a length of less than the initial offset at just - the right moment (between the two lseek calls in this function). - - An invalid initial value for *read_pos would result in - `tail -n0 -f FILE' and `tail -c0 -f FILE' doing what amounted to a - busy-wait rather than sleeping between iterations. The bug manifests - itself only when tailing regular files that are initially nonempty. - * src/tail.c (tail_bytes): Set *read_pos to new file offset after - each xlseek call. - (tail_lines): Likewise, after lseek calls. - Reported by Nick Estes. See http://bugs.debian.org/205251 for details. - * tests/tail-2/tail-n0f: New file. Test for above fix. - * tests/tail-2/Makefile.am (TESTS): Add tail-n0f. - -2003-08-15 Jim Meyering - - * Makefile.maint (sc_space_tab): Use exclusion list in separate file. - (sc_sun_os_names): Likewise. - * .x-sc_space_tab, .x-sc_sun_os_names: New files. - - * man/help2man: Remove some SPACEs before TAB. - -2003-08-14 Paul Eggert - - * Makefile.maint (LC_ALL): Set to C. - * man/Makefile.am (ASSORT): New var. - (check-x-vs-1, programs): Use it. - * src/Makefile.am (ASSORT, check-README, ../AUTHORS): Likewise. - * tests/Makefile.am (ASSORT, all_programs): Likewise. - -2003-08-11 Jim Meyering - - fold -s -wN would infloop for N < 8 with TABs in the input. - E.g., this would not terminate: printf 'a\tb' | fold -w2 -s - * src/fold.c (fold_file): Move contents of `else'-block - out of conditional so it's used also for --spaces (-s). - * tests/misc/fold: Test for the above fix. - * tests/misc/Makefile.am (TESTS): Add fold. - -2003-08-10 Jim Meyering - - * src/nice.c [!NICE_PRIORITY]: Include after - system.h so the types from time.h and sys/time.h are available. - It appears that this is necessary for OpenBSD, NetBSD, and - Darwin 6.5 (MacOS 10.2.5). Reported by Nelson Beebe. - -2003-08-06 Paul Eggert - - * NEWS: Add support for setting file timestamps to microsecond - resolution, on hosts that support this. - * src/copy.c, src/cp.c, src/install.c, src/touch.c: Include utimens.h. - * src/copy.c (copy_internal): - Set file timestamps with utimens, not utime. - * src/cp.c (re_protect): Likewise. - * src/install.c (change_timestamps): Likewise. - * src/touch.c (newtime, touch, main): Likewise. - -2003-08-09 Jim Meyering - - * Makefile.maint (sc_sun_os_names): New rule based on a regexp - from Paul Eggert. - (syntax-check-rules): Add it. - - * src/tail.c (main): Tweak Solaris OS version number in comment. - * src/wc.c (wc): Likewise - * tests/tail-2/fflush: Likewise. - - * src/tail.c: Add new undocumented option, --presume-input-pipe. - (pipe_lines): Use memchr to skip lines, rather than an explicit loop. - -2003-08-08 Paul Eggert - - Use new gnulib 'extensions' module. - * configure.ac: Invoke gl_USE_SYSTEM_EXTENSIONS instead of - AC_GNU_SOURCE. - -2003-08-08 Paul Eggert - - * tests/du/basic: Ensure that a/b/F has at least 65 bytes too. - -2003-08-09 Jim Meyering - - * tests/misc/split-fail: Reflect that `split -a 0' is now accepted. - For tests of obsolete behavior, don't presume that unsetting - _POSIX2_VERSION is equivalent to _POSIX2_VERSION=199209. - -2003-08-07 Paul Eggert - - * doc/coreutils.texi (split invocation): - Add -d or --numeric-suffixes option to 'split'. - From a suggestion by Jesse Kornblum. - * src/split.c (suffix_alphabet): New var. - (longopts, usage, next_file_name, main): Support -d. - (next_file_name, main): Allow -a0, as POSIX requires. - (next_file_name): Don't assume ASCII-like encoding; - 'a' through 'z' are not contiguous in EBCDIC. - -2003-08-05 Paul Eggert - - Merge getline from gnulib. - * lib/getline.h, lib/getline.c, m4/getline.m4: Merge from gnulib. - * lib/getndelim2.h, lib/getndelim2.c, m4/getndelim2.m4, m4/ssize_t.m4: - New files, from gnulib. - * lib/getdelim2.c, lib/getdelim2.h: Remove. - * lib/Makefile.am (libfetish_a_SOURCES): Change getdelim2.c and - getdelim2.h to getndelim2.c and getndelim2.h. - * m4/jm-macros.m4 (jm_MACROS): Use gl_GETNDELIM2 rather than - checking for getdelim. - (jm_CHECK_ALL_TYPES): Use gt_TYPE_SSIZE_T for ssize_t rather - than rolling our own. - * src/cut.c: Include getndelim2.h rather than getdelim2.h. - (cut_fields): Invoke getndelim2 rather than getdelim2. - -2003-08-04 Jim Meyering - - * src/sort.c (main): Use unsigned int instead of int for `nsigs' - and for the indices to iterate through nsigs. - -2003-08-02 Paul Eggert - - * src/sort.c: Minor code cleanups, mostly to use more accurate - types and to remove unnecessary casts. - (min, max): Remove. All uses changed to MIN and MAX. - (hard_lc_collate, hard_LC_TIME, struct buffer.eof, struct - keyfield.skipsblanks, struct keyfield.skipeblanks, struct - keyfield.numeric, struct keyfield.general_numeric, struct - keyfield.month, struct keyfield.reverse, reverse, unique, - have_read_stdin): Now bool, not int. All uses changed. - (eolchar): Now char, not int. - (struct keyfield.ignore): Now bool const *, not int *. - (struct keyfield.translate): Now char const *, not char *. - (struct month.name): Likewise. - (blanks, nonprinting, nondictionary): Now bool[], not int[]. - (cleanup, inittables, keycompare, check, mergefps, first_same_file, - check, sort, main): Use const * pointers when possible. - (month_cmp): Rewrite to avoid casts. - (inittables): Initialize tables unconditionally, to avoid branches. - (fillbuf): Return bool, not int. All uses changed. - (fillbuf, keycompare, new_key, main): - Use SIZE_MAX rather than (size_t) -1. - (trailing_blanks): Renamed from trim_trailing_blanks. - Return the number of blanks to trim. All uses changed. - (getmonth): Use trailing_blanks rather than open code. - (keycompare): Do not cast char * to unsigned char *; not needed. - CMP_WITH_IGNORE converts args to UCHAR, so no need to convert it - ourselves. - (compare, main): Use | rather than || to avoid jumps. - Replace "diff = NONZERO (alen)" with "diff = 1", since alen must - be nonzero there. - (check, first_same_file, sort, main): - Use bool instead of int local vars when possible. - (check): Merge the old 'checkfp' and 'check' into a single function, - that returns a boolean (true if the file was ordered). - All uses changed. - (main): Use int instead of unsigned for iterating through nsigs. - Rename local var "posix_pedantic" to "posixly_correct". - -2003-08-02 Jim Meyering - - * src/nice.c [!NICE_PRIORITY]: Include before - to avoid compilation error on Ultrix. Reported by Christian Krackowizer. - - * src/cut.c (cut_fields): Don't read again after encountering an - initial EOF. E.g., `cut -f2' would do so. - * tests/misc/tty-eof: Add a test for the above fix. - - * src/sort.c (sortlines): Add description and references. - From Paul Eggert. - - * tests/Makefile.am (TESTS_ENVIRONMENT): Set PATH so that - the tests in help-version will use the just-built binaries. - Reported by Christian Krackowizer. - -2003-07-31 Paul Eggert - - * NEWS: Add --rfc-2822 option to GNU date. - * doc/coreutils.texi (Time directives, Options for date, Examples - of date): Likewise. - * src/date.c (long_options, usage, main): Likewise. - * doc/getdate.texi (General date syntax): Likewise. - * doc/coreutils.texi (Options for date): Fix a typo in format: - it's now %d not %_d. Add URLs. - -2003-08-01 Jim Meyering - - * tests/shred/remove: Ensure that $? is 0 for the final `exit 0'. - Otherwise, with at least the /bin/sh from HPUX 10.20, - the trap code would end up converting that to exit 1 and thus an - unexpected test failure. Reported by Christian Krackowizer. - -2003-07-31 Paul Eggert - - * src/ptx.c: Do not include bumpalloc.h. - (WORD_TABLE): New member alloc. - (ALLOC_NEW_WORD): Remove. - (occurs_alloc): New var. - (digest_word_file, find_occurs_in_text): Check for arithmetic - overflow when computing table size. Use xrealloc rather than - bumpalloc primitives. - -2003-07-29 Jim Meyering - - * Version 5.0.90. - - * README: When running tests as root, suggest using - sudo with NON_ROOT_USERNAME=$USER. - - * tests/Makefile.am (all_programs): Makefile is in ../src, not - $(srcdir)/../src. - -2003-07-28 Jim Meyering - - * Makefile.maint (GZIP_ENV): Try Debian/gzip's new --rsyncable option. - -2003-07-28 Paul Eggert - - * lib/stdbool.hin (_Bool): Make it signed char, instead of - an enum type, so that it's guaranteed to promote to int. - * src/sort.c (sortlines_temp): Undo previous change. - -2003-07-28 Jim Meyering - - * src/sort.c (sortlines_temp): Declare local `swap' to be `int', not - `bool'. Otherwise, at least one buggy compiler (alpha gcc-2.95.4) - would cause lines[-1 - swap] (with swap = false) to evaluate to - lines[4294967295]. - -2003-07-27 Jim Meyering - - * tests/priv-check (my_uid): Use `!', not `^' in case pattern `[!0-9]', - since /bin/sh of at least NetBSD 1.6 and OpenBSD 3.2 don't accept `^'. - - * src/remove.c (prompt) [! recursive]: Don't prompt about unwritable - directories, as required by POSIX. Reported by Karl Berry. - * tests/rm/dir-no-w: New file. Test for the above fix. - * tests/rm/Makefile.am (TESTS): Add dir-no-w. - - * tests/mk-script: Emit `$xx', not its expansion. - -2003-07-27 Paul Eggert - - This change was inspired by a similar proposal by Stepan Kasal. - * src/sort.c (mergelines, sortlines_temp): New functions. - (sortlines): Use them, to reduce the number of times that - we need to copy 'struct line' values. This improved CPU - performance by about 30% on one 18 MB test. - (sort): Don't invoke sortlines unless we have 2 or more lines. - -2003-07-26 Stepan Kasal - - * src/sort.c (sort): Don't require two `struct line's per text line, - the new sort algorithm requires just 1.5. - -2003-07-27 Jim Meyering - - * src/pathchk.c (validate_path): Use %lu, not %ld. - From Paul Eggert. - * src/cut.c (is_printable_field): Simplify bit arithmetic. - From Paul Eggert. - * src/ls.c (sort_files): Put `volatile' in the right place. - From Paul Eggert. - -2003-07-26 Jim Meyering - - Use only one bit per field/offset in array, not one `int'. - * src/cut.c (printable_field): Change type to `unsigned char'. - (mark_printable_field, is_printable_field): New functions. - Use them in place of all direct accesses of `printable_field'. - - * src/expand.c (parse_tabstops): Detect overflow properly. - * src/cut.c (set_fields): Likewise. - - * src/rm.c: Include "dirname.h". - (usage): Use base_name (program_name) in body of --help output. - This lets me... - * man/Makefile.am (.x.1): ...back out the kludge of 2003-07-22. - Idea from Brendan O'Dea, who suggested using - `program_name = basename (argv[0]);' everywhere -- - can't do that, but using base_name works just fine here. - - * src/Makefile.am (AM_INSTALLCHECK_STD_OPTIONS_EXEMPT): Exempt test. - -2003-07-24 Paul Eggert - - Fix some POSIX-compliance problems with 'test'. This makes - 'test' more compatible with Bash. - - * NEWS, doc/coreutils.texi: Document the following. - * src/test.c: Include exitfail.h. - (TEST_FAILURE): New constant, used for exit status if 'test' fails. - (test-syntax_error): Use it. - (binary_operator): Now takes bool arg specifying whether left operand - is -l ARG, so that caller determines this rather than us. - All uses changed. - (term): Use posixtest to evaluate parenthesized subexpressions. - (unary_operator, one_argument): Remove support for -t without operand. - (one_argument): Take argument from argv[pos]. - (one_argument, two_arguments, three_arguments): Advance pos. - All callers changed. - (three_arguments): Look for binary ops before "!". Then look - for parenthesized one_argument expressions, instead of trusting - expr () to do the right thing. - (posixtest): Now takes number of args. All callers changed. - Treat "( A B )" like "A B". - (main): Set exit_failure to TEST_FAILURE. Don't depend on - POSIXLY_CORRECT, as we now conform to POSIX by default. - (main) [!LBRACKET]: Do not recognize "--help" or "--verbose" unless. - * tests/test/Test.pm (test_vector): Add several tests to check - the above. Syntax errors now exit with status 2, not 1. - * man/Makefile.am (mapped_name): Use `../src/[' binary to create test.1. - -2003-07-26 Jim Meyering - - * tests/help-version: Adjust for above change in test behavior: - `[' exits with 2, not 1, and test doesn't accept --help or --version. - - * Makefile.maint (ME): Don't use trick suggested in Make manual. - It doesn't work for make-3.79.1. Reported by Christian Krackowizer. - - * Makefile.maint (sc_system_h_headers): Another syntax check. - (syntax-check-rules): Add it to the list. - - * src/pathchk.c (validate_path): Cast strlen value to `unsigned long' - so it matches `%ld' format even on 32-bit systems. - - * src/fmt.c (flush_paragraph): Cast field width to `int' to - avoid warning on 64-bit systems. - - * src/ls.c (sort_files): Make `func' volatile, so it can't be - clobbered by a `longjmp' into this function. - -2003-07-25 Jim Meyering - - * src/pathchk.c (validate_path): Use %ld format (not %d) for size_t - value. - - * tests/misc/split-fail: Disable the --line-bytes=$_4gb test, - because it'd evoke spurious failure on 64-bit systems. - -2003-07-24 Jim Meyering - - * src/dd.c (usage): Document the fact that SIGUSR1 makes dd - output its current record counts. Reported by Jurriaan. - - * tests/wc/Test.pm (test_vector): Disable the `PIPE' tests when running - `wc' with no options. This goes along with the change of 2003-07-20. - -2003-07-23 Jim Meyering - - Don't include headers already included by system.h: - * src/tr.c: Don't include errno.h. - * src/true.c: Don't include version-etc.h. - * src/test.c: Don't include limits.h or error.h. - * src/stat.c: Don't include unistd.h or time.h. - * src/readlink.c: Don't include stdlib.h, unistd.h, or limits.h. - * src/pr.c: Don't include time.h. - * src/pathchk.c: Don't include errno.h. - * src/nice.c: Don't include sys/time.h. - * src/ls.c: Don't include stdlib.h. - - * basename.c, cat.c, chroot.c, cksum.c, comm.c, csplit.c, cut.c, date.c: - * dd.c, dirname.c, echo.c, env.c, expand.c, expr.c, factor.c, fmt.c: - * fold.c, head.c, hostid.c, hostname.c, id.c, join.c, kill.c, logname.c: - * md5sum.c, nice.c, nl.c, nohup.c, od.c, paste.c, pathchk.c, pinky.c: - * pr.c, printenv.c, printf.c, ptx.c, pwd.c, seq.c, setuidgid.c, shred.c: - * sleep.c, sort.c, split.c, stat.c, stty.c, su.c, sum.c, tac.c, tail.c: - * tee.c, test.c, tr.c, true.c, tsort.c, tty.c, uname.c, unexpand.c: - * uniq.c, uptime.c, users.c, wc.c, who.c, whoami.c, yes.c: - Don't include closeout.h. - - * tests/rm/fail-2eperm: Add a check for whether $NON_ROOT_USERNAME - can access the required version of rm. - * tests/rm/Makefile.am (TESTS_ENVIRONMENT): Define PACKAGE_VERSION. - - * tests/cut/Test.pm (out-delim3a): New test. - - * man/help2man: Update to version 1.33. - - * src/expand.c (parse_tabstops): Detect overflow in tabstop sizes. - - * src/dircolors.c: Include xstrndup.h. - (xstrndup): Remove function, now that it's been factored out into - it's own file. - -2003-07-22 Paul Eggert - - * src/wc.c (wc): Fix typo in computation of file from file_x, - which caused the former to be used uninitialized if file_x was - nonzero. - -2003-07-22 Jim Meyering - - * src/cut.c (set_fields): Use xcalloc in place of xmalloc+memset. - - * man/Makefile.am (.x.1): Substitute 's,$t/$*,$*,' on output of - help2man, to avoid having `rm.td/rm' appear in rm.1. Reported by - Thomas Luzat. See http://bugs.debian.org/202413 for details. - - * src/cut.c (main) [lint]: Initialize spec_list_string to avoid warning. - - * src/hostid.c: Don't include . system.h already does that. - - * src/cut.c (set_fields): Mark all selected indices before trying to - determine range endpoints. - * tests/cut/Test.pm: New test for the above fix. - - Begin to address this comment: What if someone wants to - extract the 1,000,000-th field of some huge input file? - The first step is to rearrange things so that the values - in the printable_field array are all 0/1 rather than 0/1/2. - * src/cut.c (RANGE_START_SENTINEL): Remove. - Store range-start indices in a hash table, rather than - overloading the `printable_field' array. - (range_start_ht): New global. - (hash_int, hash_compare_ints, is_range_start_index): New functions. - (print_kth): Use is_range_start_index; don't test printable_field. - (set_fields): Detect overflow. - (set_fields): Insert each range-start index into range_start_ht. - (main): Call set_fields only once, and only after - output_delimiter_specified and (if required) range_start_ht have - been defined. - -2003-07-20 Paul Eggert - - * src/wc.c (get_input_fstatus): Fix typo: `stat' was being - invoked with a null pointer when there were no file arguments. - -2003-07-20 Jim Meyering - - * Makefile.maint (sc_changelog): Add another nit-picky check. - - * src/wc.c (write_counts): Add a comment. - (wc): Rename `file' parameter. - Set new local, `file', to be the file name, or (when it's NULL) - _("standard output") so that all uses of `file' use the proper value. - Use STREQ, not strcmp. - -2003-07-20 Paul Eggert - - wc count field widths now are heuristically adjusted depending - on the input size, if known. If only one count is printed, it - is guaranteed to be printed without leading spaces. - - Previously, wc did not align the count fields if - POSIXLY_CORRECT was set, but POSIX did not actually require - this undesirable behavior, so it has been removed. - - * NEWS: Document this. - * doc/coreutils.texi (wc invocation): Likewise. - - * src/wc.c (number_width): New var. - (posixly_correct): Remove. - (struct fstatus): New struct. - (write_counts): Output fields of width number_width. - Do not worry about POSIXLY_CORRECT. - Use null file, not empty-string file, to denote stdin, - since "" is a valid file name on some hosts. - (wc, wc_file): New arg fstatus. Use it to avoid invoking fstat - if possible. - (wc): Avoid problems if end_pos - current_pos overflows. - Do not print odd message if stdin has a read error. - (get_input_fstatus, compute_number_width): New functions. - (main): Use them to implement the new behavior. - Ignore POSIXLY_CORRECT. - - * tests/wc/Test.pm: Adjust to the new output widths. - -2003-07-19 Jim Meyering - - * tests/rm/fail-eperm: Don't create temporary directory -- - we don't use it. - - * tests/shred/remove: Don't open-code test for UID != 0. - Use priv-check's require-non-root instead. - Update to use newer framework. - - * tests/help-version (expected_failure_status_expr): Record that - expr exits with status of 3 for e.g., a write error. - - * tests/priv-check: Use `id -u' to see if we're running as root, - rather than trying go write to an write-protected file. - When running as root, ensure $NON_ROOT_USERNAME is valid. - When running as root with `require-non-root', ensure that `.' - is writable by $NON_ROOT_USERNAME, then reinvoke $0 set-user-ID - to $NON_ROOT_USERNAME. If `.' is not writable, then skip the test. - - * src/printenv.c: Include "exitfail.h". - (main): Set exit_failure rather than calling close_stdout_set_status. - * src/date.c: Likewise. - * src/sort.c: Likewise. - * src/tty.c: Likewise. - -2003-07-18 Jim Meyering - - * tests/touch/not-owner: Update to use newer framework. - - * tests/rm/fail-eperm: Use $srcdir/../priv-check, create a temporary - directory, and remove Perl-coded `you may not run as root' test. - * tests/cp/fail-perm: Use $srcdir/../priv-check, rather than - hard-coding something not quite equivalent. - Paul Jarc reported the inconsistent diagnostics. - - * src/sort.c (main): Use close_stdout via atexit. - Now `sort --version' and `sort --help' fail, as they should - when their output is redirected to /dev/full. - - * src/su.c (usage): Don't call close_stdout here. - (main): Use close_stdout via atexit. - Now `su --version > /dev/full' fails, as it should. - Somehow, the change of 2000-05-07 that purports to fix this - was not checked in. - - * tests/help-version (--help/--version vs. /dev/full): Special-case - `[' to protect it from expected_failure_status-`eval'. - - * src/uniq.c (writeline): Use a SPACE, not a TAB between the - count and the corresponding line, as required by POSIX. - Reported by Clement Wang. - * tests/uniq/Test.pm (101, 102): Update tests of -c accordingly. - - * tests/expr/basic: Add tests for when exit status is 2. - - * src/nohup.c (NOHUP_FOUND_BUT_CANNOT_INVOKE, NOHUP_FAILURE): - Use an anonymous `enum', rather than #define. - -2003-07-17 Paul Eggert - - * src/expr.c: Include "exitfail.h", "quotearg.h". - (EXPR_INVALID, EXPR_ERROR): New constants. - (nomoreargs, null, toarith, nextarg): Return bool, not int. - (syntax_error): New function, exiting with status 2. Use it - insteading of printing "syntax error" ourselves. - (main): Initialize exit_failure to EXPR_ERROR. - Exit with EXPR_INVALID on syntax error (too few arguments). - (nextarg): Use strcmp, not strcoll; strcoll might return - an undesirable 0, or might fail. - (docolon, eval4, eval3): Exit with status 3 on invalid argument type - or other such error. - (eval2): Report an error if strcoll fails in a string comparison. - * src/sort.c: Include "exitfail.h". - (main): Set exit_failure, not xalloc_exit_failure and - xmemcoll_exit_failure. - * tests/expr/basic: Invalid value exits with status 3, not 2. - -2003-07-16 Jim Meyering - - * configure.ac (AC_INIT): Use 5.0.90 as the version, rather than 5.0.2, - per GNU maintainer guidelines. The next non-beta release will be 5.1. - - This script would have caught at least two recent bugs: - those in [ and kill. - * tests/help-version: Revive this script. - It wasn't doing anything useful, since $all_programs wasn't being - defined by the invoking Makefile.am. - Reflect that nohup is no longer a script, so don't exclude it. - Add framework to handle the programs added since it was last run: - kill, stat, unlink, [, link, readlink. - Fix path-related problems deriving from the move of this script - from src/ to its present location. - * tests/Makefile.am (all_programs): Define. - (TESTS_ENVIRONMENT): Use it. - - * src/kill.c (main): Fix bug introduced on 2003-05-10 (for 5.0.1) - whereby kill would always attempt to operate on argv[0] and fail. - - * src/test.c (integer_expected_error): Improve diagnostic -- now, - it also matches the one from bash's builtin test. - (binary_operator): Add \n at end of diagnostic. - - * tests/rm/fail-2eperm: Remove setuidgid-related code. Move it to ... - * tests/priv-check: Move setuidgid-related and - NON_ROOT_USERNAME-checking code to this file. - - * README: Update section on testing as `root'. - Suggestion from Paul Jarc. - - * src/test.c (AUTHORS): Replace 3-letter usernames with the actual - names of authors that I just found in bash's builtins/test.def. - - Running `[' with no arguments would evoke a segfault. - * src/test.c (main) [LBRACKET]: Move initialization of argv to - precede potential use via test_syntax_error. - - * src/Makefile.am (AM_CPPFLAGS): Rename from `INCLUDES', to avoid - warning from automake -Wall. - -2003-07-15 Jim Meyering - - * Version 5.0.1. - - * Makefile.maint (%.asc): Remove target first, so gpg doesn't - prompt us about it. - - * announce-gen (print_changelog_deltas): Relax tests for matching - version-number line in NEWS. - Change the .sig suffix to .asc here, too. - -2003-07-14 Jim Meyering - - * Makefile.maint (%.asc): Renamed from %.sig. - Generate and use ascii-armored signatures. - Use gpg's -o option. - -2003-07-13 Jim Meyering - - * src/nohup.c (NOHUP_FAILURE, NOHUP_FOUND_BUT_CANNOT_INVOKE): Define. - (main): Use them. - - * Makefile.maint (syntax-check): Move each individual check into - its own target. - (syntax-check-rules): This is the list of syntax-check targets. - (sc_unmarked_diagnostics, sc_cast_of_argument_to_free): - (sc_cast_of_x_alloc_return_value, sc_space_tab): - (sc_error_exit_success, sc_xalloc_h_in_src): New targets. - -2003-07-12 Jim Meyering - - * configure.ac: Remove uses of OPTIONAL_BIN_ZCRIPTS and last - traces of the nohup script. - - * src/Makefile.am (bin_SCRIPTS): Remove use of just-removed - $(OPTIONAL_BIN_ZCRIPTS). - - * src/Makefile.am (localedir.h): Put the `2>&1' after the redirect - target, not before the `>'. - - * src/remove.c (remove_dir): Give a diagnostic upon failed save_cwd, - now that that function no longer calls `error'. - - * src/df.c (find_mount_point): Emit a diagnostic for each - failed syscall, rather than relying on caller to do that. - The caller couldn't do a good job, anyhow -- too many different - ways to fail (each with a different referent). - Give a diagnostic upon failed save_cwd, now that that function - no longer calls `error'. - (show_point): Don't diagnose find_mount_point's errors, now that - it handles them itself. - - * src/df.c (find_mount_point): Don't let free clobber errno upon - failed chdir. - - * src/sys2.h: Remove alloca-related block. - * src/system.h: Include here, instead. - - It appears that the `#pragma alloca' included via "system.h" is - adequate, since join.c uses alloca, yet lacked an in-file #pragma. - * src/copy.c, src/cp.c, src/df.c, src/install.c, src/ln.c: - * src/ls.c, src/mv.c, src/remove.c: Remove `#pragma alloca'. - - * src/chown-core.c (change_file_owner): Do not restore any special - permission bits (e.g., set-user-ID, set-group-ID) that are reset - by chown(2) on some systems. Suggestion and insistence :-) from - Michael Stone. - - * tests/input-tty: Also check `test -t 1'. - This is necessary on linux-2.4.21. Otherwise, the stty/basic-1 - test would block when run in the background. - -2003-07-11 Jim Meyering - - * tests/sample-test: Also fail if cat-to-create-expected-output - fails. Otherwise, if both `exp' and `out' were to end up empty - because of e.g., a full disk, they would mistakenly compare equal. - - * src/nohup.c: New file. Rewrite of nohup.sh in C. - This solves a portability problem: on at least Solaris systems, - when nohup.sh used the vendor /bin/sh, it would exit with status - of `1' rather than the required 126 or 127 upon failure to exec - the specified program. - - * src/Makefile.am (EXTRA_SCRIPTS): Remove definition. - (bin_PROGRAMS): Add nohup. - (EXTRA_DIST): Remove nohup.sh. - (all_programs): Remove use of $(EXTRA_SCRIPTS). - * src/nohup.sh: Remove file. - * man/Makefile.am (nohup.1): Depend on nohup.c, rather than nohup.sh. - - * tests/misc/nohup: Tests for the above. - * tests/misc/Makefile.am (TESTS): Add nohup. - - * src/head.c (diagnose_copy_fd_failure): New function, renamed from - the macro, COPY_FD_DIAGNOSE. - (diagnose_copy_fd_failure): Enclose diagnostic in _(...). - (head_file): Likewise. - - * src/date.c: Include "quote.h". - (batch_convert): Use the quote function rather than using literal `...' - in a diagnostic. - - * src/setuidgid.c (main): Enclose diagnostic in _(...). - * src/fmt.c (main): Likewise. - * src/mknod.c (main): Likewise. - * src/tac.c (tac_seekable): Likewise. - * src/yes.c (main): Likewise. - * src/od.c (main): Likewise. - * src/install.c (change_attributes): Likewise. - -2003-07-10 Jim Meyering - - * src/head.c (usage): Use 1024*1024 in place of 1048576. - * src/tail.c (usage): Likewise. - - * tests/rm/fail-2eperm: Now that we have setuidgid, use it in - place of the kludge in this test. Suggestion from Paul Jarc. - - * src/Makefile.am (noinst_PROGRAMS): Define to setuidgid. - * src/setuidgid.c: New program, solely for testing (not installed). - - * src/chown-core.c (change_file_owner): Don't leak file descriptors - when dereferencing symlinks. - -2003-07-09 Jim Meyering - - * tests/du/slash: New file/test for today's lib/ftw.c fix. - * tests/du/Makefile.am (TESTS): Add slash - - * src/tail.c (xlseek): Avoid warning about ``return without value - from function returning non-void''. - -2003-07-08 Jim Meyering - - * man/help2man: Update to version 1.29. - - * man/help2man: Add END handler to close STDOUT and check for errors. - -2003-06-30 Paul Eggert - - Add support for a "[" that conforms to the GNU coding standards, - i.e., that does not depend on its name. - * src/lbracket.c: New file. - * README: Add "[". - * man/Makefile.am (programs): Ignore "[", since it doesn't have - a separate man page. - * src/Makefile.am (bin_PROGRAMS): Add "[". - (__SOURCES): New var. - * src/test.c (LBRACKET): Define to 0 if not defined. - (main): Use LBRACKET rather than argv[0]. - - * src/test.c (one_argument): Do not check for -t if POSIXLY_CORRECT. - Reported by Paul Jarc and Dan Jacobson. - - * src/test.c (main): Do not recognize --help or --version if - POSIXLY_CORRECT, when invoked as "test". Handle "[ ]" correctly. - Do not bother testing that margv[margc] is non-null. - -2003-07-04 Jim Meyering - - * src/who.c (print_line): Rewrite to use asprintf, in order to be - able to avoid emitting trailing spaces. Reported by Dan Jacobson. - - * tests/misc/head-elide-tail: Add tests of head's new --lines=-N - option, and perform the +1600 invocations of head IFF the envvar - RUN_EXPENSIVE_TESTS is set. - -2003-07-03 Jim Meyering - - * src/cp.c (do_copy): Give a better diagnostic when failing due - to nonexistent destination directory. Reported by Dmitry Rutsky. - See http://bugs.debian.org/199730 for details. - -2003-06-27 Jim Meyering - - split's --verbose option did nothing [broken in 4.5.10 and 5.0] - * src/split.c (longopts): Use `1', not `0' as the value for - for &verbose. Reported by Keith Thompson. - - Test for the above fix. - * tests/misc/split-a: Also use --verbose and compare stderr - output with what we'd expect. - -2003-06-20 Jim Meyering - - * src/copy.c (copy_internal) [HAVE_STRUCT_STAT_ST_AUTHOR]: - Use `error_t' (rather than int) as type for local `err'. - From Alfred M. Szmidt. - -2003-06-19 Marcus Brinkmann - - * src/copy.c (copy_internal) [HAVE_STRUCT_STAT_ST_AUTHOR]: - Fix author preservation code. - -2003-06-19 Jim Meyering - - * src/ln.c (ENABLE_HARD_LINK_TO_SYMLINK_WARNING): Define to 0. - (do_link): Don't warn about hard link to symlink. - -2003-06-18 Jim Meyering - - * src/cut.c: Include "getdelim2.h", not "getstr.h". - Reflect renaming: getstr -> getdelim2. - - * src/comm.c, src/join.c, src/nl.c, src/uniq.c: Reflect renaming: - readline -> readlinebuffer. - -2003-06-09 John David Anglin - - * src/readlink.c: Include before system.h (because - the latter includes ). Required on Ultrix 4.3. - -2003-06-17 Jim Meyering - - * src/system.h (initialize_main): Define. - Use it in every `main'. Applied via this: - p='initialize_main (&argc, &argv);' - perl -ni -e '/program_name.=.argv.0/ and print " '"$p"'\n"; print' \ - $(grep -l program_name.=.argv.0 *.c) - test.c uses margc/margv, so I made the change manually for that file. - Based on a patch from Bernard Giroud. - -2003-06-09 John David Anglin - - Fix for build failure on Ultrix 4.3. - * src/stat.c: Include sys/statvfs.h in preference to sys/vfs.h. - Include sys/param.h and sys/mount.h on ultrix. - -2003-06-16 Jim Meyering - - * src/touch.c (O_NDELAY, O_NONBLOCK, O_NOCTTY, EISDIR): Remove - definitions. - * src/system.h (O_NDELAY, O_NONBLOCK, O_NOCTTY, EISDIR): Define - them here instead, but with one change: define EISDIR to -1, not 0. - - * src/cat.c (cat): Remove `#ifndef ENOSYS', now that it's - guaranteed to be defined. - * src/system.h (ENOSYS, ENOTSUP): Define to -1 if not defined. - - * README: Mention the CVS repository. - Encourage addition of test cases. - -2003-06-12 Jim Meyering - - * src/touch.c (touch): Call close only if necessary. - From Bruno Haible. - - * src/wc.c (usage): Correct wording: wc prints counts in the order - `newline, word, byte'. Reported by Keith M. Briggs. - * man/wc.x: Fix it here, too. And change `lines' to `newlines'. - -2003-06-10 Jim Meyering - - * tests/date/Test.pm: Add a test for the new format, e.g., May-23-2003. - -2003-06-07 Jim Meyering - - * Makefile.maint (syntax-check): Add commented-out (over-aggressive) - rule. - -2003-06-06 Jim Meyering - - * src/extract-magic (main): Avoid newer 3-arg form of open, - so this script works also with e.g., perl5.005_03. - Patch by John David Anglin. - -2003-06-04 Paul Eggert - - * src/system.h: Include unconditionally. - -2003-06-04 Jim Meyering - - * man/Makefile.am (check-programs-vs-x): Rename target - from check-programs-vs-1. Adjust rule to check for the - primary (.x) file, not the generated one (.1). - -2003-06-03 Tim Mooney - - * man/kill.x: New file. - * man/Makefile.am (dist_man_MANS): Add kill.1. - (kill.1): New rule. - -2003-06-04 Jim Meyering - - Ensure that the .x file for a new program is never forgotten again. - * man/Makefile.am (programs): Define. - (check-programs-vs-1): New phony target. - (check-local): Depend on it. - -2003-06-03 Jim Meyering - - Avoid unnecessary copying of environment. - * src/env.c (main): Rather than clearing the environment and -- - unless told to ignore environment -- copying all settings from - the saved, original environment, clear the environment only when - that is requested. Suggested by Jens Elkner. - -2003-06-02 Jim Meyering - - * src/system.h: Always include , since we assume C89. - Include without checking for HAVE_LIMITS_H. - - * src/test.c [!TEST_STANDALONE]: Remove #if-0'd block. - (STREQ, S_IXUGO): Remove redundant (in system.h) definitions. - -2003-06-01 Jim Meyering - - Avoid a race condition in `tail -f' described by Ken Raeburn in - http://mail.gnu.org/archive/html/bug-textutils/2003-05/msg00007.html - * src/tail.c (file_lines): Add new parameter, *read_pos, and set it. - (pipe_lines, pipe_bytes, start_bytes, start_lines): Likewise. - (tail_bytes, tail_lines, tail): Likewise. - (tail_file): Use the new `read_pos' value as the size, - rather than stats.st_size from the fstat call. - -2003-05-28 Jim Meyering - - * src/extract-magic: Allow expansion of `$file' in the here- - document corresponding to the comment at the top of fs.h. - -2003-05-26 Jim Meyering - - * src/stat.c: Fix portability problem on FreeBSD5.0: don't include - on systems without HAVE_STRUCT_STATVFS_F_BASETYPE. - Use #if/#elif/... cascade so we get only one set of include files. - Reported by Nelson Beebe. - -2003-05-24 Jim Meyering - - * src/md5sum.c (split_3): Accept the BSD format only when in MD5 mode. - * tests/sha1sum/basic-1: Make sure `sha1sum --check' doesn't - accept the BSD format. - -2003-03-28 Joe Orton - - * src/md5sum.c (bsd_split_3): New function. - (split_3): Detect checksums from BSD 'md5' command and handle them - using bsd_split_3. - - * tests/md5sum/basic-1: New tests for --check exit status, and for - BSD-style checksum files. - -2003-05-21 Jim Meyering - - * src/head.c (elide_tail_lines_pipe): Fix a thinko. - This sort of thing is why it'd be *Really Good* to factor - out the common code used here and in tail.c. - -2003-05-14 Jim Meyering - - * src/head.c (usage): Document new feature: --bytes=-N and --lines=-N. - - * tests/du/slink: Skip this test if `.' is on an XFS file system. - - * tests/du/fd-leak: New file. Test for the bug in du that - was fixed by the 2003-05-12 change to lib/ftw.c. - * tests/du/Makefile.am (TESTS): Add fd-leak. - - * src/head.c (AUTHORS): Enclose string in N_(...), now that it - includes a translatable word, `and'. - - * src/dd.c (usage): Don't use `,' as the thousands separator - in e.g. 1,000,000 and 1,048,576. Instead, do this: - `SIZE may be ..., MB 1000*1000, M 1024*1024 and so on...' - * src/df.c (usage): Likewise. - * src/du.c (usage): Likewise. - * src/ls.c (usage): Likewise. - - * Makefile.maint (syntax-check): Add another check. - -2003-05-13 Paul Eggert - - Fix uniq to conform to POSIX, which requires that "uniq -d -u" - must output nothing. Problem reported by Josh Hyman. - - * src/uniq.c (enum output_mode, mode): Remove, replacing with: - (output_unique, output_first_repeated, output_later_repeated): - New vars. All uses of "mode" changed to use these variables, - which are not mutually exclusive as "mode" was. - (writeline): New arg "match", used to control whether to - obey output_first_repeated or output_later_repeated. - All callers changed. - (check_file, main): Adjust to above changes. - - * tests/uniq/Test.pm: Test that 'uniq -d -u' outputs nothing. - -2003-05-14 Jim Meyering - - * tests/rm/rm3: Use tr's \n notation rather than \012. - This package can afford to do that, since its tests are guaranteed use - GNU tr, which has accepted the more modern notation for 10 years. - * tests/rm/rm5: Likewise. - * tests/cp/same-file: Likewise. - * tests/stty/row-col-1: Likewise. - * tests/stty/basic-1: Likewise. - * tests/rm/deep-1: Likewise. - * tests/mv/part-symlink: Likewise. - * tests/mkdir/perm: Likewise. - * tests/misc/nice: Likewise. - -2003-05-13 Jim Meyering - - * src/copy.c (struct F_triple) [name]: Remove const attribute. - (triple_free): Don't apply cast to argument of free. - (seen_file): Add cast here instead. - - * src/cp-hash.c (struct Src_to_dest) [name]: Remove const attribute. - (src_to_dest_free): Don't apply cast to argument of free. - - * src/sort.c (zaptemp): Don't apply cast to argument of free. - * src/pr.c (init_fps, init_store_cols): Likewise. - * src/join.c (delseq, freeline): Likewise. - * src/expr.c (OLD): Likewise. - * src/sort.c (sort): Likewise. - * src/head.c (elide_tail_lines_pipe): Likewise. - - * src/tail.c: Include "quote.h". - Use quote in diagnostics. Change many error format strings - from just `%s' to e.g., `error reading %s'. - (pipe_lines): Change type of parameter, n_lines, to uintmax_t. - Rewrite newline-counting loop to use memchr. - - * src/head.c (elide_tail_lines_pipe): Use `if', not assert. - Now that assert is no longer used, don't include . - -2003-05-12 Jim Meyering - - * src/head.c: Include . - (AUTHORS): Add my name. - (elide_tail_lines_pipe): New function. - -2003-05-10 Jim Meyering - - * Makefile.maint (syntax-check): Check for `error (EXIT_SUCCESS,'. - - * src/readlink.c (main): Set program_name before first use. - Remove that (redundant) first use. - Don't exit successfully just because --verbose was specified. - Pass 0, not EXIT_SUCCESS, as first argument to error; when that - parameter is 0, error does not exit. - - * src/uname.c (main): When failing due to too many arguments, also say - that, rather than just "Try `uname --help' for more information.". - * src/comm.c (main): Likewise, but for too few arguments. - * src/logname.c: Include error.h. - (main): Say why we're failing. - - * src/uniq.c (main): Don't segfault when argc < optind. - * src/who.c (main): Handle argc < optind. - * src/df.c (main): Likewise. - * src/install.c (main): Likewise. - * src/mv.c (main): Likewise. - * src/pwd.c (main): Likewise. - * src/tty.c (main): Likewise. - * src/chroot.c (main): Likewise. - * src/hostname.c: Likewise. - * src/du.c (main): Likewise. - * src/expand.c (main): Likewise. - * src/env.c (main): Likewise. - * src/unexpand.c (main): Likewise. - * src/printenv.c (main): Likewise. - * src/sync.c (main): Handle argc == 0. - * src/expr.c (main): Likewise. - * src/printf.c (main): Likewise. - * src/basename.c (main): Likewise. - * src/ln.c (main): Test for `missing argument' before computing n_files. - * src/tail.c (main): Test for the case of no arguments before - computing n_files. - - * src/kill.c (send_signals): Don't check command line arguments here. - (main): Check them here instead. Handle argc < optind. - - * src/logname.c (main): Use error, rather than fprintf, for the sake - of consistency. - - * src/rm.c (main): Don't overrun array bound if argc is 0. - -2003-05-09 Jim Meyering - - * src/sort.c (main): Don't overrun array bound if argc is 0. - That would happen when invoked via: execl ("/usr/bin/sort", NULL); - Reported by Wartan Hachaturow. - -2003-05-07 Jim Meyering - - Implement support so that `head --lines=-N' works on seekable files. - * src/head.c (enum Copy_fd_status): Define. - (COPY_FD_DIAGNOSE): New macro. - (elide_tail_lines_seekable): New funtion. - (elide_tail_lines_file): Call it here. - -2003-05-06 Jim Meyering - - * src/sys2.h (CHAR_BIT): Remove duplicate definition. - -2003-05-04 Jim Meyering - - * tests/head/Test.pm: Remove tests of --bytes=-N; using that framework - caused the addition of thousands of small files to the tar archive. - * tests/misc/head-elide-tail: New file. Add them here instead. - * tests/misc/Makefile.am (TESTS): Add head-elide-tail. - -2003-05-04 Paul Eggert - - * src/remove.c (HAVE_WORKING_READDIR): Define to 0 if not defined. - (IF_READDIR_NEEDS_REWINDDIR): Remove. - (remove_cwd_entries): Rewrite to avoid IF_READDIR_NEEDS_REWINDDIR, - which was a bit weird because it couldn't be emulated by a function. - -2003-05-03 Jim Meyering - - Extend head to accept --lines=-N (--bytes=-N) and to print all - but the N lines (bytes) at the end of the file. - * src/head.c: Include full-write.h, full-read.h, inttostr.h, quote.h. - Use quote() in diagnostics, rather than literal `' marks. - (copy_fd, elide_tail_bytes_pipe, elide_tail_bytes_file): - New functions. - (elide_tail_lines_pipe, elide_tail_lines_file): New functions. - (head_file): Reorganize so as to call head from only one place. - (main): Likewise, for head_file. - Handle new, undocumented option, --presume-input-pipe. - Handle negative line and byte counts. - * tests/head/Test.pm: Add lots of tests to exercise --bytes=-N. - - * tests/du/8gb: Skip test if the file system of `.' doesn't support - sparse files -- otherwise it'd create a file of size 8GB. - -2003-05-02 Jim Meyering - - * src/fmt.c (usage): Don't mention obsolescent -WIDTH option. - Instead explain about `-' and standard input. - (main): Give a proper diagnostic for e.g., `fmt -c -72'. - Reported by Keith Thompson. - * tests/fmt/basic: Add test for the above fix. - - * src/fmt.c: Include "quote.h". - Use quote() in diagnostics, rather than literal `' marks. - (main): Exit nonzero when unable to open an input file. - * tests/fmt/basic: Add test for the above fix. - - * src/fmt.c (main): Diagnose invalid suffix on obsolescent width - specifications like `-72x'. - * tests/fmt/basic: Add test for the above fix. - - Work around nasty readdir bug on Darwin6.5. - * src/remove.c (IF_READDIR_NEEDS_REWINDDIR): Define. - [! HAVE_WORKING_READDIR] (remove_cwd_entries): If readdir has just - returned NULL and there has been at least one successful unlink or - rmdir call since the opendir or previous rewinddir, then call - rewinddir and reiterate the loop. - - Factor out common code. - * src/remove.c (readdir_ignoring_dotdirs): New function. - (is_empty_dir): Use it here. - (remove_cwd_entries): Use it here. - -2003-05-01 Jim Meyering - - * tests/rm/r-3: Create 500 rather than just 300 files. - There's a bug in Darwin6.5's readdir that shows up only with - 338 or more files. - Fix a bug in this test: `cd $pwd' (not to `..'), now that $tmp - has two components. - - * src/tail.c: - Change type of n_units, n_bytes, n_lines to be `uintmax_t'. - (dump_remainder): Move two declarations `down' into the scope - where they are used. - (xlseek): Return the resulting offset. - (file_lines): Rename parameter, file_length, to end_pos. - (pipe_lines): Don't coerce safe_read return value to `int'. - Adapt tests accordingly. - (pipe_bytes) [struct charbuffer] (nbytes): Change type from `int' - to `unsigned int'. - Change type of `total_bytes' from `int' to `size_t', - since the former wouldn't always be wide enough. - Don't coerce safe_read return value to `int', - and adapt tests accordingly. - Now that testing for a read error no longer involves - using `tmp', handle that case *after* freeing `tmp'. - (start_bytes): Clean up. - (tail_bytes): Now that `n_bytes' may be larger than - OFF_T_MAX, test for that condition and, if it's true, don't - use lseek optimizations. - (parse_options): Don't fail just because N_UNITS is larger than - the maximum size of a file -- tail may be applied to an input - stream (e.g., a pipe) with more data than that. - - * Makefile.maint (syntax-check): Rename from alloc-check. - Also check for SPACE-TAB sequences. - Also check for malloc/calloc/realloc casts. - -2003-05-01 Jim Meyering - - * src/tail.c (start_lines): Rewrite to use memchr. Clean up. - -2003-04-28 Jim Meyering - - * tests/misc/tty-eof: Send two tokens, not just one, so we don't - make the now-more-picky tsort fail. - -2003-04-24 Jim Meyering - - * src/tsort.c (tsort): Remove unnecessary test of have_read_stdin. - (main): Minor syntactic clean-up. - - * src/tsort.c (tsort): Fail if the input contains an odd number of - tokens. Reported by junkio@cox.net. - - * tests/tsort/basic-1: Test for the above fix. - -2003-04-21 Jim Meyering - - * tests/misc/printf: Add tests for the printf fixes below. - - * Makefile.cfg (cvs_files): Add $(srcdir)/config/depcomp to the list. - -2003-04-20 Paul Eggert - - Fix printf POSIX compatibility bug reported by Ben Harris in - . - * doc/coreutils.texi (printf invocation): It's \NNN in the format, - \0NNN in the %b operand. - * src/printf.c (usage): Likewise. - (print_esc): New arg OCTAL0 to specify whether \0NNN or \NNN - is desired. All uses changed. Behave like Bash printf if %b - operand uses \NNN where the initial N is not 0. - -2003-04-17 Jim Meyering - - * src/stty.c: Remove uses of PROTOTYPE macro. - -2003-04-15 Jim Meyering - - * Makefile.maint: Remove (or replace-with-TAB(s) to retain alignment) - each sequence of spaces before a TAB character. - -2003-04-13 Jim Meyering - - * src/remove.c (is_empty_dir): Don't closedir (NULL). - -2003-04-12 Jim Meyering - - Giving nl an invalid STYLE argument (in --header-numbering=STYLE (-h), - --body-numbering=STYLE (-b), or --footer-numbering=STYLE (-f)) or - FORMAT (--number-format=FORMAT (-n)) would not give a useful diagnostic. - * src/nl.c (main): Fix those problems and remove literal quote marks - (e.g., "`%s'") from format string; instead use "%s" in each format - string and `quote (optarg)' as the corresponding argument. - Also, diagnose all invalid command line options before failing. - - * src/nl.c (proc_text): Fix a bug that would make nl output extra - newlines in some cases. Details here: http://bugs.debian.org/177256. - This bug was introduced on 2001-11-10 for textutils-2.0.17. - * tests/misc/nl: Add test for the above-fixed bug. - - * tests/misc/readlink: New file. Test the --canonicalize option. - * tests/misc/Makefile.am (TESTS): Add readlink. - -2003-04-11 Jim Meyering - - Clean up. - * src/chown.c, src/cp.c, src/dircolors.hin, src/du.c, src/ln.c: - * src/mkfifo.c, src/ptx.c, src/spline.c, src/stty.c, src/tail.c: - * src/test.c, src/unexpand.c: Remove (or replace-with-TAB(s) to - retain alignment) each sequence of spaces before a TAB character. - - * src/ls.c: Include unconditionally. - - * Makefile.maint (xalloc-check): Rename from header-check. - - * src/yes.c: Include error.h after system.h, not before. - - Clean up. - * src/copy.c, src/cp-hash.c, src/cp.c, src/csplit.c, src/cut.c: - * src/date.c, src/df.c, src/du.c, src/expand.c, src/expr.c, src/id.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/su.c, src/tail.c, src/tee.c: - * src/tr.c: * src/unexpand.c, src/users.c: - Remove anachronistic casts of xmalloc, xrealloc, and xcalloc - return values and of xrealloc's first argument. - Fix the former with this: - perl -pi -e 's/\([^(]*?\*\) *(x(m|c|re)alloc)\b/$1/' - -2003-04-10 Jim Meyering - - * src/stty.c (wrapf): Declare with format attribute. - - The S_MAGIC_... names shouldn't be maintained in two places (prior - to this change, one would have to keep stat.c and fs.h in sync). - This change makes it so those names and the corresponding - hexadecimal constants all reside in stat.c. fs.h is now generated. - * src/Makefile.am (fs.h): New rule to generate fs.h from stat.c. - (BUILT_SOURCES): Add fs.h, now that it's generated. - (EXTRA_DIST): Add extract-magic. - * src/extract-magic: New script to extract fs.h definitions from stat.c. - * src/stat.c (human_fstype) [__linux__]: Append each hex constant from - fs.h in a comment after the corresponding `case S_MAGIC_...:' statement. - - * tests/tail-2/big-4gb: Skip this test (don't fail) if creating a - file with nominal length > 4GB fails. Reported by Michael Deutschmann. - - * man/unexpand.x: Add `SEE ALSO' reference to expand. - * man/expand.x: Add `SEE ALSO' reference to unexpand. - Suggestion from Dan Jacobson. - -2003-04-10 Maciej W. Rozycki - - * src/fs.h (S_MAGIC_DEVPTS): New magic for Linux's devpts. - * src/stat.c (human_fstype): Handle Linux's devpts. - -2003-04-09 Paul Eggert - - * src/split.c (line_bytes_split): Arg is of type size_t, since - that's all that is supported for now. - (main): Check for overflow in obsolescent line count option. - -2003-04-09 Jim Meyering - - * tests/misc/split-fail: Add a new test for the above fix. - - * src/split.c (bytes_split): Use size_t temporary (rather than - uintmax_t original) in remaining computations. From Paul Eggert. - - Handle command line option arguments larger than 2^31. - This allows e.g., splitting into files of size 2GB and larger, - and running split --lines=N with N=2^31 or more. - But for --line-bytes=N, the restriction that N <= SIZE_MAX - remains (for now), due to the way it is implemented. - - * src/split.c: Include "inttostr.h". - (bytes_split, lines_split, line_bytes_split, main): - Use uintmax_t, not size_t, for file sizes. - (main): Give a better diagnostic for option arguments == 0. - Use umaxtostr to print file sizes. - Reported by Luke Hassell. - -2003-04-08 Jim Meyering - - * src/rm.c (usage): Mention that --directory (-d) works only - on some systems. Suggestion from Samuel Tardieu. - - * tests/basename/basic: Run $PERL to see if it is available, - rather than testing its value. - * tests/sum/sysv, tests/tsort/basic-1, tests/unexpand/basic-1: - * tests/basename/basic, tests/dd/skip-seek, tests/dircolors/simple: - * tests/expr/basic, tests/factor/basic, tests/fmt/basic: - * tests/ls-2/tests, tests/md5sum/basic-1, tests/md5sum/newline-1: - * tests/misc/sort, tests/misc/tty-eof, tests/mv/i-1: - * tests/rm/empty-name, tests/rm/fail-eperm, tests/rm/unreadable: - * tests/seq/basic, tests/sha1sum/basic-1, tests/sha1sum/sample-vec: - * tests/sum/basic-1, tests/seq/basic: Likewise. - - * tests/misc/Makefile.am (TESTS): Add split-fail. - * tests/misc/split-fail: New file. - - * src/split.c: Rename local variables: nchars -> n_bytes. - (lines_split): Rename local, nlines -> n_lines. - (main): Rename local variable: s/accum/n_units/. - (main): Use STDIN_FILENO, not literal `0'. - -2003-04-07 Jim Meyering - - * src/stat.c: Add #include directives for Ultrix 4.4. - Based on a suggested change from Bert Deknuydt. - -2003-04-06 Jim Meyering - - * Makefile.maint (makefile-check): New rule. - (local-check): Add it. - -2003-04-05 Jim Meyering - - * Makefile.am (nearly all of them): - Use $(VAR) rather than @VAR@, now that we can rely on automake to - emit a definition for each substituted variable. - * tests/Makefile.am.in: Likewise. - - * tests/rm/rm5: Add a comment explaining why this test fails when - using Tru64's broken sed. - * tests/rm/rm3: Likewise. - - Make `kill -t' output signal descriptions (not `?') on Tru64. - * src/kill.c (sys_siglist): Also check for __sys_siglist. - Patch by Tony Leneis. - * configure.ac: Also check for declaration of __sys_siglist. - Required for Tru64 4.0D, 4.0F, and 5.1. - Reported by Tony Leneis. - -2003-04-04 Jim Meyering - - * src/Makefile.am (PERL): Remove unnecessary definition. - - Because of inappropriate (but POSIX-mandated) behavior of rename, - `mv a b' would not remove `a' in some unusual cases. Work around - this by unlinking `a' when necessary. - - * src/copy.c (same_file_ok): Add an output parameter. - Set it in the offending case. - (copy_internal): When necessary, unlink SRC_PATH and inform caller. - Reported by Ed Avis. - * tests/mv/hard-4: New test for the above. - * tests/mv/Makefile.am (TESTS): Add hard-4. - - Clean up rules for automatically generated sources: - * src/Makefile.am (dircolors.h, wheel-size.h, wheel.h, false.c): - Make each generated file be read-only. - Add each file name to BUILT_SOURCES separately. - (MAINTAINERCLEANFILES): Set to $(BUILT_SOURCES). - - Put LOCALEDIR macro definition in new file: localedir.h. - * src/Makefile.am (DEFS): Remove definition. - (localedir.h): New rule. - (BUILT_SOURCES, DISTCLEANFILES): Add localedir.h. - * src/system.h: Include "localedir.h". - -2003-04-02 Jim Meyering - - * Version 5.0. - - * tests/misc/Makefile.am (TESTS): Add false. - - * Makefile.maint (TMPDIR): Make sure it's defined. - (my-distcheck): Build in $(TMPDIR), not `.'. - - * src/Makefile.am (false.c): Change all occurrences of - `(EXIT_SUCCESS)' to `(EXIT_FAILURE)' so that false exits - unsuccessfully also with --help. Reported by Paul Jarc, - * tests/misc/false: New test for the above. - -2003-03-30 Jim Meyering - - * NEWS: Note the location of older NEWS files. - - * src/remove.c (is_empty_dir): Don't let a failing closedir - clobber errno. Spotted by Arnold Robbins. - - * src/env.c: Fix typo in comment. From Arnold Robbins. - -2003-03-29 Jim Meyering - - * Version 4.5.12. - - * README: Note to expect build problems for stat.c on Ultrix 4.3. - Note that there are some harmless test failures when running - `make check' as root on some systems. - -2003-03-28 Jim Meyering - - * tests/stty/row-col-1: Skip this test if stty can't get window size. - This happens when connecting to sparc-solaris5.7 via ssh from within - emacs. Reported by Karl Berry. - - * tests/du/basic: Use seq, not `yes' to generate 4KB of data. - Otherwise, on systems (DJGPP) that emulate pipes using files, - this test would never complete, waiting for `yes' to terminate. - * tests/du/slink: As above, use seq, not `yes' to generate link target. - * tests/rm/hash: As above, use seq, not `yes' to generate dir name. - Reported by Rich Dawe. - -2003-03-27 Jim Meyering - - * src/id.c: Remove Arnold Robbins' obsolete e-mail address - from `written by...' comment, at his request. - -2003-03-24 Paul Eggert - - Fix buffer overrun problem reported by TAKAI Kousuke, along - with some other POSIX incompatibilities. - - * src/printf.c (print_esc): Do not treat \x specially if - POSIXLY_CORRECT. Avoid buffer overrun if the format ends - in backslash. Treat incomplete escape sequences as strings - of characters, as POSIX requires. - (print_formatted): Allow multiple flags. Avoid buffer overrun - if the format is incomplete. - -2003-03-24 Jim Meyering - - * tests/misc/printf: Add tests for the above fixes and changes. - -2003-03-26 Jim Meyering - - * src/copy.h (struct cp_options): Add a comment. - -2003-03-23 Jim Meyering - - * README: Describe problem with 64-bit mode on HPUX 11.x, - with patch for /usr/include/inttypes.h. - * TODO: Plan to add an autoconf test to work around the bug. - -2003-03-22 Jim Meyering - - * src/stat.c: Don't include . - That is already done via system.h. Otherwise, the multiple - inclusion would evoke redefinition warnings from Cray's /bin/cc, - aka Cray Standard C Version 4.0.3 (057126) Mar 22 2003 22:02:28. - (human_fstype): Factor some directives `up', out of this function. - Cast away `const' to avoid error from Cray's /bin/cc. - -2003-03-20 Jim Meyering - - * announce-gen (print_changelog_deltas): Ensure that a newline - precedes each row of `*'s. - -2003-03-20 Jim Meyering - - * Version 4.5.11. - - * src/seq.c (valid_format): Also accept ` ' and `'' as valid - format flag characters. - Do not require that a field width be specified. - Do not fail when given a field width of `0'. - Reported by Dan Jacobson. - * tests/seq/basic: Add new tests for the above-fixed bug. - - * src/Makefile.am (all-local): Append $(EXEEXT) to use of `su' - (install-root): Likewise. - (install-exec-local): Likewise. - Based on a patch from Richard Dawe. - -2003-03-19 Jim Meyering - - * man/Makefile.am (.x.1): Use $(LN_S) instead of 'ln -s', - because the DJGPP 2.03 port of 'ln -s' doesn't work. - Include $(EXEEXT) in program names. - Since $(LN_S) may degenerate to `cp -p', be careful - to invoke it from the destination directory. - Mostly from Richard Dawe. - * configure.ac: Use AC_PROG_LN_S. - - * tests/mv/part-symlink: Unset CDPATH. Otherwise, having the - CDPATH shell variable set could cause this test to fail. - Reported by Karl Berry. - -2003-03-18 Jim Meyering - - * src/fmt.c [struct Word] (paren, period, punct, final): Change the - type of each member from bool :1 to unsigned int :1. - AIX 5.1's xlc could not compile the former. - Patch by Petter Reinholdtsen. Also reported by Mike Jetzer. - -2003-03-17 Richard Dawe - - * configure.ac: Include $(EXEEXT) in OPTIONAL_BIN_PROGS' - program names, since automake only adds $(EXEEXT) to programs - in its *_PROGRAMS. - -2003-03-16 Jim Meyering - - * src/remove.c (rm): Put two local variables in static storage, - so they can't be clobbered by the potential longjmp. - -2003-03-15 Jim Meyering - - * Makefile.cfg (gnu_rel_host): Fix code to match the comment - so that a version number with a two-digit component can still count - as an alpha release. Reported by Richard A Downing. - (gnu_rel_host): Define in terms of $(RELEASE_TYPE) instead. - -2003-03-14 Jim Meyering - - * src/ansi2knr.c: Remove no-longer-used file. - * src/ansi2knr.1: Likewise. - - * Makefile.maint (prev_version_file): Don't use ?= for this particular - assignment, since it causes trouble with old versions of GNU make - (e.g. 3.76.1). The other uses of `?=' are inoffensive. Details here. - http://mail.gnu.org/archive/html/bug-coreutils/2003-03/msg00028.html - Patch from Alexandre Duret-Lutz. - - * Use patched automake-1.7.3. Regenerate Makefile.in files in - subdirectories so that each includes a definition of ACLOCAL_M4. - - * announce-gen (main): Label the compressed source URLs. - - * Version 4.5.10. - - * tests/du/slink: Relax the test for the `local'ness of a file system, - so that now it works also for tmpfs. - - * tests/du/hard-link: Transform output from first du, so that this - test doesn't fail on file systems like tmpfs that order directory - entries differently. - -2003-03-13 Jim Meyering - - * tests/du/8gb: Work around what appears to be an NFS failure that - would make this test fail on some systems. - -2003-03-11 Jim Meyering - - * tests/du/basic: Make the test file exactly 4k bytes long. - - * src/split.c (longopts): Don't hard-code `2' here. - Instead, just specify `&verbose', and ... - (main): ... remove the `case 2:' block for --verbose. - - * tests/du/basic: Make the test file larger than 64 bytes, so that - we don't immediately disqualify file systems (e.g., NetApp) on which - smaller files take up zero disk blocks. Reported by Vin Shelton. - -2003-03-10 Jim Meyering - - Don't segfault for a negative field width or precision in format string. - Note that this is just a stopgap fix. The longer term solution may - involve adapting bash's builtins/printf.def. - - * src/printf.c: (UNSPECIFIED): Define. - (print_direc): Use the special value, UNSPECIFIED, to indicate - that field_width or precision has not been specified. - (print_formatted): Fail if field_width or precision is the - special value, UNSPECIFIED. - Reported by Oliver Kiddle - - * src/sys2.h (INT_MIN): Define, if necessary. - * tests/misc/printf: Add a test for the above-fixed bug. - -2003-03-09 Jim Meyering - - * src/remove.c (AD_stack_pop): Cast sizeof... to int before - changing its sign. This avoids a warning from gcc on 64-bit systems. - Reported by Bob Proulx. - (pop_dir): Reverse order of sign change and cast, to be consistent - with the above. - -2003-03-08 Jim Meyering - - * tests/Makefile.am (evar-check): Check for POSIXLY_CORRECT not as a - shell variable, but only in the environment. With /bin/sh->bash, the - shell variable is set to `y', and that would cause a spurious warning. - Reported by Bob Proulx. - - * tests/Makefile.am (check-root): Remove touch/fifo. - It doesn't appear to have to be run as root. - - * tests/rm/fail-2eperm: Rather than simply using the first non-root - user name, make sure that the selected user name has a usable shell. - Reported by Paul Jarc. - - Before, when using shred on a device, one had to specify --exact, - or be careful to choose a size that would not be rounded up and - exceed the maximum value; that could result in a failure of - the final write. - * src/shred.c (do_wipefd): --exact is now the default for non-regular - files. Suggestion from Ben Elliston. - (usage): Say it. - - * tests/misc/tty-eof: Require at least version 1.11 of Expect.pm. - Old versions of Expect.pm (e.g., 1.07) lack the log_user function. - Patch by Bob Proulx. - - * src/Makefile.am (check-misc): Check for use of `defined' in - #define directives. - Change to $(srcdir) before running grep. - - * src/sleep.c: Remove now-unused #include and #define directives. - - * src/du.c (process_file): If a file's size is not being counted - e.g., because it's a hard link to a file we've already counted, - then don't print a line for it. - - * tests/du/hard-link: New test for the above-fixed bug. - * tests/du/Makefile.am (TESTS): Add hard-link. - - `du -S' didn't work - * src/du.c: Revert most of the `reorganization' change of 2003-02-20, - and make the two-array approach work. - - * tests/du/basic: Correct/add tests for the above fix. - Set LC_ALL, etc., now that we use sort. - Check the block/size of a small file, too. - Correct expected results for simple dir1/dir2/file case. - Add another test of du -S. - -2003-03-07 John David Anglin - - Avoid build failure with gcc on hppa1.1-hp-hpux10.20 (see GCC PR - middle-end/9986). As one of GCC's optimizations, it transforms a - fputs_unlocked call to a fputc_unlocked call when the string is - one character long. However, hpux doesn't have fputc_unlocked. - - * expr.c (usage): Use putchar, not fputs, to output a single character. - * ls.c (dired_dump_obstack): Likewise. - * ptx.c (output_one_tex_line, output_one_dumb_line): Likewise. - * stat.c (print_it): Likewise. - -2003-03-07 Jim Meyering - - * src/cp.c: Remove everything associated with mmap-stack.c. - This reverts the two changes of 2003-02-21. - * src/du.c: Remove everything associated with mmap-stack.c. - This reverts the change of 2003-02-19. - -2003-03-06 Jim Meyering - - * tests/cp/same-file: Unset CDPATH. Otherwise, having the - CDPATH shell variable set could cause this test to fail. - Reported by Karl Berry. - -2003-03-05 Jim Meyering - - * Version 4.5.9. - - * src/printf.c (print_esc): Remove pointless comparison of unsigned - integer with zero, to avoid a warning from Intel's ecc. - Reported by Nelson Beebe. - - * src/du.c (process_file): Sizes must all be of type uintmax_t. - Otherwise, for files or totals that are too big, numbers would - be truncated. Patch mostly by Michael Stone. - Reported by Ingo Saitz as Debian bug #183210. - - * tests/du/8gb: New test for the above-fixed bug. - * tests/du/Makefile.am (TESTS): Add 8gb. - - * src/du.c (MAX_N_DESCRIPTORS): Use 3 * UTILS_OPEN_MAX / 4 - rather than UTILS_OPEN_MAX - 10. - -2003-03-04 Jim Meyering - - * README: Refer new feature discussion to bug-coreutils@gnu.org, - rather than bug-gnu-utils, now that the former is better known. - Suggestion from Göran Uddeborg. - - * src/stat.c (usage): Capitalize consistently. - Reported by Göran Uddeborg. - - * Makefile.maint (rel-files): Include $(signatures), so that - those files are also copied into $(release_archive_dir). - - * src/df.c (find_mount_point): Call error here, now that restore_cwd - no longer does it. - * src/remove.c (AD_pop_and_chdir): Likewise. - - * tests/Makefile.am (check-root): Add fail-2eperm. - -2003-03-03 Jim Meyering - - * src/remove.c (remove_cwd_entries): Include the full filename of - the offending file, not just the basename. - - * tests/misc/tty-eof: Set $ME properly. - - * Makefile.maint (THIS_VERSION_REGEXP, PREV_VERSION_REGEXP): - Remove now-unused variables. - (tag-prev-version, prev-cvs-tag): Likewise. - - * src/remove.c (remove_cwd_entries) [!ROOT_CAN_UNLINK_DIRS]: Give an - accurate diagnostic when failing to remove a file owned by some other - user. Reported by Ivo Timmermans via Michael Stone. - This fixes Debian bug# 178471. - - * tests/rm/Makefile.am (TESTS): Add fail-2eperm. - * tests/rm/fail-2eperm: New test, for the above-fixed bug. - Based on a report from Ivo Timmermans. - -2003-03-02 Jim Meyering - - * src/copy.c (copy_internal) [un_backup]: When recovering from a - failure to create a hard link, do not remove the entry associating - the source dev/ino with the destination file name. - * tests/mv/Makefile.am (TESTS): Add hard-3. - * tests/mv/hard-3: New test, for the above-fixed bug. - Inspired by a report from Iida Yosiaki. - -2003-03-01 Jim Meyering - - * src/df.c (print_header): Don't embed spaces in a separate `Type' - header string. Instead, put `Filesystem' and `Type' headers in the - same string, so translators can use horizontal space as needed. - Reported by Jean Charles Delepine. - -2003-02-28 Jim Meyering - - * src/copy.c (copy_internal): When link fails because of an - existing destination file, unlink that file and try again. - Reported by Iida Yosiaki. - - * tests/mv/Makefile.am (TESTS): Add hard-2. - * tests/mv/hard-2: New test for the above-fixed bug. - Based on a test case from Iida Yosiaki. - -2003-02-26 Jim Meyering - - * tests/du/basic: Don't test du's -b option here. Directory byte - counts are smaller (512 rather than 4096) on at least OSF/1 5.1 - and IBM AIX 4.2. Reported by Nelson Beebe. - -2003-02-25 Jim Meyering - - * Makefile.maint (announcement): Now that ChangeLog entries - are output by announce-gen, don't do it here. - * announce-gen (print_changelog_deltas): New function. - (main): Use it. - -2003-02-22 Jim Meyering - - * announce-gen: New option: --release-type=TYPE - * Makefile.maint (beta, major): New targets. Remove `release'. - Put them all together on a line. - Pass the release type (via RELEASE_TYPE envvar) to the MAKE - invocation of `announcement'. - (announcement): Invoke announce-gen with --release-type=$RELEASE_TYPE. - - * announce-gen: New option: --news=NEWS_FILE. - Extract NEWS entries here, not via rules in Makefile.maint. - * Makefile.maint (announcement): Now that NEWS entries are - extracted by announce-gen, don't do it here. - (news-r1, news-r2): Remove now-unused definitions. - -2003-02-21 Jim Meyering - - * Version 4.5.8. - - Merge in changes from autoconf's version of this file. - * Makefile.maint (www-gnu): Define. - (standards.texi-url_prefix): Use $(www-gnu). - (make-stds.texi-url_prefix): Likewise. - - * src/cp.c: Include "mmap-stack.h". - (main): Invoke `run' through a macro that (when possible) runs it - with a large, mmap'd stack. - - * src/cp.c (run): New function, preparing for the above. - Exit from this function, not from main - (main): Call run. - - * src/du.c: New option: --apparent-size. - (enum) [APPARENT_SIZE_OPTION]: New member. - (long_options): Add it. - (usage): Describe it. - (main): Handle it. - ['b']: Set apparent_size. - David Eisner reported that the behavior of --bytes had changed. - Paul Eggert proposed the use of a new option, --apparent-size. - - * src/du.c (apparent_size): New global. - (print_only_size): Reflect the fact that we're printing byte counts, - not ST_NBLOCKSIZE-byte-block counts. - (print_size): Call print_only_size rather than duplicating its code. - (process_file): Accumulate byte counts, rather than block counts. - - * src/du.c (process_file): Always reset size_to_propagate_to_parent - for --separate-dirs (-S). - -2003-02-20 Jim Meyering - - * Use automake-1.7.3. Regenerate dependent files. - - * src/stat.c (print_stat): New format: %B (to print ST_NBLOCKSIZE). - This makes %b (number of ST_NBLOCKSIZE-byte blocks) more useful. - (usage) [%B]: Describe it. - [%b]: Refer to %B. - - * src/du.c (process_file): Reorganize the code to use only - one `sum' array, and change how -S works back to the way it was - before 2003-01-31. Patch by Bruno Haible. - - * tests/du/basic: New test. - * tests/du/Makefile.am (TESTS): Add basic. - - * tests/envvar-check: Add checks for the following: - BLOCK_SIZE, DU_BLOCK_SIZE, DF_BLOCK_SIZE, LS_BLOCK_SIZE. - - * tests/Makefile.am: Rename phony target envvar-check to evar-check - so as not to conflict with the distributed file by the same name. - - * src/du.c (process_file): Set info->skip before any possible return. - - Report correct usage for directories, not 0. - * src/du.c (process_file): Return for `file_type == FTW_DPRE' - _before_ recording the dev/ino of a directory. - Reported by Bruno Haible. - - Now, df always displays the device file name corresponding to the - listed mount point under `Filesystem'. Before, for an unmounted - block- or character-special file argument, it would display the - command-line argument instead. - * src/df.c (show_disk): Return a value indicating whether - there was a match. Don't try to find a mount point here. - (show_entry): If show_disk doesn't find a match, call show_point. - -2003-02-19 Jim Meyering - - * src/du.c: Include "mmap-stack.h". - (du_files): Add prototype with ATTRIBUTE_NORETURN. - Exit from this function, not from... - (main): ...here. - Instead, if possible, invoke du_files through a macro that - runs it with a large, mmap'd stack. - - * src/join.c (usage): Change wording in --help output: - use FILENUM instead of `SIDE' and say what FILENUM means. - Reported by Bernhard Gabler. - - * src/df.c (print_header): Rather than using a hard-coded literal - string of spaces matching the length of the English `...Type' header, - output the right number of spaces to match the selected translation. - Reported by Yann Dirson and Jean Charles Delepine as Debian bug 131113. - - * src/split.c (bytes_split): Remove unnecessary `else' after break. - (lines_split): Likewise. and correct misleading indentation. - - * src/split.c: Include "full-read.h". - (bytes_split, lines_split, line_bytes_split): Use full_read, - not safe_read. The way split was using the latter, a short read - could cause split to terminate before EOF. - - * tests/misc/tty-eof: Test all programs that can read stdin, - requiring no arguments and that write to standard output. - - * tests/misc/tty-eof: New file. Renamed from ... - * tests/misc/cat-tty-eof: Remove file. Rename to tty-eof. - * tests/misc/Makefile.am (TESTS): Reflect renaming. - -2003-02-18 Jim Meyering - - cksum would perform an extra read after encountering EOF - * src/cksum.c (cksum): Exit the loop upon EOF, too. - Patch by Michael Bacarella. - - Test for the bug fixed today in cksum, md5sum, and sha1sum. - * tests/misc/cat-tty-eof: Generalize, clean-up, and test for - cat, cksum, md5sum, and sha1sum all in the same loop. - -2003-02-14 Jim Meyering - - * src/remove.c: Include "euidaccess.h". - Remove declaration of euidaccess. - -2003-02-12 Jim Meyering - - * src/pathchk.c (portable_chars_only): Remove unnecessary `const' - in cast to avoid warning from icc. Reported by Alexandre Duret-Lutz. - -2003-02-10 Jim Meyering - - * src/test.c: Don't include group-member.h. - Include euidaccess.h. - (eaccess): Rewrite function to set the real uid and gid temporarily - to the effective uid and gid, then invoke 'access', and then set the - real uid and gid back. On systems that lack setreuid or setregid, - fall back on the kludges in euidaccess. Before, it would not work - for e.g., files with ACLs, files that were marked immutable, - or on file systems mounted read-only. Nelson Beebe raised the issue. - Paul Eggert suggested the new implementation. - -2003-02-09 Jim Meyering - - * src/test.c (test_stat): Remove function. It's job is done (only - when necessary) by the wrapper in lib/stat.c. Adjust all uses. - -2003-02-08 Jim Meyering - - * Version 4.5.7. - - * tests/mv/part-symlink: Don't assume that the file owner username - length is less than 9 in ls output: instead, omit that field - altogether. Reported by, and suggested fix from, Ferdinand. - - * tests/du/restore-wd: New test for just-fixed bug in ftw.c. - * tests/du/Makefile.am (TESTS): Add restore-wd. - - * src/rm.c: Correct now-invalid comment about cycle-detection. - -2003-02-06 Jim Meyering - - * NEWS: Add entries from old/*/NEWS - from fileutils-4.1 through 4.1.11 and - from sh-utils-2.0 through 2.0.15. Suggestion from Karl Berry. - - * Version 4.5.6. - - * src/du.c (process_file): Don't return early for excluded files - or for files whose dev/inode we've already seen. - -2003-02-05 Jim Meyering - - * tests/du/exclude: New file. - * tests/du/Makefile.am (TESTS): Add exclude. - -2003-02-04 Dmitry V. Levin - - * src/who.c (print_boottime, print_deadprocs, print_runlevel): - Fix memory allocation arithmetic. - -2003-02-04 Jim Meyering - - `df /dev/block-or-char-device-file--not-mounted' now reports - the name of the file system on which the file resides, usually `/'. - Before, it would leave the `Mounted on' field blank. - * src/df.c (show_disk): Move function to precede find_mount_point. - (show_disk): Add parameter: STATP. - If we don't find a matching device name, then resort to calling - find_mount_point. Reported by Bob Proulx. - -2003-02-03 Andreas Schwab - - * tests/rm/cycle: Require non-root. - * tests/rm/isatty: Likewise. - -2003-02-02 Jim Meyering - - * Version 4.5.5. - - * man/Makefile.am (check-x-vs-1): Use @PATH_SEPARATOR@, not `:'. - - Ensure that there are no offending uses of `:'. - * Makefile.maint (makefile_path_separator_check): New rule. - (local-check): Add it to the list. - -2003-02-01 Jim Meyering - - * src/du.c (MAX_N_DESCRIPTORS): Define. - - * src/stat.c (G_fail): New global. - (human_time): Diagnose failed localtime, not failed nstrftime. - (main): Fail if G_fail is set. - -2003-01-31 Richard Dawe - - * tests/basename/Makefile.am: Use @PATH_SEPARATOR@ instead of - hard-coding the path-separator. Also double-quote the new PATH, - to avoid problems when the path-separator is a semi-colon or when - `pwd` contains e.g. a space. - * tests/chgrp/Makefile.am: Likewise. - * tests/chmod/Makefile.am: Likewise. - * tests/chown/Makefile.am: Likewise. - * tests/cp/Makefile.am: Likewise. - * tests/dd/Makefile.am: Likewise. - * tests/dircolors/Makefile.am: Likewise. - * tests/du/Makefile.am: Likewise. - * tests/expr/Makefile.am: Likewise. - * tests/factor/Makefile.am: Likewise. - * tests/fmt/Makefile.am: Likewise. - * tests/install/Makefile.am: Likewise. - * tests/ln/Makefile.am: Likewise. - * tests/ls/Makefile.am: Likewise. - * tests/ls-2/Makefile.am: Likewise. - * tests/md5sum/Makefile.am: Likewise. - * tests/misc/Makefile.am: Likewise. - * tests/mkdir/Makefile.am: Likewise. - * tests/mv/Makefile.am: Likewise. - * tests/od/Makefile.am: Likewise. - * tests/rm/Makefile.am: Likewise. - * tests/rmdir/Makefile.am: Likewise. - * tests/seq/Makefile.am: Likewise. - * tests/sha1sum/Makefile.am: Likewise. - * tests/shred/Makefile.am: Likewise. - * tests/stty/Makefile.am: Likewise. - * tests/sum/Makefile.am: Likewise. - * tests/tail-2/Makefile.am: Likewise. - * tests/touch/Makefile.am: Likewise. - * tests/tsort/Makefile.am: Likewise. - * tests/unexpand/Makefile.am: Likewise. - -2003-01-31 Jim Meyering - - * src/stat.c: Include "file-type.h" - (print_human_type): Remove function. - (human_access): Rename from print_human_access. Return a string. - (human_time): Rename from print_human_time. Return a string. - (print_stat): Arrange so that field width and an alignment specifier - are honored for the %A, %F, %x, %y, and %z formats. - [%F]: Use file_type; this gives slightly different file type strings, - e.g., `directory' instead of `Directory' and `regular file' or - `regular empty file' instead of `Regular file'. - Prompted by a report from Richard Dawe that the uses of - S_IFSOCK and S_IFIFO in print_human_time were not portable - to systems using e.g., DJGPP. - -2003-01-31 Richard Dawe - - * src/stat.c (print_stat): Use S_ISLNK rather than an explicit - test using S_IFMT and S_IFLNK. S_IFLNK may not be defined. - -2003-01-31 Jim Meyering - - * src/du.c (main): Upon processing an invalid option or an invalid - --exclude-from or --max-depth option argument, don't exit right away, - in case there are others. Rather record the failure and exit after - processing other options. - - * GNUmakefile (TAR_OPTIONS): Set and export, in order to make - tar archive easier to reproduce. - - Rewrite to perform directory traversal using nftw. - - * src/du.c: Include "dirname.h", "ftw.h", and "quotearg.h". - (AUTHORS): Add self. - (opt_one_file_system): Move global into `main'. - (path, xstat, exit_status): Remove declarations. - (arg_length, suffix_length): New globals. - (G_fail): New global, sort of like the old `exit_status'. - (IS_FTW_DIR_TYPE): Define. - (print_only_size): New function. - (process_file): New function. - (str_init, ensure_space, str_copyc, str_concatc): Remove functions. - (str_trunc, pop_dir, count_entry): Likewise. - (du_files): Rewrite to use nftw. - -2003-01-30 Jim Meyering - - * tests/du/trailing-slash: Ensure that du/ftw follows a command-line - symlink-to-directory with -L, even without the trailing slash. - -2003-01-27 Jim Meyering - - * src/Makefile.am (check-misc): Check for st_blocks, too. - - * src/stat.c (print_stat): Use ST_NBLOCKS rather than `->st_blocks'. - Reported by Richard Dawe. - -2003-01-27 Andreas Schwab - - * src/ls.c (quote_name): Add fourth parameter, width, into which to - store the screen columns, and return the number of bytes instead. - (print_dir): Pass NULL as fourth parameter of quote_name. - (print_name_with_quoting): Likewise. - (length_of_file_name_and_frills): Get the width from the fourth - parameter of quote_name instead of return value. - -2003-01-27 Jim Meyering - - * src/ls.c (decode_switches): If `dired' is set without - `format == long_format', then silently reset dired. This doesn't - change the behavior of ls (all prior uses of dired were protected - by `&& format == long_format'), and lets us... - (DIRED_INDENT): ... remove the `format == long_format' conjunct. - (PUSH_CURRENT_DIRED_POS): Likewise. - (main): Likewise. - -2003-01-22 Jim Meyering - - * tests/du/no-x: New test, for functionality added to lib/ftw.c. - * tests/du/Makefile.am (TESTS): Add no-x. - -2003-01-21 Jim Meyering - - * src/remove.c (remove_entry) [ROOT_CAN_UNLINK_DIRS - && HAVE_STRUCT_DIRENT_D_TYPE]: If a file has d_type == DT_UNKNOWN - it may still be a directory -- or not (e.g., with FreeBSD on an - NFS-mounted file system), so resort to calling lstat to find out. - Based on a patch by Michael van Elst. - - * tests/cp/same-file: Don't assume that the file owner username - length is less than 9 in ls output: instead, omit that field - altogether. Reported by, and suggested fix from, Ferdinand. - -2003-01-20 Jim Meyering - - * tests/date/Test.pm (wide-fmt): New test to demonstrate that - large format widths no longer cause strftime to infloop. - - * Makefile.maint (mail_gpg_sign_cookie): Remove now-unused definition. - -2003-01-19 Jim Meyering - - * src/readlink.c: Include "canonicalize.h". - -2003-01-18 Jim Meyering - - * src/ls.c (Dereference_symlink) [DEREF_COMMAND_LINE_SYMLINK_TO_DIR]: - New member. - (enum) [DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_OPTION]: New member. - (long_options): Add option --dereference-command-line-symlink-to-dir. - (main): Make DEREF_COMMAND_LINE_SYMLINK_TO_DIR be the default, - rather than DEREF_COMMAND_LINE_ARGUMENTS, when none of the - -d, -F, -l options is specified. - (decode_switches): Handle --dereference-command-line-symlink-to-dir. - (gobble_file): Honor DEREF_COMMAND_LINE_SYMLINK_TO_DIR. - Change --dereference-command-line (-H) to dereference *all* - command line arguments, including broken symlinks. - -2003-01-15 Paul Eggert - - Change ls -H back to the way it was yesterday, since this is - compatible with FreeBSD and the POSIX spec is confusing - and somewhat contradictory. - - * src/ls.c (DEREF_COMMAND_LINE_ARGUMENTS): Change name back - from DEREF_COMMAND_LINE_SYMLINK_TO_DIR, updating all uses. - (long_options): Change the long option name back. - (usage): Change the usage back. - (gobble_file): When -H is specified, dereference a top-level - arg even if it points to a non-directory. - -2003-01-15 Jim Meyering - - * src/ls.c (gobble_file): Fall back on using lstat when required: - when --dereference (-L) is not specified, and - - when operating on a dangling symlink - - when operating on command-line-symlink-to-directories - This fixes numerous problems. Here are examples: - - `ls dangling-symlink' would fail with `no such file...' - Now it prints `dangling-symlink'. - - `ls -i symlink' would mistakenly print the inode of the referent. - Now it prints the inode of the symlink. Likewise for --size (-s). - Based on a patch from Michael Stone. - Reported by Deepak Goel as Debian bug #173793. - - Rename ls's --dereference-command-line (-H) - option to --dereference-command-line-symlink-to-dir. - * src/ls.c [enum Dereference_symlink] - (DEREF_COMMAND_LINE_SYMLINK_TO_DIR): Rename from - DEREF_COMMAND_LINE_ARGUMENTS. Update all uses. - (long_options): Rename the long option. - (usage): Say that --dereference-... changes how ls treats - only symlinks to directories specified on the command line. - -2003-01-14 Jim Meyering - - * tests/ls/dangle: New file/test, for the above fix. - * tests/ls/inode: Another new file/test, for the above fix. - * tests/ls/Makefile.am (TESTS): Add dangle and inode. - - * src/ls.c (gobble_file): Fix a bug introduced in 4.5.4 that made it - so that ls --color would no longer highlight the names of files with - the execute bit set when not specified on the command line. - Patch by Michael Stone. Reported by Stephen Depooter as - Debian bug 175135. - - * tests/ls-2/tests (color-exe): New test, for the above fix. - -2003-01-13 Jim Meyering - - * tests/shred/exact: Also test for just fixed bug with --zero. - - * src/shred.c (long_opts): --zero does not require an argument. - Patch by Michael Stone. Reported by Roland Turner as Debian bug 172019. - -2003-01-12 Jim Meyering - - * Makefile.maint (cvs-update): Skip any file with local modifications. - - * src/unexpand.c (usage): Document --first-only and mention that - --tabs=N (-t) enables --all (-a). Reported by wiregauze@yahoo.com. - -2002-12-01 Dmitry V. Levin - - * src/df.c: Include "canonicalize.h". - Use canonicalize_file_name unconditionally. - -2003-01-09 Jim Meyering - - * README: Add readlink. - -2002-11-30 Dmitry V. Levin - - * src/df.c: Include "xgetcwd.h". - * src/pwd.c: Likewise. - -2002-11-30 Dmitry V. Levin - - * src/shred.c: Remove declaration of xstrdup. - We already get it via xalloc.h which is included via system.h. - -2002-08-27 Dmitry V. Levin - - New program: readlink. - - * src/Makefile.am (bin_PROGRAMS): Add readlink. - * src/readlink.c: New file. - - * man/readlink.x: New file. - * man/Makefile.am (dist_man_MANS): Add readlink.1. - (readlink.1): New rule. - -2003-01-09 Jim Meyering - - When selecting ranges of byte offsets (as opposed to ranges of fields) - and when --output-delimiter=STRING is specified, output STRING between - ranges of selected bytes. - * src/cut.c (RANGE_START_SENTINEL): Define. - (output_delimiter_specified): New global. - (print_kth): Add parameter. Adjust all callers. - (set_fields): Mark each range-start index with RANGE_START_SENTINEL. - (cut_bytes): When requested, output STRING between ranges of - selected bytes. - (main): Make a diagnostic a little clearer. - Based on a patch from Jan Nieuwenhuizen. - - * tests/cut/Test.pm: New tests for the above. - - * src/cut.c (set_fields): Make code agree with comment: - Don't merge abutting ranges like 4- and 2-3. This makes no - difference currently, but is required to support an upcoming change. - -2003-01-07 Jim Meyering - - * src/cut.c (set_fields): Fix typo in comment. - - * tests/touch/not-owner: New test, mostly extracted from fail-diag. - * tests/touch/Makefile.am (TESTS): Add not-owner. - * tests/touch/fail-diag: Remove the test for non-owner diagnostic. - Now, this tests only the nonexistent-directory diagnostic. - Suggestion from Michael Stone. - - * tests/touch/fail-diag: Fix typo: s/ld/ls/. - -2003-01-04 Jim Meyering - - * src/copy.h: Remove use of PARAMS. - * src/remove.h: Likewise. - * src/chown-core.h: Likewise. - - rm could be tricked into mistakenly reporting a cycle. - * src/remove.c: [cycle_check_state]: New global. - (remove_cwd_entries): Adapt to new semantics of cycle_check. - (rm): Call cycle_check_init and cycle_check_free for each file. - * tests/rm/cycle (rm): New test, for the above fix. - * tests/rm/Makefile.am (TESTS): Add cycle. - - When rm detects a cycle, don't abort the entire command, - but rather just the affected command line argument. - * src/remove.c: Include - (struct dirstack_state) [current_arg_jumpbuf]: New member. - (remove_cwd_entries): Call longjmp if we detect a cycle. - (rm): Call setjmp here. - - * src/remove.c (cycle_check, is_power_of_two): Remove functions. - Instead, include cycle-check.h and use it. - - * src/remove.h (struct dev_ino): Remove declaration. - - * src/remove.c (remove_cwd_entries): Fix typos in comment. - - Don't include trailing /. in diagnostics about directories. - * src/remove.c (full_filename_): When FILENAME is just `.' - and there is a nonempty directory-name part, don't append `/.'. - * tests/rm/unread2: Remove trailing /. from diagnostic. - * tests/rm/rm2: Likewise. - - * src/remove.c (struct dirstack_state): Define. - To be used in place of these file-scoped globals ... - (dir_stack, len_stack, Active_dir): Remove globals. - (ds_init, ds_free): New functions. - (full_filename): Define. - (full_filename_): Rename from full_filename. - - Begin to make AD_* functions more generic. - * src/remove.c (AD_push_initial): Don't set status to RM_OK here. - (AD_push): Likewise. - (AD_INIT_OTHER_MEMBERS): Define. - (remove_dir): Define the `status' member manually after each - call to AD_push or AD_push_initial. - - * src/Makefile.am (check-misc): New rule, to ensure that no more - S_IS* macro definitions sneak into the code. - (check): Depend on check-misc. - - * src/remove.c [S_ISLNK]: Don't define. It's already defined in sys2.h. - * src/du.c (count_entry) [S_ISLNK]: Don't define. - * src/shred.c [S_ISLNK, S_ISFIFO, S_ISSOCK]: Don't define. - -2003-01-03 Jim Meyering - - * src/true.c: Add copyright. - (AUTHORS): I suppose I've written it. - - * src/Makefile.am (false.c): Make the generated file be read-only. - -2003-01-04 Jim Meyering - - * src/ls.c: Include "dev-ino.h". - [struct dev_ino]: Remove declaration. - -2003-01-02 Jim Meyering - - * src/cp.c (do_copy): Tweak diagnostic to be consistent with the one - from mv: s/missing file arguments/missing file argument/. - With --target-directory=DIR, cp and mv work with a single file argument. - Reported by Karl Berry. - - * tests/rm/isatty: Enable this test. - -2002-12-31 Jim Meyering - - * src/remove.c (AD_push_initial): Don't set status to RM_OK here. - (AD_push): Likewise. - (AD_INIT_OTHER_MEMBERS): Define. - (remove_dir): Define the `status' member manually after each - call to AD_push or AD_push_initial. - - * src/ls.c [struct dev_ino]: Remove definition. - Include "dev-ino.h" instead. - -2002-12-28 Jim Meyering - - * tests/du/Makefile.am (TESTS): Add no-deref. - * tests/du/no-deref: New script. - -2002-12-23 Jim Meyering - - * src/remove.c (remove_cwd_entries): Fix typo in comment. - -2002-12-21 Jim Meyering - - * announce-gen: Generate MML-formatted announcement. - This makes it a *lot* harder to send stale MD5/SHA1 signatures. - -2002-12-20 Jim Meyering - - * src/touch.c (touch): Change the wording of a diagnostic so - that it makes sense both when the file exists and when it doesn't. - Suggestion from Michael Stone. - -2002-12-18 Jim Meyering - - * src/stty.c (valid_options): Declare to be static. - -2002-12-15 Jim Meyering - - * Makefile.cfg: Remove rules related to generating m4/jm-glibc-io.m4. - - * src/chmod.c, src/copy.c, src/copy.h, src/cp-hash.h, src/csplit.c: - * src/date.c, src/expr.c, src/fmt.c, src/id.c, src/install.c: - * src/ls.c, src/od.c, src/pathchk.c, src/pr.c, src/remove.c: - * src/shred.c, src/sort.c, src/stat.c, src/stty.c, src/sum.c: - * src/tee.c, src/test.c: Remove all uses of `PARAMS'. - - * src/remove.c (PARAMS): Remove definition. - * src/sys2.h: Likewise. - - * src/ls.c, src/stat.c, src/date.c: Remove declaration of nstrftime. - Include strftime.h instead. - -2002-12-14 Jim Meyering - - * Makefile.cfg ($(url_dir_list)): Use .../coreutils, not .../fetish. - - * src/system.h [! HAVE_DECL_MEMRCHR]: Declare memrchr. - This is necessary at least for Irix6.5 when using c89. - Reported by Nelson Beebe. - - * tests/misc/Makefile.am (TESTS): Add cat-tty-eof. - - * tests/misc/cat-tty-eof: New test. - - * src/mknod.c (usage): Specify how major and minor mode numbers - are interpreted. Report forwarded by Kristin E Thomas. - * src/mknod.c: Remove now-redundant usage-specifying comment. - -2002-12-13 Jim Meyering - - * Version 4.5.4. - - * tests/du/trailing-slash: Allow for a directory of size `0'. - That happens at least on file systems of type tmpfs on linux-2.4.18. - - * announce-gen: New script to begin replacing the commands - associated with the rule here... - * Makefile.maint (announcement): Invoke announce-gen. - * Makefile.am (EXTRA_DIST): Add announce-gen. - - * tests/cp/preserve-2: New file/test, for latest fix. - * tests/cp/Makefile.am (TESTS): Add preserve-2. - -2002-12-11 TAKAI Kousuke - - Fix a bug whereby cp would fail to parse an option like - --preserve=mode,ownership. - * src/cp.c (decode_preserve_arg): Advance `comma' to - point the character following the comma. - -2002-12-11 Jim Meyering - - * src/pathchk.c (NEED_PATHCONF_WRAPPER): Undefine before defining, - in case it's already defined. - -2002-12-09 Jim Meyering - - * tests/touch/fail-diag: Don't get a test failure if /no exists. - Instead, evoke a framework failure if /no-$$ exists. - Reported by Michael Stone. - -2002-12-08 Jim Meyering - - * src/du.c (lstat) [! LSTAT_FOLLOWS_SLASHED_SYMLINK]: - Define to rpl_lstat, so that even on systems like Solaris 5.8, - du honors (per POSIX) the trailing slash on an argument referring - to a symlink-to-directory. - -2002-12-06 Jim Meyering - - * Use autoconf-2.57. Regenerate dependent files. - * Use automake-1.7.2. Regenerate dependent files. - - * src/ls.c (gobble_file): Also stat the file if it's a - regular file and --indicator-style=classify (aka -F). - Thanks to Ed Santiago for opening my eyes. - - * tests/ls/file-type: New file. Test for the above. - A test to contrast ls -F and ls --indicator-style=file-type. - * tests/ls/Makefile.am (TESTS): Add file-type. - -2002-12-04 Jim Meyering - - * tests/ls/follow-slink: Make sure the symlink was created. - Richard Dawe reported that `ln -s link link' succeeds, but creates - no file on systems running some version of the DJGPP libc. - -2002-12-03 Jim Meyering - - * src/Makefile.am (AUTOMAKE_OPTIONS): Remove definition (to ansi2knr) - since this package no longer panders to K&R compilers. - -2002-12-02 Jim Meyering - - * tests/du/slink: Skip this test if `.' is on a non-local file system. - - * tests/Fetish.pm (_at_replace): Do the substitution only if there's - something to replace. - -2002-12-01 Jim Meyering - - * src/stat.c: Don't include or . - That's already done via system.h. - * src/dircolors.c: Don't include . - -2002-11-30 Jim Meyering - - * ls.c (gobble_file): Remove the block of code that caused - `ls --color -F symlink-to-dir' to list the files in - `symlink-to-dir/.'. Now, it prints `symlink-to-dir@', (just - like `ls -F symlink-to-dir') but with the addition of highlighting. - Similarly, `ls --color -dF symlink-to-dir' would print - `symlink-to-dir/'; now it prints `symlink-to-dir@'. - Reported by Jeff Sheinberg as Debian bug #168203. - * tests/ls-2/tests (sl-F-color, sl-dF-color): New tests for the above. - - ls is now more efficient: with certain options, it no longer needs - to stat each directory entry on systems with valid dirent.d_type. - * src/ls.c (print_dir): Add DT_LNK and DT_REG. - (main): Make --recursive set format_needs_type, not format_needs_stat. - (gobble_file): Remove a FIXME comment, now that it's fixed. - -2002-11-24 Jim Meyering - - * src/du.c (du_files): Don't strip any trailing slash. - Rewrite so that `/' is no longer represented internally as - the empty string. - (count_entry): When appending a file name component, - account for the fact that the current path may end in `/'. - François Pinard reported that `du symlink-to-dir/' was not - equivalent to `du symlink-to-dir/.'. Now it is. - * tests/du/trailing-slash: New file/test, for the above fix. - * tests/du/Makefile.am (TESTS): Add trailing-slash. - -2002-11-23 Jim Meyering - - * src/tac.c (output): Declare some local variables to be of type size_t, - rather than `int' to avoid warnings from gcc. - -2002-11-21 Paul Eggert - - * src/ls.c (decode_switches): Use case-sensitive matching to - decode the QUOTING_STYLE environment variable. This is more - consistent with the documentation, and with --quoting-style. - -2002-11-21 Martin Buck - - * tests/sum/sysv: Export LC_ALL=C, to avoid failure when - run in a UTF locale. Report and suggested fix by Bruno Haible. - * tests/fmt/basic: Likewise. - -2002-11-17 Jim Meyering - - * configure.ac: Update via autoupdate. - Add `AM_GNU_GETTEXT_VERSION(0.11.5)'. - - * src/mv.c (movefile): Don't remove trailing slashes from SOURCE. - Reported by Hans Ginzel. - -2002-11-15 Jim Meyering - - * Makefile.cfg (gnu_rel_host): Define. - (url_dir_list): Choose from (alpha|ftp).gnu.org depending - on whether $(VERSION) looks like a major release number. - - * Makefile.maint (mail_gpg_sign_cookie): Backslash-escape `#'. - (release): Rename from `alpha'. - (alpha): Depend on release. - - * Makefile.maint (signatures): Define with ?=, so it's easy to override. - -2002-11-14 Jim Meyering - - * Makefile.maint (mail_gpg_sign_cookie): Make optional. - (announcement): Use the new variable. - - * Makefile.maint: Sync with Bison, i.e.: - (po-check): Scan .l and .y files instead of the - .c and the .h files that they generate. This fixes the bug - reported by Tim Van Holder in: - - Look for N_ as well as for _. Try to avoid matching #define for - N_ and _. - From Paul Eggert. - -2002-11-12 Jim Meyering - - * src/ls.c (HAVE_SYMLINKS): Remove unnecessary macro definition. - Replace sole use with equivalent `#ifdef S_ISLNK'. - Inconsistency reported by Dmitry V. Levin. - -2002-11-11 Jim Meyering - - * src/stat.c (usage): Transform --help items output via s/ - / /, - so that help2man produces properly formatted man pages. - Reported by Herbert Xu as Debian bug #168400. - -2002-11-10 Jim Meyering - - * src/ls.c (sighandler): Handle SIGTSTP specially. - Based on suggestions from Solar Designer and Dmitry V. Levin. - Add comments. - - * Makefile.cfg (cvs_files): Define. From autoconf. - (local_updates): Likewise. - - * src/ls.c (restore_default_color_handler, sigtstp_handler): - Remove functions. - (sighandler): New function, based on the one in sort.c. - (main): Use sigaction, if possible; otherwise signal. - Handle these signals: - SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, SIGTSTP. - Don't register our handler if the signal is already being ignored. - - * src/dd.c (interrupt_handler): Use raise, rather than kill+getpid. - * src/csplit.c (interrupt_handler): Likewise. - * src/sort.c (sighandler): Likewise. - (main): Declare `i' and `nsigs' to be unsigned, not int. - -2002-11-09 Jim Meyering - - ls --color: restore terminal text color upon signal. - * src/ls.c: Include "full-write.h" and . - (restore_default_color, restore_default_color_handler): New functions. - (sigtstp_handler, put_indicator_direct): New functions. - (main) [print_with_color]: Register signal handlers. - Patch mostly by Solar Designer and Stanislav Ievlev. - - Update from autoconf. - * Makefile.maint (AMTAR): Remove definition. - (update, cvs-update, po-update, do-po-update): New rules. - (wget-update): Update (thus renaming to cvs-update). - (automake_repo): Use anoncvs@sources.redhat.com. - -2002-11-06 Jim Meyering - - * tests/misc/Makefile.am (TESTS): Add printf-hex. - - * tests/misc/printf: Be careful to test the code in this package, - not the shell built-in function. - - * src/printf.c (print_esc): A hexadecimal escape sequence has - at most two hex. digits, not three. Reported by Padraig Brady. - (usage): Update description. - * tests/misc/printf-hex: New file/test, for the above fix. - -2002-10-07 Paul Eggert - - Add support for locale-specific size indications (e.g., - thousands-separators) and for explicit size suffixes on output. - - * doc/coreutils.texi (Block size): Say that: - This affects display format as well as block size. - Fractional block counts are rounded up. - ls file size blocksize defaults to 1. - A block size spec preceded by ' generates thousands separators. - A suffix without a preceding integer generates suffixes. - (tail invocation): 32k -> 32 KiB. - (What information is listed): ls -h is now equivalent to - ls --block-size=human, and ls -H is now equivalent to - ls --block-size=si. Displayed file size is now always affected by - --block-size. - - * lib/inttostr.c, lib/inttostr.h, lib/imaxtostr.c, lib/offtostr.c, - lib/umaxtostr.c: New files, taken from GNU tar. - - * lib/Makefile.am (libfetish_a_SOURCES): Add imaxtostr.c, offtostr.c, - umaxtostr.c. - (EXTRA_DIST): Add inttostr.c. - - * lib/human.c, lib/human.h: Rewrite to support locale-specific - notations like thousands separators. - Specify what includer of include.h must include beforehand. - (human_group_digits, human_suppress_point_zero, human_autoscale, - human_base_1024, human_SI, human_B): New enum values. - (human_readable): Rename from human_readable_inexact; put the - options before the sizes. All uses changed. The old human_readable - function has been removed; use inttostr.h instead. - (human_options): Renamed from human_block_size, with new signature - that allows block sizes up to UINTMAX_MAX. All callers changed. - - * m4/prereq.m4 (jm_PREREQ_HUMAN): Check for locale.h, localeconv, - AC_HEADER_STDBOOL. No need to check for limits.h since it's in - freestanding C89. No need to check for stdlib.h or string.h since - autoconf does this now. - - * src/cksum.c (cksum): Use primitives from inttostr.h, not - human.h, to print large numbers simply. - * src/csplit.c (handle_line_error, parse_patterns): Likewise. - * src/dd.c (print_stats, main): Likewise. - * src/df.c (print_header): Likewise. - * src/factor.c (print_factors): Likewise. - * src/ls.c (print_long_format, print_file_name_and_frills): Likewise. - * src/shred.c (dopass): Likewise. - * src/sort.c (checkfp): Likewise. - * src/sum.c (bsd_sum_file, sysv_sym_file): Likewise. - * src/tail.c (xlseek): Likewise. - * src/wc.c (write_counts, wc): Likewise. - - * src/df.c (human_output_opts): New var. - (output_block_size): Now uintmax_t, not int, to handle larger - block sizes. All uses changed. - * src/du.c: Likewise. - * src/ls.c: Likewise. - - * src/df.c (print_header): In the header line, prefer SI to human - representation if it's shorter; if neither is shorter, try to - intuit what the user would prefer. - - * src/expr.c (inttostr): Remove; use new imaxtostr library - function instead. - - * src/ls.c (file_output_block_size): New var, to distinguish - file sizes from other sizes. - (decode_switches): Set it. - - * src/shred.c (OUTPUT_BLOCK_SIZE): remove. - (dopass): When printing progress, use floor for what has been done - so far (since we should be conservative there), and ceiling for - what needs to be done (since that's what other programs use). - -2002-10-19 Jim Meyering - - * src/pinky.c (print_heading): Align TTY and Name headings. - Reported by Karl Eichwalder. - -2002-10-18 Jim Meyering - - * src/split.c (cwrite): Change type of `bytes' parameter to size_t - Remove now-useless cast. - (stdread): Remove function. - (bytes_split): Use size_t instead of int. - Use safe_read, not stdread. - (lines_split): Likewise. - Use memchr rather than a `while' loop. - (line_bytes_split): Use size_t instead of int. - Use safe_read, not stdread. - (main): Add some FIXME comments to remind me to remove casts. - - * src/system.h (ST_BLKSIZE): Correct comment describing how to - reproduce HPUX-11 cat failure. From Petter Reinholdtsen. - -2002-10-17 Jim Meyering - - Fix a problem that could make e.g., `cat' misbehave on systems which - give invalid (unreasonably large) values for stat.st_blksize. - * src/system.h (ST_BLKSIZE): Ensure that the result is in [1..4MB]. - Reported by Petter Reinholdtsen. - -2002-10-14 Jim Meyering - - Specifying a printf conversion specifer as nl's separator string - could cause nl to segfault. - * src/nl.c (build_print_fmt): Don't include separator string - in the printf format; it might contain `%'. - Use a better bound on the length of the print_fmt buffer. - (print_lineno): Print the separator here instead. - Reported by Doug Coleman. - - * tests/misc/nl: New file/tests, including a test for the above. - * tests/misc/Makefile.am (TESTS): Add nl. - - * tests/misc/split-l: New test, to make sure `split --lines=N' works. - * tests/misc/Makefile.am (TESTS): Add split-l. - -2002-10-13 Jim Meyering - - * Version 4.5.3. - - * src/du.c (usage): Tweak description of --dereference-args/-D. - - * src/du.c (count_entry): Also save cwd when dereferencing (via - --dereference-args, -D) a command-line argument. - Reported by Michal Svec. Based on a patch by Andreas Schwab. - - * src/Makefile.am (../AUTHORS): New target/rule. - -2002-10-12 Jim Meyering - - * src/paste.c (paste_parallel): Declare local, `delims_saved', to be - of type size_t, since that's the way it's used and avoids a warning. - - * src/csplit.c (struct cstring) [len]: Declare to be unsigned int, - since that's how it's always used and avoids a new warning from gcc. - (read_input): Adapt to new safe_read ABI. - - * src/cut.c (cut_fields): Add a temporary size_t variable, n_bytes, - to avoid warnings. - - * src/pinky.c (print_long_entry): fread returns size_t. - Declare local `bytes' accordingly, to avoid warning. - - tail -c +N would perform an extra read after encountering EOF - [this change is analogous (bytes vs. lines) to the one of 2002-01-27] - * src/tail.c (start_bytes): Detect EOF, inform caller. - (tail_bytes): Upon EOF in start_bytes, return immediately. - (file_lines): Reorganize to use memrchr rather than an explicit loop. - Adapt to new safe_read ABI. - -2002-10-11 Jim Meyering - - * tests/du/deref: New file/test, for the above fix. - * tests/du/Makefile.am (TESTS): Add deref. - -2002-10-10 Jim Meyering - - * tests/ln/Makefile.am (TESTS): Add target-1. - * tests/ln/target-1: New file/test, for the fix on 2002-10-08. - -2002-10-09 Jim Meyering - - * tests/cp/backup-is-src: Ensure that certain environment variables - are not set (e.g., SIMPLE_BACKUP_SUFFIX). Reported by Duncan Roe. - - * tests/tail-2/big-4gb: Mark this as an expensive test; it would - consume 4GB of disk space on systems without support for sparse files. - Fix a logic error that'd make it `cat err' even though dd didn't fail. - - * src/dircolors.hin (.jar): Fix typo: s/;3$/;31/. - Patch by steven@magelico.net, forwarded by Michael Stone. - - * tests/ls/dired: Ensure that ls produces English messages. - Patch by Alexey Vyskubov, forwarded by Michael Stone. - -2002-10-08 Dmitry V. Levin - - * src/ln.c (main): Fix target_directory parsing when n_files == 1. - -2002-10-08 Jim Meyering - - * tests/tail-2/big-4gb: Use double quotes around diagnostic. - Fix syntax in test: use =, not ==. - Reported by Bob Proulx. - Change all the rest like this: grep -lR "testing framework'" .\ - |xargs perl -pi -e 's/'\''(\$0: failure in testing framework)'\''/"$1"/' - - * src/sum.c (sysv_sum_file): Adapt to new safe_read ABI. - * src/tr.c (squeeze_filter, read_and_delete, read_and_xlate): Likewise. - * src/tac.c (save_stdin, tac_stdin_to_mem): Likewise. - * src/wc.c (wc): Likewise. - -2002-10-07 Paul Eggert - - * src/cat.c (cat): - Don't advance the write pointer past the end of the write buffer. - * src/sort.c (begfield, limfield): Likewise. - -2002-10-07 Jim Meyering - - * src/cat.c (simple_cat, cat): Adapt to new safe_read ABI. - * src/head.c (head_bytes, head_lines): Likewise. - -2002-10-06 Jim Meyering - - * src/dd.c (scanargs): Ensure that specified block sizes (specified - via ibs=N, obs=N, and bs=N) are no larger than SSIZE_MAX. - (skip, dd_copy): Adapt to new safe_read ABI. - - * Makefile.maint (signatures): Define. - (%.sig): New rule. - (announcement): Depend on $(signatures). - - * Makefile.maint (announcement): Output all URLs for detached - signatures, not just the last one from the previous loop. - -2002-10-05 Jim Meyering - - * Version 4.5.2. - - * src/remove.c (remove_entry) [ROOT_CAN_UNLINK_DIRS]: With `rm -i DIR', - don't recurse into directory, DIR. Prompted by a report from - Leonardo Milano. - - * tests/rm/i-no-r: New file/test, for the above fix. - * tests/rm/Makefile.am (TESTS): Add i-no-r. - - * tests/tail-2/big-4gb: New file/test, for the fix of 2002-09-27. - * tests/tail-2/Makefile.am (TESTS): Add big-4gb. - -2002-10-03 Jim Meyering - - * src/rm.c (AUTHORS): Mark translatable string with `N_ (...)'. - * src/df.c (AUTHORS): Likewise. - * src/du.c (AUTHORS): Likewise. - * src/tail.c (AUTHORS): Likewise. - * src/touch.c (AUTHORS): Likewise. - -2002-10-02 Jim Meyering - - * Makefile.am (SUBDIRS): Remove `old'. - (EXTRA_DIST): List the files in old/. - * configure.ac (AC_CONFIG_FILES): Remove old/* names. - Suggestion from Akim Demaille. - -2002-10-01 Jim Meyering - - * src/sys2.h (SSIZE_MAX): Define. - -2002-09-30 Jim Meyering - - * src/csplit.c: Don't include stdlib.h here. It's already included - via system.h. - -2002-09-29 Jim Meyering - - * src/tr.c (find_bracketed_repeat): Rearrange pointer/integer - expression to avoid bogus warning from gcc. - - * src/cat.c (simple_cat): Use a temporary to avoid bogus warnings. - (cat): Declare insize and outsize to be of type size_t, not int. - Rearrange pointer/integer expressions to avoid bogus warnings. - (main): Declare insize and outsize to be of type size_t, not int. - - * src/tail.c (parse_options): Give a sensible diagnostic for - an invalid byte or line count. Reported by Mikko Tuumanen. - - * src/touch.c (main): Split a long line. - - * tests/du/Makefile.am (TESTS): Add slink. - * tests/du/slink: New test for system.h change of 2002-08-31. - - In move mode, always first try to rename. Before, upon failure to - rename a directory, this code would never attempt to rename any - other file in that directory, but would thenceforth always copy. - On some systems (e.g., NetApp's OnTap-6.4), renaming a directory - may fail with EXDEV, yet renaming files within that directory to - a newly-created destination directory succeeds. - * src/copy.c (copy_internal): Remove local, move_mode; - use x->move_mode instead. Based on a patch from Tom Haynes. - -2002-09-28 Jim Meyering - - * src/split.c (FAIL_ONLY_ONE_WAY): New macro. - Factor out some duplication. - (main): Use it. - [case 'a']: Use strtoul rather than strtol to avoid compiler warnings. - - * src/sort.c (begfield, limfield): Rearrange comparisons to avoid - compiler warnings. - (fillbuf, keycompare): Cast literal `-1' to size_t in comparisons, - to avoid compiler warnings. - - * src/shred.c (dopass): Use a uintmax_t temporary to avoid bogus - compiler warnings. - - Fix things so `mkdir -p' can create very deep directories, e.g., - mkdir -p $(perl -e 'print "a/" x 40000') now works. - * src/mkdir.c (main): For --parents (-p), call make_path with the - entire directory name, so we don't ever require that file operations - like stat or chmod be performed on the entire command line argument. - * makepath.c (make_path): Restore umask *before* creating the final - component. - -2002-09-27 Andreas Schwab - - * src/tail.c (tail_bytes): Change type of bytes_remaining to off_t - to avoid overflow. Reported by Hans Lermen. - -2002-09-26 Jim Meyering - - * src/install.c (get_ids): Use strtoul, not strtol. Remove some casts. - -2002-09-25 Jim Meyering - - * src/test.c (eaccess): Change type of local `euid' from int to uid_t - and add a cast, to avoid a warning about `signed and unsigned type in - conditional expression'. - -2002-09-22 Jim Meyering - - * src/rmdir.c: Include "dirname.h", for declaration of - strip_trailing_slashes. - - * src/stat.c (PRIdMAX, PRIuMAX): Remove definitions. - Now they're defined through system.h. - - * src/cp-hash.c, src/dd.c, src/df.c, src/du.c, src/ls.c, - * src/stat.c, src/wc.c: Remove all inclusions of inttypes.h, - since it's already included from sys2.h via system.h. - - * Use automake-1.6f. Regenerate dependent files. - - * src/Makefile.am (PERL): Remove duplicate definition. - - fmt's -s, -t, -c options didn't work properly for long lines. - Since get_line may end up calling put_paragraph (for long lines), - be sure to set global, `other_indent', before it is used there. - - * src/fmt.c (set_other_indent): New function, factored out of... - (get_paragraph): ... here. Call it. - (get_line): Call set_other_indent before calling flush_paragraph, - which calls fmt_paragraph, which in turn calls put_paragraph, - which uses other_indent. - - * tests/fmt/Makefile.am (TESTS): Add long-line. - * tests/fmt/long-line: New file/test, for the above fix. - -2002-09-21 Jim Meyering - - * src/od.c: No longer include deprecated . - It was required solely for now-removed reference to BITSPERBYTE. - * src/install.c: Likewise. - Suggestion from Bruno Haible. - -2002-09-06 Andreas Schwab - - `rmdir -p dir-specified-with-trailing-slash/' would fail. - * src/rmdir.c (remove_parents): Strip trailing slashes. - -2002-09-20 Jim Meyering - - * tests/rmdir/t-slash: New file/test, for the above fix. - * tests/rmdir/Makefile.am (TESTS): Add t-slash. - - * Makefile.maint (announcement): Arrange to gpg-sign the message. - Add a URL for each detached signature file. - -2002-09-07 Bruno Haible - - * configure.ac: Add need-ngettext to AM_GNU_GETTEXT invocation. - -2002-09-18 Jim Meyering - - `od -t x8' used the wrong (`l'-prefixed) printf format. - Likewise for the o8 and u8 formats. - * src/od.c (ISPEC_TO_FORMAT): Define macro. - (decode_one_format): Use PRIdMAX, PRIoMAX, etc. for LONG_LONG. - Reported by Arun Sharma. - -2002-09-17 Jim Meyering - - * src/sys2.h (PRIdMAX, PRIoMAX, PRIuMAX, PRIxMAX): Define if necessary. - From gettext's intl/loadmsgcat.c. - - * tests/od/x8: New file/test, for the above fix. - * tests/od/Makefile.am (TESTS): Add x8. - -2002-09-15 Jim Meyering - - * Use autoconf-2.54. Regenerate dependent files. - - * src/csplit.c (get_format_width): Add cast to avoid - warning about `signed and unsigned type in conditional expression'. - -2002-09-14 Jim Meyering - - * src/who.c (print_user): Change type of local to size_t - to avoid warnings about `comparison between signed and unsigned'. - * src/ptx.c (generate_all_output): Likewise. - - * src/dd.c (main, skip): Add casts to avoid warnings about - `comparison between signed and unsigned'. - - * src/id.c (print_full_info, print_group_list): Add casts to avoid - warnings about `signed and unsigned type in conditional expression'. - - * src/md5sum.c: Change type of global, digest_hex_bytes, to size_t - to avoid warnings about `comparison between signed and unsigned'. - (split_3): Change parameter names to be readable and add comment. - Clean up the test for whether a line may be ignored. - -2002-09-13 Jim Meyering - - * src/printf.c (main): Handle leading command line argument of `--'. - Reported by Raul: DervishD - * tests/misc/printf: New file: test for the above. - * tests/misc/Makefile.am (TESTS): Add printf. - - * src/date.c (usage): Explain that %S's range of [0..60] is required -- - rather than 0..59 -- to accommodate the occasional positive leap second. - Reported by Richard Neill. - -2002-09-12 Jim Meyering - - * src/Makefile.am (nanosec_libs): Define. - (sleep_LDADD, tail_LDADD): Use it here. - - Factor nanosleep-related code into ../lib/xnanosleep.c. - * src/sleep.c: Include xnanosleep.h. - Factor out fenv.h-related code. - (timespec_subtract): Remove function. - (main): Remove code that deals with computing start and stop times - as well as the loop around nanosleep. Now that's in xnanosleep.c. - - Allow S (in --sleep-interval=S) to be a floating point value. - * src/tail.c: Include xnanosleep.h and xstrtod.h. - Move declaration of global variable, sleep_interval, to ... - (main): ...here. - (usage): Update description of --sleep-interval option. - (tail_forever): New parameter, sleep_interval. Update caller. - Use xnanosleep, rather than sleep. - (parse_options): New parameter, sleep_interval. Update caller. - Use xstrtod, now that we accept floating point values. - Prompted by a patch from Augey Mikus. - -2002-09-06 Jim Meyering - - * src/remove.c (prompt): Change comment to give a better note to - translators. From Michael Piefel. - -2002-09-02 Jim Meyering - - * README: A good problem report/patch includes diffs against - the most recent test release. - - * src/pathchk.c (NEED_PATHCONF_WRAPPER): Define. - (pathconf_wrapper): Define only if NEED_PATHCONF_WRAPPER is set. - - * src/kill.c (print_table_row): Use an unsigned type for widths - to avoid warning about comparison between signed and unsigned. - (list_signals): Likewise. - - * src/od.c (skip): Add a cast to avoid warning about comparison - between signed and unsigned. - * src/install.c (get_ids): Likewise. Also rearrange range-checking - comparisons to make them more readable. - -2002-09-01 Jim Meyering - - * Version 4.5.1. - -2002-08-31 Jim Meyering - - Symlinks were always reported as using 0 blocks. - * src/system.h (ST_NBLOCKS): Don't depend on file type. - This reverts the change of 2000-01-30. - Based on a report and patch from Neil Brown via Michael Stone. - This fixes Debian Bug#156358. - - * Most files: Change `exit (0)' to `exit (EXIT_SUCCESS)', - `exit (1)' to `exit (EXIT_FAILURE)', and - `usage (1)' to `usage (EXIT_FAILURE)'. - - * chgrp.c, chmod.c, chown.c, chroot.c, cp.c, date.c, dd.c, du.c, - * hostname.c, id.c, install.c, ln.c, mkdir.c, mkfifo.c, mknod.c, - * nice.c, pinky.c, printf.c, pwd.c, shred.c, sleep.c, stty.c, - * su.c, tac-pipe.c, tail.c, tee.c, touch.c, uname.c, uptime.c, - * users.c, who.c: Change `error (1, ...' to `error (EXIT_FAILURE, ...'. - But don't change `error (0, ...' to `error (EXIT_SUCCESS, ...', since - error never exits successfully. - -2002-08-29 Jim Meyering - - * src/remove.c (remove_cwd_entries): Use closedir (not CLOSEDIR) - when ignoring any return value. - - * src/remove.c (remove_cwd_entries): Detect and diagnose readdir - failures. On some systems (at least EMC Celerra and Solaris5.8), - this appears to be necessary. - (is_empty_dir): Likewise. Also, always close directory handle. - * src/ls.c (print_dir): Likewise. - (print_dir): Rename local variable: reading -> dirp. - Reported by Mike Coleman. - -2002-08-28 Jim Meyering - - * src/remove.c (remove_cwd_entries): Use CLOSEDIR, not closedir. - Give a diagnostic and fail if closedir fails. - -2002-08-26 Jim Meyering - - * Makefile.am (THANKS-to-translators): New rule. - (EXTRA_DIST): Add both THANKS-to-translators and THANKStt.in. - * THANKStt.in: New file. - - * src/cat.c (close_stdout_wrapper): New, kludgey, function and - file-scoped global. - (main): Register it with atexit. - Close STDOUT_FILENO, to avoid a problem when writing to - /dev/audio on at least Solaris 5.7 and 5.8 systems. - Reported by Shing-Shong Shei. - -2002-08-25 Jim Meyering - - * src/cat.c (main): Close STDIN_FILENO rather than a literal `0'. - * src/tac.c (main): Likewise. - * src/tail.c (main): Likewise. - * src/tee.c (main): Likewise. - * src/tr.c (main): Likewise. - * src/wc.c (main): Likewise. - -2002-08-20 Jim Meyering - - * tests/mv/setup: Rewrite not to use `: ${VAR=not_set}' paradigm. - -2002-08-10 Paul Eggert - - * src/nohup.sh: Don't use "exec --"; it's not portable and - shouldn't be needed. - -2002-08-09 Jim Meyering - - * src/pr.c (main): Don't ignore -COLUMN if it's the last option. - (usage): Clarify help text for the -COLUMN option. - Patch by Padraig Brady. - * tests/pr/Test.pm [col-last]: New test for the above. - - * configure.ac: Start with version 4.5.1, chosen so that it's larger - than the latest version numbers of the component packages. - - * man/Makefile.am (check-x-vs-1): Set and export PATH so we use - programs in ../src. - -2002-08-08 Jim Meyering - - * src/date.c: Guard inclusion of with - `#if HAVE_LANGINFO_CODESET', not `#if HAVE_LANGINFO_H'. - * src/sort.c: Likewise. - Patch by GOTO Masanori. - -2002-08-05 Paul Eggert - - Fix some minor time-related bugs with POSIX time arguments. - Some valid time stamps were being rejected (notably -1, and - time stamps before 1900 on 64-bit hosts). And some invalid - time stamps were being accepted, e.g. September 31. - - * src/date.c (main): Adjust to posixtime signature change. - * src/touch.c (main): Likewise. Remove unnecessary initialization. - Use localtime, not posixtm, to warn about obsolete "touch". - -2002-08-05 Jim Meyering - - * tests/misc/Makefile.am (TESTS): Add nice and pathchk1. - -2002-08-04 Jim Meyering - - * src/Makefile.am (check-README): New target/rule. - (check): Depend on it. - - * configure.ac (AC_CONFIG_FILES): Add old/Makefile and old/*/Makefile. - -2002-08-03 Jim Meyering - - * Makefile.am (SUBDIRS): Add old. - * old/: New directory, containing legacy ChangeLog* and NEWS files - from the fileutils, sh-utils, and textutils packages. - - * src/Makefile.am (AM_INSTALLCHECK_STD_OPTIONS_EXEMPT): Set to false. - -2002-08-02 Paul Eggert - - * NEWS, doc/coreutils.texi: uniq now obeys LC_COLLATE. - - * src/uniq.c: Include hard-locale.h, xmemcoll.h. - (hard_LC_COLLATE): New var. - (different): Args are now char *, not const char *. - Use xmemcoll instead of memcmp to compare lines, so that - LC_COLLATE has effect. However, use memcmp if it is an - easy locale. - (check_file): Do not include newline in comparison, so that - xmemcoll has a byte to stomp on temporarily. - (main): Set hard_LC_COLLATE. - -2002-07-29 Jim Meyering - - * Makefile.am (SUBDIRS): Remove djgpp, for now. - -2002-07-20 Jim Meyering - - * Makefile.am (false.c): Convert only the final EXIT_SUCCESS - into EXIT_FAILURE. Otherwise, false --help and false --version - would fail. - -2002-07-08 Jim Meyering - - * src/Makefile.am (uninstall-local): Search for @GNU_PACKAGE@, - rather than the hard-coded `sh-utils'. - -2002-07-01 Jim Meyering - - * configure.ac: Merge the three files from fileutils, - textutils, and sh-utils. - * Makefile.am: Likewise. - * src/Makefile.am: Likewise. diff --git a/contrib/gnu-sort/INSTALL b/contrib/gnu-sort/INSTALL deleted file mode 100644 index 54caf7c190f2..000000000000 --- a/contrib/gnu-sort/INSTALL +++ /dev/null @@ -1,229 +0,0 @@ -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software -Foundation, Inc. - - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' -for details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' cannot figure out -automatically, but needs to determine by the type of machine the package -will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints -a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - - Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -will cause the specified gcc to be used as the C compiler (unless it is -overridden in the site shell script). - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/contrib/gnu-sort/NEWS b/contrib/gnu-sort/NEWS deleted file mode 100644 index 31f459bd70de..000000000000 --- a/contrib/gnu-sort/NEWS +++ /dev/null @@ -1,904 +0,0 @@ -GNU coreutils NEWS -*- outline -*- - -* Major changes in release 5.3.0 (2004-03-17) [unstable] - -** Bug fixes - - rm (without -f) no longer hangs when attempting to remove a symlink - to a file on an off-line NFS-mounted partition. - - cut's --output-delimiter=D option works with abutting byte ranges. - - rm no longer gets a failed assertion under some unusual conditions. - - Several fixes to chgrp and chown for compatibility with POSIX and BSD: - - Do not affect symbolic links by default. - Now, operate on whatever a symbolic points to, instead. - To get the old behavior, use --no-dereference (-h). - - --dereference now works, even when the specified owner - and/or group match those of an affected symlink. - - Check for incompatible options. When -R and --dereference are - both used, then either -H or -L must also be used. When -R and -h - are both used, then -P must be in effect. - - -H, -L, and -P have no effect unless -R is also specified. - If -P and -R are both specified, -h is assumed. - - Do not optimize away the chown() system call when the file's owner - and group already have the desired value. This optimization was - incorrect, as it failed to update the last-changed time and reset - special permission bits, as POSIX requires. - - Do not report an error if the owner or group of a - recursively-encountered symbolic link cannot be updated because - the file system does not support it. - - md5sum and sha1sum now report an error when given so many input - lines that their line counter overflows, instead of silently - reporting incorrect results. - - rm no longer requires read access to the current directory. - - "sort -o -" now writes to a file named "-" instead of to standard - output; POSIX requires this. - - tail -f no longer mishandles pipes and fifos. With no operands, - tail now ignores -f if standard input is a pipe, as POSIX requires. - - For some types of errors (e.g., read-only file system, I/O error) - when first encountering a directory, `rm -r' would mistakenly fail - to remove files under that directory. - - If d/x is a directory and x a file, "ln x d/" now reports an error - instead of incorrectly creating a link to d/x/x. - - Fixes for "nice": - - If it fails to lower the nice value due to lack of permissions, - it goes ahead and runs the command anyway, as POSIX requires. - - It no longer incorrectly reports an error if the current nice - value happens to be -1. - - It no longer assumes that nice values range from -20 through 19. - - It now consistently adjusts out-of-range nice values to the - closest values in range; formerly it sometimes reported an error. - - ptx now diagnoses invalid values for its --width=N (-w) - and --gap-size=N (-g) options. - - tee now exits when it gets a SIGPIPE signal, as POSIX requires. - To get tee's old behavior, use the shell command "(trap '' PIPE; tee)". - Also, "tee -" now writes to standard output instead of to a file named "-". - - ls no longer segfaults on systems for which SIZE_MAX != (size_t) -1 - - echo now conforms to POSIX better. It supports the \0ooo syntax for - octal escapes, and \c now terminates printing immediately. If - POSIXLY_CORRECT is set and the first argument is not "-n", echo now - outputs all option-like arguments instead of treating them as options. - - printf has several changes: - - It now uses 'intmax_t' (not 'long int') to format integers, so it - can now format 64-bit integers on most modern hosts. - - On modern hosts it now supports the C99-inspired %a, %A, %F conversion - specs, the "'" and "0" flags, and the ll, j, t, and z length modifiers - (this is compatible with recent Bash versions). - - The printf command now rejects invalid conversion specifications - like %#d, instead of relying on undefined behavior in the underlying - printf function. - - who now prints user names in full instead of truncating them after 8 bytes. - -** New features - - For efficiency, `sort -m' no longer copies input to a temporary file - merely because the input happens to come from a pipe. As a result, - some relatively-contrived examples like `cat F | sort -m -o F - G' - are no longer safe, as `sort' might start writing F before `cat' is - done reading it. This problem cannot occur unless `-m' is used. - - When outside the default POSIX locale, the 'who' and 'pinky' - commands now output time stamps like "2004-06-21 13:09" instead of - the traditional "Jun 21 13:09". - - pwd now works even when run from a working directory whose name - is longer than PATH_MAX. - - cp, install, ln, and mv have a new --no-target-directory (-T) option, - and -t is now a short name for their --target-directory option. - - cp -pu and mv -u (when copying) now don't bother to update the - destination if the resulting time stamp would be no newer than the - preexisting time stamp. This saves work in the common case when - copying or moving multiple times to the same destination in a file - system with a coarse time stamp resolution. - - dd has new conversions for the conv= option: - - nocreat do not create the output file - excl fail if the output file already exists - fdatasync physically write output file data before finishing - fsync likewise, but also write metadata - - dd has new iflag= and oflag= options with the following flags: - - append append mode (makes sense for output file only) - direct use direct I/O for data - dsync use synchronized I/O for data - sync likewise, but also for metadata - nonblock use non-blocking I/O - nofollow do not follow symlinks - - stty now provides support (iutf8) for setting UTF-8 input mode. - - With stat, a specified format is no longer automatically newline terminated. - If you want a newline at the end of your output, append `\n' to the format - string. - - 'df', 'du', and 'ls' now take the default block size from the - BLOCKSIZE environment variable if the BLOCK_SIZE, DF_BLOCK_SIZE, - DU_BLOCK_SIZE, and LS_BLOCK_SIZE environment variables are not set. - Unlike the other variables, though, BLOCKSIZE does not affect - values like 'ls -l' sizes that are normally displayed as bytes. - This new behavior is for compatibility with BSD. - - du accepts a new option --files0-from=FILE, where FILE contains a - list of NUL-terminated file names. - - `date -d' and `touch -d' now accept integer counts of seconds since - 1970 when prefixed by `@'. For example, `@321' represents - 1970-01-01 00:05:21 UTC. - - `date -d', `date -f' and `touch -d' now handle fractional time - stamps like 2004-02-27 14:19:13.489392193. - - `date' has a new option --iso-8601=ns that outputs - nanosecond-resolution time stamps. - - echo -e '\xHH' now outputs a byte whose hexadecimal value is HH, - for compatibility with bash. - - In the following cases POSIX allows the default GNU behavior, - so when POSIXLY_CORRECT is set: - - false, printf, true, unlink, and yes all support --help and --option. - ls supports TABSIZE. - pr no longer depends on LC_TIME for the date format in non-POSIX locales. - printf supports \u, \U, \x. - tail supports two or more files when using the obsolete option syntax. - - The usual `--' operand is now supported by chroot, hostid, hostname, - pwd, sync, and yes. - - The stat option --filesystem has been renamed to --file-system, for - consistency with POSIX "file system" and with cp and du --one-file-system. - -** Removed features - - tail's undocumented --max-consecutive-size-changes option has been removed. - -* Major changes in release 5.2.1 (2004-03-12) [stable] - -** Bug fixes - - mv could mistakenly fail to preserve hard links when moving two - or more arguments between partitions. - - `cp --sparse=always F /dev/hdx' no longer tries to use lseek to create - holes in the destination. - - nohup now sets the close-on-exec flag for its copy of the stderr file - descriptor. This avoids some nohup-induced hangs. For example, before - this change, if you ran `ssh localhost', then `nohup sleep 600 /dev/null takes about one hour - on a 1.6 GHz Athlon 2000 XP. Now it can output 2^53-1 numbers before - misbehaving. - -* Major changes in release 5.1.2 (2004-01-25): - -** Bug fixes - - rmdir -p exits with status 1 on error; formerly it sometimes exited - with status 0 when given more than one argument. - - nohup now always exits with status 127 when it finds an error, - as POSIX requires; formerly it sometimes exited with status 1. - - Several programs (including cut, date, dd, env, hostname, nl, pr, - stty, and tr) now always exit with status 1 when they find an error; - formerly they sometimes exited with status 2. - - factor no longer reports a usage error if stdin has the wrong format. - - paste no longer infloops on ppc systems (bug introduced in 5.1.1) - - -* Major changes in release 5.1.1 (2004-01-17): - -** Configuration option - - You can select the default level of POSIX conformance at configure-time, - e.g., by ./configure DEFAULT_POSIX2_VERSION=199209 - -** Bug fixes - - fold -s works once again on systems with differing sizes for int - and size_t (bug introduced in 5.1.0) - -** New features - - touch -r now specifies the origin for any relative times in the -d - operand, if both options are given. For example, "touch -r FOO -d - '-5 seconds' BAR" sets BAR's modification time to be five seconds - before FOO's. - - join: The obsolete options "-j1 FIELD", "-j2 FIELD", and - "-o LIST1 LIST2..." are no longer supported on POSIX 1003.1-2001 systems. - Portable scripts should use "-1 FIELD", "-2 FIELD", and - "-o LIST1,LIST2..." respectively. If join was compiled on a - POSIX 1003.1-2001 system, you may enable the old behavior - by setting _POSIX2_VERSION=199209 in your environment. - - -* Major changes in release 5.1.0 (2003-12-21): - -** New features - - chgrp, chmod, and chown can now process (with -R) hierarchies of virtually - unlimited depth. Before, they would fail to operate on any file they - encountered with a relative name of length PATH_MAX (often 4096) or longer. - - chgrp, chmod, chown, and rm accept the new options: - --preserve-root, --no-preserve-root (default) - - chgrp and chown now accept POSIX-mandated -L, -H, and -P options - - du can now process hierarchies of virtually unlimited depth. - Before, du was limited by the user's stack size and it would get a - stack overflow error (often a segmentation fault) when applied to - a hierarchy of depth around 30,000 or larger. - - du works even when run from an inaccessible directory - - du -D now dereferences all symlinks specified on the command line, - not just the ones that reference directories - - du now accepts -P (--no-dereference), for compatibility with du - of NetBSD and for consistency with e.g., chown and chgrp - - du's -H option will soon have the meaning required by POSIX - (--dereference-args, aka -D) rather then the current meaning of --si. - Now, using -H elicits a warning to that effect. - - When given -l and similar options, ls now adjusts the output column - widths to fit the data, so that output lines are shorter and have - columns that line up better. This may adversely affect shell - scripts that expect fixed-width columns, but such shell scripts were - not portable anyway, even with old GNU ls where the columns became - ragged when a datum was too wide. - - du accepts a new option, -0/--null, to make it produce NUL-terminated - output lines - -** Bug fixes - - printf, seq, tail, and sleep now parse floating-point operands - and options in the C locale. POSIX requires this for printf. - - od -c -w9999999 no longer segfaults - - csplit no longer reads from freed memory (dumping core on some systems) - - csplit would mistakenly exhaust virtual memory in some cases - - ls --width=N (for very large N) is no longer subject to an address - arithmetic bug that could result in bounds violations. - - ls --width=N (with -x or -C) no longer allocates more space - (potentially much more) than necessary for a given directory. - - dd `unblock' and `sync' may now be combined (e.g., dd conv=unblock,sync) - -* Major changes in release 5.0.91 (2003-09-08): - -** New features - - date accepts a new option --rfc-2822, an alias for --rfc-822. - - split accepts a new option -d or --numeric-suffixes. - - cp, install, mv, and touch now preserve microsecond resolution on - file timestamps, on platforms that have the 'utimes' system call. - Unfortunately there is no system call yet to preserve file - timestamps to their full nanosecond resolution; microsecond - resolution is the best we can do right now. - - sort now supports the zero byte (NUL) as a field separator; use -t '\0'. - The -t '' option, which formerly had no effect, is now an error. - - sort option order no longer matters for the options -S, -d, -i, -o, and -t. - Stronger options override weaker, and incompatible options are diagnosed. - - `sha1sum --check' now accepts the BSD format for SHA1 message digests - in addition to the BSD format for MD5 ones. - - who -l now means `who --login', not `who --lookup', per POSIX. - who's -l option has been eliciting an unconditional warning about - this impending change since sh-utils-2.0.12 (April 2002). - -** Bug fixes - - Mistakenly renaming a file onto itself, e.g., via `mv B b' when `B' is - the same directory entry as `b' no longer destroys the directory entry - referenced by both `b' and `B'. Note that this would happen only on - file systems like VFAT where two different names may refer to the same - directory entry, usually due to lower->upper case mapping of file names. - Now, the above can happen only on file systems that perform name mapping and - that support hard links (stat.st_nlink > 1). This mitigates the problem - in two ways: few file systems appear to be affected (hpfs and ntfs are), - when the bug is triggered, mv no longer removes the last hard link to a file. - *** ATTENTION ***: if you know how to distinguish the following two cases - without writing to the file system in question, please let me know: - 1) B and b refer to the same directory entry on a file system like NTFS - (B may well have a link count larger than 1) - 2) B and b are hard links to the same file - - stat no longer overruns a buffer for format strings ending in `%' - - fold -s -wN would infloop for N < 8 with TABs in the input. - E.g., this would not terminate: printf 'a\t' | fold -w2 -s - - `split -a0', although of questionable utility, is accepted once again. - - `df DIR' used to hang under some conditions on OSF/1 5.1. Now it doesn't. - - seq's --width (-w) option now works properly even when the endpoint - requiring the larger width is negative and smaller than the other endpoint. - - seq's default step is 1, even if LAST < FIRST. - - paste no longer mistakenly outputs 0xFF bytes for a nonempty input file - without a trailing newline. - - `tail -n0 -f FILE' and `tail -c0 -f FILE' no longer perform what amounted - to a busy wait, rather than sleeping between iterations. - - tail's long-undocumented --allow-missing option now elicits a warning - - -* Major changes in release 5.0.90 (2003-07-29): - -** New features - - sort is now up to 30% more CPU-efficient in some cases - - `test' is now more compatible with Bash and POSIX: - - `test -t', `test --help', and `test --version' now silently exit - with status 0. To test whether standard output is a terminal, use - `test -t 1'. To get help and version info for `test', use - `[ --help' and `[ --version'. - - `test' now exits with status 2 (not 1) if there is an error. - - wc count field widths now are heuristically adjusted depending on the input - size, if known. If only one count is printed, it is guaranteed to - be printed without leading spaces. - - Previously, wc did not align the count fields if POSIXLY_CORRECT was set, - but POSIX did not actually require this undesirable behavior, so it - has been removed. - -** Bug fixes - - kill no longer tries to operate on argv[0] (introduced in 5.0.1) - Why wasn't this noticed? Although many tests use kill, none of - them made an effort to avoid using the shell's built-in kill. - - `[' invoked with no arguments no longer evokes a segfault - - rm without --recursive (aka -r or -R) no longer prompts regarding - unwritable directories, as required by POSIX. - - uniq -c now uses a SPACE, not a TAB between the count and the - corresponding line, as required by POSIX. - - expr now exits with status 2 if the expression is syntactically valid, - and with status 3 if an error occurred. POSIX requires this. - - expr now reports trouble if string comparison fails due to a collation error. - - split now generates suffixes properly on EBCDIC hosts. - - split -a0 now works, as POSIX requires. - - `sort --version' and `sort --help' fail, as they should - when their output is redirected to /dev/full. - - `su --version > /dev/full' now fails, as it should. - -** Fewer arbitrary limitations - - cut requires 97% less memory when very large field numbers or - byte offsets are specified. - - -* Major changes in release 5.0.1 (2003-07-15): - -** New programs -- new program: `[' (much like `test') - -** New features -- head now accepts --lines=-N (--bytes=-N) to print all but the - N lines (bytes) at the end of the file -- md5sum --check now accepts the output of the BSD md5sum program, e.g., - MD5 (f) = d41d8cd98f00b204e9800998ecf8427e -- date -d DATE can now parse a DATE string like May-23-2003 -- chown: `.' is no longer recognized as a separator in the OWNER:GROUP - specifier on POSIX 1003.1-2001 systems. If chown *was not* compiled - on such a system, then it still accepts `.', by default. If chown - was compiled on a POSIX 1003.1-2001 system, then you may enable the - old behavior by setting _POSIX2_VERSION=199209 in your environment. -- chown no longer tries to preserve set-user-ID and set-group-ID bits; - on some systems, the chown syscall resets those bits, and previous - versions of the chown command would call chmod to restore the original, - pre-chown(2) settings, but that behavior is problematic. - 1) There was a window whereby a malicious user, M, could subvert a - chown command run by some other user and operating on files in a - directory where M has write access. - 2) Before (and even now, on systems with chown(2) that doesn't reset - those bits), an unwary admin. could use chown unwittingly to create e.g., - a set-user-ID root copy of /bin/sh. - -** Bug fixes -- chown --dereference no longer leaks a file descriptor per symlink processed -- `du /' once again prints the `/' on the last line -- split's --verbose option works once again [broken in 4.5.10 and 5.0] -- tail -f is no longer subject to a race condition that could make it - delay displaying the last part of a file that had stopped growing. That - bug could also make tail -f give an unwarranted `file truncated' warning. -- du no longer runs out of file descriptors unnecessarily -- df and `readlink --canonicalize' no longer corrupt the heap on - non-glibc, non-solaris systems -- `env -u UNSET_VARIABLE' no longer dumps core on non-glibc systems -- readlink's --canonicalize option now works on systems like Solaris that - lack the canonicalize_file_name function but do have resolvepath. -- mv now removes `a' in this example on all systems: touch a; ln a b; mv a b - This behavior is contrary to POSIX (which requires that the mv command do - nothing and exit successfully), but I suspect POSIX will change. -- date's %r format directive now honors locale settings -- date's `-' (no-pad) format flag now affects the space-padded-by-default - conversion specifiers, %e, %k, %l -- fmt now diagnoses invalid obsolescent width specifications like `-72x' -- fmt now exits nonzero when unable to open an input file -- tsort now fails when given an odd number of input tokens, - as required by POSIX. Before, it would act as if the final token - appeared one additional time. - -** Fewer arbitrary limitations -- tail's byte and line counts are no longer limited to OFF_T_MAX. - Now the limit is UINTMAX_MAX (usually 2^64). -- split can now handle --bytes=N and --lines=N with N=2^31 or more. - -** Portability -- `kill -t' now prints signal descriptions (rather than `?') on systems - like Tru64 with __sys_siglist but no strsignal function. -- stat.c now compiles on Ultrix systems -- sleep now works on AIX systems that lack support for clock_gettime -- rm now works around Darwin6.5's broken readdir function - Before `rm -rf DIR' would fail to remove all files in DIR - if there were more than 338. - -* Major changes in release 5.0 (2003-04-02): -- false --help now exits nonzero - -[4.5.12] -* printf no longer treats \x specially when POSIXLY_CORRECT is set -* printf avoids buffer overrun with format ending in a backslash and -* printf avoids buffer overrun with incomplete conversion specifier -* printf accepts multiple flags in a single conversion specifier - -[4.5.11] -* seq no longer requires that a field width be specified -* seq no longer fails when given a field width of `0' -* seq now accepts ` ' and `'' as valid format flag characters -* df now shows a HOSTNAME: prefix for each remote-mounted file system on AIX 5.1 -* portability tweaks for HP-UX, AIX 5.1, DJGPP - -[4.5.10] -* printf no longer segfaults for a negative field width or precision -* shred now always enables --exact for non-regular files -* du no longer lists hard-linked files more than once -* du no longer dumps core on some systems due to `infinite' recursion - via nftw's use of the buggy replacement function in getcwd.c -* portability patches for a few vendor compilers and 64-bit systems -* du -S *really* now works like it did before the change in 4.5.5 - -[4.5.9] -* du no longer truncates file sizes or sums to fit in 32-bit size_t -* work around Linux kernel bug in getcwd (fixed in 2.4.21-pre4), so that pwd - now fails if the name of the working directory is so long that getcwd - truncates it. Before it would print the truncated name and exit successfully. -* `df /some/mount-point' no longer hangs on a GNU libc system when another - hard-mounted NFS file system (preceding /some/mount-point in /proc/mounts) - is inaccessible. -* rm -rf now gives an accurate diagnostic when failing to remove a file - under certain unusual conditions -* mv and `cp --preserve=links' now preserve multiple hard links even under - certain unusual conditions where they used to fail - -[4.5.8] -* du -S once again works like it did before the change in 4.5.5 -* stat accepts a new file format, %B, for the size of each block reported by %b -* du accepts new option: --apparent-size -* du --bytes (-b) works the same way it did in fileutils-3.16 and before -* du reports proper sizes for directories (not zero) (broken in 4.5.6 or 4.5.7) -* df now always displays under `Filesystem', the device file name - corresponding to the listed mount point. Before, for a block- or character- - special file command line argument, df would display that argument. E.g., - `df /dev/hda' would list `/dev/hda' as the `Filesystem', rather than say - /dev/hda3 (the device on which `/' is mounted), as it does now. -* test now works properly when invoked from a set user ID or set group ID - context and when testing access to files subject to alternate protection - mechanisms. For example, without this change, a set-UID program that invoked - `test -w F' (to see if F is writable) could mistakenly report that it *was* - writable, even though F was on a read-only file system, or F had an ACL - prohibiting write access, or F was marked as immutable. - -[4.5.7] -* du would fail with more than one DIR argument when any but the last did not - contain a slash (due to a bug in ftw.c) - -[4.5.6] -* du no longer segfaults on Solaris systems (fixed heap-corrupting bug in ftw.c) -* du --exclude=FILE works once again (this was broken by the rewrite for 4.5.5) -* du no longer gets a failed assertion for certain hierarchy lay-outs - involving hard-linked directories -* `who -r' no longer segfaults when using non-C-locale messages -* df now displays a mount point (usually `/') for non-mounted - character-special and block files - -[4.5.5] -* ls --dired produces correct byte offset for file names containing - nonprintable characters in a multibyte locale -* du has been rewritten to use a variant of GNU libc's ftw.c -* du now counts the space associated with a directory's directory entry, - even if it cannot list or chdir into that subdirectory. -* du -S now includes the st_size of each entry corresponding to a subdirectory -* rm on FreeBSD can once again remove directories from NFS-mounted file systems -* ls has a new option --dereference-command-line-symlink-to-dir, which - corresponds to the new default behavior when none of -d, -l -F, -H, -L - has been specified. -* ls dangling-symlink now prints `dangling-symlink'. - Before, it would fail with `no such file or directory'. -* ls -s symlink-to-non-dir and ls -i symlink-to-non-dir now print - attributes of `symlink', rather than attributes of their referents. -* Fix a bug introduced in 4.5.4 that made it so that ls --color would no - longer highlight the names of files with the execute bit set when not - specified on the command line. -* shred's --zero (-z) option no longer gobbles up any following argument. - Before, `shred --zero file' would produce `shred: missing file argument', - and worse, `shred --zero f1 f2 ...' would appear to work, but would leave - the first file untouched. -* readlink: new program -* cut: new feature: when used to select ranges of byte offsets (as opposed - to ranges of fields) and when --output-delimiter=STRING is specified, - output STRING between ranges of selected bytes. -* rm -r can no longer be tricked into mistakenly reporting a cycle. -* when rm detects a directory cycle, it no longer aborts the entire command, - but rather merely stops processing the affected command line argument. - -[4.5.4] -* cp no longer fails to parse options like this: --preserve=mode,ownership -* `ls --color -F symlink-to-dir' works properly -* ls is much more efficient on directories with valid dirent.d_type. -* stty supports all baud rates defined in linux-2.4.19. -* `du symlink-to-dir/' would improperly remove the trailing slash -* `du ""' would evoke a bounds violation. -* In the unlikely event that running `du /' resulted in `stat ("/", ...)' - failing, du would give a diagnostic about `' (empty string) rather than `/'. -* printf: a hexadecimal escape sequence has at most two hex. digits, not three. -* The following features have been added to the --block-size option - and similar environment variables of df, du, and ls. - - A leading "'" generates numbers with thousands separators. - For example: - $ ls -l --block-size="'1" file - -rw-rw-r-- 1 eggert src 47,483,707 Sep 24 23:40 file - - A size suffix without a leading integer generates a suffix in the output. - For example: - $ ls -l --block-size="K" - -rw-rw-r-- 1 eggert src 46371K Sep 24 23:40 file -* ls's --block-size option now affects file sizes in all cases, not - just for --block-size=human-readable and --block-size=si. Fractional - sizes are now always rounded up, for consistency with df and du. -* df now displays the block size using powers of 1000 if the requested - block size seems to be a multiple of a power of 1000. -* nl no longer gets a segfault when run like this `yes|nl -s%n' - -[4.5.3] -* du --dereference-args (-D) no longer fails in certain cases -* `ln --target-dir=DIR' no longer fails when given a single argument - -[4.5.2] -* `rm -i dir' (without --recursive (-r)) no longer recurses into dir -* `tail -c N FILE' now works with files of size >= 4GB -* `mkdir -p' can now create very deep (e.g. 40,000-component) directories -* rmdir -p dir-with-trailing-slash/ no longer fails -* printf now honors the `--' command line delimiter -* od's 8-byte formats x8, o8, and u8 now work -* tail now accepts fractional seconds for its --sleep-interval=S (-s) option - -[4.5.1] -* du and ls now report sizes of symbolic links (before they'd always report 0) -* uniq now obeys the LC_COLLATE locale, as per POSIX 1003.1-2001 TC1. - -======================================================================== -Here are the NEWS entries made from fileutils-4.1 until the -point at which the packages merged to form the coreutils: - -[4.1.11] -* `rm symlink-to-unwritable' doesn't prompt [introduced in 4.1.10] -[4.1.10] -* rm once again gives a reasonable diagnostic when failing to remove a file - owned by someone else in a sticky directory [introduced in 4.1.9] -* df now rounds all quantities up, as per POSIX. -* New ls time style: long-iso, which generates YYYY-MM-DD HH:MM. -* Any time style can be preceded by "posix-"; this causes "ls" to - use traditional timestamp format when in the POSIX locale. -* The default time style is now posix-long-iso instead of posix-iso. - Set TIME_STYLE="posix-iso" to revert to the behavior of 4.1.1 thru 4.1.9. -* `rm dangling-symlink' doesn't prompt [introduced in 4.1.9] -* stat: remove support for --secure/-s option and related %S and %C format specs -* stat: rename --link/-l to --dereference/-L. - The old options will continue to work for a while. -[4.1.9] -* rm can now remove very deep hierarchies, in spite of any limit on stack size -* new programs: link, unlink, and stat -* New ls option: --author (for the Hurd). -* `touch -c no-such-file' no longer fails, per POSIX -[4.1.8] -* mv no longer mistakenly creates links to preexisting destination files - that aren't moved -[4.1.7] -* rm: close a hole that would allow a running rm process to be subverted -[4.1.6] -* New cp option: --copy-contents. -* cp -r is now equivalent to cp -R. Use cp -R -L --copy-contents to get the - traditional (and rarely desirable) cp -r behavior. -* ls now accepts --time-style=+FORMAT, where +FORMAT works like date's format -* The obsolete usage `touch [-acm] MMDDhhmm[YY] FILE...' is no longer - supported on systems conforming to POSIX 1003.1-2001. Use touch -t instead. -* cp and inter-partition mv no longer give a misleading diagnostic in some - unusual cases -[4.1.5] -* cp -r no longer preserves symlinks -* The block size notation is now compatible with SI and with IEC 60027-2. - For example, --block-size=1MB now means --block-size=1000000, - whereas --block-size=1MiB now means --block-size=1048576. - A missing `B' (e.g. `1M') has the same meaning as before. - A trailing `B' now means decimal, not binary; this is a silent change. - The nonstandard `D' suffix (e.g. `1MD') is now obsolescent. -* -H or --si now outputs the trailing 'B', for consistency with the above. -* Programs now output trailing 'K' (not 'k') to mean 1024, as per IEC 60027-2. -* New df, du short option -B is short for --block-size. -* You can omit an integer `1' before a block size suffix, - e.g. `df -BG' is equivalent to `df -B 1G' and to `df --block-size=1G'. -* The following options are now obsolescent, as their names are - incompatible with IEC 60027-2: - df, du: -m or --megabytes (use -BM or --block-size=1M) - df, du, ls: --kilobytes (use --block-size=1K) -[4.1.4] -* df --local no longer lists smbfs file systems whose name starts with // -* dd now detects the Linux/tape/lseek bug at run time and warns about it. -[4.1.3] -* ls -R once again outputs a blank line between per-directory groups of files. - This was broken by the cycle-detection change in 4.1.1. -* dd once again uses `lseek' on character devices like /dev/mem and /dev/kmem. - On systems with the linux kernel (at least up to 2.4.16), dd must still - resort to emulating `skip=N' behavior using reads on tape devices, because - lseek has no effect, yet appears to succeed. This may be a kernel bug. -[4.1.2] -* cp no longer fails when two or more source files are the same; - now it just gives a warning and doesn't copy the file the second time. - E.g., cp a a d/ produces this: - cp: warning: source file `a' specified more than once -* chmod would set the wrong bit when given symbolic mode strings like - these: g=o, o=g, o=u. E.g., `chmod a=,o=w,ug=o f' would give a mode - of --w-r---w- rather than --w--w--w-. -[4.1.1] -* mv (likewise for cp), now fails rather than silently clobbering one of - the source files in the following example: - rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c -* ls -R detects directory cycles, per POSIX. It warns and doesn't infloop. -* cp's -P option now means the same as --no-dereference, per POSIX. - Use --parents to get the old meaning. -* When copying with the -H and -L options, cp can preserve logical - links between source files with --preserve=links -* cp accepts new options: - --preserve[={mode,ownership,timestamps,links,all}] - --no-preserve={mode,ownership,timestamps,links,all} -* cp's -p and --preserve options remain unchanged and are equivalent - to `--preserve=mode,ownership,timestamps' -* mv and cp accept a new option: --reply={yes,no,query}; provides a consistent - mechanism to control whether one is prompted about certain existing - destination files. Note that cp's and mv's -f options don't have the - same meaning: cp's -f option no longer merely turns off `-i'. -* remove portability limitations (e.g., PATH_MAX on the Hurd, fixes for - 64-bit systems) -* mv now prompts before overwriting an existing, unwritable destination file - when stdin is a tty, unless --force (-f) is specified, as per POSIX. -* mv: fix the bug whereby `mv -uf source dest' would delete source, - even though it's older than dest. -* chown's --from=CURRENT_OWNER:CURRENT_GROUP option now works -* cp now ensures that the set-user-ID and set-group-ID bits are cleared for - the destination file when when copying and not preserving permissions. -* `ln -f --backup k k' gives a clearer diagnostic -* ls no longer truncates user names or group names that are longer - than 8 characters. -* ls's new --dereference-command-line option causes it to dereference - symbolic links on the command-line only. It is the default unless - one of the -d, -F, or -l options are given. -* ls -H now means the same as ls --dereference-command-line, as per POSIX. -* ls -g now acts like ls -l, except it does not display owner, as per POSIX. -* ls -n now implies -l, as per POSIX. -* ls can now display dates and times in one of four time styles: - - - The `full-iso' time style gives full ISO-style time stamps like - `2001-05-14 23:45:56.477817180 -0700'. - - The 'iso' time style gives ISO-style time stamps like '2001-05-14 ' - and '05-14 23:45'. - - The 'locale' time style gives locale-dependent time stamps like - 'touko 14 2001' and 'touko 14 23:45' (in a Finnish locale). - - The 'posix-iso' time style gives traditional POSIX-locale - time stamps like 'May 14 2001' and 'May 14 23:45' unless the user - specifies a non-POSIX locale, in which case it uses ISO-style dates. - This is the default. - - You can specify a time style with an option like --time-style='iso' - or with an environment variable like TIME_STYLE='iso'. GNU Emacs 21 - and later can parse ISO dates, but older Emacs versions cannot, so - if you are using an older version of Emacs outside the default POSIX - locale, you may need to set TIME_STYLE="locale". - -* --full-time is now an alias for "-l --time-style=full-iso". - - -======================================================================== -Here are the NEWS entries made from sh-utils-2.0 until the -point at which the packages merged to form the coreutils: - - [2.0.15] -* date no longer accepts e.g., September 31 in the MMDDhhmm syntax -* fix a bug in this package's .m4 files and in configure.ac - [2.0.14] -* nohup's behavior is changed as follows, to conform to POSIX 1003.1-2001: - - nohup no longer adjusts scheduling priority; use "nice" for that. - - nohup now redirects stderr to stdout, if stderr is not a terminal. - - nohup exit status is now 126 if command was found but not invoked, - 127 if nohup failed or if command was not found. - [2.0.13] -* uname and uptime work better on *BSD systems -* pathchk now exits nonzero for a path with a directory component - that specifies a non-directory - [2.0.12] -* kill: new program -* who accepts new options: --all (-a), --boot (-b), --dead (-d), --login, - --process (-p), --runlevel (-r), --short (-s), --time (-t), --users (-u). - The -u option now produces POSIX-specified results and is the same as - the long option `--users'. --idle is no longer the same as -u. -* The following changes apply on systems conforming to POSIX 1003.1-2001, - and are required by the new POSIX standard: - - `date -I' is no longer supported. Instead, use `date --iso-8601'. - - `nice -NUM' is no longer supported. Instead, use `nice -n NUM'. -* New 'uname' options -i or --hardware-platform, and -o or --operating-system. - 'uname -a' now outputs -i and -o information at the end. - New uname option --kernel-version is an alias for -v. - Uname option --release has been renamed to --kernel-release, - and --sysname has been renamed to --kernel-name; - the old options will work for a while, but are no longer documented. -* 'expr' now uses the LC_COLLATE locale for string comparison, as per POSIX. -* 'expr' now requires '+' rather than 'quote' to quote tokens; - this removes an incompatibility with POSIX. -* date -d 'last friday' would print a date/time that was one hour off - (e.g., 23:00 on *thursday* rather than 00:00 of the preceding friday) - when run such that the current time and the target date/time fall on - opposite sides of a daylight savings time transition. - This problem arose only with relative date strings like `last monday'. - It was not a problem with strings that include absolute dates. -* factor is twice as fast, for large numbers - [2.0.11] -* setting the date now works properly, even when using -u -* `date -f - < /dev/null' no longer dumps core -* some DOS/Windows portability changes - [2.0j] -* `date -d DATE' now parses certain relative DATEs correctly - [2.0i] -* fixed a bug introduced in 2.0h that made many programs fail with a - `write error' when invoked with the --version option - [2.0h] -* all programs fail when printing --help or --version output to a full device -* printf exits nonzero upon write failure -* yes now detects and terminates upon write failure -* date --rfc-822 now always emits day and month names from the `C' locale -* portability tweaks for Solaris8, Ultrix, and DOS - [2.0g] -* date now handles two-digit years with leading zeros correctly. -* printf interprets unicode, \uNNNN \UNNNNNNNN, on systems with the - required support; from Bruno Haible. -* stty's rprnt attribute now works on HPUX 10.20 -* seq's --equal-width option works more portably - [2.0f] -* fix build problems with ut_name vs. ut_user - [2.0e] -* stty: fix long-standing bug that caused test failures on at least HPUX - systems when COLUMNS was set to zero -* still more portability fixes -* unified lib/: now that directory and most of the configuration framework - is common between fileutils, textutils, and sh-utils - [2.0d] -* fix portability problem with sleep vs lib/strtod.c's requirement for -lm - [2.0c] -* fix portability problems with nanosleep.c and with the new code in sleep.c - [2.0b] -* Regenerate lib/Makefile.in so that nanosleep.c is distributed. - [2.0a] -* sleep accepts floating point arguments on command line -* sleep's clock continues counting down when sleep is suspended -* when a suspended sleep process is resumed, it continues sleeping if - there is any time remaining -* who once again prints whatever host information it has, even without --lookup - -======================================================================== -For older NEWS entries for the fileutils, textutils, and sh-utils -packages, see ./old/*/NEWS. - - This package began as the union of the following: - textutils-2.1, fileutils-4.1.11, sh-utils-2.0.15. diff --git a/contrib/gnu-sort/README b/contrib/gnu-sort/README deleted file mode 100644 index df35be461021..000000000000 --- a/contrib/gnu-sort/README +++ /dev/null @@ -1,147 +0,0 @@ -These are the GNU core utilities. This package is the union of -the GNU fileutils, sh-utils, and textutils packages. - -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: - - [ basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd - df dir dircolors dirname du echo env expand expr factor false fmt fold - ginstall groups head hostid hostname id join kill link ln logname ls - md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr - printenv printf ptx pwd readlink rm rmdir seq sha1sum shred sleep sort - split stat stty su sum sync tac tail tee test touch tr true tsort tty - uname unexpand uniq unlink uptime users vdir wc who whoami yes - -See the file NEWS for a list of major changes in the current release. - -See the file INSTALL for compilation and installation instructions. - -These programs are intended to conform to POSIX (with BSD and other -extensions), like the rest of the GNU system. By default they conform -to older POSIX (1003.2-1992), and therefore support obsolete usages -like "head -10" and "chown owner.group file". This default is -overridden at build-time by the value of 's _POSIX2_VERSION -macro, and this in turn can be overridden at runtime as described in -the documentation under "Standards conformance". - -The ls, dir, and vdir commands are all separate executables instead of -one program that checks argv[0] because people often rename these -programs to things like gls, gnuls, l, etc. Renaming a program -file shouldn't affect how it operates, so that people can get the -behavior they want with whatever name they want. - -Special thanks to Paul Eggert, Brian Matthews, Bruce Evans, Karl Berry, -Kaveh Ghazi, and François Pinard for help with debugging and porting -these programs. Many thanks to all of the people who have taken the -time to submit problem reports and fixes. All contributed changes are -attributed in the ChangeLog file. - -And thanks to the following people who have provided accounts for -portability testing on many different types of systems: Bob Proulx, -Christian Robert, François Pinard, Greg McGary, Harlan Stenn, -Joel N. Weber, Mark D. Roth, Matt Schalit, Nelson H. F. Beebe, -Réjean Payette, Sam Tardieu. - -Thanks to Michael Stone for inflicting test releases of the fileutils -on Debian's unstable distribution, and to all the kind folks who used -that distribution and found and reported bugs. - -Note that each man page is now automatically generated from a template -and from the corresponding --help usage message. Patches to the template -files (man/*.x) are welcome. However, the authoritative documentation -is in texinfo form in the doc directory. - -If you run the tests on a SunOS4.1.4 system, expect the ctime-part of -the ls `time-1' test to fail. I believe that is due to a bug in the -way Sun implemented link(2) and chmod(2). - -*************************************** -Last-minute notes, before coreutils-5.0 ---------------------------------------- - -A known problem exists when compiling on HPUX on both hppa and ia64 -in 64-bit mode (i.e. +DD64) on all known HPUX 11.x versions. This -is not due to a bug in the package but instead due to a bug in the -system header file which breaks things in 64-bit mode. The default -compilation mode is 32-bit and the software compiles fine using the -default mode. To build this software in 64-bit mode you will need -to fix the system /usr/include/inttypes.h header file. After -correcting that file the software also compiles fine in 64-bit mode. -Here is one possible patch to correct the problem. - ---- /usr/include/inttypes.h.orig Thu May 30 01:00:00 1996 -+++ /usr/include/inttypes.h Sun Mar 23 00:20:36 2003 -@@ -489 +489 @@ --#ifndef __STDC_32_MODE__ -+#ifndef __LP64__ - -If you run the tests as root, note that a few of them create files -and/or run programs as a non-root user, `nobody' by default. -If you want to use some other non-root username, specify it via -the NON_ROOT_USERNAME environment variable. Depending on the -permissions with which the working directories have been created, -using `nobody' may fail, because that user won't have the required -read and write access to the build and test directories. -I find that it is best to unpack and build as a non-privileged -user, and then to run the following command as that user in order -to run the privilege-requiring tests: - - sudo env NON_ROOT_USERNAME=$USER make check - -If you can run the tests as root, please do so and report any -problems. We get much less test coverage in that mode, and it's -arguably more important that these tools work well when run by -root than when run by less privileged users. - -*************************************** - -There are pretty many tests, but nowhere near as many as we need. -Additions and corrections are very welcome. - -If you see a problem that you've already reported, feel free to re-report -it -- it won't bother me to get a reminder. Besides, the more messages I -get regarding a particular problem the sooner it'll be fixed -- usually. -If you sent a complete patch and, after a couple weeks you haven't -received any acknowledgement, please ping us. A complete patch includes -a well-written ChangeLog entry, unified (diff -u format) diffs relative -to the most recent test release (or, better, relative to the latest -sources in the CVS repository), an explanation for why the patch is -necessary or useful, and if at all possible, enough information to -reproduce whatever problem prompted it. Plus, you'll earn lots of -karma if you include a test case to exercise any bug(s) you fix. -Instructions for checking out the latest source via CVS are here: - - http://savannah.gnu.org/cvs/?group=coreutils - - -If your patch adds a new feature, please try to get some sort of consensus -that it is a worthwhile change. One way to do that is to send mail to -bug-coreutils@gnu.org including as much description and justification -as you can. Based on the feedback that generates, you may be able to -convince us that it's worth adding. - - -WARNING: If you modify files like configure.in, m4/*.m4, aclocal.m4, -or any Makefile.am, then don't be surprised if what gets regenerated no -longer works. To make things work, you'll have to be using appropriate -versions of automake and autoconf. As for what versions are `appropriate', -use the versions of - - * autoconf specified via AC_PREREQ in m4/jm-macros.m4 - * automake specified via AM_INIT_AUTOMAKE in configure.ac - -Usually it's fine to use versions that are newer than those specified. - -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 Coding Standards, -http://www.gnu.org/prep/standards_toc.html. - -Mail suggestions and bug reports for these programs to -the address on the last line of --help output. diff --git a/contrib/gnu-sort/README-alpha b/contrib/gnu-sort/README-alpha deleted file mode 100644 index e57d64948dfe..000000000000 --- a/contrib/gnu-sort/README-alpha +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 44b7b020f4d1..000000000000 --- a/contrib/gnu-sort/THANKS +++ /dev/null @@ -1,463 +0,0 @@ -These people have contributed to the GNU coreutils (formerly, the 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 send a note to -the bug-report mailing list (as seen on last line of e.g., cp --help). - -??? kytek@cybercomm.net -A Costa agcosta@gis.net -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 Chin-A-Young china@thewrittenword.com -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 -Alexey Vyskubov alexey@pippuri.mawhrin.net -Alfred M. Szmidt ams@kemisten.nu -Andi Kleen freitag@alancoxonachip.com -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 -Andrei Gaponenko andr@triumf.ca -Andres Soolo andres@soolo.matti.ee -Andrew Burgess aab@cichlid.com -Andrew Dalke dalke@bioreason.com -Andrew Fabbro andrew@fabbro.org -Andrew Pham andpha@us.ibm.com -Andrew Tridgell tridge@samba.org -Andrey Borzenkov arvidjaar@mail.ru -Andries Brouwer Andries.Brouwer@cwi.nl -Andy Longton alongton@metamark.com -Anthony Thyssen anthony@griffith.edu.au -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 -Arnold Robbins arnold@skeeve.com -Arthur Pool pool@commerce.uq.edu.au -Arun Sharma arun.sharma@intel.com -Arvind Autar Autar022@planet.nl -Augey Mikus mikus@dqc.org -Austin Donnelly Austin.Donnelly@cl.cam.ac.uk -Axel Kittenberger Anshil@gmx.net -Bauke Jan Douma bjdouma@xs4all.nl -Ben Elliston bje@air.net.au -Ben Harris bjh21@netbsd.org -Benjamin Cutler cutlerbc@simla.colostate.edu -Bengt Martensson bengt@mathematik.uni-Bremen.de -Bernard Giroud bernard.giroud@creditlyonnais.ch -Bernd Leibing bernd.leibing@rz.uni-ulm.de -Bernd Melchers melchers@cis.fu-berlin.de -Bernhard Baehr bernhard.baehr@gmx.de -Bernhard Gabler bernhard@uni-koblenz.de -Bernhard Rosenkraenzer bero@redhat.de -Bert Deknuydt Bert.Deknuydt@esat.kuleuven.ac.be -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 -Bruce Korb bkorb@veritas.com -Bruce Robertson brucer@theodolite.dyndns.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 Lesniewski ctl@mit.edu -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 -Clement Wang clem.wang@overture.com -Colin Plumb colin@nyx.net -Colin Watson cjw44@riva.ucam.org -Collin Rogowski collin@rogowski.de -Cray-Cyber Project http://www.cray-cyber.org -Dale Scheetz dwarf@polaris.net -Dan Hagerty hag@gnu.ai.it.edu -Dan Jacobson http://www.geocities.com/jidani -Dan Pascu dan@services.iiruc.ro -Daniel Bergstrom noa@melody.se -Dániel Varga danielv@axelero.hu -Danny Levinson danny.levinson@overture.com -Darren Salt ds@youmustbejoking.demon.co.uk -Dave Beckett dajobe@dajobe.org -David Dyck dcd@tc.fluke.COM -David Eisner cradle@umd.edu -David Flynn dav@chess.plus.com -David Godfrey dave@delta.demon.co.uk -David Luyer david_luyer@pacific.net.au -David Malone dwmalone@cnri.dit.ie -Deepak Goel deego@gnufans.org -Dennis Henriksen opus@flamingo.osrl.dk -Dennis Smit ds@nerds-incorporated.org -Derek Clegg dclegg@next.com -Dick Streefland dick_streefland@tasking.com -Dirk Lattermann dlatt@t-online.de -Dirk-Jan Faber djfaber@snow.nl -Dmitry Rutsky rutsky@school.ioffe.rssi.ru -Dmitry V. Levin ldv@altlinux.org -Don Parsons dparsons@synapse.kent.edu -Donni Erpel donald@appc11.gsi.de -Doug Coleman coleman@iarc1.ece.utexas.edu -Doug McLaren dougmc@comco.com -Dragos Harabor dharabor@us.oracle.com -Duncan Roe duncanr@optimation.com.au -Ed Avis ed@membled.com -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 -Ferdinand fw@scenic.mine.nu -Fletcher Mattox fletcher@cs.utexas.edu -Florin Iucha fiucha@hsys.mic.ro -François Pinard pinard@iro.umontreal.ca -Frank Adler fadler@allesklar.de -Frank T Lofaro ftlofaro@snooks.Egr.UNLV.EDU -Fred Fish fnf@ninemoons.com -Frédéric L. W. Meunier 0@pervalidus.net -Frederik Eaton frederik@caltech.edu -Gabor Z. Papp gzp@gzp.org.hu -Gaël Quéri gqueri@mail.dotcom.fr -Galen Hazelwood galenh@micron.net -Gary Anderson ganderson@clark.net -Gary V. Vaughan gary@gnu.org -Gaute Hvoslef Kvalnes gaute@verdsveven.com -Geoff Collyer geoff at collyer.net -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 -Göran Uddeborg goeran@uddeborg.pp.se -GOTO Masanori gotom@debian.or.jp -Greg Louis glouis@dynamicro.on.ca -Greg McGary gkm@gnu.org -Greg Schafer gschafer@zip.com.au -Greg Troxel gdt@bbn.com -Greg Wooledge gawooledge@sherwin.com -Gregory Leblanc gleblanc@cu-portland.edu -Guido Leenders guido.leenders@invantive.com -H. J. Lu hjl@valinux.com -Hans Ginzel hans@matfyz.cz -Hans Lermen lermen@fgan.de -Hans Verkuil hans@wyst.hobby.nl -Harry Liu rliu@lek.ugcs.caltech.edu -Harti Brandt brandt@fokus.fraunhofer.de -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 -Iida Yosiaki iida@gnu.org -Ingo Saitz ingo@debian.org -Ivo Timmermans ivo@debian.org -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 -Jean Charles Delepine delepine@u-picardie.fr -Jeff Moore jbm@mordor.com -Jeff Sheinberg jeff@bsrd.net -Jens Elkner elkner@imsgroup.de -Jens Schmidt jms@jsds.hamburg.com -Jerome Abela abela@hsc.fr -Jérôme Zago bug-coreutils-ml@agt-the-walker.net -Jesse Kornblum kornblum@usna.edu -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@manyfish.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 -Jon Peatfield J.S.Peatfield@damtp.cam.ac.uk -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 -Jurriaan thunder7@xs4all.nl -jvogel jvogel@linkny.com -Kai Henningsen kai@debian.org -Kai-Uwe Rommel rommel@informatik.tu-muenchen.de -Kalle Olavi Niemitalo kon@iki.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 M. Briggs keith.briggs@bt.com -Keith Owens kaos@audio.apana.org.au -Keith Thompson kst@cts.com -Ken Pizzini kenp@halcyon.com -Kristin E Thomas kristint@us.ibm.com -Kjetil Torgrim Homme kjetilho@ifi.uio.no -Kristoffer Rose kris@diku.dk -Larry McVoy lm@sgi.com -Lars Hecking lhecking@nmrc.ucc.ie -Leah Q eequor@earthlink.net -Lehti Rami rammer@cs.tut.fi -Leonard N. Zubkoff lnz@dandelion.com -Leonardo Milano lmilano@udel.edu -Lorne Baker lbaker@nitro.avint.net -Luke Hassell lukehassell@yahoo.com -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 Haber mh+debian-bugs@zugschlus.de -Marc Olzheim marcolz@stack.nl -Marco Franzen Marco.Franzen@Thyron.com -Marcus Brinkmann http://www.marcus-brinkmann.de -Marcus Daniels marcus@ee.pdx.edu -Mark A. Thomas thommark@access.digex.net -Mark Conty Mark_Conty@cargill.com -Mark D. Roth roth@uiuc.edu -Mark Funkenhauser mfunkenhauser@rogers.com -Mark Harris mark@monitor.designacc.com -Mark Hewitt mhewitt@armature.com -Mark Hounschell markh@compro.net -Mark Hubbart discord@mac.com -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 Buck martin.buck@ascom.ch -Martin Gallant martyg@goodbit.net -Martin Hippe martin.hippe@schlund.de -Martin Michlmayr tbm@cyrius.com -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 -Matt Swift swift@alum.mit.edu -Matthew Arnison maffew@cat.org.au -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 -Matthias Urlichs smurf@noris.de -Matti Aarnio matti.aarnio@zmailer.org -Mattias Wadenstein maswan@acc.umu.se -Meelis Roos mroos@tartu.cyber.ee -Michael michael@aplatform.com -Michael ??? michael@roka.net -Michael Bacarella mbac@netgraft.com> -Michael Deutschmann michael@talamasca.ocis.net -Michael Elizabeth Chastain mec.gnu@mindspring.com -Michael Gaughen mgaughen@polyserve.com -Michael Hasselberg mikelh@zonta.ping.de -Michael Hohn hohn@math.utah.edu -Michael J. Croghan mcroghan@usatoday.com -Michael McFarland sidlon@yahoo.com -Michael Piefel piefel@informatik.hu-berlin.de -Michael Steffens michael.steffens@s.netic.de -Michael Stone mstone@debian.org -Michael Stutz stutz@dsl.org -Michael van Elst mlelstv@dev.de.cw.net -Michael Veksler mveksler@techunix.technion.ac.il -Michail Litvak mci@owl.openwall.com -Michal Politowski mpol@charybda.icm.edu.pl -Michal Svec msvec@suse.cz -Michel Robitaille robitail@IRO.UMontreal.CA -Michiel Bacchiani bacchian@raven.bu.edu -Mike Castle dalgoda@ix.netcom.com -Mike Coleman mkc@mathdogs.com -Mike Jetzer mjetzer@mke.catalystwms.com -Mikko Tuumanen m@sorvankyla.yok.utu.fi -Mikulas Patocka mikulas@artax.karlin.mff.cuni.cz -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 -Neil Brown neilb@cse.unsw.edu.au -Nelson H. F. Beebe beebe@math.utah.edu -Nick Estes debian@nickstoys.com -Nick Lawes nlawes@silverplatter.com -Niklas Edmundsson nikke@acc.umu.se -Nikola Milutinovic Nikola.Milutinovic@ev.co.yu -Noah Friedman friedman@splode.com -Noel Cragg noel@red-bean.com -Olatunji Oluwabukunmi Ruwase tjruwase@stanford.edu -Olav Morkrid olav@funcom.com -Ole Laursen olau@hardworking.dk -Oliver Kiddle okiddle@yahoo.co.uk -Ørn E. Hansen oehansen@daimi.aau.dk -Oskar Liljeblad osk@hem.passagen.se -Patrick Mauritz oxygene@studentenbude.ath.cx -Paul Eggert eggert@twinsun.com -Paul Jarc prj@po.cwru.edu -Paul Nevai nevai@ops.mps.ohio-state.edu -Paul Sauer paul@alexa.com -Paul Slootman paul@debian.org -Paul Worrall paul@basilisk.uklinux.net -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 Horst peter@ointment.org -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 -Phillip Jones mouse@datastacks.com -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 -Raúl Núñez de Arenas Coronado raul@pleyades.net -Reuben Thomas rrt@sc3d.org -Richard A Downing richard.downing@bcs.org.uk -Richard Braakman dark@xs4all.nl -Richard Dawe rich@phekda.freeserve.co.uk -Richard J. Rauenzahn rrauenza@hairball.cup.hp.com -Richard Neill rn214@hermes.cam.ac.uk -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 -Robert Millan zeratul2@wanadoo.es -Rogier Wolff R.E.Wolff@BitWizard.nl -Roland Huebner ro-huebner@gmx.de -Roland Turner raz.tah.bet@raz.cx -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 -Samuel Tardieu sam@rfc1149.net -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 -Shing-Shong Shei shei@cs.indiana.edu -Soeren Sonnenburg sonnenburg@informatik.hu-berlin.de -Solar Designer solar@owl.openwall.com -Stanislav Ievlev inger@altlinux.ru -Stéphane Chazelas Stephane_CHAZELAS@yahoo.fr -Stephen Depooter sbdep@myrealbox.com -Stephen Eglen eglen@pcg.wustl.edu -Stephen Gildea gildea@stop.mail-abuse.org -Stephen Smoogen smooge@mindspring.com -Steve McConnel steve@acadcomp.sil.org -Steven G. Johnson stevenj@alum.mit.edu -Steven Mocking ufo@quicknet.nl -Steven P Watson steven@magelico.net -Stuart Kemp skemp@peter.bmc.com -Szakacsits Szabolcs szaka@sienet.hu -Tadayoshi Funaba tadf@kt.rim.or.jp -TAKAI Kousuke takai@vlsi.kuee.kyoto-u.ac.jp -Theodore Ts'o tytso@rsts-11.mit.edu -Thomas Bushnell thomas@gnu.ai.mit.edu -Thomas Goerlich thomas@schnappmatik.de -Thomas Luzat thomas@luzat.com -Thomas Quinot thomas@Cuivre.FR.EU.ORG -Tim J. Robbins tjr@FreeBSD.org -Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu -Tim Smithers mouse@dmouse.com.au -Tim Waugh twaugh@redhat -Todd A. Jacobs tjacobs@codegnome.org -Tom Haynes thomas@netapp.com -Tom Quinn trq@dionysos.thphys.ox.ac.uk -Tommi Kyntola tkyntola@cc.hut.fi -Ton Hospel thospel@mail.dma.be -Ton Nijkes ton@murphy.nl -Tony Kocurko akocurko@mun.ca -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 -Volker Paul vpaul@dohle.com -Wartan Hachaturow wart@tepkom.ru -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 -wiregauze wiregauze@yahoo.com -Wojciech Purczynski cliph@isec.pl -Wolfram Kleff kleff@cs.uni-bonn.de -Won-kyu Park wkpark@chem.skku.ac.kr -Yann Dirson dirson@debian.org -Zvi Har'El rl@math.technion.ac.il diff --git a/contrib/gnu-sort/THANKS-to-translators b/contrib/gnu-sort/THANKS-to-translators deleted file mode 100644 index c84ff647b57e..000000000000 --- a/contrib/gnu-sort/THANKS-to-translators +++ /dev/null @@ -1,36 +0,0 @@ -The following teams have translated the many diagnostics of this -package into many different languages. Thank you! - ---- -http://www.iro.umontreal.ca/contrib/po/HTML/team-af.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-be.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-ca.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-cs.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-da.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-de.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-el.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-es.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-et.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-fi.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-fr.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-ga.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-gl.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-hu.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-it.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-ja.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-ko.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-lg.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-ms.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-nb.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-nl.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-no.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-pl.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-pt.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-pt_BR.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-ru.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-sk.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-sl.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-sv.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-tr.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-zh_CN.html -http://www.iro.umontreal.ca/contrib/po/HTML/team-zh_TW.html diff --git a/contrib/gnu-sort/TODO b/contrib/gnu-sort/TODO deleted file mode 100644 index 82a74bf6dca8..000000000000 --- a/contrib/gnu-sort/TODO +++ /dev/null @@ -1,171 +0,0 @@ -restore djgpp, eventually -merge TODO lists -add unit tests for lib/*.c - -strip: add an option to specify the program used to strip binaries. - suggestion from Karl Berry - -doc/coreutils.texi: - Address this comment: FIXME: mv's behavior in this case is system-dependent - Better still: fix the code so it's *not* system-dependent. - -implement --target-directory=DIR for install (per texinfo documentation) - -ls: add --format=FORMAT option that controls how each line is printed. - -cp --no-preserve=X should not attempt to preserve attribute X - reported by Andreas Schwab - -copy.c: Address the FIXME-maybe comment in copy_internal. -And once that's done, add an exclusion so that `cp --link' -no longer incurs the overhead of saving src. dev/ino and dest. filename -in the hash table. - -See if we can be consistent about where --verbose sends its output: - These all send --verbose output to stdout: - head, tail, rm, cp, mv, ln, chmod, chown, chgrp, install, ln - These send it to stderr: - shred mkdir split - readlink is different - -Write an autoconf test to work around build failure in HPUX's 64-bit mode. -See notes in README -- and remove them once there's a work-around. - -Integrate use of sendfile, suggested here: - http://mail.gnu.org/archive/html/bug-fileutils/2003-03/msg00030.html -I don't plan to do that, since a few tests demonstrate no significant benefit. - -Should printf '\0123' print "\n3"? - per report from TAKAI Kousuke on Mar 27 - http://mail.gnu.org/archive/html/bug-coreutils/2003-03/index.html - -printf: consider adapting builtins/printf.def from bash - -df: add `--total' option, suggested here http://bugs.debian.org/186007 - -seq: give better diagnostics for invalid formats: - e.g. no or too many % directives -seq: consider allowing format string to contain no %-directives - -m4: rename all macros that start with AC_ to start with another prefix - -resolve RH report on cp -a forwarded by Tim Waugh - -Martin Michlmayr's patch to provide ls with `--sort directory' option - -tail: don't use xlseek; it *exits*. - Instead, maybe use a macro and return nonzero. - -add mktemp? Suggested by Nelson Beebe - -df: alignment problem of `Used' heading with e.g., -mP - reported by Karl Berry - -tr: support nontrivial equivalence classes, e.g. [=e=] with LC_COLLATE=fr_FR - -fix tail -f to work with named pipes; reported by Ian D. Allen - $ mkfifo j; tail -f j & sleep 1; echo x > j - ./tail: j: file truncated - ./tail: j: cannot seek to offset 0: Illegal seek - -lib/strftime.c: Since %N is the only format that we need but that - glibc's strftime doesn't support, consider using a wrapper that - would expand /%(-_)?\d*N/ to the desired string and then pass the - resulting string to glibc's strftime. - -sort: Compress temporary files when doing large external sort/merges. - This improves performance when you can compress/uncompress faster than - you can read/write, which is common in these days of fast CPUs. - suggestion from Charles Randall on 2001-08-10 - -sort: Add an ordering option -R that causes 'sort' to sort according - to a random permutation of the correct sort order. Also, add an - option --random-seed=SEED that causes 'sort' to use an arbitrary - string SEED to select which permutations to use, in a deterministic - manner: that is, if you sort a permutation of the same input file - with the same --random-seed=SEED option twice, you'll get the same - output. The default SEED is chosen at random, and contains enough - information to ensure that the output permutation is random. - suggestion from Feth AREZKI, Stephan Kasal, and Paul Eggert on 2003-07-17 - -unexpand: [http://www.opengroup.org/onlinepubs/007908799/xcu/unexpand.html] - printf 'x\t \t y\n'|unexpand -t 8,9 should print its input, unmodified. - printf 'x\t \t y\n'|unexpand -t 5,8 should print "x\ty\n" - -Let GNU su use the `wheel' group if appropriate. - (there are a couple patches, already) - -sort: Investigate better sorting algorithms; see Knuth vol. 3. - - We tried list merge sort, but it was about 50% slower than the - recursive algorithm currently used by sortlines, and it used more - comparisons. We're not sure why this was, as the theory suggests it - should do fewer comparisons, so perhaps this should be revisited. - List merge sort was implemented in the style of Knuth algorithm - 5.2.4L, with the optimization suggested by exercise 5.2.4-22. The - test case was 140,213,394 bytes, 426,4424 lines, text taken from the - GCC 3.3 distribution, sort.c compiled with GCC 2.95.4 and running on - Debian 3.0r1 GNU/Linux, 2.4GHz Pentium 4, single pass with no - temporary files and plenty of RAM. - - Since comparisons seem to be the bottleneck, perhaps the best - algorithm to try next should be merge insertion. See Knuth section - 5.3.1, who credits Lester Ford, Jr. and Selmer Johnson, American - Mathematical Monthly 66 (1959), 387-389. - -cp --recursive: perform dir traversals in source and dest hierarchy rather - than forming full file names. The latter (current) approach fails - unnecessarily when the names become very long. - -tail --p is now ambiguous - -Remove suspicious uses of alloca (ones that may allocate more than - about 4k) - -Adapt these contribution guidelines for coreutils: - http://sources.redhat.com/automake/contribute.html - - -Changes expected to go in, post-5.2.1: -====================================== - - wc: add an option, --files0-from [as for du] to make it read NUL-delimited - file name arguments from a file. - - dd patch from Olivier Delhomme - - Apply Andreas Gruenbacher's ACL and xattr changes - - Apply Bruno Haible's hostname changes - - test/mv/*: clean up $other_partition_tmpdir in all cases - - ls: when both -l and --dereference-command-line-symlink-to-dir are - specified, consider whether to let the latter select whether to - dereference command line symlinks to directories. Since -l has - an implicit --NO-dereference-command-line-symlink-to-dir meaning. - Pointed out by Karl Berry. - - A more efficient version of factor, and possibly one that - accepts inputs of size 2^64 and larger. - - Re-add a separate test for du's stack space usage (like the one removed - from tests/rm/deep-1). - - dd: consider adding an option to suppress `bytes/block read/written' - output to stderr. Suggested here: - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=165045 - - Pending copyright papers: - ------------------------ - ls --color: Ed Avis' patch to suppress escape sequences for - non-highlighted files - - getpwnam from Bruce Korb - - pb (progress bar) from Miika Pekkarinen - - Look into improving the performance of md5sum. - `openssl md5' is consistently about 30% faster than md5sum on an idle - AMD 2000-XP system with plenty of RAM and a 261 MB input file. - openssl's md5 implementation is in assembly, generated by a perl script. diff --git a/contrib/gnu-sort/lib/__fpending.c b/contrib/gnu-sort/lib/__fpending.c deleted file mode 100644 index a872102abf8a..000000000000 --- a/contrib/gnu-sort/lib/__fpending.c +++ /dev/null @@ -1,30 +0,0 @@ -/* __fpending.c -- return the number of pending output bytes on a stream - Copyright (C) 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 "__fpending.h" - -size_t -__fpending (FILE *fp) -{ - return PENDING_OUTPUT_N_BYTES; -} diff --git a/contrib/gnu-sort/lib/__fpending.h b/contrib/gnu-sort/lib/__fpending.h deleted file mode 100644 index 5a5158216c1a..000000000000 --- a/contrib/gnu-sort/lib/__fpending.h +++ /dev/null @@ -1,17 +0,0 @@ -#if HAVE_CONFIG_H -# include -#endif - -#include -#include - -#if HAVE_STDIO_EXT_H -# include -#endif - -#ifndef HAVE_DECL___FPENDING -"this configure-time declaration test was not run" -#endif -#if !HAVE_DECL___FPENDING -size_t __fpending (FILE *); -#endif diff --git a/contrib/gnu-sort/lib/argmatch.c b/contrib/gnu-sort/lib/argmatch.c deleted file mode 100644 index 1a8ec2f54ba4..000000000000 --- a/contrib/gnu-sort/lib/argmatch.c +++ /dev/null @@ -1,278 +0,0 @@ -/* argmatch.c -- find a match for a string in an array - - Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 2004 Free - Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 */ - -#if HAVE_CONFIG_H -# include -#endif - -/* Specification. */ -#include "argmatch.h" - -#include -#include -#include -#include - -#include "gettext.h" -#define _(msgid) gettext (msgid) - -#include "error.h" -#include "exit.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 - -/* Non failing version of argmatch call this function after failing. */ -#ifndef ARGMATCH_DIE -# include "exitfail.h" -# define ARGMATCH_DIE exit (exit_failure) -#endif - -#ifdef ARGMATCH_DIE_DECL -ARGMATCH_DIE_DECL; -#endif - -static void -__argmatch_die (void) -{ - ARGMATCH_DIE; -} - -/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h. - Default to __argmatch_die, but allow caller to change this at run-time. */ -argmatch_exit_fn argmatch_die = __argmatch_die; - - -/* If ARG is an unambiguous match for an element of the - null-terminated array ARGLIST, return the index in ARGLIST - of the matched element, else -1 if it does not match any element - or -2 if it is ambiguous (is a prefix of more than one element). - - If VALLIST is none null, use it to resolve ambiguities limited to - synonyms, i.e., for - "yes", "yop" -> 0 - "no", "nope" -> 1 - "y" is a valid argument, for `0', and "n" for `1'. */ - -ptrdiff_t -argmatch (const char *arg, const char *const *arglist, - const char *vallist, size_t valsize) -{ - size_t i; /* Temporary index in ARGLIST. */ - size_t arglen; /* Length of ARG. */ - ptrdiff_t matchind = -1; /* Index of first nonexact match. */ - bool ambiguous = false; /* If true, multiple nonexact match(es). */ - - arglen = strlen (arg); - - /* Test all elements for either exact match or abbreviated matches. */ - for (i = 0; arglist[i]; i++) - { - if (!strncmp (arglist[i], arg, arglen)) - { - if (strlen (arglist[i]) == arglen) - /* Exact match found. */ - return i; - else if (matchind == -1) - /* First nonexact match found. */ - matchind = i; - else - { - /* Second nonexact match found. */ - if (vallist == NULL - || memcmp (vallist + valsize * matchind, - vallist + valsize * i, valsize)) - { - /* There is a real ambiguity, or we could not - disambiguate. */ - ambiguous = true; - } - } - } - } - if (ambiguous) - return -2; - else - return matchind; -} - -/* Error reporting for argmatch. - CONTEXT is a description of the type of entity that was being matched. - VALUE is the invalid value that was given. - PROBLEM is the return value from argmatch. */ - -void -argmatch_invalid (const char *context, const char *value, ptrdiff_t problem) -{ - char const *format = (problem == -1 - ? _("invalid argument %s for %s") - : _("ambiguous argument %s for %s")); - - error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value), - quote_n (1, context)); -} - -/* List the valid arguments for argmatch. - ARGLIST is the same as in argmatch. - VALLIST is a pointer to an array of values. - VALSIZE is the size of the elements of VALLIST */ -void -argmatch_valid (const char *const *arglist, - const char *vallist, size_t valsize) -{ - size_t i; - const char *last_val = NULL; - - /* We try to put synonyms on the same line. The assumption is that - synonyms follow each other */ - fprintf (stderr, _("Valid arguments are:")); - for (i = 0; arglist[i]; i++) - if ((i == 0) - || memcmp (last_val, vallist + valsize * i, valsize)) - { - fprintf (stderr, "\n - `%s'", arglist[i]); - last_val = vallist + valsize * i; - } - else - { - fprintf (stderr, ", `%s'", arglist[i]); - } - putc ('\n', stderr); -} - -/* Never failing versions of the previous functions. - - CONTEXT is the context for which argmatch is called (e.g., - "--version-control", or "$VERSION_CONTROL" etc.). Upon failure, - calls the (supposed never to return) function EXIT_FN. */ - -ptrdiff_t -__xargmatch_internal (const char *context, - const char *arg, const char *const *arglist, - const char *vallist, size_t valsize, - argmatch_exit_fn exit_fn) -{ - ptrdiff_t res = argmatch (arg, arglist, vallist, valsize); - if (res >= 0) - /* Success. */ - return res; - - /* We failed. Explain why. */ - argmatch_invalid (context, arg, res); - argmatch_valid (arglist, vallist, valsize); - (*exit_fn) (); - - return -1; /* To please the compilers. */ -} - -/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and - return the first corresponding argument in ARGLIST */ -const char * -argmatch_to_argument (const char *value, - const char *const *arglist, - const char *vallist, size_t valsize) -{ - size_t i; - - for (i = 0; arglist[i]; i++) - if (!memcmp (value, vallist + valsize * i, valsize)) - return arglist[i]; - return NULL; -} - -#ifdef TEST -/* - * Based on "getversion.c" by David MacKenzie - */ -char *program_name; - -/* 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 = XARGMATCH ("$VERSION_CONTROL", cp, - backup_args, backup_vals); - - if (argc == 2) - backup_type = XARGMATCH (program_name, argv[1], - backup_args, backup_vals); - - printf ("The version control is `%s'\n", - ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals)); - - return 0; -} -#endif diff --git a/contrib/gnu-sort/lib/argmatch.h b/contrib/gnu-sort/lib/argmatch.h deleted file mode 100644 index 8952394fdac7..000000000000 --- a/contrib/gnu-sort/lib/argmatch.h +++ /dev/null @@ -1,112 +0,0 @@ -/* argmatch.h -- definitions and prototypes for argmatch.c - - Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 - -# include - -# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) - -# define ARGMATCH_CONSTRAINT(Arglist, Vallist) \ - (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1) - -/* Assert there are as many real arguments as there are values - (argument list ends with a NULL guard). ARGMATCH_VERIFY is - preferred, since it is guaranteed to be checked at compile-time. - ARGMATCH_ASSERT is for backward compatibility only. */ - -# define ARGMATCH_VERIFY(Arglist, Vallist) \ - struct argmatch_verify \ - { \ - char argmatch_verify[ARGMATCH_CONSTRAINT(Arglist, Vallist) ? 1 : -1]; \ - } - -# define ARGMATCH_ASSERT(Arglist, Vallist) \ - assert (ARGMATCH_CONSTRAINT (Arglist, Vallist)) - -/* Return the index of the element of ARGLIST (NULL terminated) that - matches with ARG. If VALLIST is not NULL, then use it to resolve - false ambiguities (i.e., different matches of ARG but corresponding - to the same values in VALLIST). */ - -ptrdiff_t argmatch (char const *arg, char const *const *arglist, - char const *vallist, size_t valsize); - -# define ARGMATCH(Arg, Arglist, Vallist) \ - argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist)) - -/* xargmatch calls this function when it fails. This function should not - return. By default, this is a function that calls ARGMATCH_DIE which - in turn defaults to `exit (exit_failure)'. */ -typedef void (*argmatch_exit_fn) (void); -extern argmatch_exit_fn argmatch_die; - -/* Report on stderr why argmatch failed. Report correct values. */ - -void argmatch_invalid (char const *context, char const *value, - ptrdiff_t problem); - -/* Left for compatibility with the old name invalid_arg */ - -# define invalid_arg(Context, Value, Problem) \ - argmatch_invalid (Context, Value, Problem) - - - -/* Report on stderr the list of possible arguments. */ - -void argmatch_valid (char const *const *arglist, - char const *vallist, size_t valsize); - -# define ARGMATCH_VALID(Arglist, Vallist) \ - argmatch_valid (Arglist, (char const *) (Vallist), sizeof *(Vallist)) - - - -/* Same as argmatch, but upon failure, reports a explanation on the - failure, and exits using the function EXIT_FN. */ - -ptrdiff_t __xargmatch_internal (char const *context, - char const *arg, char const *const *arglist, - char const *vallist, size_t valsize, - argmatch_exit_fn exit_fn); - -/* Programmer friendly interface to __xargmatch_internal. */ - -# define XARGMATCH(Context, Arg, Arglist, Vallist) \ - ((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \ - (char const *) (Vallist), \ - sizeof *(Vallist), \ - argmatch_die)]) - -/* Convert a value into a corresponding argument. */ - -char const *argmatch_to_argument (char const *value, - char const *const *arglist, - char const *vallist, size_t valsize); - -# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \ - argmatch_to_argument (Value, Arglist, \ - (char const *) (Vallist), sizeof *(Vallist)) - -#endif /* ARGMATCH_H_ */ diff --git a/contrib/gnu-sort/lib/closeout.c b/contrib/gnu-sort/lib/closeout.c deleted file mode 100644 index 3c7bed9c3d55..000000000000 --- a/contrib/gnu-sort/lib/closeout.c +++ /dev/null @@ -1,93 +0,0 @@ -/* closeout.c - close standard output - - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "closeout.h" - -#include -#include - -#include "gettext.h" -#define _(msgid) gettext (msgid) - -#include "error.h" -#include "exitfail.h" -#include "quotearg.h" -#include "unlocked-io.h" -#include "__fpending.h" - -static const char *file_name; - -/* Set the file name to be reported in the event an error is detected - by close_stdout. */ -void -close_stdout_set_file_name (const char *file) -{ - file_name = file; -} - -/* Close standard output, exiting with status 'exit_failure' on failure. - If a program writes *anything* to stdout, that program should `fflush' - stdout and make sure that it succeeds before exiting. Otherwise, - suppose that you go to the extreme of checking the return status - of every function that does an explicit write to stdout. The last - printf can succeed in writing to the internal stream buffer, and yet - the fclose(stdout) could still fail (due e.g., to a disk full error) - when it tries to write out that buffered data. Thus, you would be - left with an incomplete output file and the offending program would - exit successfully. - - FIXME: note the fflush suggested above is implicit in the fclose - we actually do below. Consider doing only the fflush and/or using - setvbuf to inhibit buffering. - - Besides, it's wasteful to check the return value from every call - that writes to stdout -- just let the internal stream state record - the failure. That's what the ferror test is checking below. - - It's important to detect such failures and exit nonzero because many - tools (most notably `make' and other build-management systems) depend - on being able to detect failure in other tools via their exit status. */ - -void -close_stdout (void) -{ - int e = ferror (stdout) ? 0 : -1; - - /* If the stream's error bit is clear and there is nothing to flush, - then return right away. */ - if (e && __fpending (stdout) == 0) - return; - - if (fclose (stdout) != 0) - e = errno; - - if (0 <= e) - { - char const *write_error = _("write error"); - if (file_name) - error (exit_failure, e, "%s: %s", quotearg_colon (file_name), - write_error); - else - error (exit_failure, e, "%s", write_error); - } -} diff --git a/contrib/gnu-sort/lib/closeout.h b/contrib/gnu-sort/lib/closeout.h deleted file mode 100644 index 1b715ee30369..000000000000 --- a/contrib/gnu-sort/lib/closeout.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Close standard output. - - Copyright (C) 1998, 2000, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 CLOSEOUT_H -# define CLOSEOUT_H 1 - -# ifdef __cplusplus -extern "C" { -# endif - -void close_stdout_set_file_name (const char *file); -void close_stdout (void); - -# ifdef __cplusplus -} -# endif - -#endif diff --git a/contrib/gnu-sort/lib/dup-safer.c b/contrib/gnu-sort/lib/dup-safer.c deleted file mode 100644 index 408a1bda7602..000000000000 --- a/contrib/gnu-sort/lib/dup-safer.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Invoke dup, but avoid some glitches. - Copyright (C) 2001, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 - -#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 deleted file mode 100644 index 5a5e126b0dfb..000000000000 --- a/contrib/gnu-sort/lib/error.c +++ /dev/null @@ -1,306 +0,0 @@ -/* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2002, 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* Written by David MacKenzie . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "error.h" - -#include -#include -#include -#include - -#ifdef _LIBC -# include -#else -# include "gettext.h" -#endif - -#ifdef _LIBC -# include -# define mbsrtowcs __mbsrtowcs -#endif - -#if !_LIBC -# include "unlocked-io.h" -#endif - -#ifndef _ -# define _(String) String -#endif - -/* If NULL, error will flush stdout, then print on stderr the program - name, a colon and a space. Otherwise, error will call this - function without parameters instead. */ -void (*error_print_progname) (void); - -/* This variable is incremented each time `error' is called. */ -unsigned int error_message_count; - -#ifdef _LIBC -/* In the GNU C library, there is a predefined variable for this. */ - -# define program_name program_invocation_name -# include -# 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 - -# include -# define fflush(s) INTUSE(_IO_fflush) (s) -# undef putc -# define putc(c, fp) INTUSE(_IO_putc) (c, fp) - -# include - -#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 - -# ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -# endif - -/* The calling program should define program_name and set it to the - name of the executing program. */ -extern char *program_name; - -# if HAVE_STRERROR_R || defined strerror_r -# define __strerror_r strerror_r -# endif -#endif /* not _LIBC */ - -static void -print_errno_message (int errnum) -{ - char const *s = NULL; - -#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; -# endif -#endif - -#if !_LIBC - if (! s && ! (s = strerror (errnum))) - s = _("Unknown system error"); -#endif - -#if _LIBC - if (_IO_fwide (stderr, 0) > 0) - { - __fwprintf (stderr, L": %s", s); - return; - } -#endif - - fprintf (stderr, ": %s", s); -} - -static void -error_tail (int status, int errnum, const char *message, va_list args) -{ -#if _LIBC - if (_IO_fwide (stderr, 0) > 0) - { -# define ALLOCA_LIMIT 2000 - size_t len = strlen (message) + 1; - const wchar_t *wmessage = L"out of memory"; - wchar_t *wbuf = (len < ALLOCA_LIMIT - ? alloca (len * sizeof *wbuf) - : len <= SIZE_MAX / sizeof *wbuf - ? malloc (len * sizeof *wbuf) - : NULL); - - if (wbuf) - { - size_t res; - mbstate_t st; - const char *tmp = message; - memset (&st, '\0', sizeof (st)); - res = mbsrtowcs (wbuf, &tmp, len, &st); - wmessage = res == (size_t) -1 ? L"???" : wbuf; - } - - __vfwprintf (stderr, wmessage, args); - if (! (len < ALLOCA_LIMIT)) - free (wbuf); - } - else -#endif - vfprintf (stderr, message, args); - va_end (args); - - ++error_message_count; - if (errnum) - print_errno_message (errnum); -#if _LIBC - if (_IO_fwide (stderr, 0) > 0) - putwc (L'\n', stderr); - else -#endif - putc ('\n', stderr); - fflush (stderr); - if (status) - exit (status); -} - - -/* Print the program name and error message MESSAGE, which is a printf-style - format string with optional args. - If ERRNUM is nonzero, print its corresponding system error message. - Exit with status STATUS if it is nonzero. */ -void -error (int status, int errnum, const char *message, ...) -{ - va_list args; - -#if defined _LIBC && defined __libc_ptf_call - /* We do not want this call to be cut short by a thread - cancellation. Therefore disable cancellation for now. */ - int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), - 0); -#endif - - fflush (stdout); -#ifdef _LIBC - _IO_flockfile (stderr); -#endif - if (error_print_progname) - (*error_print_progname) (); - else - { -#if _LIBC - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s: ", program_name); - else -#endif - fprintf (stderr, "%s: ", program_name); - } - - va_start (args, message); - error_tail (status, errnum, message, args); - -#ifdef _LIBC - _IO_funlockfile (stderr); -# ifdef __libc_ptf_call - __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); -# endif -#endif -} - -/* Sometimes we want to have at most one error per line. This - variable controls whether this mode is selected or not. */ -int error_one_per_line; - -void -error_at_line (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, ...) -{ - va_list args; - - if (error_one_per_line) - { - static const char *old_file_name; - static unsigned int old_line_number; - - if (old_line_number == line_number - && (file_name == old_file_name - || strcmp (old_file_name, file_name) == 0)) - /* Simply return and print nothing. */ - return; - - old_file_name = file_name; - old_line_number = line_number; - } - -#if defined _LIBC && defined __libc_ptf_call - /* We do not want this call to be cut short by a thread - cancellation. Therefore disable cancellation for now. */ - int state = PTHREAD_CANCEL_ENABLE; - __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), - 0); -#endif - - fflush (stdout); -#ifdef _LIBC - _IO_flockfile (stderr); -#endif - if (error_print_progname) - (*error_print_progname) (); - else - { -#if _LIBC - 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 - 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); - } - - va_start (args, message); - error_tail (status, errnum, message, args); - -#ifdef _LIBC - _IO_funlockfile (stderr); -# ifdef __libc_ptf_call - __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); -# endif -#endif -} - -#ifdef _LIBC -/* Make the weak alias. */ -# undef error -# undef error_at_line -weak_alias (__error, error) -weak_alias (__error_at_line, error_at_line) -#endif diff --git a/contrib/gnu-sort/lib/error.h b/contrib/gnu-sort/lib/error.h deleted file mode 100644 index 8ed63595f24f..000000000000 --- a/contrib/gnu-sort/lib/error.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Declaration for error-reporting function - Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#ifndef _ERROR_H -#define _ERROR_H 1 - -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -# define __attribute__(Spec) /* empty */ -# endif -/* The __-protected variants of `format' and `printf' attributes - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __format__ format -# define __printf__ printf -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Print a message with `fprintf (stderr, FORMAT, ...)'; - if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). - If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ - -extern void error (int __status, int __errnum, const char *__format, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); - -extern void error_at_line (int __status, int __errnum, const char *__fname, - unsigned int __lineno, const char *__format, ...) - __attribute__ ((__format__ (__printf__, 5, 6))); - -/* If NULL, error will flush stdout, then print on stderr the program - name, a colon and a space. Otherwise, error will call this - function without parameters instead. */ -extern void (*error_print_progname) (void); - -/* This variable is incremented each time `error' is called. */ -extern unsigned int error_message_count; - -/* Sometimes we want to have at most one error per line. This - variable controls whether this mode is selected or not. */ -extern int error_one_per_line; - -#ifdef __cplusplus -} -#endif - -#endif /* error.h */ diff --git a/contrib/gnu-sort/lib/exit.h b/contrib/gnu-sort/lib/exit.h deleted file mode 100644 index 4e8d46516546..000000000000 --- a/contrib/gnu-sort/lib/exit.h +++ /dev/null @@ -1,32 +0,0 @@ -/* exit() function. - Copyright (C) 1995, 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 _EXIT_H -#define _EXIT_H - -/* Get exit() declaration. */ -#include - -/* Some systems do not define EXIT_*, even with STDC_HEADERS. */ -#ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -#endif -#ifndef EXIT_FAILURE -# define EXIT_FAILURE 1 -#endif - -#endif /* _EXIT_H */ diff --git a/contrib/gnu-sort/lib/exitfail.c b/contrib/gnu-sort/lib/exitfail.c deleted file mode 100644 index 2ae5f69555f4..000000000000 --- a/contrib/gnu-sort/lib/exitfail.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Failure exit status - - Copyright (C) 2002, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. - If not, write to the Free Software Foundation, - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#if HAVE_CONFIG_H -# include -#endif - -#include "exitfail.h" -#include "exit.h" - -int volatile exit_failure = EXIT_FAILURE; diff --git a/contrib/gnu-sort/lib/exitfail.h b/contrib/gnu-sort/lib/exitfail.h deleted file mode 100644 index cf5ab719586e..000000000000 --- a/contrib/gnu-sort/lib/exitfail.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Failure exit status - - Copyright (C) 2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. - If not, write to the Free Software Foundation, - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -extern int volatile exit_failure; diff --git a/contrib/gnu-sort/lib/fopen-safer.c b/contrib/gnu-sort/lib/fopen-safer.c deleted file mode 100644 index c5c97c8a19ab..000000000000 --- a/contrib/gnu-sort/lib/fopen-safer.c +++ /dev/null @@ -1,72 +0,0 @@ -/* Invoke fopen, but avoid some glitches. - Copyright (C) 2001, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 -#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 deleted file mode 100644 index 08ba35be3637..000000000000 --- a/contrib/gnu-sort/lib/getopt.c +++ /dev/null @@ -1,1068 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to drepper@gnu.org - before changing it! - Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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. */ - -/* This tells Alpha OSF/1 not to define a getopt prototype in . - Ditto for AIX 3.2 and . */ -#ifndef _NO_PROTO -# define _NO_PROTO -#endif - -#ifdef HAVE_CONFIG_H -# include -#endif - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -# ifndef const -# define const -# endif -#endif - -#include - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -# include -# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -# define ELIDE_CODE -# endif -#endif - -#ifndef ELIDE_CODE - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -# include -# include -#endif /* GNU C library. */ - -#ifdef VMS -# include -# if HAVE_STRING_H - 0 -# include -# endif -#endif - -#ifndef _ -/* This is for other GNU distributions with internationalized messages. */ -# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC -# include -# ifndef _ -# define _(msgid) gettext (msgid) -# endif -# else -# define _(msgid) (msgid) -# endif -#endif - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "getopt.h" - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -/* 1003.2 says this must be 1 before any call. */ -int optind = 1; - -/* Formerly, initialization of getopt depended on optind==0, which - causes problems with re-calling getopt as programs generally don't - know that. */ - -int __getopt_initialized; - -/* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - -static char *nextchar; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int optopt = '?'; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return -1 with `optind' != ARGC. */ - -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering; - -/* Value of POSIXLY_CORRECT environment variable. */ -static char *posixly_correct; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -# include -# define my_index strchr -#else - -# if HAVE_STRING_H -# include -# else -# include -# endif - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -#ifndef getenv -extern char *getenv (); -#endif - -static char * -my_index (str, chr) - const char *str; - int chr; -{ - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; -} - -/* If using GCC, we can safely declare strlen this way. - If not using GCC, it is ok not to declare it. */ -#ifdef __GNUC__ -/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. - That was relevant to code that was here before. */ -# if (!defined __STDC__ || !__STDC__) && !defined strlen -/* gcc with -traditional declares the built-in strlen to return int, - and has done so at least since version 2.4.5. -- rms. */ -extern int strlen (const char *); -# endif /* not __STDC__ */ -#endif /* __GNUC__ */ - -#endif /* not __GNU_LIBRARY__ */ - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -#ifdef _LIBC -/* Bash 2.0 gives us an environment variable containing flags - indicating ARGV elements that should not be considered arguments. */ - -#ifdef USE_NONOPTION_FLAGS -/* Defined in getopt_init.c */ -extern char *__getopt_nonoption_flags; - -static int nonoption_flags_max_len; -static int nonoption_flags_len; -#endif - -static int original_argc; -static char *const *original_argv; - -/* Make sure the environment variable bash 2.0 puts in the environment - is valid for the getopt call we must make sure that the ARGV passed - to getopt is that one passed to the process. */ -static void -__attribute__ ((unused)) -store_args_and_env (int argc, char *const *argv) -{ - /* XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ - original_argc = argc; - original_argv = argv; -} -# ifdef text_set_element -text_set_element (__libc_subinit, store_args_and_env); -# endif /* text_set_element */ - -# ifdef USE_NONOPTION_FLAGS -# define SWAP_FLAGS(ch1, ch2) \ - if (nonoption_flags_len > 0) \ - { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ - } -# else -# define SWAP_FLAGS(ch1, ch2) -# endif -#else /* !_LIBC */ -# define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -#if defined __STDC__ && __STDC__ -static void exchange (char **); -#endif - -static void -exchange (argv) - char **argv; -{ - int bottom = first_nonopt; - int middle = last_nonopt; - int top = optind; - char *tem; - - /* Exchange the shorter segment with the far end of the longer segment. - That puts the shorter segment into the right place. - It leaves the longer segment in the right place overall, - but it consists of two parts that need to be swapped next. */ - -#if defined _LIBC && defined USE_NONOPTION_FLAGS - /* First make sure the handling of the `__getopt_nonoption_flags' - string can work normally. Our top argument must be in the range - of the string. */ - if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) - { - /* We must extend the array. The user plays games with us and - presents new arguments. */ - char *new_str = malloc (top + 1); - if (new_str == NULL) - nonoption_flags_len = nonoption_flags_max_len = 0; - else - { - memset (__mempcpy (new_str, __getopt_nonoption_flags, - nonoption_flags_max_len), - '\0', top + 1 - nonoption_flags_max_len); - nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; - } - } -#endif - - while (top > middle && middle > bottom) - { - if (top - middle > middle - bottom) - { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; - - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } - else - { - /* Top segment is the short one. */ - int len = top - middle; - register int i; - - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS (bottom + i, middle + i); - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } - } - - /* Update records for the slots the non-options now occupy. */ - - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; -} - -/* Initialize the internal data when the first call is made. */ - -#if defined __STDC__ && __STDC__ -static const char *_getopt_initialize (int, char *const *, const char *); -#endif -static const char * -_getopt_initialize (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - /* Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - first_nonopt = last_nonopt = optind; - - nextchar = NULL; - - posixly_correct = getenv ("POSIXLY_CORRECT"); - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (posixly_correct != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - -#if defined _LIBC && defined USE_NONOPTION_FLAGS - if (posixly_correct == NULL - && argc == original_argc && argv == original_argv) - { - if (nonoption_flags_max_len == 0) - { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') - nonoption_flags_max_len = -1; - else - { - const char *orig_str = __getopt_nonoption_flags; - int len = nonoption_flags_max_len = strlen (orig_str); - if (nonoption_flags_max_len < argc) - nonoption_flags_max_len = argc; - __getopt_nonoption_flags = - (char *) malloc (nonoption_flags_max_len); - if (__getopt_nonoption_flags == NULL) - nonoption_flags_max_len = -1; - else - memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), - '\0', nonoption_flags_max_len - len); - } - } - nonoption_flags_len = nonoption_flags_max_len; - } - else - nonoption_flags_len = 0; -#endif - - return optstring; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If `getopt' finds another option character, it returns that character, - updating `optind' and `nextchar' so that the next call to `getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, `getopt' returns -1. - Then `optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `optarg', otherwise `optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - int print_errors = opterr; - if (optstring[0] == ':') - print_errors = 0; - - if (argc < 1) - return -1; - - optarg = NULL; - - if (optind == 0 || !__getopt_initialized) - { - if (optind == 0) - optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = _getopt_initialize (argc, argv, optstring); - __getopt_initialized = 1; - } - - /* Test whether ARGV[optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ -#if defined _LIBC && defined USE_NONOPTION_FLAGS -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ - || (optind < nonoption_flags_len \ - && __getopt_nonoption_flags[optind] == '1')) -#else -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') -#endif - - if (nextchar == NULL || *nextchar == '\0') - { - /* Advance to the next ARGV-element. */ - - /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ - if (last_nonopt > optind) - last_nonopt = optind; - if (first_nonopt > optind) - first_nonopt = optind; - - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (last_nonopt != optind) - first_nonopt = optind; - - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ - - while (optind < argc && NONOPTION_P) - optind++; - last_nonopt = optind; - } - - /* The special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (optind != argc && !strcmp (argv[optind], "--")) - { - optind++; - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; - return -1; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if (NONOPTION_P) - { - if (ordering == REQUIRE_ORDER) - return -1; - optarg = argv[optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Skip the initial punctuation. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } - - /* Decode the current option-ARGV-element. */ - - /* Check whether the ARGV-element is a long option. - - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. - - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". - - This distinction seems to be the most useful approach. */ - - if (longopts != NULL - && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; - - for (nameend = nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) - == (unsigned int) strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else if (long_only - || pfound->has_arg != p->has_arg - || pfound->flag != p->flag - || pfound->val != p->val) - /* Second or later nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (print_errors) - fprintf (stderr, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - optopt = 0; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (print_errors) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - _("%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - _("%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[optind - 1][0], pfound->name); - } - - nextchar += strlen (nextchar); - - optopt = pfound->val; - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (print_errors) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' - || my_index (optstring, *nextchar) == NULL) - { - if (print_errors) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, _("%s: unrecognized option `--%s'\n"), - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - optopt = 0; - return '?'; - } - } - - /* Look at and handle the next short option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (print_errors) - { - if (posixly_correct) - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: illegal option -- %c\n"), - argv[0], c); - else - fprintf (stderr, _("%s: invalid option -- %c\n"), - argv[0], c); - } - optopt = c; - return '?'; - } - /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (print_errors) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - - /* optarg is now the argument, see if it's in the - table of longopts. */ - - for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) - { - if (print_errors) - fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (print_errors) - fprintf (stderr, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); - - nextchar += strlen (nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (print_errors) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - nextchar = NULL; - return 'W'; /* Let the application handle it. */ - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*nextchar != '\0') - { - optarg = nextchar; - optind++; - } - else - optarg = NULL; - nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (print_errors) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, - _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of `getopt'. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - - c = getopt (argc, argv, "abc:d:0123456789"); - if (c == -1) - break; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/contrib/gnu-sort/lib/getopt.h b/contrib/gnu-sort/lib/getopt.h deleted file mode 100644 index a1b8dd6658f2..000000000000 --- a/contrib/gnu-sort/lib/getopt.h +++ /dev/null @@ -1,180 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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. */ - -#ifndef _GETOPT_H - -#ifndef __need_getopt -# define _GETOPT_H 1 -#endif - -/* If __GNU_LIBRARY__ is not already defined, either we are being used - standalone, or this is the first header included in the source file. - If we are being used with glibc, we need to include , but - that does not exist if we are standalone. So: if __GNU_LIBRARY__ is - not defined, include , which will pull in for us - if it's from glibc. (Why ctype.h? It's guaranteed to exist and it - doesn't flood the namespace with stuff the way some other headers do.) */ -#if !defined __GNU_LIBRARY__ -# include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Set to an option character which was unrecognized. */ - -extern int optopt; - -#ifndef __need_getopt -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ - -struct option -{ -# if (defined __STDC__ && __STDC__) || defined __cplusplus - const char *name; -# else - char *name; -# endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -# define no_argument 0 -# define required_argument 1 -# define optional_argument 2 -#endif /* need getopt */ - - -/* Get definitions and prototypes for functions to process the - arguments in ARGV (ARGC of them, minus the program name) for - options given in OPTS. - - Return the option character from OPTS just read. Return -1 when - there are no more options. For unrecognized options, or options - missing arguments, `optopt' is set to the option letter, and '?' is - returned. - - The OPTS string is a list of characters which are recognized option - letters, optionally followed by colons, specifying that that letter - takes an argument, to be placed in `optarg'. - - If a letter in OPTS is followed by two colons, its argument is - optional. This behavior is specific to the GNU `getopt'. - - The argument `--' causes premature termination of argument - scanning, explicitly telling `getopt' that there are no more - options. - - If OPTS begins with `--', then non-option arguments are treated as - arguments to the option '\0'. This behavior is specific to the GNU - `getopt'. */ - -#if (defined __STDC__ && __STDC__) || defined __cplusplus -# ifdef __GNU_LIBRARY__ -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int __argc, char *const *__argv, const char *__shortopts); -# else /* not __GNU_LIBRARY__ */ -extern int getopt (); -# endif /* __GNU_LIBRARY__ */ - -# ifndef __need_getopt -extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, - const struct option *__longopts, int *__longind); -extern int getopt_long_only (int __argc, char *const *__argv, - const char *__shortopts, - const struct option *__longopts, int *__longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int __argc, char *const *__argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - int __long_only); -# endif -#else /* not __STDC__ */ -extern int getopt (); -# ifndef __need_getopt -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -# endif -#endif /* __STDC__ */ - -#ifdef __cplusplus -} -#endif - -/* Make sure we later can get all the definitions and declarations. */ -#undef __need_getopt - -#endif /* getopt.h */ diff --git a/contrib/gnu-sort/lib/getopt1.c b/contrib/gnu-sort/lib/getopt1.c deleted file mode 100644 index 22a7efbdd19a..000000000000 --- a/contrib/gnu-sort/lib/getopt1.c +++ /dev/null @@ -1,188 +0,0 @@ -/* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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. */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "getopt.h" - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -#ifndef const -#define const -#endif -#endif - -#include - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -#include -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - -#ifndef ELIDE_CODE - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include -#endif - -#ifndef NULL -#define NULL 0 -#endif - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') doesn't match a long option, - but does match a short option, it is parsed as a short option - instead. */ - -int -getopt_long_only (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -#include - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static struct option long_options[] = - { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; - - c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); - if (c == -1) - break; - - switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case 'd': - printf ("option d with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/contrib/gnu-sort/lib/gettext.h b/contrib/gnu-sort/lib/gettext.h deleted file mode 100644 index 835732e01fe5..000000000000 --- a/contrib/gnu-sort/lib/gettext.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#ifndef _LIBGETTEXT_H -#define _LIBGETTEXT_H 1 - -/* NLS can be disabled through the configure --disable-nls option. */ -#if ENABLE_NLS - -/* Get declarations of GNU message catalog functions. */ -# include - -#else - -/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which - chokes if dcgettext is defined as a macro. So include it now, to make - later inclusions of a NOP. We don't include - as well because people using "gettext.h" will not include , - and also including would fail on SunOS 4, whereas - is OK. */ -#if defined(__sun) -# include -#endif - -/* Disabled NLS. - The casts to 'const char *' serve the purpose of producing warnings - for invalid uses of the value returned from these functions. - On pre-ANSI systems without 'const', the config.h file is supposed to - contain "#define const". */ -# define gettext(Msgid) ((const char *) (Msgid)) -# define dgettext(Domainname, Msgid) ((const char *) (Msgid)) -# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) -# define ngettext(Msgid1, Msgid2, N) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) -# define dngettext(Domainname, Msgid1, Msgid2, N) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) -# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) -# define textdomain(Domainname) ((const char *) (Domainname)) -# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) -# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) - -#endif - -/* A pseudo function call that serves as a marker for the automated - extraction of messages, but does not call gettext(). The run-time - translation is done at a different place in the code. - The argument, String, should be a literal string. Concatenated strings - and other string expressions won't work. - The macro's expansion is not parenthesized, so that it is suitable as - initializer for static 'char[]' or 'const char[]' variables. */ -#define gettext_noop(String) String - -#endif /* _LIBGETTEXT_H */ diff --git a/contrib/gnu-sort/lib/hard-locale.c b/contrib/gnu-sort/lib/hard-locale.c deleted file mode 100644 index 67a4144a6fec..000000000000 --- a/contrib/gnu-sort/lib/hard-locale.c +++ /dev/null @@ -1,75 +0,0 @@ -/* hard-locale.c -- Determine whether a locale is hard. - - Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "hard-locale.h" - -#if HAVE_LOCALE_H -# include -#endif - -#include -#include - -/* Return true if the current CATEGORY locale is hard, i.e. if you - can't get away with assuming traditional C or POSIX behavior. */ -bool -hard_locale (int category) -{ -#if ! HAVE_SETLOCALE - return false; -#else - - bool hard = true; - char const *p = setlocale (category, NULL); - - if (p) - { -# if defined __GLIBC__ && 2 <= __GLIBC__ - if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0) - hard = false; -# else - char *locale = malloc (strlen (p) + 1); - if (locale) - { - 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 = false; - - /* Restore the caller's locale. */ - setlocale (category, locale); - free (locale); - } -# endif - } - - return hard; - -#endif -} diff --git a/contrib/gnu-sort/lib/hard-locale.h b/contrib/gnu-sort/lib/hard-locale.h deleted file mode 100644 index 010cb27682b2..000000000000 --- a/contrib/gnu-sort/lib/hard-locale.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Determine whether a locale is hard. - - Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 HARD_LOCALE_H_ -# define HARD_LOCALE_H_ 1 - -# include - -bool hard_locale (int); - -#endif /* HARD_LOCALE_H_ */ diff --git a/contrib/gnu-sort/lib/human.c b/contrib/gnu-sort/lib/human.c deleted file mode 100644 index f024c73ea079..000000000000 --- a/contrib/gnu-sort/lib/human.c +++ /dev/null @@ -1,485 +0,0 @@ -/* human.c -- print human readable file size - - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 and Larry McVoy. */ - -#if HAVE_CONFIG_H -# include -#endif - -#include "human.h" - -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif -#ifndef UINTMAX_MAX -# define UINTMAX_MAX ((uintmax_t) -1) -#endif - -#if HAVE_LOCALE_H && HAVE_LOCALECONV -# include -#endif - -#include -#include -#include - -#include "gettext.h" -#define _(msgid) gettext (msgid) - -#include -#include -#include - -/* The maximum length of a suffix like "KiB". */ -#define HUMAN_READABLE_SUFFIX_LENGTH_MAX 3 - -static const char power_letter[] = -{ - 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 */ -}; - - -/* If INEXACT_STYLE is not human_round_to_nearest, and if easily - possible, adjust VALUE according to the style. */ - -static long double -adjust_value (int inexact_style, long double value) -{ - /* Do not use the floorl or ceill functions, as that would mean - checking for their presence and possibly 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_nearest && value < UINTMAX_MAX) - { - uintmax_t u = value; - value = u + (inexact_style == human_ceiling && u != value); - } - - return value; -} - -/* Group the digits of NUMBER according to the grouping rules of the - current locale. NUMBER contains NUMBERLEN digits. Modify the - bytes pointed to by NUMBER in place, subtracting 1 from NUMBER for - each byte inserted. Return the starting address of the modified - number. - - To group the digits, use GROUPING and THOUSANDS_SEP as in `struct - lconv' from . */ - -static char * -group_number (char *number, size_t numberlen, - char const *grouping, char const *thousands_sep) -{ - register char *d; - size_t grouplen = SIZE_MAX; - size_t thousands_seplen = strlen (thousands_sep); - size_t i = numberlen; - - /* The maximum possible value for NUMBERLEN is the number of digits - in the square of the largest uintmax_t, so double the size of - uintmax_t before converting to a bound. 302 / 1000 is ceil - (log10 (2.0)). Add 1 for integer division truncation. */ - char buf[2 * sizeof (uintmax_t) * CHAR_BIT * 302 / 1000 + 1]; - - memcpy (buf, number, numberlen); - d = number + numberlen; - - for (;;) - { - unsigned char g = *grouping; - - if (g) - { - grouplen = g < CHAR_MAX ? g : i; - grouping++; - } - - if (i < grouplen) - grouplen = i; - - d -= grouplen; - i -= grouplen; - memcpy (d, buf + i, grouplen); - if (i == 0) - return d; - - d -= thousands_seplen; - memcpy (d, thousands_sep, thousands_seplen); - } -} - -/* Convert N to a human readable format in BUF, using the options OPTS. - - N is expressed in units of FROM_BLOCK_SIZE. FROM_BLOCK_SIZE must - be nonnegative. - - Use units of TO_BLOCK_SIZE in the output number. TO_BLOCK_SIZE - must be positive. - - Use (OPTS & (human_round_to_nearest | human_floor | human_ceiling)) - to determine whether to take the ceiling or floor of any result - that cannot be expressed exactly. - - If (OPTS & human_group_digits), group the thousands digits - according to the locale, e.g., `1,000,000' in an American English - locale. - - If (OPTS & human_autoscale), deduce the output block size - automatically; TO_BLOCK_SIZE must be 1 but it has no effect on the - output. Use powers of 1024 if (OPTS & human_base_1024), and powers - of 1000 otherwise. For example, assuming powers of 1024, 8500 - would be converted to 8.3, 133456345 to 127, 56990456345 to 53, and - so on. Numbers smaller than the power aren't modified. - human_autoscale is normally used together with human_SI. - - If (OPTS & human_SI), append an SI prefix indicating which power is - being used. If in addition (OPTS & human_B), append "B" (if base - 1000) or "iB" (if base 1024) to the SI prefix. When ((OPTS & - human_SI) && ! (OPTS & human_autoscale)), TO_BLOCK_SIZE must be a - power of 1024 or of 1000, depending on (OPTS & - human_base_1024). */ - -char * -human_readable (uintmax_t n, char *buf, int opts, - uintmax_t from_block_size, uintmax_t to_block_size) -{ - int inexact_style = - opts & (human_round_to_nearest | human_floor | human_ceiling); - unsigned int base = opts & human_base_1024 ? 1024 : 1000; - uintmax_t amt; - int tenths; - int exponent = -1; - int exponent_max = sizeof power_letter - 1; - char *p; - char *psuffix; - char const *integerlim; - - /* 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; - - char const *decimal_point = "."; - size_t decimal_pointlen = 1; - char const *grouping = ""; - char const *thousands_sep = ""; -#if HAVE_LOCALE_H && HAVE_LOCALECONV - struct lconv const *l = localeconv (); - size_t pointlen = strlen (l->decimal_point); - if (0 < pointlen && pointlen <= MB_LEN_MAX) - { - decimal_point = l->decimal_point; - decimal_pointlen = pointlen; - } - grouping = l->grouping; - if (strlen (l->thousands_sep) <= MB_LEN_MAX) - thousands_sep = l->thousands_sep; -#endif - - psuffix = buf + LONGEST_HUMAN_READABLE - HUMAN_READABLE_SUFFIX_LENGTH_MAX; - p = psuffix; - - /* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE - units. If this can be done exactly with integer arithmetic, do - not use floating point operations. */ - if (to_block_size <= from_block_size) - { - if (from_block_size % to_block_size == 0) - { - uintmax_t multiplier = from_block_size / to_block_size; - amt = n * multiplier; - if (amt / multiplier == n) - { - tenths = 0; - rounding = 0; - goto use_integer_arithmetic; - } - } - } - else if (from_block_size != 0 && to_block_size % from_block_size == 0) - { - uintmax_t divisor = to_block_size / from_block_size; - uintmax_t r10 = (n % divisor) * 10; - uintmax_t r2 = (r10 % divisor) * 2; - amt = n / divisor; - tenths = r10 / divisor; - rounding = r2 < divisor ? 0 < r2 : 2 + (divisor < r2); - goto use_integer_arithmetic; - } - - { - /* 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. */ - - long double dto_block_size = to_block_size; - long double damt = n * (from_block_size / dto_block_size); - size_t buflen; - size_t nonintegerlen; - - if (! (opts & human_autoscale)) - { - sprintf (buf, "%.0Lf", adjust_value (inexact_style, damt)); - buflen = strlen (buf); - nonintegerlen = 0; - } - else - { - long double e = 1; - exponent = 0; - - do - { - e *= base; - exponent++; - } - while (e * base <= damt && exponent < exponent_max); - - damt /= e; - - sprintf (buf, "%.1Lf", adjust_value (inexact_style, damt)); - buflen = strlen (buf); - nonintegerlen = decimal_pointlen + 1; - - if (1 + nonintegerlen + ! (opts & human_base_1024) < buflen - || ((opts & human_suppress_point_zero) - && buf[buflen - 1] == '0')) - { - sprintf (buf, "%.0Lf", - adjust_value (inexact_style, damt * 10) / 10); - buflen = strlen (buf); - nonintegerlen = 0; - } - } - - p = psuffix - buflen; - memmove (p, buf, buflen); - integerlim = p + buflen - nonintegerlen; - } - goto do_grouping; - - use_integer_arithmetic: - { - /* The computation can be done exactly, with integer arithmetic. - - Use power of BASE notation if requested and if adjusted AMT is - large enough. */ - - if (opts & human_autoscale) - { - exponent = 0; - - if (base <= amt) - { - do - { - unsigned int r10 = (amt % base) * 10 + tenths; - unsigned int r2 = (r10 % base) * 2 + (rounding >> 1); - amt /= base; - tenths = r10 / base; - rounding = (r2 < base - ? (r2 + rounding) != 0 - : 2 + (base < r2 + rounding)); - exponent++; - } - while (base <= amt && exponent < exponent_max); - - if (amt < 10) - { - if (inexact_style == human_round_to_nearest - ? 2 < rounding + (tenths & 1) - : inexact_style == human_ceiling && 0 < rounding) - { - tenths++; - rounding = 0; - - if (tenths == 10) - { - amt++; - tenths = 0; - } - } - - if (amt < 10 - && (tenths || ! (opts & human_suppress_point_zero))) - { - *--p = '0' + tenths; - p -= decimal_pointlen; - memcpy (p, decimal_point, decimal_pointlen); - tenths = rounding = 0; - } - } - } - } - - if (inexact_style == human_round_to_nearest - ? 5 < tenths + (0 < rounding + (amt & 1)) - : inexact_style == human_ceiling && 0 < tenths + rounding) - { - amt++; - - if ((opts & human_autoscale) - && amt == base && exponent < exponent_max) - { - exponent++; - if (! (opts & human_suppress_point_zero)) - { - *--p = '0'; - p -= decimal_pointlen; - memcpy (p, decimal_point, decimal_pointlen); - } - amt = 1; - } - } - - integerlim = p; - - do - { - int digit = amt % 10; - *--p = digit + '0'; - } - while ((amt /= 10) != 0); - } - - do_grouping: - if (opts & human_group_digits) - p = group_number (p, integerlim - p, grouping, thousands_sep); - - if (opts & human_SI) - { - if (exponent < 0) - { - uintmax_t power; - exponent = 0; - for (power = 1; power < to_block_size; power *= base) - if (++exponent == exponent_max) - break; - } - - if (exponent) - *psuffix++ = (! (opts & human_base_1024) && exponent == 1 - ? 'k' - : power_letter[exponent]); - - if (opts & human_B) - { - if ((opts & human_base_1024) && exponent) - *psuffix++ = 'i'; - *psuffix++ = 'B'; - } - } - - *psuffix = '\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_opts[] = - { - human_autoscale + human_SI + human_base_1024, - human_autoscale + human_SI - }; - -static uintmax_t -default_block_size (void) -{ - return getenv ("POSIXLY_CORRECT") ? 512 : DEFAULT_BLOCK_SIZE; -} - -static strtol_error -humblock (char const *spec, uintmax_t *block_size, int *options) -{ - int i; - int opts = 0; - - if (! spec - && ! (spec = getenv ("BLOCK_SIZE")) - && ! (spec = getenv ("BLOCKSIZE"))) - *block_size = default_block_size (); - else - { - if (*spec == '\'') - { - opts |= human_group_digits; - spec++; - } - - if (0 <= (i = ARGMATCH (spec, block_size_args, block_size_opts))) - { - opts |= block_size_opts[i]; - *block_size = 1; - } - else - { - char *ptr; - strtol_error e = xstrtoumax (spec, &ptr, 0, block_size, - "eEgGkKmMpPtTyYzZ0"); - if (e != LONGINT_OK) - return e; - for (; ! ('0' <= *spec && *spec <= '9'); spec++) - if (spec == ptr) - { - opts |= human_SI; - if (ptr[-1] == 'B') - opts |= human_B; - if (ptr[-1] != 'B' || ptr[-2] == 'i') - opts |= human_base_1024; - break; - } - } - } - - *options = opts; - return LONGINT_OK; -} - -int -human_options (char const *spec, bool report_errors, uintmax_t *block_size) -{ - int opts; - strtol_error e = humblock (spec, block_size, &opts); - 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); - return opts; -} diff --git a/contrib/gnu-sort/lib/human.h b/contrib/gnu-sort/lib/human.h deleted file mode 100644 index b67ba4e9ae0c..000000000000 --- a/contrib/gnu-sort/lib/human.h +++ /dev/null @@ -1,88 +0,0 @@ -/* human.h -- print human readable file size - - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 - Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 and Larry McVoy. */ - -#ifndef HUMAN_H_ -# define HUMAN_H_ 1 - -# if HAVE_CONFIG_H -# include -# endif - -# include -# include - -# if HAVE_STDINT_H -# include -# endif -# if HAVE_UNISTD_H -# include -# endif - -/* A conservative bound on the maximum length of a human-readable string. - The output can be the square of the largest uintmax_t, so double - its size before converting to a bound. - 302 / 1000 is ceil (log10 (2.0)). Add 1 for integer division truncation. - Also, the output can have a thousands separator between every digit, - so multiply by MB_LEN_MAX + 1 and then subtract MB_LEN_MAX. - Finally, append 3, the maximum length of a suffix. */ -# define LONGEST_HUMAN_READABLE \ - ((2 * sizeof (uintmax_t) * CHAR_BIT * 302 / 1000 + 1) * (MB_LEN_MAX + 1) \ - - MB_LEN_MAX + 3) - -/* Options for human_readable. */ -enum -{ - /* Unless otherwise specified these options may be ORed together. */ - - /* The following three options are mutually exclusive. */ - /* Round to plus infinity (default). */ - human_ceiling = 0, - /* Round to nearest, ties to even. */ - human_round_to_nearest = 1, - /* Round to minus infinity. */ - human_floor = 2, - - /* Group digits together, e.g. `1,000,000'. This uses the - locale-defined grouping; the traditional C locale does not group, - so this has effect only if some other locale is in use. */ - human_group_digits = 4, - - /* When autoscaling, suppress ".0" at end. */ - human_suppress_point_zero = 8, - - /* Scale output and use SI-style units, ignoring the output block size. */ - human_autoscale = 16, - - /* Prefer base 1024 to base 1000. */ - human_base_1024 = 32, - - /* Append SI prefix, e.g. "k" or "M". */ - human_SI = 64, - - /* Append "B" (if base 1000) or "iB" (if base 1024) to SI prefix. */ - human_B = 128 -}; - -char *human_readable (uintmax_t, char *, int, uintmax_t, uintmax_t); - -int human_options (char const *, bool, uintmax_t *); - -#endif /* HUMAN_H_ */ diff --git a/contrib/gnu-sort/lib/inttostr.c b/contrib/gnu-sort/lib/inttostr.c deleted file mode 100644 index 78a48af84cee..000000000000 --- a/contrib/gnu-sort/lib/inttostr.c +++ /dev/null @@ -1,49 +0,0 @@ -/* inttostr.c -- convert integers to printable strings - - 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 */ - -#include "inttostr.h" - -/* Convert I to a printable string in BUF, which must be at least - INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the - printable string, which need not start at BUF. */ - -char * -inttostr (inttype i, char *buf) -{ - char *p = buf + INT_STRLEN_BOUND (inttype); - *p = 0; - - if (i < 0) - { - do - *--p = '0' - i % 10; - while ((i /= 10) != 0); - - *--p = '-'; - } - else - { - do - *--p = '0' + i % 10; - while ((i /= 10) != 0); - } - - return p; -} diff --git a/contrib/gnu-sort/lib/inttostr.h b/contrib/gnu-sort/lib/inttostr.h deleted file mode 100644 index 6f2416b53faf..000000000000 --- a/contrib/gnu-sort/lib/inttostr.h +++ /dev/null @@ -1,47 +0,0 @@ -/* inttostr.h -- convert integers to printable strings - - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 -#if HAVE_STDINT_H -# include -#endif - -#include - -#if HAVE_SYS_TYPES_H -# include -#endif - -/* Upper bound on the string length of an integer converted to string. - 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit; - add 1 for integer division truncation; add 1 more for a minus sign. */ -#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2) - -#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) - -char *offtostr (off_t, char *); -char *imaxtostr (intmax_t, char *); -char *umaxtostr (uintmax_t, char *); diff --git a/contrib/gnu-sort/lib/long-options.c b/contrib/gnu-sort/lib/long-options.c deleted file mode 100644 index 1c4e74a001d6..000000000000 --- a/contrib/gnu-sort/lib/long-options.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Utility to accept --help and --version options as unobtrusively as possible. - - Copyright (C) 1993, 1994, 1998, 1999, 2000, 2002, 2003, 2004 Free - Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 - -/* Specification. */ -#include "long-options.h" - -#include -#include -#include -#include - -#include "version-etc.h" - -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, - void (*usage_func) (int), - /* const char *author1, ...*/ ...) -{ - 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) (EXIT_SUCCESS); - - case 'v': - { - va_list authors; - va_start (authors, usage_func); - version_etc_va (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 deleted file mode 100644 index 50f0c34e1010..000000000000 --- a/contrib/gnu-sort/lib/long-options.h +++ /dev/null @@ -1,26 +0,0 @@ -/* long-options.h -- declaration for --help- and --version-handling function. - Copyright (C) 1993, 1994, 1998, 1999, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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. */ - -void parse_long_options (int _argc, - char **_argv, - const char *_command_name, - const char *_package, - const char *_version, - void (*_usage) (int), - /* const char *author1, ...*/ ...); diff --git a/contrib/gnu-sort/lib/memcoll.c b/contrib/gnu-sort/lib/memcoll.c deleted file mode 100644 index e777e6a5bc7f..000000000000 --- a/contrib/gnu-sort/lib/memcoll.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Locale-specific memory comparison. - Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "memcoll.h" - -#include -#include - -/* 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. Perhaps 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; - -#if HAVE_STRCOLL - - 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; - -#else - - diff = memcmp (s1, s2, s1len < s2len ? s1len : s2len); - if (! diff) - diff = s1len < s2len ? -1 : s1len != s2len; - errno = 0; - -#endif - - return diff; -} diff --git a/contrib/gnu-sort/lib/memcoll.h b/contrib/gnu-sort/lib/memcoll.h deleted file mode 100644 index 66b2ecb1e87f..000000000000 --- a/contrib/gnu-sort/lib/memcoll.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Locale-specific memory comparison. - - Copyright (C) 1999, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 . */ - -#ifndef MEMCOLL_H_ -# define MEMCOLL_H_ 1 - -# include - -int memcoll (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 deleted file mode 100644 index bdd756e9c51f..000000000000 --- a/contrib/gnu-sort/lib/pathmax.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Define PATH_MAX somehow. Requires sys/types.h. - Copyright (C) 1992, 1999, 2001, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 __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 deleted file mode 100644 index dc67b575cff5..000000000000 --- a/contrib/gnu-sort/lib/physmem.c +++ /dev/null @@ -1,307 +0,0 @@ -/* Calculate the size of physical memory. - Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 - -#if HAVE_SYS_SYSMP_H -# include -#endif - -#if HAVE_SYS_SYSINFO_H && HAVE_MACHINE_HAL_SYSINFO_H -# include -# include -#endif - -#if HAVE_SYS_TABLE_H -# include -#endif - -#include - -#if HAVE_SYS_PARAM_H -# include -#endif - -#if HAVE_SYS_SYSCTL_H -# include -#endif - -#if HAVE_SYS_SYSTEMCFG_H -# include -#endif - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# include -/* MEMORYSTATUSEX is missing from older windows headers, so define - a local replacement. */ -typedef struct -{ - DWORD dwLength; - DWORD dwMemoryLoad; - DWORDLONG ullTotalPhys; - DWORDLONG ullAvailPhys; - DWORDLONG ullTotalPageFile; - DWORDLONG ullAvailPageFile; - DWORDLONG ullTotalVirtual; - DWORDLONG ullAvailVirtual; - DWORDLONG ullAvailExtendedVirtual; -} lMEMORYSTATUSEX; -typedef WINBOOL (WINAPI *PFN_MS_EX) (lMEMORYSTATUSEX*); -#endif - -#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) - -/* Return the total amount of physical memory. */ -double -physmem_total (void) -{ -#if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE - { /* This works on linux-gnu, solaris2 and cygwin. */ - double pages = sysconf (_SC_PHYS_PAGES); - double pagesize = sysconf (_SC_PAGESIZE); - if (0 <= pages && 0 <= pagesize) - return pages * pagesize; - } -#endif - -#if HAVE_PSTAT_GETSTATIC - { /* This works on hpux11. */ - 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 - -#if HAVE_SYSMP && defined MP_SAGET && defined MPSA_RMINFO && defined _SC_PAGESIZE - { /* This works on irix6. */ - struct rminfo realmem; - if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0) - { - double pagesize = sysconf (_SC_PAGESIZE); - double pages = realmem.physmem; - if (0 <= pages && 0 <= pagesize) - return pages * pagesize; - } - } -#endif - -#if HAVE_GETSYSINFO && defined GSI_PHYSMEM - { /* This works on Tru64 UNIX V4/5. */ - int physmem; - - if (getsysinfo (GSI_PHYSMEM, (caddr_t) &physmem, sizeof (physmem), - NULL, NULL, NULL) == 1) - { - double kbytes = physmem; - - if (0 <= kbytes) - return kbytes * 1024.0; - } - } -#endif - -#if HAVE_SYSCTL && defined HW_PHYSMEM - { /* This works on *bsd and darwin. */ - unsigned int physmem; - size_t len = sizeof physmem; - static int mib[2] = { CTL_HW, HW_PHYSMEM }; - - if (sysctl (mib, ARRAY_SIZE (mib), &physmem, &len, NULL, 0) == 0 - && len == sizeof (physmem)) - return (double) physmem; - } -#endif - -#if HAVE__SYSTEM_CONFIGURATION - /* This works on AIX. */ - return _system_configuration.physmem; -#endif - -#if defined _WIN32 - { /* this works on windows */ - PFN_MS_EX pfnex; - HMODULE h = GetModuleHandle ("kernel32.dll"); - - if (!h) - return 0.0; - - /* Use GlobalMemoryStatusEx if available. */ - if ((pfnex = (PFN_MS_EX) GetProcAddress (h, "GlobalMemoryStatusEx"))) - { - lMEMORYSTATUSEX lms_ex; - lms_ex.dwLength = sizeof lms_ex; - if (!pfnex (&lms_ex)) - return 0.0; - return (double) lms_ex.ullTotalPhys; - } - - /* Fall back to GlobalMemoryStatus which is always available. - but returns wrong results for physical memory > 4GB. */ - else - { - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return (double) ms.dwTotalPhys; - } - } -#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 - { /* This works on linux-gnu, solaris2 and cygwin. */ - 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 - { /* This works on hpux11. */ - 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 - -#if HAVE_SYSMP && defined MP_SAGET && defined MPSA_RMINFO && defined _SC_PAGESIZE - { /* This works on irix6. */ - struct rminfo realmem; - if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0) - { - double pagesize = sysconf (_SC_PAGESIZE); - double pages = realmem.availrmem; - if (0 <= pages && 0 <= pagesize) - return pages * pagesize; - } - } -#endif - -#if HAVE_TABLE && defined TBL_VMSTATS - { /* This works on Tru64 UNIX V4/5. */ - struct tbl_vmstats vmstats; - - if (table (TBL_VMSTATS, 0, &vmstats, 1, sizeof (vmstats)) == 1) - { - double pages = vmstats.free_count; - double pagesize = vmstats.pagesize; - - if (0 <= pages && 0 <= pagesize) - return pages * pagesize; - } - } -#endif - -#if HAVE_SYSCTL && defined HW_USERMEM - { /* This works on *bsd and darwin. */ - unsigned int usermem; - size_t len = sizeof usermem; - static int mib[2] = { CTL_HW, HW_USERMEM }; - - if (sysctl (mib, ARRAY_SIZE (mib), &usermem, &len, NULL, 0) == 0 - && len == sizeof (usermem)) - return (double) usermem; - } -#endif - -#if defined _WIN32 - { /* this works on windows */ - PFN_MS_EX pfnex; - HMODULE h = GetModuleHandle ("kernel32.dll"); - - if (!h) - return 0.0; - - /* Use GlobalMemoryStatusEx if available. */ - if ((pfnex = (PFN_MS_EX) GetProcAddress (h, "GlobalMemoryStatusEx"))) - { - lMEMORYSTATUSEX lms_ex; - lms_ex.dwLength = sizeof lms_ex; - if (!pfnex (&lms_ex)) - return 0.0; - return (double) lms_ex.ullAvailPhys; - } - - /* Fall back to GlobalMemoryStatus which is always available. - but returns wrong results for physical memory > 4GB */ - else - { - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return (double) ms.dwAvailPhys; - } - } -#endif - - /* Guess 25% of physical memory. */ - return physmem_total () / 4; -} - - -#if DEBUG - -# include -# include - -int -main (void) -{ - printf ("%12.f %12.f\n", physmem_total (), physmem_available ()); - exit (0); -} - -#endif /* DEBUG */ - -/* -Local Variables: -compile-command: "gcc -DDEBUG -DHAVE_CONFIG_H -I.. -g -O -Wall -W physmem.c" -End: -*/ diff --git a/contrib/gnu-sort/lib/physmem.h b/contrib/gnu-sort/lib/physmem.h deleted file mode 100644 index 67f880c9a8d4..000000000000 --- a/contrib/gnu-sort/lib/physmem.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Calculate the size of physical memory. - - Copyright (C) 2000, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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. */ - -#ifndef PHYSMEM_H_ -# define PHYSMEM_H_ 1 - -double physmem_total (void); -double physmem_available (void); - -#endif /* PHYSMEM_H_ */ diff --git a/contrib/gnu-sort/lib/posixver.c b/contrib/gnu-sort/lib/posixver.c deleted file mode 100644 index 754d7ac55ace..000000000000 --- a/contrib/gnu-sort/lib/posixver.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Which POSIX version to conform to, for utilities. - - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "posixver.h" - -#include -#include - -#if HAVE_UNISTD_H -# include -#endif -#ifndef _POSIX2_VERSION -# define _POSIX2_VERSION 0 -#endif - -#ifndef DEFAULT_POSIX2_VERSION -# define DEFAULT_POSIX2_VERSION _POSIX2_VERSION -#endif - -/* The POSIX version that utilities should conform to. The default is - specified by the system. */ - -int -posix2_version (void) -{ - long int v = DEFAULT_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 deleted file mode 100644 index b64f6a2ea1b2..000000000000 --- a/contrib/gnu-sort/lib/posixver.h +++ /dev/null @@ -1 +0,0 @@ -int posix2_version (void); diff --git a/contrib/gnu-sort/lib/quote.c b/contrib/gnu-sort/lib/quote.c deleted file mode 100644 index 5f11d836b3c3..000000000000 --- a/contrib/gnu-sort/lib/quote.c +++ /dev/null @@ -1,41 +0,0 @@ -/* quote.c - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "quotearg.h" -#include "quote.h" - -/* Return an unambiguous printable representation of NAME, - allocated in slot N, suitable for diagnostics. */ -char const * -quote_n (int n, char const *name) -{ - return quotearg_n_style (n, locale_quoting_style, name); -} - -/* Return an unambiguous printable representation of NAME, - suitable for diagnostics. */ -char const * -quote (char const *name) -{ - return quote_n (0, name); -} diff --git a/contrib/gnu-sort/lib/quote.h b/contrib/gnu-sort/lib/quote.h deleted file mode 100644 index 682f9d1fd2f9..000000000000 --- a/contrib/gnu-sort/lib/quote.h +++ /dev/null @@ -1,22 +0,0 @@ -/* quote.h - prototypes for quote.c - - Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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. */ - - -char const *quote_n (int n, char const *name); -char const *quote (char const *name); diff --git a/contrib/gnu-sort/lib/quotearg.c b/contrib/gnu-sort/lib/quotearg.c deleted file mode 100644 index 64fa67635455..000000000000 --- a/contrib/gnu-sort/lib/quotearg.c +++ /dev/null @@ -1,673 +0,0 @@ -/* quotearg.c - quote arguments for output - - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "quotearg.h" - -#include "xalloc.h" - -#include -#include -#include -#include -#include -#include - -#include "gettext.h" -#define _(msgid) gettext (msgid) -#define N_(msgid) msgid - -#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 iswprint(wc) isprint ((unsigned char) (wc)) -# undef HAVE_MBSINIT -#endif - -#if !defined mbsinit && !HAVE_MBSINIT -# define mbsinit(ps) 1 -#endif - -#ifndef iswprint -# if HAVE_WCTYPE_H -# include -# endif -# if !defined iswprint && !HAVE_ISWPRINT -# define iswprint(wc) 1 -# endif -#endif - -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif - -#define INT_BITS (sizeof (int) * CHAR_BIT) - -struct quoting_options -{ - /* Basic quoting style. */ - enum quoting_style style; - - /* 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) -{ - int e = errno; - struct quoting_options *p = xmalloc (sizeof *p); - *p = *(o ? o : &default_quoting_options); - errno = e; - return p; -} - -/* Get the value of O's quoting style. If O is null, use the default. */ -enum quoting_style -get_quoting_style (struct quoting_options *o) -{ - return (o ? o : &default_quoting_options)->style; -} - -/* In O (or in the default if O is null), - set the value of the quoting style to S. */ -void -set_quoting_style (struct quoting_options *o, enum quoting_style s) -{ - (o ? o : &default_quoting_options)->style = s; -} - -/* In O (or in the default if O is null), - set the value of the quoting options for character C to I. - Return the old value. Currently, the only values defined for I are - 0 (the default) and 1 (which means to quote the character even if - it would not otherwise be quoted). */ -int -set_char_quoting (struct quoting_options *o, char c, int i) -{ - unsigned char uc = c; - 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 SIZE_MAX, 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; - bool backslash_escapes = false; - bool 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 = true; - quote_string = "\""; - quote_string_len = 1; - break; - - case escape_quoting_style: - backslash_escapes = true; - 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 = true; - 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_MAX ? arg[i] == '\0' : i == argsize); i++) - { - unsigned char c; - unsigned char esc; - - if (backslash_escapes - && quote_string_len - && i + quote_string_len <= argsize - && memcmp (arg + i, quote_string, quote_string_len) == 0) - 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. */ - c = arg[i + 2]; - i += 2; - STORE ('?'); - STORE ('\\'); - STORE ('?'); - break; - } - break; - - default: - break; - } - break; - - case '\a': esc = 'a'; goto c_escape; - case '\b': esc = 'b'; goto c_escape; - case '\f': esc = 'f'; goto c_escape; - case '\n': esc = 'n'; goto c_and_shell_escape; - case '\r': esc = 'r'; goto c_and_shell_escape; - case '\t': esc = 't'; goto c_and_shell_escape; - case '\v': esc = 'v'; goto c_escape; - case '\\': esc = c; 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 '}': /* sometimes special if isolated */ - if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1)) - break; - /* Fall through. */ - case '#': case '~': - if (i != 0) - break; - /* Fall through. */ - case ' ': - case '!': /* special in bash */ - case '"': case '$': case '&': - case '(': case ')': case '*': case ';': - case '<': - case '=': /* sometimes special in 0th or (with "set -k") later args */ - case '>': case '[': - case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */ - case '`': case '|': - /* A shell special character. In theory, '$' and '`' could - be the first bytes of multibyte characters, which means - we should check them with mbrtowc, but in practice this - doesn't happen so it's not worth worrying about. */ - if (quoting_style == shell_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 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': case ']': case '_': case 'a': case 'b': - case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': - case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': - case 'o': case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': - /* These characters don't cause problems, no matter what the - quoting style is. They cannot start multibyte sequences. */ - break; - - default: - /* If we have a multibyte sequence, copy it until we reach - its end, find an error, or come back to the initial shift - state. For C-like styles, if the sequence has - unprintable characters, escape the whole sequence, since - we can't easily escape single characters within it. */ - { - /* Length of multibyte sequence found so far. */ - size_t m; - - bool printable; - - if (unibyte_locale) - { - m = 1; - printable = isprint (c) != 0; - } - else - { - mbstate_t mbstate; - memset (&mbstate, 0, sizeof mbstate); - - m = 0; - printable = true; - if (argsize == SIZE_MAX) - argsize = strlen (arg); - - do - { - wchar_t w; - size_t bytes = mbrtowc (&w, &arg[i + m], - argsize - (i + m), &mbstate); - if (bytes == 0) - break; - else if (bytes == (size_t) -1) - { - printable = false; - break; - } - else if (bytes == (size_t) -2) - { - printable = false; - while (i + m < argsize && arg[i + m]) - m++; - break; - } - else - { - /* Work around a bug with older shells that "see" a '\' - that is really the 2nd byte of a multibyte character. - In practice the problem is limited to ASCII - chars >= '@' that are shell special chars. */ - if ('[' == 0x5b && quoting_style == shell_quoting_style) - { - size_t j; - for (j = 1; j < bytes; j++) - switch (arg[i + m + j]) - { - case '[': case '\\': case '^': - case '`': case '|': - goto use_shell_always_quoting_style; - } - } - - if (! iswprint (w)) - printable = false; - m += bytes; - } - } - while (! mbsinit (&mbstate)); - } - - if (1 < m || (backslash_escapes && ! printable)) - { - /* Output a multibyte sequence, or an escaped - unprintable unibyte character. */ - size_t ilim = i + m; - - for (;;) - { - if (backslash_escapes && ! printable) - { - 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 (i == 0 && quoting_style == shell_quoting_style) - goto use_shell_always_quoting_style; - - 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 SIZE_MAX, use the string length of the argument for - ARGSIZE. */ -size_t -quotearg_buffer (char *buffer, size_t buffersize, - char const *arg, size_t argsize, - struct quoting_options const *o) -{ - struct quoting_options const *p = o ? o : &default_quoting_options; - int e = errno; - size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize, - p->style, p); - errno = e; - return r; -} - -/* Like quotearg_buffer (..., ARG, ARGSIZE, O), except return newly - allocated storage containing the quoted string. */ -char * -quotearg_alloc (char const *arg, size_t argsize, - struct quoting_options const *o) -{ - int e = errno; - size_t bufsize = quotearg_buffer (0, 0, arg, argsize, o) + 1; - char *buf = xmalloc (bufsize); - quotearg_buffer (buf, bufsize, arg, argsize, o); - errno = e; - return buf; -} - -/* Use storage slot N to return a quoted version of argument ARG. - ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a - null-terminated string. - OPTIONS specifies the quoting options. - The returned value points to static storage that can be - reused by the next call to this function with the same value of N. - N must be nonnegative. N is deliberately declared with type "int" - to allow for future extensions (using negative values). */ -static char * -quotearg_n_options (int n, char const *arg, size_t argsize, - struct quoting_options const *options) -{ - int e = errno; - - /* 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; - - if (xalloc_oversized (n1, sizeof *slotvec)) - xalloc_die (); - - if (slotvec == &slotvec0) - { - slotvec = xmalloc (sizeof *slotvec); - *slotvec = slotvec0; - } - slotvec = xrealloc (slotvec, n1 * sizeof *slotvec); - 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; - if (val != slot0) - free (val); - slotvec[n].val = val = xmalloc (size); - quotearg_buffer (val, size, arg, argsize, options); - } - - errno = e; - return val; - } -} - -char * -quotearg_n (int n, char const *arg) -{ - return quotearg_n_options (n, arg, SIZE_MAX, &default_quoting_options); -} - -char * -quotearg (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_MAX, &o); -} - -char * -quotearg_n_style_mem (int n, enum quoting_style s, - char const *arg, size_t argsize) -{ - struct quoting_options const o = quoting_options_from_style (s); - return quotearg_n_options (n, arg, argsize, &o); -} - -char * -quotearg_style (enum quoting_style s, char const *arg) -{ - return quotearg_n_style (0, s, arg); -} - -char * -quotearg_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_MAX, &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 deleted file mode 100644 index 14dc316d74bd..000000000000 --- a/contrib/gnu-sort/lib/quotearg.h +++ /dev/null @@ -1,137 +0,0 @@ -/* quotearg.h - quote arguments for output - - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 */ - -#ifndef QUOTEARG_H_ -# define QUOTEARG_H_ 1 - -# include - -/* Basic quoting styles. */ -enum quoting_style - { - /* Output names as-is (ls --quoting-style=literal). */ - literal_quoting_style, - - /* Quote names for the shell if they contain shell metacharacters - or would cause ambiguous output (ls --quoting-style=shell). */ - shell_quoting_style, - - /* Quote names for the shell, even if they would normally not - require quoting (ls --quoting-style=shell-always). */ - shell_always_quoting_style, - - /* Quote names as for a C language string (ls --quoting-style=c). */ - c_quoting_style, - - /* Like c_quoting_style except omit the surrounding double-quote - characters (ls --quoting-style=escape). */ - escape_quoting_style, - - /* Like clocale_quoting_style, but quote `like this' instead of - "like this" in the default C locale (ls --quoting-style=locale). */ - locale_quoting_style, - - /* Like c_quoting_style except use quotation marks appropriate for - the locale (ls --quoting-style=clocale). */ - clocale_quoting_style - }; - -/* For now, --quoting-style=literal is the default, but this may change. */ -# ifndef DEFAULT_QUOTING_STYLE -# define DEFAULT_QUOTING_STYLE literal_quoting_style -# endif - -/* Names of quoting styles and their corresponding values. */ -extern char const *const quoting_style_args[]; -extern enum quoting_style const quoting_style_vals[]; - -struct quoting_options; - -/* The functions listed below set and use a hidden variable - that contains the default quoting style options. */ - -/* Allocate a new set of quoting options, with contents initially identical - to O if O is not null, or to the default if O is null. - It is the caller's responsibility to free the result. */ -struct quoting_options *clone_quoting_options (struct quoting_options *o); - -/* Get the value of O's quoting style. If O is null, use the default. */ -enum quoting_style get_quoting_style (struct quoting_options *o); - -/* In O (or in the default if O is null), - set the value of the quoting style to S. */ -void set_quoting_style (struct quoting_options *o, enum quoting_style s); - -/* In O (or in the default if O is null), - set the value of the quoting options for character C to I. - Return the old value. Currently, the only values defined for I are - 0 (the default) and 1 (which means to quote the character even if - it would not otherwise be quoted). */ -int set_char_quoting (struct quoting_options *o, char c, int i); - -/* 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); - -/* Like quotearg_buffer, except return the result in a newly allocated - buffer. It is the caller's responsibility to free the result. */ -char *quotearg_alloc (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 (int n, char const *arg); - -/* Equivalent to quotearg_n (0, ARG). */ -char *quotearg (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 (int n, enum quoting_style s, char const *arg); - -/* Use style S and storage slot N to return a quoted version of the - argument ARG of size ARGSIZE. This is like quotearg_n_style - (N, S, ARG), except it can quote null bytes. */ -char *quotearg_n_style_mem (int n, enum quoting_style s, - char const *arg, size_t argsize); - -/* Equivalent to quotearg_n_style (0, S, ARG). */ -char *quotearg_style (enum quoting_style s, char const *arg); - -/* Like quotearg (ARG), except also quote any instances of CH. */ -char *quotearg_char (char const *arg, char ch); - -/* Equivalent to quotearg_char (ARG, ':'). */ -char *quotearg_colon (char const *arg); - -#endif /* !QUOTEARG_H_ */ diff --git a/contrib/gnu-sort/lib/stat-macros.h b/contrib/gnu-sort/lib/stat-macros.h deleted file mode 100644 index facbabbc3c87..000000000000 --- a/contrib/gnu-sort/lib/stat-macros.h +++ /dev/null @@ -1,255 +0,0 @@ -/* stat-related macros - - Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 and Jim Meyering. */ - -#ifndef STAT_MACROS_H -# define STAT_MACROS_H 1 - -# if ! defined S_ISREG && ! defined S_IFREG -# error "you must include before including this file" -# endif - -# ifndef S_IFMT -# define S_IFMT 0170000 -# endif - -# if STAT_MACROS_BROKEN -# undef S_ISBLK -# undef S_ISCHR -# undef S_ISDIR -# undef S_ISDOOR -# undef S_ISFIFO -# undef S_ISLNK -# undef S_ISNAM -# undef S_ISMPB -# undef S_ISMPC -# undef S_ISNWK -# undef S_ISREG -# undef S_ISSOCK -# endif - - -# ifndef S_ISBLK -# ifdef S_IFBLK -# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -# else -# define S_ISBLK(m) 0 -# endif -# endif - -# ifndef S_ISCHR -# ifdef S_IFCHR -# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -# else -# define S_ISCHR(m) 0 -# endif -# endif - -# ifndef S_ISDIR -# ifdef S_IFDIR -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -# else -# define S_ISDIR(m) 0 -# endif -# endif - -# ifndef S_ISDOOR /* Solaris 2.5 and up */ -# ifdef S_IFDOOR -# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR) -# else -# define S_ISDOOR(m) 0 -# endif -# endif - -# ifndef S_ISFIFO -# ifdef S_IFIFO -# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -# else -# define S_ISFIFO(m) 0 -# endif -# endif - -# ifndef S_ISLNK -# ifdef S_IFLNK -# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -# else -# define S_ISLNK(m) 0 -# endif -# endif - -# ifndef S_ISMPB /* V7 */ -# ifdef S_IFMPB -# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) -# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) -# else -# define S_ISMPB(m) 0 -# define S_ISMPC(m) 0 -# endif -# endif - -# ifndef S_ISNAM /* Xenix */ -# ifdef S_IFNAM -# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) -# else -# define S_ISNAM(m) 0 -# endif -# endif - -# ifndef S_ISNWK /* HP/UX */ -# ifdef S_IFNWK -# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) -# else -# define S_ISNWK(m) 0 -# endif -# endif - -# ifndef S_ISREG -# ifdef S_IFREG -# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -# else -# define S_ISREG(m) 0 -# endif -# endif - -# ifndef S_ISSOCK -# ifdef S_IFSOCK -# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) -# else -# define S_ISSOCK(m) 0 -# endif -# endif - - -# ifndef S_TYPEISMQ -# define S_TYPEISMQ(p) 0 -# endif - -# ifndef S_TYPEISTMO -# define S_TYPEISTMO(p) 0 -# endif - - -# ifndef S_TYPEISSEM -# ifdef S_INSEM -# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) -# else -# define S_TYPEISSEM(p) 0 -# endif -# endif - -# ifndef S_TYPEISSHM -# ifdef S_INSHD -# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) -# else -# define S_TYPEISSHM(p) 0 -# endif -# endif - -/* contiguous */ -# ifndef S_ISCTG -# define S_ISCTG(p) 0 -# endif - -/* Cray DMF (data migration facility): off line, with data */ -# ifndef S_ISOFD -# define S_ISOFD(p) 0 -# endif - -/* Cray DMF (data migration facility): off line, with no data */ -# ifndef S_ISOFL -# define S_ISOFL(p) 0 -# endif - -/* If any of the following are undefined, - define them to their de facto standard values. */ -# 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) - -#endif /* STAT_MACROS_H */ diff --git a/contrib/gnu-sort/lib/stdio-safer.h b/contrib/gnu-sort/lib/stdio-safer.h deleted file mode 100644 index 8a22f1220658..000000000000 --- a/contrib/gnu-sort/lib/stdio-safer.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Invoke stdio functions, but avoid some glitches. - - Copyright (C) 2001, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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. */ - -#include - -FILE *fopen_safer (char const *, char const *); diff --git a/contrib/gnu-sort/lib/strnlen.c b/contrib/gnu-sort/lib/strnlen.c deleted file mode 100644 index c9f389845117..000000000000 --- a/contrib/gnu-sort/lib/strnlen.c +++ /dev/null @@ -1,48 +0,0 @@ -/* Find the length of STRING, but scan at most MAXLEN characters. - Copyright (C) 1996, 1997, 1998, 2000-2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#if HAVE_CONFIG_H -# include -#endif -#undef strnlen - -#include - -#undef __strnlen -#undef strnlen - -#ifndef _LIBC -# define strnlen rpl_strnlen -#endif - -#ifndef weak_alias -# define __strnlen strnlen -#endif - -/* Find the length of STRING, but scan at most MAXLEN characters. - If no '\0' terminator is found in that many characters, return MAXLEN. */ - -size_t -__strnlen (const char *string, size_t maxlen) -{ - const char *end = memchr (string, '\0', maxlen); - return end ? (size_t) (end - string) : maxlen; -} -#ifdef weak_alias -weak_alias (__strnlen, strnlen) -#endif diff --git a/contrib/gnu-sort/lib/timespec.h b/contrib/gnu-sort/lib/timespec.h deleted file mode 100644 index 2c32a23db425..000000000000 --- a/contrib/gnu-sort/lib/timespec.h +++ /dev/null @@ -1,71 +0,0 @@ -/* timespec -- System time interface - - Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 ! defined TIMESPEC_H -# define TIMESPEC_H - -/* You must include config.h before including this file. */ - -# include -# if TIME_WITH_SYS_TIME -# include -# include -# else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -# endif - -# if ! HAVE_STRUCT_TIMESPEC -/* Some systems don't define this struct, e.g., AIX 4.1, Ultrix 4.3. */ -struct timespec -{ - time_t tv_sec; - long tv_nsec; -}; -# endif - -# 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) - -# ifdef ST_MTIM_NSEC -# define TIMESPEC_NS(timespec) ((timespec).ST_MTIM_NSEC) -# else -# define TIMESPEC_NS(timespec) 0 -# endif - -# if ! HAVE_DECL_NANOSLEEP -/* Don't specify a prototype here. Some systems (e.g., OSF) declare - nanosleep with a conflicting one (const-less first parameter). */ -int nanosleep (); -# endif - -int gettime (struct timespec *); -int settime (struct timespec const *); - -#endif diff --git a/contrib/gnu-sort/lib/umaxtostr.c b/contrib/gnu-sort/lib/umaxtostr.c deleted file mode 100644 index 4f49a7f8ddd9..000000000000 --- a/contrib/gnu-sort/lib/umaxtostr.c +++ /dev/null @@ -1,3 +0,0 @@ -#define inttostr umaxtostr -#define inttype uintmax_t -#include "inttostr.c" diff --git a/contrib/gnu-sort/lib/unistd-safer.h b/contrib/gnu-sort/lib/unistd-safer.h deleted file mode 100644 index 2976e9d0dc01..000000000000 --- a/contrib/gnu-sort/lib/unistd-safer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Invoke unistd functions, but avoid some glitches. - - Copyright (C) 2001, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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. */ - -int dup_safer (int); diff --git a/contrib/gnu-sort/lib/version-etc.c b/contrib/gnu-sort/lib/version-etc.c deleted file mode 100644 index fd71eff93f5d..000000000000 --- a/contrib/gnu-sort/lib/version-etc.c +++ /dev/null @@ -1,176 +0,0 @@ -/* Utility to help print --version output in a consistent format. - Copyright (C) 1999-2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 - -/* Specification. */ -#include "version-etc.h" - -#include -#include -#include -#include "unlocked-io.h" - -#include "gettext.h" -#define _(msgid) gettext (msgid) - -/* Default copyright goes to the FSF. */ - -const char* version_etc_copyright = - /* Do *not* mark this string for translation. */ - "Copyright (C) 2004 Free Software Foundation, Inc."; - - -/* Like version_etc, below, but with the NULL-terminated author list - provided via a variable of type va_list. */ -void -version_etc_va (FILE *stream, - const char *command_name, const char *package, - const char *version, va_list authors) -{ - size_t n_authors; - - /* Count the number of authors. */ - { - va_list tmp_authors; - -#ifdef __va_copy - __va_copy (tmp_authors, authors); -#else - tmp_authors = authors; -#endif - - n_authors = 0; - while (va_arg (tmp_authors, const char *) != NULL) - ++n_authors; - } - - if (command_name) - fprintf (stream, "%s (%s) %s\n", command_name, package, version); - else - fprintf (stream, "%s %s\n", package, version); - - switch (n_authors) - { - case 0: - /* The caller must provide at least one author name. */ - abort (); - case 1: - /* TRANSLATORS: %s denotes an author name. */ - vfprintf (stream, _("Written by %s.\n"), authors); - break; - case 2: - /* TRANSLATORS: Each %s denotes an author name. */ - vfprintf (stream, _("Written by %s and %s.\n"), authors); - break; - case 3: - /* TRANSLATORS: Each %s denotes an author name. */ - vfprintf (stream, _("Written by %s, %s, and %s.\n"), authors); - break; - case 4: - /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), authors); - break; - case 5: - /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), authors); - break; - case 6: - /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"), - authors); - break; - case 7: - /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"), - authors); - break; - case 8: - /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("\ -Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"), - authors); - break; - case 9: - /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("\ -Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"), - authors); - break; - default: - /* 10 or more authors. Use an abbreviation, since the human reader - will probably not want to read the entire list anyway. */ - /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("\ -Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), - authors); - break; - } - va_end (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); -} - - -/* 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. - - The author names are passed as separate arguments, with an additional - NULL argument at the end. */ -void -version_etc (FILE *stream, - const char *command_name, const char *package, - const char *version, /* const char *author1, ...*/ ...) -{ - va_list authors; - - va_start (authors, version); - version_etc_va (stream, command_name, package, version, authors); -} diff --git a/contrib/gnu-sort/lib/version-etc.h b/contrib/gnu-sort/lib/version-etc.h deleted file mode 100644 index d505e75eae7d..000000000000 --- a/contrib/gnu-sort/lib/version-etc.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Utility to help print --version output in a consistent format. - Copyright (C) 1999, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 - -# include -# include - -extern const char *version_etc_copyright; - -extern void version_etc_va (FILE *stream, - const char *command_name, const char *package, - const char *version, va_list authors); - -extern void version_etc (FILE *stream, - const char *command_name, const char *package, - const char *version, - /* const char *author1, ...*/ ...); - -#endif /* VERSION_ETC_H */ diff --git a/contrib/gnu-sort/lib/xalloc-die.c b/contrib/gnu-sort/lib/xalloc-die.c deleted file mode 100644 index ca3a689fa5c4..000000000000 --- a/contrib/gnu-sort/lib/xalloc-die.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Report a memory allocation failure and exit. - - Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004 Free - Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "xalloc.h" - -#include - -#include "error.h" -#include "exitfail.h" - -#include "gettext.h" -#define _(msgid) gettext (msgid) -#define N_(msgid) msgid - -void -xalloc_die (void) -{ - error (exit_failure, 0, "%s", _("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 not return, call abort. Also, the abort is a - safety feature if exit_failure is 0 (which shouldn't happen). */ - abort (); -} diff --git a/contrib/gnu-sort/lib/xalloc.h b/contrib/gnu-sort/lib/xalloc.h deleted file mode 100644 index d81f2a676488..000000000000 --- a/contrib/gnu-sort/lib/xalloc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* xalloc.h -- malloc with out-of-memory checking - - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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_ - -# include - - -# ifdef __cplusplus -extern "C" { -# 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 - -/* This function is always triggered when memory is exhausted. - It must be defined by the application, either explicitly - or by using gnulib's xalloc-die module. This is the - function to call when one wants the program to die because of a - memory allocation failure. */ -extern void xalloc_die (void) ATTRIBUTE_NORETURN; - -void *xmalloc (size_t s); -void *xnmalloc (size_t n, size_t s); -void *xzalloc (size_t s); -void *xcalloc (size_t n, size_t s); -void *xrealloc (void *p, size_t s); -void *xnrealloc (void *p, size_t n, size_t s); -void *x2realloc (void *p, size_t *pn); -void *x2nrealloc (void *p, size_t *pn, size_t s); -void *xclone (void const *p, size_t s); -char *xstrdup (const char *str); - -/* Return 1 if an array of N objects, each of size S, cannot exist due - to size arithmetic overflow. S must be positive and N must be - nonnegative. This is a macro, not an inline function, so that it - works correctly even when SIZE_MAX < N. - - By gnulib convention, SIZE_MAX represents overflow in size - calculations, so the conservative dividend to use here is - SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. - However, malloc (SIZE_MAX) fails on all known hosts where - sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for - exactly-SIZE_MAX allocations on such hosts; this avoids a test and - branch when S is known to be 1. */ -# define xalloc_oversized(n, s) \ - ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) - -/* These macros are deprecated; they will go away soon, and are retained - temporarily only to ease conversion to the functions described above. */ -# define CCLONE(p, n) xclone (p, (n) * sizeof *(p)) -# define CLONE(p) xclone (p, sizeof *(p)) -# define NEW(type, var) type *var = xmalloc (sizeof (type)) -# define XCALLOC(type, n) xcalloc (n, sizeof (type)) -# define XMALLOC(type, n) xnmalloc (n, sizeof (type)) -# define XREALLOC(p, type, n) xnrealloc (p, n, sizeof (type)) -# define XFREE(p) free (p) - - -# ifdef __cplusplus -} -# endif - - -#endif /* !XALLOC_H_ */ diff --git a/contrib/gnu-sort/lib/xmalloc.c b/contrib/gnu-sort/lib/xmalloc.c deleted file mode 100644 index 9b7a948c2f18..000000000000 --- a/contrib/gnu-sort/lib/xmalloc.c +++ /dev/null @@ -1,221 +0,0 @@ -/* xmalloc.c -- malloc with out of memory checking - - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "xalloc.h" - -#include -#include - -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif - -/* Allocate an array of N objects, each with S bytes of memory, - dynamically, with error checking. S must be nonzero. */ - -static inline void * -xnmalloc_inline (size_t n, size_t s) -{ - void *p; - if (xalloc_oversized (n, s) || (! (p = malloc (n * s)) && n != 0)) - xalloc_die (); - return p; -} - -void * -xnmalloc (size_t n, size_t s) -{ - return xnmalloc_inline (n, s); -} - -/* Allocate N bytes of memory dynamically, with error checking. */ - -void * -xmalloc (size_t n) -{ - return xnmalloc_inline (n, 1); -} - -/* Change the size of an allocated block of memory P to an array of N - objects each of S bytes, with error checking. S must be nonzero. */ - -static inline void * -xnrealloc_inline (void *p, size_t n, size_t s) -{ - if (xalloc_oversized (n, s) || (! (p = realloc (p, n * s)) && n != 0)) - xalloc_die (); - return p; -} - -void * -xnrealloc (void *p, size_t n, size_t s) -{ - return xnrealloc_inline (p, n, s); -} - -/* Change the size of an allocated block of memory P to N bytes, - with error checking. */ - -void * -xrealloc (void *p, size_t n) -{ - return xnrealloc_inline (p, n, 1); -} - - -/* If P is null, allocate a block of at least *PN such objects; - otherwise, reallocate P so that it contains more than *PN objects - each of S bytes. *PN must be nonzero unless P is null, and S must - be nonzero. Set *PN to the new number of objects, and return the - pointer to the new block. *PN is never set to zero, and the - returned pointer is never null. - - Repeated reallocations are guaranteed to make progress, either by - allocating an initial block with a nonzero size, or by allocating a - larger block. - - In the following implementation, nonzero sizes are doubled so that - repeated reallocations have O(N log N) overall cost rather than - O(N**2) cost, but the specification for this function does not - guarantee that sizes are doubled. - - Here is an example of use: - - int *p = NULL; - size_t used = 0; - size_t allocated = 0; - - void - append_int (int value) - { - if (used == allocated) - p = x2nrealloc (p, &allocated, sizeof *p); - p[used++] = value; - } - - This causes x2nrealloc to allocate a block of some nonzero size the - first time it is called. - - To have finer-grained control over the initial size, set *PN to a - nonzero value before calling this function with P == NULL. For - example: - - int *p = NULL; - size_t used = 0; - size_t allocated = 0; - size_t allocated1 = 1000; - - void - append_int (int value) - { - if (used == allocated) - { - p = x2nrealloc (p, &allocated1, sizeof *p); - allocated = allocated1; - } - p[used++] = value; - } - - */ - -static inline void * -x2nrealloc_inline (void *p, size_t *pn, size_t s) -{ - size_t n = *pn; - - if (! p) - { - if (! n) - { - /* The approximate size to use for initial small allocation - requests, when the invoking code specifies an old size of - zero. 64 bytes is the largest "small" request for the - GNU C library malloc. */ - enum { DEFAULT_MXFAST = 64 }; - - n = DEFAULT_MXFAST / s; - n += !n; - } - } - else - { - if (SIZE_MAX / 2 / s < n) - xalloc_die (); - n *= 2; - } - - *pn = n; - return xrealloc (p, n * s); -} - -void * -x2nrealloc (void *p, size_t *pn, size_t s) -{ - return x2nrealloc_inline (p, pn, s); -} - -/* If P is null, allocate a block of at least *PN bytes; otherwise, - reallocate P so that it contains more than *PN bytes. *PN must be - nonzero unless P is null. Set *PN to the new block's size, and - return the pointer to the new block. *PN is never set to zero, and - the returned pointer is never null. */ - -void * -x2realloc (void *p, size_t *pn) -{ - return x2nrealloc_inline (p, pn, 1); -} - -/* Allocate S bytes of zeroed memory dynamically, with error checking. - There's no need for xnzalloc (N, S), since it would be equivalent - to xcalloc (N, S). */ - -void * -xzalloc (size_t s) -{ - return memset (xmalloc (s), 0, s); -} - -/* Allocate zeroed memory for N elements of S bytes, with error - checking. S must be nonzero. */ - -void * -xcalloc (size_t n, size_t s) -{ - void *p; - /* Test for overflow, since some calloc implementations don't have - proper overflow checks. */ - if (xalloc_oversized (n, s) || (! (p = calloc (n, s)) && n != 0)) - xalloc_die (); - return p; -} - -/* Clone an object P of size S, with error checking. There's no need - for xnclone (P, N, S), since xclone (P, N * S) works without any - need for an arithmetic overflow check. */ - -void * -xclone (void const *p, size_t s) -{ - return memcpy (xmalloc (s), p, s); -} diff --git a/contrib/gnu-sort/lib/xmemcoll.c b/contrib/gnu-sort/lib/xmemcoll.c deleted file mode 100644 index 433d67f9c49e..000000000000 --- a/contrib/gnu-sort/lib/xmemcoll.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Locale-specific memory comparison. - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 -#include - -#include "gettext.h" -#define _(msgid) gettext (msgid) - -#include "error.h" -#include "exitfail.h" -#include "memcoll.h" -#include "quotearg.h" -#include "xmemcoll.h" - -/* 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 (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 deleted file mode 100644 index 2f422e8c1c00..000000000000 --- a/contrib/gnu-sort/lib/xmemcoll.h +++ /dev/null @@ -1,2 +0,0 @@ -#include -int xmemcoll (char *, size_t, char *, size_t); diff --git a/contrib/gnu-sort/lib/xstrtol.c b/contrib/gnu-sort/lib/xstrtol.c deleted file mode 100644 index 906e4a1cc1e9..000000000000 --- a/contrib/gnu-sort/lib/xstrtol.c +++ /dev/null @@ -1,291 +0,0 @@ -/* A more useful interface to strtol. - - Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004 Free - Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 -# define STRTOL_T_MINIMUM LONG_MIN -# define STRTOL_T_MAXIMUM LONG_MAX -#endif - -/* Some pre-ANSI implementations (e.g. SunOS 4) - need stderr defined if assertion checking is enabled. */ -#include - -#include -#include -#include -#include -#include -#include - -/* The extra casts work around common compiler bugs. */ -#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) -#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))) - -#ifndef STRTOL_T_MINIMUM -# define STRTOL_T_MINIMUM TYPE_MINIMUM (__strtol_t) -# define STRTOL_T_MAXIMUM TYPE_MAXIMUM (__strtol_t) -#endif - -#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_STRTOIMAX && !defined strtoimax -intmax_t strtoimax (); -#endif - -#if !HAVE_DECL_STRTOUMAX && !defined strtoumax -uintmax_t strtoumax (); -#endif - -static strtol_error -bkm_scale (__strtol_t *x, int scale_factor) -{ - if (TYPE_SIGNED (__strtol_t) && *x < STRTOL_T_MINIMUM / scale_factor) - { - *x = STRTOL_T_MINIMUM; - return LONGINT_OVERFLOW; - } - if (STRTOL_T_MAXIMUM / scale_factor < *x) - { - *x = STRTOL_T_MAXIMUM; - return LONGINT_OVERFLOW; - } - *x *= scale_factor; - return LONGINT_OK; -} - -static strtol_error -bkm_scale_by_power (__strtol_t *x, int base, int power) -{ - strtol_error err = LONGINT_OK; - while (power--) - err |= bkm_scale (x, base); - return err; -} - -/* 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; - strtol_error err = LONGINT_OK; - - assert (0 <= strtol_base && strtol_base <= 36); - - p = (ptr ? ptr : &t_ptr); - - if (! TYPE_SIGNED (__strtol_t)) - { - const char *q = s; - unsigned char ch = *q; - while (ISSPACE (ch)) - ch = *++q; - if (ch == '-') - return LONGINT_INVALID; - } - - errno = 0; - tmp = __strtol (s, p, strtol_base); - - 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; - } - else if (errno != 0) - { - if (errno != ERANGE) - return LONGINT_INVALID; - err = LONGINT_OVERFLOW; - } - - /* 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 err; - } - - if (**p != '\0') - { - int base = 1024; - int suffixes = 1; - strtol_error overflow; - - if (!strchr (valid_suffixes, **p)) - { - *val = tmp; - return err | 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 err | LONGINT_INVALID_SUFFIX_CHAR; - } - - err |= overflow; - *p += suffixes; - if (**p) - err |= LONGINT_INVALID_SUFFIX_CHAR; - } - - *val = tmp; - return err; -} - -#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 deleted file mode 100644 index 0d6b98482eff..000000000000 --- a/contrib/gnu-sort/lib/xstrtol.h +++ /dev/null @@ -1,89 +0,0 @@ -/* A more useful interface to strtol. - - Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004 Free - Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 - -# include "exitfail.h" - -# if HAVE_INTTYPES_H -# include -# endif -# if HAVE_STDINT_H -# include -# endif - -# ifndef _STRTOL_ERROR -enum strtol_error - { - LONGINT_OK = 0, - - /* These two values can be ORed together, to indicate that both - errors occurred. */ - LONGINT_OVERFLOW = 1, - LONGINT_INVALID_SUFFIX_CHAR = 2, - - LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR - | LONGINT_OVERFLOW), - LONGINT_INVALID = 4 - }; -typedef enum strtol_error strtol_error; -# endif - -# define _DECLARE_XSTRTOL(name, type) \ - strtol_error name (const char *, char **, int, type *, const char *); -_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)) \ - { \ - default: \ - abort (); \ - \ - case LONGINT_INVALID: \ - error ((Exit_code), 0, "invalid %s `%s'", \ - (Argument_type_string), (Str)); \ - break; \ - \ - case LONGINT_INVALID_SUFFIX_CHAR: \ - case LONGINT_INVALID_SUFFIX_CHAR | LONGINT_OVERFLOW: \ - 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 (exit_failure, 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 deleted file mode 100644 index 285f7b96f850..000000000000 --- a/contrib/gnu-sort/lib/xstrtoul.c +++ /dev/null @@ -1,6 +0,0 @@ -#define __strtol strtoul -#define __strtol_t unsigned long int -#define __xstrtol xstrtoul -#define STRTOL_T_MINIMUM 0 -#define STRTOL_T_MAXIMUM ULONG_MAX -#include "xstrtol.c" diff --git a/contrib/gnu-sort/lib/xstrtoumax.c b/contrib/gnu-sort/lib/xstrtoumax.c deleted file mode 100644 index 8518ef077277..000000000000 --- a/contrib/gnu-sort/lib/xstrtoumax.c +++ /dev/null @@ -1,33 +0,0 @@ -/* xstrtoumax.c -- A more useful interface to strtoumax. - Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "xstrtol.h" - -#define __strtol strtoumax -#define __strtol_t uintmax_t -#define __xstrtol xstrtoumax -#ifdef UINTMAX_MAX -# define STRTOL_T_MINIMUM 0 -# define STRTOL_T_MAXIMUM UINTMAX_MAX -#endif -#include "xstrtol.c" diff --git a/contrib/gnu-sort/man/sort.1 b/contrib/gnu-sort/man/sort.1 deleted file mode 100644 index 2bb445dd74e8..000000000000 --- a/contrib/gnu-sort/man/sort.1 +++ /dev/null @@ -1,113 +0,0 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33. -.TH SORT "1" "March 2004" "sort (coreutils) 5.2.1" "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-blank to blank 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; -without \fB\-c\fR, 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 2004 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 coreutils 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 deleted file mode 100644 index 014beb7c5368..000000000000 --- a/contrib/gnu-sort/src/sort.c +++ /dev/null @@ -1,2554 +0,0 @@ -/* sort - sort lines of text (with all kinds of options). - Copyright (C) 88, 1991-2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 "system.h" -#include "error.h" -#include "hard-locale.h" -#include "inttostr.h" -#include "long-options.h" -#include "physmem.h" -#include "posixver.h" -#include "quote.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 "Mike Haertel", "Paul Eggert" - -#if HAVE_LANGINFO_CODESET -# include -#endif - -#ifndef SA_NOCLDSTOP -# define sigprocmask(How, Set, Oset) /* empty */ -# define sigset_t int -#endif - -#ifndef STDC_HEADERS -double strtod (); -#endif - -#define UCHAR_LIM (UCHAR_MAX + 1) - -#ifndef DEFAULT_TMPDIR -# define DEFAULT_TMPDIR "/tmp" -#endif - -/* Exit statuses. */ -enum - { - /* POSIX says to exit with status 1 if invoked with -c and the - input is not properly sorted. */ - SORT_OUT_OF_ORDER = 1, - - /* POSIX says any other irregular exit must exit with a status - code greater than 1. */ - SORT_FAILURE = 2 - }; - -#define C_DECIMAL_POINT '.' -#define NEGATION_SIGN '-' -#define NUMERIC_ZERO '0' - -#if HAVE_SETLOCALE - -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 bool hard_LC_COLLATE; -# if HAVE_NL_LANGINFO -static bool hard_LC_TIME; -# endif - -# define IS_THOUSANDS_SEP(x) ((x) == th_sep) - -#else - -# define decimal_point C_DECIMAL_POINT -# define IS_THOUSANDS_SEP(x) false - -#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 char 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. */ - bool eof; /* An EOF has been read. */ -}; - -struct keyfield -{ - size_t sword; /* Zero-origin 'word' to start at. */ - size_t schar; /* Additional characters to skip. */ - size_t eword; /* Zero-origin first word after field. */ - size_t echar; /* Additional characters in field. */ - bool const *ignore; /* Boolean array of characters to ignore. */ - char const *translate; /* Translation applied to characters. */ - bool skipsblanks; /* Skip leading blanks when finding start. */ - bool skipeblanks; /* Skip leading blanks when finding end. */ - bool numeric; /* Flag for numeric comparison. Handle - strings of digits with optional decimal - point, but no exponential notation. */ - bool general_numeric; /* Flag for general, numeric comparison. - Handle numbers in exponential notation. */ - bool month; /* Flag for comparison by month name. */ - bool reverse; /* Reverse the sense of comparison. */ - struct keyfield *next; /* Next keyfield to try. */ -}; - -struct month -{ - char const *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. - 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 blanks. */ -static bool blanks[UCHAR_LIM]; - -/* Table of non-printing characters. */ -static bool nonprinting[UCHAR_LIM]; - -/* Table of non-dictionary characters (not letters, digits, or blanks). */ -static bool nondictionary[UCHAR_LIM]; - -/* Translation table folding lower case to upper. */ -static char fold_toupper[UCHAR_LIM]; - -#define MONTHS_PER_YEAR 12 - -/* Table mapping month names to integers. - Alphabetic order allows binary search. */ -static 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; - -/* Flag to reverse the order of all comparisons. */ -static bool 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 bool stable; - -/* If TAB has this value, blanks separate fields. */ -enum { TAB_DEFAULT = CHAR_MAX + 1 }; - -/* Tab character separating fields. If TAB_DEFAULT, then fields are - separated by the empty string between a non-blank character and a blank - character. */ -static int tab = TAB_DEFAULT; - -/* Flag to remove consecutive duplicate lines from the output. - Only the last of a sequence of equal lines will be output. */ -static bool unique; - -/* Nonzero if any of the input files are the standard input. */ -static bool have_read_stdin; - -/* List of key field comparisons to be tried. */ -static struct keyfield *keylist; - -static void sortlines_temp (struct line *, size_t, struct line *); - -void -usage (int status) -{ - if (status != EXIT_SUCCESS) - 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-blank to blank 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\ - without -c, 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 ); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); - } - - 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 const *node; - - for (node = temphead; node; node = node->next) - unlink (node->name); -} - -/* Report MESSAGE for FILE, then clean up and exit. - If FILE is null, it represents standard output. */ - -static void die (char const *, char const *) ATTRIBUTE_NORETURN; -static void -die (char const *message, char const *file) -{ - error (0, errno, "%s: %s", message, file ? file : _("standard output")); - 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 = - 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; -} - -/* Return a stream for FILE, opened with mode HOW. A null FILE means - standard output; HOW should be "w". When opening for input, "-" - means standard input. To avoid confusion, do not return file - descriptors 0, 1, or 2. */ - -static FILE * -xfopen (const char *file, const char *how) -{ - FILE *fp; - - if (!file) - fp = stdout; - else if (STREQ (file, "-") && *how == 'r') - { - have_read_stdin = true; - fp = stdin; - } - 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_dirs = x2nrealloc (temp_dirs, &temp_dir_alloc, sizeof *temp_dirs); - - 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 (node); - break; - } -} - -#if HAVE_NL_LANGINFO - -static int -struct_month_cmp (const void *m1, const void *m2) -{ - struct month const *month1 = m1; - struct month const *month2 = m2; - return strcmp (month1->name, month2->name); -} - -#endif - -/* Initialize the character class tables. */ - -static void -inittables (void) -{ - int i; - - for (i = 0; i < UCHAR_LIM; ++i) - { - blanks[i] = !!ISBLANK (i); - nonprinting[i] = !ISPRINT (i); - nondictionary[i] = !ISALNUM (i) && !ISBLANK (i); - fold_toupper[i] = (ISLOWER (i) ? toupper (i) : i); - } - -#if 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 const *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 = xmalloc (s_len + 1); - monthtab[i].val = i + 1; - - for (j = 0; j < s_len; j++) - name[j] = fold_toupper[to_uchar (s[j])]; - name[j] = '\0'; - } - qsort ((void *) monthtab, MONTHS_PER_YEAR, - sizeof *monthtab, struct_month_cmp); - } -#endif -} - -/* 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) - { - /* If multiple sort sizes are specified, take the maximum, so - that option order does not matter. */ - if (n < sort_size) - return; - - 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. Do not exceed a bound on the size: if the bound is - not specified by the user, use a default. */ - -static size_t -sort_buffer_size (FILE *const *fps, int nfps, - char *const *files, int nfiles, - size_t line_bytes) -{ - /* A bound on the input size. If zero, the bound hasn't been - determined yet. */ - static 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) - : STREQ (files[i], "-") ? fstat (STDIN_FILENO, &st) - : stat (files[i], &st)) - != 0) - die (_("stat failed"), files[i]); - - if (S_ISREG (st.st_mode)) - file_size = st.st_size; - else - { - /* The file has unknown size. If the user specified a sort - buffer size, use that; otherwise, guess the size. */ - if (sort_size) - return sort_size; - file_size = INPUT_FILE_SIZE_GUESS; - } - - if (! size_bound) - { - size_bound = sort_size; - if (! size_bound) - size_bound = default_sort_size (); - } - - /* 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 = false; -} - -/* 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; - register size_t remaining_bytes; - - /* The leading field separator itself is included in a field when -t - is absent. */ - - if (tab != TAB_DEFAULT) - while (ptr < lim && sword--) - { - while (ptr < lim && *ptr != tab) - ++ptr; - if (ptr < lim) - ++ptr; - } - else - while (ptr < lim && sword--) - { - while (ptr < lim && blanks[to_uchar (*ptr)]) - ++ptr; - while (ptr < lim && !blanks[to_uchar (*ptr)]) - ++ptr; - } - - if (key->skipsblanks) - while (ptr < lim && blanks[to_uchar (*ptr)]) - ++ptr; - - /* Advance PTR by SCHAR (if possible), but no further than LIM. */ - remaining_bytes = lim - ptr; - if (schar < remaining_bytes) - 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; - register size_t remaining_bytes; - - /* 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 != TAB_DEFAULT) - 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[to_uchar (*ptr)]) - ++ptr; - while (ptr < lim && !blanks[to_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 - [Translated to POSIX 1003.1-2001 terminology by Paul Eggert.] - - [...]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 -k1.7,1.7 skipeblanks) - while (ptr < lim && blanks[to_uchar (*ptr)]) - ++ptr; - - /* Advance PTR by ECHAR (if possible), but no further than LIM. */ - remaining_bytes = lim - ptr; - if (echar < remaining_bytes) - ptr += echar; - else - ptr = lim; - - return ptr; -} - -/* 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 true if some input was read. */ - -static bool -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 false; - - 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 = true; - if (buf->buf == ptrlim) - return false; - 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 == SIZE_MAX - ? p - : limfield (line, key)); - - if (key->sword != SIZE_MAX) - line->keybeg = begfield (line, key); - else - { - if (key->skipsblanks) - while (blanks[to_uchar (*line_start)]) - line_start++; - line->keybeg = line_start; - } - } - - 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 true; - } - - /* The current input line is too long to fit in the buffer. - Double the buffer size and try again. */ - buf->buf = x2nrealloc (buf->buf, &buf->alloc, sizeof *(buf->buf)); - } -} - -/* 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) -{ - char tmpa; - char tmpb; - int tmp; - size_t log_a; - size_t log_b; - - tmpa = *a; - tmpb = *b; - - while (blanks[to_uchar (tmpa)]) - tmpa = *++a; - while (blanks[to_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 (log_a = 0; ISDIGIT (tmpa); ++log_a) - do - tmpa = *++a; - while (IS_THOUSANDS_SEP (tmpa)); - - for (log_b = 0; ISDIGIT (tmpb); ++log_b) - do - tmpb = *++b; - while (IS_THOUSANDS_SEP (tmpb)); - - if (log_a != log_b) - return log_a < log_b ? 1 : -1; - - if (!log_a) - 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 (log_a = 0; ISDIGIT (tmpa); ++log_a) - do - tmpa = *++a; - while (IS_THOUSANDS_SEP (tmpa)); - - for (log_b = 0; ISDIGIT (tmpb); ++log_b) - do - tmpb = *++b; - while (IS_THOUSANDS_SEP (tmpb)); - - if (log_a != log_b) - return log_a < log_b ? -1 : 1; - - if (!log_a) - 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[to_uchar (*s)]) - { - ++s; - --len; - } - - if (len == 0) - return 0; - - month = alloca (len + 1); - for (i = 0; i < len; ++i) - month[i] = fold_toupper[to_uchar (s[i])]; - month[len] = '\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 const *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 char const *translate = key->translate; - register bool const *ignore = key->ignore; - - /* Find the lengths. */ - size_t lena = lima <= texta ? 0 : lima - texta; - size_t lenb = limb <= textb ? 0 : limb - 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); - /* 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 (HAVE_SETLOCALE && hard_LC_COLLATE) - { - if (ignore || translate) - { - char *copy_a = 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[to_uchar (texta[i])] - : texta[i]); - if (!ignore || !ignore[to_uchar (texta[i])]) - ++new_len_a; - } - if (i < lenb) - { - copy_b[new_len_b] = (translate - ? translate[to_uchar (textb[i])] - : textb [i]); - if (!ignore || !ignore[to_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); - } - else if (ignore) - { -#define CMP_WITH_IGNORE(A, B) \ - do \ - { \ - for (;;) \ - { \ - while (texta < lima && ignore[to_uchar (*texta)]) \ - ++texta; \ - while (textb < limb && ignore[to_uchar (*textb)]) \ - ++textb; \ - if (! (texta < lima && textb < limb)) \ - break; \ - diff = to_uchar (A) - to_uchar (B); \ - if (diff) \ - goto not_equal; \ - ++texta; \ - ++textb; \ - } \ - \ - diff = (texta < lima) - (textb < limb); \ - } \ - while (0) - - if (translate) - CMP_WITH_IGNORE (translate[to_uchar (*texta)], - translate[to_uchar (*textb)]); - else - CMP_WITH_IGNORE (*texta, *textb); - } - else if (lena == 0) - diff = - NONZERO (lenb); - else if (lenb == 0) - goto greater; - else - { - if (translate) - { - while (texta < lima && textb < limb) - { - diff = (to_uchar (translate[to_uchar (*texta++)]) - - to_uchar (translate[to_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 != SIZE_MAX) - lima = limfield (a, key), limb = limfield (b, key); - else - lima = a->text + a->length - 1, limb = b->text + b->length - 1; - - if (key->sword != SIZE_MAX) - texta = begfield (a, key), textb = begfield (b, key); - else - { - texta = a->text, textb = b->text; - if (key->skipsblanks) - { - while (texta < lima && blanks[to_uchar (*texta)]) - ++texta; - while (textb < limb && blanks[to_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 | 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 = 1; - else if (HAVE_SETLOCALE && hard_LC_COLLATE) - diff = xmemcoll (a->text, alen, b->text, blen); - 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 FILE_NAME come in order. Print a - diagnostic (FILE_NAME, line number, contents of line) to stderr and return - false if they are not in order. Otherwise, print no diagnostic - and return true. */ - -static bool -check (char const *file_name) -{ - FILE *fp = xfopen (file_name, "r"); - struct buffer buf; /* Input buffer. */ - struct line temp; /* Copy of previous line. */ - size_t alloc = 0; - uintmax_t line_number = 0; - struct keyfield const *key = keylist; - bool nonunique = ! unique; - bool ordered = true; - - 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: - { - struct line const *disorder_line = line - 1; - uintmax_t disorder_line_number = - buffer_linelim (&buf) - disorder_line + line_number; - char hr_buf[INT_BUFSIZE_BOUND (uintmax_t)]; - fprintf (stderr, _("%s: %s:%s: disorder: "), - program_name, file_name, - umaxtostr (disorder_line_number, hr_buf)); - write_bytes (disorder_line->text, disorder_line->length, stderr, - _("standard error")); - ordered = false; - 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 ordered; -} - -/* 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 it is NULL, - the output file is standard output. If OFP is NULL, the output - file has not been opened yet (or written to, if standard output). */ - -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 const *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); -} - -/* Merge into T the two sorted arrays of lines LO (with NLO members) - and HI (with NHI members). T, LO, and HI point just past their - respective arrays, and the arrays are in reverse order. NLO and - NHI must be positive, and HI - NHI must equal T - (NLO + NHI). */ - -static inline void -mergelines (struct line *t, - struct line const *lo, size_t nlo, - struct line const *hi, size_t nhi) -{ - for (;;) - if (compare (lo - 1, hi - 1) <= 0) - { - *--t = *--lo; - if (! --nlo) - { - /* HI - NHI equalled T - (NLO + NHI) when this function - began. Therefore HI must equal T now, and there is no - need to copy from HI to T. */ - return; - } - } - else - { - *--t = *--hi; - if (! --nhi) - { - do - *--t = *--lo; - while (--nlo); - - return; - } - } -} - -/* Sort the array LINES with NLINES members, using TEMP for temporary space. - NLINES must be at least 2. - The input and output arrays are in reverse order, and LINES and - TEMP point just past the end of their respective arrays. - - Use a recursive divide-and-conquer algorithm, in the style - suggested by Knuth volume 3 (2nd edition), exercise 5.2.4-23. Use - the optimization suggested by exercise 5.2.4-10; this requires room - for only 1.5*N lines, rather than the usual 2*N lines. Knuth - writes that this memory optimization was originally published by - D. A. Bell, Comp J. 1 (1958), 75. */ - -static void -sortlines (struct line *lines, size_t nlines, struct line *temp) -{ - if (nlines == 2) - { - if (0 < compare (&lines[-1], &lines[-2])) - { - struct line tmp = lines[-1]; - lines[-1] = lines[-2]; - lines[-2] = tmp; - } - } - else - { - size_t nlo = nlines / 2; - size_t nhi = nlines - nlo; - struct line *lo = lines; - struct line *hi = lines - nlo; - struct line *sorted_lo = temp; - - sortlines (hi, nhi, temp); - if (1 < nlo) - sortlines_temp (lo, nlo, sorted_lo); - else - sorted_lo[-1] = lo[-1]; - - mergelines (lines, sorted_lo, nlo, hi, nhi); - } -} - -/* Like sortlines (LINES, NLINES, TEMP), except output into TEMP - rather than sorting in place. */ - -static void -sortlines_temp (struct line *lines, size_t nlines, struct line *temp) -{ - if (nlines == 2) - { - bool swap = (0 < compare (&lines[-1], &lines[-2])); - temp[-1] = lines[-1 - swap]; - temp[-2] = lines[-2 + swap]; - } - else - { - size_t nlo = nlines / 2; - size_t nhi = nlines - nlo; - struct line *lo = lines; - struct line *hi = lines - nlo; - struct line *sorted_hi = temp - nlo; - - sortlines_temp (hi, nhi, sorted_hi); - if (1 < nlo) - sortlines (lo, nlo, temp); - - mergelines (temp, lo, nlo, sorted_hi, nhi); - } -} - -/* Return the index of the first of NFILES FILES that is the same file - as OUTFILE. If none can be the same, return NFILES. - - This test ensures that an otherwise-erroneous use like - "sort -m -o FILE ... FILE ..." copies FILE before writing to it. - It's not clear that POSIX requires this nicety. - Detect common error cases, but don't try to catch obscure cases like - "cat ... FILE ... | sort -m -o FILE" - where traditional "sort" doesn't copy the input and where - people should know that they're getting into trouble anyway. - Catching these obscure cases would slow down performance in - common cases. */ - -static int -first_same_file (char * const *files, int nfiles, char const *outfile) -{ - int i; - bool got_outstat = false; - struct stat instat, outstat; - - for (i = 0; i < nfiles; i++) - { - bool standard_input = STREQ (files[i], "-"); - - if (outfile && STREQ (outfile, files[i]) && ! standard_input) - return i; - - if (! got_outstat) - { - got_outstat = true; - if ((outfile - ? stat (outfile, &outstat) - : fstat (STDOUT_FILENO, &outstat)) - != 0) - return nfiles; - } - - if (((standard_input - ? fstat (STDIN_FILENO, &instat) - : stat (files[i], &instat)) - == 0) - && SAME_INODE (instat, outstat)) - return i; - } - - return nfiles; -} - -/* Merge NFILES FILES onto OUTPUT_FILE. However, merge at most - MAX_MERGE input files directly onto OUTPUT_FILE. MAX_MERGE cannot - exceed NMERGE. A null OUTPUT_FILE stands for standard output. */ - -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 * const *files, int nfiles, char const *output_file) -{ - struct buffer buf; - int n_temp_files = 0; - bool output_file_created = false; - - buf.alloc = 0; - - while (nfiles) - { - char const *temp_output; - char const *file = *files; - FILE *fp = xfopen (file, "r"); - FILE *tfp; - size_t bytes_per_line = (2 * sizeof (struct line) - - sizeof (struct line) / 2); - - if (! buf.alloc) - initbuf (&buf, bytes_per_line, - sort_buffer_size (&fp, 1, files, nfiles, bytes_per_line)); - buf.eof = false; - files++; - nfiles--; - - while (fillbuf (&buf, fp, file)) - { - struct line *line; - struct line *linebase; - - if (buf.eof && nfiles - && (bytes_per_line + 1 - < (buf.alloc - buf.used - bytes_per_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; - if (1 < 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 = true; - } - 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 = xnmalloc (n_temp_files, sizeof *tempfiles); - for (node = temphead; i > 0; node = node->next) - tempfiles[--i] = node->name; - merge (tempfiles, n_temp_files, NMERGE, output_file); - free (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 (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: - case LONGINT_OVERFLOW | LONGINT_INVALID_SUFFIX_CHAR: - 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 (); - - signal (sig, SIG_DFL); - raise (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 = true; - if (blanktype == bl_end || blanktype == bl_both) - key->skipeblanks = true; - break; - case 'd': - key->ignore = nondictionary; - break; - case 'f': - key->translate = fold_toupper; - break; - case 'g': - key->general_numeric = true; - break; - case 'i': - /* Option order should not matter, so don't let -i override - -d. -d implies -i, but -i does not imply -d. */ - if (! key->ignore) - key->ignore = nonprinting; - break; - case 'M': - key->month = true; - break; - case 'n': - key->numeric = true; - break; - case 'r': - key->reverse = true; - break; - default: - return (char *) s; - } - ++s; - } - return (char *) s; -} - -static struct keyfield * -new_key (void) -{ - struct keyfield *key = xzalloc (sizeof *key); - key->eword = SIZE_MAX; - return key; -} - -int -main (int argc, char **argv) -{ - struct keyfield *key; - struct keyfield gkey; - char const *s; - int c = 0; - bool checkonly = false; - bool mergeonly = false; - int nfiles = 0; - bool posixly_correct = (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 = NULL; - - initialize_main (&argc, &argv); - program_name = argv[0]; - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); - - atexit (cleanup); - - initialize_exit_failure (SORT_FAILURE); - atexit (close_stdout); - - hard_LC_COLLATE = hard_locale (LC_COLLATE); -#if HAVE_NL_LANGINFO - hard_LC_TIME = hard_locale (LC_TIME); -#endif - -#if HAVE_SETLOCALE - /* Let's get locale's representation of the decimal point */ - { - struct lconv const *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 - - have_read_stdin = false; - inittables (); - - { - int i; - static int const sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM }; - enum { nsigs = sizeof sig / sizeof sig[0] }; - -#ifdef SA_NOCLDSTOP - struct sigaction act; - - sigemptyset (&caught_signals); - for (i = 0; i < nsigs; i++) - { - sigaction (sig[i], NULL, &act); - if (act.sa_handler != SIG_IGN) - sigaddset (&caught_signals, sig[i]); - } - - act.sa_handler = sighandler; - act.sa_mask = caught_signals; - act.sa_flags = 0; - - for (i = 0; i < nsigs; i++) - if (sigismember (&caught_signals, sig[i])) - sigaction (sig[i], &act, NULL); -#else - for (i = 0; i < nsigs; i++) - if (signal (sig[i], SIG_IGN) != SIG_IGN) - signal (sig[i], sighandler); -#endif - } - - gkey.sword = gkey.eword = SIZE_MAX; - gkey.ignore = NULL; - gkey.translate = NULL; - gkey.numeric = gkey.general_numeric = gkey.month = gkey.reverse = false; - gkey.skipsblanks = gkey.skipeblanks = false; - - files = xnmalloc (argc, sizeof *files); - - 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 - || (posixly_correct && 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 (argc <= optind) - 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 = SIZE_MAX; - 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 = true; - 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 = SIZE_MAX; - s = set_ordering (s, key, bl_start); - if (*s != ',') - { - key->eword = SIZE_MAX; - 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 = true; - break; - - case 'o': - if (outfile && !STREQ (outfile, optarg)) - error (SORT_FAILURE, 0, _("multiple output files specified")); - outfile = optarg; - break; - - case 's': - stable = true; - break; - - case 'S': - specify_sort_size (optarg); - break; - - case 't': - { - char newtab = optarg[0]; - if (! newtab) - error (SORT_FAILURE, 0, _("empty tab")); - if (optarg[1]) - { - if (STREQ (optarg, "\\0")) - newtab = '\0'; - else - { - /* 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); - } - } - if (tab != TAB_DEFAULT && tab != newtab) - error (SORT_FAILURE, 0, _("incompatible tabs")); - tab = newtab; - } - break; - - case 'T': - add_temp_dir (optarg); - break; - - case 'u': - unique = true; - 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 (0, 0, _("extra operand %s not allowed with -c"), - quote (files[1])); - usage (SORT_FAILURE); - } - - /* POSIX requires that sort return 1 IFF invoked with -c and the - input is not properly sorted. */ - exit (check (files[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/system.h b/contrib/gnu-sort/src/system.h deleted file mode 100644 index 3497969a4937..000000000000 --- a/contrib/gnu-sort/src/system.h +++ /dev/null @@ -1,831 +0,0 @@ -/* system-dependent definitions for fileutils, textutils, and sh-utils packages. - Copyright (C) 1989, 1991-2004 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 - -/* Include sys/types.h before this file. */ - -#if 2 <= __GLIBC__ && 2 <= __GLIBC_MINOR__ -# if ! defined _SYS_TYPES_H -you must include before including this file -# endif -#endif - -#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 - - -/* limits.h must come before pathmax.h because limits.h on some systems - undefs PATH_MAX, whereas pathmax.h sets PATH_MAX. */ -#include - -#include "pathmax.h" -#include "localedir.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 ! defined makedev && defined mkdev -# define makedev(maj, min) mkdev (maj, min) -#endif - -#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. */ - -#include -#if ! HAVE_DECL_MEMRCHR -void *memrchr (const void *, int, size_t); -#endif - -#include - -/* Some systems don't define the following symbols. */ -#ifndef ENOSYS -# define ENOSYS (-1) -#endif -#ifndef EISDIR -# define EISDIR (-1) -#endif - -#include - -#define getopt system_getopt -#include -#undef getopt - -/* 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 - -/* Exit statuses for programs like 'env' that exec other programs. - EXIT_FAILURE might not be 1, so use EXIT_FAIL in such programs. */ -enum -{ - EXIT_FAIL = 1, - EXIT_CANNOT_INVOKE = 126, - EXIT_ENOENT = 127 -}; - -#include "exitfail.h" - -/* Set exit_failure to STATUS if that's not the default already. */ -static inline void -initialize_exit_failure (int status) -{ - if (status != EXIT_FAILURE) - exit_failure = status; -} - -#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 - -#if !defined O_DIRECT -# define O_DIRECT 0 -#endif - -#if !defined O_DSYNC -# define O_DSYNC 0 -#endif - -#if !defined O_NDELAY -# define O_NDELAY 0 -#endif - -#if !defined O_NONBLOCK -# define O_NONBLOCK O_NDELAY -#endif - -#if !defined O_NOCTTY -# define O_NOCTTY 0 -#endif - -#if !defined O_NOFOLLOW -# define O_NOFOLLOW 0 -#endif - -#if !defined O_RSYNC -# define O_RSYNC 0 -#endif - -#if !defined O_SYNC -# define O_SYNC 0 -#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 -# ifndef O_BINARY -# define O_BINARY 0 -# endif -# 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) \ - ((statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 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. - Also, when running `rsh hpux11-system cat any-file', cat would - determine that the output stream had an st_blksize of 2147421096. - So here we arbitrarily limit the `optimal' block size to 4MB. - If anyone knows of a system for which the legitimate value for - st_blksize can exceed 4MB, please report it as a bug in this code. */ -# define ST_BLKSIZE(statbuf) ((0 < (statbuf).st_blksize \ - && (statbuf).st_blksize <= (1 << 22)) /* 4MB */ \ - ? (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 file systems 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) ((statbuf).st_blocks) -#endif - -#ifndef ST_NBLOCKSIZE -# define ST_NBLOCKSIZE 512 -#endif - -/* Redirection and wildcarding when done by the utility itself. - Generally a noop, but used in particular for native VMS. */ -#ifndef initialize_main -# define initialize_main(ac, av) -#endif - -#include "stat-macros.h" - -#include "timespec.h" - -#ifndef RETSIGTYPE -# define RETSIGTYPE void -#endif - -#ifdef __DJGPP__ - /* We need the declaration of setmode. */ -# include - /* We need the declaration of __djgpp_set_ctrl_c. */ -# include -#endif - -#if HAVE_INTTYPES_H -# include -#endif -#if HAVE_STDINT_H -# include -#endif - -#if ULONG_MAX < ULLONG_MAX -# define LONGEST_MODIFIER "ll" -#else -# define LONGEST_MODIFIER "l" -#endif -#if PRI_MACROS_BROKEN -# undef PRIdMAX -# undef PRIoMAX -# undef PRIuMAX -# undef PRIxMAX -#endif -#ifndef PRIdMAX -# define PRIdMAX LONGEST_MODIFIER "d" -#endif -#ifndef PRIoMAX -# define PRIoMAX LONGEST_MODIFIER "o" -#endif -#ifndef PRIuMAX -# define PRIuMAX LONGEST_MODIFIER "u" -#endif -#ifndef PRIxMAX -# define PRIxMAX LONGEST_MODIFIER "x" -#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 int) (c) - '0' <= 9) - -/* Convert a possibly-signed character to an unsigned character. This is - a bit safer than casting to unsigned char, since it catches some type - errors that the cast doesn't. */ -static inline unsigned char to_uchar (char ch) { return ch; } - -/* Take care of NLS matters. */ - -#if HAVE_LOCALE_H -# include -#else -# define setlocale(Category, Locale) /* empty */ -#endif - -#include "gettext.h" -#if ! ENABLE_NLS -# undef textdomain -# define textdomain(Domainname) /* empty */ -# undef bindtextdomain -# define bindtextdomain(Domainname, Dirname) /* empty */ -#endif - -#define _(msgid) gettext (msgid) -#define N_(msgid) msgid - -#ifndef HAVE_SETLOCALE -# define HAVE_SETLOCALE 0 -#endif - -#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 - -#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'))) - -/* A wrapper for readdir so that callers don't see entries for `.' or `..'. */ -static inline struct dirent const * -readdir_ignoring_dot_and_dotdot (DIR *dirp) -{ - while (1) - { - struct dirent const *dp = readdir (dirp); - if (dp == NULL || ! DOT_OR_DOTDOT (dp->d_name)) - return dp; - } -} - -#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, GNU_PACKAGE, VERSION, Authors, \ - (char *) NULL); \ - 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 - -/* 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 INT_MIN -# define INT_MIN TYPE_MINIMUM (int) -#endif - -#ifndef INTMAX_MAX -# define INTMAX_MAX TYPE_MAXIMUM (intmax_t) -#endif - -#ifndef INTMAX_MIN -# define INTMAX_MIN TYPE_MINIMUM (intmax_t) -#endif - -#ifndef UINT_MAX -# define UINT_MAX TYPE_MAXIMUM (unsigned int) -#endif - -#ifndef LONG_MAX -# define LONG_MAX TYPE_MAXIMUM (long int) -#endif - -#ifndef ULONG_MAX -# define ULONG_MAX TYPE_MAXIMUM (unsigned long int) -#endif - -#ifndef SIZE_MAX -# define SIZE_MAX TYPE_MAXIMUM (size_t) -#endif - -#ifndef SSIZE_MAX -# define SSIZE_MAX TYPE_MAXIMUM (ssize_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 - -/* 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_ = 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 int) (o) \ - ? fseek (s, o, w) \ - : (errno = EOVERFLOW, -1)) -#endif - -/* Compute the greatest common divisor of U and V using Euclid's - algorithm. U and V must be nonzero. */ - -static inline size_t -gcd (size_t u, size_t v) -{ - do - { - size_t t = u % v; - u = v; - v = t; - } - while (v); - - return u; -} - -/* Compute the least common multiple of U and V. U and V must be - nonzero. There is no overflow checking, so callers should not - specify outlandish sizes. */ - -static inline size_t -lcm (size_t u, size_t v) -{ - return u * (v / gcd (u, v)); -} - -/* Return PTR, aligned upward to the next multiple of ALIGNMENT. - ALIGNMENT must be nonzero. The caller must arrange for ((char *) - PTR) through ((char *) PTR + ALIGNMENT - 1) to be addressable - locations. */ - -static inline void * -ptr_align (void *ptr, size_t alignment) -{ - char *p0 = ptr; - char *p1 = p0 + alignment - 1; - return p1 - (size_t) p1 % alignment; -} diff --git a/lib/__fpending.c b/lib/__fpending.c new file mode 100644 index 000000000000..a872102abf8a --- /dev/null +++ b/lib/__fpending.c @@ -0,0 +1,30 @@ +/* __fpending.c -- return the number of pending output bytes on a stream + Copyright (C) 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 "__fpending.h" + +size_t +__fpending (FILE *fp) +{ + return PENDING_OUTPUT_N_BYTES; +} diff --git a/lib/__fpending.h b/lib/__fpending.h new file mode 100644 index 000000000000..5a5158216c1a --- /dev/null +++ b/lib/__fpending.h @@ -0,0 +1,17 @@ +#if HAVE_CONFIG_H +# include +#endif + +#include +#include + +#if HAVE_STDIO_EXT_H +# include +#endif + +#ifndef HAVE_DECL___FPENDING +"this configure-time declaration test was not run" +#endif +#if !HAVE_DECL___FPENDING +size_t __fpending (FILE *); +#endif diff --git a/lib/argmatch.c b/lib/argmatch.c new file mode 100644 index 000000000000..1a8ec2f54ba4 --- /dev/null +++ b/lib/argmatch.c @@ -0,0 +1,278 @@ +/* argmatch.c -- find a match for a string in an array + + Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 2004 Free + Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 */ + +#if HAVE_CONFIG_H +# include +#endif + +/* Specification. */ +#include "argmatch.h" + +#include +#include +#include +#include + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +#include "error.h" +#include "exit.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 + +/* Non failing version of argmatch call this function after failing. */ +#ifndef ARGMATCH_DIE +# include "exitfail.h" +# define ARGMATCH_DIE exit (exit_failure) +#endif + +#ifdef ARGMATCH_DIE_DECL +ARGMATCH_DIE_DECL; +#endif + +static void +__argmatch_die (void) +{ + ARGMATCH_DIE; +} + +/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h. + Default to __argmatch_die, but allow caller to change this at run-time. */ +argmatch_exit_fn argmatch_die = __argmatch_die; + + +/* If ARG is an unambiguous match for an element of the + null-terminated array ARGLIST, return the index in ARGLIST + of the matched element, else -1 if it does not match any element + or -2 if it is ambiguous (is a prefix of more than one element). + + If VALLIST is none null, use it to resolve ambiguities limited to + synonyms, i.e., for + "yes", "yop" -> 0 + "no", "nope" -> 1 + "y" is a valid argument, for `0', and "n" for `1'. */ + +ptrdiff_t +argmatch (const char *arg, const char *const *arglist, + const char *vallist, size_t valsize) +{ + size_t i; /* Temporary index in ARGLIST. */ + size_t arglen; /* Length of ARG. */ + ptrdiff_t matchind = -1; /* Index of first nonexact match. */ + bool ambiguous = false; /* If true, multiple nonexact match(es). */ + + arglen = strlen (arg); + + /* Test all elements for either exact match or abbreviated matches. */ + for (i = 0; arglist[i]; i++) + { + if (!strncmp (arglist[i], arg, arglen)) + { + if (strlen (arglist[i]) == arglen) + /* Exact match found. */ + return i; + else if (matchind == -1) + /* First nonexact match found. */ + matchind = i; + else + { + /* Second nonexact match found. */ + if (vallist == NULL + || memcmp (vallist + valsize * matchind, + vallist + valsize * i, valsize)) + { + /* There is a real ambiguity, or we could not + disambiguate. */ + ambiguous = true; + } + } + } + } + if (ambiguous) + return -2; + else + return matchind; +} + +/* Error reporting for argmatch. + CONTEXT is a description of the type of entity that was being matched. + VALUE is the invalid value that was given. + PROBLEM is the return value from argmatch. */ + +void +argmatch_invalid (const char *context, const char *value, ptrdiff_t problem) +{ + char const *format = (problem == -1 + ? _("invalid argument %s for %s") + : _("ambiguous argument %s for %s")); + + error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value), + quote_n (1, context)); +} + +/* List the valid arguments for argmatch. + ARGLIST is the same as in argmatch. + VALLIST is a pointer to an array of values. + VALSIZE is the size of the elements of VALLIST */ +void +argmatch_valid (const char *const *arglist, + const char *vallist, size_t valsize) +{ + size_t i; + const char *last_val = NULL; + + /* We try to put synonyms on the same line. The assumption is that + synonyms follow each other */ + fprintf (stderr, _("Valid arguments are:")); + for (i = 0; arglist[i]; i++) + if ((i == 0) + || memcmp (last_val, vallist + valsize * i, valsize)) + { + fprintf (stderr, "\n - `%s'", arglist[i]); + last_val = vallist + valsize * i; + } + else + { + fprintf (stderr, ", `%s'", arglist[i]); + } + putc ('\n', stderr); +} + +/* Never failing versions of the previous functions. + + CONTEXT is the context for which argmatch is called (e.g., + "--version-control", or "$VERSION_CONTROL" etc.). Upon failure, + calls the (supposed never to return) function EXIT_FN. */ + +ptrdiff_t +__xargmatch_internal (const char *context, + const char *arg, const char *const *arglist, + const char *vallist, size_t valsize, + argmatch_exit_fn exit_fn) +{ + ptrdiff_t res = argmatch (arg, arglist, vallist, valsize); + if (res >= 0) + /* Success. */ + return res; + + /* We failed. Explain why. */ + argmatch_invalid (context, arg, res); + argmatch_valid (arglist, vallist, valsize); + (*exit_fn) (); + + return -1; /* To please the compilers. */ +} + +/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and + return the first corresponding argument in ARGLIST */ +const char * +argmatch_to_argument (const char *value, + const char *const *arglist, + const char *vallist, size_t valsize) +{ + size_t i; + + for (i = 0; arglist[i]; i++) + if (!memcmp (value, vallist + valsize * i, valsize)) + return arglist[i]; + return NULL; +} + +#ifdef TEST +/* + * Based on "getversion.c" by David MacKenzie + */ +char *program_name; + +/* 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 = XARGMATCH ("$VERSION_CONTROL", cp, + backup_args, backup_vals); + + if (argc == 2) + backup_type = XARGMATCH (program_name, argv[1], + backup_args, backup_vals); + + printf ("The version control is `%s'\n", + ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals)); + + return 0; +} +#endif diff --git a/lib/argmatch.h b/lib/argmatch.h new file mode 100644 index 000000000000..8952394fdac7 --- /dev/null +++ b/lib/argmatch.h @@ -0,0 +1,112 @@ +/* argmatch.h -- definitions and prototypes for argmatch.c + + Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 + +# include + +# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) + +# define ARGMATCH_CONSTRAINT(Arglist, Vallist) \ + (ARRAY_CARDINALITY (Arglist) == ARRAY_CARDINALITY (Vallist) + 1) + +/* Assert there are as many real arguments as there are values + (argument list ends with a NULL guard). ARGMATCH_VERIFY is + preferred, since it is guaranteed to be checked at compile-time. + ARGMATCH_ASSERT is for backward compatibility only. */ + +# define ARGMATCH_VERIFY(Arglist, Vallist) \ + struct argmatch_verify \ + { \ + char argmatch_verify[ARGMATCH_CONSTRAINT(Arglist, Vallist) ? 1 : -1]; \ + } + +# define ARGMATCH_ASSERT(Arglist, Vallist) \ + assert (ARGMATCH_CONSTRAINT (Arglist, Vallist)) + +/* Return the index of the element of ARGLIST (NULL terminated) that + matches with ARG. If VALLIST is not NULL, then use it to resolve + false ambiguities (i.e., different matches of ARG but corresponding + to the same values in VALLIST). */ + +ptrdiff_t argmatch (char const *arg, char const *const *arglist, + char const *vallist, size_t valsize); + +# define ARGMATCH(Arg, Arglist, Vallist) \ + argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist)) + +/* xargmatch calls this function when it fails. This function should not + return. By default, this is a function that calls ARGMATCH_DIE which + in turn defaults to `exit (exit_failure)'. */ +typedef void (*argmatch_exit_fn) (void); +extern argmatch_exit_fn argmatch_die; + +/* Report on stderr why argmatch failed. Report correct values. */ + +void argmatch_invalid (char const *context, char const *value, + ptrdiff_t problem); + +/* Left for compatibility with the old name invalid_arg */ + +# define invalid_arg(Context, Value, Problem) \ + argmatch_invalid (Context, Value, Problem) + + + +/* Report on stderr the list of possible arguments. */ + +void argmatch_valid (char const *const *arglist, + char const *vallist, size_t valsize); + +# define ARGMATCH_VALID(Arglist, Vallist) \ + argmatch_valid (Arglist, (char const *) (Vallist), sizeof *(Vallist)) + + + +/* Same as argmatch, but upon failure, reports a explanation on the + failure, and exits using the function EXIT_FN. */ + +ptrdiff_t __xargmatch_internal (char const *context, + char const *arg, char const *const *arglist, + char const *vallist, size_t valsize, + argmatch_exit_fn exit_fn); + +/* Programmer friendly interface to __xargmatch_internal. */ + +# define XARGMATCH(Context, Arg, Arglist, Vallist) \ + ((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \ + (char const *) (Vallist), \ + sizeof *(Vallist), \ + argmatch_die)]) + +/* Convert a value into a corresponding argument. */ + +char const *argmatch_to_argument (char const *value, + char const *const *arglist, + char const *vallist, size_t valsize); + +# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \ + argmatch_to_argument (Value, Arglist, \ + (char const *) (Vallist), sizeof *(Vallist)) + +#endif /* ARGMATCH_H_ */ diff --git a/lib/closeout.c b/lib/closeout.c new file mode 100644 index 000000000000..3c7bed9c3d55 --- /dev/null +++ b/lib/closeout.c @@ -0,0 +1,93 @@ +/* closeout.c - close standard output + + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "closeout.h" + +#include +#include + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +#include "error.h" +#include "exitfail.h" +#include "quotearg.h" +#include "unlocked-io.h" +#include "__fpending.h" + +static const char *file_name; + +/* Set the file name to be reported in the event an error is detected + by close_stdout. */ +void +close_stdout_set_file_name (const char *file) +{ + file_name = file; +} + +/* Close standard output, exiting with status 'exit_failure' on failure. + If a program writes *anything* to stdout, that program should `fflush' + stdout and make sure that it succeeds before exiting. Otherwise, + suppose that you go to the extreme of checking the return status + of every function that does an explicit write to stdout. The last + printf can succeed in writing to the internal stream buffer, and yet + the fclose(stdout) could still fail (due e.g., to a disk full error) + when it tries to write out that buffered data. Thus, you would be + left with an incomplete output file and the offending program would + exit successfully. + + FIXME: note the fflush suggested above is implicit in the fclose + we actually do below. Consider doing only the fflush and/or using + setvbuf to inhibit buffering. + + Besides, it's wasteful to check the return value from every call + that writes to stdout -- just let the internal stream state record + the failure. That's what the ferror test is checking below. + + It's important to detect such failures and exit nonzero because many + tools (most notably `make' and other build-management systems) depend + on being able to detect failure in other tools via their exit status. */ + +void +close_stdout (void) +{ + int e = ferror (stdout) ? 0 : -1; + + /* If the stream's error bit is clear and there is nothing to flush, + then return right away. */ + if (e && __fpending (stdout) == 0) + return; + + if (fclose (stdout) != 0) + e = errno; + + if (0 <= e) + { + char const *write_error = _("write error"); + if (file_name) + error (exit_failure, e, "%s: %s", quotearg_colon (file_name), + write_error); + else + error (exit_failure, e, "%s", write_error); + } +} diff --git a/lib/closeout.h b/lib/closeout.h new file mode 100644 index 000000000000..1b715ee30369 --- /dev/null +++ b/lib/closeout.h @@ -0,0 +1,33 @@ +/* Close standard output. + + Copyright (C) 1998, 2000, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 CLOSEOUT_H +# define CLOSEOUT_H 1 + +# ifdef __cplusplus +extern "C" { +# endif + +void close_stdout_set_file_name (const char *file); +void close_stdout (void); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/lib/dup-safer.c b/lib/dup-safer.c new file mode 100644 index 000000000000..408a1bda7602 --- /dev/null +++ b/lib/dup-safer.c @@ -0,0 +1,59 @@ +/* Invoke dup, but avoid some glitches. + Copyright (C) 2001, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 + +#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/lib/error.c b/lib/error.c new file mode 100644 index 000000000000..5a5e126b0dfb --- /dev/null +++ b/lib/error.c @@ -0,0 +1,306 @@ +/* Error handler for noninteractive utilities + Copyright (C) 1990-1998, 2000-2002, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by David MacKenzie . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "error.h" + +#include +#include +#include +#include + +#ifdef _LIBC +# include +#else +# include "gettext.h" +#endif + +#ifdef _LIBC +# include +# define mbsrtowcs __mbsrtowcs +#endif + +#if !_LIBC +# include "unlocked-io.h" +#endif + +#ifndef _ +# define _(String) String +#endif + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +void (*error_print_progname) (void); + +/* This variable is incremented each time `error' is called. */ +unsigned int error_message_count; + +#ifdef _LIBC +/* In the GNU C library, there is a predefined variable for this. */ + +# define program_name program_invocation_name +# include +# 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 + +# include +# define fflush(s) INTUSE(_IO_fflush) (s) +# undef putc +# define putc(c, fp) INTUSE(_IO_putc) (c, fp) + +# include + +#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 + +# ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +# endif + +/* The calling program should define program_name and set it to the + name of the executing program. */ +extern char *program_name; + +# if HAVE_STRERROR_R || defined strerror_r +# define __strerror_r strerror_r +# endif +#endif /* not _LIBC */ + +static void +print_errno_message (int errnum) +{ + char const *s = NULL; + +#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; +# endif +#endif + +#if !_LIBC + if (! s && ! (s = strerror (errnum))) + s = _("Unknown system error"); +#endif + +#if _LIBC + if (_IO_fwide (stderr, 0) > 0) + { + __fwprintf (stderr, L": %s", s); + return; + } +#endif + + fprintf (stderr, ": %s", s); +} + +static void +error_tail (int status, int errnum, const char *message, va_list args) +{ +#if _LIBC + if (_IO_fwide (stderr, 0) > 0) + { +# define ALLOCA_LIMIT 2000 + size_t len = strlen (message) + 1; + const wchar_t *wmessage = L"out of memory"; + wchar_t *wbuf = (len < ALLOCA_LIMIT + ? alloca (len * sizeof *wbuf) + : len <= SIZE_MAX / sizeof *wbuf + ? malloc (len * sizeof *wbuf) + : NULL); + + if (wbuf) + { + size_t res; + mbstate_t st; + const char *tmp = message; + memset (&st, '\0', sizeof (st)); + res = mbsrtowcs (wbuf, &tmp, len, &st); + wmessage = res == (size_t) -1 ? L"???" : wbuf; + } + + __vfwprintf (stderr, wmessage, args); + if (! (len < ALLOCA_LIMIT)) + free (wbuf); + } + else +#endif + vfprintf (stderr, message, args); + va_end (args); + + ++error_message_count; + if (errnum) + print_errno_message (errnum); +#if _LIBC + if (_IO_fwide (stderr, 0) > 0) + putwc (L'\n', stderr); + else +#endif + putc ('\n', stderr); + fflush (stderr); + if (status) + exit (status); +} + + +/* Print the program name and error message MESSAGE, which is a printf-style + format string with optional args. + If ERRNUM is nonzero, print its corresponding system error message. + Exit with status STATUS if it is nonzero. */ +void +error (int status, int errnum, const char *message, ...) +{ + va_list args; + +#if defined _LIBC && defined __libc_ptf_call + /* We do not want this call to be cut short by a thread + cancellation. Therefore disable cancellation for now. */ + int state = PTHREAD_CANCEL_ENABLE; + __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), + 0); +#endif + + fflush (stdout); +#ifdef _LIBC + _IO_flockfile (stderr); +#endif + if (error_print_progname) + (*error_print_progname) (); + else + { +#if _LIBC + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s: ", program_name); + else +#endif + fprintf (stderr, "%s: ", program_name); + } + + va_start (args, message); + error_tail (status, errnum, message, args); + +#ifdef _LIBC + _IO_funlockfile (stderr); +# ifdef __libc_ptf_call + __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); +# endif +#endif +} + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +int error_one_per_line; + +void +error_at_line (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, ...) +{ + va_list args; + + if (error_one_per_line) + { + static const char *old_file_name; + static unsigned int old_line_number; + + if (old_line_number == line_number + && (file_name == old_file_name + || strcmp (old_file_name, file_name) == 0)) + /* Simply return and print nothing. */ + return; + + old_file_name = file_name; + old_line_number = line_number; + } + +#if defined _LIBC && defined __libc_ptf_call + /* We do not want this call to be cut short by a thread + cancellation. Therefore disable cancellation for now. */ + int state = PTHREAD_CANCEL_ENABLE; + __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), + 0); +#endif + + fflush (stdout); +#ifdef _LIBC + _IO_flockfile (stderr); +#endif + if (error_print_progname) + (*error_print_progname) (); + else + { +#if _LIBC + 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 + 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); + } + + va_start (args, message); + error_tail (status, errnum, message, args); + +#ifdef _LIBC + _IO_funlockfile (stderr); +# ifdef __libc_ptf_call + __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); +# endif +#endif +} + +#ifdef _LIBC +/* Make the weak alias. */ +# undef error +# undef error_at_line +weak_alias (__error, error) +weak_alias (__error_at_line, error_at_line) +#endif diff --git a/lib/error.h b/lib/error.h new file mode 100644 index 000000000000..8ed63595f24f --- /dev/null +++ b/lib/error.h @@ -0,0 +1,66 @@ +/* Declaration for error-reporting function + Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _ERROR_H +#define _ERROR_H 1 + +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +# define __attribute__(Spec) /* empty */ +# endif +/* The __-protected variants of `format' and `printf' attributes + are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) +# define __format__ format +# define __printf__ printf +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Print a message with `fprintf (stderr, FORMAT, ...)'; + if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). + If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ + +extern void error (int __status, int __errnum, const char *__format, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + +extern void error_at_line (int __status, int __errnum, const char *__fname, + unsigned int __lineno, const char *__format, ...) + __attribute__ ((__format__ (__printf__, 5, 6))); + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +extern void (*error_print_progname) (void); + +/* This variable is incremented each time `error' is called. */ +extern unsigned int error_message_count; + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +extern int error_one_per_line; + +#ifdef __cplusplus +} +#endif + +#endif /* error.h */ diff --git a/lib/exit.h b/lib/exit.h new file mode 100644 index 000000000000..4e8d46516546 --- /dev/null +++ b/lib/exit.h @@ -0,0 +1,32 @@ +/* exit() function. + Copyright (C) 1995, 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 _EXIT_H +#define _EXIT_H + +/* Get exit() declaration. */ +#include + +/* Some systems do not define EXIT_*, even with STDC_HEADERS. */ +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + +#endif /* _EXIT_H */ diff --git a/lib/exitfail.c b/lib/exitfail.c new file mode 100644 index 000000000000..2ae5f69555f4 --- /dev/null +++ b/lib/exitfail.c @@ -0,0 +1,27 @@ +/* Failure exit status + + Copyright (C) 2002, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include "exitfail.h" +#include "exit.h" + +int volatile exit_failure = EXIT_FAILURE; diff --git a/lib/exitfail.h b/lib/exitfail.h new file mode 100644 index 000000000000..cf5ab719586e --- /dev/null +++ b/lib/exitfail.h @@ -0,0 +1,20 @@ +/* Failure exit status + + Copyright (C) 2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +extern int volatile exit_failure; diff --git a/lib/fopen-safer.c b/lib/fopen-safer.c new file mode 100644 index 000000000000..c5c97c8a19ab --- /dev/null +++ b/lib/fopen-safer.c @@ -0,0 +1,72 @@ +/* Invoke fopen, but avoid some glitches. + Copyright (C) 2001, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 +#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/lib/getopt.c b/lib/getopt.c new file mode 100644 index 000000000000..08ba35be3637 --- /dev/null +++ b/lib/getopt.c @@ -0,0 +1,1068 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to drepper@gnu.org + before changing it! + Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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. */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in . + Ditto for AIX 3.2 and . */ +#ifndef _NO_PROTO +# define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +# ifndef const +# define const +# endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +# include +# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +# define ELIDE_CODE +# endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +# include +# include +#endif /* GNU C library. */ + +#ifdef VMS +# include +# if HAVE_STRING_H - 0 +# include +# endif +#endif + +#ifndef _ +/* This is for other GNU distributions with internationalized messages. */ +# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC +# include +# ifndef _ +# define _(msgid) gettext (msgid) +# endif +# else +# define _(msgid) (msgid) +# endif +#endif + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* 1003.2 says this must be 1 before any call. */ +int optind = 1; + +/* Formerly, initialization of getopt depended on optind==0, which + causes problems with re-calling getopt as programs generally don't + know that. */ + +int __getopt_initialized; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return -1 with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +# include +# define my_index strchr +#else + +# if HAVE_STRING_H +# include +# else +# include +# endif + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +#ifndef getenv +extern char *getenv (); +#endif + +static char * +my_index (str, chr) + const char *str; + int chr; +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} + +/* If using GCC, we can safely declare strlen this way. + If not using GCC, it is ok not to declare it. */ +#ifdef __GNUC__ +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +# if (!defined __STDC__ || !__STDC__) && !defined strlen +/* gcc with -traditional declares the built-in strlen to return int, + and has done so at least since version 2.4.5. -- rms. */ +extern int strlen (const char *); +# endif /* not __STDC__ */ +#endif /* __GNUC__ */ + +#endif /* not __GNU_LIBRARY__ */ + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +#ifdef _LIBC +/* Bash 2.0 gives us an environment variable containing flags + indicating ARGV elements that should not be considered arguments. */ + +#ifdef USE_NONOPTION_FLAGS +/* Defined in getopt_init.c */ +extern char *__getopt_nonoption_flags; + +static int nonoption_flags_max_len; +static int nonoption_flags_len; +#endif + +static int original_argc; +static char *const *original_argv; + +/* Make sure the environment variable bash 2.0 puts in the environment + is valid for the getopt call we must make sure that the ARGV passed + to getopt is that one passed to the process. */ +static void +__attribute__ ((unused)) +store_args_and_env (int argc, char *const *argv) +{ + /* XXX This is no good solution. We should rather copy the args so + that we can compare them later. But we must not use malloc(3). */ + original_argc = argc; + original_argv = argv; +} +# ifdef text_set_element +text_set_element (__libc_subinit, store_args_and_env); +# endif /* text_set_element */ + +# ifdef USE_NONOPTION_FLAGS +# define SWAP_FLAGS(ch1, ch2) \ + if (nonoption_flags_len > 0) \ + { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ + } +# else +# define SWAP_FLAGS(ch1, ch2) +# endif +#else /* !_LIBC */ +# define SWAP_FLAGS(ch1, ch2) +#endif /* _LIBC */ + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +#if defined __STDC__ && __STDC__ +static void exchange (char **); +#endif + +static void +exchange (argv) + char **argv; +{ + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; + + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + +#if defined _LIBC && defined USE_NONOPTION_FLAGS + /* First make sure the handling of the `__getopt_nonoption_flags' + string can work normally. Our top argument must be in the range + of the string. */ + if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) + { + /* We must extend the array. The user plays games with us and + presents new arguments. */ + char *new_str = malloc (top + 1); + if (new_str == NULL) + nonoption_flags_len = nonoption_flags_max_len = 0; + else + { + memset (__mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); + nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; + } + } +#endif + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + SWAP_FLAGS (bottom + i, middle + i); + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Initialize the internal data when the first call is made. */ + +#if defined __STDC__ && __STDC__ +static const char *_getopt_initialize (int, char *const *, const char *); +#endif +static const char * +_getopt_initialize (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + first_nonopt = last_nonopt = optind; + + nextchar = NULL; + + posixly_correct = getenv ("POSIXLY_CORRECT"); + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + +#if defined _LIBC && defined USE_NONOPTION_FLAGS + if (posixly_correct == NULL + && argc == original_argc && argv == original_argv) + { + if (nonoption_flags_max_len == 0) + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = nonoption_flags_max_len = strlen (orig_str); + if (nonoption_flags_max_len < argc) + nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); + } + } + nonoption_flags_len = nonoption_flags_max_len; + } + else + nonoption_flags_len = 0; +#endif + + return optstring; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns -1. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; +{ + int print_errors = opterr; + if (optstring[0] == ':') + print_errors = 0; + + if (argc < 1) + return -1; + + optarg = NULL; + + if (optind == 0 || !__getopt_initialized) + { + if (optind == 0) + optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring); + __getopt_initialized = 1; + } + + /* Test whether ARGV[optind] points to a non-option argument. + Either it does not have option syntax, or there is an environment flag + from the shell indicating it is not an option. The later information + is only used when the used in the GNU libc. */ +#if defined _LIBC && defined USE_NONOPTION_FLAGS +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) +#else +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +#endif + + if (nextchar == NULL || *nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (last_nonopt > optind) + last_nonopt = optind; + if (first_nonopt > optind) + first_nonopt = optind; + + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc && NONOPTION_P) + optind++; + last_nonopt = optind; + } + + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return -1; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if (NONOPTION_P) + { + if (ordering == REQUIRE_ORDER) + return -1; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = -1; + int option_index; + + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) + == (unsigned int) strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else if (long_only + || pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) + /* Second or later nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (print_errors) + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + optopt = 0; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (print_errors) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + _("%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + _("%s: option `%c%s' doesn't allow an argument\n"), + argv[0], argv[optind - 1][0], pfound->name); + } + + nextchar += strlen (nextchar); + + optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) + { + if (print_errors) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, _("%s: unrecognized option `--%s'\n"), + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + optopt = 0; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (print_errors) + { + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: illegal option -- %c\n"), + argv[0], c); + else + fprintf (stderr, _("%s: invalid option -- %c\n"), + argv[0], c); + } + optopt = c; + return '?'; + } + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';') + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (print_errors) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + + /* optarg is now the argument, see if it's in the + table of longopts. */ + + for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) + { + if (print_errors) + fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (print_errors) + fprintf (stderr, _("\ +%s: option `-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); + + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (print_errors) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + nextchar = NULL; + return 'W'; /* Let the application handle it. */ + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (print_errors) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, + _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == -1) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/lib/getopt.h b/lib/getopt.h new file mode 100644 index 000000000000..a1b8dd6658f2 --- /dev/null +++ b/lib/getopt.h @@ -0,0 +1,180 @@ +/* Declarations for getopt. + Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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. */ + +#ifndef _GETOPT_H + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif + +/* If __GNU_LIBRARY__ is not already defined, either we are being used + standalone, or this is the first header included in the source file. + If we are being used with glibc, we need to include , but + that does not exist if we are standalone. So: if __GNU_LIBRARY__ is + not defined, include , which will pull in for us + if it's from glibc. (Why ctype.h? It's guaranteed to exist and it + doesn't flood the namespace with stuff the way some other headers do.) */ +#if !defined __GNU_LIBRARY__ +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +#ifndef __need_getopt +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +# if (defined __STDC__ && __STDC__) || defined __cplusplus + const char *name; +# else + char *name; +# endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ + + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, `optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `getopt'. */ + +#if (defined __STDC__ && __STDC__) || defined __cplusplus +# ifdef __GNU_LIBRARY__ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int __argc, char *const *__argv, const char *__shortopts); +# else /* not __GNU_LIBRARY__ */ +extern int getopt (); +# endif /* __GNU_LIBRARY__ */ + +# ifndef __need_getopt +extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, + const struct option *__longopts, int *__longind); +extern int getopt_long_only (int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only); +# endif +#else /* not __STDC__ */ +extern int getopt (); +# ifndef __need_getopt +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +# endif +#endif /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ diff --git a/lib/getopt1.c b/lib/getopt1.c new file mode 100644 index 000000000000..22a7efbdd19a --- /dev/null +++ b/lib/getopt1.c @@ -0,0 +1,188 @@ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "getopt.h" + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +#include +#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +#define ELIDE_CODE +#endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +#include +#endif + +#ifndef NULL +#define NULL 0 +#endif + +int +getopt_long (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); +} + +/* Like getopt_long, but '-' as well as '--' can indicate a long option. + If an option that starts with '-' (not '--') doesn't match a long option, + but does match a short option, it is parsed as a short option + instead. */ + +int +getopt_long_only (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 1); +} + + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +#include + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = + { + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} + }; + + c = getopt_long (argc, argv, "abc:d:0123456789", + long_options, &option_index); + if (c == -1) + break; + + switch (c) + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case 'd': + printf ("option d with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/lib/gettext.h b/lib/gettext.h new file mode 100644 index 000000000000..835732e01fe5 --- /dev/null +++ b/lib/gettext.h @@ -0,0 +1,68 @@ +/* Convenience header for conditional use of GNU . + Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _LIBGETTEXT_H +#define _LIBGETTEXT_H 1 + +/* NLS can be disabled through the configure --disable-nls option. */ +#if ENABLE_NLS + +/* Get declarations of GNU message catalog functions. */ +# include + +#else + +/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which + chokes if dcgettext is defined as a macro. So include it now, to make + later inclusions of a NOP. We don't include + as well because people using "gettext.h" will not include , + and also including would fail on SunOS 4, whereas + is OK. */ +#if defined(__sun) +# include +#endif + +/* Disabled NLS. + The casts to 'const char *' serve the purpose of producing warnings + for invalid uses of the value returned from these functions. + On pre-ANSI systems without 'const', the config.h file is supposed to + contain "#define const". */ +# define gettext(Msgid) ((const char *) (Msgid)) +# define dgettext(Domainname, Msgid) ((const char *) (Msgid)) +# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) +# define ngettext(Msgid1, Msgid2, N) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define dngettext(Domainname, Msgid1, Msgid2, N) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define textdomain(Domainname) ((const char *) (Domainname)) +# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) +# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) + +#endif + +/* A pseudo function call that serves as a marker for the automated + extraction of messages, but does not call gettext(). The run-time + translation is done at a different place in the code. + The argument, String, should be a literal string. Concatenated strings + and other string expressions won't work. + The macro's expansion is not parenthesized, so that it is suitable as + initializer for static 'char[]' or 'const char[]' variables. */ +#define gettext_noop(String) String + +#endif /* _LIBGETTEXT_H */ diff --git a/lib/hard-locale.c b/lib/hard-locale.c new file mode 100644 index 000000000000..67a4144a6fec --- /dev/null +++ b/lib/hard-locale.c @@ -0,0 +1,75 @@ +/* hard-locale.c -- Determine whether a locale is hard. + + Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "hard-locale.h" + +#if HAVE_LOCALE_H +# include +#endif + +#include +#include + +/* Return true if the current CATEGORY locale is hard, i.e. if you + can't get away with assuming traditional C or POSIX behavior. */ +bool +hard_locale (int category) +{ +#if ! HAVE_SETLOCALE + return false; +#else + + bool hard = true; + char const *p = setlocale (category, NULL); + + if (p) + { +# if defined __GLIBC__ && 2 <= __GLIBC__ + if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0) + hard = false; +# else + char *locale = malloc (strlen (p) + 1); + if (locale) + { + 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 = false; + + /* Restore the caller's locale. */ + setlocale (category, locale); + free (locale); + } +# endif + } + + return hard; + +#endif +} diff --git a/lib/hard-locale.h b/lib/hard-locale.h new file mode 100644 index 000000000000..010cb27682b2 --- /dev/null +++ b/lib/hard-locale.h @@ -0,0 +1,26 @@ +/* Determine whether a locale is hard. + + Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 HARD_LOCALE_H_ +# define HARD_LOCALE_H_ 1 + +# include + +bool hard_locale (int); + +#endif /* HARD_LOCALE_H_ */ diff --git a/lib/human.c b/lib/human.c new file mode 100644 index 000000000000..f024c73ea079 --- /dev/null +++ b/lib/human.c @@ -0,0 +1,485 @@ +/* human.c -- print human readable file size + + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 and Larry McVoy. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include "human.h" + +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif +#ifndef UINTMAX_MAX +# define UINTMAX_MAX ((uintmax_t) -1) +#endif + +#if HAVE_LOCALE_H && HAVE_LOCALECONV +# include +#endif + +#include +#include +#include + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +#include +#include +#include + +/* The maximum length of a suffix like "KiB". */ +#define HUMAN_READABLE_SUFFIX_LENGTH_MAX 3 + +static const char power_letter[] = +{ + 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 */ +}; + + +/* If INEXACT_STYLE is not human_round_to_nearest, and if easily + possible, adjust VALUE according to the style. */ + +static long double +adjust_value (int inexact_style, long double value) +{ + /* Do not use the floorl or ceill functions, as that would mean + checking for their presence and possibly 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_nearest && value < UINTMAX_MAX) + { + uintmax_t u = value; + value = u + (inexact_style == human_ceiling && u != value); + } + + return value; +} + +/* Group the digits of NUMBER according to the grouping rules of the + current locale. NUMBER contains NUMBERLEN digits. Modify the + bytes pointed to by NUMBER in place, subtracting 1 from NUMBER for + each byte inserted. Return the starting address of the modified + number. + + To group the digits, use GROUPING and THOUSANDS_SEP as in `struct + lconv' from . */ + +static char * +group_number (char *number, size_t numberlen, + char const *grouping, char const *thousands_sep) +{ + register char *d; + size_t grouplen = SIZE_MAX; + size_t thousands_seplen = strlen (thousands_sep); + size_t i = numberlen; + + /* The maximum possible value for NUMBERLEN is the number of digits + in the square of the largest uintmax_t, so double the size of + uintmax_t before converting to a bound. 302 / 1000 is ceil + (log10 (2.0)). Add 1 for integer division truncation. */ + char buf[2 * sizeof (uintmax_t) * CHAR_BIT * 302 / 1000 + 1]; + + memcpy (buf, number, numberlen); + d = number + numberlen; + + for (;;) + { + unsigned char g = *grouping; + + if (g) + { + grouplen = g < CHAR_MAX ? g : i; + grouping++; + } + + if (i < grouplen) + grouplen = i; + + d -= grouplen; + i -= grouplen; + memcpy (d, buf + i, grouplen); + if (i == 0) + return d; + + d -= thousands_seplen; + memcpy (d, thousands_sep, thousands_seplen); + } +} + +/* Convert N to a human readable format in BUF, using the options OPTS. + + N is expressed in units of FROM_BLOCK_SIZE. FROM_BLOCK_SIZE must + be nonnegative. + + Use units of TO_BLOCK_SIZE in the output number. TO_BLOCK_SIZE + must be positive. + + Use (OPTS & (human_round_to_nearest | human_floor | human_ceiling)) + to determine whether to take the ceiling or floor of any result + that cannot be expressed exactly. + + If (OPTS & human_group_digits), group the thousands digits + according to the locale, e.g., `1,000,000' in an American English + locale. + + If (OPTS & human_autoscale), deduce the output block size + automatically; TO_BLOCK_SIZE must be 1 but it has no effect on the + output. Use powers of 1024 if (OPTS & human_base_1024), and powers + of 1000 otherwise. For example, assuming powers of 1024, 8500 + would be converted to 8.3, 133456345 to 127, 56990456345 to 53, and + so on. Numbers smaller than the power aren't modified. + human_autoscale is normally used together with human_SI. + + If (OPTS & human_SI), append an SI prefix indicating which power is + being used. If in addition (OPTS & human_B), append "B" (if base + 1000) or "iB" (if base 1024) to the SI prefix. When ((OPTS & + human_SI) && ! (OPTS & human_autoscale)), TO_BLOCK_SIZE must be a + power of 1024 or of 1000, depending on (OPTS & + human_base_1024). */ + +char * +human_readable (uintmax_t n, char *buf, int opts, + uintmax_t from_block_size, uintmax_t to_block_size) +{ + int inexact_style = + opts & (human_round_to_nearest | human_floor | human_ceiling); + unsigned int base = opts & human_base_1024 ? 1024 : 1000; + uintmax_t amt; + int tenths; + int exponent = -1; + int exponent_max = sizeof power_letter - 1; + char *p; + char *psuffix; + char const *integerlim; + + /* 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; + + char const *decimal_point = "."; + size_t decimal_pointlen = 1; + char const *grouping = ""; + char const *thousands_sep = ""; +#if HAVE_LOCALE_H && HAVE_LOCALECONV + struct lconv const *l = localeconv (); + size_t pointlen = strlen (l->decimal_point); + if (0 < pointlen && pointlen <= MB_LEN_MAX) + { + decimal_point = l->decimal_point; + decimal_pointlen = pointlen; + } + grouping = l->grouping; + if (strlen (l->thousands_sep) <= MB_LEN_MAX) + thousands_sep = l->thousands_sep; +#endif + + psuffix = buf + LONGEST_HUMAN_READABLE - HUMAN_READABLE_SUFFIX_LENGTH_MAX; + p = psuffix; + + /* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE + units. If this can be done exactly with integer arithmetic, do + not use floating point operations. */ + if (to_block_size <= from_block_size) + { + if (from_block_size % to_block_size == 0) + { + uintmax_t multiplier = from_block_size / to_block_size; + amt = n * multiplier; + if (amt / multiplier == n) + { + tenths = 0; + rounding = 0; + goto use_integer_arithmetic; + } + } + } + else if (from_block_size != 0 && to_block_size % from_block_size == 0) + { + uintmax_t divisor = to_block_size / from_block_size; + uintmax_t r10 = (n % divisor) * 10; + uintmax_t r2 = (r10 % divisor) * 2; + amt = n / divisor; + tenths = r10 / divisor; + rounding = r2 < divisor ? 0 < r2 : 2 + (divisor < r2); + goto use_integer_arithmetic; + } + + { + /* 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. */ + + long double dto_block_size = to_block_size; + long double damt = n * (from_block_size / dto_block_size); + size_t buflen; + size_t nonintegerlen; + + if (! (opts & human_autoscale)) + { + sprintf (buf, "%.0Lf", adjust_value (inexact_style, damt)); + buflen = strlen (buf); + nonintegerlen = 0; + } + else + { + long double e = 1; + exponent = 0; + + do + { + e *= base; + exponent++; + } + while (e * base <= damt && exponent < exponent_max); + + damt /= e; + + sprintf (buf, "%.1Lf", adjust_value (inexact_style, damt)); + buflen = strlen (buf); + nonintegerlen = decimal_pointlen + 1; + + if (1 + nonintegerlen + ! (opts & human_base_1024) < buflen + || ((opts & human_suppress_point_zero) + && buf[buflen - 1] == '0')) + { + sprintf (buf, "%.0Lf", + adjust_value (inexact_style, damt * 10) / 10); + buflen = strlen (buf); + nonintegerlen = 0; + } + } + + p = psuffix - buflen; + memmove (p, buf, buflen); + integerlim = p + buflen - nonintegerlen; + } + goto do_grouping; + + use_integer_arithmetic: + { + /* The computation can be done exactly, with integer arithmetic. + + Use power of BASE notation if requested and if adjusted AMT is + large enough. */ + + if (opts & human_autoscale) + { + exponent = 0; + + if (base <= amt) + { + do + { + unsigned int r10 = (amt % base) * 10 + tenths; + unsigned int r2 = (r10 % base) * 2 + (rounding >> 1); + amt /= base; + tenths = r10 / base; + rounding = (r2 < base + ? (r2 + rounding) != 0 + : 2 + (base < r2 + rounding)); + exponent++; + } + while (base <= amt && exponent < exponent_max); + + if (amt < 10) + { + if (inexact_style == human_round_to_nearest + ? 2 < rounding + (tenths & 1) + : inexact_style == human_ceiling && 0 < rounding) + { + tenths++; + rounding = 0; + + if (tenths == 10) + { + amt++; + tenths = 0; + } + } + + if (amt < 10 + && (tenths || ! (opts & human_suppress_point_zero))) + { + *--p = '0' + tenths; + p -= decimal_pointlen; + memcpy (p, decimal_point, decimal_pointlen); + tenths = rounding = 0; + } + } + } + } + + if (inexact_style == human_round_to_nearest + ? 5 < tenths + (0 < rounding + (amt & 1)) + : inexact_style == human_ceiling && 0 < tenths + rounding) + { + amt++; + + if ((opts & human_autoscale) + && amt == base && exponent < exponent_max) + { + exponent++; + if (! (opts & human_suppress_point_zero)) + { + *--p = '0'; + p -= decimal_pointlen; + memcpy (p, decimal_point, decimal_pointlen); + } + amt = 1; + } + } + + integerlim = p; + + do + { + int digit = amt % 10; + *--p = digit + '0'; + } + while ((amt /= 10) != 0); + } + + do_grouping: + if (opts & human_group_digits) + p = group_number (p, integerlim - p, grouping, thousands_sep); + + if (opts & human_SI) + { + if (exponent < 0) + { + uintmax_t power; + exponent = 0; + for (power = 1; power < to_block_size; power *= base) + if (++exponent == exponent_max) + break; + } + + if (exponent) + *psuffix++ = (! (opts & human_base_1024) && exponent == 1 + ? 'k' + : power_letter[exponent]); + + if (opts & human_B) + { + if ((opts & human_base_1024) && exponent) + *psuffix++ = 'i'; + *psuffix++ = 'B'; + } + } + + *psuffix = '\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_opts[] = + { + human_autoscale + human_SI + human_base_1024, + human_autoscale + human_SI + }; + +static uintmax_t +default_block_size (void) +{ + return getenv ("POSIXLY_CORRECT") ? 512 : DEFAULT_BLOCK_SIZE; +} + +static strtol_error +humblock (char const *spec, uintmax_t *block_size, int *options) +{ + int i; + int opts = 0; + + if (! spec + && ! (spec = getenv ("BLOCK_SIZE")) + && ! (spec = getenv ("BLOCKSIZE"))) + *block_size = default_block_size (); + else + { + if (*spec == '\'') + { + opts |= human_group_digits; + spec++; + } + + if (0 <= (i = ARGMATCH (spec, block_size_args, block_size_opts))) + { + opts |= block_size_opts[i]; + *block_size = 1; + } + else + { + char *ptr; + strtol_error e = xstrtoumax (spec, &ptr, 0, block_size, + "eEgGkKmMpPtTyYzZ0"); + if (e != LONGINT_OK) + return e; + for (; ! ('0' <= *spec && *spec <= '9'); spec++) + if (spec == ptr) + { + opts |= human_SI; + if (ptr[-1] == 'B') + opts |= human_B; + if (ptr[-1] != 'B' || ptr[-2] == 'i') + opts |= human_base_1024; + break; + } + } + } + + *options = opts; + return LONGINT_OK; +} + +int +human_options (char const *spec, bool report_errors, uintmax_t *block_size) +{ + int opts; + strtol_error e = humblock (spec, block_size, &opts); + 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); + return opts; +} diff --git a/lib/human.h b/lib/human.h new file mode 100644 index 000000000000..b67ba4e9ae0c --- /dev/null +++ b/lib/human.h @@ -0,0 +1,88 @@ +/* human.h -- print human readable file size + + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 and Larry McVoy. */ + +#ifndef HUMAN_H_ +# define HUMAN_H_ 1 + +# if HAVE_CONFIG_H +# include +# endif + +# include +# include + +# if HAVE_STDINT_H +# include +# endif +# if HAVE_UNISTD_H +# include +# endif + +/* A conservative bound on the maximum length of a human-readable string. + The output can be the square of the largest uintmax_t, so double + its size before converting to a bound. + 302 / 1000 is ceil (log10 (2.0)). Add 1 for integer division truncation. + Also, the output can have a thousands separator between every digit, + so multiply by MB_LEN_MAX + 1 and then subtract MB_LEN_MAX. + Finally, append 3, the maximum length of a suffix. */ +# define LONGEST_HUMAN_READABLE \ + ((2 * sizeof (uintmax_t) * CHAR_BIT * 302 / 1000 + 1) * (MB_LEN_MAX + 1) \ + - MB_LEN_MAX + 3) + +/* Options for human_readable. */ +enum +{ + /* Unless otherwise specified these options may be ORed together. */ + + /* The following three options are mutually exclusive. */ + /* Round to plus infinity (default). */ + human_ceiling = 0, + /* Round to nearest, ties to even. */ + human_round_to_nearest = 1, + /* Round to minus infinity. */ + human_floor = 2, + + /* Group digits together, e.g. `1,000,000'. This uses the + locale-defined grouping; the traditional C locale does not group, + so this has effect only if some other locale is in use. */ + human_group_digits = 4, + + /* When autoscaling, suppress ".0" at end. */ + human_suppress_point_zero = 8, + + /* Scale output and use SI-style units, ignoring the output block size. */ + human_autoscale = 16, + + /* Prefer base 1024 to base 1000. */ + human_base_1024 = 32, + + /* Append SI prefix, e.g. "k" or "M". */ + human_SI = 64, + + /* Append "B" (if base 1000) or "iB" (if base 1024) to SI prefix. */ + human_B = 128 +}; + +char *human_readable (uintmax_t, char *, int, uintmax_t, uintmax_t); + +int human_options (char const *, bool, uintmax_t *); + +#endif /* HUMAN_H_ */ diff --git a/lib/inttostr.c b/lib/inttostr.c new file mode 100644 index 000000000000..78a48af84cee --- /dev/null +++ b/lib/inttostr.c @@ -0,0 +1,49 @@ +/* inttostr.c -- convert integers to printable strings + + 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 */ + +#include "inttostr.h" + +/* Convert I to a printable string in BUF, which must be at least + INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the + printable string, which need not start at BUF. */ + +char * +inttostr (inttype i, char *buf) +{ + char *p = buf + INT_STRLEN_BOUND (inttype); + *p = 0; + + if (i < 0) + { + do + *--p = '0' - i % 10; + while ((i /= 10) != 0); + + *--p = '-'; + } + else + { + do + *--p = '0' + i % 10; + while ((i /= 10) != 0); + } + + return p; +} diff --git a/lib/inttostr.h b/lib/inttostr.h new file mode 100644 index 000000000000..6f2416b53faf --- /dev/null +++ b/lib/inttostr.h @@ -0,0 +1,47 @@ +/* inttostr.h -- convert integers to printable strings + + Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 +#if HAVE_STDINT_H +# include +#endif + +#include + +#if HAVE_SYS_TYPES_H +# include +#endif + +/* Upper bound on the string length of an integer converted to string. + 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit; + add 1 for integer division truncation; add 1 more for a minus sign. */ +#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2) + +#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) + +char *offtostr (off_t, char *); +char *imaxtostr (intmax_t, char *); +char *umaxtostr (uintmax_t, char *); diff --git a/lib/long-options.c b/lib/long-options.c new file mode 100644 index 000000000000..1c4e74a001d6 --- /dev/null +++ b/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, 2002, 2003, 2004 Free + Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 + +/* Specification. */ +#include "long-options.h" + +#include +#include +#include +#include + +#include "version-etc.h" + +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, + void (*usage_func) (int), + /* const char *author1, ...*/ ...) +{ + 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) (EXIT_SUCCESS); + + case 'v': + { + va_list authors; + va_start (authors, usage_func); + version_etc_va (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/lib/long-options.h b/lib/long-options.h new file mode 100644 index 000000000000..50f0c34e1010 --- /dev/null +++ b/lib/long-options.h @@ -0,0 +1,26 @@ +/* long-options.h -- declaration for --help- and --version-handling function. + Copyright (C) 1993, 1994, 1998, 1999, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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. */ + +void parse_long_options (int _argc, + char **_argv, + const char *_command_name, + const char *_package, + const char *_version, + void (*_usage) (int), + /* const char *author1, ...*/ ...); diff --git a/lib/memcoll.c b/lib/memcoll.c new file mode 100644 index 000000000000..e777e6a5bc7f --- /dev/null +++ b/lib/memcoll.c @@ -0,0 +1,85 @@ +/* Locale-specific memory comparison. + Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "memcoll.h" + +#include +#include + +/* 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. Perhaps 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; + +#if HAVE_STRCOLL + + 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; + +#else + + diff = memcmp (s1, s2, s1len < s2len ? s1len : s2len); + if (! diff) + diff = s1len < s2len ? -1 : s1len != s2len; + errno = 0; + +#endif + + return diff; +} diff --git a/lib/memcoll.h b/lib/memcoll.h new file mode 100644 index 000000000000..66b2ecb1e87f --- /dev/null +++ b/lib/memcoll.h @@ -0,0 +1,28 @@ +/* Locale-specific memory comparison. + + Copyright (C) 1999, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 . */ + +#ifndef MEMCOLL_H_ +# define MEMCOLL_H_ 1 + +# include + +int memcoll (char *, size_t, char *, size_t); + +#endif /* MEMCOLL_H_ */ diff --git a/lib/pathmax.h b/lib/pathmax.h new file mode 100644 index 000000000000..bdd756e9c51f --- /dev/null +++ b/lib/pathmax.h @@ -0,0 +1,54 @@ +/* Define PATH_MAX somehow. Requires sys/types.h. + Copyright (C) 1992, 1999, 2001, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 __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/lib/physmem.c b/lib/physmem.c new file mode 100644 index 000000000000..dc67b575cff5 --- /dev/null +++ b/lib/physmem.c @@ -0,0 +1,307 @@ +/* Calculate the size of physical memory. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 + +#if HAVE_SYS_SYSMP_H +# include +#endif + +#if HAVE_SYS_SYSINFO_H && HAVE_MACHINE_HAL_SYSINFO_H +# include +# include +#endif + +#if HAVE_SYS_TABLE_H +# include +#endif + +#include + +#if HAVE_SYS_PARAM_H +# include +#endif + +#if HAVE_SYS_SYSCTL_H +# include +#endif + +#if HAVE_SYS_SYSTEMCFG_H +# include +#endif + +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN +# include +/* MEMORYSTATUSEX is missing from older windows headers, so define + a local replacement. */ +typedef struct +{ + DWORD dwLength; + DWORD dwMemoryLoad; + DWORDLONG ullTotalPhys; + DWORDLONG ullAvailPhys; + DWORDLONG ullTotalPageFile; + DWORDLONG ullAvailPageFile; + DWORDLONG ullTotalVirtual; + DWORDLONG ullAvailVirtual; + DWORDLONG ullAvailExtendedVirtual; +} lMEMORYSTATUSEX; +typedef WINBOOL (WINAPI *PFN_MS_EX) (lMEMORYSTATUSEX*); +#endif + +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) + +/* Return the total amount of physical memory. */ +double +physmem_total (void) +{ +#if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE + { /* This works on linux-gnu, solaris2 and cygwin. */ + double pages = sysconf (_SC_PHYS_PAGES); + double pagesize = sysconf (_SC_PAGESIZE); + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } +#endif + +#if HAVE_PSTAT_GETSTATIC + { /* This works on hpux11. */ + 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 + +#if HAVE_SYSMP && defined MP_SAGET && defined MPSA_RMINFO && defined _SC_PAGESIZE + { /* This works on irix6. */ + struct rminfo realmem; + if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0) + { + double pagesize = sysconf (_SC_PAGESIZE); + double pages = realmem.physmem; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } + } +#endif + +#if HAVE_GETSYSINFO && defined GSI_PHYSMEM + { /* This works on Tru64 UNIX V4/5. */ + int physmem; + + if (getsysinfo (GSI_PHYSMEM, (caddr_t) &physmem, sizeof (physmem), + NULL, NULL, NULL) == 1) + { + double kbytes = physmem; + + if (0 <= kbytes) + return kbytes * 1024.0; + } + } +#endif + +#if HAVE_SYSCTL && defined HW_PHYSMEM + { /* This works on *bsd and darwin. */ + unsigned int physmem; + size_t len = sizeof physmem; + static int mib[2] = { CTL_HW, HW_PHYSMEM }; + + if (sysctl (mib, ARRAY_SIZE (mib), &physmem, &len, NULL, 0) == 0 + && len == sizeof (physmem)) + return (double) physmem; + } +#endif + +#if HAVE__SYSTEM_CONFIGURATION + /* This works on AIX. */ + return _system_configuration.physmem; +#endif + +#if defined _WIN32 + { /* this works on windows */ + PFN_MS_EX pfnex; + HMODULE h = GetModuleHandle ("kernel32.dll"); + + if (!h) + return 0.0; + + /* Use GlobalMemoryStatusEx if available. */ + if ((pfnex = (PFN_MS_EX) GetProcAddress (h, "GlobalMemoryStatusEx"))) + { + lMEMORYSTATUSEX lms_ex; + lms_ex.dwLength = sizeof lms_ex; + if (!pfnex (&lms_ex)) + return 0.0; + return (double) lms_ex.ullTotalPhys; + } + + /* Fall back to GlobalMemoryStatus which is always available. + but returns wrong results for physical memory > 4GB. */ + else + { + MEMORYSTATUS ms; + GlobalMemoryStatus (&ms); + return (double) ms.dwTotalPhys; + } + } +#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 + { /* This works on linux-gnu, solaris2 and cygwin. */ + 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 + { /* This works on hpux11. */ + 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 + +#if HAVE_SYSMP && defined MP_SAGET && defined MPSA_RMINFO && defined _SC_PAGESIZE + { /* This works on irix6. */ + struct rminfo realmem; + if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0) + { + double pagesize = sysconf (_SC_PAGESIZE); + double pages = realmem.availrmem; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } + } +#endif + +#if HAVE_TABLE && defined TBL_VMSTATS + { /* This works on Tru64 UNIX V4/5. */ + struct tbl_vmstats vmstats; + + if (table (TBL_VMSTATS, 0, &vmstats, 1, sizeof (vmstats)) == 1) + { + double pages = vmstats.free_count; + double pagesize = vmstats.pagesize; + + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; + } + } +#endif + +#if HAVE_SYSCTL && defined HW_USERMEM + { /* This works on *bsd and darwin. */ + unsigned int usermem; + size_t len = sizeof usermem; + static int mib[2] = { CTL_HW, HW_USERMEM }; + + if (sysctl (mib, ARRAY_SIZE (mib), &usermem, &len, NULL, 0) == 0 + && len == sizeof (usermem)) + return (double) usermem; + } +#endif + +#if defined _WIN32 + { /* this works on windows */ + PFN_MS_EX pfnex; + HMODULE h = GetModuleHandle ("kernel32.dll"); + + if (!h) + return 0.0; + + /* Use GlobalMemoryStatusEx if available. */ + if ((pfnex = (PFN_MS_EX) GetProcAddress (h, "GlobalMemoryStatusEx"))) + { + lMEMORYSTATUSEX lms_ex; + lms_ex.dwLength = sizeof lms_ex; + if (!pfnex (&lms_ex)) + return 0.0; + return (double) lms_ex.ullAvailPhys; + } + + /* Fall back to GlobalMemoryStatus which is always available. + but returns wrong results for physical memory > 4GB */ + else + { + MEMORYSTATUS ms; + GlobalMemoryStatus (&ms); + return (double) ms.dwAvailPhys; + } + } +#endif + + /* Guess 25% of physical memory. */ + return physmem_total () / 4; +} + + +#if DEBUG + +# include +# include + +int +main (void) +{ + printf ("%12.f %12.f\n", physmem_total (), physmem_available ()); + exit (0); +} + +#endif /* DEBUG */ + +/* +Local Variables: +compile-command: "gcc -DDEBUG -DHAVE_CONFIG_H -I.. -g -O -Wall -W physmem.c" +End: +*/ diff --git a/lib/physmem.h b/lib/physmem.h new file mode 100644 index 000000000000..67f880c9a8d4 --- /dev/null +++ b/lib/physmem.h @@ -0,0 +1,27 @@ +/* Calculate the size of physical memory. + + Copyright (C) 2000, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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. */ + +#ifndef PHYSMEM_H_ +# define PHYSMEM_H_ 1 + +double physmem_total (void); +double physmem_available (void); + +#endif /* PHYSMEM_H_ */ diff --git a/lib/posixver.c b/lib/posixver.c new file mode 100644 index 000000000000..754d7ac55ace --- /dev/null +++ b/lib/posixver.c @@ -0,0 +1,59 @@ +/* Which POSIX version to conform to, for utilities. + + Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "posixver.h" + +#include +#include + +#if HAVE_UNISTD_H +# include +#endif +#ifndef _POSIX2_VERSION +# define _POSIX2_VERSION 0 +#endif + +#ifndef DEFAULT_POSIX2_VERSION +# define DEFAULT_POSIX2_VERSION _POSIX2_VERSION +#endif + +/* The POSIX version that utilities should conform to. The default is + specified by the system. */ + +int +posix2_version (void) +{ + long int v = DEFAULT_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/lib/posixver.h b/lib/posixver.h new file mode 100644 index 000000000000..b64f6a2ea1b2 --- /dev/null +++ b/lib/posixver.h @@ -0,0 +1 @@ +int posix2_version (void); diff --git a/lib/quote.c b/lib/quote.c new file mode 100644 index 000000000000..5f11d836b3c3 --- /dev/null +++ b/lib/quote.c @@ -0,0 +1,41 @@ +/* quote.c - quote arguments for output + Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "quotearg.h" +#include "quote.h" + +/* Return an unambiguous printable representation of NAME, + allocated in slot N, suitable for diagnostics. */ +char const * +quote_n (int n, char const *name) +{ + return quotearg_n_style (n, locale_quoting_style, name); +} + +/* Return an unambiguous printable representation of NAME, + suitable for diagnostics. */ +char const * +quote (char const *name) +{ + return quote_n (0, name); +} diff --git a/lib/quote.h b/lib/quote.h new file mode 100644 index 000000000000..682f9d1fd2f9 --- /dev/null +++ b/lib/quote.h @@ -0,0 +1,22 @@ +/* quote.h - prototypes for quote.c + + Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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. */ + + +char const *quote_n (int n, char const *name); +char const *quote (char const *name); diff --git a/lib/quotearg.c b/lib/quotearg.c new file mode 100644 index 000000000000..64fa67635455 --- /dev/null +++ b/lib/quotearg.c @@ -0,0 +1,673 @@ +/* quotearg.c - quote arguments for output + + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "quotearg.h" + +#include "xalloc.h" + +#include +#include +#include +#include +#include +#include + +#include "gettext.h" +#define _(msgid) gettext (msgid) +#define N_(msgid) msgid + +#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 iswprint(wc) isprint ((unsigned char) (wc)) +# undef HAVE_MBSINIT +#endif + +#if !defined mbsinit && !HAVE_MBSINIT +# define mbsinit(ps) 1 +#endif + +#ifndef iswprint +# if HAVE_WCTYPE_H +# include +# endif +# if !defined iswprint && !HAVE_ISWPRINT +# define iswprint(wc) 1 +# endif +#endif + +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + +#define INT_BITS (sizeof (int) * CHAR_BIT) + +struct quoting_options +{ + /* Basic quoting style. */ + enum quoting_style style; + + /* 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) +{ + int e = errno; + struct quoting_options *p = xmalloc (sizeof *p); + *p = *(o ? o : &default_quoting_options); + errno = e; + return p; +} + +/* Get the value of O's quoting style. If O is null, use the default. */ +enum quoting_style +get_quoting_style (struct quoting_options *o) +{ + return (o ? o : &default_quoting_options)->style; +} + +/* In O (or in the default if O is null), + set the value of the quoting style to S. */ +void +set_quoting_style (struct quoting_options *o, enum quoting_style s) +{ + (o ? o : &default_quoting_options)->style = s; +} + +/* In O (or in the default if O is null), + set the value of the quoting options for character C to I. + Return the old value. Currently, the only values defined for I are + 0 (the default) and 1 (which means to quote the character even if + it would not otherwise be quoted). */ +int +set_char_quoting (struct quoting_options *o, char c, int i) +{ + unsigned char uc = c; + 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 SIZE_MAX, 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; + bool backslash_escapes = false; + bool 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 = true; + quote_string = "\""; + quote_string_len = 1; + break; + + case escape_quoting_style: + backslash_escapes = true; + 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 = true; + 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_MAX ? arg[i] == '\0' : i == argsize); i++) + { + unsigned char c; + unsigned char esc; + + if (backslash_escapes + && quote_string_len + && i + quote_string_len <= argsize + && memcmp (arg + i, quote_string, quote_string_len) == 0) + 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. */ + c = arg[i + 2]; + i += 2; + STORE ('?'); + STORE ('\\'); + STORE ('?'); + break; + } + break; + + default: + break; + } + break; + + case '\a': esc = 'a'; goto c_escape; + case '\b': esc = 'b'; goto c_escape; + case '\f': esc = 'f'; goto c_escape; + case '\n': esc = 'n'; goto c_and_shell_escape; + case '\r': esc = 'r'; goto c_and_shell_escape; + case '\t': esc = 't'; goto c_and_shell_escape; + case '\v': esc = 'v'; goto c_escape; + case '\\': esc = c; 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 '}': /* sometimes special if isolated */ + if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1)) + break; + /* Fall through. */ + case '#': case '~': + if (i != 0) + break; + /* Fall through. */ + case ' ': + case '!': /* special in bash */ + case '"': case '$': case '&': + case '(': case ')': case '*': case ';': + case '<': + case '=': /* sometimes special in 0th or (with "set -k") later args */ + case '>': case '[': + case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */ + case '`': case '|': + /* A shell special character. In theory, '$' and '`' could + be the first bytes of multibyte characters, which means + we should check them with mbrtowc, but in practice this + doesn't happen so it's not worth worrying about. */ + if (quoting_style == shell_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 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': case ']': case '_': case 'a': case 'b': + case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': + case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': + case 'o': case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': + /* These characters don't cause problems, no matter what the + quoting style is. They cannot start multibyte sequences. */ + break; + + default: + /* If we have a multibyte sequence, copy it until we reach + its end, find an error, or come back to the initial shift + state. For C-like styles, if the sequence has + unprintable characters, escape the whole sequence, since + we can't easily escape single characters within it. */ + { + /* Length of multibyte sequence found so far. */ + size_t m; + + bool printable; + + if (unibyte_locale) + { + m = 1; + printable = isprint (c) != 0; + } + else + { + mbstate_t mbstate; + memset (&mbstate, 0, sizeof mbstate); + + m = 0; + printable = true; + if (argsize == SIZE_MAX) + argsize = strlen (arg); + + do + { + wchar_t w; + size_t bytes = mbrtowc (&w, &arg[i + m], + argsize - (i + m), &mbstate); + if (bytes == 0) + break; + else if (bytes == (size_t) -1) + { + printable = false; + break; + } + else if (bytes == (size_t) -2) + { + printable = false; + while (i + m < argsize && arg[i + m]) + m++; + break; + } + else + { + /* Work around a bug with older shells that "see" a '\' + that is really the 2nd byte of a multibyte character. + In practice the problem is limited to ASCII + chars >= '@' that are shell special chars. */ + if ('[' == 0x5b && quoting_style == shell_quoting_style) + { + size_t j; + for (j = 1; j < bytes; j++) + switch (arg[i + m + j]) + { + case '[': case '\\': case '^': + case '`': case '|': + goto use_shell_always_quoting_style; + } + } + + if (! iswprint (w)) + printable = false; + m += bytes; + } + } + while (! mbsinit (&mbstate)); + } + + if (1 < m || (backslash_escapes && ! printable)) + { + /* Output a multibyte sequence, or an escaped + unprintable unibyte character. */ + size_t ilim = i + m; + + for (;;) + { + if (backslash_escapes && ! printable) + { + 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 (i == 0 && quoting_style == shell_quoting_style) + goto use_shell_always_quoting_style; + + 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 SIZE_MAX, use the string length of the argument for + ARGSIZE. */ +size_t +quotearg_buffer (char *buffer, size_t buffersize, + char const *arg, size_t argsize, + struct quoting_options const *o) +{ + struct quoting_options const *p = o ? o : &default_quoting_options; + int e = errno; + size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize, + p->style, p); + errno = e; + return r; +} + +/* Like quotearg_buffer (..., ARG, ARGSIZE, O), except return newly + allocated storage containing the quoted string. */ +char * +quotearg_alloc (char const *arg, size_t argsize, + struct quoting_options const *o) +{ + int e = errno; + size_t bufsize = quotearg_buffer (0, 0, arg, argsize, o) + 1; + char *buf = xmalloc (bufsize); + quotearg_buffer (buf, bufsize, arg, argsize, o); + errno = e; + return buf; +} + +/* Use storage slot N to return a quoted version of argument ARG. + ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a + null-terminated string. + OPTIONS specifies the quoting options. + The returned value points to static storage that can be + reused by the next call to this function with the same value of N. + N must be nonnegative. N is deliberately declared with type "int" + to allow for future extensions (using negative values). */ +static char * +quotearg_n_options (int n, char const *arg, size_t argsize, + struct quoting_options const *options) +{ + int e = errno; + + /* 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; + + if (xalloc_oversized (n1, sizeof *slotvec)) + xalloc_die (); + + if (slotvec == &slotvec0) + { + slotvec = xmalloc (sizeof *slotvec); + *slotvec = slotvec0; + } + slotvec = xrealloc (slotvec, n1 * sizeof *slotvec); + 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; + if (val != slot0) + free (val); + slotvec[n].val = val = xmalloc (size); + quotearg_buffer (val, size, arg, argsize, options); + } + + errno = e; + return val; + } +} + +char * +quotearg_n (int n, char const *arg) +{ + return quotearg_n_options (n, arg, SIZE_MAX, &default_quoting_options); +} + +char * +quotearg (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_MAX, &o); +} + +char * +quotearg_n_style_mem (int n, enum quoting_style s, + char const *arg, size_t argsize) +{ + struct quoting_options const o = quoting_options_from_style (s); + return quotearg_n_options (n, arg, argsize, &o); +} + +char * +quotearg_style (enum quoting_style s, char const *arg) +{ + return quotearg_n_style (0, s, arg); +} + +char * +quotearg_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_MAX, &options); +} + +char * +quotearg_colon (char const *arg) +{ + return quotearg_char (arg, ':'); +} diff --git a/lib/quotearg.h b/lib/quotearg.h new file mode 100644 index 000000000000..14dc316d74bd --- /dev/null +++ b/lib/quotearg.h @@ -0,0 +1,137 @@ +/* quotearg.h - quote arguments for output + + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 */ + +#ifndef QUOTEARG_H_ +# define QUOTEARG_H_ 1 + +# include + +/* Basic quoting styles. */ +enum quoting_style + { + /* Output names as-is (ls --quoting-style=literal). */ + literal_quoting_style, + + /* Quote names for the shell if they contain shell metacharacters + or would cause ambiguous output (ls --quoting-style=shell). */ + shell_quoting_style, + + /* Quote names for the shell, even if they would normally not + require quoting (ls --quoting-style=shell-always). */ + shell_always_quoting_style, + + /* Quote names as for a C language string (ls --quoting-style=c). */ + c_quoting_style, + + /* Like c_quoting_style except omit the surrounding double-quote + characters (ls --quoting-style=escape). */ + escape_quoting_style, + + /* Like clocale_quoting_style, but quote `like this' instead of + "like this" in the default C locale (ls --quoting-style=locale). */ + locale_quoting_style, + + /* Like c_quoting_style except use quotation marks appropriate for + the locale (ls --quoting-style=clocale). */ + clocale_quoting_style + }; + +/* For now, --quoting-style=literal is the default, but this may change. */ +# ifndef DEFAULT_QUOTING_STYLE +# define DEFAULT_QUOTING_STYLE literal_quoting_style +# endif + +/* Names of quoting styles and their corresponding values. */ +extern char const *const quoting_style_args[]; +extern enum quoting_style const quoting_style_vals[]; + +struct quoting_options; + +/* The functions listed below set and use a hidden variable + that contains the default quoting style options. */ + +/* Allocate a new set of quoting options, with contents initially identical + to O if O is not null, or to the default if O is null. + It is the caller's responsibility to free the result. */ +struct quoting_options *clone_quoting_options (struct quoting_options *o); + +/* Get the value of O's quoting style. If O is null, use the default. */ +enum quoting_style get_quoting_style (struct quoting_options *o); + +/* In O (or in the default if O is null), + set the value of the quoting style to S. */ +void set_quoting_style (struct quoting_options *o, enum quoting_style s); + +/* In O (or in the default if O is null), + set the value of the quoting options for character C to I. + Return the old value. Currently, the only values defined for I are + 0 (the default) and 1 (which means to quote the character even if + it would not otherwise be quoted). */ +int set_char_quoting (struct quoting_options *o, char c, int i); + +/* 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); + +/* Like quotearg_buffer, except return the result in a newly allocated + buffer. It is the caller's responsibility to free the result. */ +char *quotearg_alloc (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 (int n, char const *arg); + +/* Equivalent to quotearg_n (0, ARG). */ +char *quotearg (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 (int n, enum quoting_style s, char const *arg); + +/* Use style S and storage slot N to return a quoted version of the + argument ARG of size ARGSIZE. This is like quotearg_n_style + (N, S, ARG), except it can quote null bytes. */ +char *quotearg_n_style_mem (int n, enum quoting_style s, + char const *arg, size_t argsize); + +/* Equivalent to quotearg_n_style (0, S, ARG). */ +char *quotearg_style (enum quoting_style s, char const *arg); + +/* Like quotearg (ARG), except also quote any instances of CH. */ +char *quotearg_char (char const *arg, char ch); + +/* Equivalent to quotearg_char (ARG, ':'). */ +char *quotearg_colon (char const *arg); + +#endif /* !QUOTEARG_H_ */ diff --git a/lib/stat-macros.h b/lib/stat-macros.h new file mode 100644 index 000000000000..facbabbc3c87 --- /dev/null +++ b/lib/stat-macros.h @@ -0,0 +1,255 @@ +/* stat-related macros + + Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 and Jim Meyering. */ + +#ifndef STAT_MACROS_H +# define STAT_MACROS_H 1 + +# if ! defined S_ISREG && ! defined S_IFREG +# error "you must include before including this file" +# endif + +# ifndef S_IFMT +# define S_IFMT 0170000 +# endif + +# if STAT_MACROS_BROKEN +# undef S_ISBLK +# undef S_ISCHR +# undef S_ISDIR +# undef S_ISDOOR +# undef S_ISFIFO +# undef S_ISLNK +# undef S_ISNAM +# undef S_ISMPB +# undef S_ISMPC +# undef S_ISNWK +# undef S_ISREG +# undef S_ISSOCK +# endif + + +# ifndef S_ISBLK +# ifdef S_IFBLK +# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +# else +# define S_ISBLK(m) 0 +# endif +# endif + +# ifndef S_ISCHR +# ifdef S_IFCHR +# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +# else +# define S_ISCHR(m) 0 +# endif +# endif + +# ifndef S_ISDIR +# ifdef S_IFDIR +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# else +# define S_ISDIR(m) 0 +# endif +# endif + +# ifndef S_ISDOOR /* Solaris 2.5 and up */ +# ifdef S_IFDOOR +# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR) +# else +# define S_ISDOOR(m) 0 +# endif +# endif + +# ifndef S_ISFIFO +# ifdef S_IFIFO +# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +# else +# define S_ISFIFO(m) 0 +# endif +# endif + +# ifndef S_ISLNK +# ifdef S_IFLNK +# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +# else +# define S_ISLNK(m) 0 +# endif +# endif + +# ifndef S_ISMPB /* V7 */ +# ifdef S_IFMPB +# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) +# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) +# else +# define S_ISMPB(m) 0 +# define S_ISMPC(m) 0 +# endif +# endif + +# ifndef S_ISNAM /* Xenix */ +# ifdef S_IFNAM +# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) +# else +# define S_ISNAM(m) 0 +# endif +# endif + +# ifndef S_ISNWK /* HP/UX */ +# ifdef S_IFNWK +# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) +# else +# define S_ISNWK(m) 0 +# endif +# endif + +# ifndef S_ISREG +# ifdef S_IFREG +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +# else +# define S_ISREG(m) 0 +# endif +# endif + +# ifndef S_ISSOCK +# ifdef S_IFSOCK +# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +# else +# define S_ISSOCK(m) 0 +# endif +# endif + + +# ifndef S_TYPEISMQ +# define S_TYPEISMQ(p) 0 +# endif + +# ifndef S_TYPEISTMO +# define S_TYPEISTMO(p) 0 +# endif + + +# ifndef S_TYPEISSEM +# ifdef S_INSEM +# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) +# else +# define S_TYPEISSEM(p) 0 +# endif +# endif + +# ifndef S_TYPEISSHM +# ifdef S_INSHD +# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) +# else +# define S_TYPEISSHM(p) 0 +# endif +# endif + +/* contiguous */ +# ifndef S_ISCTG +# define S_ISCTG(p) 0 +# endif + +/* Cray DMF (data migration facility): off line, with data */ +# ifndef S_ISOFD +# define S_ISOFD(p) 0 +# endif + +/* Cray DMF (data migration facility): off line, with no data */ +# ifndef S_ISOFL +# define S_ISOFL(p) 0 +# endif + +/* If any of the following are undefined, + define them to their de facto standard values. */ +# 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) + +#endif /* STAT_MACROS_H */ diff --git a/lib/stdio-safer.h b/lib/stdio-safer.h new file mode 100644 index 000000000000..8a22f1220658 --- /dev/null +++ b/lib/stdio-safer.h @@ -0,0 +1,23 @@ +/* Invoke stdio functions, but avoid some glitches. + + Copyright (C) 2001, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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. */ + +#include + +FILE *fopen_safer (char const *, char const *); diff --git a/lib/strnlen.c b/lib/strnlen.c new file mode 100644 index 000000000000..c9f389845117 --- /dev/null +++ b/lib/strnlen.c @@ -0,0 +1,48 @@ +/* Find the length of STRING, but scan at most MAXLEN characters. + Copyright (C) 1996, 1997, 1998, 2000-2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif +#undef strnlen + +#include + +#undef __strnlen +#undef strnlen + +#ifndef _LIBC +# define strnlen rpl_strnlen +#endif + +#ifndef weak_alias +# define __strnlen strnlen +#endif + +/* Find the length of STRING, but scan at most MAXLEN characters. + If no '\0' terminator is found in that many characters, return MAXLEN. */ + +size_t +__strnlen (const char *string, size_t maxlen) +{ + const char *end = memchr (string, '\0', maxlen); + return end ? (size_t) (end - string) : maxlen; +} +#ifdef weak_alias +weak_alias (__strnlen, strnlen) +#endif diff --git a/lib/timespec.h b/lib/timespec.h new file mode 100644 index 000000000000..2c32a23db425 --- /dev/null +++ b/lib/timespec.h @@ -0,0 +1,71 @@ +/* timespec -- System time interface + + Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 ! defined TIMESPEC_H +# define TIMESPEC_H + +/* You must include config.h before including this file. */ + +# include +# if TIME_WITH_SYS_TIME +# include +# include +# else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +# endif + +# if ! HAVE_STRUCT_TIMESPEC +/* Some systems don't define this struct, e.g., AIX 4.1, Ultrix 4.3. */ +struct timespec +{ + time_t tv_sec; + long tv_nsec; +}; +# endif + +# 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) + +# ifdef ST_MTIM_NSEC +# define TIMESPEC_NS(timespec) ((timespec).ST_MTIM_NSEC) +# else +# define TIMESPEC_NS(timespec) 0 +# endif + +# if ! HAVE_DECL_NANOSLEEP +/* Don't specify a prototype here. Some systems (e.g., OSF) declare + nanosleep with a conflicting one (const-less first parameter). */ +int nanosleep (); +# endif + +int gettime (struct timespec *); +int settime (struct timespec const *); + +#endif diff --git a/lib/umaxtostr.c b/lib/umaxtostr.c new file mode 100644 index 000000000000..4f49a7f8ddd9 --- /dev/null +++ b/lib/umaxtostr.c @@ -0,0 +1,3 @@ +#define inttostr umaxtostr +#define inttype uintmax_t +#include "inttostr.c" diff --git a/lib/unistd-safer.h b/lib/unistd-safer.h new file mode 100644 index 000000000000..2976e9d0dc01 --- /dev/null +++ b/lib/unistd-safer.h @@ -0,0 +1,21 @@ +/* Invoke unistd functions, but avoid some glitches. + + Copyright (C) 2001, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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. */ + +int dup_safer (int); diff --git a/lib/version-etc.c b/lib/version-etc.c new file mode 100644 index 000000000000..fd71eff93f5d --- /dev/null +++ b/lib/version-etc.c @@ -0,0 +1,176 @@ +/* Utility to help print --version output in a consistent format. + Copyright (C) 1999-2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 + +/* Specification. */ +#include "version-etc.h" + +#include +#include +#include +#include "unlocked-io.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +/* Default copyright goes to the FSF. */ + +const char* version_etc_copyright = + /* Do *not* mark this string for translation. */ + "Copyright (C) 2004 Free Software Foundation, Inc."; + + +/* Like version_etc, below, but with the NULL-terminated author list + provided via a variable of type va_list. */ +void +version_etc_va (FILE *stream, + const char *command_name, const char *package, + const char *version, va_list authors) +{ + size_t n_authors; + + /* Count the number of authors. */ + { + va_list tmp_authors; + +#ifdef __va_copy + __va_copy (tmp_authors, authors); +#else + tmp_authors = authors; +#endif + + n_authors = 0; + while (va_arg (tmp_authors, const char *) != NULL) + ++n_authors; + } + + if (command_name) + fprintf (stream, "%s (%s) %s\n", command_name, package, version); + else + fprintf (stream, "%s %s\n", package, version); + + switch (n_authors) + { + case 0: + /* The caller must provide at least one author name. */ + abort (); + case 1: + /* TRANSLATORS: %s denotes an author name. */ + vfprintf (stream, _("Written by %s.\n"), authors); + break; + case 2: + /* TRANSLATORS: Each %s denotes an author name. */ + vfprintf (stream, _("Written by %s and %s.\n"), authors); + break; + case 3: + /* TRANSLATORS: Each %s denotes an author name. */ + vfprintf (stream, _("Written by %s, %s, and %s.\n"), authors); + break; + case 4: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), authors); + break; + case 5: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), authors); + break; + case 6: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"), + authors); + break; + case 7: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"), + authors); + break; + case 8: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("\ +Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"), + authors); + break; + case 9: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("\ +Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"), + authors); + break; + default: + /* 10 or more authors. Use an abbreviation, since the human reader + will probably not want to read the entire list anyway. */ + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("\ +Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), + authors); + break; + } + va_end (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); +} + + +/* 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. + + The author names are passed as separate arguments, with an additional + NULL argument at the end. */ +void +version_etc (FILE *stream, + const char *command_name, const char *package, + const char *version, /* const char *author1, ...*/ ...) +{ + va_list authors; + + va_start (authors, version); + version_etc_va (stream, command_name, package, version, authors); +} diff --git a/lib/version-etc.h b/lib/version-etc.h new file mode 100644 index 000000000000..d505e75eae7d --- /dev/null +++ b/lib/version-etc.h @@ -0,0 +1,37 @@ +/* Utility to help print --version output in a consistent format. + Copyright (C) 1999, 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 + +# include +# include + +extern const char *version_etc_copyright; + +extern void version_etc_va (FILE *stream, + const char *command_name, const char *package, + const char *version, va_list authors); + +extern void version_etc (FILE *stream, + const char *command_name, const char *package, + const char *version, + /* const char *author1, ...*/ ...); + +#endif /* VERSION_ETC_H */ diff --git a/lib/xalloc-die.c b/lib/xalloc-die.c new file mode 100644 index 000000000000..ca3a689fa5c4 --- /dev/null +++ b/lib/xalloc-die.c @@ -0,0 +1,45 @@ +/* Report a memory allocation failure and exit. + + Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004 Free + Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "xalloc.h" + +#include + +#include "error.h" +#include "exitfail.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) +#define N_(msgid) msgid + +void +xalloc_die (void) +{ + error (exit_failure, 0, "%s", _("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 not return, call abort. Also, the abort is a + safety feature if exit_failure is 0 (which shouldn't happen). */ + abort (); +} diff --git a/lib/xalloc.h b/lib/xalloc.h new file mode 100644 index 000000000000..d81f2a676488 --- /dev/null +++ b/lib/xalloc.h @@ -0,0 +1,90 @@ +/* xalloc.h -- malloc with out-of-memory checking + + Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 1999, 2000, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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_ + +# include + + +# ifdef __cplusplus +extern "C" { +# 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 + +/* This function is always triggered when memory is exhausted. + It must be defined by the application, either explicitly + or by using gnulib's xalloc-die module. This is the + function to call when one wants the program to die because of a + memory allocation failure. */ +extern void xalloc_die (void) ATTRIBUTE_NORETURN; + +void *xmalloc (size_t s); +void *xnmalloc (size_t n, size_t s); +void *xzalloc (size_t s); +void *xcalloc (size_t n, size_t s); +void *xrealloc (void *p, size_t s); +void *xnrealloc (void *p, size_t n, size_t s); +void *x2realloc (void *p, size_t *pn); +void *x2nrealloc (void *p, size_t *pn, size_t s); +void *xclone (void const *p, size_t s); +char *xstrdup (const char *str); + +/* Return 1 if an array of N objects, each of size S, cannot exist due + to size arithmetic overflow. S must be positive and N must be + nonnegative. This is a macro, not an inline function, so that it + works correctly even when SIZE_MAX < N. + + By gnulib convention, SIZE_MAX represents overflow in size + calculations, so the conservative dividend to use here is + SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. + However, malloc (SIZE_MAX) fails on all known hosts where + sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for + exactly-SIZE_MAX allocations on such hosts; this avoids a test and + branch when S is known to be 1. */ +# define xalloc_oversized(n, s) \ + ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) + +/* These macros are deprecated; they will go away soon, and are retained + temporarily only to ease conversion to the functions described above. */ +# define CCLONE(p, n) xclone (p, (n) * sizeof *(p)) +# define CLONE(p) xclone (p, sizeof *(p)) +# define NEW(type, var) type *var = xmalloc (sizeof (type)) +# define XCALLOC(type, n) xcalloc (n, sizeof (type)) +# define XMALLOC(type, n) xnmalloc (n, sizeof (type)) +# define XREALLOC(p, type, n) xnrealloc (p, n, sizeof (type)) +# define XFREE(p) free (p) + + +# ifdef __cplusplus +} +# endif + + +#endif /* !XALLOC_H_ */ diff --git a/lib/xmalloc.c b/lib/xmalloc.c new file mode 100644 index 000000000000..9b7a948c2f18 --- /dev/null +++ b/lib/xmalloc.c @@ -0,0 +1,221 @@ +/* xmalloc.c -- malloc with out of memory checking + + Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "xalloc.h" + +#include +#include + +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + +/* Allocate an array of N objects, each with S bytes of memory, + dynamically, with error checking. S must be nonzero. */ + +static inline void * +xnmalloc_inline (size_t n, size_t s) +{ + void *p; + if (xalloc_oversized (n, s) || (! (p = malloc (n * s)) && n != 0)) + xalloc_die (); + return p; +} + +void * +xnmalloc (size_t n, size_t s) +{ + return xnmalloc_inline (n, s); +} + +/* Allocate N bytes of memory dynamically, with error checking. */ + +void * +xmalloc (size_t n) +{ + return xnmalloc_inline (n, 1); +} + +/* Change the size of an allocated block of memory P to an array of N + objects each of S bytes, with error checking. S must be nonzero. */ + +static inline void * +xnrealloc_inline (void *p, size_t n, size_t s) +{ + if (xalloc_oversized (n, s) || (! (p = realloc (p, n * s)) && n != 0)) + xalloc_die (); + return p; +} + +void * +xnrealloc (void *p, size_t n, size_t s) +{ + return xnrealloc_inline (p, n, s); +} + +/* Change the size of an allocated block of memory P to N bytes, + with error checking. */ + +void * +xrealloc (void *p, size_t n) +{ + return xnrealloc_inline (p, n, 1); +} + + +/* If P is null, allocate a block of at least *PN such objects; + otherwise, reallocate P so that it contains more than *PN objects + each of S bytes. *PN must be nonzero unless P is null, and S must + be nonzero. Set *PN to the new number of objects, and return the + pointer to the new block. *PN is never set to zero, and the + returned pointer is never null. + + Repeated reallocations are guaranteed to make progress, either by + allocating an initial block with a nonzero size, or by allocating a + larger block. + + In the following implementation, nonzero sizes are doubled so that + repeated reallocations have O(N log N) overall cost rather than + O(N**2) cost, but the specification for this function does not + guarantee that sizes are doubled. + + Here is an example of use: + + int *p = NULL; + size_t used = 0; + size_t allocated = 0; + + void + append_int (int value) + { + if (used == allocated) + p = x2nrealloc (p, &allocated, sizeof *p); + p[used++] = value; + } + + This causes x2nrealloc to allocate a block of some nonzero size the + first time it is called. + + To have finer-grained control over the initial size, set *PN to a + nonzero value before calling this function with P == NULL. For + example: + + int *p = NULL; + size_t used = 0; + size_t allocated = 0; + size_t allocated1 = 1000; + + void + append_int (int value) + { + if (used == allocated) + { + p = x2nrealloc (p, &allocated1, sizeof *p); + allocated = allocated1; + } + p[used++] = value; + } + + */ + +static inline void * +x2nrealloc_inline (void *p, size_t *pn, size_t s) +{ + size_t n = *pn; + + if (! p) + { + if (! n) + { + /* The approximate size to use for initial small allocation + requests, when the invoking code specifies an old size of + zero. 64 bytes is the largest "small" request for the + GNU C library malloc. */ + enum { DEFAULT_MXFAST = 64 }; + + n = DEFAULT_MXFAST / s; + n += !n; + } + } + else + { + if (SIZE_MAX / 2 / s < n) + xalloc_die (); + n *= 2; + } + + *pn = n; + return xrealloc (p, n * s); +} + +void * +x2nrealloc (void *p, size_t *pn, size_t s) +{ + return x2nrealloc_inline (p, pn, s); +} + +/* If P is null, allocate a block of at least *PN bytes; otherwise, + reallocate P so that it contains more than *PN bytes. *PN must be + nonzero unless P is null. Set *PN to the new block's size, and + return the pointer to the new block. *PN is never set to zero, and + the returned pointer is never null. */ + +void * +x2realloc (void *p, size_t *pn) +{ + return x2nrealloc_inline (p, pn, 1); +} + +/* Allocate S bytes of zeroed memory dynamically, with error checking. + There's no need for xnzalloc (N, S), since it would be equivalent + to xcalloc (N, S). */ + +void * +xzalloc (size_t s) +{ + return memset (xmalloc (s), 0, s); +} + +/* Allocate zeroed memory for N elements of S bytes, with error + checking. S must be nonzero. */ + +void * +xcalloc (size_t n, size_t s) +{ + void *p; + /* Test for overflow, since some calloc implementations don't have + proper overflow checks. */ + if (xalloc_oversized (n, s) || (! (p = calloc (n, s)) && n != 0)) + xalloc_die (); + return p; +} + +/* Clone an object P of size S, with error checking. There's no need + for xnclone (P, N, S), since xclone (P, N * S) works without any + need for an arithmetic overflow check. */ + +void * +xclone (void const *p, size_t s) +{ + return memcpy (xmalloc (s), p, s); +} diff --git a/lib/xmemcoll.c b/lib/xmemcoll.c new file mode 100644 index 000000000000..433d67f9c49e --- /dev/null +++ b/lib/xmemcoll.c @@ -0,0 +1,59 @@ +/* Locale-specific memory comparison. + Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 +#include + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +#include "error.h" +#include "exitfail.h" +#include "memcoll.h" +#include "quotearg.h" +#include "xmemcoll.h" + +/* 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 (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/lib/xmemcoll.h b/lib/xmemcoll.h new file mode 100644 index 000000000000..2f422e8c1c00 --- /dev/null +++ b/lib/xmemcoll.h @@ -0,0 +1,2 @@ +#include +int xmemcoll (char *, size_t, char *, size_t); diff --git a/lib/xstrtol.c b/lib/xstrtol.c new file mode 100644 index 000000000000..906e4a1cc1e9 --- /dev/null +++ b/lib/xstrtol.c @@ -0,0 +1,291 @@ +/* A more useful interface to strtol. + + Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004 Free + Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 +# define STRTOL_T_MINIMUM LONG_MIN +# define STRTOL_T_MAXIMUM LONG_MAX +#endif + +/* Some pre-ANSI implementations (e.g. SunOS 4) + need stderr defined if assertion checking is enabled. */ +#include + +#include +#include +#include +#include +#include +#include + +/* The extra casts work around common compiler bugs. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +#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))) + +#ifndef STRTOL_T_MINIMUM +# define STRTOL_T_MINIMUM TYPE_MINIMUM (__strtol_t) +# define STRTOL_T_MAXIMUM TYPE_MAXIMUM (__strtol_t) +#endif + +#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_STRTOIMAX && !defined strtoimax +intmax_t strtoimax (); +#endif + +#if !HAVE_DECL_STRTOUMAX && !defined strtoumax +uintmax_t strtoumax (); +#endif + +static strtol_error +bkm_scale (__strtol_t *x, int scale_factor) +{ + if (TYPE_SIGNED (__strtol_t) && *x < STRTOL_T_MINIMUM / scale_factor) + { + *x = STRTOL_T_MINIMUM; + return LONGINT_OVERFLOW; + } + if (STRTOL_T_MAXIMUM / scale_factor < *x) + { + *x = STRTOL_T_MAXIMUM; + return LONGINT_OVERFLOW; + } + *x *= scale_factor; + return LONGINT_OK; +} + +static strtol_error +bkm_scale_by_power (__strtol_t *x, int base, int power) +{ + strtol_error err = LONGINT_OK; + while (power--) + err |= bkm_scale (x, base); + return err; +} + +/* 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; + strtol_error err = LONGINT_OK; + + assert (0 <= strtol_base && strtol_base <= 36); + + p = (ptr ? ptr : &t_ptr); + + if (! TYPE_SIGNED (__strtol_t)) + { + const char *q = s; + unsigned char ch = *q; + while (ISSPACE (ch)) + ch = *++q; + if (ch == '-') + return LONGINT_INVALID; + } + + errno = 0; + tmp = __strtol (s, p, strtol_base); + + 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; + } + else if (errno != 0) + { + if (errno != ERANGE) + return LONGINT_INVALID; + err = LONGINT_OVERFLOW; + } + + /* 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 err; + } + + if (**p != '\0') + { + int base = 1024; + int suffixes = 1; + strtol_error overflow; + + if (!strchr (valid_suffixes, **p)) + { + *val = tmp; + return err | 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 err | LONGINT_INVALID_SUFFIX_CHAR; + } + + err |= overflow; + *p += suffixes; + if (**p) + err |= LONGINT_INVALID_SUFFIX_CHAR; + } + + *val = tmp; + return err; +} + +#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/lib/xstrtol.h b/lib/xstrtol.h new file mode 100644 index 000000000000..0d6b98482eff --- /dev/null +++ b/lib/xstrtol.h @@ -0,0 +1,89 @@ +/* A more useful interface to strtol. + + Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004 Free + Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 + +# include "exitfail.h" + +# if HAVE_INTTYPES_H +# include +# endif +# if HAVE_STDINT_H +# include +# endif + +# ifndef _STRTOL_ERROR +enum strtol_error + { + LONGINT_OK = 0, + + /* These two values can be ORed together, to indicate that both + errors occurred. */ + LONGINT_OVERFLOW = 1, + LONGINT_INVALID_SUFFIX_CHAR = 2, + + LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR + | LONGINT_OVERFLOW), + LONGINT_INVALID = 4 + }; +typedef enum strtol_error strtol_error; +# endif + +# define _DECLARE_XSTRTOL(name, type) \ + strtol_error name (const char *, char **, int, type *, const char *); +_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)) \ + { \ + default: \ + abort (); \ + \ + case LONGINT_INVALID: \ + error ((Exit_code), 0, "invalid %s `%s'", \ + (Argument_type_string), (Str)); \ + break; \ + \ + case LONGINT_INVALID_SUFFIX_CHAR: \ + case LONGINT_INVALID_SUFFIX_CHAR | LONGINT_OVERFLOW: \ + 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 (exit_failure, 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/lib/xstrtoul.c b/lib/xstrtoul.c new file mode 100644 index 000000000000..285f7b96f850 --- /dev/null +++ b/lib/xstrtoul.c @@ -0,0 +1,6 @@ +#define __strtol strtoul +#define __strtol_t unsigned long int +#define __xstrtol xstrtoul +#define STRTOL_T_MINIMUM 0 +#define STRTOL_T_MAXIMUM ULONG_MAX +#include "xstrtol.c" diff --git a/lib/xstrtoumax.c b/lib/xstrtoumax.c new file mode 100644 index 000000000000..8518ef077277 --- /dev/null +++ b/lib/xstrtoumax.c @@ -0,0 +1,33 @@ +/* xstrtoumax.c -- A more useful interface to strtoumax. + Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "xstrtol.h" + +#define __strtol strtoumax +#define __strtol_t uintmax_t +#define __xstrtol xstrtoumax +#ifdef UINTMAX_MAX +# define STRTOL_T_MINIMUM 0 +# define STRTOL_T_MAXIMUM UINTMAX_MAX +#endif +#include "xstrtol.c" diff --git a/man/sort.1 b/man/sort.1 new file mode 100644 index 000000000000..2bb445dd74e8 --- /dev/null +++ b/man/sort.1 @@ -0,0 +1,113 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33. +.TH SORT "1" "March 2004" "sort (coreutils) 5.2.1" "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-blank to blank 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; +without \fB\-c\fR, 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 2004 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 coreutils sort +.PP +should give you access to the complete manual. diff --git a/src/sort.c b/src/sort.c new file mode 100644 index 000000000000..014beb7c5368 --- /dev/null +++ b/src/sort.c @@ -0,0 +1,2554 @@ +/* sort - sort lines of text (with all kinds of options). + Copyright (C) 88, 1991-2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 "system.h" +#include "error.h" +#include "hard-locale.h" +#include "inttostr.h" +#include "long-options.h" +#include "physmem.h" +#include "posixver.h" +#include "quote.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 "Mike Haertel", "Paul Eggert" + +#if HAVE_LANGINFO_CODESET +# include +#endif + +#ifndef SA_NOCLDSTOP +# define sigprocmask(How, Set, Oset) /* empty */ +# define sigset_t int +#endif + +#ifndef STDC_HEADERS +double strtod (); +#endif + +#define UCHAR_LIM (UCHAR_MAX + 1) + +#ifndef DEFAULT_TMPDIR +# define DEFAULT_TMPDIR "/tmp" +#endif + +/* Exit statuses. */ +enum + { + /* POSIX says to exit with status 1 if invoked with -c and the + input is not properly sorted. */ + SORT_OUT_OF_ORDER = 1, + + /* POSIX says any other irregular exit must exit with a status + code greater than 1. */ + SORT_FAILURE = 2 + }; + +#define C_DECIMAL_POINT '.' +#define NEGATION_SIGN '-' +#define NUMERIC_ZERO '0' + +#if HAVE_SETLOCALE + +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 bool hard_LC_COLLATE; +# if HAVE_NL_LANGINFO +static bool hard_LC_TIME; +# endif + +# define IS_THOUSANDS_SEP(x) ((x) == th_sep) + +#else + +# define decimal_point C_DECIMAL_POINT +# define IS_THOUSANDS_SEP(x) false + +#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 char 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. */ + bool eof; /* An EOF has been read. */ +}; + +struct keyfield +{ + size_t sword; /* Zero-origin 'word' to start at. */ + size_t schar; /* Additional characters to skip. */ + size_t eword; /* Zero-origin first word after field. */ + size_t echar; /* Additional characters in field. */ + bool const *ignore; /* Boolean array of characters to ignore. */ + char const *translate; /* Translation applied to characters. */ + bool skipsblanks; /* Skip leading blanks when finding start. */ + bool skipeblanks; /* Skip leading blanks when finding end. */ + bool numeric; /* Flag for numeric comparison. Handle + strings of digits with optional decimal + point, but no exponential notation. */ + bool general_numeric; /* Flag for general, numeric comparison. + Handle numbers in exponential notation. */ + bool month; /* Flag for comparison by month name. */ + bool reverse; /* Reverse the sense of comparison. */ + struct keyfield *next; /* Next keyfield to try. */ +}; + +struct month +{ + char const *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. + 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 blanks. */ +static bool blanks[UCHAR_LIM]; + +/* Table of non-printing characters. */ +static bool nonprinting[UCHAR_LIM]; + +/* Table of non-dictionary characters (not letters, digits, or blanks). */ +static bool nondictionary[UCHAR_LIM]; + +/* Translation table folding lower case to upper. */ +static char fold_toupper[UCHAR_LIM]; + +#define MONTHS_PER_YEAR 12 + +/* Table mapping month names to integers. + Alphabetic order allows binary search. */ +static 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; + +/* Flag to reverse the order of all comparisons. */ +static bool 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 bool stable; + +/* If TAB has this value, blanks separate fields. */ +enum { TAB_DEFAULT = CHAR_MAX + 1 }; + +/* Tab character separating fields. If TAB_DEFAULT, then fields are + separated by the empty string between a non-blank character and a blank + character. */ +static int tab = TAB_DEFAULT; + +/* Flag to remove consecutive duplicate lines from the output. + Only the last of a sequence of equal lines will be output. */ +static bool unique; + +/* Nonzero if any of the input files are the standard input. */ +static bool have_read_stdin; + +/* List of key field comparisons to be tried. */ +static struct keyfield *keylist; + +static void sortlines_temp (struct line *, size_t, struct line *); + +void +usage (int status) +{ + if (status != EXIT_SUCCESS) + 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-blank to blank 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\ + without -c, 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 ); + printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + } + + 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 const *node; + + for (node = temphead; node; node = node->next) + unlink (node->name); +} + +/* Report MESSAGE for FILE, then clean up and exit. + If FILE is null, it represents standard output. */ + +static void die (char const *, char const *) ATTRIBUTE_NORETURN; +static void +die (char const *message, char const *file) +{ + error (0, errno, "%s: %s", message, file ? file : _("standard output")); + 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 = + 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; +} + +/* Return a stream for FILE, opened with mode HOW. A null FILE means + standard output; HOW should be "w". When opening for input, "-" + means standard input. To avoid confusion, do not return file + descriptors 0, 1, or 2. */ + +static FILE * +xfopen (const char *file, const char *how) +{ + FILE *fp; + + if (!file) + fp = stdout; + else if (STREQ (file, "-") && *how == 'r') + { + have_read_stdin = true; + fp = stdin; + } + 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_dirs = x2nrealloc (temp_dirs, &temp_dir_alloc, sizeof *temp_dirs); + + 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 (node); + break; + } +} + +#if HAVE_NL_LANGINFO + +static int +struct_month_cmp (const void *m1, const void *m2) +{ + struct month const *month1 = m1; + struct month const *month2 = m2; + return strcmp (month1->name, month2->name); +} + +#endif + +/* Initialize the character class tables. */ + +static void +inittables (void) +{ + int i; + + for (i = 0; i < UCHAR_LIM; ++i) + { + blanks[i] = !!ISBLANK (i); + nonprinting[i] = !ISPRINT (i); + nondictionary[i] = !ISALNUM (i) && !ISBLANK (i); + fold_toupper[i] = (ISLOWER (i) ? toupper (i) : i); + } + +#if 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 const *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 = xmalloc (s_len + 1); + monthtab[i].val = i + 1; + + for (j = 0; j < s_len; j++) + name[j] = fold_toupper[to_uchar (s[j])]; + name[j] = '\0'; + } + qsort ((void *) monthtab, MONTHS_PER_YEAR, + sizeof *monthtab, struct_month_cmp); + } +#endif +} + +/* 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) + { + /* If multiple sort sizes are specified, take the maximum, so + that option order does not matter. */ + if (n < sort_size) + return; + + 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. Do not exceed a bound on the size: if the bound is + not specified by the user, use a default. */ + +static size_t +sort_buffer_size (FILE *const *fps, int nfps, + char *const *files, int nfiles, + size_t line_bytes) +{ + /* A bound on the input size. If zero, the bound hasn't been + determined yet. */ + static 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) + : STREQ (files[i], "-") ? fstat (STDIN_FILENO, &st) + : stat (files[i], &st)) + != 0) + die (_("stat failed"), files[i]); + + if (S_ISREG (st.st_mode)) + file_size = st.st_size; + else + { + /* The file has unknown size. If the user specified a sort + buffer size, use that; otherwise, guess the size. */ + if (sort_size) + return sort_size; + file_size = INPUT_FILE_SIZE_GUESS; + } + + if (! size_bound) + { + size_bound = sort_size; + if (! size_bound) + size_bound = default_sort_size (); + } + + /* 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 = false; +} + +/* 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; + register size_t remaining_bytes; + + /* The leading field separator itself is included in a field when -t + is absent. */ + + if (tab != TAB_DEFAULT) + while (ptr < lim && sword--) + { + while (ptr < lim && *ptr != tab) + ++ptr; + if (ptr < lim) + ++ptr; + } + else + while (ptr < lim && sword--) + { + while (ptr < lim && blanks[to_uchar (*ptr)]) + ++ptr; + while (ptr < lim && !blanks[to_uchar (*ptr)]) + ++ptr; + } + + if (key->skipsblanks) + while (ptr < lim && blanks[to_uchar (*ptr)]) + ++ptr; + + /* Advance PTR by SCHAR (if possible), but no further than LIM. */ + remaining_bytes = lim - ptr; + if (schar < remaining_bytes) + 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; + register size_t remaining_bytes; + + /* 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 != TAB_DEFAULT) + 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[to_uchar (*ptr)]) + ++ptr; + while (ptr < lim && !blanks[to_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 + [Translated to POSIX 1003.1-2001 terminology by Paul Eggert.] + + [...]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 -k1.7,1.7 skipeblanks) + while (ptr < lim && blanks[to_uchar (*ptr)]) + ++ptr; + + /* Advance PTR by ECHAR (if possible), but no further than LIM. */ + remaining_bytes = lim - ptr; + if (echar < remaining_bytes) + ptr += echar; + else + ptr = lim; + + return ptr; +} + +/* 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 true if some input was read. */ + +static bool +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 false; + + 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 = true; + if (buf->buf == ptrlim) + return false; + 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 == SIZE_MAX + ? p + : limfield (line, key)); + + if (key->sword != SIZE_MAX) + line->keybeg = begfield (line, key); + else + { + if (key->skipsblanks) + while (blanks[to_uchar (*line_start)]) + line_start++; + line->keybeg = line_start; + } + } + + 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 true; + } + + /* The current input line is too long to fit in the buffer. + Double the buffer size and try again. */ + buf->buf = x2nrealloc (buf->buf, &buf->alloc, sizeof *(buf->buf)); + } +} + +/* 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) +{ + char tmpa; + char tmpb; + int tmp; + size_t log_a; + size_t log_b; + + tmpa = *a; + tmpb = *b; + + while (blanks[to_uchar (tmpa)]) + tmpa = *++a; + while (blanks[to_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 (log_a = 0; ISDIGIT (tmpa); ++log_a) + do + tmpa = *++a; + while (IS_THOUSANDS_SEP (tmpa)); + + for (log_b = 0; ISDIGIT (tmpb); ++log_b) + do + tmpb = *++b; + while (IS_THOUSANDS_SEP (tmpb)); + + if (log_a != log_b) + return log_a < log_b ? 1 : -1; + + if (!log_a) + 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 (log_a = 0; ISDIGIT (tmpa); ++log_a) + do + tmpa = *++a; + while (IS_THOUSANDS_SEP (tmpa)); + + for (log_b = 0; ISDIGIT (tmpb); ++log_b) + do + tmpb = *++b; + while (IS_THOUSANDS_SEP (tmpb)); + + if (log_a != log_b) + return log_a < log_b ? -1 : 1; + + if (!log_a) + 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[to_uchar (*s)]) + { + ++s; + --len; + } + + if (len == 0) + return 0; + + month = alloca (len + 1); + for (i = 0; i < len; ++i) + month[i] = fold_toupper[to_uchar (s[i])]; + month[len] = '\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 const *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 char const *translate = key->translate; + register bool const *ignore = key->ignore; + + /* Find the lengths. */ + size_t lena = lima <= texta ? 0 : lima - texta; + size_t lenb = limb <= textb ? 0 : limb - 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); + /* 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 (HAVE_SETLOCALE && hard_LC_COLLATE) + { + if (ignore || translate) + { + char *copy_a = 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[to_uchar (texta[i])] + : texta[i]); + if (!ignore || !ignore[to_uchar (texta[i])]) + ++new_len_a; + } + if (i < lenb) + { + copy_b[new_len_b] = (translate + ? translate[to_uchar (textb[i])] + : textb [i]); + if (!ignore || !ignore[to_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); + } + else if (ignore) + { +#define CMP_WITH_IGNORE(A, B) \ + do \ + { \ + for (;;) \ + { \ + while (texta < lima && ignore[to_uchar (*texta)]) \ + ++texta; \ + while (textb < limb && ignore[to_uchar (*textb)]) \ + ++textb; \ + if (! (texta < lima && textb < limb)) \ + break; \ + diff = to_uchar (A) - to_uchar (B); \ + if (diff) \ + goto not_equal; \ + ++texta; \ + ++textb; \ + } \ + \ + diff = (texta < lima) - (textb < limb); \ + } \ + while (0) + + if (translate) + CMP_WITH_IGNORE (translate[to_uchar (*texta)], + translate[to_uchar (*textb)]); + else + CMP_WITH_IGNORE (*texta, *textb); + } + else if (lena == 0) + diff = - NONZERO (lenb); + else if (lenb == 0) + goto greater; + else + { + if (translate) + { + while (texta < lima && textb < limb) + { + diff = (to_uchar (translate[to_uchar (*texta++)]) + - to_uchar (translate[to_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 != SIZE_MAX) + lima = limfield (a, key), limb = limfield (b, key); + else + lima = a->text + a->length - 1, limb = b->text + b->length - 1; + + if (key->sword != SIZE_MAX) + texta = begfield (a, key), textb = begfield (b, key); + else + { + texta = a->text, textb = b->text; + if (key->skipsblanks) + { + while (texta < lima && blanks[to_uchar (*texta)]) + ++texta; + while (textb < limb && blanks[to_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 | 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 = 1; + else if (HAVE_SETLOCALE && hard_LC_COLLATE) + diff = xmemcoll (a->text, alen, b->text, blen); + 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 FILE_NAME come in order. Print a + diagnostic (FILE_NAME, line number, contents of line) to stderr and return + false if they are not in order. Otherwise, print no diagnostic + and return true. */ + +static bool +check (char const *file_name) +{ + FILE *fp = xfopen (file_name, "r"); + struct buffer buf; /* Input buffer. */ + struct line temp; /* Copy of previous line. */ + size_t alloc = 0; + uintmax_t line_number = 0; + struct keyfield const *key = keylist; + bool nonunique = ! unique; + bool ordered = true; + + 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: + { + struct line const *disorder_line = line - 1; + uintmax_t disorder_line_number = + buffer_linelim (&buf) - disorder_line + line_number; + char hr_buf[INT_BUFSIZE_BOUND (uintmax_t)]; + fprintf (stderr, _("%s: %s:%s: disorder: "), + program_name, file_name, + umaxtostr (disorder_line_number, hr_buf)); + write_bytes (disorder_line->text, disorder_line->length, stderr, + _("standard error")); + ordered = false; + 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 ordered; +} + +/* 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 it is NULL, + the output file is standard output. If OFP is NULL, the output + file has not been opened yet (or written to, if standard output). */ + +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 const *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); +} + +/* Merge into T the two sorted arrays of lines LO (with NLO members) + and HI (with NHI members). T, LO, and HI point just past their + respective arrays, and the arrays are in reverse order. NLO and + NHI must be positive, and HI - NHI must equal T - (NLO + NHI). */ + +static inline void +mergelines (struct line *t, + struct line const *lo, size_t nlo, + struct line const *hi, size_t nhi) +{ + for (;;) + if (compare (lo - 1, hi - 1) <= 0) + { + *--t = *--lo; + if (! --nlo) + { + /* HI - NHI equalled T - (NLO + NHI) when this function + began. Therefore HI must equal T now, and there is no + need to copy from HI to T. */ + return; + } + } + else + { + *--t = *--hi; + if (! --nhi) + { + do + *--t = *--lo; + while (--nlo); + + return; + } + } +} + +/* Sort the array LINES with NLINES members, using TEMP for temporary space. + NLINES must be at least 2. + The input and output arrays are in reverse order, and LINES and + TEMP point just past the end of their respective arrays. + + Use a recursive divide-and-conquer algorithm, in the style + suggested by Knuth volume 3 (2nd edition), exercise 5.2.4-23. Use + the optimization suggested by exercise 5.2.4-10; this requires room + for only 1.5*N lines, rather than the usual 2*N lines. Knuth + writes that this memory optimization was originally published by + D. A. Bell, Comp J. 1 (1958), 75. */ + +static void +sortlines (struct line *lines, size_t nlines, struct line *temp) +{ + if (nlines == 2) + { + if (0 < compare (&lines[-1], &lines[-2])) + { + struct line tmp = lines[-1]; + lines[-1] = lines[-2]; + lines[-2] = tmp; + } + } + else + { + size_t nlo = nlines / 2; + size_t nhi = nlines - nlo; + struct line *lo = lines; + struct line *hi = lines - nlo; + struct line *sorted_lo = temp; + + sortlines (hi, nhi, temp); + if (1 < nlo) + sortlines_temp (lo, nlo, sorted_lo); + else + sorted_lo[-1] = lo[-1]; + + mergelines (lines, sorted_lo, nlo, hi, nhi); + } +} + +/* Like sortlines (LINES, NLINES, TEMP), except output into TEMP + rather than sorting in place. */ + +static void +sortlines_temp (struct line *lines, size_t nlines, struct line *temp) +{ + if (nlines == 2) + { + bool swap = (0 < compare (&lines[-1], &lines[-2])); + temp[-1] = lines[-1 - swap]; + temp[-2] = lines[-2 + swap]; + } + else + { + size_t nlo = nlines / 2; + size_t nhi = nlines - nlo; + struct line *lo = lines; + struct line *hi = lines - nlo; + struct line *sorted_hi = temp - nlo; + + sortlines_temp (hi, nhi, sorted_hi); + if (1 < nlo) + sortlines (lo, nlo, temp); + + mergelines (temp, lo, nlo, sorted_hi, nhi); + } +} + +/* Return the index of the first of NFILES FILES that is the same file + as OUTFILE. If none can be the same, return NFILES. + + This test ensures that an otherwise-erroneous use like + "sort -m -o FILE ... FILE ..." copies FILE before writing to it. + It's not clear that POSIX requires this nicety. + Detect common error cases, but don't try to catch obscure cases like + "cat ... FILE ... | sort -m -o FILE" + where traditional "sort" doesn't copy the input and where + people should know that they're getting into trouble anyway. + Catching these obscure cases would slow down performance in + common cases. */ + +static int +first_same_file (char * const *files, int nfiles, char const *outfile) +{ + int i; + bool got_outstat = false; + struct stat instat, outstat; + + for (i = 0; i < nfiles; i++) + { + bool standard_input = STREQ (files[i], "-"); + + if (outfile && STREQ (outfile, files[i]) && ! standard_input) + return i; + + if (! got_outstat) + { + got_outstat = true; + if ((outfile + ? stat (outfile, &outstat) + : fstat (STDOUT_FILENO, &outstat)) + != 0) + return nfiles; + } + + if (((standard_input + ? fstat (STDIN_FILENO, &instat) + : stat (files[i], &instat)) + == 0) + && SAME_INODE (instat, outstat)) + return i; + } + + return nfiles; +} + +/* Merge NFILES FILES onto OUTPUT_FILE. However, merge at most + MAX_MERGE input files directly onto OUTPUT_FILE. MAX_MERGE cannot + exceed NMERGE. A null OUTPUT_FILE stands for standard output. */ + +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 * const *files, int nfiles, char const *output_file) +{ + struct buffer buf; + int n_temp_files = 0; + bool output_file_created = false; + + buf.alloc = 0; + + while (nfiles) + { + char const *temp_output; + char const *file = *files; + FILE *fp = xfopen (file, "r"); + FILE *tfp; + size_t bytes_per_line = (2 * sizeof (struct line) + - sizeof (struct line) / 2); + + if (! buf.alloc) + initbuf (&buf, bytes_per_line, + sort_buffer_size (&fp, 1, files, nfiles, bytes_per_line)); + buf.eof = false; + files++; + nfiles--; + + while (fillbuf (&buf, fp, file)) + { + struct line *line; + struct line *linebase; + + if (buf.eof && nfiles + && (bytes_per_line + 1 + < (buf.alloc - buf.used - bytes_per_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; + if (1 < 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 = true; + } + 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 = xnmalloc (n_temp_files, sizeof *tempfiles); + for (node = temphead; i > 0; node = node->next) + tempfiles[--i] = node->name; + merge (tempfiles, n_temp_files, NMERGE, output_file); + free (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 (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: + case LONGINT_OVERFLOW | LONGINT_INVALID_SUFFIX_CHAR: + 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 (); + + signal (sig, SIG_DFL); + raise (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 = true; + if (blanktype == bl_end || blanktype == bl_both) + key->skipeblanks = true; + break; + case 'd': + key->ignore = nondictionary; + break; + case 'f': + key->translate = fold_toupper; + break; + case 'g': + key->general_numeric = true; + break; + case 'i': + /* Option order should not matter, so don't let -i override + -d. -d implies -i, but -i does not imply -d. */ + if (! key->ignore) + key->ignore = nonprinting; + break; + case 'M': + key->month = true; + break; + case 'n': + key->numeric = true; + break; + case 'r': + key->reverse = true; + break; + default: + return (char *) s; + } + ++s; + } + return (char *) s; +} + +static struct keyfield * +new_key (void) +{ + struct keyfield *key = xzalloc (sizeof *key); + key->eword = SIZE_MAX; + return key; +} + +int +main (int argc, char **argv) +{ + struct keyfield *key; + struct keyfield gkey; + char const *s; + int c = 0; + bool checkonly = false; + bool mergeonly = false; + int nfiles = 0; + bool posixly_correct = (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 = NULL; + + initialize_main (&argc, &argv); + program_name = argv[0]; + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + atexit (cleanup); + + initialize_exit_failure (SORT_FAILURE); + atexit (close_stdout); + + hard_LC_COLLATE = hard_locale (LC_COLLATE); +#if HAVE_NL_LANGINFO + hard_LC_TIME = hard_locale (LC_TIME); +#endif + +#if HAVE_SETLOCALE + /* Let's get locale's representation of the decimal point */ + { + struct lconv const *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 + + have_read_stdin = false; + inittables (); + + { + int i; + static int const sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM }; + enum { nsigs = sizeof sig / sizeof sig[0] }; + +#ifdef SA_NOCLDSTOP + struct sigaction act; + + sigemptyset (&caught_signals); + for (i = 0; i < nsigs; i++) + { + sigaction (sig[i], NULL, &act); + if (act.sa_handler != SIG_IGN) + sigaddset (&caught_signals, sig[i]); + } + + act.sa_handler = sighandler; + act.sa_mask = caught_signals; + act.sa_flags = 0; + + for (i = 0; i < nsigs; i++) + if (sigismember (&caught_signals, sig[i])) + sigaction (sig[i], &act, NULL); +#else + for (i = 0; i < nsigs; i++) + if (signal (sig[i], SIG_IGN) != SIG_IGN) + signal (sig[i], sighandler); +#endif + } + + gkey.sword = gkey.eword = SIZE_MAX; + gkey.ignore = NULL; + gkey.translate = NULL; + gkey.numeric = gkey.general_numeric = gkey.month = gkey.reverse = false; + gkey.skipsblanks = gkey.skipeblanks = false; + + files = xnmalloc (argc, sizeof *files); + + 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 + || (posixly_correct && 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 (argc <= optind) + 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 = SIZE_MAX; + 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 = true; + 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 = SIZE_MAX; + s = set_ordering (s, key, bl_start); + if (*s != ',') + { + key->eword = SIZE_MAX; + 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 = true; + break; + + case 'o': + if (outfile && !STREQ (outfile, optarg)) + error (SORT_FAILURE, 0, _("multiple output files specified")); + outfile = optarg; + break; + + case 's': + stable = true; + break; + + case 'S': + specify_sort_size (optarg); + break; + + case 't': + { + char newtab = optarg[0]; + if (! newtab) + error (SORT_FAILURE, 0, _("empty tab")); + if (optarg[1]) + { + if (STREQ (optarg, "\\0")) + newtab = '\0'; + else + { + /* 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); + } + } + if (tab != TAB_DEFAULT && tab != newtab) + error (SORT_FAILURE, 0, _("incompatible tabs")); + tab = newtab; + } + break; + + case 'T': + add_temp_dir (optarg); + break; + + case 'u': + unique = true; + 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 (0, 0, _("extra operand %s not allowed with -c"), + quote (files[1])); + usage (SORT_FAILURE); + } + + /* POSIX requires that sort return 1 IFF invoked with -c and the + input is not properly sorted. */ + exit (check (files[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/src/system.h b/src/system.h new file mode 100644 index 000000000000..3497969a4937 --- /dev/null +++ b/src/system.h @@ -0,0 +1,831 @@ +/* system-dependent definitions for fileutils, textutils, and sh-utils packages. + Copyright (C) 1989, 1991-2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 + +/* Include sys/types.h before this file. */ + +#if 2 <= __GLIBC__ && 2 <= __GLIBC_MINOR__ +# if ! defined _SYS_TYPES_H +you must include before including this file +# endif +#endif + +#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 + + +/* limits.h must come before pathmax.h because limits.h on some systems + undefs PATH_MAX, whereas pathmax.h sets PATH_MAX. */ +#include + +#include "pathmax.h" +#include "localedir.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 ! defined makedev && defined mkdev +# define makedev(maj, min) mkdev (maj, min) +#endif + +#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. */ + +#include +#if ! HAVE_DECL_MEMRCHR +void *memrchr (const void *, int, size_t); +#endif + +#include + +/* Some systems don't define the following symbols. */ +#ifndef ENOSYS +# define ENOSYS (-1) +#endif +#ifndef EISDIR +# define EISDIR (-1) +#endif + +#include + +#define getopt system_getopt +#include +#undef getopt + +/* 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 + +/* Exit statuses for programs like 'env' that exec other programs. + EXIT_FAILURE might not be 1, so use EXIT_FAIL in such programs. */ +enum +{ + EXIT_FAIL = 1, + EXIT_CANNOT_INVOKE = 126, + EXIT_ENOENT = 127 +}; + +#include "exitfail.h" + +/* Set exit_failure to STATUS if that's not the default already. */ +static inline void +initialize_exit_failure (int status) +{ + if (status != EXIT_FAILURE) + exit_failure = status; +} + +#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 + +#if !defined O_DIRECT +# define O_DIRECT 0 +#endif + +#if !defined O_DSYNC +# define O_DSYNC 0 +#endif + +#if !defined O_NDELAY +# define O_NDELAY 0 +#endif + +#if !defined O_NONBLOCK +# define O_NONBLOCK O_NDELAY +#endif + +#if !defined O_NOCTTY +# define O_NOCTTY 0 +#endif + +#if !defined O_NOFOLLOW +# define O_NOFOLLOW 0 +#endif + +#if !defined O_RSYNC +# define O_RSYNC 0 +#endif + +#if !defined O_SYNC +# define O_SYNC 0 +#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 +# ifndef O_BINARY +# define O_BINARY 0 +# endif +# 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) \ + ((statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 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. + Also, when running `rsh hpux11-system cat any-file', cat would + determine that the output stream had an st_blksize of 2147421096. + So here we arbitrarily limit the `optimal' block size to 4MB. + If anyone knows of a system for which the legitimate value for + st_blksize can exceed 4MB, please report it as a bug in this code. */ +# define ST_BLKSIZE(statbuf) ((0 < (statbuf).st_blksize \ + && (statbuf).st_blksize <= (1 << 22)) /* 4MB */ \ + ? (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 file systems 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) ((statbuf).st_blocks) +#endif + +#ifndef ST_NBLOCKSIZE +# define ST_NBLOCKSIZE 512 +#endif + +/* Redirection and wildcarding when done by the utility itself. + Generally a noop, but used in particular for native VMS. */ +#ifndef initialize_main +# define initialize_main(ac, av) +#endif + +#include "stat-macros.h" + +#include "timespec.h" + +#ifndef RETSIGTYPE +# define RETSIGTYPE void +#endif + +#ifdef __DJGPP__ + /* We need the declaration of setmode. */ +# include + /* We need the declaration of __djgpp_set_ctrl_c. */ +# include +#endif + +#if HAVE_INTTYPES_H +# include +#endif +#if HAVE_STDINT_H +# include +#endif + +#if ULONG_MAX < ULLONG_MAX +# define LONGEST_MODIFIER "ll" +#else +# define LONGEST_MODIFIER "l" +#endif +#if PRI_MACROS_BROKEN +# undef PRIdMAX +# undef PRIoMAX +# undef PRIuMAX +# undef PRIxMAX +#endif +#ifndef PRIdMAX +# define PRIdMAX LONGEST_MODIFIER "d" +#endif +#ifndef PRIoMAX +# define PRIoMAX LONGEST_MODIFIER "o" +#endif +#ifndef PRIuMAX +# define PRIuMAX LONGEST_MODIFIER "u" +#endif +#ifndef PRIxMAX +# define PRIxMAX LONGEST_MODIFIER "x" +#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 int) (c) - '0' <= 9) + +/* Convert a possibly-signed character to an unsigned character. This is + a bit safer than casting to unsigned char, since it catches some type + errors that the cast doesn't. */ +static inline unsigned char to_uchar (char ch) { return ch; } + +/* Take care of NLS matters. */ + +#if HAVE_LOCALE_H +# include +#else +# define setlocale(Category, Locale) /* empty */ +#endif + +#include "gettext.h" +#if ! ENABLE_NLS +# undef textdomain +# define textdomain(Domainname) /* empty */ +# undef bindtextdomain +# define bindtextdomain(Domainname, Dirname) /* empty */ +#endif + +#define _(msgid) gettext (msgid) +#define N_(msgid) msgid + +#ifndef HAVE_SETLOCALE +# define HAVE_SETLOCALE 0 +#endif + +#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 + +#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'))) + +/* A wrapper for readdir so that callers don't see entries for `.' or `..'. */ +static inline struct dirent const * +readdir_ignoring_dot_and_dotdot (DIR *dirp) +{ + while (1) + { + struct dirent const *dp = readdir (dirp); + if (dp == NULL || ! DOT_OR_DOTDOT (dp->d_name)) + return dp; + } +} + +#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, GNU_PACKAGE, VERSION, Authors, \ + (char *) NULL); \ + 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 + +/* 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 INT_MIN +# define INT_MIN TYPE_MINIMUM (int) +#endif + +#ifndef INTMAX_MAX +# define INTMAX_MAX TYPE_MAXIMUM (intmax_t) +#endif + +#ifndef INTMAX_MIN +# define INTMAX_MIN TYPE_MINIMUM (intmax_t) +#endif + +#ifndef UINT_MAX +# define UINT_MAX TYPE_MAXIMUM (unsigned int) +#endif + +#ifndef LONG_MAX +# define LONG_MAX TYPE_MAXIMUM (long int) +#endif + +#ifndef ULONG_MAX +# define ULONG_MAX TYPE_MAXIMUM (unsigned long int) +#endif + +#ifndef SIZE_MAX +# define SIZE_MAX TYPE_MAXIMUM (size_t) +#endif + +#ifndef SSIZE_MAX +# define SSIZE_MAX TYPE_MAXIMUM (ssize_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 + +/* 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_ = 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 int) (o) \ + ? fseek (s, o, w) \ + : (errno = EOVERFLOW, -1)) +#endif + +/* Compute the greatest common divisor of U and V using Euclid's + algorithm. U and V must be nonzero. */ + +static inline size_t +gcd (size_t u, size_t v) +{ + do + { + size_t t = u % v; + u = v; + v = t; + } + while (v); + + return u; +} + +/* Compute the least common multiple of U and V. U and V must be + nonzero. There is no overflow checking, so callers should not + specify outlandish sizes. */ + +static inline size_t +lcm (size_t u, size_t v) +{ + return u * (v / gcd (u, v)); +} + +/* Return PTR, aligned upward to the next multiple of ALIGNMENT. + ALIGNMENT must be nonzero. The caller must arrange for ((char *) + PTR) through ((char *) PTR + ALIGNMENT - 1) to be addressable + locations. */ + +static inline void * +ptr_align (void *ptr, size_t alignment) +{ + char *p0 = ptr; + char *p1 = p0 + alignment - 1; + return p1 - (size_t) p1 % alignment; +} -- cgit v1.2.3