This commit was generated by cvs2svn to compensate for changes in r98038,
which included commits to RCS files with non-trunk default branches.
This commit is contained in:
commit
83eb65efea
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98039
393
contrib/gnu-sort/ABOUT-NLS
Normal file
393
contrib/gnu-sort/ABOUT-NLS
Normal file
@ -0,0 +1,393 @@
|
||||
Notes on the Free Translation Project
|
||||
*************************************
|
||||
|
||||
Free software is going international! The Free Translation Project
|
||||
is a way to get maintainers of free software, translators, and users all
|
||||
together, so that will gradually become able to speak many languages.
|
||||
A few packages already provide translations for their messages.
|
||||
|
||||
If you found this `ABOUT-NLS' file inside a distribution, you may
|
||||
assume that the distributed package does use GNU `gettext' internally,
|
||||
itself available at your nearest GNU archive site. But you do _not_
|
||||
need to install GNU `gettext' prior to configuring, installing or using
|
||||
this package with messages translated.
|
||||
|
||||
Installers will find here some useful hints. These notes also
|
||||
explain how users should proceed for getting the programs to use the
|
||||
available translations. They tell how people wanting to contribute and
|
||||
work at translations should contact the appropriate team.
|
||||
|
||||
When reporting bugs in the `intl/' directory or bugs which may be
|
||||
related to internationalization, you should tell about the version of
|
||||
`gettext' which is used. The information can be found in the
|
||||
`intl/VERSION' file, in internationalized packages.
|
||||
|
||||
Quick configuration advice
|
||||
==========================
|
||||
|
||||
If you want to exploit the full power of internationalization, you
|
||||
should configure it using
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to force usage of internationalizing routines provided within this
|
||||
package, despite the existence of internationalizing capabilities in the
|
||||
operating system where this package is being installed. So far, only
|
||||
the `gettext' implementation in the GNU C library version 2 provides as
|
||||
many features (such as locale alias, message inheritance, automatic
|
||||
charset conversion or plural form handling) as the implementation here.
|
||||
It is also not possible to offer this additional functionality on top
|
||||
of a `catgets' implementation. Future versions of GNU `gettext' will
|
||||
very likely convey even more functionality. So it might be a good idea
|
||||
to change to GNU `gettext' as soon as possible.
|
||||
|
||||
So you need _not_ provide this option if you are using GNU libc 2 or
|
||||
you have installed a recent copy of the GNU gettext package with the
|
||||
included `libintl'.
|
||||
|
||||
INSTALL Matters
|
||||
===============
|
||||
|
||||
Some packages are "localizable" when properly installed; the
|
||||
programs they contain can be made to speak your own native language.
|
||||
Most such packages use GNU `gettext'. Other packages have their own
|
||||
ways to internationalization, predating GNU `gettext'.
|
||||
|
||||
By default, this package will be installed to allow translation of
|
||||
messages. It will automatically detect whether the system already
|
||||
provides the GNU `gettext' functions. If not, the GNU `gettext' own
|
||||
library will be used. This library is wholly contained within this
|
||||
package, usually in the `intl/' subdirectory, so prior installation of
|
||||
the GNU `gettext' package is _not_ required. Installers may use
|
||||
special options at configuration time for changing the default
|
||||
behaviour. The commands:
|
||||
|
||||
./configure --with-included-gettext
|
||||
./configure --disable-nls
|
||||
|
||||
will respectively bypass any pre-existing `gettext' to use the
|
||||
internationalizing routines provided within this package, or else,
|
||||
_totally_ disable translation of messages.
|
||||
|
||||
When you already have GNU `gettext' installed on your system and run
|
||||
configure without an option for your new package, `configure' will
|
||||
probably detect the previously built and installed `libintl.a' file and
|
||||
will decide to use this. This might be not what is desirable. You
|
||||
should use the more recent version of the GNU `gettext' library. I.e.
|
||||
if the file `intl/VERSION' shows that the library which comes with this
|
||||
package is more recent, you should use
|
||||
|
||||
./configure --with-included-gettext
|
||||
|
||||
to prevent auto-detection.
|
||||
|
||||
The configuration process will not test for the `catgets' function
|
||||
and therefore it will not be used. The reason is that even an
|
||||
emulation of `gettext' on top of `catgets' could not provide all the
|
||||
extensions of the GNU `gettext' library.
|
||||
|
||||
Internationalized packages have usually many `po/LL.po' files, where
|
||||
LL gives an ISO 639 two-letter code identifying the language. Unless
|
||||
translations have been forbidden at `configure' time by using the
|
||||
`--disable-nls' switch, all available translations are installed
|
||||
together with the package. However, the environment variable `LINGUAS'
|
||||
may be set, prior to configuration, to limit the installed set.
|
||||
`LINGUAS' should then contain a space separated list of two-letter
|
||||
codes, stating which languages are allowed.
|
||||
|
||||
Using This Package
|
||||
==================
|
||||
|
||||
As a user, if your language has been installed for this package, you
|
||||
only have to set the `LANG' environment variable to the appropriate
|
||||
`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code,
|
||||
and `CC' is an ISO 3166 two-letter country code. For example, let's
|
||||
suppose that you speak German and live in Germany. At the shell
|
||||
prompt, merely execute `setenv LANG de_DE' (in `csh'),
|
||||
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
|
||||
This can be done from your `.login' or `.profile' file, once and for
|
||||
all.
|
||||
|
||||
You might think that the country code specification is redundant.
|
||||
But in fact, some languages have dialects in different countries. For
|
||||
example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The
|
||||
country code serves to distinguish the dialects.
|
||||
|
||||
The locale naming convention of `LL_CC', with `LL' denoting the
|
||||
language and `CC' denoting the country, is the one use on systems based
|
||||
on GNU libc. On other systems, some variations of this scheme are
|
||||
used, such as `LL' or `LL_CC.ENCODING'. You can get the list of
|
||||
locales supported by your system for your country by running the command
|
||||
`locale -a | grep '^LL''.
|
||||
|
||||
Not all programs have translations for all languages. By default, an
|
||||
English message is shown in place of a nonexistent translation. If you
|
||||
understand other languages, you can set up a priority list of languages.
|
||||
This is done through a different environment variable, called
|
||||
`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG'
|
||||
for the purpose of message handling, but you still need to have `LANG'
|
||||
set to the primary language; this is required by other parts of the
|
||||
system libraries. For example, some Swedish users who would rather
|
||||
read translations in German than English for when Swedish is not
|
||||
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
|
||||
|
||||
In the `LANGUAGE' environment variable, but not in the `LANG'
|
||||
environment variable, `LL_CC' combinations can be abbreviated as `LL'
|
||||
to denote the language's main dialect. For example, `de' is equivalent
|
||||
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
|
||||
(Portuguese as spoken in Portugal) in this context.
|
||||
|
||||
Translating Teams
|
||||
=================
|
||||
|
||||
For the Free Translation Project to be a success, we need interested
|
||||
people who like their own language and write it well, and who are also
|
||||
able to synergize with other translators speaking the same language.
|
||||
Each translation team has its own mailing list. The up-to-date list of
|
||||
teams can be found at the Free Translation Project's homepage,
|
||||
`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams"
|
||||
area.
|
||||
|
||||
If you'd like to volunteer to _work_ at translating messages, you
|
||||
should become a member of the translating team for your own language.
|
||||
The subscribing address is _not_ the same as the list itself, it has
|
||||
`-request' appended. For example, speakers of Swedish can send a
|
||||
message to `sv-request@li.org', having this message body:
|
||||
|
||||
subscribe
|
||||
|
||||
Keep in mind that team members are expected to participate
|
||||
_actively_ in translations, or at solving translational difficulties,
|
||||
rather than merely lurking around. If your team does not exist yet and
|
||||
you want to start one, or if you are unsure about what to do or how to
|
||||
get started, please write to `translation@iro.umontreal.ca' to reach the
|
||||
coordinator for all translator teams.
|
||||
|
||||
The English team is special. It works at improving and uniformizing
|
||||
the terminology in use. Proven linguistic skill are praised more than
|
||||
programming skill, here.
|
||||
|
||||
Available Packages
|
||||
==================
|
||||
|
||||
Languages are not equally supported in all packages. The following
|
||||
matrix shows the current state of internationalization, as of January
|
||||
2002. The matrix shows, in regard of each package, for which languages
|
||||
PO files have been submitted to translation coordination, with a
|
||||
translation percentage of at least 50%.
|
||||
|
||||
Ready PO files bg ca cs da de el en eo es et fi fr
|
||||
+-------------------------------------+
|
||||
a2ps | [] [] [] [] |
|
||||
bash | [] [] [] [] |
|
||||
bfd | [] [] |
|
||||
binutils | [] [] |
|
||||
bison | [] [] [] |
|
||||
clisp | [] [] [] [] |
|
||||
cpio | [] [] [] [] |
|
||||
diffutils | [] [] [] [] [] [] |
|
||||
enscript | [] [] |
|
||||
error | [] [] |
|
||||
fetchmail | () [] [] [] () |
|
||||
fileutils | [] [] [] [] [] |
|
||||
findutils | [] [] [] [] [] |
|
||||
flex | [] [] [] |
|
||||
gas | [] |
|
||||
gawk | [] [] |
|
||||
gcal | [] [] |
|
||||
gcc | [] [] |
|
||||
gettext | [] [] [] [] [] |
|
||||
gnupg | [] [] [] [] [] [] |
|
||||
gprof | [] [] |
|
||||
grep | [] [] [] [] [] [] |
|
||||
hello | [] [] [] [] [] [] [] [] |
|
||||
id-utils | [] [] [] |
|
||||
indent | [] [] [] [] |
|
||||
jpilot | () [] [] [] |
|
||||
jwhois | [] [] |
|
||||
kbd | [] |
|
||||
ld | [] [] |
|
||||
libc | [] [] [] [] [] [] [] |
|
||||
lilypond | [] [] |
|
||||
lynx | [] [] [] [] |
|
||||
m4 | [] [] [] [] [] |
|
||||
make | [] [] [] [] |
|
||||
mysecretdiary | [] [] |
|
||||
nano | [] () [] [] [] [] |
|
||||
nano_1_0 | [] () [] [] [] [] |
|
||||
opcodes | [] [] [] |
|
||||
parted | [] [] [] [] |
|
||||
ptx | [] [] [] [] [] |
|
||||
python | |
|
||||
recode | [] [] [] [] [] [] |
|
||||
sed | [] [] [] [] [] [] [] [] |
|
||||
sh-utils | [] [] [] [] [] [] [] [] |
|
||||
sharutils | [] [] [] [] [] [] |
|
||||
sketch | () [] () |
|
||||
soundtracker | [] [] [] |
|
||||
sp | |
|
||||
tar | [] [] [] [] [] [] |
|
||||
texinfo | [] [] [] [] [] |
|
||||
textutils | [] [] [] [] |
|
||||
util-linux | [] [] [] [] |
|
||||
wdiff | [] [] [] [] [] |
|
||||
wget | [] [] [] [] [] [] [] [] |
|
||||
+-------------------------------------+
|
||||
bg ca cs da de el en eo es et fi fr
|
||||
0 8 12 31 36 9 1 9 37 15 1 49
|
||||
|
||||
gl he hr hu id it ja ko lv nb nl nn
|
||||
+-------------------------------------+
|
||||
a2ps | () () [] |
|
||||
bash | |
|
||||
bfd | [] |
|
||||
binutils | [] |
|
||||
bison | [] |
|
||||
clisp | [] |
|
||||
cpio | [] [] [] |
|
||||
diffutils | [] [] |
|
||||
enscript | [] |
|
||||
error | [] |
|
||||
fetchmail | |
|
||||
fileutils | [] [] |
|
||||
findutils | [] [] [] [] [] [] |
|
||||
flex | [] |
|
||||
gas | |
|
||||
gawk | [] |
|
||||
gcal | |
|
||||
gcc | [] |
|
||||
gettext | [] |
|
||||
gnupg | [] [] [] |
|
||||
gprof | |
|
||||
grep | [] [] |
|
||||
hello | [] [] [] [] [] [] [] [] [] |
|
||||
id-utils | [] |
|
||||
indent | [] [] [] |
|
||||
jpilot | () () |
|
||||
jwhois | |
|
||||
kbd | |
|
||||
ld | |
|
||||
libc | [] [] [] [] |
|
||||
lilypond | [] [] |
|
||||
lynx | [] [] |
|
||||
m4 | [] [] [] [] |
|
||||
make | [] [] [] [] |
|
||||
mysecretdiary | |
|
||||
nano | [] [] [] () () [] |
|
||||
nano_1_0 | [] [] [] () () [] |
|
||||
opcodes | |
|
||||
parted | [] [] [] |
|
||||
ptx | [] [] [] [] |
|
||||
python | |
|
||||
recode | [] [] [] |
|
||||
sed | [] [] [] [] [] [] [] |
|
||||
sh-utils | [] [] [] [] [] |
|
||||
sharutils | [] [] [] |
|
||||
sketch | () |
|
||||
soundtracker | [] |
|
||||
sp | |
|
||||
tar | [] [] [] |
|
||||
texinfo | [] [] [] |
|
||||
textutils | [] [] |
|
||||
util-linux | () [] |
|
||||
wdiff | |
|
||||
wget | [] [] [] [] [] |
|
||||
+-------------------------------------+
|
||||
gl he hr hu id it ja ko lv nb nl nn
|
||||
20 6 1 3 6 11 22 9 1 6 17 4
|
||||
|
||||
no pl pt pt_BR ru sk sl sv tr uk zh
|
||||
+-------------------------------------+
|
||||
a2ps | () () () [] [] [] () | 8
|
||||
bash | | 4
|
||||
bfd | [] [] | 5
|
||||
binutils | [] | 4
|
||||
bison | [] [] [] | 7
|
||||
clisp | | 5
|
||||
cpio | [] [] [] [] | 11
|
||||
diffutils | [] [] [] | 11
|
||||
enscript | [] [] [] | 6
|
||||
error | [] [] | 5
|
||||
fetchmail | () () | 3
|
||||
fileutils | [] [] [] [] | 11
|
||||
findutils | [] [] [] [] [] [] | 17
|
||||
flex | [] [] | 6
|
||||
gas | [] | 2
|
||||
gawk | [] [] | 5
|
||||
gcal | [] | 3
|
||||
gcc | [] | 4
|
||||
gettext | [] [] [] [] | 10
|
||||
gnupg | [] [] [] | 12
|
||||
gprof | [] [] | 4
|
||||
grep | [] [] [] [] [] | 13
|
||||
hello | [] [] [] [] [] [] [] | 24
|
||||
id-utils | [] [] | 6
|
||||
indent | [] [] [] [] | 11
|
||||
jpilot | () () | 3
|
||||
jwhois | () () | 2
|
||||
kbd | [] [] | 3
|
||||
ld | [] [] | 4
|
||||
libc | [] [] [] [] [] [] | 17
|
||||
lilypond | [] | 5
|
||||
lynx | [] [] [] | 9
|
||||
m4 | [] [] [] | 12
|
||||
make | [] [] [] [] | 12
|
||||
mysecretdiary | [] | 3
|
||||
nano | () [] [] [] | 12
|
||||
nano_1_0 | () [] [] [] | 12
|
||||
opcodes | [] [] | 5
|
||||
parted | [] [] [] | 10
|
||||
ptx | [] [] [] [] [] [] | 15
|
||||
python | | 0
|
||||
recode | [] [] [] [] | 13
|
||||
sed | [] [] [] [] [] [] | 21
|
||||
sh-utils | [] [] [] [] [] [] [] [] [] | 22
|
||||
sharutils | [] [] | 11
|
||||
sketch | () | 1
|
||||
soundtracker | | 4
|
||||
sp | | 0
|
||||
tar | [] [] [] [] [] [] [] | 16
|
||||
texinfo | [] [] | 10
|
||||
textutils | [] [] | 8
|
||||
util-linux | [] [] [] | 8
|
||||
wdiff | [] [] [] [] | 9
|
||||
wget | [] [] [] [] [] [] | 19
|
||||
+-------------------------------------+
|
||||
35 teams no pl pt pt_BR ru sk sl sv tr uk zh
|
||||
54 domains 5 12 2 11 25 10 11 39 29 4 1 463
|
||||
|
||||
Some counters in the preceding matrix are higher than the number of
|
||||
visible blocks let us expect. This is because a few extra PO files are
|
||||
used for implementing regional variants of languages, or language
|
||||
dialects.
|
||||
|
||||
For a PO file in the matrix above to be effective, the package to
|
||||
which it applies should also have been internationalized and
|
||||
distributed as such by its maintainer. There might be an observable
|
||||
lag between the mere existence a PO file and its wide availability in a
|
||||
distribution.
|
||||
|
||||
If January 2002 seems to be old, you may fetch a more recent copy of
|
||||
this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date
|
||||
matrix with full percentage details can be found at
|
||||
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
|
||||
|
||||
Using `gettext' in new packages
|
||||
===============================
|
||||
|
||||
If you are writing a freely available program and want to
|
||||
internationalize it you are welcome to use GNU `gettext' in your
|
||||
package. Of course you have to respect the GNU Library General Public
|
||||
License which covers the use of the GNU `gettext' library. This means
|
||||
in particular that even non-free programs can use `libintl' as a shared
|
||||
library, whereas only free software can use `libintl' as a static
|
||||
library or use modified versions of `libintl'.
|
||||
|
||||
Once the sources are changed appropriately and the setup can handle
|
||||
to use of `gettext' the only thing missing are the translations. The
|
||||
Free Translation Project is also available for packages which are not
|
||||
developed inside the GNU project. Therefore the information given above
|
||||
applies also for every other Free Software Project. Contact
|
||||
`translation@iro.umontreal.ca' to make the `.pot' files available to
|
||||
the translation teams.
|
||||
|
10
contrib/gnu-sort/AUTHORS
Normal file
10
contrib/gnu-sort/AUTHORS
Normal file
@ -0,0 +1,10 @@
|
||||
Authors of parts of GNU textutils.
|
||||
|
||||
The following contributions warranted legal paper exchanges with the
|
||||
Free Software Foundation. Also see files ChangeLog and THANKS.
|
||||
|
||||
GPTX François Pinard CANADA, 1949
|
||||
Assigns the program.
|
||||
|
||||
GPTX Odyssee Recherches Appliquees
|
||||
Disclaims work by François Pinard
|
340
contrib/gnu-sort/COPYING
Normal file
340
contrib/gnu-sort/COPYING
Normal file
@ -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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 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.
|
||||
|
||||
<signature of Ty Coon>, 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.
|
8574
contrib/gnu-sort/ChangeLog
Normal file
8574
contrib/gnu-sort/ChangeLog
Normal file
File diff suppressed because it is too large
Load Diff
231
contrib/gnu-sort/INSTALL
Normal file
231
contrib/gnu-sort/INSTALL
Normal file
@ -0,0 +1,231 @@
|
||||
Copyright 1994, 1995, 1996, 1999, 2000, 2001 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for variables by setting
|
||||
them in the environment. You can do that on the command line like this:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of host the package
|
||||
will run on. Usually `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the host type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the host type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the host
|
||||
platform (i.e., that on which the generated programs will eventually be
|
||||
run) with `--host=TYPE'. In this case, you should also specify the
|
||||
build platform with `--build=TYPE', because, in this case, it may not
|
||||
be possible to guess the build platform (it sometimes involves
|
||||
compiling and running simple test programs, and this can't be done if
|
||||
the compiler is a cross compiler).
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
452
contrib/gnu-sort/NEWS
Normal file
452
contrib/gnu-sort/NEWS
Normal file
@ -0,0 +1,452 @@
|
||||
Changes in release 2.1
|
||||
[2.0.21]
|
||||
* split accepts new option -a or --suffix-length.
|
||||
* split no longer generates longer suffixes than requested; instead, it reports
|
||||
an error when suffixes are exhausted. POSIX requires this behavior.
|
||||
* The _POSIX2_VERSION environment variable lets you select which version
|
||||
of POSIX the utilities should conform to. Its default value is system
|
||||
dependent. Set _POSIX2_VERSION=199209 to cause the utilities to support
|
||||
obsolete usage like "sort +1".
|
||||
* The following obsolete usages are no longer supported when conforming
|
||||
to POSIX 1003.1-2001, which prohibits most digit-string options:
|
||||
expand -N (instead, use expand -t N)
|
||||
head -N (instead, use head -c N or head -n N)
|
||||
fold -N (instead, use fold -w N)
|
||||
split -N (instead, use split -l N)
|
||||
tail -N (instead, use tail -c N or tail -n N)
|
||||
unexpand -N (instead, use unexpand --first-only -t N)
|
||||
uniq -N (instead, use uniq -f N)
|
||||
The following obsolete usages (options without arguments) are no
|
||||
longer supported when conforming to POSIX 1003.1-2001, which
|
||||
prohibits most options with optional arguments:
|
||||
od -s (instead, use od --strings)
|
||||
od -w (instead, use od --width)
|
||||
pr -S (instead, use pr --sep-string)
|
||||
[2.0.20]
|
||||
* tr no longer gets failed a assertion for [==] or [::]
|
||||
* The following obsolete usages are no longer supported when conforming
|
||||
to POSIX 1003.1-2001, which prohibits most options with leading "+":
|
||||
sort +POS1 -POS2 (instead, use sort -k)
|
||||
tail +N (instead, use tail -c +N or tail -n +N)
|
||||
uniq +N (instead, use uniq -s N)
|
||||
* Warnings are issued for obsolete usages on older hosts,
|
||||
unless POSIXLY_CORRECT is set in the environment.
|
||||
* sort -m no longer segfaults when given an empty file
|
||||
* sort -S now accepts 'K' as a synonym for 'k'.
|
||||
* wc recognizes all locale-defined white-space characters, not just those
|
||||
in the "C" locale.
|
||||
[2.0.19]
|
||||
* portability tweak to make lib/regex.c compile
|
||||
* split translatable strings only in the middle of sentences
|
||||
[2.0.18]
|
||||
* sort could segfault on systems without a working mkstemp function and
|
||||
with a gettimeofday function that clobbers the static buffer that
|
||||
localtime uses for it's return value -- introduced in 2.0.17
|
||||
[2.0.17]
|
||||
* csplit no longer gets a failed assertion for this:
|
||||
printf 'a\n\n'|csplit - '/^$/' 2
|
||||
* sort detects physical memory attributes more portably
|
||||
* tail no longer gets a segfault on Linux's /proc/ksyms
|
||||
* sum -s produces the proper 16-bit checksum for large files
|
||||
(this fixes a bug that was introduced in 2.0f)
|
||||
* uniq is now about 3 times faster than the version from 2.0 on Linux systems;
|
||||
the code uses lock-avoiding variants of common I/O functions
|
||||
[2.0.16]
|
||||
* tail -F no longer segfaults
|
||||
[2.0.15]
|
||||
* `head -c N' and `od -N N' now read no more than N bytes of input
|
||||
* tail accepts new option: -F, equivalent to `--follow=name --retry',
|
||||
for compatibility with the FreeBSD and NetBSD versions of tail.
|
||||
* fmt no longer segfaults when using a maximum line width larger than 32767
|
||||
* uniq's --all-repeated option has new modes to delimit groups
|
||||
of duplicate lines: --all-repeated={precede,separate,none(default)}
|
||||
[2.0.14]
|
||||
* sort now accepts long options like "--reverse" and "--".
|
||||
* sort now checks option syntax as POSIX requires, except that (as usual
|
||||
for GNU) options can follow file names unless POSIXLY_CORRECT is set.
|
||||
For example, invalid positional combinations like "sort +1 -r -2" are
|
||||
now rejected as per POSIX.
|
||||
* The next POSIX standard will require that obsolescent 'sort'
|
||||
positional options like +1 be treated as file names, not options.
|
||||
Please use 'sort -k' instead.
|
||||
[2.0.13]
|
||||
* pr accepts new -D or --date option, to specify date format.
|
||||
* The following changes are required by POSIX:
|
||||
- If POSIXLY_CORRECT is set, dates in pr headers now look something like
|
||||
'Dec 4 23:59 2001', with the exact appearance affected by LC_TIME.
|
||||
- pr -h now affects only the center header string, not the entire header.
|
||||
- pr no longer truncates headers.
|
||||
* Spacing in pr headers has been adjusted slightly.
|
||||
* `fmt --prefix=S' now works when S contains a byte with the high bit set
|
||||
[2.0.12]
|
||||
* sort has improved performance when using very little main memory
|
||||
* sort has improved memory management
|
||||
* sort is no longer susceptible to certain denial of service attacks
|
||||
* sort no longer suffers from a race condition whereby an interrupt received
|
||||
during cleanup could cause it to fail to remove temporary files.
|
||||
This problem could arise only on hosts without sigaction.
|
||||
[2.0.11]
|
||||
* sort accepts new -S SIZE option, to specify main-memory usage.
|
||||
[2.0.10]
|
||||
* od is faster and more portable than it was in 2.0.9
|
||||
* tail avoids an uninitialized memory reference
|
||||
[2.0.9]
|
||||
* od now prints valid addresses for offsets of 2^32 and larger, and allows
|
||||
the byte offset (-j) and byte count (-N) arguments to be 2^32 and larger.
|
||||
* tail now works with line and byte counts of 2^32 and larger, on systems
|
||||
with large file support
|
||||
* join now works with an 8-bit delimiter
|
||||
* fix a compilation failure on some Solaris systems with wc.c
|
||||
[2.0.8]
|
||||
* od now supports 8-byte integers, assuming they're printable with e.g., %lld
|
||||
* new program: sha1sum
|
||||
* wc accepts new -m option: count (potentially multi-byte) characters
|
||||
* wc's `--chars' option is now equivalent to -m, not --bytes as it used to be
|
||||
* `cat -n' works properly when processing 2^31 or more lines
|
||||
[2.0g]
|
||||
* sort's --help output now warns that it is locale-aware
|
||||
* tail: fix a buffer underrun error that occurred on an empty pipe,
|
||||
also thanks to bounded pointers
|
||||
* pr: fix a bounds violation found by Greg McGary's bounded-pointers-enabled gcc
|
||||
It could have caused (with low probability) the columns on the last page of
|
||||
output *not* to be `balanced' when they should have been.
|
||||
* sort: if the -T tmpdir option is given multiple times, all the given
|
||||
directories are used; this can improve performance for huge sort/merges.
|
||||
[2.0f]
|
||||
* all programs fail when printing --help or --version output to a full device
|
||||
* cut no longer gets a segfault under some circumstances
|
||||
* unexpand accepts new option: --first-only
|
||||
[2.0e]
|
||||
* `tail -f directory' no longer gets a failed assertion
|
||||
* sort: big performance improvement when sorting many small files;
|
||||
from Charles Randall
|
||||
* configure and portability changes in m4/ and lib/
|
||||
[2.0d]
|
||||
* preliminary sort performance improvements
|
||||
* tsort now works more like the traditional UNIX tsort. Before it would
|
||||
exit when it found a loop. Now it continues and outputs all items.
|
||||
* unexpand no longer infloops on certain sequences of white space
|
||||
* unified lib/: now that directory and most of the configuration framework
|
||||
is common between fileutils, textutils, and sh-utils
|
||||
[2.0c]
|
||||
* include lib/nanosleep.h.
|
||||
[2.0b]
|
||||
* portability tweaks for error.c vs. systems with deficient strerror_r
|
||||
[2.0a]
|
||||
* `tail --follow=name' no longer gets a failed assertion for a
|
||||
dev,inode-reusing race condition
|
||||
* sort and comm no longer consider newlines to be part of the line,
|
||||
as this requirement will likely be removed from POSIX.2.
|
||||
This undoes some changes made for textutils 1.22m and 1.22n.
|
||||
* tail's (short only) -f option no longer accepts an optional argument,
|
||||
so e.g., `tail -fn 2 file' works again.
|
||||
* tail no longer refuses to operate on certain types of files
|
||||
* fixed bug in tsort's handling of cycles
|
||||
Changes in release 2.0
|
||||
[1.22q]
|
||||
* HPUX portability fix: md5sum would dump core due to use of libc's getline
|
||||
[1.22p]
|
||||
* portability fixes from Paul Eggert based largely on tar-1.13 reports
|
||||
* `tail --pid=PID' now works even when PID belongs to some other user
|
||||
[1.22o]
|
||||
* tail accepts new option: --pid=PID
|
||||
[1.22n]
|
||||
* tail accepts the following new options (some of which were added in 1.22g):
|
||||
--retry
|
||||
--follow[={name|descriptor}]
|
||||
--max-unchanged-stats=N
|
||||
--max-consecutive-size-changes=N
|
||||
--sleep-interval=S
|
||||
* wc uses the POSIX-mandated output format when POSIXLY_CORRECT is set
|
||||
* To maintain compatibility with sort, comm and join now obey the LC_COLLATE
|
||||
locale, and comm now considers newlines to be part of the lines.
|
||||
* use lib/memchr.c only if it's not provided by the system -- this means
|
||||
that on systems with a fast library memchr function you may notice an
|
||||
improvement. If you use a system with a buggy or signifcantly slower
|
||||
memchr, please report it.
|
||||
[1.22m]
|
||||
* sort now considers newlines to be part of the line, as required by POSIX.2.
|
||||
E.g. a line starting with a tab now sorts before an empty line,
|
||||
since tab precedes newline in the ASCII collating sequence.
|
||||
* sort handles NUL bytes correctly when configured/compiled with --enable-nls
|
||||
* fix typos in my version of AC_SEARCH_LIBS.
|
||||
* fix dates on config files so builders don't need autoconf/automake
|
||||
[1.22l]
|
||||
* sort no longer autodetects the locale of numbers and months,
|
||||
as that conflicts with POSIX.2
|
||||
* `join -tC' now works when input contains trailing spaces
|
||||
* portability tweaks for Irix's cc
|
||||
[1.22k]
|
||||
* `sort -n' works with negative numbers when configured/compiled
|
||||
with --enable-nls
|
||||
* head accepts byte and line counts of type uintmax_t (so up to 2^64 - 1)
|
||||
[1.22j]
|
||||
* tail: fix bug introduced in 1.22i
|
||||
[1.22i]
|
||||
* tail now terminates in `yes > k & sleep 1; tail -2c k'
|
||||
* `tail -f' now ensures that stdout is unbuffered
|
||||
* fix a bug in cut to allow use of 8-bit delimiters
|
||||
* pr accepts POSIX compliant options -s and -w,
|
||||
the new capital letter options -J, -S and _W turn off the
|
||||
unexpected interferences of the small letter options -s and -w
|
||||
if used together with the column options.
|
||||
* pr output has been adapted to other UNIXes in some cases.
|
||||
[1.22h]
|
||||
* portability tweaks
|
||||
* Window/NT/DOS support
|
||||
[1.22g]
|
||||
* uniq accepts new option: --all-repeated (-D).
|
||||
* Windows/DOS portability fixes
|
||||
* new program: tsort
|
||||
* tail has several new options
|
||||
* md5sum can handle file names with embedded backslash characters
|
||||
* pr accepts long option names (see `pr --help')
|
||||
* new program: ptx (moved to this package from being its own distribution)
|
||||
[1.22f]
|
||||
* cut accepts new --output-delimiter=STR option
|
||||
* `sort -o no-such-file no-such-file' now fails, as it should
|
||||
* fix pr bug: pr -td didn't double space
|
||||
* fix tac bug when using -b, -r, and -s SEPARATOR
|
||||
* fix sort bug whereby using key-local `d' option would cause following
|
||||
key specs to be ignored when any two keys (in the `d'-modified test)
|
||||
compared equal.
|
||||
[1.22e]
|
||||
* remove maintainer mode
|
||||
[1.22d]
|
||||
* wc accepts new option: --max-line-length (-L)
|
||||
* sort can sort according to your locale if your C library supports that
|
||||
[1.22c]
|
||||
[1.22b]
|
||||
* od supports a new trailing `z' character in a type specification:
|
||||
$ od -tx1z .
|
||||
0000000 be ef c6 0f fd f9 d7 e0 ec cb f3 c6 00 db e8 00 >................<
|
||||
0000020 00 00 d2 00 00 00 00 00 00 00 00 00 00 00 00 00 >................<
|
||||
0000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >................<
|
||||
*
|
||||
0000600 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 cc >..............5.<
|
||||
0000620 05 63 76 74 2e 6f 00 00 29 ac 08 70 72 6f 6a 65 >.cvt.o..)..proje<
|
||||
0000640 63 74 73 00 00 00 18 9a 05 63 76 74 2e 63 00 00 >cts......cvt.c..<
|
||||
0000660 18 d9 03 52 43 53 00 00 18 c0 05 78 2e 64 61 74 >...RCS.....x.dat<
|
||||
|
||||
[1.22a]
|
||||
* sort -c reports both the number and the contents of the first out-of-order
|
||||
line, in addition to the file name.
|
||||
* `head -c 4096m' is no longer treated just like `head -c 0'
|
||||
now it gets a diagnostic about 4096m being too large.
|
||||
* pr: For compatibility (also more POSIX compliant): Include default
|
||||
separator `TAB' when merging lines of full length.
|
||||
* When POSIXLY_CORRECT is not set, tail -N now accepts more than one file
|
||||
argument, to be consistent with the way head -N works. If POSIXLY_CORRECT
|
||||
is set, using two or more file arguments with the obsolescent form (-N)
|
||||
evokes an error. To avoid the warning or failure, use the POSIX -n N option
|
||||
or the GNU --lines=N option.
|
||||
|
||||
Changes in release 1.22
|
||||
[1.21a]
|
||||
* Fix a bug in tail when invoked with an argument like `+NUMBERc'
|
||||
* Add test suite for tail
|
||||
|
||||
Changes in release 1.21
|
||||
* Using --program-prefix no longer applies the prefix twice
|
||||
|
||||
Changes in release 1.20
|
||||
* fix pr: -l now uses total number of lines per page also with -f
|
||||
* fix pr: use left-hand-side truncation of header string to avoid line
|
||||
overflow
|
||||
* fix pr: it now accepts `form feeds set in input files', also with -m
|
||||
and multiple form feeds at different pages in each file
|
||||
* pr now accepts: -h "", print a blank line header
|
||||
* pr: when skipping pages (+FIRST_PAGE option) line counting (-n option)
|
||||
starts with 1st line of input file (not of 1st page printed) by default
|
||||
* pr accepts new option: -N, start printing with an optional line number
|
||||
* pr -t retains `form feeds set in input files' (`don't destroy page layout')
|
||||
* pr accepts new option: -T, equivalent to -t, but eliminate also form feeds
|
||||
(`clear file')
|
||||
* pr accepts the extension: +FIRST_PAGE[:LAST_PAGE]
|
||||
* pr -w and -s option disentangled (`use a separator' no longer destroys
|
||||
column alignment)
|
||||
* pr accepts new option: -j, merge lines of full length
|
||||
* pr accepts the extension: -s[STRING], use separator string instead of
|
||||
character only
|
||||
* pr -b is no longer an independent option, balancing is always used
|
||||
with -COLUMN (a requirement of unrestricted use of form feeds)
|
||||
* pr accepts new option: --test, to run the pr tests with a constant
|
||||
header string
|
||||
* join passes all of its tests on Alpha OSF 4.0.
|
||||
* sort no longer improperly ignores blanks in determining starting and ending
|
||||
positions for keys with explicit character offsets
|
||||
* fix bug in csplit with regexp and negative offset that led to infinite loop
|
||||
Changes in test release 1.19q
|
||||
* fix bug in sort -c that sometimes resulted in a segfault
|
||||
Changes in test release 1.19p
|
||||
* md5sum's --string option is being deprecated and is no longer documented.
|
||||
It is still accepted, but will be removed altogether in 1.22.
|
||||
* tr '[:lower:]' '[:upper:]' no longer fails when LC_CTYPE is set to
|
||||
iso_8859_1 on Solaris -- or any other character set with differing
|
||||
numbers of uppercase and lowercase characters
|
||||
* split and tail diagnose unrecognized multiplier suffixes, in e.g.,
|
||||
`split --bytes=1M' (should be `-b 1m' or `--bytes=1m')
|
||||
* fix bug in md5sum's handling of partial reads
|
||||
* fix bug in treatment by sort -f of bytes with high-bit set
|
||||
* update configuration system to use automake's aclocal program
|
||||
* configure performs sanity check on CC and CFLAGS to avoid a misleading
|
||||
failure that suggested cross-compiling was the cause
|
||||
* distribute test suites for cut, join, sort, and tr
|
||||
* unexpand no longer gets in endless loop
|
||||
* when verifying checksums, md5sum uses the binary mode flag from the
|
||||
input stream rather than the one from the command line
|
||||
|
||||
Changes in release 1.19
|
||||
* md5sum can verify digests of files with names containing newline characters
|
||||
* update from gettext-0.10.20.
|
||||
|
||||
Changes in release 1.18
|
||||
* when building sort, link with -lm on systems that use the replacement strtod
|
||||
* update from gettext-0.10.17.
|
||||
|
||||
Changes in release 1.17
|
||||
* include texinfo.tex in the distribution
|
||||
|
||||
Changes in release 1.16
|
||||
* sort is compatible with Unix sort when a key-end spec refers to the N'th
|
||||
character in a field that has fewer than N characters
|
||||
* tail with old-style options like -20k and +31m operates on units of bytes,
|
||||
as the --help usage message says. Before, it used units of lines.
|
||||
|
||||
Changes in release 1.15
|
||||
* od gives better diagnostics for invalid format specs
|
||||
* uses automake-generated Makefile templates
|
||||
* configure takes a new option: --enable-maintainer-mode
|
||||
* fix a bug in fmt when prefix has trailing white space
|
||||
* internationalized diagnostic messages
|
||||
* fix a couple bugs in tr involving use of -c and/or -d flags -- see ChangeLog
|
||||
* diagnose some improper or questionable invocations of csplit
|
||||
* properly handle `echo |csplit - 1 1', rather than aborting
|
||||
* fix join: without -t it now ignores leading blanks
|
||||
* sort accepts new option: -z for NUL terminated records
|
||||
* join accepts new option: --ignore-case, -i
|
||||
* uniq accepts new option: --ignore-case, -i
|
||||
|
||||
User-visible changes in release 1.14
|
||||
* sort -i and sort -d properly order strings containing ignored characters
|
||||
* nl: rename misleading --first-page=N option to --starting-line-number=N.
|
||||
* sort diagnoses invalid arguments to -k, then fails
|
||||
* sort -n properly orders invalid integers with respect to valid integers
|
||||
* sorting works with character offsets larger than corresponding field width
|
||||
* sort's -b option and `b' modifier work
|
||||
* sort -k2,2 works.
|
||||
* csplit detects integer overflow when converting command line arguments
|
||||
* sort accepts new option/flag, -g, for sorting numbers in scientific notation
|
||||
* join accepts POSIX `-o 0' field specifier.
|
||||
* tr 'a[b*512]' '[a*]' < /dev/null terminates
|
||||
* tr '[:*3][:digit:]' 'a-m' and tr 'a[=*2][=c=]' 'xyyz' no longer fail
|
||||
* special characters in tr's string1 and string2 may be escaped with backslash
|
||||
|
||||
User-visible changes in release 1.13
|
||||
* md5sum: with --check, distinguish between open/read failure and bad checksum
|
||||
* md5sum: remove -h, -s, -v short options
|
||||
* md5sum: rename --verbose to --warn, --quiet to --status
|
||||
* md5sum --check fails if it finds no properly formatted checksum lines
|
||||
* sort -c prints `disorder on...' message on standard error, not stdout
|
||||
* sort -k works as described in the texinfo documentation
|
||||
* tail works on NetBSD
|
||||
* md5sum reads and writes (de facto) standard Plumb/Lankester format
|
||||
* sort accepts -.1 +.2 options for compatibility
|
||||
* od works properly when dump limit is specified and is a multiple of
|
||||
bytes_per_block (set by --width, 16 by default).
|
||||
|
||||
User-visible changes in release 1.12
|
||||
* sort no longer reports spurious errors on Ultrix systems
|
||||
* new program: md5sum
|
||||
* all --help messages have been improved
|
||||
* join's -a1 and -a2 options work
|
||||
* tr '[:upper:]' '[:lower:]' no longer reads uninitialized memory
|
||||
* sort properly handles command line arguments like `+7.2n'
|
||||
* fmt properly formats paragraphs not terminated by a newline
|
||||
* tail -f flushes stdout before sleeping so that it will output partial
|
||||
lines sooner
|
||||
* sort properly orders fields where one field is a proper prefix of the other
|
||||
* sort properly interprets field offsets specified via the -k option
|
||||
* dd, od, and tail work on systems for which off_t is long long (e.g. BSD4.4)
|
||||
* wc is faster when not counting words
|
||||
* wc now works even when file pointer isn't at beginning of file
|
||||
* expand no longer seg faults with very long tab lists
|
||||
|
||||
User-visible changes in release 1.11
|
||||
* fmt is built
|
||||
|
||||
User-visible changes in release 1.10
|
||||
* skeletal texinfo documentation (mainly just the `invoking' nodes)
|
||||
* new program: fmt
|
||||
* tail -f on multiple files reports file truncation
|
||||
* tail -q has been fixed so it never prints headers
|
||||
* wc -c is much faster when operating on non-regular files
|
||||
* unexpand gives a diagnostic (rather than a segfault) when given a name of
|
||||
a nonexistent file.
|
||||
* cat, csplit, head, split, sum, tac, tail, tr, and wc no longer fail
|
||||
gratuitously when continued after a suspended read or write system call.
|
||||
* cut interprets -d '' to mean `use the NUL byte as the delimiter' rather
|
||||
than reporting that no delimiter was specified and failing.
|
||||
* `echo a:b:c: | cut -d: -f3,4' prints `c:'. Before it printed just `c'.
|
||||
* cut has been rewritten, is markedly faster for large inputs, and passes a
|
||||
fairly large test suite.
|
||||
* sort properly handles the argument to the -T option.
|
||||
|
||||
Major changes in release 1.9.1:
|
||||
* cut no longer ignores the last line of input when that line lacks a
|
||||
trailing newline character
|
||||
|
||||
Major changes in release 1.9:
|
||||
* `echo a:b:c: | cut -d: -f3-' prints `c:' and
|
||||
`echo a:b | cut -d: -f1' prints `a'.
|
||||
* the command `printf '\t\n' |fold -w n' now terminates.
|
||||
Before, it wouldn't stop for n less than 8.
|
||||
* sort accepts and ignores -y[string] options for compatibilty with Solaris.
|
||||
* cat -v /dev/null works on more systems
|
||||
* od's --compatible (-C) flag renamed to --traditional (no short option)
|
||||
* --help and --version exit successfully
|
||||
* --help gives a one-line description of each option and shows the
|
||||
correspondence between short and long-named options.
|
||||
* fix bug in cut. Now `echo 'a:b:c:' | cut -d: -f3-' works.
|
||||
Before it printed `c' instead of `c:'
|
||||
* csplit allows repeat counts to be specified via `{*}'.
|
||||
* csplit accepts a new option, --suffix=format that supercedes the
|
||||
--digits option. The --digits option will continue to work.
|
||||
* csplit accepts a new option, --elide-empty-files.
|
||||
* configure uses config.h, so DEFS won't exceed preprocessor limits of
|
||||
some compilers on the number of symbols defined via -D.
|
||||
* work around problem where $(srcdir)/config.h was used instead of
|
||||
../config.h -- this happened only when building in a subdirectory
|
||||
and when config.h remained in $(srcdir) from a previous ./configure.
|
||||
|
||||
Major changes in release 1.8:
|
||||
* added non-ANSIfied version of memchr.c from GNU libc.
|
||||
|
||||
Major changes in release 1.7:
|
||||
* none
|
||||
Major changes in release 1.6:
|
||||
* with the --version option programs print the version and exit immediately
|
||||
* pr -2a really terminates
|
||||
* pr -n produces multi-column output
|
||||
|
||||
Major changes in release 1.5:
|
||||
* sort is 8-bit clean
|
||||
* sort's -n and -M options no longer imply -b
|
||||
* several bugs in sort have been fixed
|
||||
* all programs accept --help and --version options
|
||||
* od --compatible accepts pre-POSIX arguments
|
||||
* pr -2a terminates
|
||||
|
||||
Major changes in release 1.4:
|
||||
* add od and cksum programs
|
||||
* move cmp to GNU diff distribution
|
||||
* tail -f works for multiple files
|
||||
* pr prints the file name in error messages
|
||||
* fix some off by 1 errors in pr and fold
|
||||
* optimize wc -c on regular files
|
||||
* sort handles `-' argument correctly
|
||||
* sort supports -T option
|
||||
* tr ranges like a-a work
|
||||
* tr x '' fails gracefully
|
||||
* default sum output format is BSD compatible
|
||||
* paste -d '' works
|
41
contrib/gnu-sort/README
Normal file
41
contrib/gnu-sort/README
Normal file
@ -0,0 +1,41 @@
|
||||
These are the GNU text file (actually, file contents) processing
|
||||
utilities. Most of these programs have significant advantages over
|
||||
their Unix counterparts, such as greater speed, additional options,
|
||||
and fewer arbitrary limits.
|
||||
|
||||
The programs that can be built with this package are: cat, cksum, comm,
|
||||
csplit, cut, expand, fmt, fold, head, join, md5sum, nl, od, paste, pr,
|
||||
ptx, sort, split, sum, tac, tail, tr, tsort, unexpand, uniq, and wc.
|
||||
|
||||
See the file NEWS for a list of major changes in the current release.
|
||||
|
||||
See the file INSTALL for compilation and installation instructions.
|
||||
|
||||
I M P O R T A N T:
|
||||
|
||||
Some Cray C compilers lack support for a 32-bit arithmetic type.
|
||||
Since gettext requires such a type, you should use the --disable-nls
|
||||
option when invoking configure on such systems.
|
||||
|
||||
The textutils are intended to be POSIX.2 compliant (with BSD and other
|
||||
extensions), like the rest of the GNU system. They are almost there,
|
||||
but a few incompatibilities remain.
|
||||
|
||||
Note that the man pages are now automatically generated from templates
|
||||
and from the --help usage message. Patches to the template files (man/*.x)
|
||||
are welcome. However, the authoritative documentation is in texinfo form
|
||||
in the doc directory.
|
||||
|
||||
These programs all recognize the `--version' option. When reporting
|
||||
bugs, please include in the subject line both the package name/version
|
||||
and the name of the program for which you found a problem.
|
||||
|
||||
For general documentation on the coding and usage standards
|
||||
this distribution follows, see the GNU standards document
|
||||
http://www.gnu.org/prep/standards.html, and the documentation
|
||||
for automake and autoconf:
|
||||
http://www.gnu.org/software/autoconf/autoconf.html,
|
||||
http://www.gnu.org/software/automake/automake.html.
|
||||
|
||||
Mail suggestions and bug reports for these programs to
|
||||
bug-textutils@gnu.org.
|
3
contrib/gnu-sort/README-alpha
Normal file
3
contrib/gnu-sort/README-alpha
Normal file
@ -0,0 +1,3 @@
|
||||
This is a test release of this package.
|
||||
|
||||
Please send comments and problem reports to bug-textutils@gnu.org.
|
340
contrib/gnu-sort/THANKS
Normal file
340
contrib/gnu-sort/THANKS
Normal file
@ -0,0 +1,340 @@
|
||||
These people have contributed to the GNU fileutils, textutils,
|
||||
and/or sh-utils packages. Some have reported problems, others have
|
||||
contributed improvements to the documentation, actual code, and even
|
||||
complete programs. Those contributions are described in the ChangeLog
|
||||
files. If your name has been left out, if you'd rather not be listed,
|
||||
or if you'd prefer a different address be used, please let me know.
|
||||
Some old names and addresses are still in the ChangeLog.
|
||||
|
||||
Achim Blumensath blume@corona.oche.de
|
||||
Adam Klein aklein@debian.org
|
||||
Akim Demaille demaille@inf.enst.fr
|
||||
Alain Magloire alain@qnx.com
|
||||
Alan Iwi iwi@atm.ox.ac.uk
|
||||
Albert Hopkins ahopkins@dynacare.com
|
||||
Alberto Accomazzi alberto@cfa0.harvard.edu
|
||||
aldomel aldomel@ix.netcom.com
|
||||
Alen Muzinic zveki@fly.cc.fer.hr
|
||||
Alexandre Duret-Lutz duret_g@epita.fr
|
||||
Alexey Solovyov alekso@math.uu.se
|
||||
Andre Novaes Cunha Andre.Cunha@br.global-one.net
|
||||
Andreas Gruenbacher ag@bestbits.at
|
||||
Andreas Jaeger jaeger@gnu.org
|
||||
Andreas Luik luik@isa.de
|
||||
Andreas Schwab schwab@suse.de
|
||||
Andreas Stolcke stolcke@ICSI.Berkeley.EDU
|
||||
Andres Soolo andres@soolo.matti.ee
|
||||
Andrew Burgess aab@cichlid.com
|
||||
Andrew Dalke dalke@bioreason.com
|
||||
Andrew Pham andpha@us.ibm.com
|
||||
Andrew Tridgell tridge@samba.org
|
||||
Andries Brouwer Andries.Brouwer@cwi.nl
|
||||
Andy Longton alongton@metamark.com
|
||||
Antonio Rendas ajrendas@yahoo.com
|
||||
Ariel Faigon ariel@cthulhu.engr.sgi.com
|
||||
Arne H. Juul arnej@solan.unit.no
|
||||
Arne Henrik Juul arnej@imf.unit.no
|
||||
Arthur Pool pool@commerce.uq.edu.au
|
||||
Austin Donnelly Austin.Donnelly@cl.cam.ac.uk
|
||||
Axel Kittenberger Anshil@gmx.net
|
||||
Bauke Jan Douma bjdouma@xs4all.nl
|
||||
Bengt Martensson bengt@mathematik.uni-Bremen.de
|
||||
Bernd Leibing bernd.leibing@rz.uni-ulm.de
|
||||
Bernhard Baehr bernhard.baehr@gmx.de
|
||||
Bernhard Rosenkraenzer bero@redhat.de
|
||||
Bill Peters peters@gaffel.as.arizona.edu
|
||||
Bjorn Helgaas helgaas@rsn.hp.com
|
||||
Bob McCracken kerouac@ravenet.com
|
||||
Bob Proulx rwp@fc.hp.com
|
||||
Branden Robinson branden@necrotic.deadbeast.net
|
||||
Brendan O'Dea bod@compusol.com.au
|
||||
Brian Kimball bfk@footbag.org
|
||||
Brian Youmans 3diff@gnu.org
|
||||
Bruno Haible haible@clisp.cons.org
|
||||
Carl Johnson carlj@cjlinux.home.org
|
||||
Carl Lowenstein cdl@mpl.UCSD.EDU
|
||||
Carlos Canau Carlos.Canau@relay.puug.pt
|
||||
Charles Karney karney@pppl.gov
|
||||
Charles Randall crandall@matchlogic.com
|
||||
Chip Salzenberg chip@valinux.com
|
||||
Chris Faylor cgf@cygnus.com
|
||||
Chris J. Bednar cjb@AdvancedDataSolutions.com
|
||||
Chris Sylvain csylvain@umm.edu
|
||||
Chris Yeo cyeo@biking.org
|
||||
Christi Alice Scarborough christi@chiark.greenend.org.uk
|
||||
Christian Harkort christian.harkort@web.de
|
||||
Christian Krackowizer ckrackowiz@std.schuler-ag.com
|
||||
Christian Rose menthos@menthos.com
|
||||
Christian von Roques roques@pond.sub.org
|
||||
Chuck Hedrick hedrick@klinzhai.rutgers.edu
|
||||
Clark Morgan cmorgan@aracnet.com
|
||||
Colin Plumb colin@nyx.net
|
||||
Colin Watson cjw44@riva.ucam.org
|
||||
Collin Rogowski collin@rogowski.de
|
||||
Dale Scheetz dwarf@polaris.net
|
||||
Dan Hagerty hag@gnu.ai.it.edu
|
||||
Dan Pascu dan@services.iiruc.ro
|
||||
Daniel Bergstrom noa@melody.se
|
||||
Darren Salt ds@youmustbejoking.demon.co.uk
|
||||
David Dyck dcd@tc.fluke.COM
|
||||
David Godfrey dave@delta.demon.co.uk
|
||||
David Luyer david_luyer@pacific.net.au
|
||||
Dennis Henriksen opus@flamingo.osrl.dk
|
||||
Derek Clegg dclegg@next.com
|
||||
Dick Streefland dick_streefland@tasking.com
|
||||
Dirk Lattermann dlatt@t-online.de
|
||||
Dirk-Jan Faber djfaber@snow.nl
|
||||
Dan Jacobson http://www.geocities.com/jidani
|
||||
Don Parsons dparsons@synapse.kent.edu
|
||||
Donni Erpel donald@appc11.gsi.de
|
||||
Doug McLaren dougmc@comco.com
|
||||
Dragos Harabor dharabor@us.oracle.com
|
||||
Ed Avis epa98@doc.ic.ac.uk
|
||||
Edzer Pebesma Edzer.Pebesma@rivm.nl
|
||||
Eirik Fuller eirik@hackrat.com
|
||||
Eivind eivindt@multinet.no
|
||||
Eli Zaretskii eliz@is.elta.co.il
|
||||
Emile LeBlanc leblanc@math.toronto.edu
|
||||
Eric Backus ericb@lsid.hp.com
|
||||
Eric G. Miller egm2@jps.net
|
||||
Eric Pemente pemente@northpark.edu
|
||||
Eric S. Raymond esr@snark.thyrsus.com
|
||||
Erik Bennett bennett@cvo.oneworld.com
|
||||
Erik Corry erik@kroete2.freinet.de
|
||||
Felix Lee flee@teleport.com
|
||||
Fletcher Mattox fletcher@cs.utexas.edu
|
||||
Florin Iucha fiucha@hsys.mic.ro
|
||||
Frank Adler fadler@allesklar.de
|
||||
Frank T Lofaro ftlofaro@snooks.Egr.UNLV.EDU
|
||||
François Pinard pinard@iro.umontreal.ca
|
||||
Fred Fish fnf@ninemoons.com
|
||||
Frederik Eaton frederik@caltech.edu
|
||||
Frédéric L. W. Meunier 0@pervalidus.net
|
||||
Gabor Z. Papp gzp@gzp.org.hu
|
||||
Galen Hazelwood galenh@micron.net
|
||||
Gary Anderson ganderson@clark.net
|
||||
Gaël Quéri gqueri@mail.dotcom.fr
|
||||
Geoff Kuenning geoff@cs.hmc.edu
|
||||
Geoff Odhner geoff@franklin.com
|
||||
Geoff Whale geoffw@cse.unsw.EDU.AU
|
||||
Gerhard Poul gpoul@gnu.org
|
||||
Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp
|
||||
GOTO Masanori gotom@debian.or.jp
|
||||
Greg Louis glouis@dynamicro.on.ca
|
||||
Greg McGary gkm@gnu.org
|
||||
Greg Troxel gdt@bbn.com
|
||||
Greg Wooledge gawooledge@sherwin.com
|
||||
Gregory Leblanc gleblanc@cu-portland.edu
|
||||
Göran Uddeborg goeran@uddeborg.pp.se
|
||||
H. J. Lu hjl@valinux.com
|
||||
Hans Verkuil hans@wyst.hobby.nl
|
||||
Harry Liu rliu@lek.ugcs.caltech.edu
|
||||
Herbert Xu herbert@gondor.apana.org.au
|
||||
Holger Berger hberger@ess.nec.de
|
||||
Hon-Yin Kok hkok@yoda.unl.edu
|
||||
Hugh Daniel hugh@xanadu.com
|
||||
Ian Bruce ian.bruce@myrealbox.com
|
||||
Ian Jackson ijackson@chiark.greenend.org.uk
|
||||
Ian Lance Taylor ian@cygnus.com
|
||||
Ian Turner vectro@pipeline.com
|
||||
James james@albion.glarp.com
|
||||
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
|
||||
James Sneeringer jvs@ocslink.com
|
||||
James Tanis jtt@soscorp.com
|
||||
James Youngman james+usenet@free-lunch.demon.co.uk
|
||||
Jamie Lokier jamie@imbolc.ucc.ie
|
||||
Jan Fedak J.Fedak@sh.cvut.cz
|
||||
Jan Nieuwenhuizen janneke@gnu.org
|
||||
Janos Farkas chexum@shadow.banki.hu
|
||||
Jarkko Hietaniemi jhi@epsilon.hut.fi
|
||||
Jeff Moore jbm@mordor.com
|
||||
Jeff Sheinberg jeffsh@erols.com
|
||||
Jens Schmidt jms@jsds.hamburg.com
|
||||
Jerome Abela abela@hsc.fr
|
||||
Jesse Thilo jgt2@eecs.lehigh.edu
|
||||
Jie Xu xuj@iag.net
|
||||
Jim Blandy jimb@cyclic.com
|
||||
Jim Dennis jimd@starshine.org
|
||||
Joakim Rosqvist dvljrt@cs.umu.se
|
||||
Jochen Hein jochen@jochen.org
|
||||
Joe Orton joe@orton.demon.co.uk
|
||||
Johan Danielsson joda@pdc.kth.se
|
||||
John Bley jbb6@acpub.duke.edu
|
||||
John David Anglin dave.anglin@nrc.ca
|
||||
John Gatewood Ham zappaman@alphabox.compsci.buu.ac.th
|
||||
John Gotts jgotts@umich.edu
|
||||
John Kendall kendall@capps.com
|
||||
John Kodis kodis@acm.org
|
||||
John Murphy jam@philabs.research.philips.com
|
||||
John Roll john@panic.harvard.edu
|
||||
John Salmon johns@mullet.anu.edu.au
|
||||
John Summerfield summer@OS2.ami.com.au
|
||||
Joost van Baal joostvb@xs4all.nl
|
||||
Jorge Stolfi stolfi@ic.unicamp.br
|
||||
Joseph S. Myers jsm28@cam.ac.uk
|
||||
Juan F. Codagnone juam@arnet.com.ar
|
||||
Jungshik Shin jshin@pantheon.yale.edu
|
||||
Jürgen Fluk louis@dachau.marco.de
|
||||
jvogel jvogel@linkny.com
|
||||
Kai-Uwe Rommel rommel@informatik.tu-muenchen.de
|
||||
Kai Henningsen kai@debian.org
|
||||
Kalle Olavi Niemitalo tosi@stekt.oulu.fi
|
||||
Kamal Paul Nigam Kamal_Paul_Nigam@gs35.sp.cs.cmu.edu
|
||||
Karl Eichwalder keichwa@gmx.net
|
||||
Karl Heuer kwzh@gnu.org
|
||||
Karl-Michael Schneider schneide@phil.uni-passau.de
|
||||
Karsten Thygesen karthy@kom.auc.dk
|
||||
Kaveh R. Ghazi ghazi@caip.rutgers.edu
|
||||
Keith Owens kaos@audio.apana.org.au
|
||||
Keith Thompson kst@sdsc.edu
|
||||
Ken Pizzini kenp@halcyon.com
|
||||
Kjetil Torgrim Homme kjetilho@ifi.uio.no
|
||||
Kristoffer Rose kris@diku.dk
|
||||
??? kytek@cybercomm.net
|
||||
Larry McVoy lm@sgi.com
|
||||
Lars Hecking lhecking@nmrc.ucc.ie
|
||||
Lehti Rami rammer@cs.tut.fi
|
||||
Leonard N. Zubkoff lnz@dandelion.com
|
||||
Lorne Baker lbaker@nitro.avint.net
|
||||
M. P. Suzuki mpsuzuki@hiroshima-u.ac.jp
|
||||
Maciej Kwapulinski pikpok@univ.gda.pl
|
||||
Manas Garg manas@cygsoft.com
|
||||
Manfred Hollstein manfred@s-direktnet.de
|
||||
Marc Boucher marc@mbsi.ca
|
||||
Marc Olzheim marcolz@stack.nl
|
||||
Marco Franzen Marco.Franzen@Thyron.com
|
||||
Marcus Daniels marcus@ee.pdx.edu
|
||||
Mark A. Thomas thommark@access.digex.net
|
||||
Mark D. Roth roth@uiuc.edu
|
||||
Mark Harris mark@monitor.designacc.com
|
||||
Mark Hewitt mhewitt@armature.com
|
||||
Mark Hounschell markh@compro.net
|
||||
Mark Kettenis kettenis@phys.uva.nl
|
||||
Mark Nudelman marknu@flash.net
|
||||
Mark W. Eichin eichin@cygnus.com
|
||||
Markus Demleitner msdemlei@auriga.ari.uni-heidelberg.de
|
||||
Martin martin@dresden.nacamar.de
|
||||
Martin Gallant martyg@goodbit.net
|
||||
Martin Hippe martin.hippe@schlund.de
|
||||
Martin Mitchell martin@debian.org
|
||||
Martin P.J. Zinser zinser@decus.de
|
||||
Marty Leisner leisner@sdsp.mc.xerox.com
|
||||
Masami Takikawa takikawm@CS.ORST.EDU
|
||||
Mate Wierdl mw@moni.msci.memphis.edu
|
||||
Matej Vela mvela@public.srce.hr
|
||||
Matt Perry matt@primefactor.com
|
||||
Matt Schalit mschalit@pacbell.net
|
||||
Matthew Braun matthew@ans.net
|
||||
Matthew Clarke Matthew_Clarke@mindlink.bc.ca
|
||||
Matthew S. Levine mslevine@theory.lcs.mit.edu
|
||||
Matthew Smith matts@bluesguitar.org
|
||||
Matthew Swift swift@alum.mit.edu
|
||||
Mattias Wadenstein maswan@acc.umu.se
|
||||
Matthias Urlichs smurf@noris.de
|
||||
Meelis Roos mroos@tartu.cyber.ee
|
||||
Michael ??? michael@roka.net
|
||||
Michael Deutschmann michael@talamasca.ocis.net
|
||||
Michael Gaughen mgaughen@polyserve.com
|
||||
Michael Hasselberg mikelh@zonta.ping.de
|
||||
Michael Hohn hohn@math.utah.edu
|
||||
Michael J. Croghan mcroghan@usatoday.com
|
||||
Michael Steffens michael.steffens@s.netic.de
|
||||
Michael Stone mstone@debian.org
|
||||
Michael Stutz stutz@dsl.org
|
||||
Michael Veksler mveksler@techunix.technion.ac.il
|
||||
Michel Robitaille robitail@IRO.UMontreal.CA
|
||||
Michiel Bacchiani bacchian@raven.bu.edu
|
||||
Miles Bader miles@gnu.ai.mit.edu
|
||||
Minh Tran-Le tranle@intellicorp.com
|
||||
Morten Welinder terra@diku.dk
|
||||
Neal H Walfield neal@cs.uml.edu
|
||||
Nelson H. F. Beebe beebe@math.utah.edu
|
||||
Nick Lawes nlawes@silverplatter.com
|
||||
Niklas Edmundsson nikke@acc.umu.se
|
||||
Noah Friedman friedman@splode.com
|
||||
Noel Cragg noel@red-bean.com
|
||||
Olav Morkrid olav@funcom.com
|
||||
Ole Laursen olau@hardworking.dk
|
||||
Oskar Liljeblad osk@hem.passagen.se
|
||||
Ørn E. Hansen oehansen@daimi.aau.dk
|
||||
Paul Eggert eggert@twinsun.com
|
||||
Paul Nevai nevai@ops.mps.ohio-state.edu
|
||||
Paul Sauer paul@alexa.com
|
||||
Paul Slootman paul@debian.org
|
||||
Pawel Prokop pablo@wizard.ae.krakow.pl
|
||||
Per Cederqvist ceder@lysator.liu.se
|
||||
Per Kristian Hove perhov@math.ntnu.no
|
||||
Peter Eriksson peter@ifm.liu.se
|
||||
Peter Moulder reiter@netspace.net.au
|
||||
Peter Samuelson psamuels@sampo.creighton.edu
|
||||
Peter Seebach seebs@taniemarie.solon.com
|
||||
Petter Reinholdtsen pere@hungry.com
|
||||
Phelippe Neveu pneveu@pcigeomatics.com
|
||||
Phil Richards phil.richards@vf.vodafone.co.uk
|
||||
Philippe De Muyter phdm@macqel.be
|
||||
Philippe Schnoebelen Philippe.Schnoebelen@imag.fr
|
||||
Piergiorgio Sartor sartor@sony.de
|
||||
Piotr Kwapulinski kwap@univ.gda.pl
|
||||
Prashant TR tr@eth.net
|
||||
Rainer Orth ro@TechFak.Uni-Bielefeld.DE
|
||||
Ralf W. Stephan stephan@tmt.de
|
||||
Ralph Loader loader@maths.ox.ac.uk
|
||||
Raul Miller moth@magenta.com
|
||||
Richard Braakman dark@xs4all.nl
|
||||
Richard Dawe richdawe@bigfoot.com
|
||||
Richard J. Rauenzahn rrauenza@hairball.cup.hp.com
|
||||
Richard Sharman rsharman@magmacom.com
|
||||
Rick Sladkey jrs@world.std.com
|
||||
Rik Faith faith@cs.unc.edu
|
||||
Risto Kankkunen kankkune@lingsoft.fi
|
||||
Robert H. de Vries robert@and.nl
|
||||
Rogier Wolff R.E.Wolff@BitWizard.nl
|
||||
Roland Huebner ro-huebner@gmx.de
|
||||
Ronald F. Guilmette rfg@netcom.com
|
||||
Ross Alexander r.alexander@auckland.ac.nz
|
||||
Ross Paterson rap@doc.ic.ac.uk
|
||||
Ross Ridge rridge@calum.csclub.uwaterloo.ca
|
||||
Sami Farin sfarin@ratol.fi
|
||||
Samuli Karkkainen Samuli.Karkkainen@hut.fi
|
||||
Sander van Malssen svm@kozmix.ow.nl
|
||||
Santiago Vila Doncel sanvila@unex.es
|
||||
Savochkin Andrey Vladimirovich saw@msu.ru
|
||||
Scott Lurndal slurn@griffin.engr.sgi.com
|
||||
Soeren Sonnenburg sonnenburg@informatik.hu-berlin.de
|
||||
Stéphane Chazelas Stephane_CHAZELAS@yahoo.fr
|
||||
Stephen Eglen eglen@pcg.wustl.edu
|
||||
Stephen Gildea gildea@stop.mail-abuse.org
|
||||
Stephen Smoogen ??????????
|
||||
Steve McConnel steve@acadcomp.sil.org
|
||||
Stuart Kemp skemp@peter.bmc.com
|
||||
Tadayoshi Funaba tadf@kt.rim.or.jp
|
||||
Theodore Ts'o tytso@rsts-11.mit.edu
|
||||
Thomas Bushnell thomas@gnu.ai.mit.edu
|
||||
Thomas Quinot thomas@Cuivre.FR.EU.ORG
|
||||
Tim Smithers mouse@dmouse.com.au
|
||||
Tim Waugh twaugh@redhat
|
||||
Todd A. Jacobs tjacobs@codegnome.org
|
||||
Tom Quinn trq@dionysos.thphys.ox.ac.uk
|
||||
Ton Hospel thospel@mail.dma.be
|
||||
Tony Leneis tony@plaza.ds.adp.com
|
||||
Tony Robinson ajr@eng.cam.ac.uk
|
||||
Torbjorn Granlund tege@nada.kth.se
|
||||
Torbjorn Lindgren tl@funcom.no
|
||||
Torsten Landschoff torsten@pclab.ifg.uni-kiel.de
|
||||
Ulrich Drepper drepper@gnu.org
|
||||
Urs Thuermann urs@isnogud.escape.de
|
||||
Uwe H. Steinfeld usteinfeld@gmx.net
|
||||
Vesselin Atanasov vesselin@bgnet.bg
|
||||
Vin Shelton acs@alumni.princeton.edu
|
||||
Volker Borchert bt@teknon.de
|
||||
Wayne Stewart wstewa@atl.com
|
||||
Wenjun Zheng zwj@yahoo.com
|
||||
Werner Almesberger Werner.Almesberger@epfl.ch
|
||||
Wichert Akkerman wichert@cistron.nl
|
||||
Will Edgington wedgingt@acm.org
|
||||
William Bader william@nscs.fast.net
|
||||
William Dowling will@franklin.com
|
||||
William Lewis wiml@omnigroup.com
|
||||
Wolfram Kleff kleff@cs.uni-bonn.de
|
||||
Won-kyu Park wkpark@chem.skku.ac.kr
|
||||
Zvi Har'El rl@math.technion.ac.il
|
93
contrib/gnu-sort/TODO
Normal file
93
contrib/gnu-sort/TODO
Normal file
@ -0,0 +1,93 @@
|
||||
Tasks for GNU textutils (listed in no particular order):
|
||||
|
||||
write texinfo documentation for sha1sum
|
||||
|
||||
Something that I would really appreciate is if someone would run the
|
||||
Open Group's VSC-lite test suite against the fileutils and textutils
|
||||
and report the failures.
|
||||
|
||||
http://www.opengroup.org/testing/downloads/vsclite.html
|
||||
|
||||
I've been meaning to do it myself for months, but haven't found the time.
|
||||
There's a bit of set-up required, some of which requires root access, e.g.,
|
||||
to create a few test user accounts and some test groups.
|
||||
------------------
|
||||
|
||||
uniq: remove support for obsolescent +N syntax
|
||||
|
||||
add tests for od
|
||||
add some endian-aware tests for od
|
||||
|
||||
tac: Set DONT_UNLINK_WHILE_OPEN when necessary.
|
||||
|
||||
tail: add an option so that using -f on N files doesn't monopolize
|
||||
N file descriptors
|
||||
|
||||
tac: add options to help handle boundary cases
|
||||
E.g., options to distinguish DELIM_STRING is
|
||||
- starter (see existing --before option)
|
||||
- terminator (this is what most people expect wrt NEWLINE
|
||||
- separator (this would make `echo -n a:b:c|tac -s:' print `c:b:a')
|
||||
|
||||
tail: support -r option by librarifying tac and using that
|
||||
|
||||
cut: maybe add an option to say `fields are separated by whitespace'.
|
||||
Of course, that isn't really necessary because you can preprocess
|
||||
cut's input with tr to get the same effect:
|
||||
|
||||
echo 'a b c' |tr -s '[:blank:]' | cut -d ' ' -f 2
|
||||
|
||||
------------
|
||||
|
||||
From: kwzh@gnu.ai.mit.edu (Karl Heuer)
|
||||
Subject: [textutils-1.22] [sort] feature requests
|
||||
To: textutils-bugs@gnu.ai.mit.edu
|
||||
Date: Thu, 5 Jun 97 13:06:51 -0400
|
||||
|
||||
[...]
|
||||
Another feature that I would sometimes find useful: change -c so that
|
||||
it will report up to N instances of disorder before bailing out, where
|
||||
N defaults to 1 but can be set to infinity or to some finite value by
|
||||
another option. (An "instance of disorder" is two adjacent lines that
|
||||
are malsorted; this does not imply that swapping them or removing one
|
||||
or both would cause the list to be sorted. (1 3 5 7 9 0 2 4 6 8) has
|
||||
just one instance of disorder.)
|
||||
|
||||
------------
|
||||
|
||||
Date: Fri, 1 May 1998 20:27:39 -0700 (PDT)
|
||||
From: Paul Rubin <phr@netcom.com>
|
||||
To: gnu@gnu.org
|
||||
Subject: small project suggestion
|
||||
|
||||
Someone should rewrite the "sum" utility to give a choice of
|
||||
different checksum algorithms (it's poorly organized for that now).
|
||||
An experienced programmer could probably do it in a day or so,
|
||||
or it might be a good, self-contained project for someone who is
|
||||
just getting started.
|
||||
|
||||
Algorithms that it should include are:
|
||||
-- the POSIX algorithm
|
||||
-- the BSD algorithm
|
||||
-- CRC32 algorithm (used by pkzip)
|
||||
-- CRC16 (used in TCP/IP)
|
||||
-- possibly other CRC's (like the different CCITT polynomials)
|
||||
-- SHA-1 and MD5 cryptographic hashes (replacing "md5sum").
|
||||
and possibly:
|
||||
-- DSA digital signature based on secret key generated from
|
||||
a passphrase (prompt the user, or read an environment variable).
|
||||
|
||||
|
||||
---------------------
|
||||
|
||||
comm: add an option-enable check for sortedness of input files
|
||||
|
||||
---------------------
|
||||
|
||||
uniq: add a more flexible key selection mechanism
|
||||
|
||||
---------------------
|
||||
|
||||
Charles Randall <crandall@matchlogic.com>
|
||||
is working on making sort more suitable and efficient for very
|
||||
large sets of input data.
|
309
contrib/gnu-sort/lib/argmatch.c
Normal file
309
contrib/gnu-sort/lib/argmatch.c
Normal file
@ -0,0 +1,309 @@
|
||||
/* argmatch.c -- find a match for a string in an array
|
||||
Copyright (C) 1990, 1998, 1999, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@ai.mit.edu>
|
||||
Modified by Akim Demaille <demaille@inf.enst.fr> */
|
||||
|
||||
#include "argmatch.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef STDC_HEADERS
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "quotearg.h"
|
||||
#include "quote.h"
|
||||
#include "unlocked-io.h"
|
||||
|
||||
/* When reporting an invalid argument, show nonprinting characters
|
||||
by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
|
||||
literal_quoting_style. */
|
||||
#ifndef ARGMATCH_QUOTING_STYLE
|
||||
# define ARGMATCH_QUOTING_STYLE locale_quoting_style
|
||||
#endif
|
||||
|
||||
/* The following test is to work around the gross typo in
|
||||
systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE
|
||||
is defined to 0, not 1. */
|
||||
#if !EXIT_FAILURE
|
||||
# undef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
/* Non failing version of argmatch call this function after failing. */
|
||||
#ifndef ARGMATCH_DIE
|
||||
# define ARGMATCH_DIE exit (EXIT_FAILURE)
|
||||
#endif
|
||||
|
||||
#ifdef ARGMATCH_DIE_DECL
|
||||
ARGMATCH_DIE_DECL;
|
||||
#endif
|
||||
|
||||
static void
|
||||
__argmatch_die (void)
|
||||
{
|
||||
ARGMATCH_DIE;
|
||||
}
|
||||
|
||||
/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h.
|
||||
Default to __argmatch_die, but allow caller to change this at run-time. */
|
||||
argmatch_exit_fn argmatch_die = __argmatch_die;
|
||||
|
||||
|
||||
/* If ARG is an unambiguous match for an element of the
|
||||
null-terminated array ARGLIST, return the index in ARGLIST
|
||||
of the matched element, else -1 if it does not match any element
|
||||
or -2 if it is ambiguous (is a prefix of more than one element).
|
||||
If SENSITIVE, comparison is case sensitive.
|
||||
|
||||
If VALLIST is none null, use it to resolve ambiguities limited to
|
||||
synonyms, i.e., for
|
||||
"yes", "yop" -> 0
|
||||
"no", "nope" -> 1
|
||||
"y" is a valid argument, for `0', and "n" for `1'. */
|
||||
|
||||
static int
|
||||
__argmatch_internal (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
int case_sensitive)
|
||||
{
|
||||
int i; /* Temporary index in ARGLIST. */
|
||||
size_t arglen; /* Length of ARG. */
|
||||
int matchind = -1; /* Index of first nonexact match. */
|
||||
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
|
||||
|
||||
arglen = strlen (arg);
|
||||
|
||||
/* Test all elements for either exact match or abbreviated matches. */
|
||||
for (i = 0; arglist[i]; i++)
|
||||
{
|
||||
if (case_sensitive
|
||||
? !strncmp (arglist[i], arg, arglen)
|
||||
: !strncasecmp (arglist[i], arg, arglen))
|
||||
{
|
||||
if (strlen (arglist[i]) == arglen)
|
||||
/* Exact match found. */
|
||||
return i;
|
||||
else if (matchind == -1)
|
||||
/* First nonexact match found. */
|
||||
matchind = i;
|
||||
else
|
||||
{
|
||||
/* Second nonexact match found. */
|
||||
if (vallist == NULL
|
||||
|| memcmp (vallist + valsize * matchind,
|
||||
vallist + valsize * i, valsize))
|
||||
{
|
||||
/* There is a real ambiguity, or we could not
|
||||
disambiguate. */
|
||||
ambiguous = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ambiguous)
|
||||
return -2;
|
||||
else
|
||||
return matchind;
|
||||
}
|
||||
|
||||
/* argmatch - case sensitive version */
|
||||
int
|
||||
argmatch (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
return __argmatch_internal (arg, arglist, vallist, valsize, 1);
|
||||
}
|
||||
|
||||
/* argcasematch - case insensitive version */
|
||||
int
|
||||
argcasematch (const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
return __argmatch_internal (arg, arglist, vallist, valsize, 0);
|
||||
}
|
||||
|
||||
/* Error reporting for argmatch.
|
||||
CONTEXT is a description of the type of entity that was being matched.
|
||||
VALUE is the invalid value that was given.
|
||||
PROBLEM is the return value from argmatch. */
|
||||
|
||||
void
|
||||
argmatch_invalid (const char *context, const char *value, int problem)
|
||||
{
|
||||
char const *format = (problem == -1
|
||||
? _("invalid argument %s for %s")
|
||||
: _("ambiguous argument %s for %s"));
|
||||
|
||||
error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value),
|
||||
quote_n (1, context));
|
||||
}
|
||||
|
||||
/* List the valid arguments for argmatch.
|
||||
ARGLIST is the same as in argmatch.
|
||||
VALLIST is a pointer to an array of values.
|
||||
VALSIZE is the size of the elements of VALLIST */
|
||||
void
|
||||
argmatch_valid (const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
int i;
|
||||
const char *last_val = NULL;
|
||||
|
||||
/* We try to put synonyms on the same line. The assumption is that
|
||||
synonyms follow each other */
|
||||
fprintf (stderr, _("Valid arguments are:"));
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if ((i == 0)
|
||||
|| memcmp (last_val, vallist + valsize * i, valsize))
|
||||
{
|
||||
fprintf (stderr, "\n - `%s'", arglist[i]);
|
||||
last_val = vallist + valsize * i;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, ", `%s'", arglist[i]);
|
||||
}
|
||||
putc ('\n', stderr);
|
||||
}
|
||||
|
||||
/* Never failing versions of the previous functions.
|
||||
|
||||
CONTEXT is the context for which argmatch is called (e.g.,
|
||||
"--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
|
||||
calls the (supposed never to return) function EXIT_FN. */
|
||||
|
||||
int
|
||||
__xargmatch_internal (const char *context,
|
||||
const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
int case_sensitive,
|
||||
argmatch_exit_fn exit_fn)
|
||||
{
|
||||
int res = __argmatch_internal (arg, arglist,
|
||||
vallist, valsize,
|
||||
case_sensitive);
|
||||
if (res >= 0)
|
||||
/* Success. */
|
||||
return res;
|
||||
|
||||
/* We failed. Explain why. */
|
||||
argmatch_invalid (context, arg, res);
|
||||
argmatch_valid (arglist, vallist, valsize);
|
||||
(*exit_fn) ();
|
||||
|
||||
return -1; /* To please the compilers. */
|
||||
}
|
||||
|
||||
/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
|
||||
return the first corresponding argument in ARGLIST */
|
||||
const char *
|
||||
argmatch_to_argument (const char *value,
|
||||
const char *const *arglist,
|
||||
const char *vallist, size_t valsize)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; arglist[i]; i++)
|
||||
if (!memcmp (value, vallist + valsize * i, valsize))
|
||||
return arglist[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
/*
|
||||
* Based on "getversion.c" by David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
*/
|
||||
char *program_name;
|
||||
extern const char *getenv ();
|
||||
|
||||
/* When to make backup files. */
|
||||
enum backup_type
|
||||
{
|
||||
/* Never make backups. */
|
||||
none,
|
||||
|
||||
/* Make simple backups of every file. */
|
||||
simple,
|
||||
|
||||
/* Make numbered backups of files that already have numbered backups,
|
||||
and simple backups of the others. */
|
||||
numbered_existing,
|
||||
|
||||
/* Make numbered backups of every file. */
|
||||
numbered
|
||||
};
|
||||
|
||||
/* Two tables describing arguments (keys) and their corresponding
|
||||
values */
|
||||
static const char *const backup_args[] =
|
||||
{
|
||||
"no", "none", "off",
|
||||
"simple", "never",
|
||||
"existing", "nil",
|
||||
"numbered", "t",
|
||||
0
|
||||
};
|
||||
|
||||
static const enum backup_type backup_vals[] =
|
||||
{
|
||||
none, none, none,
|
||||
simple, simple,
|
||||
numbered_existing, numbered_existing,
|
||||
numbered, numbered
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, const char *const *argv)
|
||||
{
|
||||
const char *cp;
|
||||
enum backup_type backup_type = none;
|
||||
|
||||
program_name = (char *) argv[0];
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if ((cp = getenv ("VERSION_CONTROL")))
|
||||
backup_type = XARGCASEMATCH ("$VERSION_CONTROL", cp,
|
||||
backup_args, backup_vals);
|
||||
|
||||
if (argc == 2)
|
||||
backup_type = XARGCASEMATCH (program_name, argv[1],
|
||||
backup_args, backup_vals);
|
||||
|
||||
printf ("The version control is `%s'\n",
|
||||
ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
129
contrib/gnu-sort/lib/argmatch.h
Normal file
129
contrib/gnu-sort/lib/argmatch.h
Normal file
@ -0,0 +1,129 @@
|
||||
/* argmatch.h -- definitions and prototypes for argmatch.c
|
||||
Copyright (C) 1990, 1998, 1999, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@ai.mit.edu>
|
||||
Modified by Akim Demaille <demaille@inf.enst.fr> */
|
||||
|
||||
#ifndef ARGMATCH_H_
|
||||
# define ARGMATCH_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# include <sys/types.h>
|
||||
|
||||
# ifndef PARAMS
|
||||
# if PROTOTYPES || (defined (__STDC__) && __STDC__)
|
||||
# define PARAMS(args) args
|
||||
# else
|
||||
# define PARAMS(args) ()
|
||||
# endif /* GCC. */
|
||||
# endif /* Not PARAMS. */
|
||||
|
||||
/* Assert there are as many real arguments as there are values
|
||||
(argument list ends with a NULL guard). There is no execution
|
||||
cost, since it will be statically evalauted to `assert (0)' or
|
||||
`assert (1)'. Unfortunately there is no -Wassert-0. */
|
||||
|
||||
# undef ARRAY_CARDINALITY
|
||||
# define ARRAY_CARDINALITY(Array) (sizeof ((Array)) / sizeof (*(Array)))
|
||||
|
||||
# define ARGMATCH_ASSERT(Arglist, Vallist) \
|
||||
assert (ARRAY_CARDINALITY ((Arglist)) == ARRAY_CARDINALITY ((Vallist)) + 1)
|
||||
|
||||
/* Return the index of the element of ARGLIST (NULL terminated) that
|
||||
matches with ARG. If VALLIST is not NULL, then use it to resolve
|
||||
false ambiguities (i.e., different matches of ARG but corresponding
|
||||
to the same values in VALLIST). */
|
||||
|
||||
int argmatch
|
||||
PARAMS ((const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
int argcasematch
|
||||
PARAMS ((const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
|
||||
# define ARGMATCH(Arg, Arglist, Vallist) \
|
||||
argmatch ((Arg), (Arglist), (const char *) (Vallist), sizeof (*(Vallist)))
|
||||
|
||||
# define ARGCASEMATCH(Arg, Arglist, Vallist) \
|
||||
argcasematch ((Arg), (Arglist), (const char *) (Vallist), sizeof (*(Vallist)))
|
||||
|
||||
/* xargmatch calls this function when it fails. This function should not
|
||||
return. By default, this is a function that calls ARGMATCH_DIE which
|
||||
in turn defaults to `exit (EXIT_FAILURE)'. */
|
||||
typedef void (*argmatch_exit_fn) PARAMS ((void));
|
||||
extern argmatch_exit_fn argmatch_die;
|
||||
|
||||
/* Report on stderr why argmatch failed. Report correct values. */
|
||||
|
||||
void argmatch_invalid
|
||||
PARAMS ((const char *context, const char *value, int problem));
|
||||
|
||||
/* Left for compatibility with the old name invalid_arg */
|
||||
|
||||
# define invalid_arg(Context, Value, Problem) \
|
||||
argmatch_invalid ((Context), (Value), (Problem))
|
||||
|
||||
|
||||
|
||||
/* Report on stderr the list of possible arguments. */
|
||||
|
||||
void argmatch_valid
|
||||
PARAMS ((const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
|
||||
# define ARGMATCH_VALID(Arglist, Vallist) \
|
||||
argmatch_valid (Arglist, (const char *) Vallist, sizeof (*(Vallist)))
|
||||
|
||||
|
||||
|
||||
/* Same as argmatch, but upon failure, reports a explanation on the
|
||||
failure, and exits using the function EXIT_FN. */
|
||||
|
||||
int __xargmatch_internal
|
||||
PARAMS ((const char *context,
|
||||
const char *arg, const char *const *arglist,
|
||||
const char *vallist, size_t valsize,
|
||||
int case_sensitive, argmatch_exit_fn exit_fn));
|
||||
|
||||
/* Programmer friendly interface to __xargmatch_internal. */
|
||||
|
||||
# define XARGMATCH(Context, Arg, Arglist, Vallist) \
|
||||
(Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \
|
||||
(const char *) (Vallist), \
|
||||
sizeof (*(Vallist)), \
|
||||
1, argmatch_die)])
|
||||
|
||||
# define XARGCASEMATCH(Context, Arg, Arglist, Vallist) \
|
||||
(Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \
|
||||
(const char *) (Vallist), \
|
||||
sizeof (*(Vallist)), \
|
||||
0, argmatch_die)])
|
||||
|
||||
/* Convert a value into a corresponding argument. */
|
||||
|
||||
const char *argmatch_to_argument
|
||||
PARAMS ((char const *value, const char *const *arglist,
|
||||
const char *vallist, size_t valsize));
|
||||
|
||||
# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \
|
||||
argmatch_to_argument ((Value), (Arglist), \
|
||||
(const char *) (Vallist), sizeof (*(Vallist)))
|
||||
|
||||
#endif /* ARGMATCH_H_ */
|
17
contrib/gnu-sort/lib/closeout.h
Normal file
17
contrib/gnu-sort/lib/closeout.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef CLOSEOUT_H
|
||||
# define CLOSEOUT_H 1
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
void close_stdout_set_status PARAMS ((int status));
|
||||
void close_stdout_set_file_name PARAMS ((const char *file));
|
||||
void close_stdout PARAMS ((void));
|
||||
void close_stdout_status PARAMS ((int status));
|
||||
|
||||
#endif
|
62
contrib/gnu-sort/lib/dup-safer.c
Normal file
62
contrib/gnu-sort/lib/dup-safer.c
Normal file
@ -0,0 +1,62 @@
|
||||
/* Invoke dup, but avoid some glitches.
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifndef STDERR_FILENO
|
||||
# define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
#include <unistd-safer.h>
|
||||
|
||||
/* 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
|
||||
}
|
401
contrib/gnu-sort/lib/error.c
Normal file
401
contrib/gnu-sort/lib/error.c
Normal file
@ -0,0 +1,401 @@
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-1998, 2000, 2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#if HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
#endif
|
||||
#ifdef _LIBC
|
||||
# include <wchar.h>
|
||||
# define mbsrtowcs __mbsrtowcs
|
||||
#endif
|
||||
|
||||
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
|
||||
# if __STDC__
|
||||
# include <stdarg.h>
|
||||
# define VA_START(args, lastarg) va_start(args, lastarg)
|
||||
# else
|
||||
# include <varargs.h>
|
||||
# define VA_START(args, lastarg) va_start(args)
|
||||
# endif
|
||||
#else
|
||||
# define va_alist a1, a2, a3, a4, a5, a6, a7, a8
|
||||
# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS || _LIBC
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#else
|
||||
void exit ();
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "unlocked-io.h"
|
||||
|
||||
#ifndef _
|
||||
# define _(String) String
|
||||
#endif
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
void (*error_print_progname) (
|
||||
#if __STDC__ - 0
|
||||
void
|
||||
#endif
|
||||
);
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
unsigned int error_message_count;
|
||||
|
||||
#ifdef _LIBC
|
||||
/* In the GNU C library, there is a predefined variable for this. */
|
||||
|
||||
# define program_name program_invocation_name
|
||||
# include <errno.h>
|
||||
|
||||
/* In GNU libc we want do not want to use the common name `error' directly.
|
||||
Instead make it a weak alias. */
|
||||
extern void __error (int status, int errnum, const char *message, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message,
|
||||
...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));;
|
||||
# define error __error
|
||||
# define error_at_line __error_at_line
|
||||
|
||||
# ifdef USE_IN_LIBIO
|
||||
# include <libio/iolibio.h>
|
||||
# define fflush(s) _IO_fflush (s)
|
||||
# endif
|
||||
|
||||
#else /* not _LIBC */
|
||||
|
||||
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||
# ifndef HAVE_DECL_STRERROR_R
|
||||
"this configure-time declaration test was not run"
|
||||
# endif
|
||||
char *strerror_r ();
|
||||
# endif
|
||||
|
||||
/* The calling program should define program_name and set it to the
|
||||
name of the executing program. */
|
||||
extern char *program_name;
|
||||
|
||||
# if HAVE_STRERROR_R || defined strerror_r
|
||||
# define __strerror_r strerror_r
|
||||
# else
|
||||
# if HAVE_STRERROR
|
||||
# ifndef HAVE_DECL_STRERROR
|
||||
"this configure-time declaration test was not run"
|
||||
# endif
|
||||
# if !HAVE_DECL_STRERROR
|
||||
char *strerror ();
|
||||
# endif
|
||||
# else
|
||||
static char *
|
||||
private_strerror (int errnum)
|
||||
{
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
|
||||
if (errnum > 0 && errnum <= sys_nerr)
|
||||
return _(sys_errlist[errnum]);
|
||||
return _("Unknown system error");
|
||||
}
|
||||
# define strerror private_strerror
|
||||
# endif /* HAVE_STRERROR */
|
||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||
#endif /* not _LIBC */
|
||||
|
||||
static void
|
||||
print_errno_message (int errnum)
|
||||
{
|
||||
char const *s;
|
||||
|
||||
#if defined HAVE_STRERROR_R || _LIBC
|
||||
char errbuf[1024];
|
||||
# if STRERROR_R_CHAR_P || _LIBC
|
||||
s = __strerror_r (errnum, errbuf, sizeof errbuf);
|
||||
# else
|
||||
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
|
||||
s = errbuf;
|
||||
else
|
||||
s = 0;
|
||||
# endif
|
||||
#else
|
||||
s = strerror (errnum);
|
||||
#endif
|
||||
|
||||
#if !_LIBC
|
||||
if (! s)
|
||||
s = _("Unknown system error");
|
||||
#endif
|
||||
|
||||
#if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
{
|
||||
__fwprintf (stderr, L": %s", s);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf (stderr, ": %s", s);
|
||||
}
|
||||
|
||||
#ifdef VA_START
|
||||
static void
|
||||
error_tail (int status, int errnum, const char *message, va_list args)
|
||||
{
|
||||
# if HAVE_VPRINTF || _LIBC
|
||||
# if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
{
|
||||
# define ALLOCA_LIMIT 2000
|
||||
size_t len = strlen (message) + 1;
|
||||
wchar_t *wmessage = NULL;
|
||||
mbstate_t st;
|
||||
size_t res;
|
||||
const char *tmp;
|
||||
|
||||
do
|
||||
{
|
||||
if (len < ALLOCA_LIMIT)
|
||||
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||
else
|
||||
{
|
||||
if (wmessage != NULL && len / 2 < ALLOCA_LIMIT)
|
||||
wmessage = NULL;
|
||||
|
||||
wmessage = (wchar_t *) realloc (wmessage,
|
||||
len * sizeof (wchar_t));
|
||||
|
||||
if (wmessage == NULL)
|
||||
{
|
||||
fputws_unlocked (L"out of memory\n", stderr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
memset (&st, '\0', sizeof (st));
|
||||
tmp =message;
|
||||
}
|
||||
while ((res = mbsrtowcs (wmessage, &tmp, len, &st)) == len);
|
||||
|
||||
if (res == (size_t) -1)
|
||||
/* The string cannot be converted. */
|
||||
wmessage = (wchar_t *) L"???";
|
||||
|
||||
__vfwprintf (stderr, wmessage, args);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
vfprintf (stderr, message, args);
|
||||
# else
|
||||
_doprnt (message, args, stderr);
|
||||
# endif
|
||||
va_end (args);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
print_errno_message (errnum);
|
||||
# if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
putwc (L'\n', stderr);
|
||||
else
|
||||
# endif
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||
format string with optional args.
|
||||
If ERRNUM is nonzero, print its corresponding system error message.
|
||||
Exit with status STATUS if it is nonzero. */
|
||||
/* VARARGS */
|
||||
void
|
||||
#if defined VA_START && __STDC__
|
||||
error (int status, int errnum, const char *message, ...)
|
||||
#else
|
||||
error (status, errnum, message, va_alist)
|
||||
int status;
|
||||
int errnum;
|
||||
char *message;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifdef VA_START
|
||||
va_list args;
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
# ifdef USE_IN_LIBIO
|
||||
_IO_flockfile (stderr);
|
||||
# else
|
||||
__flockfile (stderr);
|
||||
# endif
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s: ", program_name);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
}
|
||||
|
||||
#ifdef VA_START
|
||||
VA_START (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
#else
|
||||
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
print_errno_message (errnum);
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# ifdef USE_IN_LIBIO
|
||||
_IO_funlockfile (stderr);
|
||||
# else
|
||||
__funlockfile (stderr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
int error_one_per_line;
|
||||
|
||||
void
|
||||
#if defined VA_START && __STDC__
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
#else
|
||||
error_at_line (status, errnum, file_name, line_number, message, va_alist)
|
||||
int status;
|
||||
int errnum;
|
||||
const char *file_name;
|
||||
unsigned int line_number;
|
||||
char *message;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifdef VA_START
|
||||
va_list args;
|
||||
#endif
|
||||
|
||||
if (error_one_per_line)
|
||||
{
|
||||
static const char *old_file_name;
|
||||
static unsigned int old_line_number;
|
||||
|
||||
if (old_line_number == line_number
|
||||
&& (file_name == old_file_name
|
||||
|| strcmp (old_file_name, file_name) == 0))
|
||||
/* Simply return and print nothing. */
|
||||
return;
|
||||
|
||||
old_file_name = file_name;
|
||||
old_line_number = line_number;
|
||||
}
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
# ifdef USE_IN_LIBIO
|
||||
_IO_flockfile (stderr);
|
||||
# else
|
||||
__flockfile (stderr);
|
||||
# endif
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s: ", program_name);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "%s:", program_name);
|
||||
}
|
||||
|
||||
if (file_name != NULL)
|
||||
{
|
||||
#if _LIBC && USE_IN_LIBIO
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s:%d: ", file_name, line_number);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "%s:%d: ", file_name, line_number);
|
||||
}
|
||||
|
||||
#ifdef VA_START
|
||||
VA_START (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
#else
|
||||
fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
print_errno_message (errnum);
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# ifdef USE_IN_LIBIO
|
||||
_IO_funlockfile (stderr);
|
||||
# else
|
||||
__funlockfile (stderr);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Make the weak alias. */
|
||||
# undef error
|
||||
# undef error_at_line
|
||||
weak_alias (__error, error)
|
||||
weak_alias (__error_at_line, error_at_line)
|
||||
#endif
|
78
contrib/gnu-sort/lib/error.h
Normal file
78
contrib/gnu-sort/lib/error.h
Normal file
@ -0,0 +1,78 @@
|
||||
/* Declaration for error-reporting function
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef _ERROR_H
|
||||
#define _ERROR_H 1
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
|
||||
/* Print a message with `fprintf (stderr, FORMAT, ...)';
|
||||
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
|
||||
|
||||
extern void error (int status, int errnum, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
|
||||
extern void error_at_line (int status, int errnum, const char *fname,
|
||||
unsigned int lineno, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
extern void (*error_print_progname) (void);
|
||||
|
||||
#else
|
||||
void error ();
|
||||
void error_at_line ();
|
||||
extern void (*error_print_progname) ();
|
||||
#endif
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
extern unsigned int error_message_count;
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
extern int error_one_per_line;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* error.h */
|
76
contrib/gnu-sort/lib/fopen-safer.c
Normal file
76
contrib/gnu-sort/lib/fopen-safer.c
Normal file
@ -0,0 +1,76 @@
|
||||
/* Invoke fopen, but avoid some glitches.
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <unistd-safer.h>
|
||||
|
||||
#ifndef STDERR_FILENO
|
||||
# define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdio-safer.h>
|
||||
|
||||
/* 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;
|
||||
}
|
772
contrib/gnu-sort/lib/getopt.c
Normal file
772
contrib/gnu-sort/lib/getopt.c
Normal file
@ -0,0 +1,772 @@
|
||||
/* Getopt for GNU.
|
||||
NOTE: getopt is now part of the C library, so if you don't know what
|
||||
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
|
||||
before changing it!
|
||||
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
|
||||
Ditto for AIX 3.2 and <stdlib.h>. */
|
||||
#ifndef _NO_PROTO
|
||||
#define _NO_PROTO
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined (__STDC__) || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Don't include stdlib.h for non-GNU C libraries because some of them
|
||||
contain conflicting prototypes for getopt. */
|
||||
#include <stdlib.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)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
||||
but it behaves differently for the user, since it allows the user
|
||||
to intersperse the options with the other arguments.
|
||||
|
||||
As `getopt' works, it permutes the elements of ARGV so that,
|
||||
when it is done, all the options precede everything else. Thus
|
||||
all application programs are extended to handle flexible argument order.
|
||||
|
||||
Setting the environment variable POSIXLY_CORRECT disables permutation.
|
||||
Then the behavior is completely standard.
|
||||
|
||||
GNU application programs can use a third alternative mode in which
|
||||
they can distinguish the relative order of options and other arguments. */
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
char *optarg = NULL;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns EOF, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
/* XXX 1003.2 says this must be 1 before any call. */
|
||||
int optind = 0;
|
||||
|
||||
/* The next char to be scanned in the option-element
|
||||
in which the last option character we returned was found.
|
||||
This allows us to pick up the scan where we left off.
|
||||
|
||||
If this is zero, or a null string, it means resume the scan
|
||||
by advancing to the next ARGV-element. */
|
||||
|
||||
static char *nextchar;
|
||||
|
||||
/* Callers store zero here to inhibit the error message
|
||||
for unrecognized options. */
|
||||
|
||||
int opterr = 1;
|
||||
|
||||
/* Set to an option character which was unrecognized.
|
||||
This must be initialized on some systems to avoid linking in the
|
||||
system's own getopt implementation. */
|
||||
|
||||
int optopt = '?';
|
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
This is what Unix does.
|
||||
This mode of operation is selected by either setting the environment
|
||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
||||
of the list of option characters.
|
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we scan,
|
||||
so that eventually all the non-options are at the end. This allows options
|
||||
to be given in any order, even with programs that were not written to
|
||||
expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were written
|
||||
to expect options and other ARGV-elements in any order and that care about
|
||||
the ordering of the two. We describe each non-option ARGV-element
|
||||
as if it were the argument of an option with character code 1.
|
||||
Using `-' as the first character of the list of option characters
|
||||
selects this mode of operation.
|
||||
|
||||
The special argument `--' forces an end of option-scanning regardless
|
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
|
||||
|
||||
static enum
|
||||
{
|
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||
} ordering;
|
||||
|
||||
/* Value of POSIXLY_CORRECT environment variable. */
|
||||
static char *posixly_correct;
|
||||
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* We want to avoid inclusion of string.h with non-GNU libraries
|
||||
because there are many ways it can cause trouble.
|
||||
On some systems, it contains special magic macros that don't work
|
||||
in GCC. */
|
||||
#include <string.h>
|
||||
#define my_index strchr
|
||||
#else
|
||||
|
||||
/* Avoid depending on library functions or files
|
||||
whose names are inconsistent. */
|
||||
|
||||
char *getenv ();
|
||||
|
||||
static char *
|
||||
my_index (str, chr)
|
||||
const char *str;
|
||||
int chr;
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
if (*str == chr)
|
||||
return (char *) str;
|
||||
str++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If using GCC, we can safely declare strlen this way.
|
||||
If not using GCC, it is ok not to declare it. */
|
||||
#ifdef __GNUC__
|
||||
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
|
||||
That was relevant to code that was here before. */
|
||||
#if !defined (__STDC__) || !__STDC__
|
||||
/* gcc with -traditional declares the built-in strlen to return int,
|
||||
and has done so at least since version 2.4.5. -- rms. */
|
||||
extern int strlen (const char *);
|
||||
#endif /* not __STDC__ */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif /* not __GNU_LIBRARY__ */
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
been skipped. `first_nonopt' is the index in ARGV of the first of them;
|
||||
`last_nonopt' is the index after the last of them. */
|
||||
|
||||
static int first_nonopt;
|
||||
static int last_nonopt;
|
||||
|
||||
/* Exchange two adjacent subsequences of ARGV.
|
||||
One subsequence is elements [first_nonopt,last_nonopt)
|
||||
which contains all the non-options that have been skipped so far.
|
||||
The other is elements [last_nonopt,optind), which contains all
|
||||
the options processed since those non-options were skipped.
|
||||
|
||||
`first_nonopt' and `last_nonopt' are relocated so that they describe
|
||||
the new indices of the non-options in ARGV after they are moved. */
|
||||
|
||||
static void
|
||||
exchange (argv)
|
||||
char **argv;
|
||||
{
|
||||
int bottom = first_nonopt;
|
||||
int middle = last_nonopt;
|
||||
int top = optind;
|
||||
char *tem;
|
||||
|
||||
/* Exchange the shorter segment with the far end of the longer segment.
|
||||
That puts the shorter segment into the right place.
|
||||
It leaves the longer segment in the right place overall,
|
||||
but it consists of two parts that need to be swapped next. */
|
||||
|
||||
while (top > middle && middle > bottom)
|
||||
{
|
||||
if (top - middle > middle - bottom)
|
||||
{
|
||||
/* Bottom segment is the short one. */
|
||||
int len = middle - bottom;
|
||||
register int i;
|
||||
|
||||
/* Swap it with the top part of the top segment. */
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tem = argv[bottom + i];
|
||||
argv[bottom + i] = argv[top - (middle - bottom) + i];
|
||||
argv[top - (middle - bottom) + i] = tem;
|
||||
}
|
||||
/* Exclude the moved bottom segment from further swapping. */
|
||||
top -= len;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Top segment is the short one. */
|
||||
int len = top - middle;
|
||||
register int i;
|
||||
|
||||
/* Swap it with the bottom part of the bottom segment. */
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
tem = argv[bottom + i];
|
||||
argv[bottom + i] = argv[middle + i];
|
||||
argv[middle + i] = tem;
|
||||
}
|
||||
/* Exclude the moved top segment from further swapping. */
|
||||
bottom += len;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update records for the slots the non-options now occupy. */
|
||||
|
||||
first_nonopt += (optind - last_nonopt);
|
||||
last_nonopt = optind;
|
||||
}
|
||||
|
||||
/* Initialize the internal data when the first call is made. */
|
||||
|
||||
static const char *
|
||||
_getopt_initialize (optstring)
|
||||
const char *optstring;
|
||||
{
|
||||
/* Start processing options with ARGV-element 1 (since ARGV-element 0
|
||||
is the program name); the sequence of previously skipped
|
||||
non-option ARGV-elements is empty. */
|
||||
|
||||
first_nonopt = last_nonopt = optind = 1;
|
||||
|
||||
nextchar = NULL;
|
||||
|
||||
posixly_correct = getenv ("POSIXLY_CORRECT");
|
||||
|
||||
/* Determine how to handle the ordering of options and nonoptions. */
|
||||
|
||||
if (optstring[0] == '-')
|
||||
{
|
||||
ordering = RETURN_IN_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (optstring[0] == '+')
|
||||
{
|
||||
ordering = REQUIRE_ORDER;
|
||||
++optstring;
|
||||
}
|
||||
else if (posixly_correct != NULL)
|
||||
ordering = REQUIRE_ORDER;
|
||||
else
|
||||
ordering = PERMUTE;
|
||||
|
||||
return optstring;
|
||||
}
|
||||
|
||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
||||
given in OPTSTRING.
|
||||
|
||||
If an element of ARGV starts with '-', and is not exactly "-" or "--",
|
||||
then it is an option element. The characters of this element
|
||||
(aside from the initial '-') are option characters. If `getopt'
|
||||
is called repeatedly, it returns successively each of the option characters
|
||||
from each of the option elements.
|
||||
|
||||
If `getopt' finds another option character, it returns that character,
|
||||
updating `optind' and `nextchar' so that the next call to `getopt' can
|
||||
resume the scan with the following option character or ARGV-element.
|
||||
|
||||
If there are no more option characters, `getopt' returns `EOF'.
|
||||
Then `optind' is the index in ARGV of the first ARGV-element
|
||||
that is not an option. (The ARGV-elements have been permuted
|
||||
so that those that are not options now come last.)
|
||||
|
||||
OPTSTRING is a string containing the legitimate option characters.
|
||||
If an option character is seen that is not listed in OPTSTRING,
|
||||
return '?' after printing an error message. If you set `opterr' to
|
||||
zero, the error message is suppressed but we still return '?'.
|
||||
|
||||
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
|
||||
so the following text in the same ARGV-element, or the text of the following
|
||||
ARGV-element, is returned in `optarg'. Two colons mean an option that
|
||||
wants an optional arg; if there is text in the current ARGV-element,
|
||||
it is returned in `optarg', otherwise `optarg' is set to zero.
|
||||
|
||||
If OPTSTRING starts with `-' or `+', it requests different methods of
|
||||
handling the non-option ARGV-elements.
|
||||
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
|
||||
|
||||
Long-named options begin with `--' instead of `-'.
|
||||
Their names may be abbreviated as long as the abbreviation is unique
|
||||
or is an exact match for some defined option. If they have an
|
||||
argument, it follows the option name in the same ARGV-element, separated
|
||||
from the option name by a `=', or else the in next ARGV-element.
|
||||
When `getopt' finds a long-named option, it returns 0 if that option's
|
||||
`flag' field is nonzero, the value of the option's `val' field
|
||||
if the `flag' field is zero.
|
||||
|
||||
The elements of ARGV aren't really const, because we permute them.
|
||||
But we pretend they're const in the prototype to be compatible
|
||||
with other systems.
|
||||
|
||||
LONGOPTS is a vector of `struct option' terminated by an
|
||||
element containing a name which is zero.
|
||||
|
||||
LONGIND returns the index in LONGOPT of the long-named option found.
|
||||
It is only valid when a long-named option has been found by the most
|
||||
recent call.
|
||||
|
||||
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
|
||||
long-named options. */
|
||||
|
||||
int
|
||||
_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *optstring;
|
||||
const struct option *longopts;
|
||||
int *longind;
|
||||
int long_only;
|
||||
{
|
||||
optarg = NULL;
|
||||
|
||||
if (optind == 0)
|
||||
{
|
||||
optstring = _getopt_initialize (optstring);
|
||||
optind = 1; /* Don't scan ARGV[0], the program name. */
|
||||
}
|
||||
|
||||
if (nextchar == NULL || *nextchar == '\0')
|
||||
{
|
||||
/* Advance to the next ARGV-element. */
|
||||
|
||||
if (ordering == PERMUTE)
|
||||
{
|
||||
/* If we have just processed some options following some non-options,
|
||||
exchange them so that the options come first. */
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange ((char **) argv);
|
||||
else if (last_nonopt != optind)
|
||||
first_nonopt = optind;
|
||||
|
||||
/* Skip any additional non-options
|
||||
and extend the range of non-options previously skipped. */
|
||||
|
||||
while (optind < argc
|
||||
&& (argv[optind][0] != '-' || argv[optind][1] == '\0'))
|
||||
optind++;
|
||||
last_nonopt = optind;
|
||||
}
|
||||
|
||||
/* The special ARGV-element `--' means premature end of options.
|
||||
Skip it like a null option,
|
||||
then exchange with previous non-options as if it were an option,
|
||||
then skip everything else like a non-option. */
|
||||
|
||||
if (optind != argc && !strcmp (argv[optind], "--"))
|
||||
{
|
||||
optind++;
|
||||
|
||||
if (first_nonopt != last_nonopt && last_nonopt != optind)
|
||||
exchange ((char **) argv);
|
||||
else if (first_nonopt == last_nonopt)
|
||||
first_nonopt = optind;
|
||||
last_nonopt = argc;
|
||||
|
||||
optind = argc;
|
||||
}
|
||||
|
||||
/* If we have done all the ARGV-elements, stop the scan
|
||||
and back over any non-options that we skipped and permuted. */
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
/* Set the next-arg-index to point at the non-options
|
||||
that we previously skipped, so the caller will digest them. */
|
||||
if (first_nonopt != last_nonopt)
|
||||
optind = first_nonopt;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* If we have come to a non-option and did not permute it,
|
||||
either stop the scan or describe it to the caller and pass it by. */
|
||||
|
||||
if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
|
||||
{
|
||||
if (ordering == REQUIRE_ORDER)
|
||||
return EOF;
|
||||
optarg = argv[optind++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* We have found another option-ARGV-element.
|
||||
Skip the initial punctuation. */
|
||||
|
||||
nextchar = (argv[optind] + 1
|
||||
+ (longopts != NULL && argv[optind][1] == '-'));
|
||||
}
|
||||
|
||||
/* Decode the current option-ARGV-element. */
|
||||
|
||||
/* Check whether the ARGV-element is a long option.
|
||||
|
||||
If long_only and the ARGV-element has the form "-f", where f is
|
||||
a valid short option, don't consider it an abbreviated form of
|
||||
a long option that starts with f. Otherwise there would be no
|
||||
way to give the -f short option.
|
||||
|
||||
On the other hand, if there's a long option "fubar" and
|
||||
the ARGV-element is "-fu", do consider that an abbreviation of
|
||||
the long option, just like "--fu", and not "-f" with arg "u".
|
||||
|
||||
This distinction seems to be the most useful approach. */
|
||||
|
||||
if (longopts != NULL
|
||||
&& (argv[optind][1] == '-'
|
||||
|| (long_only && (argv[optind][2]
|
||||
|| !my_index (optstring, argv[optind][1])))))
|
||||
{
|
||||
char *nameend;
|
||||
const struct option *p;
|
||||
const struct option *pfound = NULL;
|
||||
int exact = 0;
|
||||
int ambig = 0;
|
||||
int indfound;
|
||||
int option_index;
|
||||
|
||||
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
|
||||
/* Do nothing. */ ;
|
||||
|
||||
#ifdef lint
|
||||
indfound = 0; /* Avoid spurious compiler warning. */
|
||||
#endif
|
||||
|
||||
/* Test all long options for either exact match
|
||||
or abbreviated matches. */
|
||||
for (p = longopts, option_index = 0; p->name; p++, option_index++)
|
||||
if (!strncmp (p->name, nextchar, nameend - nextchar))
|
||||
{
|
||||
if (nameend - nextchar == strlen (p->name))
|
||||
{
|
||||
/* Exact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
exact = 1;
|
||||
break;
|
||||
}
|
||||
else if (pfound == NULL)
|
||||
{
|
||||
/* First nonexact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else
|
||||
/* Second or later nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
|
||||
if (ambig && !exact)
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
|
||||
argv[0], argv[optind]);
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
|
||||
if (pfound != NULL)
|
||||
{
|
||||
option_index = indfound;
|
||||
optind++;
|
||||
if (*nameend)
|
||||
{
|
||||
/* Don't test has_arg with >, because some C compilers don't
|
||||
allow it to be used on enums. */
|
||||
if (pfound->has_arg)
|
||||
optarg = nameend + 1;
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `--%s' doesn't allow an argument\n"),
|
||||
argv[0], pfound->name);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
_("%s: option `%c%s' doesn't allow an argument\n"),
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
else if (pfound->has_arg == 1)
|
||||
{
|
||||
if (optind < argc)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr,
|
||||
_("%s: option `%s' requires an argument\n"),
|
||||
argv[0], argv[optind - 1]);
|
||||
nextchar += strlen (nextchar);
|
||||
return optstring[0] == ':' ? ':' : '?';
|
||||
}
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
if (longind != NULL)
|
||||
*longind = option_index;
|
||||
if (pfound->flag)
|
||||
{
|
||||
*(pfound->flag) = pfound->val;
|
||||
return 0;
|
||||
}
|
||||
return pfound->val;
|
||||
}
|
||||
|
||||
/* Can't find it as a long option. If this is not getopt_long_only,
|
||||
or the option starts with '--' or is not a valid short
|
||||
option, then it's an error.
|
||||
Otherwise interpret it as a short option. */
|
||||
if (!long_only || argv[optind][1] == '-'
|
||||
|| my_index (optstring, *nextchar) == NULL)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
|
||||
argv[0], nextchar);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
|
||||
argv[0], argv[optind][0], nextchar);
|
||||
}
|
||||
nextchar = (char *) "";
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at and handle the next short option-character. */
|
||||
|
||||
{
|
||||
char c = *nextchar++;
|
||||
char *temp = my_index (optstring, c);
|
||||
|
||||
/* Increment `optind' when we start to process its last character. */
|
||||
if (*nextchar == '\0')
|
||||
++optind;
|
||||
|
||||
if (temp == NULL || c == ':')
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (posixly_correct)
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
fprintf (stderr, _("%s: illegal option -- %c\n"),
|
||||
argv[0], c);
|
||||
else
|
||||
fprintf (stderr, _("%s: invalid option -- %c\n"),
|
||||
argv[0], c);
|
||||
}
|
||||
optopt = c;
|
||||
return '?';
|
||||
}
|
||||
if (temp[1] == ':')
|
||||
{
|
||||
if (temp[2] == ':')
|
||||
{
|
||||
/* This is an option that accepts an argument optionally. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
optarg = NULL;
|
||||
nextchar = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an option that requires an argument. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
/* If we end this ARGV-element by taking the rest as an arg,
|
||||
we must advance to the next element now. */
|
||||
optind++;
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
/* 1003.2 specifies the format of this message. */
|
||||
fprintf (stderr,
|
||||
_("%s: option requires an argument -- %c\n"),
|
||||
argv[0], c);
|
||||
}
|
||||
optopt = c;
|
||||
if (optstring[0] == ':')
|
||||
c = ':';
|
||||
else
|
||||
c = '?';
|
||||
}
|
||||
else
|
||||
/* We already incremented `optind' once;
|
||||
increment it again when taking next ARGV-elt as argument. */
|
||||
optarg = argv[optind++];
|
||||
nextchar = NULL;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
getopt (argc, argv, optstring)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *optstring;
|
||||
{
|
||||
return _getopt_internal (argc, argv, optstring,
|
||||
(const struct option *) 0,
|
||||
(int *) 0,
|
||||
0);
|
||||
}
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
/* Compile with -DTEST to make an executable for use in testing
|
||||
the above definition of `getopt'. */
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
|
||||
c = getopt (argc, argv, "abc:d:0123456789");
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
131
contrib/gnu-sort/lib/getopt.h
Normal file
131
contrib/gnu-sort/lib/getopt.h
Normal file
@ -0,0 +1,131 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns EOF, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
#if defined (__STDC__) && __STDC__
|
||||
const char *name;
|
||||
#else
|
||||
char *name;
|
||||
#endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
#else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt ();
|
||||
#endif /* __GNU_LIBRARY__ */
|
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
extern int getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
#else /* not __STDC__ */
|
||||
extern int getopt ();
|
||||
extern int getopt_long ();
|
||||
extern int getopt_long_only ();
|
||||
|
||||
extern int _getopt_internal ();
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GETOPT_H */
|
182
contrib/gnu-sort/lib/getopt1.c
Normal file
182
contrib/gnu-sort/lib/getopt1.c
Normal file
@ -0,0 +1,182 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#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 <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
char *getenv ();
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == EOF)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
87
contrib/gnu-sort/lib/hard-locale.c
Normal file
87
contrib/gnu-sort/lib/hard-locale.c
Normal file
@ -0,0 +1,87 @@
|
||||
/* hard-locale.c -- Determine whether a locale is hard.
|
||||
Copyright 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <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_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
/* Return nonzero if the current CATEGORY locale is hard, i.e. if you
|
||||
can't get away with assuming traditional C or POSIX behavior. */
|
||||
int
|
||||
hard_locale (int category)
|
||||
{
|
||||
#if ! (defined ENABLE_NLS && HAVE_SETLOCALE)
|
||||
return 0;
|
||||
#else
|
||||
|
||||
int hard = 1;
|
||||
char const *p = setlocale (category, 0);
|
||||
|
||||
if (p)
|
||||
{
|
||||
# if defined __GLIBC__ && __GLIBC__ >= 2
|
||||
if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
|
||||
hard = 0;
|
||||
# else
|
||||
char *locale = alloca (strlen (p) + 1);
|
||||
strcpy (locale, p);
|
||||
|
||||
/* Temporarily set the locale to the "C" and "POSIX" locales to
|
||||
find their names, so that we can determine whether one or the
|
||||
other is the caller's locale. */
|
||||
if (((p = setlocale (category, "C")) && strcmp (p, locale) == 0)
|
||||
|| ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0))
|
||||
hard = 0;
|
||||
|
||||
/* Restore the caller's locale. */
|
||||
setlocale (category, locale);
|
||||
# endif
|
||||
}
|
||||
|
||||
return hard;
|
||||
|
||||
#endif
|
||||
}
|
18
contrib/gnu-sort/lib/hard-locale.h
Normal file
18
contrib/gnu-sort/lib/hard-locale.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef HARD_LOCALE_H_
|
||||
# define HARD_LOCALE_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
int hard_locale PARAMS ((int));
|
||||
|
||||
#endif /* HARD_LOCALE_H_ */
|
366
contrib/gnu-sort/lib/human.c
Normal file
366
contrib/gnu-sort/lib/human.c
Normal file
@ -0,0 +1,366 @@
|
||||
/* human.c -- print human readable file size
|
||||
|
||||
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Originally contributed by lm@sgi.com;
|
||||
--si, output block size selection, and large file support
|
||||
added by eggert@twinsun.com. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DECL_GETENV
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_GETENV
|
||||
char *getenv ();
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
#include <argmatch.h>
|
||||
#include <error.h>
|
||||
#include <xstrtol.h>
|
||||
|
||||
#include "human.h"
|
||||
|
||||
static const char suffixes[] =
|
||||
{
|
||||
0, /* not used */
|
||||
'K', /* kibi ('k' for kilo is a special case) */
|
||||
'M', /* mega or mebi */
|
||||
'G', /* giga or gibi */
|
||||
'T', /* tera or tebi */
|
||||
'P', /* peta or pebi */
|
||||
'E', /* exa or exbi */
|
||||
'Z', /* zetta or 2**70 */
|
||||
'Y' /* yotta or 2**80 */
|
||||
};
|
||||
|
||||
/* Generate into P[-1] (and possibly P[-2]) the proper suffix for
|
||||
POWER and BASE. Return the address of the generated suffix. */
|
||||
static char *
|
||||
generate_suffix_backwards (char *p, int power, int base)
|
||||
{
|
||||
char letter = suffixes[power];
|
||||
|
||||
if (base == 1000)
|
||||
{
|
||||
*--p = 'B';
|
||||
if (power == 1)
|
||||
letter = 'k';
|
||||
}
|
||||
|
||||
*--p = letter;
|
||||
return p;
|
||||
}
|
||||
|
||||
/* If INEXACT_STYLE is not human_round_to_even, and if easily
|
||||
possible, adjust VALUE according to the style. */
|
||||
static double
|
||||
adjust_value (enum human_inexact_style inexact_style, double value)
|
||||
{
|
||||
/* Do not use the floor or ceil functions, as that would mean
|
||||
linking with the standard math library, which is a porting pain.
|
||||
So leave the value alone if it is too large to easily round. */
|
||||
if (inexact_style != human_round_to_even && value < (uintmax_t) -1)
|
||||
{
|
||||
uintmax_t u = value;
|
||||
value = u + (inexact_style == human_ceiling && u != value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/* Like human_readable_inexact, except always round to even. */
|
||||
char *
|
||||
human_readable (uintmax_t n, char *buf,
|
||||
int from_block_size, int output_block_size)
|
||||
{
|
||||
return human_readable_inexact (n, buf, from_block_size, output_block_size,
|
||||
human_round_to_even);
|
||||
}
|
||||
|
||||
/* Convert N to a human readable format in BUF.
|
||||
|
||||
N is expressed in units of FROM_BLOCK_SIZE. FROM_BLOCK_SIZE must
|
||||
be nonnegative.
|
||||
|
||||
OUTPUT_BLOCK_SIZE must be nonzero. If it is positive, use units of
|
||||
OUTPUT_BLOCK_SIZE in the output number.
|
||||
|
||||
Use INEXACT_STYLE to determine whether to take the ceiling or floor
|
||||
of any result that cannot be expressed exactly.
|
||||
|
||||
If OUTPUT_BLOCK_SIZE is negative, use a format like "127K" if
|
||||
possible, using powers of -OUTPUT_BLOCK_SIZE; otherwise, use
|
||||
ordinary decimal format. Normally -OUTPUT_BLOCK_SIZE is either
|
||||
1000 or 1024; it must be at least 2. Most people visually process
|
||||
strings of 3-4 digits effectively, but longer strings of digits are
|
||||
more prone to misinterpretation. Hence, converting to an
|
||||
abbreviated form usually improves readability. Use a suffix
|
||||
indicating which power is being used. For example, assuming
|
||||
-OUTPUT_BLOCK_SIZE is 1024, 8500 would be converted to 8.3K,
|
||||
133456345 to 127M, 56990456345 to 53G, and so on. Numbers smaller
|
||||
than -OUTPUT_BLOCK_SIZE aren't modified. If -OUTPUT_BLOCK_SIZE is
|
||||
1024, append a "B" after any size letter. */
|
||||
|
||||
char *
|
||||
human_readable_inexact (uintmax_t n, char *buf,
|
||||
int from_block_size, int output_block_size,
|
||||
enum human_inexact_style inexact_style)
|
||||
{
|
||||
uintmax_t amt;
|
||||
int base;
|
||||
int to_block_size;
|
||||
int tenths = 0;
|
||||
int power;
|
||||
char *p;
|
||||
|
||||
/* 0 means adjusted N == AMT.TENTHS;
|
||||
1 means AMT.TENTHS < adjusted N < AMT.TENTHS + 0.05;
|
||||
2 means adjusted N == AMT.TENTHS + 0.05;
|
||||
3 means AMT.TENTHS + 0.05 < adjusted N < AMT.TENTHS + 0.1. */
|
||||
int rounding = 0;
|
||||
|
||||
if (output_block_size < 0)
|
||||
{
|
||||
base = -output_block_size;
|
||||
to_block_size = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
base = 0;
|
||||
to_block_size = output_block_size;
|
||||
}
|
||||
|
||||
p = buf + LONGEST_HUMAN_READABLE;
|
||||
*p = '\0';
|
||||
|
||||
#ifdef lint
|
||||
/* Suppress `used before initialized' warning. */
|
||||
power = 0;
|
||||
#endif
|
||||
|
||||
/* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE units. */
|
||||
|
||||
{
|
||||
int multiplier;
|
||||
int divisor;
|
||||
int r2;
|
||||
int r10;
|
||||
if (to_block_size <= from_block_size
|
||||
? (from_block_size % to_block_size != 0
|
||||
|| (multiplier = from_block_size / to_block_size,
|
||||
(amt = n * multiplier) / multiplier != n))
|
||||
: (from_block_size == 0
|
||||
|| to_block_size % from_block_size != 0
|
||||
|| (divisor = to_block_size / from_block_size,
|
||||
r10 = (n % divisor) * 10,
|
||||
r2 = (r10 % divisor) * 2,
|
||||
amt = n / divisor,
|
||||
tenths = r10 / divisor,
|
||||
rounding = r2 < divisor ? 0 < r2 : 2 + (divisor < r2),
|
||||
0)))
|
||||
{
|
||||
/* Either the result cannot be computed easily using uintmax_t,
|
||||
or from_block_size is zero. Fall back on floating point.
|
||||
FIXME: This can yield answers that are slightly off. */
|
||||
|
||||
double damt = n * (from_block_size / (double) to_block_size);
|
||||
|
||||
if (! base)
|
||||
sprintf (buf, "%.0f", adjust_value (inexact_style, damt));
|
||||
else
|
||||
{
|
||||
char suffix[3];
|
||||
char const *psuffix;
|
||||
double e = 1;
|
||||
power = 0;
|
||||
|
||||
do
|
||||
{
|
||||
e *= base;
|
||||
power++;
|
||||
}
|
||||
while (e * base <= damt && power < sizeof suffixes - 1);
|
||||
|
||||
damt /= e;
|
||||
|
||||
suffix[2] = '\0';
|
||||
psuffix = generate_suffix_backwards (suffix + 2, power, base);
|
||||
sprintf (buf, "%.1f%s",
|
||||
adjust_value (inexact_style, damt), psuffix);
|
||||
if (4 + (base == 1000) < strlen (buf))
|
||||
sprintf (buf, "%.0f%s",
|
||||
adjust_value (inexact_style, damt * 10) / 10, psuffix);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
/* Use power of BASE notation if adjusted AMT is large enough. */
|
||||
|
||||
if (base && base <= amt)
|
||||
{
|
||||
power = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int r10 = (amt % base) * 10 + tenths;
|
||||
int r2 = (r10 % base) * 2 + (rounding >> 1);
|
||||
amt /= base;
|
||||
tenths = r10 / base;
|
||||
rounding = (r2 < base
|
||||
? 0 < r2 + rounding
|
||||
: 2 + (base < r2 + rounding));
|
||||
power++;
|
||||
}
|
||||
while (base <= amt && power < sizeof suffixes - 1);
|
||||
|
||||
p = generate_suffix_backwards (p, power, base);
|
||||
|
||||
if (amt < 10)
|
||||
{
|
||||
if (2 * (1 - (int) inexact_style)
|
||||
< rounding + (tenths & (inexact_style == human_round_to_even)))
|
||||
{
|
||||
tenths++;
|
||||
rounding = 0;
|
||||
|
||||
if (tenths == 10)
|
||||
{
|
||||
amt++;
|
||||
tenths = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (amt < 10)
|
||||
{
|
||||
*--p = '0' + tenths;
|
||||
*--p = '.';
|
||||
tenths = rounding = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inexact_style == human_ceiling
|
||||
? 0 < tenths + rounding
|
||||
: inexact_style == human_round_to_even
|
||||
? 5 < tenths + (2 < rounding + (amt & 1))
|
||||
: /* inexact_style == human_floor */ 0)
|
||||
{
|
||||
amt++;
|
||||
|
||||
if (amt == base && power < sizeof suffixes - 1)
|
||||
{
|
||||
*p = suffixes[power + 1];
|
||||
*--p = '0';
|
||||
*--p = '.';
|
||||
amt = 1;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
*--p = '0' + (int) (amt % 10);
|
||||
while ((amt /= 10) != 0);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/* The default block size used for output. This number may change in
|
||||
the future as disks get larger. */
|
||||
#ifndef DEFAULT_BLOCK_SIZE
|
||||
# define DEFAULT_BLOCK_SIZE 1024
|
||||
#endif
|
||||
|
||||
static char const *const block_size_args[] = { "human-readable", "si", 0 };
|
||||
static int const block_size_types[] = { -1024, -1000 };
|
||||
|
||||
static int
|
||||
default_block_size (void)
|
||||
{
|
||||
return getenv ("POSIXLY_CORRECT") ? 512 : DEFAULT_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
static strtol_error
|
||||
humblock (char const *spec, int *block_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (! spec && ! (spec = getenv ("BLOCK_SIZE")))
|
||||
*block_size = default_block_size ();
|
||||
else if (0 <= (i = ARGMATCH (spec, block_size_args, block_size_types)))
|
||||
*block_size = block_size_types[i];
|
||||
else
|
||||
{
|
||||
char *ptr;
|
||||
unsigned long val;
|
||||
strtol_error e = xstrtoul (spec, &ptr, 0, &val, "eEgGkKmMpPtTyYzZ0");
|
||||
if (e != LONGINT_OK)
|
||||
return e;
|
||||
if (*ptr)
|
||||
return LONGINT_INVALID_SUFFIX_CHAR;
|
||||
if ((int) val < 0 || val != (int) val)
|
||||
return LONGINT_OVERFLOW;
|
||||
*block_size = (int) val;
|
||||
}
|
||||
|
||||
return LONGINT_OK;
|
||||
}
|
||||
|
||||
void
|
||||
human_block_size (char const *spec, int report_errors, int *block_size)
|
||||
{
|
||||
strtol_error e = humblock (spec, block_size);
|
||||
if (*block_size == 0)
|
||||
{
|
||||
*block_size = default_block_size ();
|
||||
e = LONGINT_INVALID;
|
||||
}
|
||||
if (e != LONGINT_OK && report_errors)
|
||||
STRTOL_FATAL_ERROR (spec, _("block size"), e);
|
||||
}
|
39
contrib/gnu-sort/lib/human.h
Normal file
39
contrib/gnu-sort/lib/human.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef HUMAN_H_
|
||||
# define HUMAN_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
|
||||
/* A conservative bound on the maximum length of a human-readable string.
|
||||
The output can be the product of the largest uintmax_t and the largest int,
|
||||
so add their sizes before converting to a bound on digits. */
|
||||
# define LONGEST_HUMAN_READABLE ((sizeof (uintmax_t) + sizeof (int)) \
|
||||
* CHAR_BIT / 3)
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
enum human_inexact_style
|
||||
{
|
||||
human_floor = -1,
|
||||
human_round_to_even = 0,
|
||||
human_ceiling = 1
|
||||
};
|
||||
|
||||
char *human_readable PARAMS ((uintmax_t, char *, int, int));
|
||||
char *human_readable_inexact PARAMS ((uintmax_t, char *, int, int,
|
||||
enum human_inexact_style));
|
||||
|
||||
void human_block_size PARAMS ((char const *, int, int *));
|
||||
|
||||
#endif /* HUMAN_H_ */
|
91
contrib/gnu-sort/lib/long-options.c
Normal file
91
contrib/gnu-sort/lib/long-options.c
Normal file
@ -0,0 +1,91 @@
|
||||
/* Utility to accept --help and --version options as unobtrusively as possible.
|
||||
Copyright (C) 1993, 1994, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "long-options.h"
|
||||
#include "version-etc.h"
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* Process long options --help and --version, but only if argc == 2.
|
||||
Be careful not to gobble up `--'. */
|
||||
|
||||
void
|
||||
parse_long_options (int argc,
|
||||
char **argv,
|
||||
const char *command_name,
|
||||
const char *package,
|
||||
const char *version,
|
||||
const char *authors,
|
||||
void (*usage_func)())
|
||||
{
|
||||
int c;
|
||||
int saved_opterr;
|
||||
|
||||
saved_opterr = opterr;
|
||||
|
||||
/* Don't print an error message for unrecognized options. */
|
||||
opterr = 0;
|
||||
|
||||
if (argc == 2
|
||||
&& (c = getopt_long (argc, argv, "+", long_options, NULL)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
(*usage_func) (0);
|
||||
|
||||
case 'v':
|
||||
version_etc (stdout, command_name, package, version, authors);
|
||||
exit (0);
|
||||
|
||||
default:
|
||||
/* Don't process any other long-named options. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore previous value. */
|
||||
opterr = saved_opterr;
|
||||
|
||||
/* Reset this to zero so that getopt internals get initialized from
|
||||
the probably-new parameters when/if getopt is called later. */
|
||||
optind = 0;
|
||||
}
|
35
contrib/gnu-sort/lib/long-options.h
Normal file
35
contrib/gnu-sort/lib/long-options.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* long-options.h -- declaration for --help- and --version-handling function.
|
||||
Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void
|
||||
parse_long_options PARAMS ((int _argc,
|
||||
char **_argv,
|
||||
const char *_command_name,
|
||||
const char *_package,
|
||||
const char *_version,
|
||||
const char *_authors,
|
||||
void (*_usage) (int)));
|
79
contrib/gnu-sort/lib/memcoll.c
Normal file
79
contrib/gnu-sort/lib/memcoll.c
Normal file
@ -0,0 +1,79 @@
|
||||
/* Locale-specific memory comparison.
|
||||
Copyright 1999, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Contributed by Paul Eggert <eggert@twinsun.com>. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
/* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according
|
||||
to the LC_COLLATE locale. S1 and S2 do not overlap, and are not
|
||||
adjacent. Temporarily modify the bytes after S1 and S2, but
|
||||
restore their original contents before returning. Set errno to an
|
||||
error number if there is an error, and to zero otherwise. */
|
||||
int
|
||||
memcoll (char *s1, size_t s1len, char *s2, size_t s2len)
|
||||
{
|
||||
int diff;
|
||||
char n1 = s1[s1len];
|
||||
char n2 = s2[s2len];
|
||||
|
||||
s1[s1len++] = '\0';
|
||||
s2[s2len++] = '\0';
|
||||
|
||||
while (! (errno = 0, (diff = strcoll (s1, s2)) || errno))
|
||||
{
|
||||
/* strcoll found no difference, but perhaps it was fooled by NUL
|
||||
characters in the data. Work around this problem by advancing
|
||||
past the NUL chars. */
|
||||
size_t size1 = strlen (s1) + 1;
|
||||
size_t size2 = strlen (s2) + 1;
|
||||
s1 += size1;
|
||||
s2 += size2;
|
||||
s1len -= size1;
|
||||
s2len -= size2;
|
||||
|
||||
if (s1len == 0)
|
||||
{
|
||||
if (s2len != 0)
|
||||
diff = -1;
|
||||
break;
|
||||
}
|
||||
else if (s2len == 0)
|
||||
{
|
||||
diff = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
s1[s1len - 1] = n1;
|
||||
s2[s2len - 1] = n2;
|
||||
|
||||
return diff;
|
||||
}
|
18
contrib/gnu-sort/lib/memcoll.h
Normal file
18
contrib/gnu-sort/lib/memcoll.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef MEMCOLL_H_
|
||||
# define MEMCOLL_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
int memcoll PARAMS ((char *, size_t, char *, size_t));
|
||||
|
||||
#endif /* MEMCOLL_H_ */
|
54
contrib/gnu-sort/lib/pathmax.h
Normal file
54
contrib/gnu-sort/lib/pathmax.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* Define PATH_MAX somehow. Requires sys/types.h.
|
||||
Copyright (C) 1992, 1999, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _PATHMAX_H
|
||||
# define _PATHMAX_H
|
||||
|
||||
# if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
|
||||
/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define
|
||||
PATH_MAX but might cause redefinition warnings when sys/param.h is
|
||||
later included (as on MORE/BSD 4.3). */
|
||||
# if defined _POSIX_VERSION || (defined HAVE_LIMITS_H && !defined __GNUC__)
|
||||
# include <limits.h>
|
||||
# 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 <sys/param.h>
|
||||
# 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 */
|
94
contrib/gnu-sort/lib/physmem.c
Normal file
94
contrib/gnu-sort/lib/physmem.c
Normal file
@ -0,0 +1,94 @@
|
||||
/* Calculate the size of physical memory.
|
||||
Copyright 2000, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "physmem.h"
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_PSTAT_H
|
||||
# include <sys/pstat.h>
|
||||
#endif
|
||||
|
||||
/* Return the total amount of physical memory. */
|
||||
double
|
||||
physmem_total (void)
|
||||
{
|
||||
#if defined _SC_PHYS_PAGES && defined _SC_PAGESIZE
|
||||
{
|
||||
double pages = sysconf (_SC_PHYS_PAGES);
|
||||
double pagesize = sysconf (_SC_PAGESIZE);
|
||||
if (0 <= pages && 0 <= pagesize)
|
||||
return pages * pagesize;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_PSTAT_GETSTATIC
|
||||
{
|
||||
struct pst_static pss;
|
||||
if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0))
|
||||
{
|
||||
double pages = pss.physical_memory;
|
||||
double pagesize = pss.page_size;
|
||||
if (0 <= pages && 0 <= pagesize)
|
||||
return pages * pagesize;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Guess 64 MB. It's probably an older host, so guess small. */
|
||||
return 64 * 1024 * 1024;
|
||||
}
|
||||
|
||||
/* Return the amount of physical memory available. */
|
||||
double
|
||||
physmem_available (void)
|
||||
{
|
||||
#if defined _SC_AVPHYS_PAGES && defined _SC_PAGESIZE
|
||||
{
|
||||
double pages = sysconf (_SC_AVPHYS_PAGES);
|
||||
double pagesize = sysconf (_SC_PAGESIZE);
|
||||
if (0 <= pages && 0 <= pagesize)
|
||||
return pages * pagesize;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_PSTAT_GETSTATIC && HAVE_PSTAT_GETDYNAMIC
|
||||
{
|
||||
struct pst_static pss;
|
||||
struct pst_dynamic psd;
|
||||
if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0)
|
||||
&& 0 <= pstat_getdynamic (&psd, sizeof psd, 1, 0))
|
||||
{
|
||||
double pages = psd.psd_free;
|
||||
double pagesize = pss.page_size;
|
||||
if (0 <= pages && 0 <= pagesize)
|
||||
return pages * pagesize;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Guess 25% of physical memory. */
|
||||
return physmem_total () / 4;
|
||||
}
|
19
contrib/gnu-sort/lib/physmem.h
Normal file
19
contrib/gnu-sort/lib/physmem.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef PHYSMEM_H_
|
||||
# define PHYSMEM_H_ 1
|
||||
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# endif
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
double physmem_total PARAMS ((void));
|
||||
double physmem_available PARAMS ((void));
|
||||
|
||||
#endif /* PHYSMEM_H_ */
|
58
contrib/gnu-sort/lib/posixver.c
Normal file
58
contrib/gnu-sort/lib/posixver.c
Normal file
@ -0,0 +1,58 @@
|
||||
/* Which POSIX version to conform to, for utilities.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#if !HAVE_DECL_GETENV && !defined getenv
|
||||
char *getenv ();
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifndef _POSIX2_VERSION
|
||||
# define _POSIX2_VERSION 0
|
||||
#endif
|
||||
|
||||
/* The POSIX version that utilities should conform to. The default is
|
||||
specified by the system. */
|
||||
|
||||
int
|
||||
posix2_version (void)
|
||||
{
|
||||
long int v = _POSIX2_VERSION;
|
||||
char const *s = getenv ("_POSIX2_VERSION");
|
||||
|
||||
if (s && *s)
|
||||
{
|
||||
char *e;
|
||||
long int i = strtol (s, &e, 10);
|
||||
if (! *e)
|
||||
v = i;
|
||||
}
|
||||
|
||||
return v < INT_MIN ? INT_MIN : v < INT_MAX ? v : INT_MAX;
|
||||
}
|
1
contrib/gnu-sort/lib/posixver.h
Normal file
1
contrib/gnu-sort/lib/posixver.h
Normal file
@ -0,0 +1 @@
|
||||
int posix2_version (void);
|
28
contrib/gnu-sort/lib/quote.c
Normal file
28
contrib/gnu-sort/lib/quote.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDDEF_H
|
||||
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <quotearg.h>
|
||||
#include <quote.h>
|
||||
|
||||
/* Return an unambiguous printable representated, allocated in slot N,
|
||||
for NAME, suitable for diagnostics. */
|
||||
char const *
|
||||
quote_n (int n, char const *name)
|
||||
{
|
||||
return quotearg_n_style (n, locale_quoting_style, name);
|
||||
}
|
||||
|
||||
/* Return an unambiguous printable representation of NAME, suitable
|
||||
for diagnostics. */
|
||||
char const *
|
||||
quote (char const *name)
|
||||
{
|
||||
return quote_n (0, name);
|
||||
}
|
12
contrib/gnu-sort/lib/quote.h
Normal file
12
contrib/gnu-sort/lib/quote.h
Normal file
@ -0,0 +1,12 @@
|
||||
/* prototypes for quote.c */
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
char const *quote_n PARAMS ((int n, char const *name));
|
||||
char const *quote PARAMS ((char const *name));
|
658
contrib/gnu-sort/lib/quotearg.c
Normal file
658
contrib/gnu-sort/lib/quotearg.c
Normal file
@ -0,0 +1,658 @@
|
||||
/* quotearg.c - quote arguments for output
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDDEF_H
|
||||
# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <quotearg.h>
|
||||
#include <xalloc.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(text) gettext (text)
|
||||
#else
|
||||
# define _(text) text
|
||||
#endif
|
||||
#define N_(text) text
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
#ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX ((unsigned char) -1)
|
||||
#endif
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX ((unsigned int) -1)
|
||||
#endif
|
||||
|
||||
#if HAVE_C_BACKSLASH_A
|
||||
# define ALERT_CHAR '\a'
|
||||
#else
|
||||
# define ALERT_CHAR '\7'
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_WCHAR_H
|
||||
|
||||
/* BSD/OS 4.1 wchar.h requires FILE and struct tm to be declared. */
|
||||
# include <stdio.h>
|
||||
# include <time.h>
|
||||
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
#if !HAVE_MBRTOWC
|
||||
/* Disable multibyte processing entirely. Since MB_CUR_MAX is 1, the
|
||||
other macros are defined only for documentation and to satisfy C
|
||||
syntax. */
|
||||
# undef MB_CUR_MAX
|
||||
# define MB_CUR_MAX 1
|
||||
# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
|
||||
# define mbsinit(ps) 1
|
||||
# define iswprint(wc) ISPRINT ((unsigned char) (wc))
|
||||
#endif
|
||||
|
||||
#ifndef iswprint
|
||||
# if HAVE_WCTYPE_H
|
||||
# include <wctype.h>
|
||||
# endif
|
||||
# if !defined iswprint && !HAVE_ISWPRINT
|
||||
# define iswprint(wc) 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define INT_BITS (sizeof (int) * CHAR_BIT)
|
||||
|
||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
#endif
|
||||
|
||||
/* Undefine to protect against the definition in wctype.h of solaris2.6. */
|
||||
#undef ISPRINT
|
||||
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
|
||||
|
||||
struct quoting_options
|
||||
{
|
||||
/* Basic quoting style. */
|
||||
enum quoting_style style;
|
||||
|
||||
/* Quote the characters indicated by this bit vector even if the
|
||||
quoting style would not normally require them to be quoted. */
|
||||
int quote_these_too[(UCHAR_MAX / INT_BITS) + 1];
|
||||
};
|
||||
|
||||
/* Names of quoting styles. */
|
||||
char const *const quoting_style_args[] =
|
||||
{
|
||||
"literal",
|
||||
"shell",
|
||||
"shell-always",
|
||||
"c",
|
||||
"escape",
|
||||
"locale",
|
||||
"clocale",
|
||||
0
|
||||
};
|
||||
|
||||
/* Correspondences to quoting style names. */
|
||||
enum quoting_style const quoting_style_vals[] =
|
||||
{
|
||||
literal_quoting_style,
|
||||
shell_quoting_style,
|
||||
shell_always_quoting_style,
|
||||
c_quoting_style,
|
||||
escape_quoting_style,
|
||||
locale_quoting_style,
|
||||
clocale_quoting_style
|
||||
};
|
||||
|
||||
/* The default quoting options. */
|
||||
static struct quoting_options default_quoting_options;
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to the default if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *
|
||||
clone_quoting_options (struct quoting_options *o)
|
||||
{
|
||||
struct quoting_options *p
|
||||
= (struct quoting_options *) xmalloc (sizeof (struct quoting_options));
|
||||
*p = *(o ? o : &default_quoting_options);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Get the value of O's quoting style. If O is null, use the default. */
|
||||
enum quoting_style
|
||||
get_quoting_style (struct quoting_options *o)
|
||||
{
|
||||
return (o ? o : &default_quoting_options)->style;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting style to S. */
|
||||
void
|
||||
set_quoting_style (struct quoting_options *o, enum quoting_style s)
|
||||
{
|
||||
(o ? o : &default_quoting_options)->style = s;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int
|
||||
set_char_quoting (struct quoting_options *o, char c, int i)
|
||||
{
|
||||
unsigned char uc = c;
|
||||
int *p = (o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS;
|
||||
int shift = uc % INT_BITS;
|
||||
int r = (*p >> shift) & 1;
|
||||
*p ^= ((i & 1) ^ r) << shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* MSGID approximates a quotation mark. Return its translation if it
|
||||
has one; otherwise, return either it or "\"", depending on S. */
|
||||
static char const *
|
||||
gettext_quote (char const *msgid, enum quoting_style s)
|
||||
{
|
||||
char const *translation = _(msgid);
|
||||
if (translation == msgid && s == clocale_quoting_style)
|
||||
translation = "\"";
|
||||
return translation;
|
||||
}
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using QUOTING_STYLE and the
|
||||
non-quoting-style part of O to control quoting.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE.
|
||||
|
||||
This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG,
|
||||
ARGSIZE, O), except it uses QUOTING_STYLE instead of the quoting
|
||||
style specified by O, and O may not be null. */
|
||||
|
||||
static size_t
|
||||
quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
enum quoting_style quoting_style,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
size_t i;
|
||||
size_t len = 0;
|
||||
char const *quote_string = 0;
|
||||
size_t quote_string_len = 0;
|
||||
int backslash_escapes = 0;
|
||||
int unibyte_locale = MB_CUR_MAX == 1;
|
||||
|
||||
#define STORE(c) \
|
||||
do \
|
||||
{ \
|
||||
if (len < buffersize) \
|
||||
buffer[len] = (c); \
|
||||
len++; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
switch (quoting_style)
|
||||
{
|
||||
case c_quoting_style:
|
||||
STORE ('"');
|
||||
backslash_escapes = 1;
|
||||
quote_string = "\"";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
case escape_quoting_style:
|
||||
backslash_escapes = 1;
|
||||
break;
|
||||
|
||||
case locale_quoting_style:
|
||||
case clocale_quoting_style:
|
||||
{
|
||||
/* Get translations for open and closing quotation marks.
|
||||
|
||||
The message catalog should translate "`" to a left
|
||||
quotation mark suitable for the locale, and similarly for
|
||||
"'". If the catalog has no translation,
|
||||
locale_quoting_style quotes `like this', and
|
||||
clocale_quoting_style quotes "like this".
|
||||
|
||||
For example, an American English Unicode locale should
|
||||
translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and
|
||||
should translate "'" to U+201D (RIGHT DOUBLE QUOTATION
|
||||
MARK). A British English Unicode locale should instead
|
||||
translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and
|
||||
U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. */
|
||||
|
||||
char const *left = gettext_quote (N_("`"), quoting_style);
|
||||
char const *right = gettext_quote (N_("'"), quoting_style);
|
||||
for (quote_string = left; *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
backslash_escapes = 1;
|
||||
quote_string = right;
|
||||
quote_string_len = strlen (quote_string);
|
||||
}
|
||||
break;
|
||||
|
||||
case shell_always_quoting_style:
|
||||
STORE ('\'');
|
||||
quote_string = "'";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; ! (argsize == (size_t) -1 ? arg[i] == '\0' : i == argsize); i++)
|
||||
{
|
||||
unsigned char c;
|
||||
unsigned char esc;
|
||||
|
||||
if (backslash_escapes
|
||||
&& quote_string_len
|
||||
&& i + quote_string_len <= argsize
|
||||
&& memcmp (arg + i, quote_string, quote_string_len) == 0)
|
||||
STORE ('\\');
|
||||
|
||||
c = arg[i];
|
||||
switch (c)
|
||||
{
|
||||
case '\0':
|
||||
if (backslash_escapes)
|
||||
{
|
||||
STORE ('\\');
|
||||
STORE ('0');
|
||||
STORE ('0');
|
||||
c = '0';
|
||||
}
|
||||
break;
|
||||
|
||||
case '?':
|
||||
switch (quoting_style)
|
||||
{
|
||||
case shell_quoting_style:
|
||||
goto use_shell_always_quoting_style;
|
||||
|
||||
case c_quoting_style:
|
||||
if (i + 2 < argsize && arg[i + 1] == '?')
|
||||
switch (arg[i + 2])
|
||||
{
|
||||
case '!': case '\'':
|
||||
case '(': case ')': case '-': case '/':
|
||||
case '<': case '=': case '>':
|
||||
/* Escape the second '?' in what would otherwise be
|
||||
a trigraph. */
|
||||
i += 2;
|
||||
c = arg[i + 2];
|
||||
STORE ('?');
|
||||
STORE ('\\');
|
||||
STORE ('?');
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ALERT_CHAR: esc = 'a'; goto c_escape;
|
||||
case '\b': esc = 'b'; goto c_escape;
|
||||
case '\f': esc = 'f'; goto c_escape;
|
||||
case '\n': esc = 'n'; goto c_and_shell_escape;
|
||||
case '\r': esc = 'r'; goto c_and_shell_escape;
|
||||
case '\t': esc = 't'; goto c_and_shell_escape;
|
||||
case '\v': esc = 'v'; goto c_escape;
|
||||
case '\\': esc = c; goto c_and_shell_escape;
|
||||
|
||||
c_and_shell_escape:
|
||||
if (quoting_style == shell_quoting_style)
|
||||
goto use_shell_always_quoting_style;
|
||||
c_escape:
|
||||
if (backslash_escapes)
|
||||
{
|
||||
c = esc;
|
||||
goto store_escape;
|
||||
}
|
||||
break;
|
||||
|
||||
case '#': case '~':
|
||||
if (i != 0)
|
||||
break;
|
||||
/* Fall through. */
|
||||
case ' ':
|
||||
case '!': /* special in bash */
|
||||
case '"': case '$': case '&':
|
||||
case '(': case ')': case '*': case ';':
|
||||
case '<': case '>': case '[':
|
||||
case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
|
||||
case '`': case '|':
|
||||
/* A shell special character. In theory, '$' and '`' could
|
||||
be the first bytes of multibyte characters, which means
|
||||
we should check them with mbrtowc, but in practice this
|
||||
doesn't happen so it's not worth worrying about. */
|
||||
if (quoting_style == shell_quoting_style)
|
||||
goto use_shell_always_quoting_style;
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
switch (quoting_style)
|
||||
{
|
||||
case shell_quoting_style:
|
||||
goto use_shell_always_quoting_style;
|
||||
|
||||
case shell_always_quoting_style:
|
||||
STORE ('\'');
|
||||
STORE ('\\');
|
||||
STORE ('\'');
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '%': case '+': case ',': case '-': case '.': case '/':
|
||||
case '0': case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9': case ':': case '=':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
|
||||
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
|
||||
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
|
||||
case 'Y': case 'Z': case ']': case '_': case 'a': case 'b':
|
||||
case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
|
||||
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
|
||||
case 'o': case 'p': case 'q': case 'r': case 's': case 't':
|
||||
case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
|
||||
case '{': case '}':
|
||||
/* These characters don't cause problems, no matter what the
|
||||
quoting style is. They cannot start multibyte sequences. */
|
||||
break;
|
||||
|
||||
default:
|
||||
/* If we have a multibyte sequence, copy it until we reach
|
||||
its end, find an error, or come back to the initial shift
|
||||
state. For C-like styles, if the sequence has
|
||||
unprintable characters, escape the whole sequence, since
|
||||
we can't easily escape single characters within it. */
|
||||
{
|
||||
/* Length of multibyte sequence found so far. */
|
||||
size_t m;
|
||||
|
||||
int printable;
|
||||
|
||||
if (unibyte_locale)
|
||||
{
|
||||
m = 1;
|
||||
printable = ISPRINT (c);
|
||||
}
|
||||
else
|
||||
{
|
||||
mbstate_t mbstate;
|
||||
memset (&mbstate, 0, sizeof mbstate);
|
||||
|
||||
m = 0;
|
||||
printable = 1;
|
||||
if (argsize == (size_t) -1)
|
||||
argsize = strlen (arg);
|
||||
|
||||
do
|
||||
{
|
||||
wchar_t w;
|
||||
size_t bytes = mbrtowc (&w, &arg[i + m],
|
||||
argsize - (i + m), &mbstate);
|
||||
if (bytes == 0)
|
||||
break;
|
||||
else if (bytes == (size_t) -1)
|
||||
{
|
||||
printable = 0;
|
||||
break;
|
||||
}
|
||||
else if (bytes == (size_t) -2)
|
||||
{
|
||||
printable = 0;
|
||||
while (i + m < argsize && arg[i + m])
|
||||
m++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! iswprint (w))
|
||||
printable = 0;
|
||||
m += bytes;
|
||||
}
|
||||
}
|
||||
while (! mbsinit (&mbstate));
|
||||
}
|
||||
|
||||
if (1 < m || (backslash_escapes && ! printable))
|
||||
{
|
||||
/* Output a multibyte sequence, or an escaped
|
||||
unprintable unibyte character. */
|
||||
size_t ilim = i + m;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (backslash_escapes && ! printable)
|
||||
{
|
||||
STORE ('\\');
|
||||
STORE ('0' + (c >> 6));
|
||||
STORE ('0' + ((c >> 3) & 7));
|
||||
c = '0' + (c & 7);
|
||||
}
|
||||
if (ilim <= i + 1)
|
||||
break;
|
||||
STORE (c);
|
||||
c = arg[++i];
|
||||
}
|
||||
|
||||
goto store_c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! (backslash_escapes
|
||||
&& o->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))))
|
||||
goto store_c;
|
||||
|
||||
store_escape:
|
||||
STORE ('\\');
|
||||
|
||||
store_c:
|
||||
STORE (c);
|
||||
}
|
||||
|
||||
if (quote_string)
|
||||
for (; *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
|
||||
if (len < buffersize)
|
||||
buffer[len] = '\0';
|
||||
return len;
|
||||
|
||||
use_shell_always_quoting_style:
|
||||
return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||
shell_always_quoting_style, o);
|
||||
}
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
|
||||
size_t
|
||||
quotearg_buffer (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
struct quoting_options const *p = o ? o : &default_quoting_options;
|
||||
return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||
p->style, p);
|
||||
}
|
||||
|
||||
/* Use storage slot N to return a quoted version of argument ARG.
|
||||
ARG is of size ARGSIZE, but if that is -1, ARG is a null-terminated string.
|
||||
OPTIONS specifies the quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. N is deliberately declared with type "int"
|
||||
to allow for future extensions (using negative values). */
|
||||
static char *
|
||||
quotearg_n_options (int n, char const *arg, size_t argsize,
|
||||
struct quoting_options const *options)
|
||||
{
|
||||
/* Preallocate a slot 0 buffer, so that the caller can always quote
|
||||
one small component of a "memory exhausted" message in slot 0. */
|
||||
static char slot0[256];
|
||||
static unsigned int nslots = 1;
|
||||
unsigned int n0 = n;
|
||||
struct slotvec
|
||||
{
|
||||
size_t size;
|
||||
char *val;
|
||||
};
|
||||
static struct slotvec slotvec0 = {sizeof slot0, slot0};
|
||||
static struct slotvec *slotvec = &slotvec0;
|
||||
|
||||
if (n < 0)
|
||||
abort ();
|
||||
|
||||
if (nslots <= n0)
|
||||
{
|
||||
unsigned int n1 = n0 + 1;
|
||||
size_t s = n1 * sizeof *slotvec;
|
||||
|
||||
if (SIZE_MAX / UINT_MAX <= sizeof *slotvec
|
||||
&& n1 != s / sizeof *slotvec)
|
||||
xalloc_die ();
|
||||
|
||||
if (slotvec == &slotvec0)
|
||||
{
|
||||
slotvec = (struct slotvec *) xmalloc (sizeof *slotvec);
|
||||
*slotvec = slotvec0;
|
||||
}
|
||||
slotvec = (struct slotvec *) xrealloc (slotvec, s);
|
||||
memset (slotvec + nslots, 0, (n1 - nslots) * sizeof *slotvec);
|
||||
nslots = n1;
|
||||
}
|
||||
|
||||
{
|
||||
size_t size = slotvec[n].size;
|
||||
char *val = slotvec[n].val;
|
||||
size_t qsize = quotearg_buffer (val, size, arg, argsize, options);
|
||||
|
||||
if (size <= qsize)
|
||||
{
|
||||
slotvec[n].size = size = qsize + 1;
|
||||
slotvec[n].val = val = xrealloc (val == slot0 ? 0 : val, size);
|
||||
quotearg_buffer (val, size, arg, argsize, options);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n (int n, char const *arg)
|
||||
{
|
||||
return quotearg_n_options (n, arg, (size_t) -1, &default_quoting_options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg (char const *arg)
|
||||
{
|
||||
return quotearg_n (0, arg);
|
||||
}
|
||||
|
||||
/* Return quoting options for STYLE, with no extra quoting. */
|
||||
static struct quoting_options
|
||||
quoting_options_from_style (enum quoting_style style)
|
||||
{
|
||||
struct quoting_options o;
|
||||
o.style = style;
|
||||
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
||||
return o;
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style (int n, enum quoting_style s, char const *arg)
|
||||
{
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, (size_t) -1, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style_mem (int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize)
|
||||
{
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, argsize, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_style (enum quoting_style s, char const *arg)
|
||||
{
|
||||
return quotearg_n_style (0, s, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_char (char const *arg, char ch)
|
||||
{
|
||||
struct quoting_options options;
|
||||
options = default_quoting_options;
|
||||
set_char_quoting (&options, ch, 1);
|
||||
return quotearg_n_options (0, arg, (size_t) -1, &options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_colon (char const *arg)
|
||||
{
|
||||
return quotearg_char (arg, ':');
|
||||
}
|
114
contrib/gnu-sort/lib/quotearg.h
Normal file
114
contrib/gnu-sort/lib/quotearg.h
Normal file
@ -0,0 +1,114 @@
|
||||
/* quotearg.h - quote arguments for output
|
||||
Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
/* Basic quoting styles. */
|
||||
enum quoting_style
|
||||
{
|
||||
literal_quoting_style, /* --quoting-style=literal */
|
||||
shell_quoting_style, /* --quoting-style=shell */
|
||||
shell_always_quoting_style, /* --quoting-style=shell-always */
|
||||
c_quoting_style, /* --quoting-style=c */
|
||||
escape_quoting_style, /* --quoting-style=escape */
|
||||
locale_quoting_style, /* --quoting-style=locale */
|
||||
clocale_quoting_style /* --quoting-style=clocale */
|
||||
};
|
||||
|
||||
/* For now, --quoting-style=literal is the default, but this may change. */
|
||||
#ifndef DEFAULT_QUOTING_STYLE
|
||||
# define DEFAULT_QUOTING_STYLE literal_quoting_style
|
||||
#endif
|
||||
|
||||
/* Names of quoting styles and their corresponding values. */
|
||||
extern char const *const quoting_style_args[];
|
||||
extern enum quoting_style const quoting_style_vals[];
|
||||
|
||||
struct quoting_options;
|
||||
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || defined __STDC__
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The functions listed below set and use a hidden variable
|
||||
that contains the default quoting style options. */
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to the default if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *clone_quoting_options
|
||||
PARAMS ((struct quoting_options *o));
|
||||
|
||||
/* Get the value of O's quoting style. If O is null, use the default. */
|
||||
enum quoting_style get_quoting_style PARAMS ((struct quoting_options *o));
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting style to S. */
|
||||
void set_quoting_style PARAMS ((struct quoting_options *o,
|
||||
enum quoting_style s));
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int set_char_quoting PARAMS ((struct quoting_options *o, char c, int i));
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
|
||||
size_t quotearg_buffer PARAMS ((char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o));
|
||||
|
||||
/* Use storage slot N to return a quoted version of the string ARG.
|
||||
Use the default quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. */
|
||||
char *quotearg_n PARAMS ((int n, char const *arg));
|
||||
|
||||
/* Equivalent to quotearg_n (0, ARG). */
|
||||
char *quotearg PARAMS ((char const *arg));
|
||||
|
||||
/* Use style S and storage slot N to return a quoted version of the string ARG.
|
||||
This is like quotearg_n (N, ARG), except that it uses S with no other
|
||||
options to specify the quoting method. */
|
||||
char *quotearg_n_style PARAMS ((int n, enum quoting_style s, char const *arg));
|
||||
/* Use style S and storage slot N to return a quoted version of the
|
||||
argument ARG of size ARGSIZE. This is like quotearg_n_style
|
||||
(N, S, ARG), except it can quote null bytes. */
|
||||
char *quotearg_n_style_mem PARAMS ((int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize));
|
||||
|
||||
/* Equivalent to quotearg_n_style (0, S, ARG). */
|
||||
char *quotearg_style PARAMS ((enum quoting_style s, char const *arg));
|
||||
|
||||
/* Like quotearg (ARG), except also quote any instances of CH. */
|
||||
char *quotearg_char PARAMS ((char const *arg, char ch));
|
||||
|
||||
/* Equivalent to quotearg_char (ARG, ':'). */
|
||||
char *quotearg_colon PARAMS ((char const *arg));
|
9
contrib/gnu-sort/lib/stdio-safer.h
Normal file
9
contrib/gnu-sort/lib/stdio-safer.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
FILE *fopen_safer PARAMS ((char const *, char const *));
|
9
contrib/gnu-sort/lib/unistd-safer.h
Normal file
9
contrib/gnu-sort/lib/unistd-safer.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int dup_safer PARAMS ((int));
|
71
contrib/gnu-sort/lib/version-etc.c
Normal file
71
contrib/gnu-sort/lib/version-etc.c
Normal file
@ -0,0 +1,71 @@
|
||||
/* Utility to help print --version output in a consistent format.
|
||||
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "unlocked-io.h"
|
||||
#include "version-etc.h"
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
/* Default copyright goes to the FSF. */
|
||||
|
||||
char* version_etc_copyright =
|
||||
/* Do *not* mark this string for translation. */
|
||||
"Copyright (C) 2002 Free Software Foundation, Inc.";
|
||||
|
||||
|
||||
/* Display the --version information the standard way.
|
||||
|
||||
If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of
|
||||
the program. The formats are therefore:
|
||||
|
||||
PACKAGE VERSION
|
||||
|
||||
or
|
||||
|
||||
COMMAND_NAME (PACKAGE) VERSION. */
|
||||
void
|
||||
version_etc (FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, const char *authors)
|
||||
{
|
||||
if (command_name)
|
||||
fprintf (stream, "%s (%s) %s\n", command_name, package, version);
|
||||
else
|
||||
fprintf (stream, "%s %s\n", package, version);
|
||||
fprintf (stream, _("Written by %s.\n"), authors);
|
||||
putc ('\n', stream);
|
||||
|
||||
fputs (version_etc_copyright, stream);
|
||||
putc ('\n', stream);
|
||||
|
||||
fputs (_("\
|
||||
This is free software; see the source for copying conditions. There is NO\n\
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"),
|
||||
stream);
|
||||
}
|
38
contrib/gnu-sort/lib/version-etc.h
Normal file
38
contrib/gnu-sort/lib/version-etc.h
Normal file
@ -0,0 +1,38 @@
|
||||
/* Utility to help print --version output in a consistent format.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#ifndef VERSION_ETC_H
|
||||
# define VERSION_ETC_H 1
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
extern char *version_etc_copyright;
|
||||
|
||||
void
|
||||
version_etc PARAMS ((FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, const char *authors));
|
||||
|
||||
#endif /* VERSION_ETC_H */
|
87
contrib/gnu-sort/lib/xalloc.h
Normal file
87
contrib/gnu-sort/lib/xalloc.h
Normal file
@ -0,0 +1,87 @@
|
||||
/* xalloc.h -- malloc with out-of-memory checking
|
||||
Copyright (C) 1990-1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef XALLOC_H_
|
||||
# define XALLOC_H_
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# endif
|
||||
|
||||
/* Exit value when the requested amount of memory is not available.
|
||||
It is initialized to EXIT_FAILURE, but the caller may set it to
|
||||
some other value. */
|
||||
extern int xalloc_exit_failure;
|
||||
|
||||
/* If this pointer is non-zero, run the specified function upon each
|
||||
allocation failure. It is initialized to zero. */
|
||||
extern void (*xalloc_fail_func) PARAMS ((void));
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this
|
||||
message is output. It is translated via gettext.
|
||||
Its value is "memory exhausted". */
|
||||
extern char const xalloc_msg_memory_exhausted[];
|
||||
|
||||
/* This function is always triggered when memory is exhausted. It is
|
||||
in charge of honoring the three previous items. This is the
|
||||
function to call when one wants the program to die because of a
|
||||
memory allocation failure. */
|
||||
extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN;
|
||||
|
||||
void *xmalloc PARAMS ((size_t n));
|
||||
void *xcalloc PARAMS ((size_t n, size_t s));
|
||||
void *xrealloc PARAMS ((void *p, size_t n));
|
||||
char *xstrdup PARAMS ((const char *str));
|
||||
|
||||
# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items)))
|
||||
# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items)))
|
||||
# define XREALLOC(Ptr, Type, N_items) \
|
||||
((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items)))
|
||||
|
||||
/* Declare and alloc memory for VAR of type TYPE. */
|
||||
# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1)
|
||||
|
||||
/* Free VAR only if non NULL. */
|
||||
# define XFREE(Var) \
|
||||
do { \
|
||||
if (Var) \
|
||||
free (Var); \
|
||||
} while (0)
|
||||
|
||||
/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */
|
||||
# define CCLONE(Src, Num) \
|
||||
(memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num)))
|
||||
|
||||
/* Return a malloc'ed copy of SRC. */
|
||||
# define CLONE(Src) CCLONE (Src, 1)
|
||||
|
||||
|
||||
#endif /* !XALLOC_H_ */
|
116
contrib/gnu-sort/lib/xmalloc.c
Normal file
116
contrib/gnu-sort/lib/xmalloc.c
Normal file
@ -0,0 +1,116 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
Copyright (C) 1990-1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
void *calloc ();
|
||||
void *malloc ();
|
||||
void *realloc ();
|
||||
void free ();
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define textdomain(Domain)
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
#define N_(Text) Text
|
||||
|
||||
#include "error.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#ifndef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DONE_WORKING_MALLOC_CHECK
|
||||
"you must run the autoconf test for a properly working malloc -- see malloc.m4"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DONE_WORKING_REALLOC_CHECK
|
||||
"you must run the autoconf test for a properly working realloc --see realloc.m4"
|
||||
#endif
|
||||
|
||||
/* Exit value when the requested amount of memory is not available.
|
||||
The caller may set it to some other value. */
|
||||
int xalloc_exit_failure = EXIT_FAILURE;
|
||||
|
||||
/* If non NULL, call this function when memory is exhausted. */
|
||||
void (*xalloc_fail_func) PARAMS ((void)) = 0;
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message
|
||||
before exiting when memory is exhausted. Goes through gettext. */
|
||||
char const xalloc_msg_memory_exhausted[] = N_("memory exhausted");
|
||||
|
||||
void
|
||||
xalloc_die (void)
|
||||
{
|
||||
if (xalloc_fail_func)
|
||||
(*xalloc_fail_func) ();
|
||||
error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
|
||||
/* The `noreturn' cannot be given to error, since it may return if
|
||||
its first argument is 0. To help compilers understand the
|
||||
xalloc_die does terminate, call exit. */
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
void *
|
||||
xmalloc (size_t n)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = malloc (n);
|
||||
if (p == 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. */
|
||||
|
||||
void *
|
||||
xrealloc (void *p, size_t n)
|
||||
{
|
||||
p = realloc (p, n);
|
||||
if (p == 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Allocate memory for N elements of S bytes, with error checking. */
|
||||
|
||||
void *
|
||||
xcalloc (size_t n, size_t s)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = calloc (n, s);
|
||||
if (p == 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
70
contrib/gnu-sort/lib/xmemcoll.c
Normal file
70
contrib/gnu-sort/lib/xmemcoll.c
Normal file
@ -0,0 +1,70 @@
|
||||
/* Locale-specific memory comparison.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Contributed by Paul Eggert <eggert@twinsun.com>. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
#else
|
||||
# define _(Text) Text
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "memcoll.h"
|
||||
#include "quotearg.h"
|
||||
#include "xmemcoll.h"
|
||||
|
||||
/* Exit value when xmemcoll fails.
|
||||
The caller may set it to some other value. */
|
||||
int xmemcoll_exit_failure = EXIT_FAILURE;
|
||||
|
||||
/* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according
|
||||
to the LC_COLLATE locale. S1 and S2 do not overlap, and are not
|
||||
adjacent. Temporarily modify the bytes after S1 and S2, but
|
||||
restore their original contents before returning. Report an error
|
||||
and exit if there is an error. */
|
||||
|
||||
int
|
||||
xmemcoll (char *s1, size_t s1len, char *s2, size_t s2len)
|
||||
{
|
||||
int diff = memcoll (s1, s1len, s2, s2len);
|
||||
int collation_errno = errno;
|
||||
|
||||
if (collation_errno)
|
||||
{
|
||||
error (0, collation_errno, _("string comparison failed"));
|
||||
error (0, 0, _("Set LC_ALL='C' to work around the problem."));
|
||||
error (xmemcoll_exit_failure, 0,
|
||||
_("The strings compared were %s and %s."),
|
||||
quotearg_n_style_mem (0, locale_quoting_style, s1, s1len),
|
||||
quotearg_n_style_mem (1, locale_quoting_style, s2, s2len));
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
2
contrib/gnu-sort/lib/xmemcoll.h
Normal file
2
contrib/gnu-sort/lib/xmemcoll.h
Normal file
@ -0,0 +1,2 @@
|
||||
extern int xmemcoll_exit_failure;
|
||||
int xmemcoll (char *, size_t, char *, size_t);
|
302
contrib/gnu-sort/lib/xstrtol.c
Normal file
302
contrib/gnu-sort/lib/xstrtol.c
Normal file
@ -0,0 +1,302 @@
|
||||
/* A more useful interface to strtol.
|
||||
Copyright (C) 1995, 1996, 1998-2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifndef __strtol
|
||||
# define __strtol strtol
|
||||
# define __strtol_t long int
|
||||
# define __xstrtol xstrtol
|
||||
#endif
|
||||
|
||||
/* Some pre-ANSI implementations (e.g. SunOS 4)
|
||||
need stderr defined if assertion checking is enabled. */
|
||||
#include <stdio.h>
|
||||
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
# ifndef strchr
|
||||
# define strchr index
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* The extra casts work around common compiler bugs. */
|
||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
|
||||
It is necessary at least when t == time_t. */
|
||||
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
|
||||
#define TYPE_MAXIMUM(t) (~ (t) 0 - TYPE_MINIMUM (t))
|
||||
|
||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
#endif
|
||||
|
||||
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
|
||||
|
||||
#include "xstrtol.h"
|
||||
|
||||
#if !HAVE_DECL_STRTOL && !defined strtol
|
||||
long int strtol ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STRTOUL && !defined strtoul
|
||||
unsigned long int strtoul ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STRTOIMAX && !defined strtoimax
|
||||
intmax_t strtoimax ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STRTOUMAX && !defined strtoumax
|
||||
uintmax_t strtoumax ();
|
||||
#endif
|
||||
|
||||
static int
|
||||
bkm_scale (__strtol_t *x, int scale_factor)
|
||||
{
|
||||
__strtol_t product = *x * scale_factor;
|
||||
if (*x != product / scale_factor)
|
||||
return 1;
|
||||
*x = product;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
bkm_scale_by_power (__strtol_t *x, int base, int power)
|
||||
{
|
||||
while (power--)
|
||||
if (bkm_scale (x, base))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: comment. */
|
||||
|
||||
strtol_error
|
||||
__xstrtol (const char *s, char **ptr, int strtol_base,
|
||||
__strtol_t *val, const char *valid_suffixes)
|
||||
{
|
||||
char *t_ptr;
|
||||
char **p;
|
||||
__strtol_t tmp;
|
||||
|
||||
assert (0 <= strtol_base && strtol_base <= 36);
|
||||
|
||||
p = (ptr ? ptr : &t_ptr);
|
||||
|
||||
if (! TYPE_SIGNED (__strtol_t))
|
||||
{
|
||||
const char *q = s;
|
||||
while (ISSPACE ((unsigned char) *q))
|
||||
++q;
|
||||
if (*q == '-')
|
||||
return LONGINT_INVALID;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
tmp = __strtol (s, p, strtol_base);
|
||||
if (errno != 0)
|
||||
return LONGINT_OVERFLOW;
|
||||
|
||||
if (*p == s)
|
||||
{
|
||||
/* If there is no number but there is a valid suffix, assume the
|
||||
number is 1. The string is invalid otherwise. */
|
||||
if (valid_suffixes && **p && strchr (valid_suffixes, **p))
|
||||
tmp = 1;
|
||||
else
|
||||
return LONGINT_INVALID;
|
||||
}
|
||||
|
||||
/* Let valid_suffixes == NULL mean `allow any suffix'. */
|
||||
/* FIXME: update all callers except the ones that allow suffixes
|
||||
after the number, changing last parameter NULL to `""'. */
|
||||
if (!valid_suffixes)
|
||||
{
|
||||
*val = tmp;
|
||||
return LONGINT_OK;
|
||||
}
|
||||
|
||||
if (**p != '\0')
|
||||
{
|
||||
int base = 1024;
|
||||
int suffixes = 1;
|
||||
int overflow;
|
||||
|
||||
if (!strchr (valid_suffixes, **p))
|
||||
{
|
||||
*val = tmp;
|
||||
return LONGINT_INVALID_SUFFIX_CHAR;
|
||||
}
|
||||
|
||||
if (strchr (valid_suffixes, '0'))
|
||||
{
|
||||
/* The ``valid suffix'' '0' is a special flag meaning that
|
||||
an optional second suffix is allowed, which can change
|
||||
the base. A suffix "B" (e.g. "100MB") stands for a power
|
||||
of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for
|
||||
a power of 1024. If no suffix (e.g. "100M"), assume
|
||||
power-of-1024. */
|
||||
|
||||
switch (p[0][1])
|
||||
{
|
||||
case 'i':
|
||||
if (p[0][2] == 'B')
|
||||
suffixes += 2;
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
case 'D': /* 'D' is obsolescent */
|
||||
base = 1000;
|
||||
suffixes++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (**p)
|
||||
{
|
||||
case 'b':
|
||||
overflow = bkm_scale (&tmp, 512);
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
overflow = bkm_scale (&tmp, 1024);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
overflow = 0;
|
||||
break;
|
||||
|
||||
case 'E': /* exa or exbi */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 6);
|
||||
break;
|
||||
|
||||
case 'G': /* giga or gibi */
|
||||
case 'g': /* 'g' is undocumented; for compatibility only */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 3);
|
||||
break;
|
||||
|
||||
case 'k': /* kilo */
|
||||
case 'K': /* kibi */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 1);
|
||||
break;
|
||||
|
||||
case 'M': /* mega or mebi */
|
||||
case 'm': /* 'm' is undocumented; for compatibility only */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 2);
|
||||
break;
|
||||
|
||||
case 'P': /* peta or pebi */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 5);
|
||||
break;
|
||||
|
||||
case 'T': /* tera or tebi */
|
||||
case 't': /* 't' is undocumented; for compatibility only */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 4);
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
overflow = bkm_scale (&tmp, 2);
|
||||
break;
|
||||
|
||||
case 'Y': /* yotta or 2**80 */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 8);
|
||||
break;
|
||||
|
||||
case 'Z': /* zetta or 2**70 */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 7);
|
||||
break;
|
||||
|
||||
default:
|
||||
*val = tmp;
|
||||
return LONGINT_INVALID_SUFFIX_CHAR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (overflow)
|
||||
return LONGINT_OVERFLOW;
|
||||
|
||||
(*p) += suffixes;
|
||||
}
|
||||
|
||||
*val = tmp;
|
||||
return LONGINT_OK;
|
||||
}
|
||||
|
||||
#ifdef TESTING_XSTRTO
|
||||
|
||||
# include <stdio.h>
|
||||
# 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<argc; i++)
|
||||
{
|
||||
char *p;
|
||||
__strtol_t val;
|
||||
|
||||
s_err = __xstrtol (argv[i], &p, 0, &val, "bckmw");
|
||||
if (s_err == LONGINT_OK)
|
||||
{
|
||||
printf ("%s->%lu (%s)\n", argv[i], val, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
STRTOL_FATAL_ERROR (argv[i], "arg", s_err);
|
||||
}
|
||||
}
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TESTING_XSTRTO */
|
82
contrib/gnu-sort/lib/xstrtol.h
Normal file
82
contrib/gnu-sort/lib/xstrtol.h
Normal file
@ -0,0 +1,82 @@
|
||||
/* A more useful interface to strtol.
|
||||
Copyright 1995, 1996, 1998, 1999, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef XSTRTOL_H_
|
||||
# define XSTRTOL_H_ 1
|
||||
|
||||
# if HAVE_INTTYPES_H
|
||||
# include <inttypes.h> /* for uintmax_t */
|
||||
# endif
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef _STRTOL_ERROR
|
||||
enum strtol_error
|
||||
{
|
||||
LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW
|
||||
};
|
||||
typedef enum strtol_error strtol_error;
|
||||
# endif
|
||||
|
||||
# define _DECLARE_XSTRTOL(name, type) \
|
||||
strtol_error \
|
||||
name PARAMS ((const char *s, char **ptr, int base, \
|
||||
type *val, const char *valid_suffixes));
|
||||
_DECLARE_XSTRTOL (xstrtol, long int)
|
||||
_DECLARE_XSTRTOL (xstrtoul, unsigned long int)
|
||||
_DECLARE_XSTRTOL (xstrtoimax, intmax_t)
|
||||
_DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
|
||||
|
||||
# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \
|
||||
do \
|
||||
{ \
|
||||
switch ((Err)) \
|
||||
{ \
|
||||
case LONGINT_OK: \
|
||||
abort (); \
|
||||
\
|
||||
case LONGINT_INVALID: \
|
||||
error ((Exit_code), 0, "invalid %s `%s'", \
|
||||
(Argument_type_string), (Str)); \
|
||||
break; \
|
||||
\
|
||||
case LONGINT_INVALID_SUFFIX_CHAR: \
|
||||
error ((Exit_code), 0, "invalid character following %s in `%s'", \
|
||||
(Argument_type_string), (Str)); \
|
||||
break; \
|
||||
\
|
||||
case LONGINT_OVERFLOW: \
|
||||
error ((Exit_code), 0, "%s `%s' too large", \
|
||||
(Argument_type_string), (Str)); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
# define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \
|
||||
_STRTOL_ERROR (2, Str, Argument_type_string, Err)
|
||||
|
||||
# define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \
|
||||
_STRTOL_ERROR (0, Str, Argument_type_string, Err)
|
||||
|
||||
#endif /* not XSTRTOL_H_ */
|
4
contrib/gnu-sort/lib/xstrtoul.c
Normal file
4
contrib/gnu-sort/lib/xstrtoul.c
Normal file
@ -0,0 +1,4 @@
|
||||
#define __strtol strtoul
|
||||
#define __strtol_t unsigned long int
|
||||
#define __xstrtol xstrtoul
|
||||
#include "xstrtol.c"
|
31
contrib/gnu-sort/lib/xstrtoumax.c
Normal file
31
contrib/gnu-sort/lib/xstrtoumax.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* xstrtoumax.c -- A more useful interface to strtoumax.
|
||||
Copyright 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#define __strtol strtoumax
|
||||
#define __strtol_t uintmax_t
|
||||
#define __xstrtol xstrtoumax
|
||||
#include "xstrtol.c"
|
113
contrib/gnu-sort/man/sort.1
Normal file
113
contrib/gnu-sort/man/sort.1
Normal file
@ -0,0 +1,113 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.25.
|
||||
.TH SORT "1" "February 2002" "sort (textutils) 2.0.21" "User Commands"
|
||||
.SH NAME
|
||||
sort \- sort lines of text files
|
||||
.SH SYNOPSIS
|
||||
.B sort
|
||||
[\fIOPTION\fR]... [\fIFILE\fR]...
|
||||
.SH DESCRIPTION
|
||||
.\" Add any additional description here
|
||||
.PP
|
||||
Write sorted concatenation of all FILE(s) to standard output.
|
||||
.PP
|
||||
Ordering options:
|
||||
.PP
|
||||
Mandatory arguments to long options are mandatory for short options too.
|
||||
.HP
|
||||
\fB\-b\fR, \fB\-\-ignore\-leading\-blanks\fR ignore leading blanks
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-dictionary\-order\fR
|
||||
consider only blanks and alphanumeric characters
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-ignore\-case\fR
|
||||
fold lower case to upper case characters
|
||||
.TP
|
||||
\fB\-g\fR, \fB\-\-general\-numeric\-sort\fR
|
||||
compare according to general numerical value
|
||||
.TP
|
||||
\fB\-i\fR, \fB\-\-ignore\-nonprinting\fR
|
||||
consider only printable characters
|
||||
.TP
|
||||
\fB\-M\fR, \fB\-\-month\-sort\fR
|
||||
compare (unknown) < `JAN' < ... < `DEC'
|
||||
.TP
|
||||
\fB\-n\fR, \fB\-\-numeric\-sort\fR
|
||||
compare according to string numerical value
|
||||
.TP
|
||||
\fB\-r\fR, \fB\-\-reverse\fR
|
||||
reverse the result of comparisons
|
||||
.PP
|
||||
Other options:
|
||||
.TP
|
||||
\fB\-c\fR, \fB\-\-check\fR
|
||||
check whether input is sorted; do not sort
|
||||
.TP
|
||||
\fB\-k\fR, \fB\-\-key\fR=\fIPOS1[\fR,POS2]
|
||||
start a key at POS1, end it at POS 2 (origin 1)
|
||||
.TP
|
||||
\fB\-m\fR, \fB\-\-merge\fR
|
||||
merge already sorted files; do not sort
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR
|
||||
write result to FILE instead of standard output
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-stable\fR
|
||||
stabilize sort by disabling last-resort comparison
|
||||
.TP
|
||||
\fB\-S\fR, \fB\-\-buffer\-size\fR=\fISIZE\fR
|
||||
use SIZE for main memory buffer
|
||||
.HP
|
||||
\fB\-t\fR, \fB\-\-field\-separator\fR=\fISEP\fR use SEP instead of non- to whitespace transition
|
||||
.TP
|
||||
\fB\-T\fR, \fB\-\-temporary\-directory\fR=\fIDIR\fR
|
||||
use DIR for temporaries, not $TMPDIR or /tmp
|
||||
multiple options specify multiple directories
|
||||
.TP
|
||||
\fB\-u\fR, \fB\-\-unique\fR
|
||||
with \fB\-c\fR: check for strict ordering
|
||||
otherwise: output only the first of an equal run
|
||||
.TP
|
||||
\fB\-z\fR, \fB\-\-zero\-terminated\fR
|
||||
end lines with 0 byte, not newline
|
||||
.TP
|
||||
\fB\-\-help\fR
|
||||
display this help and exit
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
output version information and exit
|
||||
.PP
|
||||
POS is F[.C][OPTS], where F is the field number and C the character position
|
||||
in the field. OPTS is one or more single-letter ordering options, which
|
||||
override global ordering options for that key. If no key is given, use the
|
||||
entire line as the key.
|
||||
.PP
|
||||
SIZE may be followed by the following multiplicative suffixes:
|
||||
% 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y.
|
||||
.PP
|
||||
With no FILE, or when FILE is -, read standard input.
|
||||
.PP
|
||||
*** WARNING ***
|
||||
The locale specified by the environment affects sort order.
|
||||
Set LC_ALL=C to get the traditional sort order that uses
|
||||
native byte values.
|
||||
.SH AUTHOR
|
||||
Written by Mike Haertel and Paul Eggert.
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to <bug-textutils@gnu.org>.
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 2002 Free Software Foundation, Inc.
|
||||
.br
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B sort
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B sort
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info sort
|
||||
.PP
|
||||
should give you access to the complete manual.
|
2502
contrib/gnu-sort/src/sort.c
Normal file
2502
contrib/gnu-sort/src/sort.c
Normal file
File diff suppressed because it is too large
Load Diff
565
contrib/gnu-sort/src/sys2.h
Normal file
565
contrib/gnu-sort/src/sys2.h
Normal file
@ -0,0 +1,565 @@
|
||||
/* WARNING -- this file is temporary. It is shared between the
|
||||
sh-utils, fileutils, and textutils packages. Once I find a little
|
||||
more time, I'll merge the remaining things in system.h and everything
|
||||
in this file will go back there. */
|
||||
|
||||
#if STAT_MACROS_BROKEN
|
||||
# undef S_ISBLK
|
||||
# undef S_ISCHR
|
||||
# undef S_ISDIR
|
||||
# undef S_ISDOOR
|
||||
# undef S_ISFIFO
|
||||
# undef S_ISLNK
|
||||
# undef S_ISMPB
|
||||
# undef S_ISMPC
|
||||
# undef S_ISNWK
|
||||
# undef S_ISREG
|
||||
# undef S_ISSOCK
|
||||
#endif /* STAT_MACROS_BROKEN. */
|
||||
|
||||
#ifndef S_IFMT
|
||||
# define S_IFMT 0170000
|
||||
#endif
|
||||
#if !defined(S_ISBLK) && defined(S_IFBLK)
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#endif
|
||||
#if !defined(S_ISCHR) && defined(S_IFCHR)
|
||||
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#endif
|
||||
#if !defined(S_ISDIR) && defined(S_IFDIR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#if !defined(S_ISREG) && defined(S_IFREG)
|
||||
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
#if !defined(S_ISFIFO) && defined(S_IFIFO)
|
||||
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#endif
|
||||
#if !defined(S_ISLNK) && defined(S_IFLNK)
|
||||
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#endif
|
||||
#if !defined(S_ISSOCK) && defined(S_IFSOCK)
|
||||
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
#endif
|
||||
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
|
||||
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
|
||||
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
|
||||
#endif
|
||||
#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
|
||||
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
|
||||
#endif
|
||||
#if !defined(S_ISDOOR) && defined(S_IFDOOR) /* Solaris 2.5 and up */
|
||||
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
|
||||
#endif
|
||||
|
||||
#if !S_ISUID
|
||||
# define S_ISUID 04000
|
||||
#endif
|
||||
#if !S_ISGID
|
||||
# define S_ISGID 02000
|
||||
#endif
|
||||
|
||||
/* S_ISVTX is a common extension to POSIX. */
|
||||
#ifndef S_ISVTX
|
||||
# define S_ISVTX 01000
|
||||
#endif
|
||||
|
||||
#if !S_IRUSR && S_IREAD
|
||||
# define S_IRUSR S_IREAD
|
||||
#endif
|
||||
#if !S_IRUSR
|
||||
# define S_IRUSR 00400
|
||||
#endif
|
||||
#if !S_IRGRP
|
||||
# define S_IRGRP (S_IRUSR >> 3)
|
||||
#endif
|
||||
#if !S_IROTH
|
||||
# define S_IROTH (S_IRUSR >> 6)
|
||||
#endif
|
||||
|
||||
#if !S_IWUSR && S_IWRITE
|
||||
# define S_IWUSR S_IWRITE
|
||||
#endif
|
||||
#if !S_IWUSR
|
||||
# define S_IWUSR 00200
|
||||
#endif
|
||||
#if !S_IWGRP
|
||||
# define S_IWGRP (S_IWUSR >> 3)
|
||||
#endif
|
||||
#if !S_IWOTH
|
||||
# define S_IWOTH (S_IWUSR >> 6)
|
||||
#endif
|
||||
|
||||
#if !S_IXUSR && S_IEXEC
|
||||
# define S_IXUSR S_IEXEC
|
||||
#endif
|
||||
#if !S_IXUSR
|
||||
# define S_IXUSR 00100
|
||||
#endif
|
||||
#if !S_IXGRP
|
||||
# define S_IXGRP (S_IXUSR >> 3)
|
||||
#endif
|
||||
#if !S_IXOTH
|
||||
# define S_IXOTH (S_IXUSR >> 6)
|
||||
#endif
|
||||
|
||||
#if !S_IRWXU
|
||||
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
|
||||
#endif
|
||||
#if !S_IRWXG
|
||||
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
|
||||
#endif
|
||||
#if !S_IRWXO
|
||||
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
|
||||
#endif
|
||||
|
||||
/* S_IXUGO is a common extension to POSIX. */
|
||||
#if !S_IXUGO
|
||||
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
|
||||
#endif
|
||||
|
||||
#ifndef S_IRWXUGO
|
||||
# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
|
||||
#endif
|
||||
|
||||
/* All the mode bits that can be affected by chmod. */
|
||||
#define CHMOD_MODE_BITS \
|
||||
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
|
||||
|
||||
#ifdef ST_MTIM_NSEC
|
||||
# define ST_TIME_CMP_NS(a, b, ns) ((a).ns < (b).ns ? -1 : (a).ns > (b).ns)
|
||||
#else
|
||||
# define ST_TIME_CMP_NS(a, b, ns) 0
|
||||
#endif
|
||||
#define ST_TIME_CMP(a, b, s, ns) \
|
||||
((a).s < (b).s ? -1 : (a).s > (b).s ? 1 : ST_TIME_CMP_NS(a, b, ns))
|
||||
#define ATIME_CMP(a, b) ST_TIME_CMP (a, b, st_atime, st_atim.ST_MTIM_NSEC)
|
||||
#define CTIME_CMP(a, b) ST_TIME_CMP (a, b, st_ctime, st_ctim.ST_MTIM_NSEC)
|
||||
#define MTIME_CMP(a, b) ST_TIME_CMP (a, b, st_mtime, st_mtim.ST_MTIM_NSEC)
|
||||
|
||||
#ifndef RETSIGTYPE
|
||||
# define RETSIGTYPE void
|
||||
#endif
|
||||
|
||||
#if __GNUC__
|
||||
# ifndef alloca
|
||||
# define alloca __builtin_alloca
|
||||
# endif
|
||||
#else
|
||||
# if HAVE_ALLOCA_H
|
||||
# include <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
|
||||
|
||||
#ifdef __DJGPP__
|
||||
/* We need the declaration of setmode. */
|
||||
# include <io.h>
|
||||
/* We need the declaration of __djgpp_set_ctrl_c. */
|
||||
# include <sys/exceptn.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h> /* for the definition of UINTMAX_MAX */
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
/* 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 <sys/euc.h> on at least Solaris2.6 systems. */
|
||||
#undef ISPRINT
|
||||
|
||||
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
|
||||
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
|
||||
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
|
||||
#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
|
||||
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
|
||||
#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
|
||||
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
|
||||
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
|
||||
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
|
||||
#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
|
||||
|
||||
#if STDC_HEADERS
|
||||
# define TOLOWER(Ch) tolower (Ch)
|
||||
# define TOUPPER(Ch) toupper (Ch)
|
||||
#else
|
||||
# define TOLOWER(Ch) (ISUPPER (Ch) ? tolower (Ch) : (Ch))
|
||||
# define TOUPPER(Ch) (ISLOWER (Ch) ? toupper (Ch) : (Ch))
|
||||
#endif
|
||||
|
||||
/* ISDIGIT differs from ISDIGIT_LOCALE, as follows:
|
||||
- Its arg may be any int or unsigned int; it need not be an unsigned char.
|
||||
- It's guaranteed to evaluate its argument exactly once.
|
||||
- It's typically faster.
|
||||
POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
|
||||
ISDIGIT_LOCALE unless it's important to use the locale's definition
|
||||
of `digit' even when the host does not conform to POSIX. */
|
||||
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
|
||||
|
||||
#ifndef PARAMS
|
||||
# if PROTOTYPES
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Take care of NLS matters. */
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
#if !HAVE_SETLOCALE
|
||||
# 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
|
||||
|
||||
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
|
||||
|
||||
#if !HAVE_DECL_FREE
|
||||
void free ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_MALLOC
|
||||
char *malloc ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_MEMCHR
|
||||
char *memchr ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_REALLOC
|
||||
char *realloc ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STPCPY
|
||||
# ifndef stpcpy
|
||||
char *stpcpy ();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STRNDUP
|
||||
char *strndup ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STRSTR
|
||||
char *strstr ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_GETENV
|
||||
char *getenv ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_LSEEK
|
||||
off_t lseek ();
|
||||
#endif
|
||||
|
||||
/* This is needed on some AIX systems. */
|
||||
#if !HAVE_DECL_STRTOUL
|
||||
unsigned long strtoul ();
|
||||
#endif
|
||||
|
||||
/* This is needed on some AIX systems. */
|
||||
#if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG
|
||||
unsigned long long strtoull ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_GETLOGIN
|
||||
char *getlogin ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_TTYNAME
|
||||
char *ttyname ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_GETEUID
|
||||
uid_t geteuid ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_GETPWUID
|
||||
struct passwd *getpwuid ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_GETGRGID
|
||||
struct group *getgrgid ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_GETUID
|
||||
uid_t getuid ();
|
||||
#endif
|
||||
|
||||
#include "xalloc.h"
|
||||
|
||||
#if ! defined HAVE_MEMPCPY && ! defined mempcpy
|
||||
/* Be CAREFUL that there are no side effects in N. */
|
||||
# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
|
||||
#endif
|
||||
|
||||
/* Include automatically-generated macros for unlocked I/O. */
|
||||
#include "unlocked-io.h"
|
||||
|
||||
#define SAME_INODE(Stat_buf_1, Stat_buf_2) \
|
||||
((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
|
||||
&& (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
|
||||
|
||||
#define DOT_OR_DOTDOT(Basename) \
|
||||
(Basename[0] == '.' && (Basename[1] == '\0' \
|
||||
|| (Basename[1] == '.' && Basename[2] == '\0')))
|
||||
|
||||
#if SETVBUF_REVERSED
|
||||
# define SETVBUF(Stream, Buffer, Type, Size) \
|
||||
setvbuf (Stream, Type, Buffer, Size)
|
||||
#else
|
||||
# define SETVBUF(Stream, Buffer, Type, Size) \
|
||||
setvbuf (Stream, Buffer, Type, Size)
|
||||
#endif
|
||||
|
||||
/* Factor out some of the common --help and --version processing code. */
|
||||
|
||||
/* These enum values cannot possibly conflict with the option values
|
||||
ordinarily used by commands, including CHAR_MAX + 1, etc. Avoid
|
||||
CHAR_MIN - 1, as it may equal -1, the getopt end-of-options value. */
|
||||
enum
|
||||
{
|
||||
GETOPT_HELP_CHAR = (CHAR_MIN - 2),
|
||||
GETOPT_VERSION_CHAR = (CHAR_MIN - 3)
|
||||
};
|
||||
|
||||
#define GETOPT_HELP_OPTION_DECL \
|
||||
"help", no_argument, 0, GETOPT_HELP_CHAR
|
||||
#define GETOPT_VERSION_OPTION_DECL \
|
||||
"version", no_argument, 0, GETOPT_VERSION_CHAR
|
||||
|
||||
#define case_GETOPT_HELP_CHAR \
|
||||
case GETOPT_HELP_CHAR: \
|
||||
usage (EXIT_SUCCESS); \
|
||||
break;
|
||||
|
||||
#define HELP_OPTION_DESCRIPTION \
|
||||
_(" --help display this help and exit\n")
|
||||
#define VERSION_OPTION_DESCRIPTION \
|
||||
_(" --version output version information and exit\n")
|
||||
|
||||
#include "closeout.h"
|
||||
#include "version-etc.h"
|
||||
|
||||
#define case_GETOPT_VERSION_CHAR(Program_name, Authors) \
|
||||
case GETOPT_VERSION_CHAR: \
|
||||
version_etc (stdout, Program_name, PACKAGE, VERSION, Authors); \
|
||||
exit (EXIT_SUCCESS); \
|
||||
break;
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* The extra casts work around common compiler bugs. */
|
||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
|
||||
It is necessary at least when t == time_t. */
|
||||
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
|
||||
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
||||
|
||||
/* Upper bound on the string length of an integer converted to string.
|
||||
302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
|
||||
add 1 for integer division truncation; add 1 more for a minus sign. */
|
||||
#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
|
||||
|
||||
#ifndef CHAR_MIN
|
||||
# define CHAR_MIN TYPE_MINIMUM (char)
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_MAX
|
||||
# define CHAR_MAX TYPE_MAXIMUM (char)
|
||||
#endif
|
||||
|
||||
#ifndef SCHAR_MIN
|
||||
# define SCHAR_MIN (-1 - SCHAR_MAX)
|
||||
#endif
|
||||
|
||||
#ifndef SCHAR_MAX
|
||||
# define SCHAR_MAX (CHAR_MAX == UCHAR_MAX ? CHAR_MAX / 2 : CHAR_MAX)
|
||||
#endif
|
||||
|
||||
#ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX TYPE_MAXIMUM (unsigned char)
|
||||
#endif
|
||||
|
||||
#ifndef SHRT_MIN
|
||||
# define SHRT_MIN TYPE_MINIMUM (short int)
|
||||
#endif
|
||||
|
||||
#ifndef SHRT_MAX
|
||||
# define SHRT_MAX TYPE_MAXIMUM (short int)
|
||||
#endif
|
||||
|
||||
#ifndef INT_MAX
|
||||
# define INT_MAX TYPE_MAXIMUM (int)
|
||||
#endif
|
||||
|
||||
#ifndef UINT_MAX
|
||||
# define UINT_MAX TYPE_MAXIMUM (unsigned int)
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MAX
|
||||
# define LONG_MAX TYPE_MAXIMUM (long)
|
||||
#endif
|
||||
|
||||
#ifndef ULONG_MAX
|
||||
# define ULONG_MAX TYPE_MAXIMUM (unsigned long)
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX TYPE_MAXIMUM (size_t)
|
||||
#endif
|
||||
|
||||
#ifndef UINTMAX_MAX
|
||||
# define UINTMAX_MAX TYPE_MAXIMUM (uintmax_t)
|
||||
#endif
|
||||
|
||||
#ifndef OFF_T_MIN
|
||||
# define OFF_T_MIN TYPE_MINIMUM (off_t)
|
||||
#endif
|
||||
|
||||
#ifndef OFF_T_MAX
|
||||
# define OFF_T_MAX TYPE_MAXIMUM (off_t)
|
||||
#endif
|
||||
|
||||
#ifndef UID_T_MAX
|
||||
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
|
||||
#endif
|
||||
|
||||
#ifndef GID_T_MAX
|
||||
# define GID_T_MAX TYPE_MAXIMUM (gid_t)
|
||||
#endif
|
||||
|
||||
#ifndef PID_T_MAX
|
||||
# define PID_T_MAX TYPE_MAXIMUM (pid_t)
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* Use this to suppress gcc's `...may be used before initialized' warnings. */
|
||||
#ifdef lint
|
||||
# define IF_LINT(Code) Code
|
||||
#else
|
||||
# define IF_LINT(Code) /* empty */
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
#endif
|
||||
|
||||
#if defined strdupa
|
||||
# define ASSIGN_STRDUPA(DEST, S) \
|
||||
do { DEST = strdupa(S); } while (0)
|
||||
#else
|
||||
# define ASSIGN_STRDUPA(DEST, S) \
|
||||
do \
|
||||
{ \
|
||||
const char *s_ = (S); \
|
||||
size_t len_ = strlen (s_) + 1; \
|
||||
char *tmp_dest_ = (char *) alloca (len_); \
|
||||
DEST = memcpy (tmp_dest_, (s_), len_); \
|
||||
} \
|
||||
while (0)
|
||||
#endif
|
||||
|
||||
#ifndef EOVERFLOW
|
||||
# define EOVERFLOW EINVAL
|
||||
#endif
|
||||
|
||||
#if ! HAVE_FSEEKO && ! defined fseeko
|
||||
# define fseeko(s, o, w) ((o) == (long) (o) \
|
||||
? fseek (s, o, w) \
|
||||
: (errno = EOVERFLOW, -1))
|
||||
#endif
|
286
contrib/gnu-sort/src/system.h
Normal file
286
contrib/gnu-sort/src/system.h
Normal file
@ -0,0 +1,286 @@
|
||||
/* system-dependent definitions for fileutils, textutils, and sh-utils packages.
|
||||
Copyright (C) 1989, 1991-2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Include sys/types.h before this file. */
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if !defined(HAVE_MKFIFO)
|
||||
# define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
/* <unistd.h> should be included before any preprocessor test
|
||||
of _POSIX_VERSION. */
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef STDIN_FILENO
|
||||
# define STDIN_FILENO 0
|
||||
#endif
|
||||
|
||||
#ifndef STDOUT_FILENO
|
||||
# define STDOUT_FILENO 1
|
||||
#endif
|
||||
|
||||
#ifndef STDERR_FILENO
|
||||
# define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
/* limits.h must come before pathmax.h because limits.h on some systems
|
||||
undefs PATH_MAX, whereas pathmax.h sets PATH_MAX. */
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#include "pathmax.h"
|
||||
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Since major is a function on SVR4, we can't use `ifndef major'. */
|
||||
#if MAJOR_IN_MKDEV
|
||||
# include <sys/mkdev.h>
|
||||
# define HAVE_MAJOR
|
||||
#endif
|
||||
#if MAJOR_IN_SYSMACROS
|
||||
# include <sys/sysmacros.h>
|
||||
# define HAVE_MAJOR
|
||||
#endif
|
||||
#ifdef major /* Might be defined in sys/types.h. */
|
||||
# define HAVE_MAJOR
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MAJOR
|
||||
# define major(dev) (((dev) >> 8) & 0xff)
|
||||
# define minor(dev) ((dev) & 0xff)
|
||||
# define makedev(maj, min) (((maj) << 8) | (min))
|
||||
#endif
|
||||
#undef HAVE_MAJOR
|
||||
|
||||
#if HAVE_UTIME_H
|
||||
# include <utime.h>
|
||||
#endif
|
||||
|
||||
/* Some systems (even some that do have <utime.h>) don't declare this
|
||||
structure anywhere. */
|
||||
#ifndef HAVE_STRUCT_UTIMBUF
|
||||
struct utimbuf
|
||||
{
|
||||
long actime;
|
||||
long modtime;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Don't use bcopy! Use memmove if source and destination may overlap,
|
||||
memcpy otherwise. */
|
||||
|
||||
#if HAVE_STRING_H
|
||||
# if !STDC_HEADERS && HAVE_MEMORY_H
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
typedef enum {false = 0, true = 1} bool;
|
||||
#endif
|
||||
|
||||
#if HAVE_STDLIB_H
|
||||
# define getopt system_getopt
|
||||
# include <stdlib.h>
|
||||
# undef getopt
|
||||
#endif
|
||||
|
||||
/* The following test is to work around the gross typo in
|
||||
systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE
|
||||
is defined to 0, not 1. */
|
||||
#if !EXIT_FAILURE
|
||||
# undef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#ifndef EXIT_SUCCESS
|
||||
# define EXIT_SUCCESS 0
|
||||
#endif
|
||||
|
||||
#if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#else
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
|
||||
#if !defined (SEEK_SET)
|
||||
# define SEEK_SET 0
|
||||
# define SEEK_CUR 1
|
||||
# define SEEK_END 2
|
||||
#endif
|
||||
#ifndef F_OK
|
||||
# define F_OK 0
|
||||
# define X_OK 1
|
||||
# define W_OK 2
|
||||
# define R_OK 4
|
||||
#endif
|
||||
|
||||
/* For systems that distinguish between text and binary I/O.
|
||||
O_BINARY is usually declared in fcntl.h */
|
||||
#if !defined O_BINARY && defined _O_BINARY
|
||||
/* For MSC-compatible compilers. */
|
||||
# define O_BINARY _O_BINARY
|
||||
# define O_TEXT _O_TEXT
|
||||
#endif
|
||||
|
||||
#ifdef __BEOS__
|
||||
/* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */
|
||||
# undef O_BINARY
|
||||
# undef O_TEXT
|
||||
#endif
|
||||
|
||||
#if O_BINARY
|
||||
# ifndef __DJGPP__
|
||||
# define setmode _setmode
|
||||
# define fileno(_fp) _fileno (_fp)
|
||||
# endif /* not DJGPP */
|
||||
# define SET_MODE(_f, _m) setmode (_f, _m)
|
||||
# define SET_BINARY(_f) do {if (!isatty(_f)) setmode (_f, O_BINARY);} while (0)
|
||||
# define SET_BINARY2(_f1, _f2) \
|
||||
do { \
|
||||
if (!isatty (_f1)) \
|
||||
{ \
|
||||
setmode (_f1, O_BINARY); \
|
||||
if (!isatty (_f2)) \
|
||||
setmode (_f2, O_BINARY); \
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
# define SET_MODE(_f, _m) (void)0
|
||||
# define SET_BINARY(f) (void)0
|
||||
# define SET_BINARY2(f1,f2) (void)0
|
||||
# define O_BINARY 0
|
||||
# define O_TEXT 0
|
||||
#endif /* O_BINARY */
|
||||
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
# 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 <sys/ndir.h>
|
||||
# endif /* HAVE_SYS_NDIR_H */
|
||||
# if HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif /* HAVE_SYS_DIR_H */
|
||||
# if HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif /* HAVE_NDIR_H */
|
||||
#endif /* HAVE_DIRENT_H */
|
||||
|
||||
#if CLOSEDIR_VOID
|
||||
/* Fake a return value. */
|
||||
# define CLOSEDIR(d) (closedir (d), 0)
|
||||
#else
|
||||
# define CLOSEDIR(d) closedir (d)
|
||||
#endif
|
||||
|
||||
/* Get or fake the disk device blocksize.
|
||||
Usually defined by sys/param.h (if at all). */
|
||||
#if !defined DEV_BSIZE && defined BSIZE
|
||||
# define DEV_BSIZE BSIZE
|
||||
#endif
|
||||
#if !defined DEV_BSIZE && defined BBSIZE /* SGI */
|
||||
# define DEV_BSIZE BBSIZE
|
||||
#endif
|
||||
#ifndef DEV_BSIZE
|
||||
# define DEV_BSIZE 4096
|
||||
#endif
|
||||
|
||||
/* Extract or fake data from a `struct stat'.
|
||||
ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes.
|
||||
ST_NBLOCKS: Number of blocks in the file, including indirect blocks.
|
||||
ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS. */
|
||||
#ifndef HAVE_STRUCT_STAT_ST_BLOCKS
|
||||
# define ST_BLKSIZE(statbuf) DEV_BSIZE
|
||||
# if defined(_POSIX_SOURCE) || !defined(BSIZE) /* fileblocks.c uses BSIZE. */
|
||||
# define ST_NBLOCKS(statbuf) \
|
||||
(S_ISREG ((statbuf).st_mode) \
|
||||
|| S_ISDIR ((statbuf).st_mode) \
|
||||
? (statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 0) : 0)
|
||||
# else /* !_POSIX_SOURCE && BSIZE */
|
||||
# define ST_NBLOCKS(statbuf) \
|
||||
(S_ISREG ((statbuf).st_mode) \
|
||||
|| S_ISDIR ((statbuf).st_mode) \
|
||||
? st_blocks ((statbuf).st_size) : 0)
|
||||
# endif /* !_POSIX_SOURCE && BSIZE */
|
||||
#else /* HAVE_STRUCT_STAT_ST_BLOCKS */
|
||||
/* Some systems, like Sequents, return st_blksize of 0 on pipes. */
|
||||
# define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
|
||||
? (statbuf).st_blksize : DEV_BSIZE)
|
||||
# if defined(hpux) || defined(__hpux__) || defined(__hpux)
|
||||
/* HP-UX counts st_blocks in 1024-byte units.
|
||||
This loses when mixing HP-UX and BSD filesystems with NFS. */
|
||||
# define ST_NBLOCKSIZE 1024
|
||||
# else /* !hpux */
|
||||
# if defined(_AIX) && defined(_I386)
|
||||
/* AIX PS/2 counts st_blocks in 4K units. */
|
||||
# define ST_NBLOCKSIZE (4 * 1024)
|
||||
# else /* not AIX PS/2 */
|
||||
# if defined(_CRAY)
|
||||
# define ST_NBLOCKS(statbuf) \
|
||||
(S_ISREG ((statbuf).st_mode) \
|
||||
|| S_ISDIR ((statbuf).st_mode) \
|
||||
? (statbuf).st_blocks * ST_BLKSIZE(statbuf)/ST_NBLOCKSIZE : 0)
|
||||
# endif /* _CRAY */
|
||||
# endif /* not AIX PS/2 */
|
||||
# endif /* !hpux */
|
||||
#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
|
||||
|
||||
#ifndef ST_NBLOCKS
|
||||
# define ST_NBLOCKS(statbuf) \
|
||||
(S_ISREG ((statbuf).st_mode) \
|
||||
|| S_ISDIR ((statbuf).st_mode) \
|
||||
? (statbuf).st_blocks : 0)
|
||||
#endif
|
||||
|
||||
#ifndef ST_NBLOCKSIZE
|
||||
# define ST_NBLOCKSIZE 512
|
||||
#endif
|
||||
|
||||
#include "sys2.h"
|
Loading…
Reference in New Issue
Block a user