Virgin import of diffutils 2.8.7.
This commit is contained in:
parent
964382dc00
commit
18fd37a72c
768
contrib/diff/ABOUT-NLS
Normal file
768
contrib/diff/ABOUT-NLS
Normal file
@ -0,0 +1,768 @@
|
||||
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'.
|
||||
|
||||
Special advice for Norwegian users: The language code for Norwegian
|
||||
bokma*l changed from `no' to `nb' recently (in 2003). During the
|
||||
transition period, while some message catalogs for this language are
|
||||
installed under `nb' and some older ones under `no', it's recommended
|
||||
for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and
|
||||
older translations are used.
|
||||
|
||||
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
|
||||
2004. 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 af am ar az be bg bs ca cs da de el en en_GB eo es
|
||||
+----------------------------------------------------+
|
||||
a2ps | [] [] [] [] |
|
||||
aegis | () |
|
||||
ant-phone | () |
|
||||
anubis | |
|
||||
ap-utils | |
|
||||
aspell | [] |
|
||||
bash | [] [] [] [] |
|
||||
batchelor | |
|
||||
bfd | [] [] |
|
||||
binutils | [] [] |
|
||||
bison | [] [] [] |
|
||||
bluez-pin | [] [] [] |
|
||||
clisp | |
|
||||
clisp | [] [] [] |
|
||||
console-tools | [] [] |
|
||||
coreutils | [] [] [] [] |
|
||||
cpio | [] [] [] |
|
||||
darkstat | [] () [] |
|
||||
diffutils | [] [] [] [] [] [] [] |
|
||||
e2fsprogs | [] [] [] |
|
||||
enscript | [] [] [] [] |
|
||||
error | [] [] [] [] [] |
|
||||
fetchmail | [] () [] [] [] [] |
|
||||
fileutils | [] [] [] |
|
||||
findutils | [] [] [] [] [] [] [] |
|
||||
flex | [] [] [] [] |
|
||||
fslint | |
|
||||
gas | [] |
|
||||
gawk | [] [] [] [] |
|
||||
gbiff | [] |
|
||||
gcal | [] |
|
||||
gcc | [] [] |
|
||||
gettext | [] [] [] [] [] |
|
||||
gettext-examples | [] [] [] [] |
|
||||
gettext-runtime | [] [] [] [] [] |
|
||||
gettext-tools | [] [] [] |
|
||||
gimp-print | [] [] [] [] [] |
|
||||
gliv | |
|
||||
glunarclock | [] [] |
|
||||
gnubiff | [] |
|
||||
gnucash | [] () [] [] |
|
||||
gnucash-glossary | [] () [] |
|
||||
gnupg | [] () [] [] [] [] |
|
||||
gpe-aerial | [] |
|
||||
gpe-beam | [] [] |
|
||||
gpe-calendar | [] [] |
|
||||
gpe-clock | [] [] |
|
||||
gpe-conf | [] [] |
|
||||
gpe-contacts | [] [] |
|
||||
gpe-edit | [] |
|
||||
gpe-go | [] |
|
||||
gpe-login | [] [] |
|
||||
gpe-ownerinfo | [] [] |
|
||||
gpe-sketchbook | [] [] |
|
||||
gpe-su | [] [] |
|
||||
gpe-taskmanager | [] [] |
|
||||
gpe-timesheet | [] |
|
||||
gpe-today | [] [] |
|
||||
gpe-todo | [] [] |
|
||||
gphoto2 | [] [] [] [] |
|
||||
gprof | [] [] [] |
|
||||
gpsdrive | () () () |
|
||||
gramadoir | [] |
|
||||
grep | [] [] [] [] [] [] |
|
||||
gretl | [] |
|
||||
gtick | [] () |
|
||||
hello | [] [] [] [] [] [] |
|
||||
id-utils | [] [] |
|
||||
indent | [] [] [] [] |
|
||||
iso_3166 | [] [] [] [] [] [] [] [] [] [] |
|
||||
iso_3166_1 | [] [] [] [] [] [] |
|
||||
iso_3166_2 | |
|
||||
iso_3166_3 | [] |
|
||||
iso_4217 | [] [] [] [] |
|
||||
iso_639 | |
|
||||
jpilot | [] [] [] |
|
||||
jtag | |
|
||||
jwhois | [] |
|
||||
kbd | [] [] [] [] [] |
|
||||
latrine | () |
|
||||
ld | [] [] |
|
||||
libc | [] [] [] [] [] [] |
|
||||
libgpewidget | [] [] |
|
||||
libiconv | [] [] [] [] [] |
|
||||
lifelines | [] () |
|
||||
lilypond | [] |
|
||||
lingoteach | |
|
||||
lingoteach_lessons | () () |
|
||||
lynx | [] [] [] [] |
|
||||
m4 | [] [] [] [] |
|
||||
mailutils | [] [] |
|
||||
make | [] [] [] |
|
||||
man-db | [] () [] [] () |
|
||||
minicom | [] [] [] |
|
||||
mysecretdiary | [] [] [] |
|
||||
nano | [] () [] [] [] |
|
||||
nano_1_0 | [] () [] [] [] |
|
||||
opcodes | [] |
|
||||
parted | [] [] [] [] [] |
|
||||
ptx | [] [] [] [] [] |
|
||||
python | |
|
||||
radius | [] |
|
||||
recode | [] [] [] [] [] [] [] |
|
||||
rpm | [] [] |
|
||||
screem | |
|
||||
scrollkeeper | [] [] [] [] [] [] |
|
||||
sed | [] [] [] [] [] [] |
|
||||
sh-utils | [] [] [] |
|
||||
shared-mime-info | |
|
||||
sharutils | [] [] [] [] [] [] |
|
||||
silky | () |
|
||||
skencil | [] () [] |
|
||||
sketch | [] () [] |
|
||||
soundtracker | [] [] [] |
|
||||
sp | [] |
|
||||
tar | [] [] [] [] |
|
||||
texinfo | [] [] [] |
|
||||
textutils | [] [] [] [] |
|
||||
tin | () () |
|
||||
tp-robot | |
|
||||
tuxpaint | [] [] [] [] [] [] [] |
|
||||
unicode-han-tra... | |
|
||||
unicode-transla... | |
|
||||
util-linux | [] [] [] [] [] |
|
||||
vorbis-tools | [] [] [] [] |
|
||||
wastesedge | () |
|
||||
wdiff | [] [] [] [] |
|
||||
wget | [] [] [] [] [] [] |
|
||||
xchat | [] [] [] [] |
|
||||
xfree86_xkb_xml | [] [] |
|
||||
xpad | [] |
|
||||
+----------------------------------------------------+
|
||||
af am ar az be bg bs ca cs da de el en en_GB eo es
|
||||
4 0 0 1 9 4 1 40 41 60 78 17 1 5 13 68
|
||||
|
||||
et eu fa fi fr ga gl he hr hu id is it ja ko lg
|
||||
+-------------------------------------------------+
|
||||
a2ps | [] [] [] () () |
|
||||
aegis | |
|
||||
ant-phone | [] |
|
||||
anubis | [] |
|
||||
ap-utils | [] |
|
||||
aspell | [] [] |
|
||||
bash | [] [] |
|
||||
batchelor | [] [] |
|
||||
bfd | [] |
|
||||
binutils | [] [] |
|
||||
bison | [] [] [] [] |
|
||||
bluez-pin | [] [] [] [] [] |
|
||||
clisp | |
|
||||
clisp | [] |
|
||||
console-tools | |
|
||||
coreutils | [] [] [] [] [] [] |
|
||||
cpio | [] [] [] [] |
|
||||
darkstat | () [] [] [] |
|
||||
diffutils | [] [] [] [] [] [] [] |
|
||||
e2fsprogs | |
|
||||
enscript | [] [] |
|
||||
error | [] [] [] [] |
|
||||
fetchmail | [] |
|
||||
fileutils | [] [] [] [] [] [] |
|
||||
findutils | [] [] [] [] [] [] [] [] [] [] [] |
|
||||
flex | [] [] [] |
|
||||
fslint | [] |
|
||||
gas | [] |
|
||||
gawk | [] [] [] |
|
||||
gbiff | [] |
|
||||
gcal | [] |
|
||||
gcc | [] |
|
||||
gettext | [] [] [] |
|
||||
gettext-examples | [] [] |
|
||||
gettext-runtime | [] [] [] [] [] |
|
||||
gettext-tools | [] [] [] |
|
||||
gimp-print | [] [] |
|
||||
gliv | () |
|
||||
glunarclock | [] [] [] [] |
|
||||
gnubiff | [] |
|
||||
gnucash | () [] |
|
||||
gnucash-glossary | [] |
|
||||
gnupg | [] [] [] [] [] [] [] |
|
||||
gpe-aerial | [] |
|
||||
gpe-beam | [] |
|
||||
gpe-calendar | [] [] [] |
|
||||
gpe-clock | [] |
|
||||
gpe-conf | [] |
|
||||
gpe-contacts | [] [] |
|
||||
gpe-edit | [] [] |
|
||||
gpe-go | [] |
|
||||
gpe-login | [] [] |
|
||||
gpe-ownerinfo | [] [] [] |
|
||||
gpe-sketchbook | [] |
|
||||
gpe-su | [] |
|
||||
gpe-taskmanager | [] |
|
||||
gpe-timesheet | [] [] [] |
|
||||
gpe-today | [] [] |
|
||||
gpe-todo | [] [] |
|
||||
gphoto2 | [] [] [] |
|
||||
gprof | [] [] |
|
||||
gpsdrive | () () () |
|
||||
gramadoir | [] [] |
|
||||
grep | [] [] [] [] [] [] [] [] [] [] [] |
|
||||
gretl | [] [] |
|
||||
gtick | [] [] [] |
|
||||
hello | [] [] [] [] [] [] [] [] [] [] [] [] [] |
|
||||
id-utils | [] [] [] [] |
|
||||
indent | [] [] [] [] [] [] [] [] [] |
|
||||
iso_3166 | [] [] [] [] [] [] [] |
|
||||
iso_3166_1 | [] [] [] [] [] |
|
||||
iso_3166_2 | |
|
||||
iso_3166_3 | |
|
||||
iso_4217 | [] [] [] [] [] [] |
|
||||
iso_639 | |
|
||||
jpilot | [] () |
|
||||
jtag | [] |
|
||||
jwhois | [] [] [] [] |
|
||||
kbd | [] |
|
||||
latrine | [] |
|
||||
ld | [] |
|
||||
libc | [] [] [] [] [] [] |
|
||||
libgpewidget | [] [] [] [] |
|
||||
libiconv | [] [] [] [] [] [] [] [] [] |
|
||||
lifelines | () |
|
||||
lilypond | [] |
|
||||
lingoteach | [] [] |
|
||||
lingoteach_lessons | |
|
||||
lynx | [] [] [] [] |
|
||||
m4 | [] [] [] [] |
|
||||
mailutils | |
|
||||
make | [] [] [] [] [] [] |
|
||||
man-db | () () |
|
||||
minicom | [] [] [] [] |
|
||||
mysecretdiary | [] [] |
|
||||
nano | [] [] [] [] |
|
||||
nano_1_0 | [] [] [] [] |
|
||||
opcodes | [] |
|
||||
parted | [] [] [] |
|
||||
ptx | [] [] [] [] [] [] [] |
|
||||
python | |
|
||||
radius | [] |
|
||||
recode | [] [] [] [] [] [] |
|
||||
rpm | [] [] |
|
||||
screem | |
|
||||
scrollkeeper | [] |
|
||||
sed | [] [] [] [] [] [] [] [] [] |
|
||||
sh-utils | [] [] [] [] [] [] [] |
|
||||
shared-mime-info | [] [] [] |
|
||||
sharutils | [] [] [] [] [] |
|
||||
silky | () [] () () |
|
||||
skencil | [] |
|
||||
sketch | [] |
|
||||
soundtracker | [] [] |
|
||||
sp | [] () |
|
||||
tar | [] [] [] [] [] [] [] [] [] |
|
||||
texinfo | [] [] [] [] |
|
||||
textutils | [] [] [] [] [] [] |
|
||||
tin | [] () |
|
||||
tp-robot | [] |
|
||||
tuxpaint | [] [] [] [] [] [] [] [] [] |
|
||||
unicode-han-tra... | |
|
||||
unicode-transla... | [] [] |
|
||||
util-linux | [] [] [] [] () [] |
|
||||
vorbis-tools | [] |
|
||||
wastesedge | () |
|
||||
wdiff | [] [] [] [] [] [] |
|
||||
wget | [] [] [] [] [] [] [] |
|
||||
xchat | [] [] [] |
|
||||
xfree86_xkb_xml | [] [] |
|
||||
xpad | [] [] |
|
||||
+-------------------------------------------------+
|
||||
et eu fa fi fr ga gl he hr hu id is it ja ko lg
|
||||
22 2 1 26 106 28 24 8 10 41 33 1 26 33 12 0
|
||||
|
||||
lt lv mk mn ms mt nb nl nn no nso pl pt pt_BR ro ru
|
||||
+-----------------------------------------------------+
|
||||
a2ps | [] [] () () [] [] [] |
|
||||
aegis | () () () |
|
||||
ant-phone | [] [] |
|
||||
anubis | [] [] [] [] [] [] |
|
||||
ap-utils | [] () [] |
|
||||
aspell | [] |
|
||||
bash | [] [] [] |
|
||||
batchelor | [] |
|
||||
bfd | [] |
|
||||
binutils | [] |
|
||||
bison | [] [] [] [] [] |
|
||||
bluez-pin | [] [] [] |
|
||||
clisp | |
|
||||
clisp | [] |
|
||||
console-tools | [] |
|
||||
coreutils | [] [] |
|
||||
cpio | [] [] [] [] [] |
|
||||
darkstat | [] [] [] [] |
|
||||
diffutils | [] [] [] [] [] [] |
|
||||
e2fsprogs | [] |
|
||||
enscript | [] [] [] [] |
|
||||
error | [] [] [] |
|
||||
fetchmail | [] [] () [] |
|
||||
fileutils | [] [] [] |
|
||||
findutils | [] [] [] [] [] |
|
||||
flex | [] [] [] [] |
|
||||
fslint | [] [] |
|
||||
gas | |
|
||||
gawk | [] [] [] |
|
||||
gbiff | [] [] |
|
||||
gcal | |
|
||||
gcc | |
|
||||
gettext | [] [] [] |
|
||||
gettext-examples | [] [] [] |
|
||||
gettext-runtime | [] [] [] [] |
|
||||
gettext-tools | [] [] |
|
||||
gimp-print | [] |
|
||||
gliv | [] [] [] |
|
||||
glunarclock | [] [] [] [] |
|
||||
gnubiff | [] |
|
||||
gnucash | [] [] () [] |
|
||||
gnucash-glossary | [] [] |
|
||||
gnupg | [] |
|
||||
gpe-aerial | [] [] [] [] |
|
||||
gpe-beam | [] [] [] [] |
|
||||
gpe-calendar | [] [] [] [] |
|
||||
gpe-clock | [] [] [] [] |
|
||||
gpe-conf | [] [] [] [] |
|
||||
gpe-contacts | [] [] [] [] |
|
||||
gpe-edit | [] [] [] [] |
|
||||
gpe-go | [] [] [] |
|
||||
gpe-login | [] [] [] [] |
|
||||
gpe-ownerinfo | [] [] [] [] |
|
||||
gpe-sketchbook | [] [] [] [] |
|
||||
gpe-su | [] [] [] [] |
|
||||
gpe-taskmanager | [] [] [] [] |
|
||||
gpe-timesheet | [] [] [] [] |
|
||||
gpe-today | [] [] [] [] |
|
||||
gpe-todo | [] [] [] [] |
|
||||
gphoto2 | [] |
|
||||
gprof | [] [] |
|
||||
gpsdrive | () () [] |
|
||||
gramadoir | () [] |
|
||||
grep | [] [] [] [] [] |
|
||||
gretl | |
|
||||
gtick | [] [] [] |
|
||||
hello | [] [] [] [] [] [] [] [] [] [] |
|
||||
id-utils | [] [] [] [] |
|
||||
indent | [] [] [] [] |
|
||||
iso_3166 | [] [] [] |
|
||||
iso_3166_1 | [] [] |
|
||||
iso_3166_2 | |
|
||||
iso_3166_3 | [] |
|
||||
iso_4217 | [] [] [] [] [] [] [] [] |
|
||||
iso_639 | [] |
|
||||
jpilot | () () |
|
||||
jtag | |
|
||||
jwhois | [] [] [] [] () |
|
||||
kbd | [] [] [] |
|
||||
latrine | [] |
|
||||
ld | |
|
||||
libc | [] [] [] [] |
|
||||
libgpewidget | [] [] [] |
|
||||
libiconv | [] [] [] [] [] |
|
||||
lifelines | |
|
||||
lilypond | |
|
||||
lingoteach | |
|
||||
lingoteach_lessons | |
|
||||
lynx | [] [] [] |
|
||||
m4 | [] [] [] [] [] |
|
||||
mailutils | [] [] [] |
|
||||
make | [] [] [] [] |
|
||||
man-db | [] |
|
||||
minicom | [] [] [] [] |
|
||||
mysecretdiary | [] [] [] |
|
||||
nano | [] [] [] [] [] |
|
||||
nano_1_0 | [] [] [] [] [] [] |
|
||||
opcodes | [] [] |
|
||||
parted | [] [] [] [] |
|
||||
ptx | [] [] [] [] [] [] [] [] |
|
||||
python | |
|
||||
radius | [] [] |
|
||||
recode | [] [] [] [] |
|
||||
rpm | [] [] [] |
|
||||
screem | |
|
||||
scrollkeeper | [] [] [] [] [] |
|
||||
sed | [] [] [] |
|
||||
sh-utils | [] [] |
|
||||
shared-mime-info | [] [] |
|
||||
sharutils | [] [] |
|
||||
silky | () |
|
||||
skencil | [] [] |
|
||||
sketch | [] [] |
|
||||
soundtracker | |
|
||||
sp | |
|
||||
tar | [] [] [] [] [] [] |
|
||||
texinfo | [] [] [] [] |
|
||||
textutils | [] [] |
|
||||
tin | |
|
||||
tp-robot | [] |
|
||||
tuxpaint | [] [] [] [] [] [] [] [] |
|
||||
unicode-han-tra... | |
|
||||
unicode-transla... | |
|
||||
util-linux | [] [] [] |
|
||||
vorbis-tools | [] [] [] |
|
||||
wastesedge | |
|
||||
wdiff | [] [] [] [] [] |
|
||||
wget | [] [] [] |
|
||||
xchat | [] [] [] |
|
||||
xfree86_xkb_xml | [] [] |
|
||||
xpad | [] [] |
|
||||
+-----------------------------------------------------+
|
||||
lt lv mk mn ms mt nb nl nn no nso pl pt pt_BR ro ru
|
||||
1 2 0 3 12 0 10 69 6 7 1 40 26 36 76 63
|
||||
|
||||
sk sl sr sv ta th tr uk ven vi wa xh zh_CN zh_TW zu
|
||||
+-----------------------------------------------------+
|
||||
a2ps | [] [] [] [] | 16
|
||||
aegis | | 0
|
||||
ant-phone | | 3
|
||||
anubis | [] [] | 9
|
||||
ap-utils | () | 3
|
||||
aspell | | 4
|
||||
bash | | 9
|
||||
batchelor | | 3
|
||||
bfd | [] [] | 6
|
||||
binutils | [] [] [] | 8
|
||||
bison | [] [] | 14
|
||||
bluez-pin | [] [] [] | 14
|
||||
clisp | | 0
|
||||
clisp | | 5
|
||||
console-tools | | 3
|
||||
coreutils | [] [] [] [] | 16
|
||||
cpio | [] [] | 14
|
||||
darkstat | [] [] [] () () | 12
|
||||
diffutils | [] [] [] | 23
|
||||
e2fsprogs | [] [] | 6
|
||||
enscript | [] [] | 12
|
||||
error | [] [] [] | 15
|
||||
fetchmail | [] [] | 11
|
||||
fileutils | [] [] [] [] [] | 17
|
||||
findutils | [] [] [] [] [] [] | 29
|
||||
flex | [] [] | 13
|
||||
fslint | | 3
|
||||
gas | [] | 3
|
||||
gawk | [] [] | 12
|
||||
gbiff | | 4
|
||||
gcal | [] [] | 4
|
||||
gcc | [] | 4
|
||||
gettext | [] [] [] [] [] | 16
|
||||
gettext-examples | [] [] [] [] [] | 14
|
||||
gettext-runtime | [] [] [] [] [] [] [] [] | 22
|
||||
gettext-tools | [] [] [] [] [] [] | 14
|
||||
gimp-print | [] [] | 10
|
||||
gliv | | 3
|
||||
glunarclock | [] [] [] | 13
|
||||
gnubiff | | 3
|
||||
gnucash | [] [] | 9
|
||||
gnucash-glossary | [] [] [] | 8
|
||||
gnupg | [] [] [] [] | 17
|
||||
gpe-aerial | [] | 7
|
||||
gpe-beam | [] | 8
|
||||
gpe-calendar | [] [] [] [] | 13
|
||||
gpe-clock | [] [] [] | 10
|
||||
gpe-conf | [] [] | 9
|
||||
gpe-contacts | [] [] [] | 11
|
||||
gpe-edit | [] [] [] [] [] | 12
|
||||
gpe-go | | 5
|
||||
gpe-login | [] [] [] [] [] | 13
|
||||
gpe-ownerinfo | [] [] [] [] | 13
|
||||
gpe-sketchbook | [] [] | 9
|
||||
gpe-su | [] [] [] | 10
|
||||
gpe-taskmanager | [] [] [] | 10
|
||||
gpe-timesheet | [] [] [] [] | 12
|
||||
gpe-today | [] [] [] [] [] | 13
|
||||
gpe-todo | [] [] [] [] | 12
|
||||
gphoto2 | [] [] [] | 11
|
||||
gprof | [] [] | 9
|
||||
gpsdrive | [] [] | 3
|
||||
gramadoir | [] | 5
|
||||
grep | [] [] [] [] | 26
|
||||
gretl | | 3
|
||||
gtick | | 7
|
||||
hello | [] [] [] [] [] | 34
|
||||
id-utils | [] [] | 12
|
||||
indent | [] [] [] [] | 21
|
||||
iso_3166 | [] [] [] [] [] [] [] | 27
|
||||
iso_3166_1 | [] [] [] | 16
|
||||
iso_3166_2 | | 0
|
||||
iso_3166_3 | | 2
|
||||
iso_4217 | [] [] [] [] [] [] | 24
|
||||
iso_639 | | 1
|
||||
jpilot | [] [] [] [] [] | 9
|
||||
jtag | [] | 2
|
||||
jwhois | () [] [] | 11
|
||||
kbd | [] [] | 11
|
||||
latrine | | 2
|
||||
ld | [] [] | 5
|
||||
libc | [] [] [] [] | 20
|
||||
libgpewidget | [] [] [] [] | 13
|
||||
libiconv | [] [] [] [] [] [] [] [] | 27
|
||||
lifelines | [] | 2
|
||||
lilypond | [] | 3
|
||||
lingoteach | | 2
|
||||
lingoteach_lessons | () | 0
|
||||
lynx | [] [] [] | 14
|
||||
m4 | [] [] | 15
|
||||
mailutils | | 5
|
||||
make | [] [] [] | 16
|
||||
man-db | [] | 5
|
||||
minicom | | 11
|
||||
mysecretdiary | [] [] | 10
|
||||
nano | [] [] [] [] | 17
|
||||
nano_1_0 | [] [] [] | 17
|
||||
opcodes | [] [] | 6
|
||||
parted | [] [] [] | 15
|
||||
ptx | [] [] | 22
|
||||
python | | 0
|
||||
radius | | 4
|
||||
recode | [] [] [] | 20
|
||||
rpm | [] [] | 9
|
||||
screem | [] [] | 2
|
||||
scrollkeeper | [] [] [] | 15
|
||||
sed | [] [] [] [] [] [] | 24
|
||||
sh-utils | [] [] | 14
|
||||
shared-mime-info | [] [] | 7
|
||||
sharutils | [] [] [] [] | 17
|
||||
silky | () | 3
|
||||
skencil | [] | 6
|
||||
sketch | [] | 6
|
||||
soundtracker | [] [] | 7
|
||||
sp | [] | 3
|
||||
tar | [] [] [] [] [] | 24
|
||||
texinfo | [] [] [] | 14
|
||||
textutils | [] [] [] [] | 16
|
||||
tin | | 1
|
||||
tp-robot | | 2
|
||||
tuxpaint | [] [] [] [] [] | 29
|
||||
unicode-han-tra... | | 0
|
||||
unicode-transla... | | 2
|
||||
util-linux | [] [] | 15
|
||||
vorbis-tools | | 8
|
||||
wastesedge | | 0
|
||||
wdiff | [] [] [] | 18
|
||||
wget | [] [] [] [] [] [] [] [] | 24
|
||||
xchat | [] [] [] [] [] | 15
|
||||
xfree86_xkb_xml | [] [] [] [] [] | 11
|
||||
xpad | | 5
|
||||
+-----------------------------------------------------+
|
||||
63 teams sk sl sr sv ta th tr uk ven vi wa xh zh_CN zh_TW zu
|
||||
131 domains 47 19 28 83 0 0 59 13 1 1 11 0 22 22 0 1373
|
||||
|
||||
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 2004 seems to be old, you may fetch a more recent copy of
|
||||
this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date
|
||||
matrix with full percentage details can be found at
|
||||
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
|
||||
|
||||
Using `gettext' in new packages
|
||||
===============================
|
||||
|
||||
If you are writing a freely available program and want to
|
||||
internationalize it you are welcome to use GNU `gettext' in your
|
||||
package. Of course you have to respect the GNU Library General Public
|
||||
License which covers the use of the GNU `gettext' library. This means
|
||||
in particular that even non-free programs can use `libintl' as a shared
|
||||
library, whereas only free software can use `libintl' as a static
|
||||
library or use modified versions of `libintl'.
|
||||
|
||||
Once the sources are changed appropriately and the setup can handle
|
||||
the use of `gettext' the only thing missing are the translations. The
|
||||
Free Translation Project is also available for packages which are not
|
||||
developed inside the GNU project. Therefore the information given above
|
||||
applies also for every other Free Software Project. Contact
|
||||
`translation@iro.umontreal.ca' to make the `.pot' files available to
|
||||
the translation teams.
|
||||
|
112
contrib/diff/AUTHORS
Normal file
112
contrib/diff/AUTHORS
Normal file
@ -0,0 +1,112 @@
|
||||
Authors of GNU diffutils.
|
||||
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU diffutils.
|
||||
|
||||
GNU diffutils 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.
|
||||
|
||||
GNU diffutils 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 GNU diffutils; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
The following contributions warranted legal paper exchanges with the
|
||||
Free Software Foundation. Also see files ChangeLog and THANKS.
|
||||
|
||||
DIFFUTILS Leonard H. Tower Jr. US 1949 1987-03-09
|
||||
Assigns diff (diff.c, initial version).
|
||||
|
||||
DIFFUTILS Torbjorn Granlund Sweden 1961 1988-01-11
|
||||
Assigns cmp.
|
||||
tege@matematik.su.se
|
||||
|
||||
DIFFUTILS Mike Haertel US 1967 1988-09-16
|
||||
Assigns changes to diff.
|
||||
|
||||
DIFFUTILS David S. Hayes US ? 1988-01-12
|
||||
Assigns changes to diff.
|
||||
|
||||
DIFFUTILS Randall Smith US 1964 1988-09-21
|
||||
Assigns diff3.
|
||||
|
||||
DIFFUTILS Richard Stallman US 1953 1988-01-15
|
||||
Assigns changes to GNU Diff.
|
||||
|
||||
DIFFUTILS F. Thomas May US 1965 1989-08-22
|
||||
Assigns changes to diff (for -D).
|
||||
|
||||
DIFFUTILS Optimal Solutions, Inc. 1989-08-14
|
||||
Disclaims changes by Thomas May to diff.
|
||||
|
||||
DIFFUTILS Wayne Davison 1990-09-10
|
||||
Disclaims changes to diff.
|
||||
|
||||
DIFFUTILS Digital Research Inc. 1990-09-13
|
||||
Disclaims changes by Wayne Davison to diff.
|
||||
|
||||
DIFFUTILS Paul Eggert 1990-03-16
|
||||
Disclaims changes to diff.
|
||||
eggert@twinsun.com
|
||||
|
||||
DIFFUTILS Paul Eggert 1990-08-14
|
||||
Disclaims changes to GNU Diff.
|
||||
eggert@twinsun.com
|
||||
|
||||
DIFFUTILS Twin Sun Inc. 1990-03-16
|
||||
Disclaims changes to GNU Diff by Paul Eggert.
|
||||
|
||||
DIFFUTILS Twin Sun Inc. 1990-08-14
|
||||
Disclaims changes to GNU Diff by Paul Eggert.
|
||||
|
||||
DIFFUTILS Chip Rosenthal US 1959 1990-03-06
|
||||
Assigns changes to diff.
|
||||
chip@chinacat.Unicom.COM
|
||||
|
||||
DIFFUTILS Unicom Systems Development 1990-03-06
|
||||
Disclaims changes by Chip Rosenthal to diff.
|
||||
|
||||
GCC DIFFUTILS Paul Eggert and Twin Sun Inc. 1992-03-11
|
||||
Disclaims changes by Paul Eggert to gcc and diff.
|
||||
eggert@twinsun.com
|
||||
|
||||
DIFF Wayne Davison 1993-06-20
|
||||
Disclaims diffcvt.c.
|
||||
|
||||
DIFFUTILS Francois Pinard Canada 1949 1993-01-15
|
||||
Assigns wdiff and future changes submitted to the FSF.
|
||||
pinard@iro.umontreal.ca
|
||||
|
||||
DIFFUTILS Patrick D'Cruze Australia 1971 1994-11-10
|
||||
Assigns changes (makefile.in, analyze.c, cmp.c, error.c, diff.c,
|
||||
diff3.c, getopt.c, getopt1.c, regex.c, sdiff.c, util.c, xmalloc.c;
|
||||
new file: language.++)
|
||||
|
||||
DIFFUTILS Paul R. Eggert US 1954 1997-04-07
|
||||
Assigns past and future changes.
|
||||
eggert@twinsun.com
|
||||
|
||||
DIFFUTILS Paul R. Eggert US 1954 1997-04-07
|
||||
Assigns past and future changes to manual.
|
||||
eggert@twinsun.com
|
||||
|
||||
ANY DIFFUTILS GNATS Cyclic Software 1997-11-11
|
||||
Assigns past and future works (work for hire by Tim Pierce (diffutils) and
|
||||
Abe Feldman (GNATS)).
|
||||
kingdon@cyclic.com
|
||||
|
||||
WEBPAGES Gregory B. Harvey Canada 1976 1998-02-14
|
||||
Assigns web pages describing GNU Diffutils and future changes.
|
||||
|
||||
DIFFUTILS Olga Nikulin Russia 1965 2001-01-11
|
||||
Assigns changes to diff. (diffutils-2.7.2/analyze.c, context.c, diff.[ch],
|
||||
ed.c, ifdef.c, io.c, normal.c, side.c, util.c)
|
||||
onikulin@yahoo.com
|
@ -2,7 +2,7 @@
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
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.
|
||||
|
||||
@ -279,7 +279,7 @@ POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
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
|
||||
@ -291,7 +291,7 @@ 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) 19yy <name of author>
|
||||
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
|
||||
@ -305,14 +305,15 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
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) 19yy name of author
|
||||
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.
|
||||
|
File diff suppressed because it is too large
Load Diff
23
contrib/diff/Makefile.am
Normal file
23
contrib/diff/Makefile.am
Normal file
@ -0,0 +1,23 @@
|
||||
# Main Automakefile for GNU diffutils.
|
||||
|
||||
# Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2, or (at your option)
|
||||
## any later version.
|
||||
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
## 02111-1307, USA.
|
||||
|
||||
EXTRA_DIST = bootstrap exgettext
|
||||
SUBDIRS = doc lib m4 ms src man po
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
@ -1,6 +1,102 @@
|
||||
Version 2.8.7 contains no user-visible changes.
|
||||
|
||||
User-visible changes in version 2.8.6:
|
||||
|
||||
* New diff3 option --strip-trailing-cr.
|
||||
|
||||
* With -N and -P, inaccessible empty regular files (the kind of files
|
||||
that 'patch' creates to indicate nonexistent backups) are now
|
||||
treated as nonexistent when they are in the 'backup' file position.
|
||||
|
||||
* If multiple SKIP values are given to cmp, e.g., `cmp -i 10 -i 20',
|
||||
cmp now uses the maximal value instead of the last one.
|
||||
|
||||
* diff now omits the ".000000000" on hosts that do not support
|
||||
fractional time stamps.
|
||||
|
||||
Version 2.8.5 was not publicly released.
|
||||
|
||||
User-visible changes in version 2.8.4:
|
||||
|
||||
* Diff now simply prints "Files A and B differ" instead of "Binary
|
||||
files A and B differ". The message is output if either A or B
|
||||
appears to be a binary file, and the old wording was misleading
|
||||
because it implied that both files are binary, which is not
|
||||
necessarily the case.
|
||||
|
||||
User-visible changes in version 2.8.3:
|
||||
|
||||
* New locale: en_US.
|
||||
|
||||
User-visible changes in version 2.8.2:
|
||||
|
||||
* New diff and sdiff option:
|
||||
--tabsize=COLUMNS
|
||||
* If --ignore-space-change or --ignore-all-space is also specified,
|
||||
--ignore-blank-lines now considers lines to be empty if they contain
|
||||
only white space.
|
||||
* More platforms now handle multibyte characters correctly when
|
||||
excluding files by name (diff -x and -X).
|
||||
* New locales: hu, pt_BR.
|
||||
|
||||
User-visible changes in version 2.8.1:
|
||||
|
||||
* Documentation fixes.
|
||||
|
||||
User-visible changes in version 2.8:
|
||||
|
||||
* cmp and diff now conform to POSIX 1003.1-2001 (IEEE Std 1003.1-2001)
|
||||
if the underlying system conforms to POSIX and if the _POSIX2_VERSION
|
||||
environment variable is set to 200112. Conformance removes support
|
||||
for `diff -NUM', where NUM is a number. Use -C NUM or -U NUM instead.
|
||||
* cmp now supports trailing operands SKIP1 and SKIP2, like BSD cmp.
|
||||
* cmp -i or --ignore-initial now accepts SKIP1:SKIP2 option value.
|
||||
* New cmp option: -n or --bytes.
|
||||
* cmp's old -c or --print-chars option has been renamed;
|
||||
use -b or --print-bytes instead.
|
||||
* cmp now outputs "byte" rather than "char" outside the POSIX locale.
|
||||
* cmp -l's index column width now adjusts to fit larger (or smaller) files.
|
||||
* cmp -l -s and cmp -s -l are not allowed. Use cmp -s or cmp -l instead.
|
||||
* diff uses ISO 8601 style time stamps for output times (e.g. "2001-11-23
|
||||
16:44:36.875702460 -0800") unless in the C or POSIX locale and the
|
||||
-c style is specified.
|
||||
* diff's -I and -F options use the regexp syntax of grep, not of Emacs.
|
||||
* diff now accepts multiple context arguments, and uses their maximum value.
|
||||
* New diff and sdiff options:
|
||||
-E --ignore-tab-expansion
|
||||
--strip-trailing-cr
|
||||
* New diff options:
|
||||
--from-file=FILE, --to-file=FILE
|
||||
--ignore-file-name-case
|
||||
--no-ignore-file-name-case
|
||||
* New diff3 and sdiff option:
|
||||
--diff-program=PROGRAM
|
||||
* The following diff options are still accepted, but are no longer documented.
|
||||
They may be withdrawn in future releases.
|
||||
-h (omit; it has no effect)
|
||||
-H (use --speed-large-files instead)
|
||||
-L (use --label instead)
|
||||
-P (use --unidirectional-new-file instead)
|
||||
--inhibit-hunk-merge (omit; it has no effect)
|
||||
* Recursive diffs now sort file names according to the LC_COLLATE locale
|
||||
category if possible, instead of using native byte comparison.
|
||||
* Recursive diffs now detect and report directory loops.
|
||||
* Diff printf specs can now use the "0" and "'" flags.
|
||||
* The new sdiff interactive command `ed' precedes each version with a header.
|
||||
* On 64-bit hosts, files larger than 2 GB can be compared.
|
||||
* Some internationalization support has been added, but multibyte locales
|
||||
are still not completely supported yet.
|
||||
* Some diagnostics have been reworded slightly for consistency.
|
||||
Also, `diff -D FOO' now outputs `/* ! FOO */' instead of `/* not FOO */'.
|
||||
* The `patch' part of the manual now describes `patch' version 2.5.4.
|
||||
* Man pages are now distributed and installed.
|
||||
* There is support for DJGPP; see the 'ms' subdirectory and the files
|
||||
m4/dos.m4 and */setmode.*.
|
||||
|
||||
|
||||
User-visible changes in version 2.7:
|
||||
|
||||
* New diff option: --binary (useful only on non-Posix hosts)
|
||||
* New diff option: --binary (useful only on non-POSIX hosts)
|
||||
* diff -b and -w now ignore line incompleteness; -B no longer does this.
|
||||
* cmp -c now uses locale to decide which output characters to quote.
|
||||
* Help and version messages are reorganized.
|
||||
@ -64,8 +160,8 @@ User-visible changes in version 2.4:
|
||||
* The format spec %0 introduced in version 2.1 has been removed, since it
|
||||
is incompatible with printf specs like %02d. To represent a null char,
|
||||
use %c'\0' instead.
|
||||
* cmp and diff now conform to Posix.2 (ISO/IEC 9945-2:1993)
|
||||
if the underlying system conforms to Posix:
|
||||
* cmp and diff now conform to POSIX 1003.2-1992 (ISO/IEC 9945-2:1993)
|
||||
if the underlying system conforms to POSIX:
|
||||
- Some messages' wordings are changed in minor ways.
|
||||
- ``White space'' is now whatever C's `isspace' says it is.
|
||||
- When comparing directories, if `diff' finds a file that is not a regular
|
||||
@ -124,3 +220,25 @@ User-visible changes in version 2.0:
|
||||
* Add long-named equivalents for other diff3 options.
|
||||
* diff options -F (--show-function-line) and -I (--ignore-matching-lines)
|
||||
can now be given more than once.
|
||||
|
||||
|
||||
|
||||
Copyright (C) 1993, 1994, 1998, 2001, 2002, 2004 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is part of GNU Diffutils.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that they will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
@ -1,9 +1,69 @@
|
||||
README for GNU DIFF
|
||||
|
||||
This directory contains the GNU diff, diff3, sdiff, and cmp utilities.
|
||||
Their features are a superset of the Unix features and they are
|
||||
significantly faster. cmp has been moved here from the GNU textutils.
|
||||
significantly faster.
|
||||
|
||||
See the file COPYING for copying conditions.
|
||||
See the file diff.texi (or diff.info*) for documentation.
|
||||
See the file INSTALL for compilation and installation instructions.
|
||||
Please see the file COPYING for copying conditions.
|
||||
|
||||
Report bugs to bug-gnu-utils@prep.ai.mit.edu
|
||||
Please see the file doc/version.texi for version information.
|
||||
|
||||
Please see the file doc/diff.texi (or doc/diff.info) for documentation
|
||||
that can be printed with TeX, or read with the `info' program or with
|
||||
Emacs's `M-x info'. Brief man pages are in man/*, but they are no
|
||||
substitute for the documentation.
|
||||
|
||||
Please see the file ABOUT-NLS for notes about translations.
|
||||
|
||||
Please see the file INSTALL for generic compilation and installation
|
||||
instructions. Briefly, you can run "./configure; make install". The
|
||||
command "./configure --help" lists the supported --enable and --with
|
||||
options.
|
||||
|
||||
If you have a problem with internationalization, you might be able to
|
||||
work around it as described in ABOUT-NLS by invoking `./configure
|
||||
--disable-nls'. Many of the problems arise from dynamic linking
|
||||
issues on non-GNU platforms (e.g. with the iconv library). Such
|
||||
problems tend to be shared by other GNU applications on these
|
||||
platforms, and can usually be fixed by carefully tweaking your non-GNU
|
||||
installation. If you have an older version of libiconv, please
|
||||
upgrade to the latest one; see <ftp://ftp.gnu.org/gnu/libiconv/>. If
|
||||
the problem seems isolated to diffutils, though, please report a bug.
|
||||
|
||||
This program requires a Standard C compiler (C89 or later). If you
|
||||
have a nonstandard compiler, please install GCC first.
|
||||
|
||||
If you make changes to the source code, you may need appropriate
|
||||
versions of GNU build tools to regenerate the intermediate files. The
|
||||
following versions were used to generate the intermediate files in
|
||||
this distribution:
|
||||
|
||||
* Autoconf 2.59 <ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.59.tar.gz>
|
||||
* Automake 1.8.3 <ftp://ftp.gnu.org/gnu/automake/automake-1.8.3.tar.gz>
|
||||
* gettext 0.14.1 <ftp://ftp.gnu.org/gnu/gettext/gettext-0.14.1.tar.gz>
|
||||
* help2man 1.33 <ftp://ftp.gnu.org/gnu/help2man/help2man-1.33.1.tar.gz>
|
||||
* Texinfo 4.7 <ftp://ftp.gnu.org/gnu/texinfo/texinfo-4.7.tar.gz>
|
||||
|
||||
Please report bugs to <bug-gnu-utils@gnu.org>.
|
||||
|
||||
-----
|
||||
|
||||
Copyright (C) 1992, 1998, 2001, 2002, 2004 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is part of GNU Diffutils.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
22
contrib/diff/THANKS
Normal file
22
contrib/diff/THANKS
Normal file
@ -0,0 +1,22 @@
|
||||
Thanks to all the following for their contributions to GNU diffutils:
|
||||
|
||||
Thomas Bushnell <tb@becket.net>
|
||||
Wayne Davison <wayned@users.sourceforge.net>
|
||||
Ulrich Drepper <drepper@redhat.com>
|
||||
Paul Eggert <eggert@twinsun.com>
|
||||
Jay Fenlason <hack@gnu.org>
|
||||
John Gilmore <gnu@cygnus.com>
|
||||
Torbjorn Granlund <tege@swox.com>
|
||||
Mike Haertel <mike@ichips.intel.com>
|
||||
Bruno Haible <haible@ilog.fr>
|
||||
Chris Hanson <cph@gnu.org>
|
||||
Jim Kingdon <kingdon@panix.com>
|
||||
Tom Lord <lord@gnu.org>
|
||||
David J. MacKenzie <djm@gnu.org>
|
||||
Roland McGrath <roland@gnu.org>
|
||||
Jim Meyering <meyering@lucent.com>
|
||||
Eugene W. Myers <gene@cs.arizona.edu>
|
||||
Randy Smith <randy@gnu.org>
|
||||
Richard Stallman <rms@gnu.org>
|
||||
Leonard H. Tower Jr. <tower@ai.mit.edu>
|
||||
Eli Zaretskii <eliz@is.elta.co.il>
|
1
contrib/diff/TODO
Normal file
1
contrib/diff/TODO
Normal file
@ -0,0 +1 @@
|
||||
Add --include option (opposite of --exclude).
|
180
contrib/diff/bootstrap
Executable file
180
contrib/diff/bootstrap
Executable file
@ -0,0 +1,180 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Bootstrap this package from CVS.
|
||||
|
||||
# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
# Written by Paul Eggert.
|
||||
|
||||
package=diffutils
|
||||
|
||||
# Parse options.
|
||||
|
||||
for option
|
||||
do
|
||||
case $option in
|
||||
--help)
|
||||
echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-auth=AUTH-METHOD] [--cvs-user=USERNAME] [--skip-po]"
|
||||
exit;;
|
||||
--gnulib-srcdir=*)
|
||||
GNULIB_SRCDIR=`expr "$1" : '--gnulib-srcdir=\(.*\)'`;;
|
||||
--cvs-auth=*)
|
||||
CVS_AUTH=`expr "$1" : '--cvs-auth=\(.*\)'`;;
|
||||
--cvs-user=*)
|
||||
CVS_USER=`expr "$1" : '--cvs-user=\(.*\)'`;;
|
||||
--skip-po)
|
||||
SKIP_PO=t;;
|
||||
*)
|
||||
echo >&2 "$0: $option: unknown option"
|
||||
exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "$0: Bootstrapping CVS $package..."
|
||||
|
||||
build_cvs_prefix() {
|
||||
CVS_PREFIX=:${1}:
|
||||
if [ "${2}" != - ]; then
|
||||
CVS_PREFIX=${CVS_PREFIX}${2}@
|
||||
fi
|
||||
}
|
||||
|
||||
# Get gnulib files.
|
||||
|
||||
case ${GNULIB_SRCDIR--} in
|
||||
-)
|
||||
if [ ! -d gnulib ]; then
|
||||
echo "$0: getting gnulib files..."
|
||||
|
||||
trap exit 1 2 13 15
|
||||
trap 'rm -fr gnulib; exit 1' 0
|
||||
|
||||
case "${CVS_AUTH--}" in
|
||||
-) : ${CVS_RSH:?}
|
||||
CVS_PREFIX="";;
|
||||
pserver) build_cvs_prefix $CVS_AUTH ${CVS_USER:-anoncvs};;
|
||||
gserver|server)
|
||||
build_cvs_prefix $CVS_AUTH ${CVS_USER--};;
|
||||
ext) : ${CVS_RSH:?}
|
||||
build_cvs_prefix $CVS_AUTH ${CVS_USER--};;
|
||||
*) echo "$0: Unknown CVS access method" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
if [ "${CVS_AUTH--}" = "pserver" ]; then
|
||||
cvs -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/gnulib login || exit
|
||||
fi
|
||||
cvs -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/gnulib co gnulib || exit
|
||||
|
||||
trap 0
|
||||
fi
|
||||
GNULIB_SRCDIR=gnulib
|
||||
esac
|
||||
|
||||
<$GNULIB_SRCDIR/gnulib-tool || exit
|
||||
|
||||
gnulib_modules='
|
||||
c-stack
|
||||
dirname
|
||||
error
|
||||
exclude
|
||||
exit
|
||||
exitfail
|
||||
file-type
|
||||
fnmatch-gnu
|
||||
getopt
|
||||
hard-locale
|
||||
inttostr
|
||||
mkstemp
|
||||
posixver
|
||||
regex
|
||||
strcase
|
||||
strftime
|
||||
strtoumax
|
||||
unlocked-io
|
||||
version-etc
|
||||
xalloc
|
||||
xstrtoumax
|
||||
'
|
||||
|
||||
previous_gnulib_modules=
|
||||
while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
|
||||
previous_gnulib_modules=$gnulib_modules
|
||||
gnulib_modules=`
|
||||
(echo "$gnulib_modules"
|
||||
for gnulib_module in $gnulib_modules; do
|
||||
$GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
|
||||
done) | sort -u
|
||||
`
|
||||
done
|
||||
|
||||
gnulib_files=`
|
||||
(for gnulib_module in $gnulib_modules; do
|
||||
$GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
|
||||
done) | sort -u
|
||||
`
|
||||
|
||||
gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
|
||||
mkdir -p $gnulib_dirs || exit
|
||||
|
||||
for gnulib_file in $gnulib_files; do
|
||||
dest=$gnulib_file
|
||||
|
||||
case $gnulib_file in
|
||||
m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
|
||||
esac
|
||||
|
||||
rm -f $dest &&
|
||||
echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
|
||||
cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
|
||||
done
|
||||
|
||||
|
||||
# Get translations.
|
||||
|
||||
case $SKIP_PO in
|
||||
'')
|
||||
echo "$0: getting translations into po..."
|
||||
(cd po &&
|
||||
rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
|
||||
wget -nv -nd -r -l 1 -A .po -C off \
|
||||
http://www2.iro.umontreal.ca/~gnutra/po/maint/$package/ &&
|
||||
ls *.po | sed 's/\.po$//' >LINGUAS
|
||||
) || exit;;
|
||||
esac
|
||||
|
||||
|
||||
# Reconfigure, getting other files.
|
||||
|
||||
echo "$0: autoreconf --verbose --install --force ..."
|
||||
autoreconf --verbose --install --force || exit
|
||||
|
||||
|
||||
# Generate autoconf and automake snippets.
|
||||
|
||||
(echo '# This file is generated automatically by "bootstrap".' &&
|
||||
echo 'AC_DEFUN([GNULIB_AUTOCONF_SNIPPET],[' &&
|
||||
$GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_modules &&
|
||||
echo '])'
|
||||
) >m4/gnulib.m4 || exit
|
||||
|
||||
(echo '# This file is generated automatically by "bootstrap".' &&
|
||||
$GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_modules
|
||||
) >lib/gnulib.mk || exit
|
||||
|
||||
|
||||
echo "$0: done. Now you can run './configure'."
|
24
contrib/diff/doc/Makefile.am
Normal file
24
contrib/diff/doc/Makefile.am
Normal file
@ -0,0 +1,24 @@
|
||||
# Makefile for GNU diffutils documentation.
|
||||
|
||||
# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2, or (at your option)
|
||||
## any later version.
|
||||
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program; if not, write to the Free Software Foundation,
|
||||
## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
AM_MAKEINFOFLAGS = --no-split
|
||||
|
||||
info_TEXINFOS = diff.texi
|
||||
diff_TEXINFOS = fdl.texi
|
||||
|
||||
EXTRA_DIST = diagmeet.note
|
71
contrib/diff/doc/diagmeet.note
Normal file
71
contrib/diff/doc/diagmeet.note
Normal file
@ -0,0 +1,71 @@
|
||||
Here is a comparison matrix which shows a case in which
|
||||
it is possible for the forward and backward scan in `diag'
|
||||
to meet along a nonzero length of diagonal simultaneous
|
||||
(so that bdiag[d] and fdiag[d] are not equal)
|
||||
even though there is no snake on that diagonal at the meeting point.
|
||||
|
||||
|
||||
85 1 1 1 159 1 1 17
|
||||
1 2 3 4
|
||||
60
|
||||
1 2
|
||||
1
|
||||
2 2 3 4
|
||||
71
|
||||
3 3 4 5
|
||||
85
|
||||
4 3 4 5
|
||||
17
|
||||
5 4 5
|
||||
1
|
||||
6 4 5 6
|
||||
183
|
||||
7 5 6 7
|
||||
10
|
||||
8 6 7
|
||||
1
|
||||
9 6 7 8
|
||||
12
|
||||
7 8 9 10
|
||||
13
|
||||
10 8 9 10
|
||||
14
|
||||
10 9 10
|
||||
17
|
||||
10 10
|
||||
1
|
||||
10 9 10
|
||||
1
|
||||
8 10 10 10
|
||||
183
|
||||
8 7 9 9 9
|
||||
10
|
||||
7 6 8 9 8 8
|
||||
1
|
||||
6 5 7 7
|
||||
1
|
||||
5 6 6
|
||||
1
|
||||
5 5 5
|
||||
50
|
||||
5 4 4 4
|
||||
1
|
||||
4 3 3
|
||||
85
|
||||
5 4 3 2 2
|
||||
1
|
||||
2 1
|
||||
17
|
||||
5 4 3 2 1 1
|
||||
1
|
||||
1 0
|
||||
85 1 1 1 159 1 1 17
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
4649
contrib/diff/doc/diff.texi
Normal file
4649
contrib/diff/doc/diff.texi
Normal file
File diff suppressed because it is too large
Load Diff
452
contrib/diff/doc/fdl.texi
Normal file
452
contrib/diff/doc/fdl.texi
Normal file
@ -0,0 +1,452 @@
|
||||
|
||||
@node GNU Free Documentation License
|
||||
@appendixsec GNU Free Documentation License
|
||||
|
||||
@cindex FDL, GNU Free Documentation License
|
||||
@center Version 1.2, November 2002
|
||||
|
||||
@display
|
||||
Copyright @copyright{} 2000,2001,2002 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.
|
||||
@end display
|
||||
|
||||
@enumerate 0
|
||||
@item
|
||||
PREAMBLE
|
||||
|
||||
The purpose of this License is to make a manual, textbook, or other
|
||||
functional and useful document @dfn{free} in the sense of freedom: to
|
||||
assure everyone the effective freedom to copy and redistribute it,
|
||||
with or without modifying it, either commercially or noncommercially.
|
||||
Secondarily, this License preserves for the author and publisher a way
|
||||
to get credit for their work, while not being considered responsible
|
||||
for modifications made by others.
|
||||
|
||||
This License is a kind of ``copyleft'', which means that derivative
|
||||
works of the document must themselves be free in the same sense. It
|
||||
complements the GNU General Public License, which is a copyleft
|
||||
license designed for free software.
|
||||
|
||||
We have designed this License in order to use it for manuals for free
|
||||
software, because free software needs free documentation: a free
|
||||
program should come with manuals providing the same freedoms that the
|
||||
software does. But this License is not limited to software manuals;
|
||||
it can be used for any textual work, regardless of subject matter or
|
||||
whether it is published as a printed book. We recommend this License
|
||||
principally for works whose purpose is instruction or reference.
|
||||
|
||||
@item
|
||||
APPLICABILITY AND DEFINITIONS
|
||||
|
||||
This License applies to any manual or other work, in any medium, that
|
||||
contains a notice placed by the copyright holder saying it can be
|
||||
distributed under the terms of this License. Such a notice grants a
|
||||
world-wide, royalty-free license, unlimited in duration, to use that
|
||||
work under the conditions stated herein. The ``Document'', below,
|
||||
refers to any such manual or work. Any member of the public is a
|
||||
licensee, and is addressed as ``you''. You accept the license if you
|
||||
copy, modify or distribute the work in a way requiring permission
|
||||
under copyright law.
|
||||
|
||||
A ``Modified Version'' of the Document means any work containing the
|
||||
Document or a portion of it, either copied verbatim, or with
|
||||
modifications and/or translated into another language.
|
||||
|
||||
A ``Secondary Section'' is a named appendix or a front-matter section
|
||||
of the Document that deals exclusively with the relationship of the
|
||||
publishers or authors of the Document to the Document's overall
|
||||
subject (or to related matters) and contains nothing that could fall
|
||||
directly within that overall subject. (Thus, if the Document is in
|
||||
part a textbook of mathematics, a Secondary Section may not explain
|
||||
any mathematics.) The relationship could be a matter of historical
|
||||
connection with the subject or with related matters, or of legal,
|
||||
commercial, philosophical, ethical or political position regarding
|
||||
them.
|
||||
|
||||
The ``Invariant Sections'' are certain Secondary Sections whose titles
|
||||
are designated, as being those of Invariant Sections, in the notice
|
||||
that says that the Document is released under this License. If a
|
||||
section does not fit the above definition of Secondary then it is not
|
||||
allowed to be designated as Invariant. The Document may contain zero
|
||||
Invariant Sections. If the Document does not identify any Invariant
|
||||
Sections then there are none.
|
||||
|
||||
The ``Cover Texts'' are certain short passages of text that are listed,
|
||||
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
||||
the Document is released under this License. A Front-Cover Text may
|
||||
be at most 5 words, and a Back-Cover Text may be at most 25 words.
|
||||
|
||||
A ``Transparent'' copy of the Document means a machine-readable copy,
|
||||
represented in a format whose specification is available to the
|
||||
general public, that is suitable for revising the document
|
||||
straightforwardly with generic text editors or (for images composed of
|
||||
pixels) generic paint programs or (for drawings) some widely available
|
||||
drawing editor, and that is suitable for input to text formatters or
|
||||
for automatic translation to a variety of formats suitable for input
|
||||
to text formatters. A copy made in an otherwise Transparent file
|
||||
format whose markup, or absence of markup, has been arranged to thwart
|
||||
or discourage subsequent modification by readers is not Transparent.
|
||||
An image format is not Transparent if used for any substantial amount
|
||||
of text. A copy that is not ``Transparent'' is called ``Opaque''.
|
||||
|
||||
Examples of suitable formats for Transparent copies include plain
|
||||
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
|
||||
format, @acronym{SGML} or @acronym{XML} using a publicly available
|
||||
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
|
||||
PostScript or @acronym{PDF} designed for human modification. Examples
|
||||
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
|
||||
@acronym{JPG}. Opaque formats include proprietary formats that can be
|
||||
read and edited only by proprietary word processors, @acronym{SGML} or
|
||||
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
|
||||
not generally available, and the machine-generated @acronym{HTML},
|
||||
PostScript or @acronym{PDF} produced by some word processors for
|
||||
output purposes only.
|
||||
|
||||
The ``Title Page'' means, for a printed book, the title page itself,
|
||||
plus such following pages as are needed to hold, legibly, the material
|
||||
this License requires to appear in the title page. For works in
|
||||
formats which do not have any title page as such, ``Title Page'' means
|
||||
the text near the most prominent appearance of the work's title,
|
||||
preceding the beginning of the body of the text.
|
||||
|
||||
A section ``Entitled XYZ'' means a named subunit of the Document whose
|
||||
title either is precisely XYZ or contains XYZ in parentheses following
|
||||
text that translates XYZ in another language. (Here XYZ stands for a
|
||||
specific section name mentioned below, such as ``Acknowledgements'',
|
||||
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
|
||||
of such a section when you modify the Document means that it remains a
|
||||
section ``Entitled XYZ'' according to this definition.
|
||||
|
||||
The Document may include Warranty Disclaimers next to the notice which
|
||||
states that this License applies to the Document. These Warranty
|
||||
Disclaimers are considered to be included by reference in this
|
||||
License, but only as regards disclaiming warranties: any other
|
||||
implication that these Warranty Disclaimers may have is void and has
|
||||
no effect on the meaning of this License.
|
||||
|
||||
@item
|
||||
VERBATIM COPYING
|
||||
|
||||
You may copy and distribute the Document in any medium, either
|
||||
commercially or noncommercially, provided that this License, the
|
||||
copyright notices, and the license notice saying this License applies
|
||||
to the Document are reproduced in all copies, and that you add no other
|
||||
conditions whatsoever to those of this License. You may not use
|
||||
technical measures to obstruct or control the reading or further
|
||||
copying of the copies you make or distribute. However, you may accept
|
||||
compensation in exchange for copies. If you distribute a large enough
|
||||
number of copies you must also follow the conditions in section 3.
|
||||
|
||||
You may also lend copies, under the same conditions stated above, and
|
||||
you may publicly display copies.
|
||||
|
||||
@item
|
||||
COPYING IN QUANTITY
|
||||
|
||||
If you publish printed copies (or copies in media that commonly have
|
||||
printed covers) of the Document, numbering more than 100, and the
|
||||
Document's license notice requires Cover Texts, you must enclose the
|
||||
copies in covers that carry, clearly and legibly, all these Cover
|
||||
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
||||
the back cover. Both covers must also clearly and legibly identify
|
||||
you as the publisher of these copies. The front cover must present
|
||||
the full title with all words of the title equally prominent and
|
||||
visible. You may add other material on the covers in addition.
|
||||
Copying with changes limited to the covers, as long as they preserve
|
||||
the title of the Document and satisfy these conditions, can be treated
|
||||
as verbatim copying in other respects.
|
||||
|
||||
If the required texts for either cover are too voluminous to fit
|
||||
legibly, you should put the first ones listed (as many as fit
|
||||
reasonably) on the actual cover, and continue the rest onto adjacent
|
||||
pages.
|
||||
|
||||
If you publish or distribute Opaque copies of the Document numbering
|
||||
more than 100, you must either include a machine-readable Transparent
|
||||
copy along with each Opaque copy, or state in or with each Opaque copy
|
||||
a computer-network location from which the general network-using
|
||||
public has access to download using public-standard network protocols
|
||||
a complete Transparent copy of the Document, free of added material.
|
||||
If you use the latter option, you must take reasonably prudent steps,
|
||||
when you begin distribution of Opaque copies in quantity, to ensure
|
||||
that this Transparent copy will remain thus accessible at the stated
|
||||
location until at least one year after the last time you distribute an
|
||||
Opaque copy (directly or through your agents or retailers) of that
|
||||
edition to the public.
|
||||
|
||||
It is requested, but not required, that you contact the authors of the
|
||||
Document well before redistributing any large number of copies, to give
|
||||
them a chance to provide you with an updated version of the Document.
|
||||
|
||||
@item
|
||||
MODIFICATIONS
|
||||
|
||||
You may copy and distribute a Modified Version of the Document under
|
||||
the conditions of sections 2 and 3 above, provided that you release
|
||||
the Modified Version under precisely this License, with the Modified
|
||||
Version filling the role of the Document, thus licensing distribution
|
||||
and modification of the Modified Version to whoever possesses a copy
|
||||
of it. In addition, you must do these things in the Modified Version:
|
||||
|
||||
@enumerate A
|
||||
@item
|
||||
Use in the Title Page (and on the covers, if any) a title distinct
|
||||
from that of the Document, and from those of previous versions
|
||||
(which should, if there were any, be listed in the History section
|
||||
of the Document). You may use the same title as a previous version
|
||||
if the original publisher of that version gives permission.
|
||||
|
||||
@item
|
||||
List on the Title Page, as authors, one or more persons or entities
|
||||
responsible for authorship of the modifications in the Modified
|
||||
Version, together with at least five of the principal authors of the
|
||||
Document (all of its principal authors, if it has fewer than five),
|
||||
unless they release you from this requirement.
|
||||
|
||||
@item
|
||||
State on the Title page the name of the publisher of the
|
||||
Modified Version, as the publisher.
|
||||
|
||||
@item
|
||||
Preserve all the copyright notices of the Document.
|
||||
|
||||
@item
|
||||
Add an appropriate copyright notice for your modifications
|
||||
adjacent to the other copyright notices.
|
||||
|
||||
@item
|
||||
Include, immediately after the copyright notices, a license notice
|
||||
giving the public permission to use the Modified Version under the
|
||||
terms of this License, in the form shown in the Addendum below.
|
||||
|
||||
@item
|
||||
Preserve in that license notice the full lists of Invariant Sections
|
||||
and required Cover Texts given in the Document's license notice.
|
||||
|
||||
@item
|
||||
Include an unaltered copy of this License.
|
||||
|
||||
@item
|
||||
Preserve the section Entitled ``History'', Preserve its Title, and add
|
||||
to it an item stating at least the title, year, new authors, and
|
||||
publisher of the Modified Version as given on the Title Page. If
|
||||
there is no section Entitled ``History'' in the Document, create one
|
||||
stating the title, year, authors, and publisher of the Document as
|
||||
given on its Title Page, then add an item describing the Modified
|
||||
Version as stated in the previous sentence.
|
||||
|
||||
@item
|
||||
Preserve the network location, if any, given in the Document for
|
||||
public access to a Transparent copy of the Document, and likewise
|
||||
the network locations given in the Document for previous versions
|
||||
it was based on. These may be placed in the ``History'' section.
|
||||
You may omit a network location for a work that was published at
|
||||
least four years before the Document itself, or if the original
|
||||
publisher of the version it refers to gives permission.
|
||||
|
||||
@item
|
||||
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
|
||||
the Title of the section, and preserve in the section all the
|
||||
substance and tone of each of the contributor acknowledgements and/or
|
||||
dedications given therein.
|
||||
|
||||
@item
|
||||
Preserve all the Invariant Sections of the Document,
|
||||
unaltered in their text and in their titles. Section numbers
|
||||
or the equivalent are not considered part of the section titles.
|
||||
|
||||
@item
|
||||
Delete any section Entitled ``Endorsements''. Such a section
|
||||
may not be included in the Modified Version.
|
||||
|
||||
@item
|
||||
Do not retitle any existing section to be Entitled ``Endorsements'' or
|
||||
to conflict in title with any Invariant Section.
|
||||
|
||||
@item
|
||||
Preserve any Warranty Disclaimers.
|
||||
@end enumerate
|
||||
|
||||
If the Modified Version includes new front-matter sections or
|
||||
appendices that qualify as Secondary Sections and contain no material
|
||||
copied from the Document, you may at your option designate some or all
|
||||
of these sections as invariant. To do this, add their titles to the
|
||||
list of Invariant Sections in the Modified Version's license notice.
|
||||
These titles must be distinct from any other section titles.
|
||||
|
||||
You may add a section Entitled ``Endorsements'', provided it contains
|
||||
nothing but endorsements of your Modified Version by various
|
||||
parties---for example, statements of peer review or that the text has
|
||||
been approved by an organization as the authoritative definition of a
|
||||
standard.
|
||||
|
||||
You may add a passage of up to five words as a Front-Cover Text, and a
|
||||
passage of up to 25 words as a Back-Cover Text, to the end of the list
|
||||
of Cover Texts in the Modified Version. Only one passage of
|
||||
Front-Cover Text and one of Back-Cover Text may be added by (or
|
||||
through arrangements made by) any one entity. If the Document already
|
||||
includes a cover text for the same cover, previously added by you or
|
||||
by arrangement made by the same entity you are acting on behalf of,
|
||||
you may not add another; but you may replace the old one, on explicit
|
||||
permission from the previous publisher that added the old one.
|
||||
|
||||
The author(s) and publisher(s) of the Document do not by this License
|
||||
give permission to use their names for publicity for or to assert or
|
||||
imply endorsement of any Modified Version.
|
||||
|
||||
@item
|
||||
COMBINING DOCUMENTS
|
||||
|
||||
You may combine the Document with other documents released under this
|
||||
License, under the terms defined in section 4 above for modified
|
||||
versions, provided that you include in the combination all of the
|
||||
Invariant Sections of all of the original documents, unmodified, and
|
||||
list them all as Invariant Sections of your combined work in its
|
||||
license notice, and that you preserve all their Warranty Disclaimers.
|
||||
|
||||
The combined work need only contain one copy of this License, and
|
||||
multiple identical Invariant Sections may be replaced with a single
|
||||
copy. If there are multiple Invariant Sections with the same name but
|
||||
different contents, make the title of each such section unique by
|
||||
adding at the end of it, in parentheses, the name of the original
|
||||
author or publisher of that section if known, or else a unique number.
|
||||
Make the same adjustment to the section titles in the list of
|
||||
Invariant Sections in the license notice of the combined work.
|
||||
|
||||
In the combination, you must combine any sections Entitled ``History''
|
||||
in the various original documents, forming one section Entitled
|
||||
``History''; likewise combine any sections Entitled ``Acknowledgements'',
|
||||
and any sections Entitled ``Dedications''. You must delete all
|
||||
sections Entitled ``Endorsements.''
|
||||
|
||||
@item
|
||||
COLLECTIONS OF DOCUMENTS
|
||||
|
||||
You may make a collection consisting of the Document and other documents
|
||||
released under this License, and replace the individual copies of this
|
||||
License in the various documents with a single copy that is included in
|
||||
the collection, provided that you follow the rules of this License for
|
||||
verbatim copying of each of the documents in all other respects.
|
||||
|
||||
You may extract a single document from such a collection, and distribute
|
||||
it individually under this License, provided you insert a copy of this
|
||||
License into the extracted document, and follow this License in all
|
||||
other respects regarding verbatim copying of that document.
|
||||
|
||||
@item
|
||||
AGGREGATION WITH INDEPENDENT WORKS
|
||||
|
||||
A compilation of the Document or its derivatives with other separate
|
||||
and independent documents or works, in or on a volume of a storage or
|
||||
distribution medium, is called an ``aggregate'' if the copyright
|
||||
resulting from the compilation is not used to limit the legal rights
|
||||
of the compilation's users beyond what the individual works permit.
|
||||
When the Document is included in an aggregate, this License does not
|
||||
apply to the other works in the aggregate which are not themselves
|
||||
derivative works of the Document.
|
||||
|
||||
If the Cover Text requirement of section 3 is applicable to these
|
||||
copies of the Document, then if the Document is less than one half of
|
||||
the entire aggregate, the Document's Cover Texts may be placed on
|
||||
covers that bracket the Document within the aggregate, or the
|
||||
electronic equivalent of covers if the Document is in electronic form.
|
||||
Otherwise they must appear on printed covers that bracket the whole
|
||||
aggregate.
|
||||
|
||||
@item
|
||||
TRANSLATION
|
||||
|
||||
Translation is considered a kind of modification, so you may
|
||||
distribute translations of the Document under the terms of section 4.
|
||||
Replacing Invariant Sections with translations requires special
|
||||
permission from their copyright holders, but you may include
|
||||
translations of some or all Invariant Sections in addition to the
|
||||
original versions of these Invariant Sections. You may include a
|
||||
translation of this License, and all the license notices in the
|
||||
Document, and any Warranty Disclaimers, provided that you also include
|
||||
the original English version of this License and the original versions
|
||||
of those notices and disclaimers. In case of a disagreement between
|
||||
the translation and the original version of this License or a notice
|
||||
or disclaimer, the original version will prevail.
|
||||
|
||||
If a section in the Document is Entitled ``Acknowledgements'',
|
||||
``Dedications'', or ``History'', the requirement (section 4) to Preserve
|
||||
its Title (section 1) will typically require changing the actual
|
||||
title.
|
||||
|
||||
@item
|
||||
TERMINATION
|
||||
|
||||
You may not copy, modify, sublicense, or distribute the Document except
|
||||
as expressly provided for under this License. Any other attempt to
|
||||
copy, modify, sublicense or distribute the Document 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.
|
||||
|
||||
@item
|
||||
FUTURE REVISIONS OF THIS LICENSE
|
||||
|
||||
The Free Software Foundation may publish new, revised versions
|
||||
of the GNU Free Documentation 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. See
|
||||
@uref{http://www.gnu.org/copyleft/}.
|
||||
|
||||
Each version of the License is given a distinguishing version number.
|
||||
If the Document specifies that a particular numbered version of this
|
||||
License ``or any later version'' applies to it, you have the option of
|
||||
following the terms and conditions either of that specified version or
|
||||
of any later version that has been published (not as a draft) by the
|
||||
Free Software Foundation. If the Document does not specify a version
|
||||
number of this License, you may choose any version ever published (not
|
||||
as a draft) by the Free Software Foundation.
|
||||
@end enumerate
|
||||
|
||||
@page
|
||||
@appendixsubsec ADDENDUM: How to use this License for your documents
|
||||
|
||||
To use this License in a document you have written, include a copy of
|
||||
the License in the document and put the following copyright and
|
||||
license notices just after the title page:
|
||||
|
||||
@smallexample
|
||||
@group
|
||||
Copyright (C) @var{year} @var{your name}.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
|
||||
Texts. A copy of the license is included in the section entitled ``GNU
|
||||
Free Documentation License''.
|
||||
@end group
|
||||
@end smallexample
|
||||
|
||||
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
|
||||
replace the ``with...Texts.'' line with this:
|
||||
|
||||
@smallexample
|
||||
@group
|
||||
with the Invariant Sections being @var{list their titles}, with
|
||||
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
|
||||
being @var{list}.
|
||||
@end group
|
||||
@end smallexample
|
||||
|
||||
If you have Invariant Sections without Cover Texts, or some other
|
||||
combination of the three, merge those two alternatives to suit the
|
||||
situation.
|
||||
|
||||
If your document contains nontrivial examples of program code, we
|
||||
recommend releasing these examples in parallel under your choice of
|
||||
free software license, such as the GNU General Public License,
|
||||
to permit their use in free software.
|
||||
|
||||
@c Local Variables:
|
||||
@c ispell-local-pdict: "ispell-dict"
|
||||
@c End:
|
||||
|
4
contrib/diff/doc/stamp-vti
Normal file
4
contrib/diff/doc/stamp-vti
Normal file
@ -0,0 +1,4 @@
|
||||
@set UPDATED 12 April 2004
|
||||
@set UPDATED-MONTH April 2004
|
||||
@set EDITION 2.8.7
|
||||
@set VERSION 2.8.7
|
4
contrib/diff/doc/version.texi
Normal file
4
contrib/diff/doc/version.texi
Normal file
@ -0,0 +1,4 @@
|
||||
@set UPDATED 12 April 2004
|
||||
@set UPDATED-MONTH April 2004
|
||||
@set EDITION 2.8.7
|
||||
@set VERSION 2.8.7
|
115
contrib/diff/exgettext
Executable file
115
contrib/diff/exgettext
Executable file
@ -0,0 +1,115 @@
|
||||
#! /bin/sh
|
||||
# Wrapper around gettext for programs using the msgid convention.
|
||||
|
||||
# Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
|
||||
|
||||
# Written by Paul Eggert <eggert@twinsun.com>.
|
||||
|
||||
# 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 GNU CC; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# Always operate in the C locale.
|
||||
LANG=C
|
||||
LANGUAGE=C
|
||||
LC_ALL=C
|
||||
export LANG LANGUAGE LC_ALL
|
||||
|
||||
# Set AWK if environment has not already set it.
|
||||
AWK=${AWK-awk}
|
||||
|
||||
# The argument to this wrapper is the xgettext command to be executed.
|
||||
# Extract the xgettext program name from the rest of the command.
|
||||
xgettext=${1?}
|
||||
shift
|
||||
|
||||
# Save work if we're just wrapping a no-op.
|
||||
case $xgettext in
|
||||
:) exit;;
|
||||
esac
|
||||
|
||||
# Find the files to be scanned, and the directory to scan them from.
|
||||
directory=.
|
||||
files=
|
||||
for i
|
||||
do
|
||||
case $i in
|
||||
--directory=*)
|
||||
directory=`expr " $i" : ' --directory=\(.*\)'`;;
|
||||
--files-from=*)
|
||||
files_from=`expr " $i" : ' --files-from=\(.*\)'`
|
||||
files=`$AWK '/^[^#]/ { print }' $files_from`;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Generate keyword options for xgettext,
|
||||
# by scanning for declarations of functions
|
||||
# whose parameter names end in "msgid".
|
||||
generate_keyword_options='
|
||||
/^[A-Z_a-z].*\(.*msgid[,)]/ {
|
||||
|
||||
paren_index = index($0, "(")
|
||||
|
||||
name = substr($0, 1, paren_index - 1)
|
||||
sub(/[^0-9A-Z_a-z]*$/, "", name)
|
||||
sub(/[ ]+PARAMS/, "", name)
|
||||
sub(/[ ]+VPARAMS/, "", name)
|
||||
sub(/.*[^0-9A-Z_a-z]/, "", name)
|
||||
|
||||
args = substr($0, paren_index)
|
||||
sub(/msgid[,)].*/, "", args)
|
||||
for (n = 1; sub(/^[^,]*,/, "", args); n++) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (n == 1) {
|
||||
keyword = name
|
||||
} else {
|
||||
keyword = name ":" n
|
||||
}
|
||||
|
||||
if (! keyword_seen[keyword]++) {
|
||||
print "--keyword=" keyword
|
||||
}
|
||||
}
|
||||
'
|
||||
keyword_options=`(
|
||||
cd $directory &&
|
||||
$AWK "$generate_keyword_options" $files < /dev/null
|
||||
)` || exit
|
||||
|
||||
# Run the xgettext command, with extra input containing the extra
|
||||
# msgids that it wouldn't normally find.
|
||||
generate_emsgids='
|
||||
/%e.*}/ {
|
||||
line = $0
|
||||
while ((percent_index = index(line, "%e")) != 0) {
|
||||
line = substr(line, percent_index + 2)
|
||||
bracket_index = index(line, "}")
|
||||
if (bracket_index == 0) {
|
||||
continue
|
||||
}
|
||||
msgid = substr(line, 1, bracket_index - 1)
|
||||
if (index(msgid, "%") != 0) {
|
||||
continue
|
||||
}
|
||||
printf "#line %d \"%s\"\n", FNR, FILENAME
|
||||
printf "_(\"%s\")\n", msgid
|
||||
line = substr(line, bracket_index + 1)
|
||||
}
|
||||
}
|
||||
'
|
||||
(cd $directory &&
|
||||
$AWK "$generate_emsgids" $files < /dev/null
|
||||
) | "$xgettext" $keyword_options ${1+"$@"} -
|
35
contrib/diff/lib/Makefile.am
Normal file
35
contrib/diff/lib/Makefile.am
Normal file
@ -0,0 +1,35 @@
|
||||
# Automakefile for GNU Diffutils library.
|
||||
|
||||
# Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2, or (at your option)
|
||||
## any later version.
|
||||
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
## 02111-1307, USA.
|
||||
|
||||
noinst_LIBRARIES = libdiffutils.a
|
||||
|
||||
noinst_HEADERS = cmpbuf.h prepargs.h quotesys.h
|
||||
|
||||
libdiffutils_a_SOURCES = $(lib_SOURCES)
|
||||
lib_SOURCES = cmpbuf.c prepargs.c quotesys.c
|
||||
|
||||
libdiffutils_a_LIBADD = @ALLOCA@ @LIBOBJS@
|
||||
libdiffutils_a_DEPENDENCIES = $(libdiffutils_a_LIBADD)
|
||||
|
||||
BUILT_SOURCES =
|
||||
DISTCLEANFILES =
|
||||
EXTRA_DIST = setmode.h waitpid.c
|
||||
MOSTLYCLEANFILES =
|
||||
|
||||
include gnulib.mk
|
489
contrib/diff/lib/alloca.c
Normal file
489
contrib/diff/lib/alloca.c
Normal file
@ -0,0 +1,489 @@
|
||||
/* alloca.c -- allocate automatically reclaimed memory
|
||||
(Mostly) portable public-domain implementation -- D A Gwyn
|
||||
|
||||
This implementation of the PWB library alloca function,
|
||||
which is used to allocate space off the run-time stack so
|
||||
that it is automatically reclaimed upon procedure exit,
|
||||
was inspired by discussions with J. Q. Johnson of Cornell.
|
||||
J.Otto Tennant <jot@cray.com> contributed the Cray support.
|
||||
|
||||
There are some preprocessor constants that can
|
||||
be defined when compiling for your specific system, for
|
||||
improved efficiency; however, the defaults should be okay.
|
||||
|
||||
The general concept of this implementation is to keep
|
||||
track of all alloca-allocated blocks, and reclaim any
|
||||
that are found to be deeper in the stack than the current
|
||||
invocation. This heuristic does not reclaim storage as
|
||||
soon as it becomes invalid, but it will do so eventually.
|
||||
|
||||
As a special case, alloca(0) reclaims storage without
|
||||
allocating any. It is a good idea to use alloca(0) in
|
||||
your main control loop, etc. to force garbage collection. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef emacs
|
||||
# include "lisp.h"
|
||||
# include "blockinput.h"
|
||||
# ifdef EMACS_FREE
|
||||
# undef free
|
||||
# define free EMACS_FREE
|
||||
# endif
|
||||
#else
|
||||
# define memory_full() abort ()
|
||||
#endif
|
||||
|
||||
/* If compiling with GCC 2, this file's not needed. */
|
||||
#if !defined (__GNUC__) || __GNUC__ < 2
|
||||
|
||||
/* If someone has defined alloca as a macro,
|
||||
there must be some other way alloca is supposed to work. */
|
||||
# ifndef alloca
|
||||
|
||||
# ifdef emacs
|
||||
# ifdef static
|
||||
/* actually, only want this if static is defined as ""
|
||||
-- this is for usg, in which emacs must undefine static
|
||||
in order to make unexec workable
|
||||
*/
|
||||
# ifndef STACK_DIRECTION
|
||||
you
|
||||
lose
|
||||
-- must know STACK_DIRECTION at compile-time
|
||||
/* Using #error here is not wise since this file should work for
|
||||
old and obscure compilers. */
|
||||
# endif /* STACK_DIRECTION undefined */
|
||||
# endif /* static */
|
||||
# endif /* emacs */
|
||||
|
||||
/* If your stack is a linked list of frames, you have to
|
||||
provide an "address metric" ADDRESS_FUNCTION macro. */
|
||||
|
||||
# if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
long i00afunc ();
|
||||
# define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
|
||||
# else
|
||||
# define ADDRESS_FUNCTION(arg) &(arg)
|
||||
# endif
|
||||
|
||||
/* Define STACK_DIRECTION if you know the direction of stack
|
||||
growth for your system; otherwise it will be automatically
|
||||
deduced at run-time.
|
||||
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
|
||||
# ifndef STACK_DIRECTION
|
||||
# define STACK_DIRECTION 0 /* Direction unknown. */
|
||||
# endif
|
||||
|
||||
# if STACK_DIRECTION != 0
|
||||
|
||||
# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
|
||||
|
||||
# else /* STACK_DIRECTION == 0; need run-time code. */
|
||||
|
||||
static int stack_dir; /* 1 or -1 once known. */
|
||||
# define STACK_DIR stack_dir
|
||||
|
||||
static void
|
||||
find_stack_direction (void)
|
||||
{
|
||||
static char *addr = NULL; /* Address of first `dummy', once known. */
|
||||
auto char dummy; /* To get stack address. */
|
||||
|
||||
if (addr == NULL)
|
||||
{ /* Initial entry. */
|
||||
addr = ADDRESS_FUNCTION (dummy);
|
||||
|
||||
find_stack_direction (); /* Recurse once. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Second entry. */
|
||||
if (ADDRESS_FUNCTION (dummy) > addr)
|
||||
stack_dir = 1; /* Stack grew upward. */
|
||||
else
|
||||
stack_dir = -1; /* Stack grew downward. */
|
||||
}
|
||||
}
|
||||
|
||||
# endif /* STACK_DIRECTION == 0 */
|
||||
|
||||
/* An "alloca header" is used to:
|
||||
(a) chain together all alloca'ed blocks;
|
||||
(b) keep track of stack depth.
|
||||
|
||||
It is very important that sizeof(header) agree with malloc
|
||||
alignment chunk size. The following default should work okay. */
|
||||
|
||||
# ifndef ALIGN_SIZE
|
||||
# define ALIGN_SIZE sizeof(double)
|
||||
# endif
|
||||
|
||||
typedef union hdr
|
||||
{
|
||||
char align[ALIGN_SIZE]; /* To force sizeof(header). */
|
||||
struct
|
||||
{
|
||||
union hdr *next; /* For chaining headers. */
|
||||
char *deep; /* For stack depth measure. */
|
||||
} h;
|
||||
} header;
|
||||
|
||||
static header *last_alloca_header = NULL; /* -> last alloca header. */
|
||||
|
||||
/* Return a pointer to at least SIZE bytes of storage,
|
||||
which will be automatically reclaimed upon exit from
|
||||
the procedure that called alloca. Originally, this space
|
||||
was supposed to be taken from the current stack frame of the
|
||||
caller, but that method cannot be made to work for some
|
||||
implementations of C, for example under Gould's UTX/32. */
|
||||
|
||||
void *
|
||||
alloca (size_t size)
|
||||
{
|
||||
auto char probe; /* Probes stack depth: */
|
||||
register char *depth = ADDRESS_FUNCTION (probe);
|
||||
|
||||
# if STACK_DIRECTION == 0
|
||||
if (STACK_DIR == 0) /* Unknown growth direction. */
|
||||
find_stack_direction ();
|
||||
# endif
|
||||
|
||||
/* Reclaim garbage, defined as all alloca'd storage that
|
||||
was allocated from deeper in the stack than currently. */
|
||||
|
||||
{
|
||||
register header *hp; /* Traverses linked list. */
|
||||
|
||||
# ifdef emacs
|
||||
BLOCK_INPUT;
|
||||
# endif
|
||||
|
||||
for (hp = last_alloca_header; hp != NULL;)
|
||||
if ((STACK_DIR > 0 && hp->h.deep > depth)
|
||||
|| (STACK_DIR < 0 && hp->h.deep < depth))
|
||||
{
|
||||
register header *np = hp->h.next;
|
||||
|
||||
free (hp); /* Collect garbage. */
|
||||
|
||||
hp = np; /* -> next header. */
|
||||
}
|
||||
else
|
||||
break; /* Rest are not deeper. */
|
||||
|
||||
last_alloca_header = hp; /* -> last valid storage. */
|
||||
|
||||
# ifdef emacs
|
||||
UNBLOCK_INPUT;
|
||||
# endif
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
return NULL; /* No allocation required. */
|
||||
|
||||
/* Allocate combined header + user data storage. */
|
||||
|
||||
{
|
||||
/* Address of header. */
|
||||
register header *new;
|
||||
|
||||
size_t combined_size = sizeof (header) + size;
|
||||
if (combined_size < sizeof (header))
|
||||
memory_full ();
|
||||
|
||||
new = malloc (combined_size);
|
||||
|
||||
if (! new)
|
||||
memory_full ();
|
||||
|
||||
new->h.next = last_alloca_header;
|
||||
new->h.deep = depth;
|
||||
|
||||
last_alloca_header = new;
|
||||
|
||||
/* User storage begins just after header. */
|
||||
|
||||
return (void *) (new + 1);
|
||||
}
|
||||
}
|
||||
|
||||
# if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
|
||||
# ifndef CRAY_STACK
|
||||
# define CRAY_STACK
|
||||
# ifndef CRAY2
|
||||
/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
|
||||
struct stack_control_header
|
||||
{
|
||||
long shgrow:32; /* Number of times stack has grown. */
|
||||
long shaseg:32; /* Size of increments to stack. */
|
||||
long shhwm:32; /* High water mark of stack. */
|
||||
long shsize:32; /* Current size of stack (all segments). */
|
||||
};
|
||||
|
||||
/* The stack segment linkage control information occurs at
|
||||
the high-address end of a stack segment. (The stack
|
||||
grows from low addresses to high addresses.) The initial
|
||||
part of the stack segment linkage control information is
|
||||
0200 (octal) words. This provides for register storage
|
||||
for the routine which overflows the stack. */
|
||||
|
||||
struct stack_segment_linkage
|
||||
{
|
||||
long ss[0200]; /* 0200 overflow words. */
|
||||
long sssize:32; /* Number of words in this segment. */
|
||||
long ssbase:32; /* Offset to stack base. */
|
||||
long:32;
|
||||
long sspseg:32; /* Offset to linkage control of previous
|
||||
segment of stack. */
|
||||
long:32;
|
||||
long sstcpt:32; /* Pointer to task common address block. */
|
||||
long sscsnm; /* Private control structure number for
|
||||
microtasking. */
|
||||
long ssusr1; /* Reserved for user. */
|
||||
long ssusr2; /* Reserved for user. */
|
||||
long sstpid; /* Process ID for pid based multi-tasking. */
|
||||
long ssgvup; /* Pointer to multitasking thread giveup. */
|
||||
long sscray[7]; /* Reserved for Cray Research. */
|
||||
long ssa0;
|
||||
long ssa1;
|
||||
long ssa2;
|
||||
long ssa3;
|
||||
long ssa4;
|
||||
long ssa5;
|
||||
long ssa6;
|
||||
long ssa7;
|
||||
long sss0;
|
||||
long sss1;
|
||||
long sss2;
|
||||
long sss3;
|
||||
long sss4;
|
||||
long sss5;
|
||||
long sss6;
|
||||
long sss7;
|
||||
};
|
||||
|
||||
# else /* CRAY2 */
|
||||
/* The following structure defines the vector of words
|
||||
returned by the STKSTAT library routine. */
|
||||
struct stk_stat
|
||||
{
|
||||
long now; /* Current total stack size. */
|
||||
long maxc; /* Amount of contiguous space which would
|
||||
be required to satisfy the maximum
|
||||
stack demand to date. */
|
||||
long high_water; /* Stack high-water mark. */
|
||||
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
|
||||
long hits; /* Number of internal buffer hits. */
|
||||
long extends; /* Number of block extensions. */
|
||||
long stko_mallocs; /* Block allocations by $STKOFEN. */
|
||||
long underflows; /* Number of stack underflow calls ($STKRETN). */
|
||||
long stko_free; /* Number of deallocations by $STKRETN. */
|
||||
long stkm_free; /* Number of deallocations by $STKMRET. */
|
||||
long segments; /* Current number of stack segments. */
|
||||
long maxs; /* Maximum number of stack segments so far. */
|
||||
long pad_size; /* Stack pad size. */
|
||||
long current_address; /* Current stack segment address. */
|
||||
long current_size; /* Current stack segment size. This
|
||||
number is actually corrupted by STKSTAT to
|
||||
include the fifteen word trailer area. */
|
||||
long initial_address; /* Address of initial segment. */
|
||||
long initial_size; /* Size of initial segment. */
|
||||
};
|
||||
|
||||
/* The following structure describes the data structure which trails
|
||||
any stack segment. I think that the description in 'asdef' is
|
||||
out of date. I only describe the parts that I am sure about. */
|
||||
|
||||
struct stk_trailer
|
||||
{
|
||||
long this_address; /* Address of this block. */
|
||||
long this_size; /* Size of this block (does not include
|
||||
this trailer). */
|
||||
long unknown2;
|
||||
long unknown3;
|
||||
long link; /* Address of trailer block of previous
|
||||
segment. */
|
||||
long unknown5;
|
||||
long unknown6;
|
||||
long unknown7;
|
||||
long unknown8;
|
||||
long unknown9;
|
||||
long unknown10;
|
||||
long unknown11;
|
||||
long unknown12;
|
||||
long unknown13;
|
||||
long unknown14;
|
||||
};
|
||||
|
||||
# endif /* CRAY2 */
|
||||
# endif /* not CRAY_STACK */
|
||||
|
||||
# ifdef CRAY2
|
||||
/* Determine a "stack measure" for an arbitrary ADDRESS.
|
||||
I doubt that "lint" will like this much. */
|
||||
|
||||
static long
|
||||
i00afunc (long *address)
|
||||
{
|
||||
struct stk_stat status;
|
||||
struct stk_trailer *trailer;
|
||||
long *block, size;
|
||||
long result = 0;
|
||||
|
||||
/* We want to iterate through all of the segments. The first
|
||||
step is to get the stack status structure. We could do this
|
||||
more quickly and more directly, perhaps, by referencing the
|
||||
$LM00 common block, but I know that this works. */
|
||||
|
||||
STKSTAT (&status);
|
||||
|
||||
/* Set up the iteration. */
|
||||
|
||||
trailer = (struct stk_trailer *) (status.current_address
|
||||
+ status.current_size
|
||||
- 15);
|
||||
|
||||
/* There must be at least one stack segment. Therefore it is
|
||||
a fatal error if "trailer" is null. */
|
||||
|
||||
if (trailer == 0)
|
||||
abort ();
|
||||
|
||||
/* Discard segments that do not contain our argument address. */
|
||||
|
||||
while (trailer != 0)
|
||||
{
|
||||
block = (long *) trailer->this_address;
|
||||
size = trailer->this_size;
|
||||
if (block == 0 || size == 0)
|
||||
abort ();
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
if ((block <= address) && (address < (block + size)))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the result to the offset in this segment and add the sizes
|
||||
of all predecessor segments. */
|
||||
|
||||
result = address - block;
|
||||
|
||||
if (trailer == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (trailer->this_size <= 0)
|
||||
abort ();
|
||||
result += trailer->this_size;
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
}
|
||||
while (trailer != 0);
|
||||
|
||||
/* We are done. Note that if you present a bogus address (one
|
||||
not in any segment), you will get a different number back, formed
|
||||
from subtracting the address of the first block. This is probably
|
||||
not what you want. */
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
# else /* not CRAY2 */
|
||||
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
|
||||
Determine the number of the cell within the stack,
|
||||
given the address of the cell. The purpose of this
|
||||
routine is to linearize, in some sense, stack addresses
|
||||
for alloca. */
|
||||
|
||||
static long
|
||||
i00afunc (long address)
|
||||
{
|
||||
long stkl = 0;
|
||||
|
||||
long size, pseg, this_segment, stack;
|
||||
long result = 0;
|
||||
|
||||
struct stack_segment_linkage *ssptr;
|
||||
|
||||
/* Register B67 contains the address of the end of the
|
||||
current stack segment. If you (as a subprogram) store
|
||||
your registers on the stack and find that you are past
|
||||
the contents of B67, you have overflowed the segment.
|
||||
|
||||
B67 also points to the stack segment linkage control
|
||||
area, which is what we are really interested in. */
|
||||
|
||||
stkl = CRAY_STACKSEG_END ();
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
|
||||
/* If one subtracts 'size' from the end of the segment,
|
||||
one has the address of the first word of the segment.
|
||||
|
||||
If this is not the first segment, 'pseg' will be
|
||||
nonzero. */
|
||||
|
||||
pseg = ssptr->sspseg;
|
||||
size = ssptr->sssize;
|
||||
|
||||
this_segment = stkl - size;
|
||||
|
||||
/* It is possible that calling this routine itself caused
|
||||
a stack overflow. Discard stack segments which do not
|
||||
contain the target address. */
|
||||
|
||||
while (!(this_segment <= address && address <= stkl))
|
||||
{
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
|
||||
# endif
|
||||
if (pseg == 0)
|
||||
break;
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
this_segment = stkl - size;
|
||||
}
|
||||
|
||||
result = address - this_segment;
|
||||
|
||||
/* If you subtract pseg from the current end of the stack,
|
||||
you get the address of the previous stack segment's end.
|
||||
This seems a little convoluted to me, but I'll bet you save
|
||||
a cycle somewhere. */
|
||||
|
||||
while (pseg != 0)
|
||||
{
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o\n", pseg, size);
|
||||
# endif
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
result += size;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
# endif /* not CRAY2 */
|
||||
# endif /* CRAY */
|
||||
|
||||
# endif /* no alloca */
|
||||
#endif /* not GCC version 2 */
|
68
contrib/diff/lib/alloca_.h
Normal file
68
contrib/diff/lib/alloca_.h
Normal file
@ -0,0 +1,68 @@
|
||||
/* Memory allocation on the stack.
|
||||
Copyright (C) 1995, 1999, 2001-2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
/* When this file is included, it may be preceded only by preprocessor
|
||||
declarations. Thanks to AIX. Therefore we include it right after
|
||||
"config.h", not later. */
|
||||
|
||||
#ifndef _ALLOCA_H
|
||||
# define _ALLOCA_H
|
||||
|
||||
/* alloca(N) returns a pointer (void* or char*) to N bytes of memory
|
||||
allocated on the stack, and which will last until the function returns.
|
||||
Use of alloca should be avoided:
|
||||
- inside arguments of function calls - undefined behaviour,
|
||||
- in inline functions - the allocation may actually last until the
|
||||
calling function returns,
|
||||
- for huge N (say, N >= 65536) - you never know how large (or small)
|
||||
the stack is, and when the stack cannot fulfill the memory allocation
|
||||
request, the program just crashes.
|
||||
*/
|
||||
|
||||
# ifdef __GNUC__
|
||||
# ifndef alloca
|
||||
# define alloca __builtin_alloca
|
||||
# endif
|
||||
# else
|
||||
# ifdef _MSC_VER
|
||||
# include <malloc.h>
|
||||
# define alloca _alloca
|
||||
# else
|
||||
# if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifdef _AIX
|
||||
# pragma alloca
|
||||
# else
|
||||
# ifdef __hpux /* This section must match that of bison generated files. */
|
||||
# ifdef __cplusplus
|
||||
extern "C" void *alloca (unsigned int);
|
||||
# else /* not __cplusplus */
|
||||
extern void *alloca ();
|
||||
# endif /* not __cplusplus */
|
||||
# else /* not __hpux */
|
||||
# ifndef alloca
|
||||
extern char *alloca ();
|
||||
# endif
|
||||
# endif /* __hpux */
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif /* _ALLOCA_H */
|
79
contrib/diff/lib/basename.c
Normal file
79
contrib/diff/lib/basename.c
Normal file
@ -0,0 +1,79 @@
|
||||
/* basename.c -- return the last element in a path
|
||||
|
||||
Copyright (C) 1990, 1998, 1999, 2000, 2001, 2003 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "dirname.h"
|
||||
#include <string.h>
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `basename' modifies its argument.
|
||||
|
||||
Return the address of the last file name component of NAME. If
|
||||
NAME has no file name components because it is all slashes, return
|
||||
NAME if it is empty, the address of its last slash otherwise. */
|
||||
|
||||
char *
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = name + FILESYSTEM_PREFIX_LEN (name);
|
||||
char const *p;
|
||||
|
||||
for (p = base; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
{
|
||||
/* Treat multiple adjacent slashes like a single slash. */
|
||||
do p++;
|
||||
while (ISSLASH (*p));
|
||||
|
||||
/* If the file name ends in slash, use the trailing slash as
|
||||
the basename if no non-slashes have been found. */
|
||||
if (! *p)
|
||||
{
|
||||
if (ISSLASH (*base))
|
||||
base = p - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* *P is a non-slash preceded by a slash. */
|
||||
base = p;
|
||||
}
|
||||
}
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
/* Return the length of of the basename NAME. Typically NAME is the
|
||||
value returned by base_name. Act like strlen (NAME), except omit
|
||||
redundant trailing slashes. */
|
||||
|
||||
size_t
|
||||
base_len (char const *name)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
|
||||
continue;
|
||||
|
||||
return len;
|
||||
}
|
311
contrib/diff/lib/c-stack.c
Normal file
311
contrib/diff/lib/c-stack.c
Normal file
@ -0,0 +1,311 @@
|
||||
/* Stack overflow handling.
|
||||
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
/* NOTES:
|
||||
|
||||
A program that uses alloca, dynamic arrays, or large local
|
||||
variables may extend the stack by more than a page at a time. If
|
||||
so, when the stack overflows the operating system may not detect
|
||||
the overflow until the program uses the array, and this module may
|
||||
incorrectly report a program error instead of a stack overflow.
|
||||
|
||||
To avoid this problem, allocate only small objects on the stack; a
|
||||
program should be OK if it limits single allocations to a page or
|
||||
less. Allocate larger arrays in static storage, or on the heap
|
||||
(e.g., with malloc). Yes, this is a pain, but we don't know of any
|
||||
better solution that is portable.
|
||||
|
||||
No attempt has been made to deal with multithreaded applications. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 3 || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef ENOTSUP
|
||||
# define ENOTSUP EINVAL
|
||||
#endif
|
||||
#ifndef EOVERFLOW
|
||||
# define EOVERFLOW EINVAL
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#if ! HAVE_STACK_T && ! defined stack_t
|
||||
typedef struct sigaltstack stack_t;
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_SYS_RESOURCE_H
|
||||
/* Include sys/time.h here, because...
|
||||
SunOS-4.1.x <sys/resource.h> fails to include <sys/time.h>.
|
||||
This gives "incomplete type" errors for ru_utime and tu_stime. */
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# endif
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UCONTEXT_H
|
||||
# include <ucontext.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifndef STDERR_FILENO
|
||||
# define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "c-stack.h"
|
||||
#include "exitfail.h"
|
||||
|
||||
#if (HAVE_STRUCT_SIGACTION_SA_SIGACTION && defined SA_NODEFER \
|
||||
&& defined SA_ONSTACK && defined SA_RESETHAND && defined SA_SIGINFO)
|
||||
# define SIGACTION_WORKS 1
|
||||
#else
|
||||
# define SIGACTION_WORKS 0
|
||||
#endif
|
||||
|
||||
extern char *program_name;
|
||||
|
||||
/* The user-specified action to take when a SEGV-related program error
|
||||
or stack overflow occurs. */
|
||||
static void (* volatile segv_action) (int);
|
||||
|
||||
/* Translated messages for program errors and stack overflow. Do not
|
||||
translate them in the signal handler, since gettext is not
|
||||
async-signal-safe. */
|
||||
static char const * volatile program_error_message;
|
||||
static char const * volatile stack_overflow_message;
|
||||
|
||||
/* Output an error message, then exit with status EXIT_FAILURE if it
|
||||
appears to have been a stack overflow, or with a core dump
|
||||
otherwise. This function is async-signal-safe. */
|
||||
|
||||
static void die (int) __attribute__ ((noreturn));
|
||||
static void
|
||||
die (int signo)
|
||||
{
|
||||
char const *message;
|
||||
segv_action (signo);
|
||||
message = signo ? program_error_message : stack_overflow_message;
|
||||
write (STDERR_FILENO, program_name, strlen (program_name));
|
||||
write (STDERR_FILENO, ": ", 2);
|
||||
write (STDERR_FILENO, message, strlen (message));
|
||||
write (STDERR_FILENO, "\n", 1);
|
||||
if (! signo)
|
||||
_exit (exit_failure);
|
||||
kill (getpid (), signo);
|
||||
abort ();
|
||||
}
|
||||
|
||||
#if HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK
|
||||
|
||||
/* Direction of the C runtime stack. This function is
|
||||
async-signal-safe. */
|
||||
|
||||
# if STACK_DIRECTION
|
||||
# define find_stack_direction(ptr) STACK_DIRECTION
|
||||
# else
|
||||
static int
|
||||
find_stack_direction (char const *addr)
|
||||
{
|
||||
char dummy;
|
||||
return ! addr ? find_stack_direction (&dummy) : addr < &dummy ? 1 : -1;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Storage for the alternate signal stack. */
|
||||
static union
|
||||
{
|
||||
char buffer[SIGSTKSZ];
|
||||
|
||||
/* These other members are for proper alignment. There's no
|
||||
standard way to guarantee stack alignment, but this seems enough
|
||||
in practice. */
|
||||
long double ld;
|
||||
long l;
|
||||
void *p;
|
||||
} alternate_signal_stack;
|
||||
|
||||
# if SIGACTION_WORKS
|
||||
|
||||
/* Handle a segmentation violation and exit. This function is
|
||||
async-signal-safe. */
|
||||
|
||||
static void segv_handler (int, siginfo_t *, void *) __attribute__((noreturn));
|
||||
static void
|
||||
segv_handler (int signo, siginfo_t *info,
|
||||
void *context __attribute__ ((unused)))
|
||||
{
|
||||
/* Clear SIGNO if it seems to have been a stack overflow. */
|
||||
if (0 < info->si_code)
|
||||
{
|
||||
# if ! HAVE_XSI_STACK_OVERFLOW_HEURISTIC
|
||||
/* We can't easily determine whether it is a stack overflow; so
|
||||
assume that the rest of our program is perfect (!) and that
|
||||
this segmentation violation is a stack overflow. */
|
||||
signo = 0;
|
||||
# else
|
||||
/* If the faulting address is within the stack, or within one
|
||||
page of the stack end, assume that it is a stack
|
||||
overflow. */
|
||||
ucontext_t const *user_context = context;
|
||||
char const *stack_base = user_context->uc_stack.ss_sp;
|
||||
size_t stack_size = user_context->uc_stack.ss_size;
|
||||
char const *faulting_address = info->si_addr;
|
||||
size_t s = faulting_address - stack_base;
|
||||
size_t page_size = sysconf (_SC_PAGESIZE);
|
||||
if (find_stack_direction (0) < 0)
|
||||
s += page_size;
|
||||
if (s < stack_size + page_size)
|
||||
signo = 0;
|
||||
|
||||
# if DEBUG
|
||||
{
|
||||
char buf[1024];
|
||||
sprintf (buf,
|
||||
"segv_handler fault=%p base=%p size=%lx page=%lx signo=%d\n",
|
||||
faulting_address, stack_base, (unsigned long) stack_size,
|
||||
(unsigned long) page_size, signo);
|
||||
write (STDERR_FILENO, buf, strlen (buf));
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
|
||||
die (signo);
|
||||
}
|
||||
# endif
|
||||
|
||||
static void
|
||||
null_action (int signo __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
/* Set up ACTION so that it is invoked on C stack overflow. Return -1
|
||||
(setting errno) if this cannot be done.
|
||||
|
||||
When ACTION is called, it is passed an argument equal to SIGSEGV
|
||||
for a segmentation violation that does not appear related to stack
|
||||
overflow, and is passed zero otherwise. On many platforms it is
|
||||
hard to tell; when in doubt, zero is passed.
|
||||
|
||||
A null ACTION acts like an action that does nothing.
|
||||
|
||||
ACTION must be async-signal-safe. ACTION together with its callees
|
||||
must not require more than SIGSTKSZ bytes of stack space. */
|
||||
|
||||
int
|
||||
c_stack_action (void (*action) (int))
|
||||
{
|
||||
int r;
|
||||
stack_t st;
|
||||
st.ss_flags = 0;
|
||||
st.ss_sp = alternate_signal_stack.buffer;
|
||||
st.ss_size = sizeof alternate_signal_stack.buffer;
|
||||
r = sigaltstack (&st, 0);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
segv_action = action ? action : null_action;
|
||||
program_error_message = _("program error");
|
||||
stack_overflow_message = _("stack overflow");
|
||||
|
||||
{
|
||||
# if SIGACTION_WORKS
|
||||
struct sigaction act;
|
||||
sigemptyset (&act.sa_mask);
|
||||
|
||||
/* POSIX 1003.1-2001 says SA_RESETHAND implies SA_NODEFER, but
|
||||
this is not true on Solaris 8 at least. It doesn't hurt to use
|
||||
SA_NODEFER here, so leave it in. */
|
||||
act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
|
||||
|
||||
act.sa_sigaction = segv_handler;
|
||||
|
||||
return sigaction (SIGSEGV, &act, 0);
|
||||
# else
|
||||
return signal (SIGSEGV, die) == SIG_ERR ? -1 : 0;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
#else /* ! (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK) */
|
||||
|
||||
int
|
||||
c_stack_action (void (*action) (int) __attribute__ ((unused)))
|
||||
{
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if DEBUG
|
||||
|
||||
int volatile exit_failure;
|
||||
|
||||
static long
|
||||
recurse (char *p)
|
||||
{
|
||||
char array[500];
|
||||
array[0] = 1;
|
||||
return *p + recurse (array);
|
||||
}
|
||||
|
||||
char *program_name;
|
||||
|
||||
int
|
||||
main (int argc __attribute__ ((unused)), char **argv)
|
||||
{
|
||||
program_name = argv[0];
|
||||
fprintf (stderr,
|
||||
"The last output line should contain \"stack overflow\".\n");
|
||||
if (c_stack_action (0) == 0)
|
||||
return recurse ("\1");
|
||||
perror ("c_stack_action");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
compile-command: "gcc -DDEBUG -DHAVE_CONFIG_H -I.. -g -O -Wall -W c-stack.c"
|
||||
End:
|
||||
*/
|
19
contrib/diff/lib/c-stack.h
Normal file
19
contrib/diff/lib/c-stack.h
Normal file
@ -0,0 +1,19 @@
|
||||
/* Stack overflow handling.
|
||||
|
||||
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
int c_stack_action (void (*) (int));
|
147
contrib/diff/lib/cmpbuf.c
Normal file
147
contrib/diff/lib/cmpbuf.c
Normal file
@ -0,0 +1,147 @@
|
||||
/* Buffer primitives for comparison operations.
|
||||
|
||||
Copyright (C) 1993, 1995, 1998, 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <signal.h>
|
||||
#ifndef SA_RESTART
|
||||
# ifdef SA_INTERRUPT /* e.g. SunOS 4.1.x */
|
||||
# define SA_RESTART SA_INTERRUPT
|
||||
# else
|
||||
# define SA_RESTART 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "cmpbuf.h"
|
||||
|
||||
/* Determine whether an integer type is signed, and its bounds.
|
||||
This code assumes two's (or one's!) complement with no holes. */
|
||||
|
||||
/* The extra casts work around common compiler bugs,
|
||||
e.g. Cray C 5.0.3.0 when t == time_t. */
|
||||
#ifndef TYPE_SIGNED
|
||||
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
#endif
|
||||
#ifndef TYPE_MINIMUM
|
||||
# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
|
||||
: (t) 0))
|
||||
#endif
|
||||
#ifndef TYPE_MAXIMUM
|
||||
# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
||||
#endif
|
||||
|
||||
#ifndef PTRDIFF_MAX
|
||||
# define PTRDIFF_MAX TYPE_MAXIMUM (ptrdiff_t)
|
||||
#endif
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX TYPE_MAXIMUM (size_t)
|
||||
#endif
|
||||
#ifndef SSIZE_MAX
|
||||
# define SSIZE_MAX TYPE_MAXIMUM (ssize_t)
|
||||
#endif
|
||||
|
||||
#undef MIN
|
||||
#define MIN(a, b) ((a) <= (b) ? (a) : (b))
|
||||
|
||||
/* Read NBYTES bytes from descriptor FD into BUF.
|
||||
NBYTES must not be SIZE_MAX.
|
||||
Return the number of characters successfully read.
|
||||
On error, return SIZE_MAX, setting errno.
|
||||
The number returned is always NBYTES unless end-of-file or error. */
|
||||
|
||||
size_t
|
||||
block_read (int fd, char *buf, size_t nbytes)
|
||||
{
|
||||
char *bp = buf;
|
||||
char const *buflim = buf + nbytes;
|
||||
size_t readlim = SSIZE_MAX;
|
||||
|
||||
do
|
||||
{
|
||||
size_t bytes_to_read = MIN (buflim - bp, readlim);
|
||||
ssize_t nread = read (fd, bp, bytes_to_read);
|
||||
if (nread <= 0)
|
||||
{
|
||||
if (nread == 0)
|
||||
break;
|
||||
|
||||
/* Accommodate Tru64 5.1, which can't read more than INT_MAX
|
||||
bytes at a time. They call that a 64-bit OS? */
|
||||
if (errno == EINVAL && INT_MAX < bytes_to_read)
|
||||
{
|
||||
readlim = INT_MAX;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* This is needed for programs that have signal handlers on
|
||||
older hosts without SA_RESTART. It also accommodates
|
||||
ancient AIX hosts that set errno to EINTR after uncaught
|
||||
SIGCONT. See <news:1r77ojINN85n@ftp.UU.NET>
|
||||
(1993-04-22). */
|
||||
if (! SA_RESTART && errno == EINTR)
|
||||
continue;
|
||||
|
||||
return SIZE_MAX;
|
||||
}
|
||||
bp += nread;
|
||||
}
|
||||
while (bp < buflim);
|
||||
|
||||
return bp - buf;
|
||||
}
|
||||
|
||||
/* Least common multiple of two buffer sizes A and B. However, if
|
||||
either A or B is zero, or if the multiple is greater than LCM_MAX,
|
||||
return a reasonable buffer size. */
|
||||
|
||||
size_t
|
||||
buffer_lcm (size_t a, size_t b, size_t lcm_max)
|
||||
{
|
||||
size_t lcm, m, n, q, r;
|
||||
|
||||
/* Yield reasonable values if buffer sizes are zero. */
|
||||
if (!a)
|
||||
return b ? b : 8 * 1024;
|
||||
if (!b)
|
||||
return a;
|
||||
|
||||
/* n = gcd (a, b) */
|
||||
for (m = a, n = b; (r = m % n) != 0; m = n, n = r)
|
||||
continue;
|
||||
|
||||
/* Yield a if there is an overflow. */
|
||||
q = a / n;
|
||||
lcm = q * b;
|
||||
return lcm <= lcm_max && lcm / b == q ? lcm : a;
|
||||
}
|
21
contrib/diff/lib/cmpbuf.h
Normal file
21
contrib/diff/lib/cmpbuf.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* Buffer primitives for comparison operations.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
size_t block_read (int, char *, size_t);
|
||||
size_t buffer_lcm (size_t, size_t, size_t);
|
119
contrib/diff/lib/dirname.c
Normal file
119
contrib/diff/lib/dirname.c
Normal file
@ -0,0 +1,119 @@
|
||||
/* dirname.c -- return all but the last element in a path
|
||||
Copyright (C) 1990, 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "xalloc.h"
|
||||
|
||||
/* Return the length of `dirname (PATH)', or zero if PATH is
|
||||
in the working directory. Works properly even if
|
||||
there are trailing slashes (by effectively ignoring them). */
|
||||
size_t
|
||||
dir_len (char const *path)
|
||||
{
|
||||
size_t prefix_length = FILESYSTEM_PREFIX_LEN (path);
|
||||
size_t length;
|
||||
|
||||
/* Strip the basename and any redundant slashes before it. */
|
||||
for (length = base_name (path) - path; prefix_length < length; length--)
|
||||
if (! ISSLASH (path[length - 1]))
|
||||
return length;
|
||||
|
||||
/* But don't strip the only slash from "/". */
|
||||
return prefix_length + ISSLASH (path[prefix_length]);
|
||||
}
|
||||
|
||||
/* Return the leading directories part of PATH,
|
||||
allocated with xmalloc.
|
||||
Works properly even if there are trailing slashes
|
||||
(by effectively ignoring them). */
|
||||
|
||||
char *
|
||||
dir_name (char const *path)
|
||||
{
|
||||
size_t length = dir_len (path);
|
||||
int append_dot = (length == FILESYSTEM_PREFIX_LEN (path));
|
||||
char *newpath = xmalloc (length + append_dot + 1);
|
||||
memcpy (newpath, path, length);
|
||||
if (append_dot)
|
||||
newpath[length++] = '.';
|
||||
newpath[length] = 0;
|
||||
return newpath;
|
||||
}
|
||||
|
||||
#ifdef TEST_DIRNAME
|
||||
/*
|
||||
|
||||
Run the test like this (expect no output):
|
||||
gcc -DHAVE_CONFIG_H -DTEST_DIRNAME -I.. -O -Wall \
|
||||
basename.c dirname.c xmalloc.c error.c
|
||||
sed -n '/^BEGIN-DATA$/,/^END-DATA$/p' dirname.c|grep -v DATA|./a.out
|
||||
|
||||
If it's been built on a DOS or Windows platforms, run another test like
|
||||
this (again, expect no output):
|
||||
sed -n '/^BEGIN-DOS-DATA$/,/^END-DOS-DATA$/p' dirname.c|grep -v DATA|./a.out
|
||||
|
||||
BEGIN-DATA
|
||||
foo//// .
|
||||
bar/foo//// bar
|
||||
foo/ .
|
||||
/ /
|
||||
. .
|
||||
a .
|
||||
END-DATA
|
||||
|
||||
BEGIN-DOS-DATA
|
||||
c:///// c:/
|
||||
c:/ c:/
|
||||
c:/. c:/
|
||||
c:foo c:.
|
||||
c:foo/bar c:foo
|
||||
END-DOS-DATA
|
||||
|
||||
*/
|
||||
|
||||
# define MAX_BUFF_LEN 1024
|
||||
# include <stdio.h>
|
||||
|
||||
char *program_name;
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
char buff[MAX_BUFF_LEN + 1];
|
||||
|
||||
program_name = argv[0];
|
||||
|
||||
buff[MAX_BUFF_LEN] = 0;
|
||||
while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0])
|
||||
{
|
||||
char path[MAX_BUFF_LEN];
|
||||
char expected_result[MAX_BUFF_LEN];
|
||||
char const *result;
|
||||
sscanf (buff, "%s %s", path, expected_result);
|
||||
result = dir_name (path);
|
||||
if (strcmp (result, expected_result))
|
||||
printf ("%s: got %s, expected %s\n", path, result, expected_result);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
43
contrib/diff/lib/dirname.h
Normal file
43
contrib/diff/lib/dirname.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* Take file names apart into directory and base names.
|
||||
|
||||
Copyright (C) 1998, 2001, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef DIRNAME_H_
|
||||
# define DIRNAME_H_ 1
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
# ifndef DIRECTORY_SEPARATOR
|
||||
# define DIRECTORY_SEPARATOR '/'
|
||||
# endif
|
||||
|
||||
# ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
|
||||
# endif
|
||||
|
||||
# ifndef FILESYSTEM_PREFIX_LEN
|
||||
# define FILESYSTEM_PREFIX_LEN(Filename) 0
|
||||
# endif
|
||||
|
||||
char *base_name (char const *path);
|
||||
char *dir_name (char const *path);
|
||||
size_t base_len (char const *path);
|
||||
size_t dir_len (char const *path);
|
||||
|
||||
int strip_trailing_slashes (char *path);
|
||||
|
||||
#endif /* not DIRNAME_H_ */
|
310
contrib/diff/lib/error.c
Normal file
310
contrib/diff/lib/error.c
Normal file
@ -0,0 +1,310 @@
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-1998, 2000-2002, 2003 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <libintl.h>
|
||||
#else
|
||||
# include "gettext.h"
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <wchar.h>
|
||||
# define mbsrtowcs __mbsrtowcs
|
||||
#endif
|
||||
|
||||
#if !_LIBC
|
||||
# include "unlocked-io.h"
|
||||
#endif
|
||||
|
||||
#ifndef _
|
||||
# define _(String) String
|
||||
#endif
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
void (*error_print_progname) (void);
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
unsigned int error_message_count;
|
||||
|
||||
#ifdef _LIBC
|
||||
/* In the GNU C library, there is a predefined variable for this. */
|
||||
|
||||
# define program_name program_invocation_name
|
||||
# include <errno.h>
|
||||
# include <libio/libioP.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
|
||||
|
||||
# include <libio/iolibio.h>
|
||||
# define fflush(s) INTUSE(_IO_fflush) (s)
|
||||
# undef putc
|
||||
# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
|
||||
|
||||
# include <bits/libc-lock.h>
|
||||
|
||||
#else /* not _LIBC */
|
||||
|
||||
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||
# ifndef HAVE_DECL_STRERROR_R
|
||||
"this configure-time declaration test was not run"
|
||||
# endif
|
||||
char *strerror_r ();
|
||||
# endif
|
||||
|
||||
# ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
# endif
|
||||
|
||||
/* The calling program should define program_name and set it to the
|
||||
name of the executing program. */
|
||||
extern char *program_name;
|
||||
|
||||
# if HAVE_STRERROR_R || defined strerror_r
|
||||
# define __strerror_r strerror_r
|
||||
# endif
|
||||
#endif /* not _LIBC */
|
||||
|
||||
static void
|
||||
print_errno_message (int errnum)
|
||||
{
|
||||
char const *s;
|
||||
|
||||
#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
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
{
|
||||
__fwprintf (stderr, L": %s", s);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf (stderr, ": %s", s);
|
||||
}
|
||||
|
||||
static void
|
||||
error_tail (int status, int errnum, const char *message, va_list args)
|
||||
{
|
||||
#if _LIBC
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
{
|
||||
# define ALLOCA_LIMIT 2000
|
||||
size_t len = strlen (message) + 1;
|
||||
const wchar_t *wmessage = L"out of memory";
|
||||
wchar_t *wbuf = (len < ALLOCA_LIMIT
|
||||
? alloca (len * sizeof *wbuf)
|
||||
: len <= SIZE_MAX / sizeof *wbuf
|
||||
? malloc (len * sizeof *wbuf)
|
||||
: NULL);
|
||||
|
||||
if (wbuf)
|
||||
{
|
||||
size_t res;
|
||||
mbstate_t st;
|
||||
const char *tmp = message;
|
||||
memset (&st, '\0', sizeof (st));
|
||||
res = mbsrtowcs (wbuf, &tmp, len, &st);
|
||||
wmessage = res == (size_t) -1 ? L"???" : wbuf;
|
||||
}
|
||||
|
||||
__vfwprintf (stderr, wmessage, args);
|
||||
if (! (len < ALLOCA_LIMIT))
|
||||
free (wbuf);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
vfprintf (stderr, message, args);
|
||||
va_end (args);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
print_errno_message (errnum);
|
||||
#if _LIBC
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
putwc (L'\n', stderr);
|
||||
else
|
||||
#endif
|
||||
putc ('\n', stderr);
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
}
|
||||
|
||||
|
||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||
format string with optional args.
|
||||
If ERRNUM is nonzero, print its corresponding system error message.
|
||||
Exit with status STATUS if it is nonzero. */
|
||||
void
|
||||
error (int status, int errnum, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
#if defined _LIBC && defined __libc_ptf_call
|
||||
/* We do not want this call to be cut short by a thread
|
||||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
_IO_flockfile (stderr);
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s: ", program_name);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
}
|
||||
|
||||
va_start (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
|
||||
#ifdef _LIBC
|
||||
_IO_funlockfile (stderr);
|
||||
# ifdef __libc_ptf_call
|
||||
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
int error_one_per_line;
|
||||
|
||||
void
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (error_one_per_line)
|
||||
{
|
||||
static const char *old_file_name;
|
||||
static unsigned int old_line_number;
|
||||
|
||||
if (old_line_number == line_number
|
||||
&& (file_name == old_file_name
|
||||
|| strcmp (old_file_name, file_name) == 0))
|
||||
/* Simply return and print nothing. */
|
||||
return;
|
||||
|
||||
old_file_name = file_name;
|
||||
old_line_number = line_number;
|
||||
}
|
||||
|
||||
#if defined _LIBC && defined __libc_ptf_call
|
||||
/* We do not want this call to be cut short by a thread
|
||||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
_IO_flockfile (stderr);
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s: ", program_name);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "%s:", program_name);
|
||||
}
|
||||
|
||||
if (file_name != NULL)
|
||||
{
|
||||
#if _LIBC
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
__fwprintf (stderr, L"%s:%d: ", file_name, line_number);
|
||||
else
|
||||
#endif
|
||||
fprintf (stderr, "%s:%d: ", file_name, line_number);
|
||||
}
|
||||
|
||||
va_start (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
|
||||
#ifdef _LIBC
|
||||
_IO_funlockfile (stderr);
|
||||
# ifdef __libc_ptf_call
|
||||
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Make the weak alias. */
|
||||
# undef error
|
||||
# undef error_at_line
|
||||
weak_alias (__error, error)
|
||||
weak_alias (__error_at_line, error_at_line)
|
||||
#endif
|
66
contrib/diff/lib/error.h
Normal file
66
contrib/diff/lib/error.h
Normal file
@ -0,0 +1,66 @@
|
||||
/* Declaration for error-reporting function
|
||||
Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _ERROR_H
|
||||
#define _ERROR_H 1
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Print a message with `fprintf (stderr, FORMAT, ...)';
|
||||
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
|
||||
|
||||
extern void error (int __status, int __errnum, const char *__format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
|
||||
extern void error_at_line (int __status, int __errnum, const char *__fname,
|
||||
unsigned int __lineno, const char *__format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
extern void (*error_print_progname) (void);
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
extern unsigned int error_message_count;
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
extern int error_one_per_line;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* error.h */
|
263
contrib/diff/lib/exclude.c
Normal file
263
contrib/diff/lib/exclude.c
Normal file
@ -0,0 +1,263 @@
|
||||
/* exclude.c -- exclude file names
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "exclude.h"
|
||||
#include "fnmatch.h"
|
||||
#include "unlocked-io.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
|
||||
# define IN_CTYPE_DOMAIN(c) true
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii (c)
|
||||
#endif
|
||||
|
||||
static inline bool
|
||||
is_space (unsigned char c)
|
||||
{
|
||||
return IN_CTYPE_DOMAIN (c) && isspace (c);
|
||||
}
|
||||
|
||||
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
|
||||
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
|
||||
|
||||
/* Non-GNU systems lack these options, so we don't need to check them. */
|
||||
#ifndef FNM_CASEFOLD
|
||||
# define FNM_CASEFOLD 0
|
||||
#endif
|
||||
#ifndef FNM_LEADING_DIR
|
||||
# define FNM_LEADING_DIR 0
|
||||
#endif
|
||||
|
||||
verify (EXCLUDE_macros_do_not_collide_with_FNM_macros,
|
||||
(((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | EXCLUDE_WILDCARDS)
|
||||
& (FNM_PATHNAME | FNM_NOESCAPE | FNM_PERIOD | FNM_LEADING_DIR
|
||||
| FNM_CASEFOLD))
|
||||
== 0));
|
||||
|
||||
/* An exclude pattern-options pair. The options are fnmatch options
|
||||
ORed with EXCLUDE_* options. */
|
||||
|
||||
struct patopts
|
||||
{
|
||||
char const *pattern;
|
||||
int options;
|
||||
};
|
||||
|
||||
/* An exclude list, of pattern-options pairs. */
|
||||
|
||||
struct exclude
|
||||
{
|
||||
struct patopts *exclude;
|
||||
size_t exclude_alloc;
|
||||
size_t exclude_count;
|
||||
};
|
||||
|
||||
/* Return a newly allocated and empty exclude list. */
|
||||
|
||||
struct exclude *
|
||||
new_exclude (void)
|
||||
{
|
||||
return xzalloc (sizeof *new_exclude ());
|
||||
}
|
||||
|
||||
/* Free the storage associated with an exclude list. */
|
||||
|
||||
void
|
||||
free_exclude (struct exclude *ex)
|
||||
{
|
||||
free (ex->exclude);
|
||||
free (ex);
|
||||
}
|
||||
|
||||
/* Return zero if PATTERN matches F, obeying OPTIONS, except that
|
||||
(unlike fnmatch) wildcards are disabled in PATTERN. */
|
||||
|
||||
static int
|
||||
fnmatch_no_wildcards (char const *pattern, char const *f, int options)
|
||||
{
|
||||
if (! (options & FNM_LEADING_DIR))
|
||||
return ((options & FNM_CASEFOLD)
|
||||
? strcasecmp (pattern, f)
|
||||
: strcmp (pattern, f));
|
||||
else
|
||||
{
|
||||
size_t patlen = strlen (pattern);
|
||||
int r = ((options & FNM_CASEFOLD)
|
||||
? strncasecmp (pattern, f, patlen)
|
||||
: strncmp (pattern, f, patlen));
|
||||
if (! r)
|
||||
{
|
||||
r = f[patlen];
|
||||
if (r == '/')
|
||||
r = 0;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return true if EX excludes F. */
|
||||
|
||||
bool
|
||||
excluded_filename (struct exclude const *ex, char const *f)
|
||||
{
|
||||
size_t exclude_count = ex->exclude_count;
|
||||
|
||||
/* If no options are given, the default is to include. */
|
||||
if (exclude_count == 0)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
struct patopts const *exclude = ex->exclude;
|
||||
size_t i;
|
||||
|
||||
/* Otherwise, the default is the opposite of the first option. */
|
||||
bool excluded = !! (exclude[0].options & EXCLUDE_INCLUDE);
|
||||
|
||||
/* Scan through the options, seeing whether they change F from
|
||||
excluded to included or vice versa. */
|
||||
for (i = 0; i < exclude_count; i++)
|
||||
{
|
||||
char const *pattern = exclude[i].pattern;
|
||||
int options = exclude[i].options;
|
||||
if (excluded == !! (options & EXCLUDE_INCLUDE))
|
||||
{
|
||||
int (*matcher) (char const *, char const *, int) =
|
||||
(options & EXCLUDE_WILDCARDS
|
||||
? fnmatch
|
||||
: fnmatch_no_wildcards);
|
||||
bool matched = ((*matcher) (pattern, f, options) == 0);
|
||||
char const *p;
|
||||
|
||||
if (! (options & EXCLUDE_ANCHORED))
|
||||
for (p = f; *p && ! matched; p++)
|
||||
if (*p == '/' && p[1] != '/')
|
||||
matched = ((*matcher) (pattern, p + 1, options) == 0);
|
||||
|
||||
excluded ^= matched;
|
||||
}
|
||||
}
|
||||
|
||||
return excluded;
|
||||
}
|
||||
}
|
||||
|
||||
/* Append to EX the exclusion PATTERN with OPTIONS. */
|
||||
|
||||
void
|
||||
add_exclude (struct exclude *ex, char const *pattern, int options)
|
||||
{
|
||||
struct patopts *patopts;
|
||||
|
||||
if (ex->exclude_count == ex->exclude_alloc)
|
||||
ex->exclude = x2nrealloc (ex->exclude, &ex->exclude_alloc,
|
||||
sizeof *ex->exclude);
|
||||
|
||||
patopts = &ex->exclude[ex->exclude_count++];
|
||||
patopts->pattern = pattern;
|
||||
patopts->options = options;
|
||||
}
|
||||
|
||||
/* Use ADD_FUNC to append to EX the patterns in FILENAME, each with
|
||||
OPTIONS. LINE_END terminates each pattern in the file. If
|
||||
LINE_END is a space character, ignore trailing spaces and empty
|
||||
lines in FILE. Return -1 on failure, 0 on success. */
|
||||
|
||||
int
|
||||
add_exclude_file (void (*add_func) (struct exclude *, char const *, int),
|
||||
struct exclude *ex, char const *filename, int options,
|
||||
char line_end)
|
||||
{
|
||||
bool use_stdin = filename[0] == '-' && !filename[1];
|
||||
FILE *in;
|
||||
char *buf = NULL;
|
||||
char *p;
|
||||
char const *pattern;
|
||||
char const *lim;
|
||||
size_t buf_alloc = 0;
|
||||
size_t buf_count = 0;
|
||||
int c;
|
||||
int e = 0;
|
||||
|
||||
if (use_stdin)
|
||||
in = stdin;
|
||||
else if (! (in = fopen (filename, "r")))
|
||||
return -1;
|
||||
|
||||
while ((c = getc (in)) != EOF)
|
||||
{
|
||||
if (buf_count == buf_alloc)
|
||||
buf = x2realloc (buf, &buf_alloc);
|
||||
buf[buf_count++] = c;
|
||||
}
|
||||
|
||||
if (ferror (in))
|
||||
e = errno;
|
||||
|
||||
if (!use_stdin && fclose (in) != 0)
|
||||
e = errno;
|
||||
|
||||
buf = xrealloc (buf, buf_count + 1);
|
||||
buf[buf_count] = line_end;
|
||||
lim = buf + buf_count + ! (buf_count == 0 || buf[buf_count - 1] == line_end);
|
||||
pattern = buf;
|
||||
|
||||
for (p = buf; p < lim; p++)
|
||||
if (*p == line_end)
|
||||
{
|
||||
char *pattern_end = p;
|
||||
|
||||
if (is_space (line_end))
|
||||
{
|
||||
for (; ; pattern_end--)
|
||||
if (pattern_end == pattern)
|
||||
goto next_pattern;
|
||||
else if (! is_space (pattern_end[-1]))
|
||||
break;
|
||||
}
|
||||
|
||||
*pattern_end = '\0';
|
||||
(*add_func) (ex, pattern, options);
|
||||
|
||||
next_pattern:
|
||||
pattern = p + 1;
|
||||
}
|
||||
|
||||
errno = e;
|
||||
return e ? -1 : 0;
|
||||
}
|
43
contrib/diff/lib/exclude.h
Normal file
43
contrib/diff/lib/exclude.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* exclude.h -- declarations for excluding file names
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1997, 1999, 2001, 2002, 2003 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
/* Exclude options, which can be ORed with fnmatch options. */
|
||||
|
||||
/* Patterns must match the start of file names, instead of matching
|
||||
anywhere after a '/'. */
|
||||
#define EXCLUDE_ANCHORED (1 << 30)
|
||||
|
||||
/* Include instead of exclude. */
|
||||
#define EXCLUDE_INCLUDE (1 << 29)
|
||||
|
||||
/* '?', '*', '[', and '\\' are special in patterns. Without this
|
||||
option, these characters are ordinary and fnmatch is not used. */
|
||||
#define EXCLUDE_WILDCARDS (1 << 28)
|
||||
|
||||
struct exclude;
|
||||
|
||||
struct exclude *new_exclude (void);
|
||||
void free_exclude (struct exclude *);
|
||||
void add_exclude (struct exclude *, char const *, int);
|
||||
int add_exclude_file (void (*) (struct exclude *, char const *, int),
|
||||
struct exclude *, char const *, int, char);
|
||||
bool excluded_filename (struct exclude const *, char const *);
|
32
contrib/diff/lib/exit.h
Normal file
32
contrib/diff/lib/exit.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* exit() function.
|
||||
Copyright (C) 1995, 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _EXIT_H
|
||||
#define _EXIT_H
|
||||
|
||||
/* Get exit() declaration. */
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Some systems do not define EXIT_*, even with STDC_HEADERS. */
|
||||
#ifndef EXIT_SUCCESS
|
||||
# define EXIT_SUCCESS 0
|
||||
#endif
|
||||
#ifndef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#endif /* _EXIT_H */
|
27
contrib/diff/lib/exitfail.c
Normal file
27
contrib/diff/lib/exitfail.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "exitfail.h"
|
||||
#include "exit.h"
|
||||
|
||||
int volatile exit_failure = EXIT_FAILURE;
|
20
contrib/diff/lib/exitfail.h
Normal file
20
contrib/diff/lib/exitfail.h
Normal file
@ -0,0 +1,20 @@
|
||||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
extern int volatile exit_failure;
|
75
contrib/diff/lib/file-type.c
Normal file
75
contrib/diff/lib/file-type.c
Normal file
@ -0,0 +1,75 @@
|
||||
/* Return a string describing the type of a file.
|
||||
|
||||
Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "file-type.h"
|
||||
|
||||
#include <gettext.h>
|
||||
#define _(text) gettext (text)
|
||||
|
||||
char const *
|
||||
file_type (struct stat const *st)
|
||||
{
|
||||
/* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107 for some of
|
||||
these formats.
|
||||
|
||||
To keep diagnostics grammatical in English, the returned string
|
||||
must start with a consonant. */
|
||||
|
||||
if (S_ISREG (st->st_mode))
|
||||
return st->st_size == 0 ? _("regular empty file") : _("regular file");
|
||||
|
||||
if (S_ISDIR (st->st_mode))
|
||||
return _("directory");
|
||||
|
||||
if (S_ISBLK (st->st_mode))
|
||||
return _("block special file");
|
||||
|
||||
if (S_ISCHR (st->st_mode))
|
||||
return _("character special file");
|
||||
|
||||
if (S_ISFIFO (st->st_mode))
|
||||
return _("fifo");
|
||||
|
||||
if (S_ISLNK (st->st_mode))
|
||||
return _("symbolic link");
|
||||
|
||||
if (S_ISSOCK (st->st_mode))
|
||||
return _("socket");
|
||||
|
||||
if (S_TYPEISMQ (st))
|
||||
return _("message queue");
|
||||
|
||||
if (S_TYPEISSEM (st))
|
||||
return _("semaphore");
|
||||
|
||||
if (S_TYPEISSHM (st))
|
||||
return _("shared memory object");
|
||||
|
||||
if (S_TYPEISTMO (st))
|
||||
return _("typed memory object");
|
||||
|
||||
return _("weird file");
|
||||
}
|
166
contrib/diff/lib/file-type.h
Normal file
166
contrib/diff/lib/file-type.h
Normal file
@ -0,0 +1,166 @@
|
||||
/* Return a string describing the type of a file.
|
||||
|
||||
Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert and Jim Meyering. */
|
||||
|
||||
#ifndef FILE_TYPE_H
|
||||
# define FILE_TYPE_H 1
|
||||
|
||||
# if ! defined S_ISREG && ! defined S_IFREG
|
||||
you must include <sys/stat.h> before including this file
|
||||
# endif
|
||||
|
||||
char const *file_type (struct stat const *);
|
||||
|
||||
# ifndef S_IFMT
|
||||
# define S_IFMT 0170000
|
||||
# endif
|
||||
|
||||
# if STAT_MACROS_BROKEN
|
||||
# undef S_ISBLK
|
||||
# undef S_ISCHR
|
||||
# undef S_ISDIR
|
||||
# undef S_ISDOOR
|
||||
# undef S_ISFIFO
|
||||
# undef S_ISLNK
|
||||
# undef S_ISNAM
|
||||
# undef S_ISMPB
|
||||
# undef S_ISMPC
|
||||
# undef S_ISNWK
|
||||
# undef S_ISREG
|
||||
# undef S_ISSOCK
|
||||
# endif
|
||||
|
||||
|
||||
# ifndef S_ISBLK
|
||||
# ifdef S_IFBLK
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
# else
|
||||
# define S_ISBLK(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISCHR
|
||||
# ifdef S_IFCHR
|
||||
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
# else
|
||||
# define S_ISCHR(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISDIR
|
||||
# ifdef S_IFDIR
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
# else
|
||||
# define S_ISDIR(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISDOOR /* Solaris 2.5 and up */
|
||||
# ifdef S_IFDOOR
|
||||
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
|
||||
# else
|
||||
# define S_ISDOOR(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISFIFO
|
||||
# ifdef S_IFIFO
|
||||
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
# else
|
||||
# define S_ISFIFO(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISLNK
|
||||
# ifdef S_IFLNK
|
||||
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
# else
|
||||
# define S_ISLNK(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISMPB /* V7 */
|
||||
# ifdef S_IFMPB
|
||||
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
|
||||
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
|
||||
# else
|
||||
# define S_ISMPB(m) 0
|
||||
# define S_ISMPC(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISNAM /* Xenix */
|
||||
# ifdef S_IFNAM
|
||||
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
|
||||
# else
|
||||
# define S_ISNAM(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISNWK /* HP/UX */
|
||||
# ifdef S_IFNWK
|
||||
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
|
||||
# else
|
||||
# define S_ISNWK(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISREG
|
||||
# ifdef S_IFREG
|
||||
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
# else
|
||||
# define S_ISREG(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_ISSOCK
|
||||
# ifdef S_IFSOCK
|
||||
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
# else
|
||||
# define S_ISSOCK(m) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
||||
# ifndef S_TYPEISMQ
|
||||
# define S_TYPEISMQ(p) 0
|
||||
# endif
|
||||
|
||||
# ifndef S_TYPEISTMO
|
||||
# define S_TYPEISTMO(p) 0
|
||||
# endif
|
||||
|
||||
|
||||
# ifndef S_TYPEISSEM
|
||||
# ifdef S_INSEM
|
||||
# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
|
||||
# else
|
||||
# define S_TYPEISSEM(p) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef S_TYPEISSHM
|
||||
# ifdef S_INSHD
|
||||
# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
|
||||
# else
|
||||
# define S_TYPEISSHM(p) 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif /* FILE_TYPE_H */
|
403
contrib/diff/lib/fnmatch.c
Normal file
403
contrib/diff/lib/fnmatch.c
Normal file
@ -0,0 +1,403 @@
|
||||
/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Enable GNU extensions in fnmatch.h. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define alloca __builtin_alloca
|
||||
# define HAVE_ALLOCA 1
|
||||
#else
|
||||
# if defined HAVE_ALLOCA_H || defined _LIBC
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifdef _AIX
|
||||
# pragma alloca
|
||||
# else
|
||||
# ifndef alloca
|
||||
char *alloca ();
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ! defined __builtin_expect && __GNUC__ < 3
|
||||
# define __builtin_expect(expr, expected) (expr)
|
||||
#endif
|
||||
|
||||
#include <fnmatch.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define WIDE_CHAR_SUPPORT (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC)
|
||||
|
||||
/* For platform which support the ISO C amendement 1 functionality we
|
||||
support user defined character classes. */
|
||||
#if defined _LIBC || WIDE_CHAR_SUPPORT
|
||||
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
|
||||
# include <wchar.h>
|
||||
# include <wctype.h>
|
||||
#endif
|
||||
|
||||
/* We need some of the locale data (the collation sequence information)
|
||||
but there is no interface to get this information in general. Therefore
|
||||
we support a correct implementation only in glibc. */
|
||||
#ifdef _LIBC
|
||||
# include "../locale/localeinfo.h"
|
||||
# include "../locale/elem-hash.h"
|
||||
# include "../locale/coll-lookup.h"
|
||||
# include <shlib-compat.h>
|
||||
|
||||
# define CONCAT(a,b) __CONCAT(a,b)
|
||||
# define mbsrtowcs __mbsrtowcs
|
||||
# define fnmatch __fnmatch
|
||||
extern int fnmatch (const char *pattern, const char *string, int flags);
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */
|
||||
#define NO_LEADING_PERIOD(flags) \
|
||||
((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself, and have not detected a bug
|
||||
in the library. 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__ || !HAVE_FNMATCH_GNU
|
||||
|
||||
|
||||
# if defined STDC_HEADERS || !defined isascii
|
||||
# define ISASCII(c) 1
|
||||
# else
|
||||
# define ISASCII(c) isascii(c)
|
||||
# endif
|
||||
|
||||
# ifdef isblank
|
||||
# define ISBLANK(c) (ISASCII (c) && isblank (c))
|
||||
# else
|
||||
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
|
||||
# endif
|
||||
# ifdef isgraph
|
||||
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
|
||||
# else
|
||||
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
|
||||
# endif
|
||||
|
||||
# define ISPRINT(c) (ISASCII (c) && isprint (c))
|
||||
# define ISDIGIT(c) (ISASCII (c) && isdigit (c))
|
||||
# define ISALNUM(c) (ISASCII (c) && isalnum (c))
|
||||
# define ISALPHA(c) (ISASCII (c) && isalpha (c))
|
||||
# define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
|
||||
# define ISLOWER(c) (ISASCII (c) && islower (c))
|
||||
# define ISPUNCT(c) (ISASCII (c) && ispunct (c))
|
||||
# define ISSPACE(c) (ISASCII (c) && isspace (c))
|
||||
# define ISUPPER(c) (ISASCII (c) && isupper (c))
|
||||
# define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
|
||||
|
||||
# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
|
||||
|
||||
# if defined _LIBC || WIDE_CHAR_SUPPORT
|
||||
/* The GNU C library provides support for user-defined character classes
|
||||
and the functions from ISO C amendement 1. */
|
||||
# ifdef CHARCLASS_NAME_MAX
|
||||
# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
|
||||
# else
|
||||
/* This shouldn't happen but some implementation might still have this
|
||||
problem. Use a reasonable default value. */
|
||||
# define CHAR_CLASS_MAX_LENGTH 256
|
||||
# endif
|
||||
|
||||
# ifdef _LIBC
|
||||
# define IS_CHAR_CLASS(string) __wctype (string)
|
||||
# else
|
||||
# define IS_CHAR_CLASS(string) wctype (string)
|
||||
# endif
|
||||
|
||||
# ifdef _LIBC
|
||||
# define ISWCTYPE(WC, WT) __iswctype (WC, WT)
|
||||
# else
|
||||
# define ISWCTYPE(WC, WT) iswctype (WC, WT)
|
||||
# endif
|
||||
|
||||
# if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
|
||||
/* In this case we are implementing the multibyte character handling. */
|
||||
# define HANDLE_MULTIBYTE 1
|
||||
# endif
|
||||
|
||||
# else
|
||||
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
|
||||
|
||||
# define IS_CHAR_CLASS(string) \
|
||||
(STREQ (string, "alpha") || STREQ (string, "upper") \
|
||||
|| STREQ (string, "lower") || STREQ (string, "digit") \
|
||||
|| STREQ (string, "alnum") || STREQ (string, "xdigit") \
|
||||
|| STREQ (string, "space") || STREQ (string, "print") \
|
||||
|| STREQ (string, "punct") || STREQ (string, "graph") \
|
||||
|| STREQ (string, "cntrl") || STREQ (string, "blank"))
|
||||
# endif
|
||||
|
||||
/* Avoid depending on library functions or files
|
||||
whose names are inconsistent. */
|
||||
|
||||
# ifndef errno
|
||||
extern int errno;
|
||||
# endif
|
||||
|
||||
/* Global variable. */
|
||||
static int posixly_correct;
|
||||
|
||||
# ifndef internal_function
|
||||
/* Inside GNU libc we mark some function in a special way. In other
|
||||
environments simply ignore the marking. */
|
||||
# define internal_function
|
||||
# endif
|
||||
|
||||
/* Note that this evaluates C many times. */
|
||||
# ifdef _LIBC
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
|
||||
# else
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
|
||||
# endif
|
||||
# define CHAR char
|
||||
# define UCHAR unsigned char
|
||||
# define INT int
|
||||
# define FCT internal_fnmatch
|
||||
# define EXT ext_match
|
||||
# define END end_pattern
|
||||
# define L(CS) CS
|
||||
# ifdef _LIBC
|
||||
# define BTOWC(C) __btowc (C)
|
||||
# else
|
||||
# define BTOWC(C) btowc (C)
|
||||
# endif
|
||||
# define STRLEN(S) strlen (S)
|
||||
# define STRCAT(D, S) strcat (D, S)
|
||||
# ifdef _LIBC
|
||||
# define MEMPCPY(D, S, N) __mempcpy (D, S, N)
|
||||
# else
|
||||
# if HAVE_MEMPCPY
|
||||
# define MEMPCPY(D, S, N) mempcpy (D, S, N)
|
||||
# else
|
||||
# define MEMPCPY(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
|
||||
# endif
|
||||
# endif
|
||||
# define MEMCHR(S, C, N) memchr (S, C, N)
|
||||
# define STRCOLL(S1, S2) strcoll (S1, S2)
|
||||
# include "fnmatch_loop.c"
|
||||
|
||||
|
||||
# if HANDLE_MULTIBYTE
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
|
||||
# define CHAR wchar_t
|
||||
# define UCHAR wint_t
|
||||
# define INT wint_t
|
||||
# define FCT internal_fnwmatch
|
||||
# define EXT ext_wmatch
|
||||
# define END end_wpattern
|
||||
# define L(CS) L##CS
|
||||
# define BTOWC(C) (C)
|
||||
# ifdef _LIBC
|
||||
# define STRLEN(S) __wcslen (S)
|
||||
# define STRCAT(D, S) __wcscat (D, S)
|
||||
# define MEMPCPY(D, S, N) __wmempcpy (D, S, N)
|
||||
# else
|
||||
# define STRLEN(S) wcslen (S)
|
||||
# define STRCAT(D, S) wcscat (D, S)
|
||||
# if HAVE_WMEMPCPY
|
||||
# define MEMPCPY(D, S, N) wmempcpy (D, S, N)
|
||||
# else
|
||||
# define MEMPCPY(D, S, N) (wmemcpy (D, S, N) + (N))
|
||||
# endif
|
||||
# endif
|
||||
# define MEMCHR(S, C, N) wmemchr (S, C, N)
|
||||
# define STRCOLL(S1, S2) wcscoll (S1, S2)
|
||||
# define WIDE_CHAR_VERSION 1
|
||||
|
||||
# undef IS_CHAR_CLASS
|
||||
/* We have to convert the wide character string in a multibyte string. But
|
||||
we know that the character class names consist of alphanumeric characters
|
||||
from the portable character set, and since the wide character encoding
|
||||
for a member of the portable character set is the same code point as
|
||||
its single-byte encoding, we can use a simplified method to convert the
|
||||
string to a multibyte character string. */
|
||||
static wctype_t
|
||||
is_char_class (const wchar_t *wcs)
|
||||
{
|
||||
char s[CHAR_CLASS_MAX_LENGTH + 1];
|
||||
char *cp = s;
|
||||
|
||||
do
|
||||
{
|
||||
/* Test for a printable character from the portable character set. */
|
||||
# ifdef _LIBC
|
||||
if (*wcs < 0x20 || *wcs > 0x7e
|
||||
|| *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
|
||||
return (wctype_t) 0;
|
||||
# else
|
||||
switch (*wcs)
|
||||
{
|
||||
case L' ': case L'!': case L'"': case L'#': case L'%':
|
||||
case L'&': case L'\'': case L'(': case L')': case L'*':
|
||||
case L'+': case L',': case L'-': case L'.': case L'/':
|
||||
case L'0': case L'1': case L'2': case L'3': case L'4':
|
||||
case L'5': case L'6': case L'7': case L'8': case L'9':
|
||||
case L':': case L';': case L'<': case L'=': case L'>':
|
||||
case L'?':
|
||||
case L'A': case L'B': case L'C': case L'D': case L'E':
|
||||
case L'F': case L'G': case L'H': case L'I': case L'J':
|
||||
case L'K': case L'L': case L'M': case L'N': case L'O':
|
||||
case L'P': case L'Q': case L'R': case L'S': case L'T':
|
||||
case L'U': case L'V': case L'W': case L'X': case L'Y':
|
||||
case L'Z':
|
||||
case L'[': case L'\\': case L']': case L'^': case L'_':
|
||||
case L'a': case L'b': case L'c': case L'd': case L'e':
|
||||
case L'f': case L'g': case L'h': case L'i': case L'j':
|
||||
case L'k': case L'l': case L'm': case L'n': case L'o':
|
||||
case L'p': case L'q': case L'r': case L's': case L't':
|
||||
case L'u': case L'v': case L'w': case L'x': case L'y':
|
||||
case L'z': case L'{': case L'|': case L'}': case L'~':
|
||||
break;
|
||||
default:
|
||||
return (wctype_t) 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Avoid overrunning the buffer. */
|
||||
if (cp == s + CHAR_CLASS_MAX_LENGTH)
|
||||
return (wctype_t) 0;
|
||||
|
||||
*cp++ = (char) *wcs++;
|
||||
}
|
||||
while (*wcs != L'\0');
|
||||
|
||||
*cp = '\0';
|
||||
|
||||
# ifdef _LIBC
|
||||
return __wctype (s);
|
||||
# else
|
||||
return wctype (s);
|
||||
# endif
|
||||
}
|
||||
# define IS_CHAR_CLASS(string) is_char_class (string)
|
||||
|
||||
# include "fnmatch_loop.c"
|
||||
# endif
|
||||
|
||||
|
||||
int
|
||||
fnmatch (const char *pattern, const char *string, int flags)
|
||||
{
|
||||
# if HANDLE_MULTIBYTE
|
||||
# define ALLOCA_LIMIT 2000
|
||||
if (__builtin_expect (MB_CUR_MAX, 1) != 1)
|
||||
{
|
||||
mbstate_t ps;
|
||||
size_t patsize;
|
||||
size_t strsize;
|
||||
size_t totsize;
|
||||
wchar_t *wpattern;
|
||||
wchar_t *wstring;
|
||||
int res;
|
||||
|
||||
/* Calculate the size needed to convert the strings to
|
||||
wide characters. */
|
||||
memset (&ps, '\0', sizeof (ps));
|
||||
patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1;
|
||||
if (__builtin_expect (patsize == 0, 0))
|
||||
/* Something wrong.
|
||||
XXX Do we have to set `errno' to something which mbsrtows hasn't
|
||||
already done? */
|
||||
return -1;
|
||||
assert (mbsinit (&ps));
|
||||
strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
|
||||
if (__builtin_expect (strsize == 0, 0))
|
||||
/* Something wrong.
|
||||
XXX Do we have to set `errno' to something which mbsrtows hasn't
|
||||
already done? */
|
||||
return -1;
|
||||
assert (mbsinit (&ps));
|
||||
totsize = patsize + strsize;
|
||||
if (__builtin_expect (! (patsize <= totsize
|
||||
&& totsize <= SIZE_MAX / sizeof (wchar_t)),
|
||||
0))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Allocate room for the wide characters. */
|
||||
if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
|
||||
wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
|
||||
else
|
||||
{
|
||||
wpattern = malloc (totsize * sizeof (wchar_t));
|
||||
if (__builtin_expect (! wpattern, 0))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
wstring = wpattern + patsize;
|
||||
|
||||
/* Convert the strings into wide characters. */
|
||||
mbsrtowcs (wpattern, &pattern, patsize, &ps);
|
||||
assert (mbsinit (&ps));
|
||||
mbsrtowcs (wstring, &string, strsize, &ps);
|
||||
|
||||
res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
|
||||
flags & FNM_PERIOD, flags);
|
||||
|
||||
if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
|
||||
free (wpattern);
|
||||
return res;
|
||||
}
|
||||
# endif /* HANDLE_MULTIBYTE */
|
||||
|
||||
return internal_fnmatch (pattern, string, string + strlen (string),
|
||||
flags & FNM_PERIOD, flags);
|
||||
}
|
||||
|
||||
# ifdef _LIBC
|
||||
# undef fnmatch
|
||||
versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3);
|
||||
# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3)
|
||||
strong_alias (__fnmatch, __fnmatch_old)
|
||||
compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
|
||||
# endif
|
||||
libc_hidden_ver (__fnmatch, fnmatch)
|
||||
# endif
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
63
contrib/diff/lib/fnmatch_.h
Normal file
63
contrib/diff/lib/fnmatch_.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _FNMATCH_H
|
||||
# define _FNMATCH_H 1
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* We #undef these before defining them because some losing systems
|
||||
(HP-UX A.08.07 for example) define these in <unistd.h>. */
|
||||
# undef FNM_PATHNAME
|
||||
# undef FNM_NOESCAPE
|
||||
# undef FNM_PERIOD
|
||||
|
||||
/* Bits set in the FLAGS argument to `fnmatch'. */
|
||||
# define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
|
||||
# define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
|
||||
# define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
|
||||
|
||||
# if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
|
||||
# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
|
||||
# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
|
||||
# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
|
||||
# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
|
||||
# endif
|
||||
|
||||
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
|
||||
# define FNM_NOMATCH 1
|
||||
|
||||
/* This value is returned if the implementation does not support
|
||||
`fnmatch'. Since this is not the case here it will never be
|
||||
returned but the conformance test suites still require the symbol
|
||||
to be defined. */
|
||||
# ifdef _XOPEN_SOURCE
|
||||
# define FNM_NOSYS (-1)
|
||||
# endif
|
||||
|
||||
/* Match NAME against the filename pattern PATTERN,
|
||||
returning zero if it matches, FNM_NOMATCH if not. */
|
||||
extern int fnmatch (const char *__pattern, const char *__name,
|
||||
int __flags);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* fnmatch.h */
|
1192
contrib/diff/lib/fnmatch_loop.c
Normal file
1192
contrib/diff/lib/fnmatch_loop.c
Normal file
File diff suppressed because it is too large
Load Diff
1254
contrib/diff/lib/getopt.c
Normal file
1254
contrib/diff/lib/getopt.c
Normal file
File diff suppressed because it is too large
Load Diff
176
contrib/diff/lib/getopt.h
Normal file
176
contrib/diff/lib/getopt.h
Normal file
@ -0,0 +1,176 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
|
||||
#ifndef __need_getopt
|
||||
# define _GETOPT_H 1
|
||||
#endif
|
||||
|
||||
/* If __GNU_LIBRARY__ is not already defined, either we are being used
|
||||
standalone, or this is the first header included in the source file.
|
||||
If we are being used with glibc, we need to include <features.h>, but
|
||||
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
||||
not defined, include <ctype.h>, which will pull in <features.h> for us
|
||||
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
||||
doesn't flood the namespace with stuff the way some other headers do.) */
|
||||
#if !defined __GNU_LIBRARY__
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifndef __THROW
|
||||
# ifndef __GNUC_PREREQ
|
||||
# define __GNUC_PREREQ(maj, min) (0)
|
||||
# endif
|
||||
# if defined __cplusplus && __GNUC_PREREQ (2,8)
|
||||
# define __THROW throw ()
|
||||
# else
|
||||
# define __THROW
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
#ifndef __need_getopt
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
const char *name;
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#endif /* need getopt */
|
||||
|
||||
|
||||
/* Get definitions and prototypes for functions to process the
|
||||
arguments in ARGV (ARGC of them, minus the program name) for
|
||||
options given in OPTS.
|
||||
|
||||
Return the option character from OPTS just read. Return -1 when
|
||||
there are no more options. For unrecognized options, or options
|
||||
missing arguments, `optopt' is set to the option letter, and '?' is
|
||||
returned.
|
||||
|
||||
The OPTS string is a list of characters which are recognized option
|
||||
letters, optionally followed by colons, specifying that that letter
|
||||
takes an argument, to be placed in `optarg'.
|
||||
|
||||
If a letter in OPTS is followed by two colons, its argument is
|
||||
optional. This behavior is specific to the GNU `getopt'.
|
||||
|
||||
The argument `--' causes premature termination of argument
|
||||
scanning, explicitly telling `getopt' that there are no more
|
||||
options.
|
||||
|
||||
If OPTS begins with `--', then non-option arguments are treated as
|
||||
arguments to the option '\0'. This behavior is specific to the GNU
|
||||
`getopt'. */
|
||||
|
||||
#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)
|
||||
__THROW;
|
||||
#else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt ();
|
||||
#endif /* __GNU_LIBRARY__ */
|
||||
|
||||
#ifndef __need_getopt
|
||||
extern int getopt_long (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
extern int getopt_long_only (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we later can get all the definitions and declarations. */
|
||||
#undef __need_getopt
|
||||
|
||||
#endif /* getopt.h */
|
191
contrib/diff/lib/getopt1.c
Normal file
191
contrib/diff/lib/getopt1.c
Normal file
@ -0,0 +1,191 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <getopt.h>
|
||||
#else
|
||||
# include "getopt.h"
|
||||
#endif
|
||||
#include "getopt_int.h"
|
||||
|
||||
#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. */
|
||||
|
||||
#define GETOPT_INTERFACE_VERSION 2
|
||||
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (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);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_r (int argc, char *const *argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
{
|
||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||
0, d);
|
||||
}
|
||||
|
||||
/* 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 (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);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_only_r (int argc, char *const *argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
{
|
||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||
1, d);
|
||||
}
|
||||
|
||||
#endif /* Not ELIDE_CODE. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
129
contrib/diff/lib/getopt_int.h
Normal file
129
contrib/diff/lib/getopt_int.h
Normal file
@ -0,0 +1,129 @@
|
||||
/* Internal declarations for getopt.
|
||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _GETOPT_INT_H
|
||||
#define _GETOPT_INT_H 1
|
||||
|
||||
extern int _getopt_internal (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only);
|
||||
|
||||
|
||||
/* Reentrant versions which can handle parsing multiple argument
|
||||
vectors at the same time. */
|
||||
|
||||
/* Data type for reentrant functions. */
|
||||
struct _getopt_data
|
||||
{
|
||||
/* These have exactly the same meaning as the corresponding global
|
||||
variables, except that they are used for the reentrant
|
||||
versions of getopt. */
|
||||
int optind;
|
||||
int opterr;
|
||||
int optopt;
|
||||
char *optarg;
|
||||
|
||||
/* Internal members. */
|
||||
|
||||
/* True if the internal members have been initialized. */
|
||||
int __initialized;
|
||||
|
||||
/* The next char to be scanned in the option-element
|
||||
in which the last option character we returned was found.
|
||||
This allows us to pick up the scan where we left off.
|
||||
|
||||
If this is zero, or a null string, it means resume the scan
|
||||
by advancing to the next ARGV-element. */
|
||||
char *__nextchar;
|
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
This is what Unix does.
|
||||
This mode of operation is selected by either setting the environment
|
||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
||||
of the list of option characters.
|
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we
|
||||
scan, so that eventually all the non-options are at the end.
|
||||
This allows options to be given in any order, even with programs
|
||||
that were not written to expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were
|
||||
written to expect options and other ARGV-elements in any order
|
||||
and that care about the ordering of the two. We describe each
|
||||
non-option ARGV-element as if it were the argument of an option
|
||||
with character code 1. Using `-' as the first character of the
|
||||
list of option characters selects this mode of operation.
|
||||
|
||||
The special argument `--' forces an end of option-scanning regardless
|
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
||||
|
||||
enum
|
||||
{
|
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||
} __ordering;
|
||||
|
||||
/* If the POSIXLY_CORRECT environment variable is set. */
|
||||
int __posixly_correct;
|
||||
|
||||
|
||||
/* 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. */
|
||||
|
||||
int __first_nonopt;
|
||||
int __last_nonopt;
|
||||
|
||||
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||
int __nonoption_flags_max_len;
|
||||
int __nonoption_flags_len;
|
||||
# endif
|
||||
};
|
||||
|
||||
/* The initializer is necessary to set OPTIND and OPTERR to their
|
||||
default values and to clear the initialization flag. */
|
||||
#define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
||||
|
||||
extern int _getopt_internal_r (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, struct _getopt_data *__data);
|
||||
|
||||
extern int _getopt_long_r (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
extern int _getopt_long_only_r (int ___argc, char *const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts,
|
||||
int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
#endif /* getopt_int.h */
|
68
contrib/diff/lib/gettext.h
Normal file
68
contrib/diff/lib/gettext.h
Normal file
@ -0,0 +1,68 @@
|
||||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
|
||||
/* NLS can be disabled through the configure --disable-nls option. */
|
||||
#if ENABLE_NLS
|
||||
|
||||
/* Get declarations of GNU message catalog functions. */
|
||||
# include <libintl.h>
|
||||
|
||||
#else
|
||||
|
||||
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
|
||||
chokes if dcgettext is defined as a macro. So include it now, to make
|
||||
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
|
||||
as well because people using "gettext.h" will not include <libintl.h>,
|
||||
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
|
||||
is OK. */
|
||||
#if defined(__sun)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
|
||||
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
|
||||
|
||||
#endif
|
||||
|
||||
/* A pseudo function call that serves as a marker for the automated
|
||||
extraction of messages, but does not call gettext(). The run-time
|
||||
translation is done at a different place in the code.
|
||||
The argument, String, should be a literal string. Concatenated strings
|
||||
and other string expressions won't work.
|
||||
The macro's expansion is not parenthesized, so that it is suitable as
|
||||
initializer for static 'char[]' or 'const char[]' variables. */
|
||||
#define gettext_noop(String) String
|
||||
|
||||
#endif /* _LIBGETTEXT_H */
|
121
contrib/diff/lib/gettimeofday.c
Normal file
121
contrib/diff/lib/gettimeofday.c
Normal file
@ -0,0 +1,121 @@
|
||||
/* Work around the bug in some systems whereby gettimeofday clobbers the
|
||||
static buffer that localtime uses for it's return value. The gettimeofday
|
||||
function from Mac OS X 10.0.4, i.e. Darwin 1.3.7 has this problem.
|
||||
The tzset replacement is necessary for at least Solaris 2.5, 2.5.1, and 2.6.
|
||||
Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Disable the definitions of these functions (from config.h)
|
||||
so we can use the library versions here. */
|
||||
#undef gettimeofday
|
||||
#undef gmtime
|
||||
#undef localtime
|
||||
#undef tzset
|
||||
|
||||
#include <sys/types.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
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static struct tm *localtime_buffer_addr;
|
||||
|
||||
/* This is a wrapper for localtime. It is used only on systems for which
|
||||
gettimeofday clobbers the static buffer used for localtime's result.
|
||||
|
||||
On the first call, record the address of the static buffer that
|
||||
localtime uses for its result. */
|
||||
|
||||
struct tm *
|
||||
rpl_localtime (const time_t *timep)
|
||||
{
|
||||
struct tm *tm = localtime (timep);
|
||||
|
||||
if (! localtime_buffer_addr)
|
||||
localtime_buffer_addr = tm;
|
||||
|
||||
return tm;
|
||||
}
|
||||
|
||||
/* Same as above, since gmtime and localtime use the same buffer. */
|
||||
struct tm *
|
||||
rpl_gmtime (const time_t *timep)
|
||||
{
|
||||
struct tm *tm = gmtime (timep);
|
||||
|
||||
if (! localtime_buffer_addr)
|
||||
localtime_buffer_addr = tm;
|
||||
|
||||
return tm;
|
||||
}
|
||||
|
||||
/* This is a wrapper for gettimeofday. It is used only on systems for which
|
||||
gettimeofday clobbers the static buffer used for localtime's result.
|
||||
|
||||
Save and restore the contents of the buffer used for localtime's result
|
||||
around the call to gettimeofday. */
|
||||
|
||||
int
|
||||
rpl_gettimeofday (struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
struct tm save;
|
||||
int result;
|
||||
|
||||
if (! localtime_buffer_addr)
|
||||
{
|
||||
time_t t = 0;
|
||||
localtime_buffer_addr = localtime (&t);
|
||||
}
|
||||
|
||||
save = *localtime_buffer_addr;
|
||||
result = gettimeofday (tv, tz);
|
||||
*localtime_buffer_addr = save;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* This is a wrapper for tzset. It is used only on systems for which
|
||||
tzset may clobber the static buffer used for localtime's result.
|
||||
Save and restore the contents of the buffer used for localtime's
|
||||
result around the call to tzset. */
|
||||
void
|
||||
rpl_tzset (void)
|
||||
{
|
||||
struct tm save;
|
||||
|
||||
if (! localtime_buffer_addr)
|
||||
{
|
||||
time_t t = 0;
|
||||
localtime_buffer_addr = localtime (&t);
|
||||
}
|
||||
|
||||
save = *localtime_buffer_addr;
|
||||
tzset ();
|
||||
*localtime_buffer_addr = save;
|
||||
}
|
90
contrib/diff/lib/gnulib.mk
Normal file
90
contrib/diff/lib/gnulib.mk
Normal file
@ -0,0 +1,90 @@
|
||||
# This file is generated automatically by "bootstrap".
|
||||
BUILT_SOURCES += $(ALLOCA_H)
|
||||
EXTRA_DIST += alloca_.h
|
||||
|
||||
# We need the following in order to create an <alloca.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
all-local $(lib_OBJECTS): $(ALLOCA_H)
|
||||
alloca.h: alloca_.h
|
||||
cp $(srcdir)/alloca_.h $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += alloca.h alloca.h-t
|
||||
|
||||
lib_SOURCES += c-stack.h c-stack.c
|
||||
|
||||
lib_SOURCES += dirname.h dirname.c basename.c stripslash.c
|
||||
|
||||
|
||||
lib_SOURCES += exclude.h exclude.c
|
||||
|
||||
lib_SOURCES += exit.h
|
||||
|
||||
lib_SOURCES += exitfail.h exitfail.c
|
||||
|
||||
|
||||
lib_SOURCES += file-type.h file-type.c
|
||||
|
||||
BUILT_SOURCES += $(FNMATCH_H)
|
||||
EXTRA_DIST += fnmatch_.h fnmatch_loop.c
|
||||
|
||||
# We need the following in order to create an <fnmatch.h> when the system
|
||||
# doesn't have one that supports the required API.
|
||||
all-local $(lib_OBJECTS): $(FNMATCH_H)
|
||||
fnmatch.h: fnmatch_.h
|
||||
cp $(srcdir)/fnmatch_.h $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
|
||||
|
||||
|
||||
lib_SOURCES += getopt.h getopt.c getopt1.c getopt_int.h
|
||||
|
||||
lib_SOURCES += gettext.h
|
||||
|
||||
|
||||
lib_SOURCES += hard-locale.h hard-locale.c
|
||||
|
||||
EXTRA_DIST += inttostr.c
|
||||
lib_SOURCES += imaxtostr.c inttostr.h offtostr.c umaxtostr.c
|
||||
|
||||
|
||||
|
||||
lib_SOURCES += posixver.h posixver.c
|
||||
|
||||
|
||||
lib_SOURCES += regex.h
|
||||
|
||||
|
||||
BUILT_SOURCES += $(STDBOOL_H)
|
||||
EXTRA_DIST += stdbool_.h
|
||||
|
||||
# We need the following in order to create an <stdbool.h> when the system
|
||||
# doesn't have one that works.
|
||||
all-local $(lib_OBJECTS): $(STDBOOL_H)
|
||||
stdbool.h: stdbool_.h
|
||||
sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += stdbool.h stdbool.h-t
|
||||
|
||||
lib_SOURCES += strcase.h
|
||||
|
||||
lib_SOURCES += strftime.c
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
lib_SOURCES += time_r.h
|
||||
|
||||
|
||||
lib_SOURCES += unlocked-io.h
|
||||
|
||||
lib_SOURCES += version-etc.h version-etc.c
|
||||
|
||||
lib_SOURCES += xalloc.h xmalloc.c xstrdup.c
|
||||
|
||||
lib_SOURCES += xstrtol.h xstrtol.c xstrtoul.c
|
||||
|
||||
lib_SOURCES += xstrtoumax.c
|
||||
|
74
contrib/diff/lib/hard-locale.c
Normal file
74
contrib/diff/lib/hard-locale.c
Normal file
@ -0,0 +1,74 @@
|
||||
/* hard-locale.c -- Determine whether a locale is hard.
|
||||
|
||||
Copyright (C) 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; 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 "hard-locale.h"
|
||||
|
||||
#if HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Return nonzero if the current CATEGORY locale is hard, i.e. if you
|
||||
can't get away with assuming traditional C or POSIX behavior. */
|
||||
int
|
||||
hard_locale (int category)
|
||||
{
|
||||
#if ! HAVE_SETLOCALE
|
||||
return 0;
|
||||
#else
|
||||
|
||||
int hard = 1;
|
||||
char const *p = setlocale (category, 0);
|
||||
|
||||
if (p)
|
||||
{
|
||||
# if defined __GLIBC__ && 2 <= __GLIBC__
|
||||
if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
|
||||
hard = 0;
|
||||
# else
|
||||
char *locale = malloc (strlen (p) + 1);
|
||||
if (locale)
|
||||
{
|
||||
strcpy (locale, p);
|
||||
|
||||
/* Temporarily set the locale to the "C" and "POSIX" locales
|
||||
to find their names, so that we can determine whether one
|
||||
or the other is the caller's locale. */
|
||||
if (((p = setlocale (category, "C"))
|
||||
&& strcmp (p, locale) == 0)
|
||||
|| ((p = setlocale (category, "POSIX"))
|
||||
&& strcmp (p, locale) == 0))
|
||||
hard = 0;
|
||||
|
||||
/* Restore the caller's locale. */
|
||||
setlocale (category, locale);
|
||||
free (locale);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
return hard;
|
||||
|
||||
#endif
|
||||
}
|
24
contrib/diff/lib/hard-locale.h
Normal file
24
contrib/diff/lib/hard-locale.h
Normal file
@ -0,0 +1,24 @@
|
||||
/* Determine whether a locale is hard.
|
||||
|
||||
Copyright (C) 1999, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef HARD_LOCALE_H_
|
||||
# define HARD_LOCALE_H_ 1
|
||||
|
||||
int hard_locale (int);
|
||||
|
||||
#endif /* HARD_LOCALE_H_ */
|
3
contrib/diff/lib/imaxtostr.c
Normal file
3
contrib/diff/lib/imaxtostr.c
Normal file
@ -0,0 +1,3 @@
|
||||
#define inttostr imaxtostr
|
||||
#define inttype intmax_t
|
||||
#include "inttostr.c"
|
49
contrib/diff/lib/inttostr.c
Normal file
49
contrib/diff/lib/inttostr.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* inttostr.c -- convert integers to printable strings
|
||||
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert */
|
||||
|
||||
#include "inttostr.h"
|
||||
|
||||
/* Convert I to a printable string in BUF, which must be at least
|
||||
INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the
|
||||
printable string, which need not start at BUF. */
|
||||
|
||||
char *
|
||||
inttostr (inttype i, char *buf)
|
||||
{
|
||||
char *p = buf + INT_STRLEN_BOUND (inttype);
|
||||
*p = 0;
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
do
|
||||
*--p = '0' - i % 10;
|
||||
while ((i /= 10) != 0);
|
||||
|
||||
*--p = '-';
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
*--p = '0' + i % 10;
|
||||
while ((i /= 10) != 0);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
47
contrib/diff/lib/inttostr.h
Normal file
47
contrib/diff/lib/inttostr.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* inttostr.h -- convert integers to printable strings
|
||||
|
||||
Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* Upper bound on the string length of an integer converted to string.
|
||||
302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
|
||||
add 1 for integer division truncation; add 1 more for a minus sign. */
|
||||
#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
|
||||
|
||||
#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
|
||||
|
||||
char *offtostr (off_t, char *);
|
||||
char *imaxtostr (intmax_t, char *);
|
||||
char *umaxtostr (uintmax_t, char *);
|
36
contrib/diff/lib/malloc.c
Normal file
36
contrib/diff/lib/malloc.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* Work around bug on some systems where malloc (0) fails.
|
||||
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#undef malloc
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Allocate an N-byte block of memory from the heap.
|
||||
If N is zero, allocate a 1-byte block. */
|
||||
|
||||
void *
|
||||
rpl_malloc (size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
return malloc (n);
|
||||
}
|
42
contrib/diff/lib/mkstemp.c
Normal file
42
contrib/diff/lib/mkstemp.c
Normal file
@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
|
||||
This file is derived from the one in the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Disable the definition of mkstemp to rpl_mkstemp (from config.h) in this
|
||||
file. Otherwise, we'd get conflicting prototypes for rpl_mkstemp on
|
||||
most systems. */
|
||||
#undef mkstemp
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef __GT_FILE
|
||||
# define __GT_FILE 0
|
||||
#endif
|
||||
|
||||
int __gen_tempname ();
|
||||
|
||||
/* Generate a unique temporary file name from TEMPLATE.
|
||||
The last six characters of TEMPLATE must be "XXXXXX";
|
||||
they are replaced with a string that makes the filename unique.
|
||||
Then open the file and return a fd. */
|
||||
int
|
||||
rpl_mkstemp (char *template)
|
||||
{
|
||||
return __gen_tempname (template, __GT_FILE);
|
||||
}
|
3
contrib/diff/lib/offtostr.c
Normal file
3
contrib/diff/lib/offtostr.c
Normal file
@ -0,0 +1,3 @@
|
||||
#define inttostr offtostr
|
||||
#define inttype off_t
|
||||
#include "inttostr.c"
|
59
contrib/diff/lib/posixver.c
Normal file
59
contrib/diff/lib/posixver.c
Normal file
@ -0,0 +1,59 @@
|
||||
/* Which POSIX version to conform to, for utilities.
|
||||
|
||||
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "posixver.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifndef _POSIX2_VERSION
|
||||
# define _POSIX2_VERSION 0
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_POSIX2_VERSION
|
||||
# define DEFAULT_POSIX2_VERSION _POSIX2_VERSION
|
||||
#endif
|
||||
|
||||
/* The POSIX version that utilities should conform to. The default is
|
||||
specified by the system. */
|
||||
|
||||
int
|
||||
posix2_version (void)
|
||||
{
|
||||
long int v = DEFAULT_POSIX2_VERSION;
|
||||
char const *s = getenv ("_POSIX2_VERSION");
|
||||
|
||||
if (s && *s)
|
||||
{
|
||||
char *e;
|
||||
long int i = strtol (s, &e, 10);
|
||||
if (! *e)
|
||||
v = i;
|
||||
}
|
||||
|
||||
return v < INT_MIN ? INT_MIN : v < INT_MAX ? v : INT_MAX;
|
||||
}
|
1
contrib/diff/lib/posixver.h
Normal file
1
contrib/diff/lib/posixver.h
Normal file
@ -0,0 +1 @@
|
||||
int posix2_version (void);
|
93
contrib/diff/lib/prepargs.c
Normal file
93
contrib/diff/lib/prepargs.c
Normal file
@ -0,0 +1,93 @@
|
||||
/* Parse arguments from a string and prepend them to an argv.
|
||||
|
||||
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 Paul Eggert <eggert@twinsun.com>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include "prepargs.h"
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <xalloc.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
/* IN_CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
|
||||
as an argument to <ctype.h> macros like "isspace". */
|
||||
#ifdef STDC_HEADERS
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) ((c) <= 0177)
|
||||
#endif
|
||||
|
||||
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
|
||||
|
||||
/* Find the white-space-separated options specified by OPTIONS, and
|
||||
using BUF to store copies of these options, set ARGV[0], ARGV[1],
|
||||
etc. to the option copies. Return the number N of options found.
|
||||
Do not set ARGV[N]. If ARGV is zero, do not store ARGV[0] etc.
|
||||
Backslash can be used to escape whitespace (and backslashes). */
|
||||
static int
|
||||
prepend_args (char const *options, char *buf, char **argv)
|
||||
{
|
||||
char const *o = options;
|
||||
char *b = buf;
|
||||
int n = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
while (ISSPACE ((unsigned char) *o))
|
||||
o++;
|
||||
if (!*o)
|
||||
return n;
|
||||
if (argv)
|
||||
argv[n] = b;
|
||||
n++;
|
||||
|
||||
do
|
||||
if ((*b++ = *o++) == '\\' && *o)
|
||||
b[-1] = *o++;
|
||||
while (*o && ! ISSPACE ((unsigned char) *o));
|
||||
|
||||
*b++ = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepend the whitespace-separated options in OPTIONS to the argument
|
||||
vector of a main program with argument count *PARGC and argument
|
||||
vector *PARGV. */
|
||||
void
|
||||
prepend_default_options (char const *options, int *pargc, char ***pargv)
|
||||
{
|
||||
if (options)
|
||||
{
|
||||
char *buf = xmalloc (strlen (options) + 1);
|
||||
int prepended = prepend_args (options, buf, (char **) 0);
|
||||
int argc = *pargc;
|
||||
char * const *argv = *pargv;
|
||||
char **pp = (char **) xmalloc ((prepended + argc + 1) * sizeof *pp);
|
||||
*pargc = prepended + argc;
|
||||
*pargv = pp;
|
||||
*pp++ = *argv++;
|
||||
pp += prepend_args (options, buf, pp);
|
||||
while ((*pp++ = *argv++))
|
||||
continue;
|
||||
}
|
||||
}
|
3
contrib/diff/lib/prepargs.h
Normal file
3
contrib/diff/lib/prepargs.h
Normal file
@ -0,0 +1,3 @@
|
||||
/* Parse arguments from a string and prepend them to an argv. */
|
||||
|
||||
void prepend_default_options (char const *, int *, char ***);
|
125
contrib/diff/lib/quotesys.c
Normal file
125
contrib/diff/lib/quotesys.c
Normal file
@ -0,0 +1,125 @@
|
||||
/* Shell command argument quoting.
|
||||
Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <quotesys.h>
|
||||
|
||||
/* Place into QUOTED a quoted version of ARG suitable for `system'.
|
||||
Return the length of the resulting string (which is not null-terminated).
|
||||
If QUOTED is null, return the length without any side effects. */
|
||||
|
||||
size_t
|
||||
quote_system_arg (quoted, arg)
|
||||
char *quoted;
|
||||
char const *arg;
|
||||
{
|
||||
char const *a;
|
||||
size_t len = 0;
|
||||
|
||||
/* Scan ARG, copying it to QUOTED if QUOTED is not null,
|
||||
looking for shell metacharacters. */
|
||||
|
||||
for (a = arg; ; a++)
|
||||
{
|
||||
char c = *a;
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
/* ARG has no shell metacharacters. */
|
||||
return len;
|
||||
|
||||
case '=':
|
||||
if (*arg == '-')
|
||||
break;
|
||||
/* Fall through. */
|
||||
case '\t': case '\n': case ' ':
|
||||
case '!': case '"': case '#': case '$': case '%': case '&': case '\'':
|
||||
case '(': case ')': case '*': case ';':
|
||||
case '<': case '>': case '?': case '[': case '\\':
|
||||
case '^': case '`': case '|': case '~':
|
||||
{
|
||||
/* ARG has a shell metacharacter.
|
||||
Start over, quoting it this time. */
|
||||
|
||||
len = 0;
|
||||
c = *arg++;
|
||||
|
||||
/* If ARG is an option, quote just its argument.
|
||||
This is not necessary, but it looks nicer. */
|
||||
if (c == '-' && arg < a)
|
||||
{
|
||||
c = *arg++;
|
||||
|
||||
if (quoted)
|
||||
{
|
||||
quoted[len] = '-';
|
||||
quoted[len + 1] = c;
|
||||
}
|
||||
len += 2;
|
||||
|
||||
if (c == '-')
|
||||
while (arg < a)
|
||||
{
|
||||
c = *arg++;
|
||||
if (quoted)
|
||||
quoted[len] = c;
|
||||
len++;
|
||||
if (c == '=')
|
||||
break;
|
||||
}
|
||||
c = *arg++;
|
||||
}
|
||||
|
||||
if (quoted)
|
||||
quoted[len] = '\'';
|
||||
len++;
|
||||
|
||||
for (; c; c = *arg++)
|
||||
{
|
||||
if (c == '\'')
|
||||
{
|
||||
if (quoted)
|
||||
{
|
||||
quoted[len] = '\'';
|
||||
quoted[len + 1] = '\\';
|
||||
quoted[len + 2] = '\'';
|
||||
}
|
||||
len += 3;
|
||||
}
|
||||
if (quoted)
|
||||
quoted[len] = c;
|
||||
len++;
|
||||
}
|
||||
|
||||
if (quoted)
|
||||
quoted[len] = '\'';
|
||||
return len + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (quoted)
|
||||
quoted[len] = c;
|
||||
len++;
|
||||
}
|
||||
}
|
9
contrib/diff/lib/quotesys.h
Normal file
9
contrib/diff/lib/quotesys.h
Normal file
@ -0,0 +1,9 @@
|
||||
/* quotesys.h -- declarations for quoting system arguments */
|
||||
|
||||
#if defined __STDC__ || __GNUC__
|
||||
# define __QUOTESYS_P(args) args
|
||||
#else
|
||||
# define __QUOTESYS_P(args) ()
|
||||
#endif
|
||||
|
||||
size_t quote_system_arg __QUOTESYS_P ((char *, char const *));
|
39
contrib/diff/lib/realloc.c
Normal file
39
contrib/diff/lib/realloc.c
Normal file
@ -0,0 +1,39 @@
|
||||
/* Work around bug on some systems where realloc (NULL, 0) fails.
|
||||
Copyright (C) 1997, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#undef realloc
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. If N is zero, change it to 1. If P is NULL,
|
||||
use malloc. */
|
||||
|
||||
void *
|
||||
rpl_realloc (void *p, size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
if (p == 0)
|
||||
return malloc (n);
|
||||
return realloc (p, n);
|
||||
}
|
8298
contrib/diff/lib/regex.c
Normal file
8298
contrib/diff/lib/regex.c
Normal file
File diff suppressed because it is too large
Load Diff
556
contrib/diff/lib/regex.h
Normal file
556
contrib/diff/lib/regex.h
Normal file
@ -0,0 +1,556 @@
|
||||
/* Definitions for data structures and routines for the regular
|
||||
expression library.
|
||||
Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _REGEX_H
|
||||
#define _REGEX_H 1
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Allow the use in C++ code. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* POSIX says that <sys/types.h> must be included (by the caller) before
|
||||
<regex.h>. */
|
||||
|
||||
#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
|
||||
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
|
||||
should be there. */
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
/* The following two types have to be signed and unsigned integer type
|
||||
wide enough to hold a value of a pointer. For most ANSI compilers
|
||||
ptrdiff_t and size_t should be likely OK. Still size of these two
|
||||
types is 2 for Microsoft C. Ugh... */
|
||||
typedef long int s_reg_t;
|
||||
typedef unsigned long int active_reg_t;
|
||||
|
||||
/* The following bits are used to determine the regexp syntax we
|
||||
recognize. The set/not-set meanings are chosen so that Emacs syntax
|
||||
remains the value 0. The bits are given in alphabetical order, and
|
||||
the definitions shifted by one from the previous bit; thus, when we
|
||||
add or remove a bit, only one other definition need change. */
|
||||
typedef unsigned long int reg_syntax_t;
|
||||
|
||||
/* If this bit is not set, then \ inside a bracket expression is literal.
|
||||
If set, then such a \ quotes the following character. */
|
||||
#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
|
||||
|
||||
/* If this bit is not set, then + and ? are operators, and \+ and \? are
|
||||
literals.
|
||||
If set, then \+ and \? are operators and + and ? are literals. */
|
||||
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
|
||||
|
||||
/* If this bit is set, then character classes are supported. They are:
|
||||
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
|
||||
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
|
||||
If not set, then character classes are not supported. */
|
||||
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
|
||||
|
||||
/* If this bit is set, then ^ and $ are always anchors (outside bracket
|
||||
expressions, of course).
|
||||
If this bit is not set, then it depends:
|
||||
^ is an anchor if it is at the beginning of a regular
|
||||
expression or after an open-group or an alternation operator;
|
||||
$ is an anchor if it is at the end of a regular expression, or
|
||||
before a close-group or an alternation operator.
|
||||
|
||||
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
|
||||
POSIX draft 11.2 says that * etc. in leading positions is undefined.
|
||||
We already implemented a previous draft which made those constructs
|
||||
invalid, though, so we haven't changed the code back. */
|
||||
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
|
||||
|
||||
/* If this bit is set, then special characters are always special
|
||||
regardless of where they are in the pattern.
|
||||
If this bit is not set, then special characters are special only in
|
||||
some contexts; otherwise they are ordinary. Specifically,
|
||||
* + ? and intervals are only special when not after the beginning,
|
||||
open-group, or alternation operator. */
|
||||
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
|
||||
|
||||
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
|
||||
immediately after an alternation or begin-group operator. */
|
||||
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . matches newline.
|
||||
If not set, then it doesn't. */
|
||||
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . doesn't match NUL.
|
||||
If not set, then it does. */
|
||||
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, nonmatching lists [^...] do not match newline.
|
||||
If not set, they do. */
|
||||
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
|
||||
|
||||
/* If this bit is set, either \{...\} or {...} defines an
|
||||
interval, depending on RE_NO_BK_BRACES.
|
||||
If not set, \{, \}, {, and } are literals. */
|
||||
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, +, ? and | aren't recognized as operators.
|
||||
If not set, they are. */
|
||||
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
|
||||
|
||||
/* If this bit is set, newline is an alternation operator.
|
||||
If not set, newline is literal. */
|
||||
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
|
||||
|
||||
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
|
||||
are literals.
|
||||
If not set, then `\{...\}' defines an interval. */
|
||||
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
|
||||
|
||||
/* If this bit is set, (...) defines a group, and \( and \) are literals.
|
||||
If not set, \(...\) defines a group, and ( and ) are literals. */
|
||||
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
|
||||
|
||||
/* If this bit is set, then \<digit> matches <digit>.
|
||||
If not set, then \<digit> is a back-reference. */
|
||||
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
|
||||
|
||||
/* If this bit is set, then | is an alternation operator, and \| is literal.
|
||||
If not set, then \| is an alternation operator, and | is literal. */
|
||||
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
|
||||
|
||||
/* If this bit is set, then an ending range point collating higher
|
||||
than the starting range point, as in [z-a], is invalid.
|
||||
If not set, then when ending range point collates higher than the
|
||||
starting range point, the range is ignored. */
|
||||
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
|
||||
|
||||
/* If this bit is set, then an unmatched ) is ordinary.
|
||||
If not set, then an unmatched ) is invalid. */
|
||||
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
|
||||
|
||||
/* If this bit is set, succeed as soon as we match the whole pattern,
|
||||
without further backtracking. */
|
||||
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
|
||||
|
||||
/* If this bit is set, do not process the GNU regex operators.
|
||||
If not set, then the GNU regex operators are recognized. */
|
||||
#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
|
||||
|
||||
/* If this bit is set, turn on internal regex debugging.
|
||||
If not set, and debugging was on, turn it off.
|
||||
This only works if regex.c is compiled -DDEBUG.
|
||||
We define this bit always, so that all that's needed to turn on
|
||||
debugging is to recompile regex.c; the calling code can always have
|
||||
this bit set, and it won't affect anything in the normal case. */
|
||||
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
|
||||
|
||||
/* If this bit is set, a syntactically invalid interval is treated as
|
||||
a string of ordinary characters. For example, the ERE 'a{1' is
|
||||
treated as 'a\{1'. */
|
||||
#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
|
||||
|
||||
/* If this bit is set, then ignore case when matching.
|
||||
If not set, then case is significant. */
|
||||
#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
|
||||
|
||||
/* This global variable defines the particular regexp syntax to use (for
|
||||
some interfaces). When a regexp is compiled, the syntax used is
|
||||
stored in the pattern buffer, so changing this does not affect
|
||||
already-compiled regexps. */
|
||||
extern reg_syntax_t re_syntax_options;
|
||||
|
||||
/* Define combinations of the above bits for the standard possibilities.
|
||||
(The [[[ comments delimit what gets put into the Texinfo file, so
|
||||
don't delete them!) */
|
||||
/* [[[begin syntaxes]]] */
|
||||
#define RE_SYNTAX_EMACS 0
|
||||
|
||||
#define RE_SYNTAX_AWK \
|
||||
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
|
||||
| RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GNU_AWK \
|
||||
((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
|
||||
& ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \
|
||||
| RE_CONTEXT_INVALID_OPS ))
|
||||
|
||||
#define RE_SYNTAX_POSIX_AWK \
|
||||
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
|
||||
| RE_INTERVALS | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GREP \
|
||||
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
|
||||
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
|
||||
| RE_NEWLINE_ALT)
|
||||
|
||||
#define RE_SYNTAX_EGREP \
|
||||
(RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
|
||||
| RE_NEWLINE_ALT | RE_NO_BK_PARENS \
|
||||
| RE_NO_BK_VBAR)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EGREP \
|
||||
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
|
||||
| RE_INVALID_INTERVAL_ORD)
|
||||
|
||||
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
|
||||
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
/* Syntax bits common to both basic and extended POSIX regex syntax. */
|
||||
#define _RE_SYNTAX_POSIX_COMMON \
|
||||
(RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
|
||||
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
|
||||
|
||||
#define RE_SYNTAX_POSIX_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
|
||||
|
||||
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
|
||||
RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
|
||||
isn't minimal, since other operators, such as \`, aren't disabled. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
|
||||
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
|
||||
removed and RE_NO_BK_REFS is added. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
/* [[[end syntaxes]]] */
|
||||
|
||||
/* Maximum number of duplicates an interval can allow. Some systems
|
||||
(erroneously) define this in other header files, but we want our
|
||||
value, so remove any previous define. */
|
||||
#ifdef RE_DUP_MAX
|
||||
# undef RE_DUP_MAX
|
||||
#endif
|
||||
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
|
||||
#define RE_DUP_MAX (0x7fff)
|
||||
|
||||
|
||||
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
|
||||
|
||||
/* If this bit is set, then use extended regular expression syntax.
|
||||
If not set, then use basic regular expression syntax. */
|
||||
#define REG_EXTENDED 1
|
||||
|
||||
/* If this bit is set, then ignore case when matching.
|
||||
If not set, then case is significant. */
|
||||
#define REG_ICASE (REG_EXTENDED << 1)
|
||||
|
||||
/* If this bit is set, then anchors do not match at newline
|
||||
characters in the string.
|
||||
If not set, then anchors do match at newlines. */
|
||||
#define REG_NEWLINE (REG_ICASE << 1)
|
||||
|
||||
/* If this bit is set, then report only success or fail in regexec.
|
||||
If not set, then returns differ between not matching and errors. */
|
||||
#define REG_NOSUB (REG_NEWLINE << 1)
|
||||
|
||||
|
||||
/* POSIX `eflags' bits (i.e., information for regexec). */
|
||||
|
||||
/* If this bit is set, then the beginning-of-line operator doesn't match
|
||||
the beginning of the string (presumably because it's not the
|
||||
beginning of a line).
|
||||
If not set, then the beginning-of-line operator does match the
|
||||
beginning of the string. */
|
||||
#define REG_NOTBOL 1
|
||||
|
||||
/* Like REG_NOTBOL, except for the end-of-line. */
|
||||
#define REG_NOTEOL (1 << 1)
|
||||
|
||||
|
||||
/* If any error codes are removed, changed, or added, update the
|
||||
`re_error_msg' table in regex.c. */
|
||||
typedef enum
|
||||
{
|
||||
#ifdef _XOPEN_SOURCE
|
||||
REG_ENOSYS = -1, /* This will never happen for this implementation. */
|
||||
#endif
|
||||
|
||||
REG_NOERROR = 0, /* Success. */
|
||||
REG_NOMATCH, /* Didn't find a match (for regexec). */
|
||||
|
||||
/* POSIX regcomp return error codes. (In the order listed in the
|
||||
standard.) */
|
||||
REG_BADPAT, /* Invalid pattern. */
|
||||
REG_ECOLLATE, /* Not implemented. */
|
||||
REG_ECTYPE, /* Invalid character class name. */
|
||||
REG_EESCAPE, /* Trailing backslash. */
|
||||
REG_ESUBREG, /* Invalid back reference. */
|
||||
REG_EBRACK, /* Unmatched left bracket. */
|
||||
REG_EPAREN, /* Parenthesis imbalance. */
|
||||
REG_EBRACE, /* Unmatched \{. */
|
||||
REG_BADBR, /* Invalid contents of \{\}. */
|
||||
REG_ERANGE, /* Invalid range end. */
|
||||
REG_ESPACE, /* Ran out of memory. */
|
||||
REG_BADRPT, /* No preceding re for repetition op. */
|
||||
|
||||
/* Error codes we've added. */
|
||||
REG_EEND, /* Premature end. */
|
||||
REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
|
||||
REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
|
||||
} reg_errcode_t;
|
||||
|
||||
/* This data structure represents a compiled pattern. Before calling
|
||||
the pattern compiler, the fields `buffer', `allocated', `fastmap',
|
||||
`translate', and `no_sub' can be set. After the pattern has been
|
||||
compiled, the `re_nsub' field is available. All other fields are
|
||||
private to the regex routines. */
|
||||
|
||||
#ifndef RE_TRANSLATE_TYPE
|
||||
# define RE_TRANSLATE_TYPE char *
|
||||
#endif
|
||||
|
||||
struct re_pattern_buffer
|
||||
{
|
||||
/* [[[begin pattern_buffer]]] */
|
||||
/* Space that holds the compiled pattern. It is declared as
|
||||
`unsigned char *' because its elements are
|
||||
sometimes used as array indexes. */
|
||||
unsigned char *buffer;
|
||||
|
||||
/* Number of bytes to which `buffer' points. */
|
||||
unsigned long int allocated;
|
||||
|
||||
/* Number of bytes actually used in `buffer'. */
|
||||
unsigned long int used;
|
||||
|
||||
/* Syntax setting with which the pattern was compiled. */
|
||||
reg_syntax_t syntax;
|
||||
|
||||
/* Pointer to a fastmap, if any, otherwise zero. re_search uses
|
||||
the fastmap, if there is one, to skip over impossible
|
||||
starting points for matches. */
|
||||
char *fastmap;
|
||||
|
||||
/* Either a translate table to apply to all characters before
|
||||
comparing them, or zero for no translation. The translation
|
||||
is applied to a pattern when it is compiled and to a string
|
||||
when it is matched. */
|
||||
RE_TRANSLATE_TYPE translate;
|
||||
|
||||
/* Number of subexpressions found by the compiler. */
|
||||
size_t re_nsub;
|
||||
|
||||
/* Zero if this pattern cannot match the empty string, one else.
|
||||
Well, in truth it's used only in `re_search_2', to see
|
||||
whether or not we should use the fastmap, so we don't set
|
||||
this absolutely perfectly; see `re_compile_fastmap' (the
|
||||
`duplicate' case). */
|
||||
unsigned can_be_null : 1;
|
||||
|
||||
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
|
||||
for `max (RE_NREGS, re_nsub + 1)' groups.
|
||||
If REGS_REALLOCATE, reallocate space if necessary.
|
||||
If REGS_FIXED, use what's there. */
|
||||
#define REGS_UNALLOCATED 0
|
||||
#define REGS_REALLOCATE 1
|
||||
#define REGS_FIXED 2
|
||||
unsigned regs_allocated : 2;
|
||||
|
||||
/* Set to zero when `regex_compile' compiles a pattern; set to one
|
||||
by `re_compile_fastmap' if it updates the fastmap. */
|
||||
unsigned fastmap_accurate : 1;
|
||||
|
||||
/* If set, `re_match_2' does not return information about
|
||||
subexpressions. */
|
||||
unsigned no_sub : 1;
|
||||
|
||||
/* If set, a beginning-of-line anchor doesn't match at the
|
||||
beginning of the string. */
|
||||
unsigned not_bol : 1;
|
||||
|
||||
/* Similarly for an end-of-line anchor. */
|
||||
unsigned not_eol : 1;
|
||||
|
||||
/* If true, an anchor at a newline matches. */
|
||||
unsigned newline_anchor : 1;
|
||||
|
||||
/* [[[end pattern_buffer]]] */
|
||||
};
|
||||
|
||||
typedef struct re_pattern_buffer regex_t;
|
||||
|
||||
/* Type for byte offsets within the string. POSIX mandates this. */
|
||||
typedef int regoff_t;
|
||||
|
||||
|
||||
/* This is the structure we store register match data in. See
|
||||
regex.texinfo for a full description of what registers match. */
|
||||
struct re_registers
|
||||
{
|
||||
unsigned num_regs;
|
||||
regoff_t *start;
|
||||
regoff_t *end;
|
||||
};
|
||||
|
||||
|
||||
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
|
||||
`re_match_2' returns information about at least this many registers
|
||||
the first time a `regs' structure is passed. */
|
||||
#ifndef RE_NREGS
|
||||
# define RE_NREGS 30
|
||||
#endif
|
||||
|
||||
|
||||
/* POSIX specification for registers. Aside from the different names than
|
||||
`re_registers', POSIX uses an array of structures, instead of a
|
||||
structure of arrays. */
|
||||
typedef struct
|
||||
{
|
||||
regoff_t rm_so; /* Byte offset from string's start to substring's start. */
|
||||
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
|
||||
} regmatch_t;
|
||||
|
||||
/* Declarations for routines. */
|
||||
|
||||
/* Sets the current default syntax to SYNTAX, and return the old syntax.
|
||||
You can also simply assign to the `re_syntax_options' variable. */
|
||||
extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
|
||||
|
||||
/* Compile the regular expression PATTERN, with length LENGTH
|
||||
and syntax given by the global `re_syntax_options', into the buffer
|
||||
BUFFER. Return NULL if successful, and an error string if not. */
|
||||
extern const char *re_compile_pattern (const char *pattern, size_t length,
|
||||
struct re_pattern_buffer *buffer);
|
||||
|
||||
|
||||
/* Compile a fastmap for the compiled pattern in BUFFER; used to
|
||||
accelerate searches. Return 0 if successful and -2 if was an
|
||||
internal error. */
|
||||
extern int re_compile_fastmap (struct re_pattern_buffer *buffer);
|
||||
|
||||
|
||||
/* Search in the string STRING (with length LENGTH) for the pattern
|
||||
compiled into BUFFER. Start searching at position START, for RANGE
|
||||
characters. Return the starting position of the match, -1 for no
|
||||
match, or -2 for an internal error. Also return register
|
||||
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
|
||||
extern int re_search (struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, int range,
|
||||
struct re_registers *regs);
|
||||
|
||||
|
||||
/* Like `re_search', but search in the concatenation of STRING1 and
|
||||
STRING2. Also, stop searching at index START + STOP. */
|
||||
extern int re_search_2 (struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, int range, struct re_registers *regs,
|
||||
int stop);
|
||||
|
||||
|
||||
/* Like `re_search', but return how many characters in STRING the regexp
|
||||
in BUFFER matched, starting at position START. */
|
||||
extern int re_match (struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, struct re_registers *regs);
|
||||
|
||||
|
||||
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
|
||||
extern int re_match_2 (struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, struct re_registers *regs, int stop);
|
||||
|
||||
|
||||
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
|
||||
ENDS. Subsequent matches using BUFFER and REGS will use this memory
|
||||
for recording register information. STARTS and ENDS must be
|
||||
allocated with malloc, and must each be at least `NUM_REGS * sizeof
|
||||
(regoff_t)' bytes long.
|
||||
|
||||
If NUM_REGS == 0, then subsequent matches should allocate their own
|
||||
register data.
|
||||
|
||||
Unless this function is called, the first search or match using
|
||||
PATTERN_BUFFER will allocate its own register data, without
|
||||
freeing the old data. */
|
||||
extern void re_set_registers (struct re_pattern_buffer *buffer,
|
||||
struct re_registers *regs, unsigned num_regs,
|
||||
regoff_t *starts, regoff_t *ends);
|
||||
|
||||
#if defined _REGEX_RE_COMP || defined _LIBC
|
||||
# ifndef _CRAY
|
||||
/* 4.2 bsd compatibility. */
|
||||
extern char *re_comp (const char *);
|
||||
extern int re_exec (const char *);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* GCC 2.95 and later have "__restrict"; C99 compilers have
|
||||
"restrict", and "configure" may have defined "restrict". */
|
||||
#ifndef __restrict
|
||||
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
|
||||
# if defined restrict || 199901L <= __STDC_VERSION__
|
||||
# define __restrict restrict
|
||||
# else
|
||||
# define __restrict
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
/* gcc 3.1 and up support the [restrict] syntax. */
|
||||
#ifndef __restrict_arr
|
||||
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||
# define __restrict_arr __restrict
|
||||
# else
|
||||
# define __restrict_arr
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* POSIX compatibility. */
|
||||
extern int regcomp (regex_t *__restrict __preg,
|
||||
const char *__restrict __pattern,
|
||||
int __cflags);
|
||||
|
||||
extern int regexec (const regex_t *__restrict __preg,
|
||||
const char *__restrict __string, size_t __nmatch,
|
||||
regmatch_t __pmatch[__restrict_arr],
|
||||
int __eflags);
|
||||
|
||||
extern size_t regerror (int __errcode, const regex_t *__preg,
|
||||
char *__errbuf, size_t __errbuf_size);
|
||||
|
||||
extern void regfree (regex_t *__preg);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
#endif /* regex.h */
|
||||
|
||||
/*
|
||||
Local variables:
|
||||
make-backup-files: t
|
||||
version-control: t
|
||||
trim-versions-without-asking: nil
|
||||
End:
|
||||
*/
|
67
contrib/diff/lib/setmode.c
Normal file
67
contrib/diff/lib/setmode.c
Normal file
@ -0,0 +1,67 @@
|
||||
/* Set a file descriptor's mode to binary or to text.
|
||||
|
||||
Copyright (C) 2001, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
typedef enum {false = 0, true = 1} bool;
|
||||
#endif
|
||||
|
||||
#if HAVE_SETMODE_DOS
|
||||
# include <io.h>
|
||||
# if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
# endif
|
||||
# if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "setmode.h"
|
||||
#undef set_binary_mode
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 3 || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Set the binary mode of FD to MODE, returning its previous mode.
|
||||
MODE is 1 for binary and 0 for text. If setting the mode might
|
||||
cause problems, ignore the request and return MODE. Always return
|
||||
1 on POSIX platforms, which do not distinguish between text and
|
||||
binary. */
|
||||
|
||||
#if HAVE_SETMODE_DOS
|
||||
bool
|
||||
set_binary_mode (int fd, bool mode)
|
||||
{
|
||||
if (isatty (fd))
|
||||
return mode;
|
||||
return setmode (fd, mode ? O_BINARY : O_TEXT) != O_TEXT;
|
||||
}
|
||||
#else
|
||||
static char dummy;
|
||||
#endif
|
27
contrib/diff/lib/setmode.h
Normal file
27
contrib/diff/lib/setmode.h
Normal file
@ -0,0 +1,27 @@
|
||||
/* Set a file descriptor's mode to binary or to text.
|
||||
|
||||
Copyright (C) 2001, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#ifndef set_binary_mode
|
||||
bool set_binary_mode (int, bool);
|
||||
# if ! HAVE_SETMODE_DOS
|
||||
# define set_binary_mode(fd, mode) true
|
||||
# endif
|
||||
#endif
|
93
contrib/diff/lib/stdbool_.h
Normal file
93
contrib/diff/lib/stdbool_.h
Normal file
@ -0,0 +1,93 @@
|
||||
/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
|
||||
|
||||
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 _STDBOOL_H
|
||||
#define _STDBOOL_H
|
||||
|
||||
/* ISO C 99 <stdbool.h> for platforms that lack it. */
|
||||
|
||||
/* Usage suggestions:
|
||||
|
||||
Programs that use <stdbool.h> should be aware of some limitations
|
||||
and standards compliance issues.
|
||||
|
||||
Standards compliance:
|
||||
|
||||
- <stdbool.h> must be #included before 'bool', 'false', 'true'
|
||||
can be used.
|
||||
|
||||
- You cannot assume that sizeof (bool) == 1.
|
||||
|
||||
- Programs should not undefine the macros bool, true, and false,
|
||||
as C99 lists that as an "obsolescent feature".
|
||||
|
||||
Limitations of this substitute, when used in a C89 environment:
|
||||
|
||||
- <stdbool.h> must be #included before the '_Bool' type can be used.
|
||||
|
||||
- You cannot assume that _Bool is a typedef; it might be a macro.
|
||||
|
||||
- In C99, casts and automatic conversions to '_Bool' or 'bool' are
|
||||
performed in such a way that every nonzero value gets converted
|
||||
to 'true', and zero gets converted to 'false'. This doesn't work
|
||||
with this substitute. With this substitute, only the values 0 and 1
|
||||
give the expected result when converted to _Bool' or 'bool'.
|
||||
|
||||
Also, it is suggested that programs use 'bool' rather than '_Bool';
|
||||
this isn't required, but 'bool' is more common. */
|
||||
|
||||
|
||||
/* 7.16. Boolean type and values */
|
||||
|
||||
/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
|
||||
definitions below, but temporarily we have to #undef them. */
|
||||
#ifdef __BEOS__
|
||||
# include <OS.h> /* defines bool but not _Bool */
|
||||
# undef false
|
||||
# undef true
|
||||
#endif
|
||||
|
||||
/* For the sake of symbolic names in gdb, we define true and false as
|
||||
enum constants, not only as macros.
|
||||
It is tempting to write
|
||||
typedef enum { false = 0, true = 1 } _Bool;
|
||||
so that gdb prints values of type 'bool' symbolically. But if we do
|
||||
this, values of type '_Bool' may promote to 'int' or 'unsigned int'
|
||||
(see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
|
||||
(see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
|
||||
enum; this ensures that '_Bool' promotes to 'int'. */
|
||||
#if !(defined __cplusplus || defined __BEOS__)
|
||||
# if !@HAVE__BOOL@
|
||||
# if defined __SUNPRO_C && (__SUNPRO_C < 0x550 || __STDC__ == 1)
|
||||
/* Avoid stupid "warning: _Bool is a keyword in ISO C99". */
|
||||
# define _Bool signed char
|
||||
enum { false = 0, true = 1 };
|
||||
# else
|
||||
typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
typedef bool _Bool;
|
||||
#endif
|
||||
#define bool _Bool
|
||||
|
||||
/* The other macros must be usable in preprocessor directives. */
|
||||
#define false 0
|
||||
#define true 1
|
||||
#define __bool_true_false_are_defined 1
|
||||
|
||||
#endif /* _STDBOOL_H */
|
35
contrib/diff/lib/strcase.h
Normal file
35
contrib/diff/lib/strcase.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* Case-insensitive string comparison functions.
|
||||
Copyright (C) 1995-1996, 2001, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _STRCASE_H
|
||||
#define _STRCASE_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
|
||||
greater than zero if S1 is lexicographically less than, equal to or greater
|
||||
than S2.
|
||||
Note: This function does not work correctly in multibyte locales. */
|
||||
extern int strcasecmp (const char *s1, const char *s2);
|
||||
|
||||
/* Compare no more than N characters of strings S1 and S2, ignoring case,
|
||||
returning less than, equal to or greater than zero if S1 is
|
||||
lexicographically less than, equal to or greater than S2.
|
||||
Note: This function can not work correctly in multibyte locales. */
|
||||
extern int strncasecmp (const char *s1, const char *s2, size_t n);
|
||||
|
||||
#endif /* _STRCASE_H */
|
66
contrib/diff/lib/strcasecmp.c
Normal file
66
contrib/diff/lib/strcasecmp.c
Normal file
@ -0,0 +1,66 @@
|
||||
/* strcasecmp.c -- case insensitive string comparator
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef LENGTH_LIMIT
|
||||
# define STRXCASECMP_FUNCTION strncasecmp
|
||||
# define STRXCASECMP_DECLARE_N , size_t n
|
||||
# define LENGTH_LIMIT_EXPR(Expr) Expr
|
||||
#else
|
||||
# define STRXCASECMP_FUNCTION strcasecmp
|
||||
# define STRXCASECMP_DECLARE_N /* empty */
|
||||
# define LENGTH_LIMIT_EXPR(Expr) 0
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
|
||||
|
||||
/* Compare {{no more than N characters of }}strings S1 and S2,
|
||||
ignoring case, returning less than, equal to or
|
||||
greater than zero if S1 is lexicographically less
|
||||
than, equal to or greater than S2. */
|
||||
|
||||
int
|
||||
STRXCASECMP_FUNCTION (const char *s1, const char *s2 STRXCASECMP_DECLARE_N)
|
||||
{
|
||||
register const unsigned char *p1 = (const unsigned char *) s1;
|
||||
register const unsigned char *p2 = (const unsigned char *) s2;
|
||||
unsigned char c1, c2;
|
||||
|
||||
if (p1 == p2 || LENGTH_LIMIT_EXPR (n == 0))
|
||||
return 0;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = TOLOWER (*p1);
|
||||
c2 = TOLOWER (*p2);
|
||||
|
||||
if (LENGTH_LIMIT_EXPR (--n == 0) || c1 == '\0')
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
}
|
||||
while (c1 == c2);
|
||||
|
||||
return c1 - c2;
|
||||
}
|
1330
contrib/diff/lib/strftime.c
Normal file
1330
contrib/diff/lib/strftime.c
Normal file
File diff suppressed because it is too large
Load Diff
39
contrib/diff/lib/stripslash.c
Normal file
39
contrib/diff/lib/stripslash.c
Normal file
@ -0,0 +1,39 @@
|
||||
/* stripslash.c -- remove redundant trailing slashes from a file name
|
||||
Copyright (C) 1990, 2001, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
/* Remove trailing slashes from PATH.
|
||||
Return nonzero if a trailing slash was removed.
|
||||
This is useful when using filename completion from a shell that
|
||||
adds a "/" after directory names (such as tcsh and bash), because
|
||||
the Unix rename and rmdir system calls return an "Invalid argument" error
|
||||
when given a path that ends in "/" (except for the root directory). */
|
||||
|
||||
int
|
||||
strip_trailing_slashes (char *path)
|
||||
{
|
||||
char *base = base_name (path);
|
||||
char *base_lim = base + base_len (base);
|
||||
int had_slash = *base_lim;
|
||||
*base_lim = '\0';
|
||||
return had_slash;
|
||||
}
|
2
contrib/diff/lib/strncasecmp.c
Normal file
2
contrib/diff/lib/strncasecmp.c
Normal file
@ -0,0 +1,2 @@
|
||||
#define LENGTH_LIMIT
|
||||
#include "strcasecmp.c"
|
80
contrib/diff/lib/strtoimax.c
Normal file
80
contrib/diff/lib/strtoimax.c
Normal file
@ -0,0 +1,80 @@
|
||||
/* Convert string representation of a number into an intmax_t value.
|
||||
Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; 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>
|
||||
#elif HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
|
||||
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
|
||||
|
||||
#ifdef UNSIGNED
|
||||
# ifndef HAVE_DECL_STRTOULL
|
||||
"this configure-time declaration test was not run"
|
||||
# endif
|
||||
# if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG
|
||||
unsigned long long strtoull (char const *, char **, int);
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
# ifndef HAVE_DECL_STRTOLL
|
||||
"this configure-time declaration test was not run"
|
||||
# endif
|
||||
# if !HAVE_DECL_STRTOLL && HAVE_UNSIGNED_LONG_LONG
|
||||
long long strtoll (char const *, char **, int);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef UNSIGNED
|
||||
# undef HAVE_LONG_LONG
|
||||
# define HAVE_LONG_LONG HAVE_UNSIGNED_LONG_LONG
|
||||
# define INT uintmax_t
|
||||
# define strtoimax strtoumax
|
||||
# define strtol strtoul
|
||||
# define strtoll strtoull
|
||||
#else
|
||||
# define INT intmax_t
|
||||
#endif
|
||||
|
||||
INT
|
||||
strtoimax (char const *ptr, char **endptr, int base)
|
||||
{
|
||||
#if HAVE_LONG_LONG
|
||||
verify (size_is_that_of_long_or_long_long,
|
||||
(sizeof (INT) == sizeof (long)
|
||||
|| sizeof (INT) == sizeof (long long)));
|
||||
|
||||
if (sizeof (INT) != sizeof (long))
|
||||
return strtoll (ptr, endptr, base);
|
||||
#else
|
||||
verify (size_is_that_of_long,
|
||||
sizeof (INT) == sizeof (long));
|
||||
#endif
|
||||
|
||||
return strtol (ptr, endptr, base);
|
||||
}
|
432
contrib/diff/lib/strtol.c
Normal file
432
contrib/diff/lib/strtol.c
Normal file
@ -0,0 +1,432 @@
|
||||
/* Convert string representation of a number into an integer value.
|
||||
|
||||
Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003
|
||||
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@gnu.org.
|
||||
|
||||
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
|
||||
|
||||
#ifdef _LIBC
|
||||
# define USE_NUMBER_GROUPING
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
#ifndef __set_errno
|
||||
# define __set_errno(Val) errno = (Val)
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
# include "../locale/localeinfo.h"
|
||||
#endif
|
||||
|
||||
/* Nonzero if we are defining `strtoul' or `strtoull', operating on
|
||||
unsigned integers. */
|
||||
#ifndef UNSIGNED
|
||||
# define UNSIGNED 0
|
||||
# define INT LONG int
|
||||
#else
|
||||
# define INT unsigned LONG int
|
||||
#endif
|
||||
|
||||
/* Determine the name. */
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# if UNSIGNED
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol __wcstoull_l
|
||||
# else
|
||||
# define strtol __wcstoul_l
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol __strtoull_l
|
||||
# else
|
||||
# define strtol __strtoul_l
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol __wcstoll_l
|
||||
# else
|
||||
# define strtol __wcstol_l
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol __strtoll_l
|
||||
# else
|
||||
# define strtol __strtol_l
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# if UNSIGNED
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstoull
|
||||
# else
|
||||
# define strtol wcstoul
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol strtoull
|
||||
# else
|
||||
# define strtol strtoul
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# ifdef USE_WIDE_CHAR
|
||||
# ifdef QUAD
|
||||
# define strtol wcstoll
|
||||
# else
|
||||
# define strtol wcstol
|
||||
# endif
|
||||
# else
|
||||
# ifdef QUAD
|
||||
# define strtol strtoll
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If QUAD is defined, we are defining `strtoll' or `strtoull',
|
||||
operating on `long long int's. */
|
||||
#ifdef QUAD
|
||||
# define LONG long long
|
||||
# define STRTOL_LONG_MIN LONG_LONG_MIN
|
||||
# define STRTOL_LONG_MAX LONG_LONG_MAX
|
||||
# define STRTOL_ULONG_MAX ULONG_LONG_MAX
|
||||
|
||||
/* The extra casts work around common compiler bugs,
|
||||
e.g. Cray C 5.0.3.0 when t == time_t. */
|
||||
# ifndef TYPE_SIGNED
|
||||
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
# endif
|
||||
# ifndef TYPE_MINIMUM
|
||||
# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
|
||||
: (t) 0))
|
||||
# endif
|
||||
# ifndef TYPE_MAXIMUM
|
||||
# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
||||
# endif
|
||||
|
||||
# ifndef ULONG_LONG_MAX
|
||||
# define ULONG_LONG_MAX TYPE_MAXIMUM (unsigned long long)
|
||||
# endif
|
||||
# ifndef LONG_LONG_MAX
|
||||
# define LONG_LONG_MAX TYPE_MAXIMUM (long long int)
|
||||
# endif
|
||||
# ifndef LONG_LONG_MIN
|
||||
# define LONG_LONG_MIN TYPE_MINIMUM (long long int)
|
||||
# endif
|
||||
|
||||
# if __GNUC__ == 2 && __GNUC_MINOR__ < 7
|
||||
/* Work around gcc bug with using this constant. */
|
||||
static const unsigned long long int maxquad = ULONG_LONG_MAX;
|
||||
# undef STRTOL_ULONG_MAX
|
||||
# define STRTOL_ULONG_MAX maxquad
|
||||
# endif
|
||||
#else
|
||||
# define LONG long
|
||||
# define STRTOL_LONG_MIN LONG_MIN
|
||||
# define STRTOL_LONG_MAX LONG_MAX
|
||||
# define STRTOL_ULONG_MAX ULONG_MAX
|
||||
#endif
|
||||
|
||||
|
||||
/* We use this code also for the extended locale handling where the
|
||||
function gets as an additional argument the locale which has to be
|
||||
used. To access the values we have to redefine the _NL_CURRENT
|
||||
macro. */
|
||||
#ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# undef _NL_CURRENT
|
||||
# define _NL_CURRENT(category, item) \
|
||||
(current->values[_NL_ITEM_INDEX (item)].string)
|
||||
# define LOCALE_PARAM , loc
|
||||
# define LOCALE_PARAM_PROTO , __locale_t loc
|
||||
#else
|
||||
# define LOCALE_PARAM
|
||||
# define LOCALE_PARAM_PROTO
|
||||
#endif
|
||||
|
||||
#if defined _LIBC || defined HAVE_WCHAR_H
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIDE_CHAR
|
||||
# include <wctype.h>
|
||||
# define L_(Ch) L##Ch
|
||||
# define UCHAR_TYPE wint_t
|
||||
# define STRING_TYPE wchar_t
|
||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# define ISSPACE(Ch) __iswspace_l ((Ch), loc)
|
||||
# define ISALPHA(Ch) __iswalpha_l ((Ch), loc)
|
||||
# define TOUPPER(Ch) __towupper_l ((Ch), loc)
|
||||
# else
|
||||
# define ISSPACE(Ch) iswspace (Ch)
|
||||
# define ISALPHA(Ch) iswalpha (Ch)
|
||||
# define TOUPPER(Ch) towupper (Ch)
|
||||
# endif
|
||||
#else
|
||||
# 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 L_(Ch) Ch
|
||||
# define UCHAR_TYPE unsigned char
|
||||
# define STRING_TYPE char
|
||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
# define ISSPACE(Ch) __isspace_l ((Ch), loc)
|
||||
# define ISALPHA(Ch) __isalpha_l ((Ch), loc)
|
||||
# define TOUPPER(Ch) __toupper_l ((Ch), loc)
|
||||
# else
|
||||
# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch))
|
||||
# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch))
|
||||
# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define INTERNAL(X) INTERNAL1(X)
|
||||
#define INTERNAL1(X) __##X##_internal
|
||||
#define WEAKNAME(X) WEAKNAME1(X)
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
/* This file defines a function to check for correct grouping. */
|
||||
# include "grouping.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
|
||||
If BASE is 0 the base is determined by the presence of a leading
|
||||
zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
|
||||
If BASE is < 2 or > 36, it is reset to 10.
|
||||
If ENDPTR is not NULL, a pointer to the character after the last
|
||||
one converted is stored in *ENDPTR. */
|
||||
|
||||
INT
|
||||
INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
|
||||
int base, int group LOCALE_PARAM_PROTO)
|
||||
{
|
||||
int negative;
|
||||
register unsigned LONG int cutoff;
|
||||
register unsigned int cutlim;
|
||||
register unsigned LONG int i;
|
||||
register const STRING_TYPE *s;
|
||||
register UCHAR_TYPE c;
|
||||
const STRING_TYPE *save, *end;
|
||||
int overflow;
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
# ifdef USE_IN_EXTENDED_LOCALE_MODEL
|
||||
struct locale_data *current = loc->__locales[LC_NUMERIC];
|
||||
# endif
|
||||
/* The thousands character of the current locale. */
|
||||
wchar_t thousands = L'\0';
|
||||
/* The numeric grouping specification of the current locale,
|
||||
in the format described in <locale.h>. */
|
||||
const char *grouping;
|
||||
|
||||
if (group)
|
||||
{
|
||||
grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
|
||||
if (*grouping <= 0 || *grouping == CHAR_MAX)
|
||||
grouping = NULL;
|
||||
else
|
||||
{
|
||||
/* Figure out the thousands separator character. */
|
||||
# if defined _LIBC || defined _HAVE_BTOWC
|
||||
thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP));
|
||||
if (thousands == WEOF)
|
||||
thousands = L'\0';
|
||||
# endif
|
||||
if (thousands == L'\0')
|
||||
grouping = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
grouping = NULL;
|
||||
#endif
|
||||
|
||||
if (base < 0 || base == 1 || base > 36)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
save = s = nptr;
|
||||
|
||||
/* Skip white space. */
|
||||
while (ISSPACE (*s))
|
||||
++s;
|
||||
if (*s == L_('\0'))
|
||||
goto noconv;
|
||||
|
||||
/* Check for a sign. */
|
||||
if (*s == L_('-'))
|
||||
{
|
||||
negative = 1;
|
||||
++s;
|
||||
}
|
||||
else if (*s == L_('+'))
|
||||
{
|
||||
negative = 0;
|
||||
++s;
|
||||
}
|
||||
else
|
||||
negative = 0;
|
||||
|
||||
/* Recognize number prefix and if BASE is zero, figure it out ourselves. */
|
||||
if (*s == L_('0'))
|
||||
{
|
||||
if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X'))
|
||||
{
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
else if (base == 0)
|
||||
base = 8;
|
||||
}
|
||||
else if (base == 0)
|
||||
base = 10;
|
||||
|
||||
/* Save the pointer so we can check later if anything happened. */
|
||||
save = s;
|
||||
|
||||
#ifdef USE_NUMBER_GROUPING
|
||||
if (group)
|
||||
{
|
||||
/* Find the end of the digit string and check its grouping. */
|
||||
end = s;
|
||||
for (c = *end; c != L_('\0'); c = *++end)
|
||||
if ((wchar_t) c != thousands
|
||||
&& ((wchar_t) c < L_('0') || (wchar_t) c > L_('9'))
|
||||
&& (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base))
|
||||
break;
|
||||
if (*s == thousands)
|
||||
end = s;
|
||||
else
|
||||
end = correctly_grouped_prefix (s, end, thousands, grouping);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
end = NULL;
|
||||
|
||||
cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base;
|
||||
cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base;
|
||||
|
||||
overflow = 0;
|
||||
i = 0;
|
||||
for (c = *s; c != L_('\0'); c = *++s)
|
||||
{
|
||||
if (s == end)
|
||||
break;
|
||||
if (c >= L_('0') && c <= L_('9'))
|
||||
c -= L_('0');
|
||||
else if (ISALPHA (c))
|
||||
c = TOUPPER (c) - L_('A') + 10;
|
||||
else
|
||||
break;
|
||||
if ((int) c >= base)
|
||||
break;
|
||||
/* Check for overflow. */
|
||||
if (i > cutoff || (i == cutoff && c > cutlim))
|
||||
overflow = 1;
|
||||
else
|
||||
{
|
||||
i *= (unsigned LONG int) base;
|
||||
i += c;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if anything actually happened. */
|
||||
if (s == save)
|
||||
goto noconv;
|
||||
|
||||
/* Store in ENDPTR the address of one character
|
||||
past the last character we converted. */
|
||||
if (endptr != NULL)
|
||||
*endptr = (STRING_TYPE *) s;
|
||||
|
||||
#if !UNSIGNED
|
||||
/* Check for a value that is within the range of
|
||||
`unsigned LONG int', but outside the range of `LONG int'. */
|
||||
if (overflow == 0
|
||||
&& i > (negative
|
||||
? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1
|
||||
: (unsigned LONG int) STRTOL_LONG_MAX))
|
||||
overflow = 1;
|
||||
#endif
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
#if UNSIGNED
|
||||
return STRTOL_ULONG_MAX;
|
||||
#else
|
||||
return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return the result of the appropriate sign. */
|
||||
return negative ? -i : i;
|
||||
|
||||
noconv:
|
||||
/* We must handle a special case here: the base is 0 or 16 and the
|
||||
first two characters are '0' and 'x', but the rest are no
|
||||
hexadecimal digits. This is no error case. We return 0 and
|
||||
ENDPTR points to the `x`. */
|
||||
if (endptr != NULL)
|
||||
{
|
||||
if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
|
||||
&& save[-2] == L_('0'))
|
||||
*endptr = (STRING_TYPE *) &save[-1];
|
||||
else
|
||||
/* There was no number to convert. */
|
||||
*endptr = (STRING_TYPE *) nptr;
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/* External user entry point. */
|
||||
|
||||
|
||||
INT
|
||||
#ifdef weak_function
|
||||
weak_function
|
||||
#endif
|
||||
strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr,
|
||||
int base LOCALE_PARAM_PROTO)
|
||||
{
|
||||
return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM);
|
||||
}
|
33
contrib/diff/lib/strtoll.c
Normal file
33
contrib/diff/lib/strtoll.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* Function to parse a `long long int' from text.
|
||||
Copyright (C) 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define QUAD 1
|
||||
|
||||
#include <strtol.c>
|
||||
|
||||
#ifdef _LIBC
|
||||
# ifdef SHARED
|
||||
# include <shlib-compat.h>
|
||||
|
||||
# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
|
||||
compat_symbol (libc, __strtoll_internal, __strtoq_internal, GLIBC_2_0);
|
||||
# endif
|
||||
|
||||
# endif
|
||||
weak_alias (strtoll, strtoq)
|
||||
#endif
|
20
contrib/diff/lib/strtoul.c
Normal file
20
contrib/diff/lib/strtoul.c
Normal file
@ -0,0 +1,20 @@
|
||||
/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define UNSIGNED 1
|
||||
|
||||
#include "strtol.c"
|
27
contrib/diff/lib/strtoull.c
Normal file
27
contrib/diff/lib/strtoull.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* Function to parse an `unsigned long long int' from text.
|
||||
Copyright (C) 1995, 1996, 1997, 1999 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@gnu.org.
|
||||
|
||||
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. */
|
||||
|
||||
#define QUAD 1
|
||||
|
||||
#include "strtoul.c"
|
||||
|
||||
#ifdef _LIBC
|
||||
strong_alias (__strtoull_internal, __strtouq_internal)
|
||||
weak_alias (strtoull, strtouq)
|
||||
#endif
|
2
contrib/diff/lib/strtoumax.c
Normal file
2
contrib/diff/lib/strtoumax.c
Normal file
@ -0,0 +1,2 @@
|
||||
#define UNSIGNED 1
|
||||
#include "strtoimax.c"
|
344
contrib/diff/lib/tempname.c
Normal file
344
contrib/diff/lib/tempname.c
Normal file
@ -0,0 +1,344 @@
|
||||
/* tempname.c - generate the name of a temporary file.
|
||||
|
||||
Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; 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>
|
||||
#include <assert.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef __set_errno
|
||||
# define __set_errno(Val) errno = (Val)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef P_tmpdir
|
||||
# define P_tmpdir "/tmp"
|
||||
#endif
|
||||
#ifndef TMP_MAX
|
||||
# define TMP_MAX 238328
|
||||
#endif
|
||||
#ifndef __GT_FILE
|
||||
# define __GT_FILE 0
|
||||
# define __GT_BIGFILE 1
|
||||
# define __GT_DIR 2
|
||||
# define __GT_NOCREATE 3
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_FCNTL_H || _LIBC
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_TIME_H || _LIBC
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_STDINT_H || _LIBC
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H || _LIBC
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#if STAT_MACROS_BROKEN
|
||||
# undef S_ISDIR
|
||||
#endif
|
||||
#if !defined S_ISDIR && defined S_IFDIR
|
||||
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#if !S_IRUSR && S_IREAD
|
||||
# define S_IRUSR S_IREAD
|
||||
#endif
|
||||
#if !S_IRUSR
|
||||
# define S_IRUSR 00400
|
||||
#endif
|
||||
#if !S_IWUSR && S_IWRITE
|
||||
# define S_IWUSR S_IWRITE
|
||||
#endif
|
||||
#if !S_IWUSR
|
||||
# define S_IWUSR 00200
|
||||
#endif
|
||||
#if !S_IXUSR && S_IEXEC
|
||||
# define S_IXUSR S_IEXEC
|
||||
#endif
|
||||
#if !S_IXUSR
|
||||
# define S_IXUSR 00100
|
||||
#endif
|
||||
|
||||
#if _LIBC
|
||||
# define struct_stat64 struct stat64
|
||||
#else
|
||||
# define struct_stat64 struct stat
|
||||
# define __getpid getpid
|
||||
# define __gettimeofday gettimeofday
|
||||
# define __mkdir mkdir
|
||||
# define __open open
|
||||
# define __open64 open
|
||||
# define __lxstat64(version, path, buf) lstat (path, buf)
|
||||
# define __xstat64(version, path, buf) stat (path, buf)
|
||||
#endif
|
||||
|
||||
#if ! (HAVE___SECURE_GETENV || _LIBC)
|
||||
# define __secure_getenv getenv
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <hp-timing.h>
|
||||
# if HP_TIMING_AVAIL
|
||||
# define RANDOM_BITS(Var) \
|
||||
if (__builtin_expect (value == UINT64_C (0), 0)) \
|
||||
{ \
|
||||
/* If this is the first time this function is used initialize \
|
||||
the variable we accumulate the value in to some somewhat \
|
||||
random value. If we'd not do this programs at startup time \
|
||||
might have a reduced set of possible names, at least on slow \
|
||||
machines. */ \
|
||||
struct timeval tv; \
|
||||
__gettimeofday (&tv, NULL); \
|
||||
value = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; \
|
||||
} \
|
||||
HP_TIMING_NOW (Var)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Use the widest available unsigned type if uint64_t is not
|
||||
available. The algorithm below extracts a number less than 62**6
|
||||
(approximately 2**35.725) from uint64_t, so ancient hosts where
|
||||
uintmax_t is only 32 bits lose about 3.725 bits of randomness,
|
||||
which is better than not having mkstemp at all. */
|
||||
#if !defined UINT64_MAX && !defined uint64_t
|
||||
# define uint64_t uintmax_t
|
||||
#endif
|
||||
|
||||
/* Return nonzero if DIR is an existent directory. */
|
||||
static int
|
||||
direxists (const char *dir)
|
||||
{
|
||||
struct_stat64 buf;
|
||||
return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode);
|
||||
}
|
||||
|
||||
/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
|
||||
non-null and exists, uses it; otherwise uses the first of $TMPDIR,
|
||||
P_tmpdir, /tmp that exists. Copies into TMPL a template suitable
|
||||
for use with mk[s]temp. Will fail (-1) if DIR is non-null and
|
||||
doesn't exist, none of the searched dirs exists, or there's not
|
||||
enough space in TMPL. */
|
||||
int
|
||||
__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
|
||||
int try_tmpdir)
|
||||
{
|
||||
const char *d;
|
||||
size_t dlen, plen;
|
||||
|
||||
if (!pfx || !pfx[0])
|
||||
{
|
||||
pfx = "file";
|
||||
plen = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
plen = strlen (pfx);
|
||||
if (plen > 5)
|
||||
plen = 5;
|
||||
}
|
||||
|
||||
if (try_tmpdir)
|
||||
{
|
||||
d = __secure_getenv ("TMPDIR");
|
||||
if (d != NULL && direxists (d))
|
||||
dir = d;
|
||||
else if (dir != NULL && direxists (dir))
|
||||
/* nothing */ ;
|
||||
else
|
||||
dir = NULL;
|
||||
}
|
||||
if (dir == NULL)
|
||||
{
|
||||
if (direxists (P_tmpdir))
|
||||
dir = P_tmpdir;
|
||||
else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
|
||||
dir = "/tmp";
|
||||
else
|
||||
{
|
||||
__set_errno (ENOENT);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
dlen = strlen (dir);
|
||||
while (dlen > 1 && dir[dlen - 1] == '/')
|
||||
dlen--; /* remove trailing slashes */
|
||||
|
||||
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
|
||||
if (tmpl_len < dlen + 1 + plen + 6 + 1)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* These are the characters used in temporary filenames. */
|
||||
static const char letters[] =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
/* Generate a temporary file name based on TMPL. TMPL must match the
|
||||
rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
|
||||
does not exist at the time of the call to __gen_tempname. TMPL is
|
||||
overwritten with the result.
|
||||
|
||||
KIND may be one of:
|
||||
__GT_NOCREATE: simply verify that the name does not exist
|
||||
at the time of the call.
|
||||
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
|
||||
and return a read-write fd. The file is mode 0600.
|
||||
__GT_BIGFILE: same as __GT_FILE but use open64().
|
||||
__GT_DIR: create a directory, which will be mode 0700.
|
||||
|
||||
We use a clever algorithm to get hard-to-predict names. */
|
||||
int
|
||||
__gen_tempname (char *tmpl, int kind)
|
||||
{
|
||||
int len;
|
||||
char *XXXXXX;
|
||||
static uint64_t value;
|
||||
uint64_t random_time_bits;
|
||||
unsigned int count;
|
||||
int fd = -1;
|
||||
int save_errno = errno;
|
||||
struct_stat64 st;
|
||||
|
||||
/* A lower bound on the number of temporary files to attempt to
|
||||
generate. The maximum total number of temporary file names that
|
||||
can exist for a given template is 62**6. It should never be
|
||||
necessary to try all these combinations. Instead if a reasonable
|
||||
number of names is tried (we define reasonable as 62**3) fail to
|
||||
give the system administrator the chance to remove the problems. */
|
||||
unsigned int attempts_min = 62 * 62 * 62;
|
||||
|
||||
/* The number of times to attempt to generate a temporary file. To
|
||||
conform to POSIX, this must be no smaller than TMP_MAX. */
|
||||
unsigned int attempts = attempts_min < TMP_MAX ? TMP_MAX : attempts_min;
|
||||
|
||||
len = strlen (tmpl);
|
||||
if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This is where the Xs start. */
|
||||
XXXXXX = &tmpl[len - 6];
|
||||
|
||||
/* Get some more or less random data. */
|
||||
#ifdef RANDOM_BITS
|
||||
RANDOM_BITS (random_time_bits);
|
||||
#else
|
||||
# if HAVE_GETTIMEOFDAY || _LIBC
|
||||
{
|
||||
struct timeval tv;
|
||||
__gettimeofday (&tv, NULL);
|
||||
random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec;
|
||||
}
|
||||
# else
|
||||
random_time_bits = time (NULL);
|
||||
# endif
|
||||
#endif
|
||||
value += random_time_bits ^ __getpid ();
|
||||
|
||||
for (count = 0; count < attempts; value += 7777, ++count)
|
||||
{
|
||||
uint64_t v = value;
|
||||
|
||||
/* Fill in the random bits. */
|
||||
XXXXXX[0] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[1] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[2] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[3] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[4] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[5] = letters[v % 62];
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
case __GT_FILE:
|
||||
fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
break;
|
||||
|
||||
case __GT_BIGFILE:
|
||||
fd = __open64 (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
break;
|
||||
|
||||
case __GT_DIR:
|
||||
fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
break;
|
||||
|
||||
case __GT_NOCREATE:
|
||||
/* This case is backward from the other three. __gen_tempname
|
||||
succeeds if __xstat fails because the name does not exist.
|
||||
Note the continue to bypass the common logic at the bottom
|
||||
of the loop. */
|
||||
if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
/* Give up now. */
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
|
||||
default:
|
||||
assert (! "invalid KIND in __gen_tempname");
|
||||
}
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
return fd;
|
||||
}
|
||||
else if (errno != EEXIST)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We got out of the loop because we ran out of combinations to try. */
|
||||
__set_errno (EEXIST);
|
||||
return -1;
|
||||
}
|
69
contrib/diff/lib/time_r.c
Normal file
69
contrib/diff/lib/time_r.c
Normal file
@ -0,0 +1,69 @@
|
||||
/* Reentrant time functions like localtime_r.
|
||||
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "time_r.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static char *
|
||||
copy_string_result (char *dest, char const *src)
|
||||
{
|
||||
if (! src)
|
||||
return 0;
|
||||
return strcpy (dest, src);
|
||||
}
|
||||
|
||||
static struct tm *
|
||||
copy_tm_result (struct tm *dest, struct tm const *src)
|
||||
{
|
||||
if (! src)
|
||||
return 0;
|
||||
*dest = *src;
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
asctime_r (struct tm const * restrict tm, char * restrict buf)
|
||||
{
|
||||
return copy_string_result (buf, asctime (tm));
|
||||
}
|
||||
|
||||
char *
|
||||
ctime_r (time_t const *t, char *buf)
|
||||
{
|
||||
return copy_string_result (buf, ctime (t));
|
||||
}
|
||||
|
||||
struct tm *
|
||||
gmtime_r (time_t const * restrict t, struct tm * restrict tp)
|
||||
{
|
||||
return copy_tm_result (tp, gmtime (t));
|
||||
}
|
||||
|
||||
struct tm *
|
||||
localtime_r (time_t const * restrict t, struct tm * restrict tp)
|
||||
{
|
||||
return copy_tm_result (tp, localtime (t));
|
||||
}
|
46
contrib/diff/lib/time_r.h
Normal file
46
contrib/diff/lib/time_r.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* Reentrant time functions like localtime_r.
|
||||
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#ifndef _TIME_R_H
|
||||
#define _TIME_R_H
|
||||
|
||||
/* Include <time.h> first, since it may declare these functions with
|
||||
signatures that disagree with POSIX, and we don't want to rename
|
||||
those declarations. */
|
||||
#include <time.h>
|
||||
|
||||
#if !HAVE_TIME_R_POSIX
|
||||
# undef asctime_r
|
||||
# undef ctime_r
|
||||
# undef gmtime_r
|
||||
# undef localtime_r
|
||||
|
||||
# define asctime_r rpl_asctime_r
|
||||
# define ctime_r rpl_ctime_r
|
||||
# define gmtime_r rpl_gmtime_r
|
||||
# define localtime_r rpl_localtime_r
|
||||
|
||||
char *asctime_r (struct tm const * restrict, char * restrict);
|
||||
char *ctime_r (time_t const *, char *);
|
||||
struct tm *gmtime_r (time_t const * restrict, struct tm * restrict);
|
||||
struct tm *localtime_r (time_t const * restrict, struct tm * restrict);
|
||||
#endif
|
||||
|
||||
#endif
|
3
contrib/diff/lib/umaxtostr.c
Normal file
3
contrib/diff/lib/umaxtostr.c
Normal file
@ -0,0 +1,3 @@
|
||||
#define inttostr umaxtostr
|
||||
#define inttype uintmax_t
|
||||
#include "inttostr.c"
|
132
contrib/diff/lib/unlocked-io.h
Normal file
132
contrib/diff/lib/unlocked-io.h
Normal file
@ -0,0 +1,132 @@
|
||||
/* Prefer faster, non-thread-safe stdio functions if available.
|
||||
|
||||
Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#ifndef UNLOCKED_IO_H
|
||||
# define UNLOCKED_IO_H 1
|
||||
|
||||
# ifndef USE_UNLOCKED_IO
|
||||
# define USE_UNLOCKED_IO 1
|
||||
# endif
|
||||
|
||||
# if USE_UNLOCKED_IO
|
||||
|
||||
/* These are wrappers for functions/macros from the GNU C library, and
|
||||
from other C libraries supporting POSIX's optional thread-safe functions.
|
||||
|
||||
The standard I/O functions are thread-safe. These *_unlocked ones are
|
||||
more efficient but not thread-safe. That they're not thread-safe is
|
||||
fine since all of the applications in this package are single threaded.
|
||||
|
||||
Also, some code that is shared with the GNU C library may invoke
|
||||
the *_unlocked functions directly. On hosts that lack those
|
||||
functions, invoke the non-thread-safe versions instead. */
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
# if HAVE_DECL_CLEARERR_UNLOCKED
|
||||
# undef clearerr
|
||||
# define clearerr(x) clearerr_unlocked (x)
|
||||
# else
|
||||
# define clearerr_unlocked(x) clearerr (x)
|
||||
# endif
|
||||
# if HAVE_DECL_FEOF_UNLOCKED
|
||||
# undef feof
|
||||
# define feof(x) feof_unlocked (x)
|
||||
# else
|
||||
# define feof_unlocked(x) feof (x)
|
||||
# endif
|
||||
# if HAVE_DECL_FERROR_UNLOCKED
|
||||
# undef ferror
|
||||
# define ferror(x) ferror_unlocked (x)
|
||||
# else
|
||||
# define ferror_unlocked(x) ferror (x)
|
||||
# endif
|
||||
# if HAVE_DECL_FFLUSH_UNLOCKED
|
||||
# undef fflush
|
||||
# define fflush(x) fflush_unlocked (x)
|
||||
# else
|
||||
# define fflush_unlocked(x) fflush (x)
|
||||
# endif
|
||||
# if HAVE_DECL_FGETS_UNLOCKED
|
||||
# undef fgets
|
||||
# define fgets(x,y,z) fgets_unlocked (x,y,z)
|
||||
# else
|
||||
# define fgets_unlocked(x,y,z) fgets (x,y,z)
|
||||
# endif
|
||||
# if HAVE_DECL_FPUTC_UNLOCKED
|
||||
# undef fputc
|
||||
# define fputc(x,y) fputc_unlocked (x,y)
|
||||
# else
|
||||
# define fputc_unlocked(x,y) fputc (x,y)
|
||||
# endif
|
||||
# if HAVE_DECL_FPUTS_UNLOCKED
|
||||
# undef fputs
|
||||
# define fputs(x,y) fputs_unlocked (x,y)
|
||||
# else
|
||||
# define fputs_unlocked(x,y) fputs (x,y)
|
||||
# endif
|
||||
# if HAVE_DECL_FREAD_UNLOCKED
|
||||
# undef fread
|
||||
# define fread(w,x,y,z) fread_unlocked (w,x,y,z)
|
||||
# else
|
||||
# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
|
||||
# endif
|
||||
# if HAVE_DECL_FWRITE_UNLOCKED
|
||||
# undef fwrite
|
||||
# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
|
||||
# else
|
||||
# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
|
||||
# endif
|
||||
# if HAVE_DECL_GETC_UNLOCKED
|
||||
# undef getc
|
||||
# define getc(x) getc_unlocked (x)
|
||||
# else
|
||||
# define getc_unlocked(x) getc (x)
|
||||
# endif
|
||||
# if HAVE_DECL_GETCHAR_UNLOCKED
|
||||
# undef getchar
|
||||
# define getchar() getchar_unlocked ()
|
||||
# else
|
||||
# define getchar_unlocked() getchar ()
|
||||
# endif
|
||||
# if HAVE_DECL_PUTC_UNLOCKED
|
||||
# undef putc
|
||||
# define putc(x,y) putc_unlocked (x,y)
|
||||
# else
|
||||
# define putc_unlocked(x,y) putc (x,y)
|
||||
# endif
|
||||
# if HAVE_DECL_PUTCHAR_UNLOCKED
|
||||
# undef putchar
|
||||
# define putchar(x) putchar_unlocked (x)
|
||||
# else
|
||||
# define putchar_unlocked(x) putchar (x)
|
||||
# endif
|
||||
|
||||
# undef flockfile
|
||||
# define flockfile(x) ((void) 0)
|
||||
|
||||
# undef ftrylockfile
|
||||
# define ftrylockfile(x) 0
|
||||
|
||||
# undef funlockfile
|
||||
# define funlockfile(x) ((void) 0)
|
||||
|
||||
# endif /* USE_UNLOCKED_IO */
|
||||
#endif /* UNLOCKED_IO_H */
|
176
contrib/diff/lib/version-etc.c
Normal file
176
contrib/diff/lib/version-etc.c
Normal file
@ -0,0 +1,176 @@
|
||||
/* Utility to help print --version output in a consistent format.
|
||||
Copyright (C) 1999-2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Specification. */
|
||||
#include "version-etc.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "unlocked-io.h"
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
|
||||
/* Default copyright goes to the FSF. */
|
||||
|
||||
const char* version_etc_copyright =
|
||||
/* Do *not* mark this string for translation. */
|
||||
"Copyright (C) 2004 Free Software Foundation, Inc.";
|
||||
|
||||
|
||||
/* Like version_etc, below, but with the NULL-terminated author list
|
||||
provided via a variable of type va_list. */
|
||||
void
|
||||
version_etc_va (FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, va_list authors)
|
||||
{
|
||||
unsigned int n_authors;
|
||||
|
||||
/* Count the number of authors. */
|
||||
{
|
||||
va_list tmp_authors;
|
||||
|
||||
#ifdef __va_copy
|
||||
__va_copy (tmp_authors, authors);
|
||||
#else
|
||||
tmp_authors = authors;
|
||||
#endif
|
||||
|
||||
n_authors = 0;
|
||||
while (va_arg (tmp_authors, const char *) != NULL)
|
||||
++n_authors;
|
||||
}
|
||||
|
||||
if (command_name)
|
||||
fprintf (stream, "%s (%s) %s\n", command_name, package, version);
|
||||
else
|
||||
fprintf (stream, "%s %s\n", package, version);
|
||||
|
||||
switch (n_authors)
|
||||
{
|
||||
case 0:
|
||||
/* The caller must provide at least one author name. */
|
||||
abort ();
|
||||
case 1:
|
||||
/* TRANSLATORS: %s denotes an author name. */
|
||||
vfprintf (stream, _("Written by %s.\n"), authors);
|
||||
break;
|
||||
case 2:
|
||||
/* TRANSLATORS: Each %s denotes an author name. */
|
||||
vfprintf (stream, _("Written by %s and %s.\n"), authors);
|
||||
break;
|
||||
case 3:
|
||||
/* TRANSLATORS: Each %s denotes an author name. */
|
||||
vfprintf (stream, _("Written by %s, %s, and %s.\n"), authors);
|
||||
break;
|
||||
case 4:
|
||||
/* TRANSLATORS: Each %s denotes an author name.
|
||||
You can use line breaks, estimating that each author name occupies
|
||||
ca. 16 screen columns and that a screen line has ca. 80 columns. */
|
||||
vfprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), authors);
|
||||
break;
|
||||
case 5:
|
||||
/* TRANSLATORS: Each %s denotes an author name.
|
||||
You can use line breaks, estimating that each author name occupies
|
||||
ca. 16 screen columns and that a screen line has ca. 80 columns. */
|
||||
vfprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), authors);
|
||||
break;
|
||||
case 6:
|
||||
/* TRANSLATORS: Each %s denotes an author name.
|
||||
You can use line breaks, estimating that each author name occupies
|
||||
ca. 16 screen columns and that a screen line has ca. 80 columns. */
|
||||
vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"),
|
||||
authors);
|
||||
break;
|
||||
case 7:
|
||||
/* TRANSLATORS: Each %s denotes an author name.
|
||||
You can use line breaks, estimating that each author name occupies
|
||||
ca. 16 screen columns and that a screen line has ca. 80 columns. */
|
||||
vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"),
|
||||
authors);
|
||||
break;
|
||||
case 8:
|
||||
/* TRANSLATORS: Each %s denotes an author name.
|
||||
You can use line breaks, estimating that each author name occupies
|
||||
ca. 16 screen columns and that a screen line has ca. 80 columns. */
|
||||
vfprintf (stream, _("\
|
||||
Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"),
|
||||
authors);
|
||||
break;
|
||||
case 9:
|
||||
/* TRANSLATORS: Each %s denotes an author name.
|
||||
You can use line breaks, estimating that each author name occupies
|
||||
ca. 16 screen columns and that a screen line has ca. 80 columns. */
|
||||
vfprintf (stream, _("\
|
||||
Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"),
|
||||
authors);
|
||||
break;
|
||||
default:
|
||||
/* 10 or more authors. Use an abbreviation, since the human reader
|
||||
will probably not want to read the entire list anyway. */
|
||||
/* TRANSLATORS: Each %s denotes an author name.
|
||||
You can use line breaks, estimating that each author name occupies
|
||||
ca. 16 screen columns and that a screen line has ca. 80 columns. */
|
||||
vfprintf (stream, _("\
|
||||
Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
|
||||
authors);
|
||||
break;
|
||||
}
|
||||
va_end (authors);
|
||||
putc ('\n', stream);
|
||||
|
||||
fputs (version_etc_copyright, stream);
|
||||
putc ('\n', stream);
|
||||
|
||||
fputs (_("\
|
||||
This is free software; see the source for copying conditions. There is NO\n\
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"),
|
||||
stream);
|
||||
}
|
||||
|
||||
|
||||
/* Display the --version information the standard way.
|
||||
|
||||
If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of
|
||||
the program. The formats are therefore:
|
||||
|
||||
PACKAGE VERSION
|
||||
|
||||
or
|
||||
|
||||
COMMAND_NAME (PACKAGE) VERSION.
|
||||
|
||||
The author names are passed as separate arguments, with an additional
|
||||
NULL argument at the end. */
|
||||
void
|
||||
version_etc (FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, /* const char *author1, ...*/ ...)
|
||||
{
|
||||
va_list authors;
|
||||
|
||||
va_start (authors, version);
|
||||
version_etc_va (stream, command_name, package, version, authors);
|
||||
}
|
37
contrib/diff/lib/version-etc.h
Normal file
37
contrib/diff/lib/version-etc.h
Normal file
@ -0,0 +1,37 @@
|
||||
/* Utility to help print --version output in a consistent format.
|
||||
Copyright (C) 1999, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#ifndef VERSION_ETC_H
|
||||
# define VERSION_ETC_H 1
|
||||
|
||||
# include <stdarg.h>
|
||||
# include <stdio.h>
|
||||
|
||||
extern const char *version_etc_copyright;
|
||||
|
||||
extern void version_etc_va (FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, va_list authors);
|
||||
|
||||
extern void version_etc (FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version,
|
||||
/* const char *author1, ...*/ ...);
|
||||
|
||||
#endif /* VERSION_ETC_H */
|
72
contrib/diff/lib/waitpid.c
Normal file
72
contrib/diff/lib/waitpid.c
Normal file
@ -0,0 +1,72 @@
|
||||
/* Emulate waitpid on systems that just have wait.
|
||||
Copyright (C) 1994, 1995, 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; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#define WAITPID_CHILDREN 8
|
||||
static pid_t waited_pid[WAITPID_CHILDREN];
|
||||
static int waited_status[WAITPID_CHILDREN];
|
||||
|
||||
pid_t
|
||||
waitpid (pid_t pid, int *stat_loc, int options)
|
||||
{
|
||||
int i;
|
||||
pid_t p;
|
||||
|
||||
if (!options && (pid == -1 || 0 < pid))
|
||||
{
|
||||
/* If we have already waited for this child, return it immediately. */
|
||||
for (i = 0; i < WAITPID_CHILDREN; i++)
|
||||
{
|
||||
p = waited_pid[i];
|
||||
if (p && (p == pid || pid == -1))
|
||||
{
|
||||
waited_pid[i] = 0;
|
||||
goto success;
|
||||
}
|
||||
}
|
||||
|
||||
/* The child has not returned yet; wait for it, accumulating status. */
|
||||
for (i = 0; i < WAITPID_CHILDREN; i++)
|
||||
if (! waited_pid[i])
|
||||
{
|
||||
p = wait (&waited_status[i]);
|
||||
if (p < 0)
|
||||
return p;
|
||||
if (p == pid || pid == -1)
|
||||
goto success;
|
||||
waited_pid[i] = p;
|
||||
}
|
||||
}
|
||||
|
||||
/* We cannot emulate this wait call, e.g. because of too many children. */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
|
||||
success:
|
||||
if (stat_loc)
|
||||
*stat_loc = waited_status[i];
|
||||
return p;
|
||||
}
|
87
contrib/diff/lib/xalloc.h
Normal file
87
contrib/diff/lib/xalloc.h
Normal file
@ -0,0 +1,87 @@
|
||||
/* xalloc.h -- malloc with out-of-memory checking
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef XALLOC_H_
|
||||
# define XALLOC_H_
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# endif
|
||||
|
||||
/* If this pointer is non-zero, run the specified function upon each
|
||||
allocation failure. It is initialized to zero. */
|
||||
extern void (*xalloc_fail_func) (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 two previous items. It exits with status
|
||||
exit_failure (defined in exitfail.h). This is the
|
||||
function to call when one wants the program to die because of a
|
||||
memory allocation failure. */
|
||||
extern void xalloc_die (void) ATTRIBUTE_NORETURN;
|
||||
|
||||
void *xmalloc (size_t s);
|
||||
void *xnmalloc (size_t n, size_t s);
|
||||
void *xzalloc (size_t s);
|
||||
void *xcalloc (size_t n, size_t s);
|
||||
void *xrealloc (void *p, size_t s);
|
||||
void *xnrealloc (void *p, size_t n, size_t s);
|
||||
void *x2realloc (void *p, size_t *pn);
|
||||
void *x2nrealloc (void *p, size_t *pn, size_t s);
|
||||
void *xclone (void const *p, size_t s);
|
||||
char *xstrdup (const char *str);
|
||||
|
||||
/* Return 1 if an array of N objects, each of size S, cannot exist due
|
||||
to size arithmetic overflow. S must be positive and N must be
|
||||
nonnegative. This is a macro, not an inline function, so that it
|
||||
works correctly even when SIZE_MAX < N.
|
||||
|
||||
By gnulib convention, SIZE_MAX represents overflow in size
|
||||
calculations, so the conservative dividend to use here is
|
||||
SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
|
||||
However, malloc (SIZE_MAX) fails on all known hosts where
|
||||
sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
|
||||
exactly-SIZE_MAX allocations on such hosts; this avoids a test and
|
||||
branch when S is known to be 1. */
|
||||
# define xalloc_oversized(n, s) \
|
||||
((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
|
||||
|
||||
/* These macros are deprecated; they will go away soon, and are retained
|
||||
temporarily only to ease conversion to the functions described above. */
|
||||
# define CCLONE(p, n) xclone (p, (n) * sizeof *(p))
|
||||
# define CLONE(p) xclone (p, sizeof *(p))
|
||||
# define NEW(type, var) type *var = xmalloc (sizeof (type))
|
||||
# define XCALLOC(type, n) xcalloc (n, sizeof (type))
|
||||
# define XMALLOC(type, n) xnmalloc (n, sizeof (type))
|
||||
# define XREALLOC(p, type, n) xnrealloc (p, n, sizeof (type))
|
||||
# define XFREE(p) free (p)
|
||||
|
||||
#endif /* !XALLOC_H_ */
|
255
contrib/diff/lib/xmalloc.c
Normal file
255
contrib/diff/lib/xmalloc.c
Normal file
@ -0,0 +1,255 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2003,
|
||||
1999, 2000, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; 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 "xalloc.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
#define N_(msgid) msgid
|
||||
|
||||
#include "error.h"
|
||||
#include "exitfail.h"
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MALLOC
|
||||
"you must run the autoconf test for a GNU libc compatible malloc"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_REALLOC
|
||||
"you must run the autoconf test for a GNU libc compatible realloc"
|
||||
#endif
|
||||
|
||||
/* If non NULL, call this function when memory is exhausted. */
|
||||
void (*xalloc_fail_func) (void) = 0;
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message
|
||||
before exiting when memory is exhausted. Goes through gettext. */
|
||||
char const xalloc_msg_memory_exhausted[] = N_("memory exhausted");
|
||||
|
||||
void
|
||||
xalloc_die (void)
|
||||
{
|
||||
if (xalloc_fail_func)
|
||||
(*xalloc_fail_func) ();
|
||||
error (exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
|
||||
/* The `noreturn' cannot be given to error, since it may return if
|
||||
its first argument is 0. To help compilers understand the
|
||||
xalloc_die does terminate, call abort. */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* Allocate an array of N objects, each with S bytes of memory,
|
||||
dynamically, with error checking. S must be nonzero. */
|
||||
|
||||
static inline void *
|
||||
xnmalloc_inline (size_t n, size_t s)
|
||||
{
|
||||
void *p;
|
||||
if (xalloc_oversized (n, s) || ! (p = malloc (n * s)))
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
void *
|
||||
xnmalloc (size_t n, size_t s)
|
||||
{
|
||||
return xnmalloc_inline (n, s);
|
||||
}
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
void *
|
||||
xmalloc (size_t n)
|
||||
{
|
||||
return xnmalloc_inline (n, 1);
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to an array of N
|
||||
objects each of S bytes, with error checking. S must be nonzero. */
|
||||
|
||||
static inline void *
|
||||
xnrealloc_inline (void *p, size_t n, size_t s)
|
||||
{
|
||||
if (xalloc_oversized (n, s) || ! (p = realloc (p, n * s)))
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
void *
|
||||
xnrealloc (void *p, size_t n, size_t s)
|
||||
{
|
||||
return xnrealloc_inline (p, n, s);
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. */
|
||||
|
||||
void *
|
||||
xrealloc (void *p, size_t n)
|
||||
{
|
||||
return xnrealloc_inline (p, n, 1);
|
||||
}
|
||||
|
||||
|
||||
/* If P is null, allocate a block of at least *PN such objects;
|
||||
otherwise, reallocate P so that it contains more than *PN objects
|
||||
each of S bytes. *PN must be nonzero unless P is null, and S must
|
||||
be nonzero. Set *PN to the new number of objects, and return the
|
||||
pointer to the new block. *PN is never set to zero, and the
|
||||
returned pointer is never null.
|
||||
|
||||
Repeated reallocations are guaranteed to make progress, either by
|
||||
allocating an initial block with a nonzero size, or by allocating a
|
||||
larger block.
|
||||
|
||||
In the following implementation, nonzero sizes are doubled so that
|
||||
repeated reallocations have O(N log N) overall cost rather than
|
||||
O(N**2) cost, but the specification for this function does not
|
||||
guarantee that sizes are doubled.
|
||||
|
||||
Here is an example of use:
|
||||
|
||||
int *p = NULL;
|
||||
size_t used = 0;
|
||||
size_t allocated = 0;
|
||||
|
||||
void
|
||||
append_int (int value)
|
||||
{
|
||||
if (used == allocated)
|
||||
p = x2nrealloc (p, &allocated, sizeof *p);
|
||||
p[used++] = value;
|
||||
}
|
||||
|
||||
This causes x2nrealloc to allocate a block of some nonzero size the
|
||||
first time it is called.
|
||||
|
||||
To have finer-grained control over the initial size, set *PN to a
|
||||
nonzero value before calling this function with P == NULL. For
|
||||
example:
|
||||
|
||||
int *p = NULL;
|
||||
size_t used = 0;
|
||||
size_t allocated = 0;
|
||||
size_t allocated1 = 1000;
|
||||
|
||||
void
|
||||
append_int (int value)
|
||||
{
|
||||
if (used == allocated)
|
||||
{
|
||||
p = x2nrealloc (p, &allocated1, sizeof *p);
|
||||
allocated = allocated1;
|
||||
}
|
||||
p[used++] = value;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
static inline void *
|
||||
x2nrealloc_inline (void *p, size_t *pn, size_t s)
|
||||
{
|
||||
size_t n = *pn;
|
||||
|
||||
if (! p)
|
||||
{
|
||||
if (! n)
|
||||
{
|
||||
/* The approximate size to use for initial small allocation
|
||||
requests, when the invoking code specifies an old size of
|
||||
zero. 64 bytes is the largest "small" request for the
|
||||
GNU C library malloc. */
|
||||
enum { DEFAULT_MXFAST = 64 };
|
||||
|
||||
n = DEFAULT_MXFAST / s;
|
||||
n += !n;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SIZE_MAX / 2 / s < n)
|
||||
xalloc_die ();
|
||||
n *= 2;
|
||||
}
|
||||
|
||||
*pn = n;
|
||||
return xrealloc (p, n * s);
|
||||
}
|
||||
|
||||
void *
|
||||
x2nrealloc (void *p, size_t *pn, size_t s)
|
||||
{
|
||||
return x2nrealloc_inline (p, pn, s);
|
||||
}
|
||||
|
||||
/* If P is null, allocate a block of at least *PN bytes; otherwise,
|
||||
reallocate P so that it contains more than *PN bytes. *PN must be
|
||||
nonzero unless P is null. Set *PN to the new block's size, and
|
||||
return the pointer to the new block. *PN is never set to zero, and
|
||||
the returned pointer is never null. */
|
||||
|
||||
void *
|
||||
x2realloc (void *p, size_t *pn)
|
||||
{
|
||||
return x2nrealloc_inline (p, pn, 1);
|
||||
}
|
||||
|
||||
/* Allocate S bytes of zeroed memory dynamically, with error checking.
|
||||
There's no need for xnzalloc (N, S), since it would be equivalent
|
||||
to xcalloc (N, S). */
|
||||
|
||||
void *
|
||||
xzalloc (size_t s)
|
||||
{
|
||||
return memset (xmalloc (s), 0, s);
|
||||
}
|
||||
|
||||
/* Allocate zeroed memory for N elements of S bytes, with error
|
||||
checking. S must be nonzero. */
|
||||
|
||||
void *
|
||||
xcalloc (size_t n, size_t s)
|
||||
{
|
||||
void *p;
|
||||
/* Test for overflow, since some calloc implementations don't have
|
||||
proper overflow checks. */
|
||||
if (xalloc_oversized (n, s) || ! (p = calloc (n, s)))
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Clone an object P of size S, with error checking. There's no need
|
||||
for xnclone (P, N, S), since xclone (P, N * S) works without any
|
||||
need for an arithmetic overflow check. */
|
||||
|
||||
void *
|
||||
xclone (void const *p, size_t s)
|
||||
{
|
||||
return memcpy (xmalloc (s), p, s);
|
||||
}
|
33
contrib/diff/lib/xstrdup.c
Normal file
33
contrib/diff/lib/xstrdup.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* xstrdup.c -- copy a string with out of memory checking
|
||||
Copyright (C) 1990, 1996, 1998, 2001, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Specification. */
|
||||
#include "xalloc.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Return a newly allocated copy of STRING. */
|
||||
|
||||
char *
|
||||
xstrdup (const char *string)
|
||||
{
|
||||
return xclone (string, strlen (string) + 1);
|
||||
}
|
295
contrib/diff/lib/xstrtol.c
Normal file
295
contrib/diff/lib/xstrtol.c
Normal file
@ -0,0 +1,295 @@
|
||||
/* A more useful interface to strtol.
|
||||
|
||||
Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifndef __strtol
|
||||
# define __strtol strtol
|
||||
# define __strtol_t long int
|
||||
# define __xstrtol xstrtol
|
||||
# define STRTOL_T_MINIMUM LONG_MIN
|
||||
# define STRTOL_T_MAXIMUM LONG_MAX
|
||||
#endif
|
||||
|
||||
/* Some pre-ANSI implementations (e.g. SunOS 4)
|
||||
need stderr defined if assertion checking is enabled. */
|
||||
#include <stdio.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
/* The extra casts work around common compiler bugs. */
|
||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
|
||||
: (t) 0))
|
||||
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
|
||||
|
||||
#ifndef STRTOL_T_MINIMUM
|
||||
# define STRTOL_T_MINIMUM TYPE_MINIMUM (__strtol_t)
|
||||
# define STRTOL_T_MAXIMUM TYPE_MAXIMUM (__strtol_t)
|
||||
#endif
|
||||
|
||||
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
#endif
|
||||
|
||||
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
|
||||
|
||||
#include "xstrtol.h"
|
||||
|
||||
#if !HAVE_DECL_STRTOIMAX && !defined strtoimax
|
||||
intmax_t strtoimax ();
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STRTOUMAX && !defined strtoumax
|
||||
uintmax_t strtoumax ();
|
||||
#endif
|
||||
|
||||
static strtol_error
|
||||
bkm_scale (__strtol_t *x, int scale_factor)
|
||||
{
|
||||
if (TYPE_SIGNED (__strtol_t) && *x < STRTOL_T_MINIMUM / scale_factor)
|
||||
{
|
||||
*x = STRTOL_T_MINIMUM;
|
||||
return LONGINT_OVERFLOW;
|
||||
}
|
||||
if (STRTOL_T_MAXIMUM / scale_factor < *x)
|
||||
{
|
||||
*x = STRTOL_T_MAXIMUM;
|
||||
return LONGINT_OVERFLOW;
|
||||
}
|
||||
*x *= scale_factor;
|
||||
return LONGINT_OK;
|
||||
}
|
||||
|
||||
static strtol_error
|
||||
bkm_scale_by_power (__strtol_t *x, int base, int power)
|
||||
{
|
||||
strtol_error err = LONGINT_OK;
|
||||
while (power--)
|
||||
err |= bkm_scale (x, base);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* FIXME: comment. */
|
||||
|
||||
strtol_error
|
||||
__xstrtol (const char *s, char **ptr, int strtol_base,
|
||||
__strtol_t *val, const char *valid_suffixes)
|
||||
{
|
||||
char *t_ptr;
|
||||
char **p;
|
||||
__strtol_t tmp;
|
||||
strtol_error err = LONGINT_OK;
|
||||
|
||||
assert (0 <= strtol_base && strtol_base <= 36);
|
||||
|
||||
p = (ptr ? ptr : &t_ptr);
|
||||
|
||||
if (! TYPE_SIGNED (__strtol_t))
|
||||
{
|
||||
const char *q = s;
|
||||
while (ISSPACE ((unsigned char) *q))
|
||||
++q;
|
||||
if (*q == '-')
|
||||
return LONGINT_INVALID;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
tmp = __strtol (s, p, strtol_base);
|
||||
|
||||
if (*p == s)
|
||||
{
|
||||
/* If there is no number but there is a valid suffix, assume the
|
||||
number is 1. The string is invalid otherwise. */
|
||||
if (valid_suffixes && **p && strchr (valid_suffixes, **p))
|
||||
tmp = 1;
|
||||
else
|
||||
return LONGINT_INVALID;
|
||||
}
|
||||
else if (errno != 0)
|
||||
{
|
||||
if (errno != ERANGE)
|
||||
return LONGINT_INVALID;
|
||||
err = LONGINT_OVERFLOW;
|
||||
}
|
||||
|
||||
/* Let valid_suffixes == NULL mean `allow any suffix'. */
|
||||
/* FIXME: update all callers except the ones that allow suffixes
|
||||
after the number, changing last parameter NULL to `""'. */
|
||||
if (!valid_suffixes)
|
||||
{
|
||||
*val = tmp;
|
||||
return err;
|
||||
}
|
||||
|
||||
if (**p != '\0')
|
||||
{
|
||||
int base = 1024;
|
||||
int suffixes = 1;
|
||||
strtol_error overflow;
|
||||
|
||||
if (!strchr (valid_suffixes, **p))
|
||||
{
|
||||
*val = tmp;
|
||||
return err | LONGINT_INVALID_SUFFIX_CHAR;
|
||||
}
|
||||
|
||||
if (strchr (valid_suffixes, '0'))
|
||||
{
|
||||
/* The ``valid suffix'' '0' is a special flag meaning that
|
||||
an optional second suffix is allowed, which can change
|
||||
the base. A suffix "B" (e.g. "100MB") stands for a power
|
||||
of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for
|
||||
a power of 1024. If no suffix (e.g. "100M"), assume
|
||||
power-of-1024. */
|
||||
|
||||
switch (p[0][1])
|
||||
{
|
||||
case 'i':
|
||||
if (p[0][2] == 'B')
|
||||
suffixes += 2;
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
case 'D': /* 'D' is obsolescent */
|
||||
base = 1000;
|
||||
suffixes++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (**p)
|
||||
{
|
||||
case 'b':
|
||||
overflow = bkm_scale (&tmp, 512);
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
overflow = bkm_scale (&tmp, 1024);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
overflow = 0;
|
||||
break;
|
||||
|
||||
case 'E': /* exa or exbi */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 6);
|
||||
break;
|
||||
|
||||
case 'G': /* giga or gibi */
|
||||
case 'g': /* 'g' is undocumented; for compatibility only */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 3);
|
||||
break;
|
||||
|
||||
case 'k': /* kilo */
|
||||
case 'K': /* kibi */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 1);
|
||||
break;
|
||||
|
||||
case 'M': /* mega or mebi */
|
||||
case 'm': /* 'm' is undocumented; for compatibility only */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 2);
|
||||
break;
|
||||
|
||||
case 'P': /* peta or pebi */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 5);
|
||||
break;
|
||||
|
||||
case 'T': /* tera or tebi */
|
||||
case 't': /* 't' is undocumented; for compatibility only */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 4);
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
overflow = bkm_scale (&tmp, 2);
|
||||
break;
|
||||
|
||||
case 'Y': /* yotta or 2**80 */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 8);
|
||||
break;
|
||||
|
||||
case 'Z': /* zetta or 2**70 */
|
||||
overflow = bkm_scale_by_power (&tmp, base, 7);
|
||||
break;
|
||||
|
||||
default:
|
||||
*val = tmp;
|
||||
return err | LONGINT_INVALID_SUFFIX_CHAR;
|
||||
}
|
||||
|
||||
err |= overflow;
|
||||
*p += suffixes;
|
||||
if (**p)
|
||||
err |= LONGINT_INVALID_SUFFIX_CHAR;
|
||||
}
|
||||
|
||||
*val = tmp;
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef TESTING_XSTRTO
|
||||
|
||||
# include <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 */
|
91
contrib/diff/lib/xstrtol.h
Normal file
91
contrib/diff/lib/xstrtol.h
Normal file
@ -0,0 +1,91 @@
|
||||
/* A more useful interface to strtol.
|
||||
|
||||
Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef XSTRTOL_H_
|
||||
# define XSTRTOL_H_ 1
|
||||
|
||||
# include "exitfail.h"
|
||||
|
||||
/* Get uintmax_t. */
|
||||
# if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
# else
|
||||
# if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef _STRTOL_ERROR
|
||||
enum strtol_error
|
||||
{
|
||||
LONGINT_OK = 0,
|
||||
|
||||
/* These two values can be ORed together, to indicate that both
|
||||
errors occurred. */
|
||||
LONGINT_OVERFLOW = 1,
|
||||
LONGINT_INVALID_SUFFIX_CHAR = 2,
|
||||
|
||||
LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR
|
||||
| LONGINT_OVERFLOW),
|
||||
LONGINT_INVALID = 4
|
||||
};
|
||||
typedef enum strtol_error strtol_error;
|
||||
# endif
|
||||
|
||||
# define _DECLARE_XSTRTOL(name, type) \
|
||||
strtol_error name (const char *, char **, int, type *, const char *);
|
||||
_DECLARE_XSTRTOL (xstrtol, long int)
|
||||
_DECLARE_XSTRTOL (xstrtoul, unsigned long int)
|
||||
_DECLARE_XSTRTOL (xstrtoimax, intmax_t)
|
||||
_DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
|
||||
|
||||
# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \
|
||||
do \
|
||||
{ \
|
||||
switch ((Err)) \
|
||||
{ \
|
||||
default: \
|
||||
abort (); \
|
||||
\
|
||||
case LONGINT_INVALID: \
|
||||
error ((Exit_code), 0, "invalid %s `%s'", \
|
||||
(Argument_type_string), (Str)); \
|
||||
break; \
|
||||
\
|
||||
case LONGINT_INVALID_SUFFIX_CHAR: \
|
||||
case LONGINT_INVALID_SUFFIX_CHAR | LONGINT_OVERFLOW: \
|
||||
error ((Exit_code), 0, "invalid character following %s in `%s'", \
|
||||
(Argument_type_string), (Str)); \
|
||||
break; \
|
||||
\
|
||||
case LONGINT_OVERFLOW: \
|
||||
error ((Exit_code), 0, "%s `%s' too large", \
|
||||
(Argument_type_string), (Str)); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
# define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \
|
||||
_STRTOL_ERROR (exit_failure, Str, Argument_type_string, Err)
|
||||
|
||||
# define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \
|
||||
_STRTOL_ERROR (0, Str, Argument_type_string, Err)
|
||||
|
||||
#endif /* not XSTRTOL_H_ */
|
6
contrib/diff/lib/xstrtoul.c
Normal file
6
contrib/diff/lib/xstrtoul.c
Normal file
@ -0,0 +1,6 @@
|
||||
#define __strtol strtoul
|
||||
#define __strtol_t unsigned long int
|
||||
#define __xstrtol xstrtoul
|
||||
#define STRTOL_T_MINIMUM 0
|
||||
#define STRTOL_T_MAXIMUM ULONG_MAX
|
||||
#include "xstrtol.c"
|
37
contrib/diff/lib/xstrtoumax.c
Normal file
37
contrib/diff/lib/xstrtoumax.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* xstrtoumax.c -- A more useful interface to strtoumax.
|
||||
Copyright (C) 1999, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#define __strtol strtoumax
|
||||
#define __strtol_t uintmax_t
|
||||
#define __xstrtol xstrtoumax
|
||||
#ifdef UINTMAX_MAX
|
||||
# define STRTOL_T_MINIMUM 0
|
||||
# define STRTOL_T_MAXIMUM UINTMAX_MAX
|
||||
#endif
|
||||
#include "xstrtol.c"
|
34
contrib/diff/man/Makefile.am
Normal file
34
contrib/diff/man/Makefile.am
Normal file
@ -0,0 +1,34 @@
|
||||
# Automakefile for GNU diffutils man pages
|
||||
|
||||
# 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.
|
||||
|
||||
dist_man_MANS = cmp.1 diff.1 diff3.1 sdiff.1
|
||||
MAINTAINERCLEANFILES = $(dist_man_MANS)
|
||||
|
||||
S = $(top_srcdir)/src
|
||||
cmp.1: $S/cmp.c
|
||||
diff.1: $S/diff.c
|
||||
diff3.1: $S/diff3.c
|
||||
sdiff.1: $S/sdiff.c
|
||||
|
||||
# Depend on configure.ac to get version number changes.
|
||||
$(dist_man_MANS): $(top_srcdir)/configure.ac
|
||||
base=`expr $@ : '\(.*\).1'` && \
|
||||
(echo '[NAME]' && sed 's@/\* *@@; s/-/\\-/; q' $S/$$base.c) | \
|
||||
$(HELP2MAN) -i - -S '$(PACKAGE) $(VERSION)' ../src/$$base | \
|
||||
sed 's/^\.B info .*/.B info diff/' >$@
|
63
contrib/diff/man/cmp.1
Normal file
63
contrib/diff/man/cmp.1
Normal file
@ -0,0 +1,63 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33.
|
||||
.TH CMP "1" "April 2004" "diffutils 2.8.7" "User Commands"
|
||||
.SH NAME
|
||||
cmp \- compare two files byte by byte
|
||||
.SH SYNOPSIS
|
||||
.B cmp
|
||||
[\fIOPTION\fR]... \fIFILE1 \fR[\fIFILE2 \fR[\fISKIP1 \fR[\fISKIP2\fR]]]
|
||||
.SH DESCRIPTION
|
||||
Compare two files byte by byte.
|
||||
.TP
|
||||
\fB\-b\fR \fB\-\-print\-bytes\fR
|
||||
Print differing bytes.
|
||||
.TP
|
||||
\fB\-i\fR SKIP \fB\-\-ignore\-initial\fR=\fISKIP\fR
|
||||
Skip the first SKIP bytes of input.
|
||||
.HP
|
||||
\fB\-i\fR SKIP1:SKIP2 \fB\-\-ignore\-initial\fR=\fISKIP1\fR:SKIP2
|
||||
.IP
|
||||
Skip the first SKIP1 bytes of FILE1 and the first SKIP2 bytes of FILE2.
|
||||
.TP
|
||||
\fB\-l\fR \fB\-\-verbose\fR
|
||||
Output byte numbers and values of all differing bytes.
|
||||
.TP
|
||||
\fB\-n\fR LIMIT \fB\-\-bytes\fR=\fILIMIT\fR
|
||||
Compare at most LIMIT bytes.
|
||||
.TP
|
||||
\fB\-s\fR \fB\-\-quiet\fR \fB\-\-silent\fR
|
||||
Output nothing; yield exit status only.
|
||||
.TP
|
||||
\fB\-v\fR \fB\-\-version\fR
|
||||
Output version info.
|
||||
.TP
|
||||
\fB\-\-help\fR
|
||||
Output this help.
|
||||
.PP
|
||||
SKIP1 and SKIP2 are the number of bytes to skip in each file.
|
||||
SKIP values may be followed by the following multiplicative suffixes:
|
||||
kB 1000, K 1024, MB 1,000,000, M 1,048,576,
|
||||
GB 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y.
|
||||
.PP
|
||||
If a FILE is `-' or missing, read standard input.
|
||||
Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.
|
||||
.SH AUTHOR
|
||||
Written by Torbjorn Granlund and David MacKenzie.
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to <bug-gnu-utils@gnu.org>.
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 2004 Free Software Foundation, Inc.
|
||||
.br
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B cmp
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B cmp
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info diff
|
||||
.PP
|
||||
should give you access to the complete manual.
|
227
contrib/diff/man/diff.1
Normal file
227
contrib/diff/man/diff.1
Normal file
@ -0,0 +1,227 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33.
|
||||
.TH DIFF "1" "April 2004" "diffutils 2.8.7" "User Commands"
|
||||
.SH NAME
|
||||
diff \- compare files line by line
|
||||
.SH SYNOPSIS
|
||||
.B diff
|
||||
[\fIOPTION\fR]... \fIFILES\fR
|
||||
.SH DESCRIPTION
|
||||
Compare files line by line.
|
||||
.TP
|
||||
\fB\-i\fR \fB\-\-ignore\-case\fR
|
||||
Ignore case differences in file contents.
|
||||
.TP
|
||||
\fB\-\-ignore\-file\-name\-case\fR
|
||||
Ignore case when comparing file names.
|
||||
.TP
|
||||
\fB\-\-no\-ignore\-file\-name\-case\fR
|
||||
Consider case when comparing file names.
|
||||
.TP
|
||||
\fB\-E\fR \fB\-\-ignore\-tab\-expansion\fR
|
||||
Ignore changes due to tab expansion.
|
||||
.TP
|
||||
\fB\-b\fR \fB\-\-ignore\-space\-change\fR
|
||||
Ignore changes in the amount of white space.
|
||||
.TP
|
||||
\fB\-w\fR \fB\-\-ignore\-all\-space\fR
|
||||
Ignore all white space.
|
||||
.TP
|
||||
\fB\-B\fR \fB\-\-ignore\-blank\-lines\fR
|
||||
Ignore changes whose lines are all blank.
|
||||
.TP
|
||||
\fB\-I\fR RE \fB\-\-ignore\-matching\-lines\fR=\fIRE\fR
|
||||
Ignore changes whose lines all match RE.
|
||||
.TP
|
||||
\fB\-\-strip\-trailing\-cr\fR
|
||||
Strip trailing carriage return on input.
|
||||
.TP
|
||||
\fB\-a\fR \fB\-\-text\fR
|
||||
Treat all files as text.
|
||||
.TP
|
||||
\fB\-c\fR \fB\-C\fR NUM \fB\-\-context\fR[=\fINUM\fR]
|
||||
Output NUM (default 3) lines of copied context.
|
||||
.TP
|
||||
\fB\-u\fR \fB\-U\fR NUM \fB\-\-unified\fR[=\fINUM\fR]
|
||||
Output NUM (default 3) lines of unified context.
|
||||
.TP
|
||||
\fB\-\-label\fR LABEL
|
||||
Use LABEL instead of file name.
|
||||
.TP
|
||||
\fB\-p\fR \fB\-\-show\-c\-function\fR
|
||||
Show which C function each change is in.
|
||||
.TP
|
||||
\fB\-F\fR RE \fB\-\-show\-function\-line\fR=\fIRE\fR
|
||||
Show the most recent line matching RE.
|
||||
.TP
|
||||
\fB\-q\fR \fB\-\-brief\fR
|
||||
Output only whether files differ.
|
||||
.TP
|
||||
\fB\-e\fR \fB\-\-ed\fR
|
||||
Output an ed script.
|
||||
.TP
|
||||
\fB\-\-normal\fR
|
||||
Output a normal diff.
|
||||
.TP
|
||||
\fB\-n\fR \fB\-\-rcs\fR
|
||||
Output an RCS format diff.
|
||||
.TP
|
||||
\fB\-y\fR \fB\-\-side\-by\-side\fR
|
||||
Output in two columns.
|
||||
.TP
|
||||
\fB\-W\fR NUM \fB\-\-width\fR=\fINUM\fR
|
||||
Output at most NUM (default 130) print columns.
|
||||
.TP
|
||||
\fB\-\-left\-column\fR
|
||||
Output only the left column of common lines.
|
||||
.TP
|
||||
\fB\-\-suppress\-common\-lines\fR
|
||||
Do not output common lines.
|
||||
.TP
|
||||
\fB\-D\fR NAME \fB\-\-ifdef\fR=\fINAME\fR
|
||||
Output merged file to show `#ifdef NAME' diffs.
|
||||
.TP
|
||||
\fB\-\-GTYPE\-group\-format\fR=\fIGFMT\fR
|
||||
Similar, but format GTYPE input groups with GFMT.
|
||||
.TP
|
||||
\fB\-\-line\-format\fR=\fILFMT\fR
|
||||
Similar, but format all input lines with LFMT.
|
||||
.TP
|
||||
\fB\-\-LTYPE\-line\-format\fR=\fILFMT\fR
|
||||
Similar, but format LTYPE input lines with LFMT.
|
||||
.TP
|
||||
LTYPE is `old', `new', or `unchanged'.
|
||||
GTYPE is LTYPE or `changed'.
|
||||
.IP
|
||||
GFMT may contain:
|
||||
.TP
|
||||
%<
|
||||
lines from FILE1
|
||||
.TP
|
||||
%>
|
||||
lines from FILE2
|
||||
.TP
|
||||
%=
|
||||
lines common to FILE1 and FILE2
|
||||
.TP
|
||||
%[-][WIDTH][.[PREC]]{doxX}LETTER
|
||||
printf-style spec for LETTER
|
||||
.IP
|
||||
LETTERs are as follows for new group, lower case for old group:
|
||||
.TP
|
||||
F
|
||||
first line number
|
||||
.TP
|
||||
L
|
||||
last line number
|
||||
.TP
|
||||
N
|
||||
number of lines = L-F+1
|
||||
.TP
|
||||
E
|
||||
F-1
|
||||
.TP
|
||||
M
|
||||
L+1
|
||||
.IP
|
||||
LFMT may contain:
|
||||
.TP
|
||||
%L
|
||||
contents of line
|
||||
.TP
|
||||
%l
|
||||
contents of line, excluding any trailing newline
|
||||
.TP
|
||||
%[-][WIDTH][.[PREC]]{doxX}n
|
||||
printf-style spec for input line number
|
||||
.IP
|
||||
Either GFMT or LFMT may contain:
|
||||
.TP
|
||||
%%
|
||||
%
|
||||
.TP
|
||||
%c'C'
|
||||
the single character C
|
||||
.TP
|
||||
%c'\eOOO'
|
||||
the character with octal code OOO
|
||||
.TP
|
||||
\fB\-l\fR \fB\-\-paginate\fR
|
||||
Pass the output through `pr' to paginate it.
|
||||
.TP
|
||||
\fB\-t\fR \fB\-\-expand\-tabs\fR
|
||||
Expand tabs to spaces in output.
|
||||
.TP
|
||||
\fB\-T\fR \fB\-\-initial\-tab\fR
|
||||
Make tabs line up by prepending a tab.
|
||||
.TP
|
||||
\fB\-\-tabsize\fR=\fINUM\fR
|
||||
Tab stops are every NUM (default 8) print columns.
|
||||
.TP
|
||||
\fB\-r\fR \fB\-\-recursive\fR
|
||||
Recursively compare any subdirectories found.
|
||||
.TP
|
||||
\fB\-N\fR \fB\-\-new\-file\fR
|
||||
Treat absent files as empty.
|
||||
.TP
|
||||
\fB\-\-unidirectional\-new\-file\fR
|
||||
Treat absent first files as empty.
|
||||
.TP
|
||||
\fB\-s\fR \fB\-\-report\-identical\-files\fR
|
||||
Report when two files are the same.
|
||||
.TP
|
||||
\fB\-x\fR PAT \fB\-\-exclude\fR=\fIPAT\fR
|
||||
Exclude files that match PAT.
|
||||
.TP
|
||||
\fB\-X\fR FILE \fB\-\-exclude\-from\fR=\fIFILE\fR
|
||||
Exclude files that match any pattern in FILE.
|
||||
.TP
|
||||
\fB\-S\fR FILE \fB\-\-starting\-file\fR=\fIFILE\fR
|
||||
Start with FILE when comparing directories.
|
||||
.TP
|
||||
\fB\-\-from\-file\fR=\fIFILE1\fR
|
||||
Compare FILE1 to all operands. FILE1 can be a directory.
|
||||
.TP
|
||||
\fB\-\-to\-file\fR=\fIFILE2\fR
|
||||
Compare all operands to FILE2. FILE2 can be a directory.
|
||||
.TP
|
||||
\fB\-\-horizon\-lines\fR=\fINUM\fR
|
||||
Keep NUM lines of the common prefix and suffix.
|
||||
.TP
|
||||
\fB\-d\fR \fB\-\-minimal\fR
|
||||
Try hard to find a smaller set of changes.
|
||||
.TP
|
||||
\fB\-\-speed\-large\-files\fR
|
||||
Assume large files and many scattered small changes.
|
||||
.TP
|
||||
\fB\-v\fR \fB\-\-version\fR
|
||||
Output version info.
|
||||
.TP
|
||||
\fB\-\-help\fR
|
||||
Output this help.
|
||||
.PP
|
||||
FILES are `FILE1 FILE2' or `DIR1 DIR2' or `DIR FILE...' or `FILE... DIR'.
|
||||
If \fB\-\-from\-file\fR or \fB\-\-to\-file\fR is given, there are no restrictions on FILES.
|
||||
If a FILE is `-', read standard input.
|
||||
Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.
|
||||
.SH AUTHOR
|
||||
Written by Paul Eggert, Mike Haertel, David Hayes,
|
||||
Richard Stallman, and Len Tower.
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to <bug-gnu-utils@gnu.org>.
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 2004 Free Software Foundation, Inc.
|
||||
.br
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B diff
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B diff
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info diff
|
||||
.PP
|
||||
should give you access to the complete manual.
|
78
contrib/diff/man/diff3.1
Normal file
78
contrib/diff/man/diff3.1
Normal file
@ -0,0 +1,78 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33.
|
||||
.TH DIFF3 "1" "April 2004" "diffutils 2.8.7" "User Commands"
|
||||
.SH NAME
|
||||
diff3 \- compare three files line by line
|
||||
.SH SYNOPSIS
|
||||
.B diff3
|
||||
[\fIOPTION\fR]... \fIMYFILE OLDFILE YOURFILE\fR
|
||||
.SH DESCRIPTION
|
||||
Compare three files line by line.
|
||||
.TP
|
||||
\fB\-e\fR \fB\-\-ed\fR
|
||||
Output unmerged changes from OLDFILE to YOURFILE into MYFILE.
|
||||
.TP
|
||||
\fB\-E\fR \fB\-\-show\-overlap\fR
|
||||
Output unmerged changes, bracketing conflicts.
|
||||
.TP
|
||||
\fB\-A\fR \fB\-\-show\-all\fR
|
||||
Output all changes, bracketing conflicts.
|
||||
.TP
|
||||
\fB\-x\fR \fB\-\-overlap\-only\fR
|
||||
Output overlapping changes.
|
||||
.TP
|
||||
\fB\-X\fR
|
||||
Output overlapping changes, bracketing them.
|
||||
.TP
|
||||
\fB\-3\fR \fB\-\-easy\-only\fR
|
||||
Output unmerged nonoverlapping changes.
|
||||
.TP
|
||||
\fB\-m\fR \fB\-\-merge\fR
|
||||
Output merged file instead of ed script (default \fB\-A\fR).
|
||||
.TP
|
||||
\fB\-L\fR LABEL \fB\-\-label\fR=\fILABEL\fR
|
||||
Use LABEL instead of file name.
|
||||
.TP
|
||||
\fB\-i\fR
|
||||
Append `w' and `q' commands to ed scripts.
|
||||
.TP
|
||||
\fB\-a\fR \fB\-\-text\fR
|
||||
Treat all files as text.
|
||||
.TP
|
||||
\fB\-\-strip\-trailing\-cr\fR
|
||||
Strip trailing carriage return on input.
|
||||
.TP
|
||||
\fB\-T\fR \fB\-\-initial\-tab\fR
|
||||
Make tabs line up by prepending a tab.
|
||||
.TP
|
||||
\fB\-\-diff\-program\fR=\fIPROGRAM\fR
|
||||
Use PROGRAM to compare files.
|
||||
.TP
|
||||
\fB\-v\fR \fB\-\-version\fR
|
||||
Output version info.
|
||||
.TP
|
||||
\fB\-\-help\fR
|
||||
Output this help.
|
||||
.PP
|
||||
If a FILE is `-', read standard input.
|
||||
Exit status is 0 if successful, 1 if conflicts, 2 if trouble.
|
||||
.SH AUTHOR
|
||||
Written by Randy Smith.
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to <bug-gnu-utils@gnu.org>.
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 2004 Free Software Foundation, Inc.
|
||||
.br
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B diff3
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B diff3
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info diff
|
||||
.PP
|
||||
should give you access to the complete manual.
|
90
contrib/diff/man/sdiff.1
Normal file
90
contrib/diff/man/sdiff.1
Normal file
@ -0,0 +1,90 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33.
|
||||
.TH SDIFF "1" "April 2004" "diffutils 2.8.7" "User Commands"
|
||||
.SH NAME
|
||||
sdiff \- side-by-side merge of file differences
|
||||
.SH SYNOPSIS
|
||||
.B sdiff
|
||||
[\fIOPTION\fR]... \fIFILE1 FILE2\fR
|
||||
.SH DESCRIPTION
|
||||
Side-by-side merge of file differences.
|
||||
.TP
|
||||
\fB\-o\fR FILE \fB\-\-output\fR=\fIFILE\fR
|
||||
Operate interactively, sending output to FILE.
|
||||
.TP
|
||||
\fB\-i\fR \fB\-\-ignore\-case\fR
|
||||
Consider upper- and lower-case to be the same.
|
||||
.TP
|
||||
\fB\-E\fR \fB\-\-ignore\-tab\-expansion\fR
|
||||
Ignore changes due to tab expansion.
|
||||
.TP
|
||||
\fB\-b\fR \fB\-\-ignore\-space\-change\fR
|
||||
Ignore changes in the amount of white space.
|
||||
.TP
|
||||
\fB\-W\fR \fB\-\-ignore\-all\-space\fR
|
||||
Ignore all white space.
|
||||
.TP
|
||||
\fB\-B\fR \fB\-\-ignore\-blank\-lines\fR
|
||||
Ignore changes whose lines are all blank.
|
||||
.TP
|
||||
\fB\-I\fR RE \fB\-\-ignore\-matching\-lines\fR=\fIRE\fR
|
||||
Ignore changes whose lines all match RE.
|
||||
.TP
|
||||
\fB\-\-strip\-trailing\-cr\fR
|
||||
Strip trailing carriage return on input.
|
||||
.TP
|
||||
\fB\-a\fR \fB\-\-text\fR
|
||||
Treat all files as text.
|
||||
.TP
|
||||
\fB\-w\fR NUM \fB\-\-width\fR=\fINUM\fR
|
||||
Output at most NUM (default 130) print columns.
|
||||
.TP
|
||||
\fB\-l\fR \fB\-\-left\-column\fR
|
||||
Output only the left column of common lines.
|
||||
.TP
|
||||
\fB\-s\fR \fB\-\-suppress\-common\-lines\fR
|
||||
Do not output common lines.
|
||||
.TP
|
||||
\fB\-t\fR \fB\-\-expand\-tabs\fR
|
||||
Expand tabs to spaces in output.
|
||||
.TP
|
||||
\fB\-\-tabsize\fR=\fINUM\fR
|
||||
Tab stops are every NUM (default 8) print columns.
|
||||
.TP
|
||||
\fB\-d\fR \fB\-\-minimal\fR
|
||||
Try hard to find a smaller set of changes.
|
||||
.TP
|
||||
\fB\-H\fR \fB\-\-speed\-large\-files\fR
|
||||
Assume large files and many scattered small changes.
|
||||
.TP
|
||||
\fB\-\-diff\-program\fR=\fIPROGRAM\fR
|
||||
Use PROGRAM to compare files.
|
||||
.TP
|
||||
\fB\-v\fR \fB\-\-version\fR
|
||||
Output version info.
|
||||
.TP
|
||||
\fB\-\-help\fR
|
||||
Output this help.
|
||||
.PP
|
||||
If a FILE is `-', read standard input.
|
||||
Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.
|
||||
.SH AUTHOR
|
||||
Written by Thomas Lord.
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to <bug-gnu-utils@gnu.org>.
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 2004 Free Software Foundation, Inc.
|
||||
.br
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B sdiff
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B sdiff
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info diff
|
||||
.PP
|
||||
should give you access to the complete manual.
|
44
contrib/diff/src/Makefile.am
Normal file
44
contrib/diff/src/Makefile.am
Normal file
@ -0,0 +1,44 @@
|
||||
# Automakefile for GNU diffutils programs.
|
||||
|
||||
# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2, or (at your option)
|
||||
## any later version.
|
||||
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
## 02111-1307, USA.
|
||||
|
||||
bin_PROGRAMS = cmp diff diff3 sdiff
|
||||
|
||||
noinst_HEADERS = system.h
|
||||
|
||||
localedir = $(datadir)/locale
|
||||
|
||||
AM_CPPFLAGS = -I../lib -I$(top_srcdir)/lib
|
||||
|
||||
LDADD = ../lib/libdiffutils.a @LIBINTL@
|
||||
diff_LDADD = $(LDADD) @LIB_CLOCK_GETTIME@
|
||||
|
||||
cmp_SOURCES = cmp.c
|
||||
diff3_SOURCES = diff3.c
|
||||
sdiff_SOURCES = sdiff.c
|
||||
diff_SOURCES = \
|
||||
analyze.c context.c diff.c diff.h dir.c ed.c ifdef.c io.c \
|
||||
normal.c side.c util.c
|
||||
|
||||
MOSTLYCLEANFILES = paths.h paths.ht
|
||||
|
||||
cmp.$(OBJEXT) diff3.$(OBJEXT) diff.$(OBJEXT) sdiff.$(OBJEXT): paths.h
|
||||
paths.h:
|
||||
(echo '#define DEFAULT_DIFF_PROGRAM "$(bindir)/'`echo diff|sed '$(transform)'`'"' && \
|
||||
echo '#define LOCALEDIR "$(localedir)"') >$@t
|
||||
mv $@t $@
|
1038
contrib/diff/src/analyze.c
Normal file
1038
contrib/diff/src/analyze.c
Normal file
File diff suppressed because it is too large
Load Diff
677
contrib/diff/src/cmp.c
Normal file
677
contrib/diff/src/cmp.c
Normal file
@ -0,0 +1,677 @@
|
||||
/* cmp - compare two files byte by byte
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2001,
|
||||
2002, 2004 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "system.h"
|
||||
#include "paths.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <c-stack.h>
|
||||
#include <cmpbuf.h>
|
||||
#include <error.h>
|
||||
#include <exit.h>
|
||||
#include <exitfail.h>
|
||||
#include <file-type.h>
|
||||
#include <getopt.h>
|
||||
#include <hard-locale.h>
|
||||
#include <inttostr.h>
|
||||
#include <setmode.h>
|
||||
#include <unlocked-io.h>
|
||||
#include <version-etc.h>
|
||||
#include <xalloc.h>
|
||||
#include <xstrtol.h>
|
||||
|
||||
#if defined LC_MESSAGES && ENABLE_NLS
|
||||
# define hard_locale_LC_MESSAGES hard_locale (LC_MESSAGES)
|
||||
#else
|
||||
# define hard_locale_LC_MESSAGES 0
|
||||
#endif
|
||||
|
||||
static int cmp (void);
|
||||
static off_t file_position (int);
|
||||
static size_t block_compare (word const *, word const *);
|
||||
static size_t block_compare_and_count (word const *, word const *, off_t *);
|
||||
static void sprintc (char *, unsigned char);
|
||||
|
||||
/* Name under which this program was invoked. */
|
||||
char *program_name;
|
||||
|
||||
/* Filenames of the compared files. */
|
||||
static char const *file[2];
|
||||
|
||||
/* File descriptors of the files. */
|
||||
static int file_desc[2];
|
||||
|
||||
/* Status of the files. */
|
||||
static struct stat stat_buf[2];
|
||||
|
||||
/* Read buffers for the files. */
|
||||
static word *buffer[2];
|
||||
|
||||
/* Optimal block size for the files. */
|
||||
static size_t buf_size;
|
||||
|
||||
/* Initial prefix to ignore for each file. */
|
||||
static off_t ignore_initial[2];
|
||||
|
||||
/* Number of bytes to compare. */
|
||||
static uintmax_t bytes = UINTMAX_MAX;
|
||||
|
||||
/* Output format. */
|
||||
static enum comparison_type
|
||||
{
|
||||
type_first_diff, /* Print the first difference. */
|
||||
type_all_diffs, /* Print all differences. */
|
||||
type_status /* Exit status only. */
|
||||
} comparison_type;
|
||||
|
||||
/* If nonzero, print values of bytes quoted like cat -t does. */
|
||||
static bool opt_print_bytes;
|
||||
|
||||
/* Values for long options that do not have single-letter equivalents. */
|
||||
enum
|
||||
{
|
||||
HELP_OPTION = CHAR_MAX + 1
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"print-bytes", 0, 0, 'b'},
|
||||
{"print-chars", 0, 0, 'c'}, /* obsolescent as of diffutils 2.7.3 */
|
||||
{"ignore-initial", 1, 0, 'i'},
|
||||
{"verbose", 0, 0, 'l'},
|
||||
{"bytes", 1, 0, 'n'},
|
||||
{"silent", 0, 0, 's'},
|
||||
{"quiet", 0, 0, 's'},
|
||||
{"version", 0, 0, 'v'},
|
||||
{"help", 0, 0, HELP_OPTION},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static void try_help (char const *, char const *) __attribute__((noreturn));
|
||||
static void
|
||||
try_help (char const *reason_msgid, char const *operand)
|
||||
{
|
||||
if (reason_msgid)
|
||||
error (0, 0, _(reason_msgid), operand);
|
||||
error (EXIT_TROUBLE, 0,
|
||||
_("Try `%s --help' for more information."), program_name);
|
||||
abort ();
|
||||
}
|
||||
|
||||
static char const valid_suffixes[] = "kKMGTPEZY0";
|
||||
|
||||
/* Update ignore_initial[F] according to the result of parsing an
|
||||
*operand ARGPTR of --ignore-initial, updating *ARGPTR to point
|
||||
*after the operand. If DELIMITER is nonzero, the operand may be
|
||||
*followed by DELIMITER; otherwise it must be null-terminated. */
|
||||
static void
|
||||
specify_ignore_initial (int f, char **argptr, char delimiter)
|
||||
{
|
||||
uintmax_t val;
|
||||
off_t o;
|
||||
char const *arg = *argptr;
|
||||
strtol_error e = xstrtoumax (arg, argptr, 0, &val, valid_suffixes);
|
||||
if (! (e == LONGINT_OK
|
||||
|| (e == LONGINT_INVALID_SUFFIX_CHAR && **argptr == delimiter))
|
||||
|| (o = val) < 0 || o != val || val == UINTMAX_MAX)
|
||||
try_help ("invalid --ignore-initial value `%s'", arg);
|
||||
if (ignore_initial[f] < o)
|
||||
ignore_initial[f] = o;
|
||||
}
|
||||
|
||||
/* Specify the output format. */
|
||||
static void
|
||||
specify_comparison_type (enum comparison_type t)
|
||||
{
|
||||
if (comparison_type && comparison_type != t)
|
||||
try_help ("options -l and -s are incompatible", 0);
|
||||
comparison_type = t;
|
||||
}
|
||||
|
||||
static void
|
||||
check_stdout (void)
|
||||
{
|
||||
if (ferror (stdout))
|
||||
error (EXIT_TROUBLE, 0, "%s", _("write failed"));
|
||||
else if (fclose (stdout) != 0)
|
||||
error (EXIT_TROUBLE, errno, "%s", _("standard output"));
|
||||
}
|
||||
|
||||
static char const * const option_help_msgid[] = {
|
||||
N_("-b --print-bytes Print differing bytes."),
|
||||
N_("-i SKIP --ignore-initial=SKIP Skip the first SKIP bytes of input."),
|
||||
N_("-i SKIP1:SKIP2 --ignore-initial=SKIP1:SKIP2"),
|
||||
N_(" Skip the first SKIP1 bytes of FILE1 and the first SKIP2 bytes of FILE2."),
|
||||
N_("-l --verbose Output byte numbers and values of all differing bytes."),
|
||||
N_("-n LIMIT --bytes=LIMIT Compare at most LIMIT bytes."),
|
||||
N_("-s --quiet --silent Output nothing; yield exit status only."),
|
||||
N_("-v --version Output version info."),
|
||||
N_("--help Output this help."),
|
||||
0
|
||||
};
|
||||
|
||||
static void
|
||||
usage (void)
|
||||
{
|
||||
char const * const *p;
|
||||
|
||||
printf (_("Usage: %s [OPTION]... FILE1 [FILE2 [SKIP1 [SKIP2]]]\n"),
|
||||
program_name);
|
||||
printf ("%s\n\n", _("Compare two files byte by byte."));
|
||||
for (p = option_help_msgid; *p; p++)
|
||||
printf (" %s\n", _(*p));
|
||||
printf ("\n%s\n%s\n\n%s\n%s\n\n%s\n",
|
||||
_("SKIP1 and SKIP2 are the number of bytes to skip in each file."),
|
||||
_("SKIP values may be followed by the following multiplicative suffixes:\n\
|
||||
kB 1000, K 1024, MB 1,000,000, M 1,048,576,\n\
|
||||
GB 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y."),
|
||||
_("If a FILE is `-' or missing, read standard input."),
|
||||
_("Exit status is 0 if inputs are the same, 1 if different, 2 if trouble."),
|
||||
_("Report bugs to <bug-gnu-utils@gnu.org>."));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int c, f, exit_status;
|
||||
size_t words_per_buffer;
|
||||
|
||||
exit_failure = EXIT_TROUBLE;
|
||||
initialize_main (&argc, &argv);
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
c_stack_action (0);
|
||||
|
||||
/* Parse command line options. */
|
||||
|
||||
while ((c = getopt_long (argc, argv, "bci:ln:sv", long_options, 0))
|
||||
!= -1)
|
||||
switch (c)
|
||||
{
|
||||
case 'b':
|
||||
case 'c': /* 'c' is obsolescent as of diffutils 2.7.3 */
|
||||
opt_print_bytes = true;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
specify_ignore_initial (0, &optarg, ':');
|
||||
if (*optarg++ == ':')
|
||||
specify_ignore_initial (1, &optarg, 0);
|
||||
else if (ignore_initial[1] < ignore_initial[0])
|
||||
ignore_initial[1] = ignore_initial[0];
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
specify_comparison_type (type_all_diffs);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
{
|
||||
uintmax_t n;
|
||||
if (xstrtoumax (optarg, 0, 0, &n, valid_suffixes) != LONGINT_OK)
|
||||
try_help ("invalid --bytes value `%s'", optarg);
|
||||
if (n < bytes)
|
||||
bytes = n;
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
specify_comparison_type (type_status);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
/* TRANSLATORS: Please translate the second "o" in "Torbjorn
|
||||
Granlund" to an o-with-umlaut (U+00F6, LATIN SMALL LETTER O
|
||||
WITH DIAERESIS) if possible. */
|
||||
version_etc (stdout, "cmp", PACKAGE_NAME, PACKAGE_VERSION,
|
||||
_("Torbjorn Granlund"), "David MacKenzie", (char *) 0);
|
||||
check_stdout ();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
case HELP_OPTION:
|
||||
usage ();
|
||||
check_stdout ();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
try_help (0, 0);
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
try_help ("missing operand after `%s'", argv[argc - 1]);
|
||||
|
||||
file[0] = argv[optind++];
|
||||
file[1] = optind < argc ? argv[optind++] : "-";
|
||||
|
||||
for (f = 0; f < 2 && optind < argc; f++)
|
||||
{
|
||||
char *arg = argv[optind++];
|
||||
specify_ignore_initial (f, &arg, 0);
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
try_help ("extra operand `%s'", argv[optind]);
|
||||
|
||||
for (f = 0; f < 2; f++)
|
||||
{
|
||||
/* If file[1] is "-", treat it first; this avoids a misdiagnostic if
|
||||
stdin is closed and opening file[0] yields file descriptor 0. */
|
||||
int f1 = f ^ (strcmp (file[1], "-") == 0);
|
||||
|
||||
/* Two files with the same name and offset are identical.
|
||||
But wait until we open the file once, for proper diagnostics. */
|
||||
if (f && ignore_initial[0] == ignore_initial[1]
|
||||
&& file_name_cmp (file[0], file[1]) == 0)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
file_desc[f1] = (strcmp (file[f1], "-") == 0
|
||||
? STDIN_FILENO
|
||||
: open (file[f1], O_RDONLY, 0));
|
||||
if (file_desc[f1] < 0 || fstat (file_desc[f1], stat_buf + f1) != 0)
|
||||
{
|
||||
if (file_desc[f1] < 0 && comparison_type == type_status)
|
||||
exit (EXIT_TROUBLE);
|
||||
else
|
||||
error (EXIT_TROUBLE, errno, "%s", file[f1]);
|
||||
}
|
||||
|
||||
set_binary_mode (file_desc[f1], true);
|
||||
}
|
||||
|
||||
/* If the files are links to the same inode and have the same file position,
|
||||
they are identical. */
|
||||
|
||||
if (0 < same_file (&stat_buf[0], &stat_buf[1])
|
||||
&& same_file_attributes (&stat_buf[0], &stat_buf[1])
|
||||
&& file_position (0) == file_position (1))
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
/* If output is redirected to the null device, we may assume `-s'. */
|
||||
|
||||
if (comparison_type != type_status)
|
||||
{
|
||||
struct stat outstat, nullstat;
|
||||
|
||||
if (fstat (STDOUT_FILENO, &outstat) == 0
|
||||
&& stat (NULL_DEVICE, &nullstat) == 0
|
||||
&& 0 < same_file (&outstat, &nullstat))
|
||||
comparison_type = type_status;
|
||||
}
|
||||
|
||||
/* If only a return code is needed,
|
||||
and if both input descriptors are associated with plain files,
|
||||
conclude that the files differ if they have different sizes
|
||||
and if more bytes will be compared than are in the smaller file. */
|
||||
|
||||
if (comparison_type == type_status
|
||||
&& S_ISREG (stat_buf[0].st_mode)
|
||||
&& S_ISREG (stat_buf[1].st_mode))
|
||||
{
|
||||
off_t s0 = stat_buf[0].st_size - file_position (0);
|
||||
off_t s1 = stat_buf[1].st_size - file_position (1);
|
||||
if (s0 < 0)
|
||||
s0 = 0;
|
||||
if (s1 < 0)
|
||||
s1 = 0;
|
||||
if (s0 != s1 && MIN (s0, s1) < bytes)
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Get the optimal block size of the files. */
|
||||
|
||||
buf_size = buffer_lcm (STAT_BLOCKSIZE (stat_buf[0]),
|
||||
STAT_BLOCKSIZE (stat_buf[1]),
|
||||
PTRDIFF_MAX - sizeof (word));
|
||||
|
||||
/* Allocate word-aligned buffers, with space for sentinels at the end. */
|
||||
|
||||
words_per_buffer = (buf_size + 2 * sizeof (word) - 1) / sizeof (word);
|
||||
buffer[0] = xmalloc (2 * sizeof (word) * words_per_buffer);
|
||||
buffer[1] = buffer[0] + words_per_buffer;
|
||||
|
||||
exit_status = cmp ();
|
||||
|
||||
for (f = 0; f < 2; f++)
|
||||
if (close (file_desc[f]) != 0)
|
||||
error (EXIT_TROUBLE, errno, "%s", file[f]);
|
||||
if (exit_status != 0 && comparison_type != type_status)
|
||||
check_stdout ();
|
||||
exit (exit_status);
|
||||
return exit_status;
|
||||
}
|
||||
|
||||
/* Compare the two files already open on `file_desc[0]' and `file_desc[1]',
|
||||
using `buffer[0]' and `buffer[1]'.
|
||||
Return EXIT_SUCCESS if identical, EXIT_FAILURE if different,
|
||||
>1 if error. */
|
||||
|
||||
static int
|
||||
cmp (void)
|
||||
{
|
||||
off_t line_number = 1; /* Line number (1...) of difference. */
|
||||
off_t byte_number = 1; /* Byte number (1...) of difference. */
|
||||
uintmax_t remaining = bytes; /* Remaining number of bytes to compare. */
|
||||
size_t read0, read1; /* Number of bytes read from each file. */
|
||||
size_t first_diff; /* Offset (0...) in buffers of 1st diff. */
|
||||
size_t smaller; /* The lesser of `read0' and `read1'. */
|
||||
word *buffer0 = buffer[0];
|
||||
word *buffer1 = buffer[1];
|
||||
char *buf0 = (char *) buffer0;
|
||||
char *buf1 = (char *) buffer1;
|
||||
int ret = EXIT_SUCCESS;
|
||||
int f;
|
||||
int offset_width;
|
||||
|
||||
if (comparison_type == type_all_diffs)
|
||||
{
|
||||
off_t byte_number_max = MIN (bytes, TYPE_MAXIMUM (off_t));
|
||||
|
||||
for (f = 0; f < 2; f++)
|
||||
if (S_ISREG (stat_buf[f].st_mode))
|
||||
{
|
||||
off_t file_bytes = stat_buf[f].st_size - file_position (f);
|
||||
if (file_bytes < byte_number_max)
|
||||
byte_number_max = file_bytes;
|
||||
}
|
||||
|
||||
for (offset_width = 1; (byte_number_max /= 10) != 0; offset_width++)
|
||||
continue;
|
||||
}
|
||||
|
||||
for (f = 0; f < 2; f++)
|
||||
{
|
||||
off_t ig = ignore_initial[f];
|
||||
if (ig && file_position (f) == -1)
|
||||
{
|
||||
/* lseek failed; read and discard the ignored initial prefix. */
|
||||
do
|
||||
{
|
||||
size_t bytes_to_read = MIN (ig, buf_size);
|
||||
size_t r = block_read (file_desc[f], buf0, bytes_to_read);
|
||||
if (r != bytes_to_read)
|
||||
{
|
||||
if (r == SIZE_MAX)
|
||||
error (EXIT_TROUBLE, errno, "%s", file[f]);
|
||||
break;
|
||||
}
|
||||
ig -= r;
|
||||
}
|
||||
while (ig);
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
size_t bytes_to_read = buf_size;
|
||||
|
||||
if (remaining != UINTMAX_MAX)
|
||||
{
|
||||
if (remaining < bytes_to_read)
|
||||
bytes_to_read = remaining;
|
||||
remaining -= bytes_to_read;
|
||||
}
|
||||
|
||||
read0 = block_read (file_desc[0], buf0, bytes_to_read);
|
||||
if (read0 == SIZE_MAX)
|
||||
error (EXIT_TROUBLE, errno, "%s", file[0]);
|
||||
read1 = block_read (file_desc[1], buf1, bytes_to_read);
|
||||
if (read1 == SIZE_MAX)
|
||||
error (EXIT_TROUBLE, errno, "%s", file[1]);
|
||||
|
||||
/* Insert sentinels for the block compare. */
|
||||
|
||||
buf0[read0] = ~buf1[read0];
|
||||
buf1[read1] = ~buf0[read1];
|
||||
|
||||
/* If the line number should be written for differing files,
|
||||
compare the blocks and count the number of newlines
|
||||
simultaneously. */
|
||||
first_diff = (comparison_type == type_first_diff
|
||||
? block_compare_and_count (buffer0, buffer1, &line_number)
|
||||
: block_compare (buffer0, buffer1));
|
||||
|
||||
byte_number += first_diff;
|
||||
smaller = MIN (read0, read1);
|
||||
|
||||
if (first_diff < smaller)
|
||||
{
|
||||
switch (comparison_type)
|
||||
{
|
||||
case type_first_diff:
|
||||
{
|
||||
char byte_buf[INT_BUFSIZE_BOUND (off_t)];
|
||||
char line_buf[INT_BUFSIZE_BOUND (off_t)];
|
||||
char const *byte_num = offtostr (byte_number, byte_buf);
|
||||
char const *line_num = offtostr (line_number, line_buf);
|
||||
if (!opt_print_bytes)
|
||||
{
|
||||
/* See POSIX 1003.1-2001 for this format. This
|
||||
message is used only in the POSIX locale, so it
|
||||
need not be translated. */
|
||||
static char const char_message[] =
|
||||
"%s %s differ: char %s, line %s\n";
|
||||
|
||||
/* The POSIX rationale recommends using the word
|
||||
"byte" outside the POSIX locale. Some gettext
|
||||
implementations translate even in the POSIX
|
||||
locale if certain other environment variables
|
||||
are set, so use "byte" if a translation is
|
||||
available, or if outside the POSIX locale. */
|
||||
static char const byte_msgid[] =
|
||||
N_("%s %s differ: byte %s, line %s\n");
|
||||
char const *byte_message = _(byte_msgid);
|
||||
bool use_byte_message = (byte_message != byte_msgid
|
||||
|| hard_locale_LC_MESSAGES);
|
||||
|
||||
printf (use_byte_message ? byte_message : char_message,
|
||||
file[0], file[1], byte_num, line_num);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char c0 = buf0[first_diff];
|
||||
unsigned char c1 = buf1[first_diff];
|
||||
char s0[5];
|
||||
char s1[5];
|
||||
sprintc (s0, c0);
|
||||
sprintc (s1, c1);
|
||||
printf (_("%s %s differ: byte %s, line %s is %3o %s %3o %s\n"),
|
||||
file[0], file[1], byte_num, line_num,
|
||||
c0, s0, c1, s1);
|
||||
}
|
||||
}
|
||||
/* Fall through. */
|
||||
case type_status:
|
||||
return EXIT_FAILURE;
|
||||
|
||||
case type_all_diffs:
|
||||
do
|
||||
{
|
||||
unsigned char c0 = buf0[first_diff];
|
||||
unsigned char c1 = buf1[first_diff];
|
||||
if (c0 != c1)
|
||||
{
|
||||
char byte_buf[INT_BUFSIZE_BOUND (off_t)];
|
||||
char const *byte_num = offtostr (byte_number, byte_buf);
|
||||
if (!opt_print_bytes)
|
||||
{
|
||||
/* See POSIX 1003.1-2001 for this format. */
|
||||
printf ("%*s %3o %3o\n",
|
||||
offset_width, byte_num, c0, c1);
|
||||
}
|
||||
else
|
||||
{
|
||||
char s0[5];
|
||||
char s1[5];
|
||||
sprintc (s0, c0);
|
||||
sprintc (s1, c1);
|
||||
printf ("%*s %3o %-4s %3o %s\n",
|
||||
offset_width, byte_num, c0, s0, c1, s1);
|
||||
}
|
||||
}
|
||||
byte_number++;
|
||||
first_diff++;
|
||||
}
|
||||
while (first_diff < smaller);
|
||||
ret = EXIT_FAILURE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (read0 != read1)
|
||||
{
|
||||
if (comparison_type != type_status)
|
||||
{
|
||||
/* See POSIX 1003.1-2001 for this format. */
|
||||
fprintf (stderr, _("cmp: EOF on %s\n"), file[read1 < read0]);
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
while (read0 == buf_size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Compare two blocks of memory P0 and P1 until they differ,
|
||||
and count the number of '\n' occurrences in the common
|
||||
part of P0 and P1.
|
||||
If the blocks are not guaranteed to be different, put sentinels at the ends
|
||||
of the blocks before calling this function.
|
||||
|
||||
Return the offset of the first byte that differs.
|
||||
Increment *COUNT by the count of '\n' occurrences. */
|
||||
|
||||
static size_t
|
||||
block_compare_and_count (word const *p0, word const *p1, off_t *count)
|
||||
{
|
||||
word l; /* One word from first buffer. */
|
||||
word const *l0, *l1; /* Pointers into each buffer. */
|
||||
char const *c0, *c1; /* Pointers for finding exact address. */
|
||||
size_t cnt = 0; /* Number of '\n' occurrences. */
|
||||
word nnnn; /* Newline, sizeof (word) times. */
|
||||
int i;
|
||||
|
||||
nnnn = 0;
|
||||
for (i = 0; i < sizeof nnnn; i++)
|
||||
nnnn = (nnnn << CHAR_BIT) | '\n';
|
||||
|
||||
/* Find the rough position of the first difference by reading words,
|
||||
not bytes. */
|
||||
|
||||
for (l0 = p0, l1 = p1; (l = *l0) == *l1; l0++, l1++)
|
||||
{
|
||||
l ^= nnnn;
|
||||
for (i = 0; i < sizeof l; i++)
|
||||
{
|
||||
unsigned char uc = l;
|
||||
cnt += ! uc;
|
||||
l >>= CHAR_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the exact differing position (endianness independent). */
|
||||
|
||||
for (c0 = (char const *) l0, c1 = (char const *) l1;
|
||||
*c0 == *c1;
|
||||
c0++, c1++)
|
||||
cnt += *c0 == '\n';
|
||||
|
||||
*count += cnt;
|
||||
return c0 - (char const *) p0;
|
||||
}
|
||||
|
||||
/* Compare two blocks of memory P0 and P1 until they differ.
|
||||
If the blocks are not guaranteed to be different, put sentinels at the ends
|
||||
of the blocks before calling this function.
|
||||
|
||||
Return the offset of the first byte that differs. */
|
||||
|
||||
static size_t
|
||||
block_compare (word const *p0, word const *p1)
|
||||
{
|
||||
word const *l0, *l1;
|
||||
char const *c0, *c1;
|
||||
|
||||
/* Find the rough position of the first difference by reading words,
|
||||
not bytes. */
|
||||
|
||||
for (l0 = p0, l1 = p1; *l0 == *l1; l0++, l1++)
|
||||
continue;
|
||||
|
||||
/* Find the exact differing position (endianness independent). */
|
||||
|
||||
for (c0 = (char const *) l0, c1 = (char const *) l1;
|
||||
*c0 == *c1;
|
||||
c0++, c1++)
|
||||
continue;
|
||||
|
||||
return c0 - (char const *) p0;
|
||||
}
|
||||
|
||||
/* Put into BUF the unsigned char C, making unprintable bytes
|
||||
visible by quoting like cat -t does. */
|
||||
|
||||
static void
|
||||
sprintc (char *buf, unsigned char c)
|
||||
{
|
||||
if (! isprint (c))
|
||||
{
|
||||
if (c >= 128)
|
||||
{
|
||||
*buf++ = 'M';
|
||||
*buf++ = '-';
|
||||
c -= 128;
|
||||
}
|
||||
if (c < 32)
|
||||
{
|
||||
*buf++ = '^';
|
||||
c += 64;
|
||||
}
|
||||
else if (c == 127)
|
||||
{
|
||||
*buf++ = '^';
|
||||
c = '?';
|
||||
}
|
||||
}
|
||||
|
||||
*buf++ = c;
|
||||
*buf = 0;
|
||||
}
|
||||
|
||||
/* Position file F to ignore_initial[F] bytes from its initial position,
|
||||
and yield its new position. Don't try more than once. */
|
||||
|
||||
static off_t
|
||||
file_position (int f)
|
||||
{
|
||||
static bool positioned[2];
|
||||
static off_t position[2];
|
||||
|
||||
if (! positioned[f])
|
||||
{
|
||||
positioned[f] = true;
|
||||
position[f] = lseek (file_desc[f], ignore_initial[f], SEEK_CUR);
|
||||
}
|
||||
return position[f];
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user