summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2003-08-30 14:05:55 +0000
committerache <ache@FreeBSD.org>2003-08-30 14:05:55 +0000
commit910036be02c73b909b0758449a14b99212525529 (patch)
tree3fe4ecb5ab88f0a96f31b8c6b791d7e10df18c7e /contrib
parent0ec16ad8f3387117932b28e20a6db5928a4fde52 (diff)
downloadFreeBSD-src-910036be02c73b909b0758449a14b99212525529.zip
FreeBSD-src-910036be02c73b909b0758449a14b99212525529.tar.gz
Virgin import (trimmed) of GNU Sort, textutils 2.1
Diffstat (limited to 'contrib')
-rw-r--r--contrib/gnu-sort/ABOUT-NLS339
-rw-r--r--contrib/gnu-sort/ChangeLog169
-rw-r--r--contrib/gnu-sort/NEWS5
-rw-r--r--contrib/gnu-sort/README4
-rw-r--r--contrib/gnu-sort/THANKS15
-rw-r--r--contrib/gnu-sort/lib/getopt.c458
-rw-r--r--contrib/gnu-sort/lib/getopt.h121
-rw-r--r--contrib/gnu-sort/lib/getopt1.c46
-rw-r--r--contrib/gnu-sort/lib/gettext.h69
-rw-r--r--contrib/gnu-sort/lib/hard-locale.c62
-rw-r--r--contrib/gnu-sort/lib/xmalloc.c10
-rw-r--r--contrib/gnu-sort/man/sort.14
-rw-r--r--contrib/gnu-sort/src/sort.c51
-rw-r--r--contrib/gnu-sort/src/sys2.h160
-rw-r--r--contrib/gnu-sort/src/system.h20
15 files changed, 1122 insertions, 411 deletions
diff --git a/contrib/gnu-sort/ABOUT-NLS b/contrib/gnu-sort/ABOUT-NLS
index f083395..57e4b67 100644
--- a/contrib/gnu-sort/ABOUT-NLS
+++ b/contrib/gnu-sort/ABOUT-NLS
@@ -171,190 +171,229 @@ Available Packages
==================
Languages are not equally supported in all packages. The following
-matrix shows the current state of internationalization, as of January
+matrix shows the current state of internationalization, as of July
2002. The matrix shows, in regard of each package, for which languages
PO files have been submitted to translation coordination, with a
translation percentage of at least 50%.
- Ready PO files bg ca cs da de el en eo es et fi fr
- +-------------------------------------+
- a2ps | [] [] [] [] |
- bash | [] [] [] [] |
- bfd | [] [] |
- binutils | [] [] |
- bison | [] [] [] |
- clisp | [] [] [] [] |
- cpio | [] [] [] [] |
- diffutils | [] [] [] [] [] [] |
- enscript | [] [] |
- error | [] [] |
- fetchmail | () [] [] [] () |
- fileutils | [] [] [] [] [] |
- findutils | [] [] [] [] [] |
- flex | [] [] [] |
- gas | [] |
- gawk | [] [] |
- gcal | [] [] |
- gcc | [] [] |
- gettext | [] [] [] [] [] |
- gnupg | [] [] [] [] [] [] |
- gprof | [] [] |
- grep | [] [] [] [] [] [] |
- hello | [] [] [] [] [] [] [] [] |
- id-utils | [] [] [] |
- indent | [] [] [] [] |
- jpilot | () [] [] [] |
- jwhois | [] [] |
- kbd | [] |
- ld | [] [] |
- libc | [] [] [] [] [] [] [] |
- lilypond | [] [] |
- lynx | [] [] [] [] |
- m4 | [] [] [] [] [] |
- make | [] [] [] [] |
- mysecretdiary | [] [] |
- nano | [] () [] [] [] [] |
- nano_1_0 | [] () [] [] [] [] |
- opcodes | [] [] [] |
- parted | [] [] [] [] |
- ptx | [] [] [] [] [] |
- python | |
- recode | [] [] [] [] [] [] |
- sed | [] [] [] [] [] [] [] [] |
- sh-utils | [] [] [] [] [] [] [] [] |
- sharutils | [] [] [] [] [] [] |
- sketch | () [] () |
- soundtracker | [] [] [] |
- sp | |
- tar | [] [] [] [] [] [] |
- texinfo | [] [] [] [] [] |
- textutils | [] [] [] [] |
- util-linux | [] [] [] [] |
- wdiff | [] [] [] [] [] |
- wget | [] [] [] [] [] [] [] [] |
- +-------------------------------------+
- bg ca cs da de el en eo es et fi fr
- 0 8 12 31 36 9 1 9 37 15 1 49
+ Ready PO files be bg ca cs da de el en eo es et fi fr
+ +----------------------------------------+
+ a2ps | [] [] [] [] |
+ bash | [] [] [] [] |
+ bfd | [] [] |
+ binutils | [] [] |
+ bison | [] [] [] [] |
+ clisp | [] [] [] [] |
+ clisp | |
+ clisplow | |
+ cpio | [] [] [] [] |
+ darkstat | () |
+ diffutils | [] [] [] [] [] [] |
+ enscript | [] [] |
+ error | [] [] [] |
+ fetchmail | [] () [] [] [] () |
+ fileutils | [] [] [] [] [] |
+ findutils | [] [] [] [] [] [] |
+ flex | [] [] [] [] [] |
+ gas | [] [] |
+ gawk | [] [] [] |
+ gcal | [] [] |
+ gcc | [] [] |
+ gettext | [] [] [] [] [] |
+ gnupg | [] [] [] [] [] [] [] |
+ gprof | [] [] |
+ gpsdrive | () () () () () |
+ grep | [] [] [] [] [] [] [] |
+ gretl | [] |
+ gthumb | () () () |
+ hello | [] [] [] [] [] [] [] [] [] |
+ id-utils | [] [] [] |
+ indent | [] [] [] [] [] |
+ jpilot | () [] [] [] |
+ jwhois | [] [] |
+ kbd | [] [] [] |
+ ld | [] [] |
+ libc | [] [] [] [] [] [] [] |
+ libiconv | [] [] [] [] |
+ lifelines | () () |
+ lilypond | [] [] [] |
+ lingoteach | [] [] |
+ lingoteach_lessons| () () |
+ lynx | [] [] [] [] [] |
+ m4 | [] [] [] [] [] |
+ make | [] [] [] [] |
+ man-db | [] () () [] () () |
+ mysecretdiary | [] [] [] |
+ nano | [] () [] [] [] [] |
+ nano_1_0 | [] () [] [] [] [] |
+ opcodes | [] [] [] |
+ parted | [] [] [] [] [] |
+ ptx | [] [] [] [] [] [] [] |
+ python | |
+ recode | [] [] [] [] [] [] |
+ sed | [] [] [] [] [] [] [] [] [] |
+ sh-utils | [] [] [] [] |
+ sharutils | [] [] [] [] [] [] |
+ sketch | () [] () |
+ soundtracker | [] [] [] |
+ sp | [] |
+ tar | [] [] [] [] [] [] |
+ texinfo | [] [] [] [] [] |
+ textutils | [] [] [] [] [] |
+ util-linux | [] [] [] [] [] [] |
+ vorbis-tools | [] |
+ wastesedge | |
+ wdiff | [] [] [] [] [] [] |
+ wget | [] [] [] [] [] [] [] [] [] [] |
+ +----------------------------------------+
+ be bg ca cs da de el en eo es et fi fr
+ 0 2 19 10 30 44 9 1 12 45 16 3 53
gl he hr hu id it ja ko lv nb nl nn
+-------------------------------------+
a2ps | () () [] |
- bash | |
+ bash | [] |
bfd | [] |
binutils | [] |
- bison | [] |
+ bison | [] [] [] [] |
clisp | [] |
- cpio | [] [] [] |
- diffutils | [] [] |
- enscript | [] |
+ clisp | |
+ clisplow | |
+ cpio | [] [] [] [] |
+ darkstat | () |
+ diffutils | [] [] [] [] [] |
+ enscript | [] [] |
error | [] |
- fetchmail | |
- fileutils | [] [] |
- findutils | [] [] [] [] [] [] |
+ fetchmail | [] |
+ fileutils | [] [] [] |
+ findutils | [] [] [] [] [] [] [] [] |
flex | [] |
gas | |
gawk | [] |
gcal | |
gcc | [] |
- gettext | [] |
- gnupg | [] [] [] |
+ gettext | [] [] |
+ gnupg | [] [] [] [] |
gprof | |
- grep | [] [] |
- hello | [] [] [] [] [] [] [] [] [] |
- id-utils | [] |
- indent | [] [] [] |
+ gpsdrive | [] () () |
+ grep | [] [] [] [] [] [] [] |
+ gretl | |
+ gthumb | () () |
+ hello | [] [] [] [] [] [] [] [] [] [] [] [] |
+ id-utils | [] [] |
+ indent | [] [] [] [] |
jpilot | () () |
- jwhois | |
+ jwhois | [] [] |
kbd | |
ld | |
libc | [] [] [] [] |
+ libiconv | [] [] [] |
+ lifelines | |
lilypond | [] [] |
- lynx | [] [] |
+ lingoteach | [] |
+ lingoteach_lessons| |
+ lynx | [] [] [] [] |
m4 | [] [] [] [] |
- make | [] [] [] [] |
- mysecretdiary | |
- nano | [] [] [] () () [] |
- nano_1_0 | [] [] [] () () [] |
- opcodes | |
+ make | [] [] [] [] [] [] |
+ man-db | () () |
+ mysecretdiary | [] |
+ nano | [] [] [] [] [] [] |
+ nano_1_0 | [] [] [] [] [] |
+ opcodes | [] [] |
parted | [] [] [] |
- ptx | [] [] [] [] |
+ ptx | [] [] [] [] [] |
python | |
recode | [] [] [] |
- sed | [] [] [] [] [] [] [] |
- sh-utils | [] [] [] [] [] |
+ sed | [] [] [] [] [] [] [] [] |
+ sh-utils | [] [] [] |
sharutils | [] [] [] |
sketch | () |
- soundtracker | [] |
+ soundtracker | [] [] |
sp | |
- tar | [] [] [] |
+ tar | [] [] [] [] [] |
texinfo | [] [] [] |
- textutils | [] [] |
+ textutils | [] [] [] |
util-linux | () [] |
- wdiff | |
- wget | [] [] [] [] [] |
+ vorbis-tools | |
+ wastesedge | |
+ wdiff | [] [] [] |
+ wget | [] [] [] [] [] [] |
+-------------------------------------+
gl he hr hu id it ja ko lv nb nl nn
- 20 6 1 3 6 11 22 9 1 6 17 4
+ 23 9 12 18 14 13 26 9 1 8 19 4
- no pl pt pt_BR ru sk sl sv tr uk zh
- +-------------------------------------+
- a2ps | () () () [] [] [] () | 8
- bash | | 4
- bfd | [] [] | 5
- binutils | [] | 4
- bison | [] [] [] | 7
- clisp | | 5
- cpio | [] [] [] [] | 11
- diffutils | [] [] [] | 11
- enscript | [] [] [] | 6
- error | [] [] | 5
- fetchmail | () () | 3
- fileutils | [] [] [] [] | 11
- findutils | [] [] [] [] [] [] | 17
- flex | [] [] | 6
- gas | [] | 2
- gawk | [] [] | 5
- gcal | [] | 3
- gcc | [] | 4
- gettext | [] [] [] [] | 10
- gnupg | [] [] [] | 12
- gprof | [] [] | 4
- grep | [] [] [] [] [] | 13
- hello | [] [] [] [] [] [] [] | 24
- id-utils | [] [] | 6
- indent | [] [] [] [] | 11
- jpilot | () () | 3
- jwhois | () () | 2
- kbd | [] [] | 3
- ld | [] [] | 4
- libc | [] [] [] [] [] [] | 17
- lilypond | [] | 5
- lynx | [] [] [] | 9
- m4 | [] [] [] | 12
- make | [] [] [] [] | 12
- mysecretdiary | [] | 3
- nano | () [] [] [] | 12
- nano_1_0 | () [] [] [] | 12
- opcodes | [] [] | 5
- parted | [] [] [] | 10
- ptx | [] [] [] [] [] [] | 15
- python | | 0
- recode | [] [] [] [] | 13
- sed | [] [] [] [] [] [] | 21
- sh-utils | [] [] [] [] [] [] [] [] [] | 22
- sharutils | [] [] | 11
- sketch | () | 1
- soundtracker | | 4
- sp | | 0
- tar | [] [] [] [] [] [] [] | 16
- texinfo | [] [] | 10
- textutils | [] [] | 8
- util-linux | [] [] [] | 8
- wdiff | [] [] [] [] | 9
- wget | [] [] [] [] [] [] | 19
- +-------------------------------------+
- 35 teams no pl pt pt_BR ru sk sl sv tr uk zh
- 54 domains 5 12 2 11 25 10 11 39 29 4 1 463
+ no pl pt pt_BR ru sk sl sv tr uk zh_TW
+ +----------------------------------------+
+ a2ps | () () () [] [] [] [] [] | 10
+ bash | [] | 6
+ bfd | [] [] | 5
+ binutils | [] [] | 5
+ bison | [] [] [] | 11
+ clisp | | 5
+ clisp | | 0
+ clisplow | | 0
+ cpio | [] [] [] [] | 12
+ darkstat | [] () | 1
+ diffutils | [] [] [] [] [] [] | 17
+ enscript | [] [] [] [] | 8
+ error | [] [] [] | 7
+ fetchmail | () () [] | 6
+ fileutils | [] [] [] [] [] | 13
+ findutils | [] [] [] [] [] [] [] | 21
+ flex | [] [] [] | 9
+ gas | [] | 3
+ gawk | [] [] | 6
+ gcal | [] [] | 4
+ gcc | [] | 4
+ gettext | [] [] [] [] [] [] | 13
+ gnupg | [] [] [] | 14
+ gprof | [] [] | 4
+ gpsdrive | [] [] () | 3
+ grep | [] [] [] [] | 18
+ gretl | | 1
+ gthumb | () () [] | 1
+ hello | [] [] [] [] [] [] [] | 28
+ id-utils | [] [] [] [] | 9
+ indent | [] [] [] [] [] | 14
+ jpilot | () () [] | 4
+ jwhois | [] () () [] [] | 7
+ kbd | [] [] | 5
+ ld | [] [] | 4
+ libc | [] [] [] [] [] [] | 17
+ libiconv | [] [] [] [] | 11
+ lifelines | [] | 1
+ lilypond | [] | 6
+ lingoteach | [] [] | 5
+ lingoteach_lessons| | 0
+ lynx | [] [] [] [] | 13
+ m4 | [] [] [] | 12
+ make | [] [] [] [] | 14
+ man-db | | 3
+ mysecretdiary | [] [] [] | 7
+ nano | [] [] [] [] | 15
+ nano_1_0 | [] [] [] [] | 14
+ opcodes | [] [] | 7
+ parted | [] [] [] | 11
+ ptx | [] [] [] [] [] [] [] | 19
+ python | | 0
+ recode | [] [] [] [] [] [] | 15
+ sed | [] [] [] [] [] [] | 23
+ sh-utils | [] | 8
+ sharutils | [] [] [] [] | 13
+ sketch | [] () [] | 4
+ soundtracker | [] | 6
+ sp | | 1
+ tar | [] [] [] [] [] [] [] | 18
+ texinfo | [] [] | 10
+ textutils | [] [] [] [] [] | 13
+ util-linux | [] [] [] | 10
+ vorbis-tools | [] | 2
+ wastesedge | | 0
+ wdiff | [] [] [] [] [] | 14
+ wget | [] [] [] [] [] [] [] [] | 24
+ +----------------------------------------+
+ 36 teams no pl pt pt_BR ru sk sl sv tr uk zh_TW
+ 67 domains 4 15 2 24 26 12 10 47 42 4 8 594
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
@@ -367,7 +406,7 @@ distributed as such by its maintainer. There might be an observable
lag between the mere existence a PO file and its wide availability in a
distribution.
- If January 2002 seems to be old, you may fetch a more recent copy of
+ If July 2002 seems to be old, you may fetch a more recent copy of
this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date
matrix with full percentage details can be found at
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
diff --git a/contrib/gnu-sort/ChangeLog b/contrib/gnu-sort/ChangeLog
index 87e22a2..bc43c75 100644
--- a/contrib/gnu-sort/ChangeLog
+++ b/contrib/gnu-sort/ChangeLog
@@ -1,3 +1,172 @@
+2002-07-29 Jim Meyering <meyering@lucent.com>
+
+ * Version 2.1.
+
+ * src/tail.c: Adjust command examples in comments to use
+ POSIX 1003.1-2001 option syntax.
+ * src/sort.c: Likewise.
+ From Paul Eggert.
+
+2002-07-28 Jim Meyering <meyering@lucent.com>
+
+ * configure.ac: Require automake-1.6b.
+
+2002-07-20 Jim Meyering <meyering@lucent.com>
+
+ * Version 2.0.22.
+
+ * Upgrade to cvs automake -- required to work with 2.53b.
+ * configure.ac: Require automake-1.6a.
+
+ * Upgrade to gettext-0.11.3.
+ * Upgrade to autoconf-2.53b.
+
+2002-07-02 Jim Meyering <meyering@lucent.com>
+
+ * src/cat.c, src/cksum.c, src/comm.c, src/csplit.c, src/cut.c (usage):
+ Use the PACKAGE_BUGREPORT e-mail address, rather than hard-coding it.
+ * src/expand.c, src/fmt.c, src/fold.c, src/head.c, src/join.c: Likewise.
+ * src/md5sum.c, src/nl.c, src/od.c, src/paste.c, src/pr.c: Likewise.
+ * src/sort.c, src/split.c, src/sum.c, src/tac.c, src/tail.c: Likewise.
+ * src/tr.c, src/tsort.c, src/unexpand.c, src/uniq.c, src/wc.c: Likewise.
+
+2002-06-22 Jim Meyering <meyering@lucent.com>
+
+ * configure.ac: Invoke AC_GNU_SOURCE very early.
+
+2002-06-15 Jim Meyering <meyering@lucent.com>
+
+ * src/cksum.c: Include <sys/types.h> before system.h.
+
+2002-05-22 Jim Meyering <meyering@lucent.com>
+
+ * src/od.c [struct dummy]: Renamed. Don't rely on portability of
+ zero-length arrays. Instead, use sizes of -1 or +1.
+ Reported by Eric Backus.
+
+2002-05-14 Jim Meyering <meyering@lucent.com>
+
+ `od -t f8' didn't work.
+ This bug was introduced with my change of 2000-10-22 (textutils-2.0.8).
+ * src/od.c (ulonglong_t): Move declaration to precede new use.
+ [enum size_spec] (N_SIZE_SPECS): New member.
+ (width_bytes): Add initializer corresponding to ulonglong_t type.
+ (struct assert_width_bytes_matches_size_spec_decl): Declare.
+ Based on a patch from Tony Kocurko.
+
+2002-04-29 Paul Eggert <eggert@twinsun.com>
+
+ Use ENABLE_NLS only for gettext-related stuff, not also for
+ setlocale-related stuff. From a patch suggested by Bruno
+ Haible.
+
+ Since setlocale is now almost universal, this patch also
+ removes some of the optimizations that clutter up the code and
+ which don't help all that much even on hosts that lack
+ setlocale.
+
+ * lib/hard-locale.c: Upgrade to version used in GNU Diffutils 2.8.1.
+ * m4/prereq.m4 (jm_PREREQ_HARD_LOCALE): Check for stdlib.h.
+ Do not check for alloca.h (no longer used) or stdbool.h (was never
+ used?). Add AM_C_PROTOTYPES since hard-locale.h uses it.
+
+ * src/sys2.h (HAVE_SETLOCALE): Define to 0 if not defined.
+ * src/comm.c (compare_files): Replace #ifdef ENABLE_NLS
+ with if (HAVE_SETLOCALE).
+ * src/join.c (keycmp): Likewise.
+ * src/sort.c (keycompare, compare): Likewise.
+
+ * src/comm.c (hard_LC_COLLATE): Define even if ! ENABLE_NLS.
+ * src/join.c (hard_LC_COLLATE): Likewise.
+ * src/sort.c (hard_LC_COLLATE): Likewise.
+
+ * src/comm.c (main): Always initialize hard_LC_COLLATE.
+ Put initialization next to other locale-related stuff.
+ * src/join.c (main): Likewise.
+ * src/sort.c (main): Likewise.
+
+ * src/sort.c: Include <langinfo.h> even if ! ENABLE_NLS.
+ (decimal_point, th_sep): Depend on HAVE_SETLOCALE, not ENABLE_NLS.
+ (main): Likewise.
+ (MONTHTAB_CONST): Remove; all uses removed.
+ (struct_month_cmp, inittables): Do not depend on ENABLE_NLS.
+ (main): hard_LC_TIME locale does not depend on ENABLE_NLS.
+
+2002-04-29 Jim Meyering <meyering@lucent.com>
+
+ * src/tail.c (parse_obsolescent_option): Do not limit the maximum
+ line/byte count (when specified via obsolete option syntax) to be
+ less than ULONG_MAX on systems where OFF_T_MAX is larger.
+
+2002-04-28 Paul Eggert <eggert@twinsun.com>
+
+ * src/tail.c (tail_forever): Do not treat
+ max_n_unchanged_stats_between_opens specially (as if it were
+ infinite) if it has its maximal value. Similarly for
+ max_n_consecutive_size_changes_between_opens.
+
+2002-04-28 Jim Meyering <meyering@lucent.com>
+
+ Avoid new warnings from gcc.
+ * src/pr.c [struct COLUMN] <name>: Declare member to be const.
+ (init_fps): Declare local variable `firstname' to be const.
+
+2002-04-25 Jim Meyering <meyering@lucent.com>
+
+ * src/wc.c (usage): Adjust ordering to match that of default output.
+ Suggestion from Gaute Hvoslef Kvalnes.
+
+ * configure.ac (AM_GNU_GETTEXT): Add external arg.
+ (AC_CONFIG_FILES): Remove intl/Makefile.
+ * Makefile.am (SUBDIRS): Remove intl.
+ * src/Makefile.am (INCLUDES): Remove -I../intl.
+
+2002-04-15 Jim Meyering <meyering@lucent.com>
+
+ * src/tr.c (usage): Give a verbose description of --squeeze-repeats,
+ including the mention of SET1. Reported by Dan Jacobson.
+
+2002-04-12 Jim Meyering <meyering@lucent.com>
+
+ * src/Makefile.am (LDADD): List ../lib/libfetish.a both before
+ and after @LIBINTL@. Thanks to Paul Eggert for the fix and to
+ Bruno Haible for diagnosing the problem.
+
+2002-03-16 Jim Meyering <meyering@lucent.com>
+
+ * src/Makefile.am (datadir): Don't override $(datadir)
+ which might be set by --datadir and different from $(prefix)/share.
+ Patch from Albert Chin-A-Young.
+
+2002-03-10 Jim Meyering <meyering@lucent.com>
+
+ * configure.ac (AM_INIT_AUTOMAKE): Specify the required version
+ of automake (1.6), and options (gnits dist-bzip2), rather than...
+ * Makefile.am (AUTOMAKE_OPTIONS): ...here. Remove definition.
+
+2002-03-09 Jim Meyering <meyering@lucent.com>
+
+ * Makefile.am (EXTRA_DIST): Remove config/config.rpath,
+ now that automake knows about it.
+
+2002-03-05 Jim Meyering <meyering@lucent.com>
+
+ * Makefile.am (EXTRA_DIST): Add config/config.rpath.
+
+2002-02-23 Paul Eggert <eggert@twinsun.com>
+
+ * src/cat.c (simple_cat, cat, main): Use char * rather than
+ unsigned char *, to avoid some technical violations of the C
+ standard, and to avoid the need for casts. I guess the
+ unsigned char * was probably there for improved performance
+ with ancient compilers, but the code wasn't using the
+ unsignedness any more.
+ Reported by Nelson H. F. Beebe.
+
+ (cat): int -> size_t for full_write arg. This doesn't
+ fix any bugs since the buffer size is small, but it makes
+ the code a bit clearer.
+
2002-02-18 Jim Meyering <meyering@lucent.com>
* Version 2.0.21.
diff --git a/contrib/gnu-sort/NEWS b/contrib/gnu-sort/NEWS
index fab6754..a172299 100644
--- a/contrib/gnu-sort/NEWS
+++ b/contrib/gnu-sort/NEWS
@@ -1,4 +1,8 @@
Changes in release 2.1
+[2.0.22]
+* `od -t f8' works once again [bug introduced in textutils-2.0.8]
+* various portability fixes, and general clean-up
+* various minor, corner-case bug fixes
[2.0.21]
* split accepts new option -a or --suffix-length.
* split no longer generates longer suffixes than requested; instead, it reports
@@ -142,6 +146,7 @@ Changes in release 2.1
so e.g., `tail -fn 2 file' works again.
* tail no longer refuses to operate on certain types of files
* fixed bug in tsort's handling of cycles
+
Changes in release 2.0
[1.22q]
* HPUX portability fix: md5sum would dump core due to use of libc's getline
diff --git a/contrib/gnu-sort/README b/contrib/gnu-sort/README
index 48e7bec..e2fb18e 100644
--- a/contrib/gnu-sort/README
+++ b/contrib/gnu-sort/README
@@ -4,8 +4,8 @@ their Unix counterparts, such as greater speed, additional options,
and fewer arbitrary limits.
The programs that can be built with this package are: cat, cksum, comm,
-csplit, cut, expand, fmt, fold, head, join, md5sum, nl, od, paste, pr,
-ptx, sort, split, sum, tac, tail, tr, tsort, unexpand, uniq, and wc.
+csplit, cut, expand, fmt, fold, head, join, md5sum, nl, od, paste, pr, ptx
+sha1sum, sort, split, sum, tac, tail, tr, tsort, unexpand, uniq, and wc.
See the file NEWS for a list of major changes in the current release.
diff --git a/contrib/gnu-sort/THANKS b/contrib/gnu-sort/THANKS
index 08e0186..25dfff8 100644
--- a/contrib/gnu-sort/THANKS
+++ b/contrib/gnu-sort/THANKS
@@ -11,12 +11,15 @@ 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
+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
@@ -76,6 +79,7 @@ Dan Hagerty hag@gnu.ai.it.edu
Dan Pascu dan@services.iiruc.ro
Daniel Bergstrom noa@melody.se
Darren Salt ds@youmustbejoking.demon.co.uk
+Dave Beckett dajobe@dajobe.org
David Dyck dcd@tc.fluke.COM
David Godfrey dave@delta.demon.co.uk
David Luyer david_luyer@pacific.net.au
@@ -113,6 +117,7 @@ Frédéric L. W. Meunier 0@pervalidus.net
Gabor Z. Papp gzp@gzp.org.hu
Galen Hazelwood galenh@micron.net
Gary Anderson ganderson@clark.net
+Gaute Hvoslef Kvalnes gaute@verdsveven.com
Gaël Quéri gqueri@mail.dotcom.fr
Geoff Kuenning geoff@cs.hmc.edu
Geoff Odhner geoff@franklin.com
@@ -137,6 +142,7 @@ 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
James james@albion.glarp.com
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
James Sneeringer jvs@ocslink.com
@@ -203,6 +209,7 @@ Manfred Hollstein manfred@s-direktnet.de
Marc Boucher marc@mbsi.ca
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 D. Roth roth@uiuc.edu
@@ -216,6 +223,7 @@ Markus Demleitner msdemlei@auriga.ari.uni-heidelberg.de
Martin martin@dresden.nacamar.de
Martin Gallant martyg@goodbit.net
Martin Hippe martin.hippe@schlund.de
+Martin Michlmayr tbm@cyrius.com
Martin Mitchell martin@debian.org
Martin P.J. Zinser zinser@decus.de
Marty Leisner leisner@sdsp.mc.xerox.com
@@ -224,6 +232,7 @@ Mate Wierdl mw@moni.msci.memphis.edu
Matej Vela mvela@public.srce.hr
Matt Perry matt@primefactor.com
Matt Schalit mschalit@pacbell.net
+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
@@ -238,12 +247,14 @@ Michael Gaughen mgaughen@polyserve.com
Michael Hasselberg mikelh@zonta.ping.de
Michael Hohn hohn@math.utah.edu
Michael J. Croghan mcroghan@usatoday.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 Veksler mveksler@techunix.technion.ac.il
Michel Robitaille robitail@IRO.UMontreal.CA
Michiel Bacchiani bacchian@raven.bu.edu
+Mike Castle dalgoda@ix.netcom.com
Miles Bader miles@gnu.ai.mit.edu
Minh Tran-Le tranle@intellicorp.com
Morten Welinder terra@diku.dk
@@ -308,14 +319,17 @@ Stephen Smoogen ??????????
Steve McConnel steve@acadcomp.sil.org
Stuart Kemp skemp@peter.bmc.com
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 Quinot thomas@Cuivre.FR.EU.ORG
+Tim J. Robbins tjr@FreeBSD.org
Tim Smithers mouse@dmouse.com.au
Tim Waugh twaugh@redhat
Todd A. Jacobs tjacobs@codegnome.org
Tom Quinn trq@dionysos.thphys.ox.ac.uk
Ton Hospel thospel@mail.dma.be
+Tony Kocurko akocurko@mun.ca
Tony Leneis tony@plaza.ds.adp.com
Tony Robinson ajr@eng.cam.ac.uk
Torbjorn Granlund tege@nada.kth.se
@@ -335,6 +349,7 @@ Will Edgington wedgingt@acm.org
William Bader william@nscs.fast.net
William Dowling will@franklin.com
William Lewis wiml@omnigroup.com
+Wojciech Purczynski cliph@isec.pl
Wolfram Kleff kleff@cs.uni-bonn.de
Won-kyu Park wkpark@chem.skku.ac.kr
Zvi Har'El rl@math.technion.ac.il
diff --git a/contrib/gnu-sort/lib/getopt.c b/contrib/gnu-sort/lib/getopt.c
index fa46c85..08ba35b 100644
--- a/contrib/gnu-sort/lib/getopt.c
+++ b/contrib/gnu-sort/lib/getopt.c
@@ -1,43 +1,42 @@
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
+ "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
+ Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
+ 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.
- This program is distributed in the hope that it will be useful,
+ 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
-/* $FreeBSD$ */
+ 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 <stdio.h>.
Ditto for AIX 3.2 and <stdlib.h>. */
#ifndef _NO_PROTO
-#define _NO_PROTO
+# define _NO_PROTO
#endif
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
-#if !defined (__STDC__) || !__STDC__
+#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
-#ifndef const
-#define const
-#endif
+# ifndef const
+# define const
+# endif
#endif
#include <stdio.h>
@@ -50,7 +49,15 @@
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
+# include <gnu-versions.h>
+# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+# define ELIDE_CODE
+# endif
+#endif
+
+#ifndef ELIDE_CODE
/* This needs to come after some library #include
@@ -58,18 +65,27 @@
#ifdef __GNU_LIBRARY__
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
-#include <stdlib.h>
+# include <stdlib.h>
+# include <unistd.h>
#endif /* GNU C library. */
-#ifndef _
-/* This is for other GNU distributions with internationalized messages.
- When compiling libc, the _ macro is predefined. */
-#ifdef HAVE_LIBINTL_H
-# include <libintl.h>
-# define _(msgid) gettext (msgid)
-#else
-# define _(msgid) (msgid)
+#ifdef VMS
+# include <unixlib.h>
+# if HAVE_STRING_H - 0
+# include <string.h>
+# endif
#endif
+
+#ifndef _
+/* This is for other GNU distributions with internationalized messages. */
+# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
+# include <libintl.h>
+# ifndef _
+# define _(msgid) gettext (msgid)
+# endif
+# else
+# define _(msgid) (msgid)
+# endif
#endif
/* This version of `getopt' appears to the caller like standard Unix `getopt'
@@ -94,7 +110,7 @@
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
-char *optarg = NULL;
+char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
@@ -102,14 +118,20 @@ char *optarg = NULL;
On entry to `getopt', zero means this is the first call; initialize.
- When `getopt' returns EOF, this is the index of the first of the
+ 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. */
-/* XXX 1003.2 says this must be 1 before any call. */
-int optind = 0;
+/* 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.
@@ -158,7 +180,7 @@ int optopt = '?';
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return EOF with `optind' != ARGC. */
+ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
static enum
{
@@ -173,14 +195,22 @@ static char *posixly_correct;
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
in GCC. */
-#include <string.h>
-#define my_index strchr
+# include <string.h>
+# define my_index strchr
#else
+# if HAVE_STRING_H
+# include <string.h>
+# else
+# include <strings.h>
+# endif
+
/* Avoid depending on library functions or files
whose names are inconsistent. */
-char *getenv ();
+#ifndef getenv
+extern char *getenv ();
+#endif
static char *
my_index (str, chr)
@@ -201,11 +231,11 @@ my_index (str, chr)
#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__
+# 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 /* not __STDC__ */
#endif /* __GNUC__ */
#endif /* not __GNU_LIBRARY__ */
@@ -219,6 +249,52 @@ extern int strlen (const char *);
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.
@@ -228,6 +304,10 @@ static int last_nonopt;
`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;
@@ -242,6 +322,28 @@ exchange (argv)
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)
@@ -256,6 +358,7 @@ exchange (argv)
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;
@@ -272,6 +375,7 @@ exchange (argv)
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;
@@ -286,15 +390,20 @@ exchange (argv)
/* 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 (optstring)
+_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 = 1;
+ first_nonopt = last_nonopt = optind;
nextchar = NULL;
@@ -317,6 +426,36 @@ _getopt_initialize (optstring)
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;
}
@@ -333,7 +472,7 @@ _getopt_initialize (optstring)
updating `optind' and `nextchar' so that the next call to `getopt' can
resume the scan with the following option character or ARGV-element.
- If there are no more option characters, `getopt' returns `EOF'.
+ 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.)
@@ -385,18 +524,46 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
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)
+ if (optind == 0 || !__getopt_initialized)
{
- optstring = _getopt_initialize (optstring);
- optind = 1; /* Don't scan ARGV[0], the program name. */
+ 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,
@@ -410,8 +577,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
/* Skip any additional non-options
and extend the range of non-options previously skipped. */
- while (optind < argc
- && (argv[optind][0] != '-' || argv[optind][1] == '\0'))
+ while (optind < argc && NONOPTION_P)
optind++;
last_nonopt = optind;
}
@@ -443,16 +609,16 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
that we previously skipped, so the caller will digest them. */
if (first_nonopt != last_nonopt)
optind = first_nonopt;
- return EOF;
+ 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 ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
+ if (NONOPTION_P)
{
if (ordering == REQUIRE_ORDER)
- return EOF;
+ return -1;
optarg = argv[optind++];
return 1;
}
@@ -481,30 +647,26 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (longopts != NULL
&& (argv[optind][1] == '-'
- || (long_only && (argv[optind][2]
- || !my_index (optstring, argv[optind][1])))))
+ || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
{
char *nameend;
const struct option *p;
const struct option *pfound = NULL;
int exact = 0;
int ambig = 0;
- int indfound;
+ int indfound = -1;
int option_index;
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
/* Do nothing. */ ;
-#ifdef lint
- indfound = 0; /* Avoid spurious compiler warning. */
-#endif
-
/* Test all long options for either exact match
or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, nextchar, nameend - nextchar))
{
- if (nameend - nextchar == strlen (p->name))
+ if ((unsigned int) (nameend - nextchar)
+ == (unsigned int) strlen (p->name))
{
/* Exact match found. */
pfound = p;
@@ -518,18 +680,22 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
pfound = p;
indfound = option_index;
}
- else
+ 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 (opterr)
+ if (print_errors)
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
+ optopt = 0;
return '?';
}
@@ -545,19 +711,23 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
optarg = nameend + 1;
else
{
- if (opterr)
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- _("%s: option `--%s' doesn't allow an argument\n"),
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- _("%s: option `%c%s' doesn't allow an argument\n"),
- argv[0], argv[optind - 1][0], pfound->name);
+ 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 '?';
}
}
@@ -567,11 +737,12 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
optarg = argv[optind++];
else
{
- if (opterr)
+ 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] == ':' ? ':' : '?';
}
}
@@ -593,7 +764,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (!long_only || argv[optind][1] == '-'
|| my_index (optstring, *nextchar) == NULL)
{
- if (opterr)
+ if (print_errors)
{
if (argv[optind][1] == '-')
/* --option */
@@ -606,6 +777,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
}
nextchar = (char *) "";
optind++;
+ optopt = 0;
return '?';
}
}
@@ -622,7 +794,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (temp == NULL || c == ':')
{
- if (opterr)
+ if (print_errors)
{
if (posixly_correct)
/* 1003.2 specifies the format of this message. */
@@ -635,6 +807,130 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
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] == ':')
@@ -661,12 +957,12 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
}
else if (optind == argc)
{
- if (opterr)
+ if (print_errors)
{
/* 1003.2 specifies the format of this message. */
fprintf (stderr,
- _("%s: option requires an argument -- %c\n"),
- argv[0], c);
+ _("%s: option requires an argument -- %c\n"),
+ argv[0], c);
}
optopt = c;
if (optstring[0] == ':')
@@ -697,7 +993,7 @@ getopt (argc, argv, optstring)
0);
}
-#endif /* _LIBC or not __GNU_LIBRARY__. */
+#endif /* Not ELIDE_CODE. */
#ifdef TEST
@@ -717,7 +1013,7 @@ main (argc, argv)
int this_option_optind = optind ? optind : 1;
c = getopt (argc, argv, "abc:d:0123456789");
- if (c == EOF)
+ if (c == -1)
break;
switch (c)
diff --git a/contrib/gnu-sort/lib/getopt.h b/contrib/gnu-sort/lib/getopt.h
index 89bc731..a1b8dd6 100644
--- a/contrib/gnu-sort/lib/getopt.h
+++ b/contrib/gnu-sort/lib/getopt.h
@@ -1,24 +1,38 @@
/* Declarations for getopt.
- Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+ Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
+ 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.
- This program is distributed in the hope that it will be useful,
+ 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 General Public License for more details.
+ 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 General Public License
- along with this program; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* $FreeBSD$ */
+ 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
-#define _GETOPT_H 1
+
+#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 <features.h>, but
+ that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
+ not defined, include <ctype.h>, which will pull in <features.h> for us
+ if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
+ doesn't flood the namespace with stuff the way some other headers do.) */
+#if !defined __GNU_LIBRARY__
+# include <ctype.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -38,7 +52,7 @@ extern char *optarg;
On entry to `getopt', zero means this is the first call; initialize.
- When `getopt' returns EOF, this is the index of the first of the
+ 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
@@ -55,6 +69,7 @@ extern int opterr;
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
@@ -78,11 +93,11 @@ extern int optopt;
struct option
{
-#if defined (__STDC__) && __STDC__
+# if (defined __STDC__ && __STDC__) || defined __cplusplus
const char *name;
-#else
+# else
char *name;
-#endif
+# 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;
@@ -92,40 +107,74 @@ struct option
/* Names for the values of the `has_arg' field of `struct option'. */
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
+# 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.
-#if defined (__STDC__) && __STDC__
-#ifdef __GNU_LIBRARY__
+ 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 (int __argc, char *const *__argv, const char *__shortopts);
+# else /* not __GNU_LIBRARY__ */
extern int getopt ();
-#endif /* __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
+# 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);
+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
-#endif /* _GETOPT_H */
+/* 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
index 3d068e9..22a7efb 100644
--- a/contrib/gnu-sort/lib/getopt1.c
+++ b/contrib/gnu-sort/lib/getopt1.c
@@ -1,22 +1,22 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994
- Free Software Foundation, Inc.
+ Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
+ 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.
- This program is distributed in the hope that it will be useful,
+ 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 General Public License for more details.
+ 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 General Public License
- along with this program; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* $FreeBSD$ */
+ 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 <config.h>
@@ -24,7 +24,7 @@
#include "getopt.h"
-#if !defined (__STDC__) || !__STDC__
+#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
@@ -42,15 +42,21 @@
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
-#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
+#include <gnu-versions.h>
+#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 <stdlib.h>
-#else
-char *getenv ();
#endif
#ifndef NULL
@@ -85,7 +91,7 @@ getopt_long_only (argc, argv, options, long_options, opt_index)
}
-#endif /* _LIBC or not __GNU_LIBRARY__. */
+#endif /* Not ELIDE_CODE. */
#ifdef TEST
@@ -116,7 +122,7 @@ main (argc, argv)
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
- if (c == EOF)
+ if (c == -1)
break;
switch (c)
diff --git a/contrib/gnu-sort/lib/gettext.h b/contrib/gnu-sort/lib/gettext.h
new file mode 100644
index 0000000..6d2d4f8
--- /dev/null
+++ b/contrib/gnu-sort/lib/gettext.h
@@ -0,0 +1,69 @@
+/* Convenience header for conditional use of GNU <libintl.h>.
+ 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 Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+#ifndef _LIBGETTEXT_H
+# define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option. */
+# if ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions. */
+# include <libintl.h>
+
+# else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+ chokes if dcgettext is defined as a macro. So include it now, to make
+ later inclusions of <locale.h> a NOP. We don't include <libintl.h>
+ as well because people using "gettext.h" will not include <libintl.h>,
+ and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+ is OK. */
+# if defined(__sun)
+# include <locale.h>
+# endif
+
+/* 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
index 01e0ebd..0070542 100644
--- a/contrib/gnu-sort/lib/hard-locale.c
+++ b/contrib/gnu-sort/lib/hard-locale.c
@@ -1,5 +1,6 @@
/* hard-locale.c -- Determine whether a locale is hard.
- Copyright 1997, 1998, 1999 Free Software Foundation, Inc.
+
+ Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,41 +20,26 @@
# include <config.h>
#endif
-#if __GNUC__
-# define alloca __builtin_alloca
-#else
-# ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifdef _AIX
- # pragma alloca
-# else
-# ifdef _WIN32
-# include <malloc.h>
-# include <io.h>
-# else
-# ifndef alloca
-char *alloca ();
-# endif
-# endif
-# endif
-# endif
-#endif
-
#if HAVE_LOCALE_H
# include <locale.h>
#endif
+#if HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
#if HAVE_STRING_H
# include <string.h>
#endif
+#include "hard-locale.h"
+
/* Return nonzero if the current CATEGORY locale is hard, i.e. if you
can't get away with assuming traditional C or POSIX behavior. */
int
hard_locale (int category)
{
-#if ! (defined ENABLE_NLS && HAVE_SETLOCALE)
+#if ! HAVE_SETLOCALE
return 0;
#else
@@ -62,22 +48,28 @@ hard_locale (int category)
if (p)
{
-# if defined __GLIBC__ && __GLIBC__ >= 2
+# if defined __GLIBC__ && 2 <= __GLIBC__
if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
hard = 0;
# else
- char *locale = alloca (strlen (p) + 1);
- strcpy (locale, p);
-
- /* Temporarily set the locale to the "C" and "POSIX" locales to
- find their names, so that we can determine whether one or the
- other is the caller's locale. */
- if (((p = setlocale (category, "C")) && strcmp (p, locale) == 0)
- || ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0))
- hard = 0;
+ 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 = 0;
- /* Restore the caller's locale. */
- setlocale (category, locale);
+ /* Restore the caller's locale. */
+ setlocale (category, locale);
+ free (locale);
+ }
# endif
}
diff --git a/contrib/gnu-sort/lib/xmalloc.c b/contrib/gnu-sort/lib/xmalloc.c
index 2f103d6..bc6c0bd 100644
--- a/contrib/gnu-sort/lib/xmalloc.c
+++ b/contrib/gnu-sort/lib/xmalloc.c
@@ -1,5 +1,5 @@
/* xmalloc.c -- malloc with out of memory checking
- Copyright (C) 1990-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1990-1999, 2000, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -46,12 +46,12 @@ void free ();
# define EXIT_FAILURE 1
#endif
-#ifndef HAVE_DONE_WORKING_MALLOC_CHECK
-"you must run the autoconf test for a properly working malloc -- see malloc.m4"
+#ifndef HAVE_MALLOC
+"you must run the autoconf test for a properly working malloc"
#endif
-#ifndef HAVE_DONE_WORKING_REALLOC_CHECK
-"you must run the autoconf test for a properly working realloc --see realloc.m4"
+#ifndef HAVE_REALLOC
+"you must run the autoconf test for a properly working realloc"
#endif
/* Exit value when the requested amount of memory is not available.
diff --git a/contrib/gnu-sort/man/sort.1 b/contrib/gnu-sort/man/sort.1
index 919d355..9dcbace 100644
--- a/contrib/gnu-sort/man/sort.1
+++ b/contrib/gnu-sort/man/sort.1
@@ -1,5 +1,5 @@
-.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.25.
-.TH SORT "1" "February 2002" "sort (textutils) 2.0.21" "User Commands"
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28.
+.TH SORT "1" "July 2002" "sort (textutils) 2.1" "User Commands"
.SH NAME
sort \- sort lines of text files
.SH SYNOPSIS
diff --git a/contrib/gnu-sort/src/sort.c b/contrib/gnu-sort/src/sort.c
index a2b0ef16..5b75ebe 100644
--- a/contrib/gnu-sort/src/sort.c
+++ b/contrib/gnu-sort/src/sort.c
@@ -52,7 +52,7 @@ struct rlimit { size_t rlim_cur; };
#define AUTHORS N_ ("Mike Haertel and Paul Eggert")
-#if defined ENABLE_NLS && HAVE_LANGINFO_H
+#if HAVE_LANGINFO_H
# include <langinfo.h>
#endif
@@ -91,7 +91,7 @@ double strtod ();
#define NEGATION_SIGN '-'
#define NUMERIC_ZERO '0'
-#ifdef ENABLE_NLS
+#if HAVE_SETLOCALE
static char decimal_point;
static int th_sep; /* if CHAR_MAX + 1, then there is no thousands separator */
@@ -194,15 +194,9 @@ static char fold_toupper[UCHAR_LIM];
#define MONTHS_PER_YEAR 12
-#if defined ENABLE_NLS && HAVE_NL_LANGINFO
-# define MONTHTAB_CONST /* empty */
-#else
-# define MONTHTAB_CONST const
-#endif
-
/* Table mapping month names to integers.
Alphabetic order allows binary search. */
-static MONTHTAB_CONST struct month monthtab[] =
+static struct month monthtab[] =
{
{"APR", 4},
{"AUG", 8},
@@ -349,7 +343,7 @@ The locale specified by the environment affects sort order.\n\
Set LC_ALL=C to get the traditional sort order that uses\n\
native byte values.\n\
"), stdout );
- puts (_("\nReport bugs to <bug-textutils@gnu.org>."));
+ printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
/* Don't use EXIT_FAILURE here in case it is defined to be 1.
POSIX requires that sort return 1 IFF invoked with -c and
@@ -536,7 +530,7 @@ zaptemp (const char *name)
}
}
-#if defined ENABLE_NLS && HAVE_NL_LANGINFO
+#if HAVE_NL_LANGINFO
static int
struct_month_cmp (const void *m1, const void *m2)
@@ -568,7 +562,7 @@ inittables (void)
fold_toupper[i] = i;
}
-#if defined ENABLE_NLS && HAVE_NL_LANGINFO
+#if HAVE_NL_LANGINFO
/* If we're not in the "C" locale, read different names for months. */
if (hard_LC_TIME)
{
@@ -591,7 +585,7 @@ inittables (void)
qsort ((void *) monthtab, MONTHS_PER_YEAR,
sizeof (struct month), struct_month_cmp);
}
-#endif /* NLS */
+#endif
}
/* Specify the amount of main memory to use when sorting. */
@@ -858,24 +852,25 @@ limfield (const struct line *line, const struct keyfield *key)
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 +0.6 -0.7 </tmp/sort.in
+ $ textutils-1.15/src/sort -k1.7,1.7 </tmp/sort.in
a b c 2 d
pq rs 1 t
- $ /bin/sort +0.6 -0.7 </tmp/sort.in
+ $ /bin/sort -k1.7,1.7 </tmp/sort.in
pq rs 1 t
a b c 2 d
Unix sort produced the answer I expected: sort on the single character
- in column 6. GNU sort produced different results, because it disagrees
- on the interpretation of the key-end spec "-M.N". Unix sort reads this
- as "skip M fields, then N characters"; but GNU sort wants it to mean
- "skip M fields, then either N characters or the rest of the current
+ in column 7. GNU sort produced different results, because it disagrees
+ on the interpretation of the key-end spec "M.N". Unix sort reads this
+ as "skip M-1 fields, then N-1 characters"; but GNU sort wants it to mean
+ "skip M-1 fields, then either N-1 characters or the rest of the current
field, whichever comes first". This extra clause applies only to
key-ends, not key-starts.
*/
@@ -1366,10 +1361,9 @@ keycompare (const struct line *a, const struct line *b)
}
else if (key->month)
diff = getmonth (texta, lena) - getmonth (textb, lenb);
-#ifdef ENABLE_NLS
/* Sorting like this may become slow, so in a simple locale the user
can select a faster sort that is similar to ascii sort */
- else if (hard_LC_COLLATE)
+ else if (HAVE_SETLOCALE && hard_LC_COLLATE)
{
if (ignore || translate)
{
@@ -1407,7 +1401,6 @@ keycompare (const struct line *a, const struct line *b)
else
diff = xmemcoll (texta, lena, textb, lenb);
}
-#endif
else if (ignore)
{
#define CMP_WITH_IGNORE(A, B) \
@@ -1527,10 +1520,8 @@ compare (register const struct line *a, register const struct line *b)
diff = - NONZERO (blen);
else if (blen == 0)
diff = NONZERO (alen);
-#ifdef ENABLE_NLS
- else if (hard_LC_COLLATE)
+ else if (HAVE_SETLOCALE && hard_LC_COLLATE)
diff = xmemcoll (a->text, alen, b->text, blen);
-#endif
else if (! (diff = memcmp (a->text, b->text, min (alen, blen))))
diff = alen < blen ? -1 : alen != blen;
@@ -2187,13 +2178,12 @@ main (int argc, char **argv)
atexit (cleanup);
-#ifdef ENABLE_NLS
-
hard_LC_COLLATE = hard_locale (LC_COLLATE);
-# if HAVE_NL_LANGINFO
+#if HAVE_NL_LANGINFO
hard_LC_TIME = hard_locale (LC_TIME);
-# endif
+#endif
+#if HAVE_SETLOCALE
/* Let's get locale's representation of the decimal point */
{
struct lconv *lconvp = localeconv ();
@@ -2210,8 +2200,7 @@ main (int argc, char **argv)
if (! th_sep || lconvp->thousands_sep[1])
th_sep = CHAR_MAX + 1;
}
-
-#endif /* NLS */
+#endif
have_read_stdin = 0;
inittables ();
diff --git a/contrib/gnu-sort/src/sys2.h b/contrib/gnu-sort/src/sys2.h
index 610c1fd..0ba910e 100644
--- a/contrib/gnu-sort/src/sys2.h
+++ b/contrib/gnu-sort/src/sys2.h
@@ -3,6 +3,10 @@
more time, I'll merge the remaining things in system.h and everything
in this file will go back there. */
+#ifndef S_IFMT
+# define S_IFMT 0170000
+#endif
+
#if STAT_MACROS_BROKEN
# undef S_ISBLK
# undef S_ISCHR
@@ -10,48 +14,129 @@
# 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 /* STAT_MACROS_BROKEN. */
+#endif
-#ifndef S_IFMT
-# define S_IFMT 0170000
+
+#ifndef S_ISBLK
+# ifdef S_IFBLK
+# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+# else
+# define S_ISBLK(m) 0
+# endif
#endif
-#if !defined(S_ISBLK) && defined(S_IFBLK)
-# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+
+#ifndef S_ISCHR
+# ifdef S_IFCHR
+# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+# else
+# define S_ISCHR(m) 0
+# endif
#endif
-#if !defined(S_ISCHR) && defined(S_IFCHR)
-# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+
+#ifndef S_ISDIR
+# ifdef S_IFDIR
+# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+# else
+# define S_ISDIR(m) 0
+# endif
#endif
-#if !defined(S_ISDIR) && defined(S_IFDIR)
-# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+
+#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
-#if !defined(S_ISREG) && defined(S_IFREG)
-# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+
+#ifndef S_ISFIFO
+# ifdef S_IFIFO
+# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+# else
+# define S_ISFIFO(m) 0
+# endif
#endif
-#if !defined(S_ISFIFO) && defined(S_IFIFO)
-# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+
+#ifndef S_ISLNK
+# ifdef S_IFLNK
+# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+# else
+# define S_ISLNK(m) 0
+# endif
#endif
-#if !defined(S_ISLNK) && defined(S_IFLNK)
-# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+
+#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
-#if !defined(S_ISSOCK) && defined(S_IFSOCK)
-# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+
+#ifndef S_ISNAM /* Xenix */
+# ifdef S_IFNAM
+# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
+# else
+# define S_ISNAM(m) 0
+# endif
#endif
-#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
-# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
-# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
+
+#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
-#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
-# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
+
+#ifndef S_ISREG
+# ifdef S_IFREG
+# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+# else
+# define S_ISREG(m) 0
+# endif
#endif
-#if !defined(S_ISDOOR) && defined(S_IFDOOR) /* Solaris 2.5 and up */
-# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
+
+#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_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
+
+#ifndef S_TYPEISMQ
+# define S_TYPEISMQ(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
@@ -260,27 +345,18 @@ char *alloca ();
#if HAVE_LOCALE_H
# include <locale.h>
-#endif
-#if !HAVE_SETLOCALE
+#else
# define setlocale(Category, Locale) /* empty */
#endif
-#if ENABLE_NLS
-# include <libintl.h>
-# if HAVE_GETTEXT && !HAVE_DCGETTEXT && !defined dcgettext
-# define dcgettext(Domain, Text, Category) Text
-# endif
-# define _(Text) gettext (Text)
-#else
-# undef bindtextdomain
-# define bindtextdomain(Domain, Directory) /* empty */
-# undef textdomain
-# define textdomain(Domain) /* empty */
-# undef dcgettext
-# define dcgettext(Domainname, Text, Category) Text
-# define _(Text) Text
-#endif
-#define N_(Text) Text
+#include "gettext.h"
+
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
+#ifndef HAVE_SETLOCALE
+# define HAVE_SETLOCALE 0
+#endif
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
diff --git a/contrib/gnu-sort/src/system.h b/contrib/gnu-sort/src/system.h
index 6e11e44..a2c08d2 100644
--- a/contrib/gnu-sort/src/system.h
+++ b/contrib/gnu-sort/src/system.h
@@ -1,5 +1,5 @@
/* system-dependent definitions for fileutils, textutils, and sh-utils packages.
- Copyright (C) 1989, 1991-2001 Free Software Foundation, Inc.
+ Copyright (C) 1989, 1991-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,9 +17,15 @@
/* Include sys/types.h before this file. */
+#if 2 <= __GLIBC__ && 2 <= __GLIBC_MINOR__
+# if ! defined _SYS_TYPES_H
+you must include <sys/types.h> before including this file
+# endif
+#endif
+
#include <sys/stat.h>
-#if !defined(HAVE_MKFIFO)
+#if !defined HAVE_MKFIFO
# define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
#endif
@@ -146,7 +152,7 @@ typedef enum {false = 0, true = 1} bool;
# include <sys/file.h>
#endif
-#if !defined (SEEK_SET)
+#if !defined SEEK_SET
# define SEEK_SET 0
# define SEEK_CUR 1
# define SEEK_END 2
@@ -238,7 +244,7 @@ typedef enum {false = 0, true = 1} bool;
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. */
+# if defined _POSIX_SOURCE || !defined BSIZE /* fileblocks.c uses BSIZE. */
# define ST_NBLOCKS(statbuf) \
(S_ISREG ((statbuf).st_mode) \
|| S_ISDIR ((statbuf).st_mode) \
@@ -253,16 +259,16 @@ typedef enum {false = 0, true = 1} bool;
/* Some systems, like Sequents, return st_blksize of 0 on pipes. */
# define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
? (statbuf).st_blksize : DEV_BSIZE)
-# if defined(hpux) || defined(__hpux__) || defined(__hpux)
+# if defined hpux || defined __hpux__ || defined __hpux
/* HP-UX counts st_blocks in 1024-byte units.
This loses when mixing HP-UX and BSD filesystems with NFS. */
# define ST_NBLOCKSIZE 1024
# else /* !hpux */
-# if defined(_AIX) && defined(_I386)
+# 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)
+# if defined _CRAY
# define ST_NBLOCKS(statbuf) \
(S_ISREG ((statbuf).st_mode) \
|| S_ISDIR ((statbuf).st_mode) \
OpenPOWER on IntegriCloud