Adding upstream version 2.13.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
This commit is contained in:
parent
38ef975b7f
commit
1fa764a8d3
1212 changed files with 566468 additions and 0 deletions
139
.gitignore
vendored
Normal file
139
.gitignore
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
**/*.a
|
||||
**/*.la
|
||||
**/*.lo
|
||||
**/*.o
|
||||
**/*.so
|
||||
**/*~
|
||||
**/.libs
|
||||
**/Makefile
|
||||
**/Makefile.in
|
||||
/ABOUT-NLS
|
||||
/aclocal.m4
|
||||
/autom4te.cache
|
||||
/build-aux
|
||||
/config.h
|
||||
/config.h.in
|
||||
/config.log
|
||||
/config.status
|
||||
/config.status.lineno
|
||||
/configure
|
||||
/gl
|
||||
/gnulib
|
||||
/libtool
|
||||
/stamp-h*
|
||||
docs/INSTALL.autoconf
|
||||
init/systemd/man-db.conf
|
||||
init/systemd/man-db.service
|
||||
lib/.deps
|
||||
libdb/.deps
|
||||
man/**/*.log
|
||||
man/**/*.trs
|
||||
man/*/man1/*.1
|
||||
man/*/man5/*.5
|
||||
man/*/man8/*.8
|
||||
man/*/replace.sed
|
||||
man/da/man1
|
||||
man/da/man5
|
||||
man/da/man8
|
||||
man/de/man1
|
||||
man/de/man5
|
||||
man/de/man8
|
||||
man/es/man1
|
||||
man/es/man5
|
||||
man/es/man8
|
||||
man/fr/man1
|
||||
man/fr/man5
|
||||
man/fr/man8
|
||||
man/id/man1
|
||||
man/id/man5
|
||||
man/id/man8
|
||||
man/ja/man1
|
||||
man/ja/man5
|
||||
man/ja/man8
|
||||
man/ko/man1
|
||||
man/ko/man5
|
||||
man/ko/man8
|
||||
man/man1/*.1
|
||||
man/man5/*.5
|
||||
man/man8/*.8
|
||||
man/nl/man1
|
||||
man/nl/man5
|
||||
man/nl/man8
|
||||
man/pl/man1
|
||||
man/pl/man5
|
||||
man/pl/man8
|
||||
man/pt/man1
|
||||
man/pt/man5
|
||||
man/pt/man8
|
||||
man/pt_BR/man1
|
||||
man/pt_BR/man5
|
||||
man/pt_BR/man8
|
||||
man/replace.sed
|
||||
man/replace.sin
|
||||
man/ro/man1
|
||||
man/ro/man5
|
||||
man/ro/man8
|
||||
man/ru/man1
|
||||
man/ru/man5
|
||||
man/ru/man8
|
||||
man/sr/man1
|
||||
man/sr/man5
|
||||
man/sr/man8
|
||||
man/sv/man1
|
||||
man/sv/man5
|
||||
man/sv/man8
|
||||
man/tr/man1
|
||||
man/tr/man5
|
||||
man/tr/man8
|
||||
man/uk/man1
|
||||
man/uk/man5
|
||||
man/uk/man8
|
||||
man/zh_CN/man1
|
||||
man/zh_CN/man5
|
||||
man/zh_CN/man8
|
||||
manual/man_db.cat
|
||||
manual/man_db.dvi
|
||||
manual/man_db.html
|
||||
manual/man_db.pp
|
||||
manual/man_db.ps
|
||||
manual/man_db.tps
|
||||
manual/version
|
||||
po/*.gmo
|
||||
po/ChangeLog
|
||||
po/Makefile.in.in
|
||||
po/Makevars
|
||||
po/Makevars.template
|
||||
po/POTFILES
|
||||
po/Rules-quot
|
||||
po/boldquot.sed
|
||||
po/en@boldquot.header
|
||||
po/en@quot.header
|
||||
po/insert-header.sin
|
||||
po/messages.mo
|
||||
po/quot.sed
|
||||
po/remove-potcdate.sed
|
||||
po/remove-potcdate.sin
|
||||
po/stamp-po
|
||||
src/.deps
|
||||
src/accessdb
|
||||
src/apropos
|
||||
src/catman
|
||||
src/globbing
|
||||
src/lexgrog
|
||||
src/lexgrog.c
|
||||
src/man
|
||||
src/man-recode
|
||||
src/man_db.conf
|
||||
src/manconv
|
||||
src/mandb
|
||||
src/manpath
|
||||
src/tests/*.log
|
||||
src/tests/*.trs
|
||||
src/tests/.deps
|
||||
src/tests/fspause
|
||||
src/tests/get-mtime
|
||||
src/tests/tmp-*
|
||||
src/whatis
|
||||
src/wrapper
|
||||
src/zsoelim
|
||||
src/zsoelim.c
|
674
COPYING
Normal file
674
COPYING
Normal file
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
13184
ChangeLog-2013
Normal file
13184
ChangeLog-2013
Normal file
File diff suppressed because it is too large
Load diff
67
FAQ
Normal file
67
FAQ
Normal file
|
@ -0,0 +1,67 @@
|
|||
Frequently Asked Questions
|
||||
--------------------------
|
||||
|
||||
Why use man-db instead of man?
|
||||
==============================
|
||||
|
||||
The man (currently http://primates.ximian.com/~flucifredi/man/) and man-db
|
||||
packages forked from a common code base in the mid-1990s. The original goal
|
||||
of man-db was, as indicated by the name, to add database caching to manual
|
||||
page searches. The increase in computer performance has considerably
|
||||
outpaced the growth of manual page collections, so some people now ask what
|
||||
the point is of using man-db rather than man.
|
||||
|
||||
These days, the database is indeed not such an important difference between
|
||||
man-db and man, but there are several other areas where man-db does a
|
||||
significantly better job than man:
|
||||
|
||||
* Internationalisation
|
||||
|
||||
man uses the obsolete catgets system for translations of the messages
|
||||
emitted by its programs, which cannot deal with the user using a
|
||||
different output encoding (e.g. UTF-8) from that provided by the
|
||||
translators. man-db uses gettext, which is more correct and robust.
|
||||
|
||||
In order to support many cases of non-English manual pages, man requires
|
||||
manual hardcoding of iconv pipelines (or similar) and *roff device names
|
||||
in its configuration file, and cannot operate correctly in environments
|
||||
involving a variety of encodings. man-db handles all this out of the
|
||||
box.
|
||||
|
||||
* Security and code quality
|
||||
|
||||
Security matters because both man and man-db can be installed setuid to
|
||||
a special user, and also because man is sometimes used in semi-trusted
|
||||
or untrusted contexts, such as from CGI scripts.
|
||||
|
||||
Both man and man-db spend a lot of time calling external programs, often
|
||||
in pipelines. man does so by assembling strings which it then feeds to
|
||||
the shell; this approach is nowadays well-known to be fragile and prone
|
||||
to security vulnerabilities. man-db has been redesigned from top to
|
||||
bottom to have safe and correct command execution, using a special
|
||||
"libpipeline" library.
|
||||
|
||||
* Performance
|
||||
|
||||
Happily, dealing with manual pages is not normally a
|
||||
performance-critical task these days; manual pages can normally be found
|
||||
and rendered comfortably within expected interactive response times.
|
||||
However, there are a few cases that are still more difficult, such as
|
||||
'man -K' to perform a full-text search on all manual pages. Neither man
|
||||
nor man-db includes a proper full-text search engine, but there is
|
||||
nevertheless a significant performance difference here: man-db performs
|
||||
this search at least three times as quickly as man, and in some cases
|
||||
much better than that. (On the test system, man took five minutes to
|
||||
search all manual pages, severely degrading interactive performance of
|
||||
the rest of the system for that time; man-db took around 40 seconds.)
|
||||
|
||||
* Maintenance
|
||||
|
||||
At the time of writing (February 2012), man-db has had ten full releases
|
||||
since the start of 2008 with substantial feature work, while man has had
|
||||
one release with a few minor changes.
|
||||
|
||||
I have great respect for the people who maintain man, but as a project it
|
||||
has fallen badly behind. Rather than continuing to struggle along with
|
||||
complicated patch sets, those distributions that still use man would
|
||||
probably be better off switching to man-db.
|
92
Makefile.am
Normal file
92
Makefile.am
Normal file
|
@ -0,0 +1,92 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
##
|
||||
## Copyright (C) 1994, 1995 Graeme Wilford.
|
||||
## Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010, 2011, 2012
|
||||
## Colin Watson.
|
||||
##
|
||||
## This file is part of man-db.
|
||||
##
|
||||
## man-db is free software; you can redistribute it and/or modify it
|
||||
## under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## man-db 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 man-db; if not, write to the Free Software Foundation,
|
||||
## Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
if HAVE_GNULIB_PO
|
||||
GNULIB_PO = gl/po
|
||||
endif
|
||||
|
||||
SUBDIRS = docs gl/lib $(GNULIB_PO) init lib libdb src man manual po tools
|
||||
|
||||
dist_noinst_DATA = FAQ README.md
|
||||
noinst_HEADERS = include/manconfig.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
.gitignore \
|
||||
ChangeLog-2013 \
|
||||
bootstrap \
|
||||
bootstrap.conf \
|
||||
patches/argp-domain.patch
|
||||
|
||||
# These macro files are imported by gnulib-tool, but at present not used. We
|
||||
# include them in the distribution anyway for maximum consistency.
|
||||
EXTRA_DIST += \
|
||||
gl/m4/glibc2.m4 \
|
||||
gl/m4/intdiv0.m4 \
|
||||
gl/m4/intl.m4 \
|
||||
gl/m4/intldir.m4 \
|
||||
gl/m4/intmax.m4 \
|
||||
gl/m4/inttypes-pri.m4 \
|
||||
gl/m4/lcmessage.m4 \
|
||||
gl/m4/math_h.m4 \
|
||||
gl/m4/printf-posix.m4 \
|
||||
gl/m4/sockpfaf.m4 \
|
||||
gl/m4/uintmax_t.m4 \
|
||||
gl/m4/visibility.m4
|
||||
|
||||
# Installing in --enable-setuid mode (the default) requires root; disable
|
||||
# this so that distcheck can be run as non-root.
|
||||
# The defaults for systemdsystemunitdir and systemdtmpfilesdir are
|
||||
# intentionally not prefix-sensitive, but we need to adjust them in order
|
||||
# for distcheck to pass.
|
||||
AM_DISTCHECK_CONFIGURE_FLAGS = \
|
||||
--disable-setuid \
|
||||
--with-systemdsystemunitdir=\$${prefix}/lib/systemd/system \
|
||||
--with-systemdtmpfilesdir=\$${prefix}/lib/tmpfiles.d
|
||||
|
||||
# We deliberately leave the configuration file in place on uninstall, since
|
||||
# it may contain local customisations.
|
||||
distuninstallcheck_listfiles = \
|
||||
find . -type f -print | grep -v 'etc/man_db\.conf'
|
||||
|
||||
# Note that autopoint installs into the first directory here. Yes, this
|
||||
# means that it installs into gl/m4, so we always run gnulib-tool after
|
||||
# autopoint, at least for now. See
|
||||
# https://lists.gnu.org/archive/html/bug-gnulib/2009-03/msg00154.html and
|
||||
# thread.
|
||||
ACLOCAL_AMFLAGS = -I gl/m4 -I m4
|
||||
|
||||
dist-hook: gen-ChangeLog
|
||||
|
||||
gen_start_date = 2013-12-09 00:52
|
||||
.PHONY: gen-ChangeLog
|
||||
gen-ChangeLog:
|
||||
$(AM_V_GEN)if test -d .git; then \
|
||||
$(top_srcdir)/build-aux/gitlog-to-changelog \
|
||||
--format='%s%n%n%b%n' \
|
||||
--since="$(gen_start_date)" > $(distdir)/cl-t; \
|
||||
rm -f $(distdir)/ChangeLog; \
|
||||
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
|
||||
fi
|
||||
|
||||
update-po:
|
||||
$(MAKE) -C po update-po
|
||||
$(MAKE) -C man/po4a update-po
|
2643
Makefile.in
Normal file
2643
Makefile.in
Normal file
File diff suppressed because it is too large
Load diff
316
README.md
Normal file
316
README.md
Normal file
|
@ -0,0 +1,316 @@
|
|||
# The man-db manual pager suite
|
||||
|
||||
https://gitlab.com/man-db/man-db
|
||||
|
||||
https://man-db.gitlab.io/man-db/
|
||||
|
||||
Please read the man-db manual, included in the manual subdirectory of this
|
||||
distribution. It contains configuration details and other aspects of this
|
||||
manual pager suite that are not duplicated or relevant in this README.
|
||||
Check manual/README for details of the formatters required.
|
||||
|
||||
* Read docs/INSTALL.autoconf for generic options to configure. (If you
|
||||
cloned man-db from git, then run `./bootstrap` to create this file.)
|
||||
* Read docs/INSTALL.quick if you know all about man-db.
|
||||
* Read NEWS.md for visible changes since the last public release.
|
||||
* Read ChangeLog for details of recent source code changes.
|
||||
* Read docs/TODO for future plans.
|
||||
|
||||
The C source requires an C99 compiler.
|
||||
|
||||
|
||||
## Copyright and licensing
|
||||
|
||||
Copyright (C) 1990, 1991 John W. Eaton.
|
||||
|
||||
Copyright (C) 1994, 1995 Markus Armbruster.
|
||||
|
||||
Copyright (C) 1994, 1995 Graeme W. Wilford. (Wilf.)
|
||||
|
||||
Copyright (C) 1995 Carl Edman.
|
||||
|
||||
Copyright (C) 1996, 1997, 1998, 2000 Fabrizio Polacco.
|
||||
|
||||
Copyright (C) 2001-2024 Colin Watson.
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 1991, 1992, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||
2010, 2011, 2012 Free Software Foundation, Inc.
|
||||
|
||||
man-db is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
man-db 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 man-db; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
In addition, man-db incorporates Gnulib, copyrighted by the Free Software
|
||||
Foundation and others. Note that much of Gnulib is distributed under the GNU
|
||||
General Public License version 3 or later. This means that, although
|
||||
man-db's own source code is licensed under GPL v2 or later, the work as a
|
||||
whole falls under the terms of the GPL v3 or later. Unless you take special
|
||||
pains to remove the GPL v3 portions, you must therefore follow the terms and
|
||||
conditions of the GPL v3 or later when distributing man-db.
|
||||
|
||||
|
||||
## Notice regarding current state of FHS (Linux/?BSD)
|
||||
|
||||
As of May 13th, 2001, the last public release of the Filesystem Hierarchy
|
||||
Standard proposed the root of the manual page hierarchy as `/usr/share` and
|
||||
the root of the writable cat hierarchy as `/var/cache/man` for the purposes
|
||||
of man-to-cat filename translation. As such, the following are defined in
|
||||
`./include/manconfig.h`:
|
||||
|
||||
```c
|
||||
#define FHS_CAT_ROOT "/var/cache/man" /* required by fsstnd() */
|
||||
#define FHS_MAN_ROOT "/usr/share" /* required by fsstnd() */
|
||||
```
|
||||
|
||||
For compatibility with the old FSSTND, the following locations are also
|
||||
defined:
|
||||
|
||||
```c
|
||||
#define CAT_ROOT "/var/catman" /* required by fsstnd() */
|
||||
#define MAN_ROOT "/usr" /* required by fsstnd() */
|
||||
```
|
||||
|
||||
Should these locations change, simply define the paths accordingly and
|
||||
recompile. Other FHS changes relating to man/cat paths will not be
|
||||
compatible with this version of man-db.
|
||||
|
||||
|
||||
## Non-generic arguments to configure
|
||||
|
||||
To allow the configuration program, configure, to be non-interactive, it can
|
||||
be passed various options to alter the default settings. Generic configure
|
||||
options are discussed in docs/INSTALL.autoconf. The following list of
|
||||
options is extracted from the man-db manual. It is strongly recommended
|
||||
that relevant sections of the manual are read if any of these options are
|
||||
used.
|
||||
|
||||
* `--enable-cache-owner[=ARG]`
|
||||
|
||||
By default, system-wide cache files will be owned by user man. Use this
|
||||
option with an argument to change the cache file owner.
|
||||
|
||||
* `--disable-cache-owner`
|
||||
|
||||
Use this option to leave the ownership of system-wide cache files
|
||||
unconstrained. Users will be allowed to modify them.
|
||||
|
||||
* `--disable-setuid`
|
||||
|
||||
By default, man will be installed as a setuid program to the user that
|
||||
owns the system-wide cache files. Use this option to install man as a
|
||||
non-setuid program instead.
|
||||
|
||||
* `--enable-mandirs=OS`
|
||||
|
||||
By default, man-db supports manual page directories in any of several
|
||||
layouts used by free and proprietary versions of UNIX. However, in
|
||||
certain cases, this can cause man-db to find the wrong page by mistake,
|
||||
especially when the names of some manual pages on the system contain
|
||||
periods. Use this option with an argument of GNU, HPUX, IRIX, Solaris,
|
||||
or BSD (or more than one of these, separated by commas) to support only
|
||||
the layouts typically used on each of those systems. Note that man-db is
|
||||
not currently capable of writing cat pages in the proper BSD layout.
|
||||
|
||||
* `--with-device=DEVICE`
|
||||
|
||||
Use this flag to alter the default output device used by NROFF. DEVICE is
|
||||
passed to NROFF with the -T option. configure will test that NROFF will
|
||||
run with the supplied device argument.
|
||||
|
||||
* `--with-db=LIBRARY`
|
||||
|
||||
configure will look for database interface libraries in the order gdbm,
|
||||
Berkeley DB and finally ndbm and will #define appropriate variables
|
||||
relative to the first one found. To override the built-in order on
|
||||
platforms having a choice of interface library, use this option to
|
||||
specify which library to use.
|
||||
|
||||
* `--enable-automatic-create`
|
||||
|
||||
If this flag is used, man will automatically create index databases for
|
||||
users' private manual page hierarchies.
|
||||
|
||||
* `--disable-automatic-update`
|
||||
|
||||
Normally, man will update entries in index databases if it finds newly
|
||||
installed manual pages (if the --update flag is used) or delete entries
|
||||
if manual pages are removed. This flag suppresses this behaviour.
|
||||
|
||||
* `--disable-cats`
|
||||
|
||||
Normally, man will automatically try to create cat files corresponding to
|
||||
manual files when a manual page is read. This flag suppresses this
|
||||
behaviour.
|
||||
|
||||
* `--disable-manual`
|
||||
|
||||
Don't build or install the man-db manual. This may be useful when
|
||||
cross-compiling, or to reduce the installation size.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Configure man-db:
|
||||
|
||||
* **Read** `docs/INSTALL.autoconf` regarding `./configure` options.
|
||||
|
||||
* **Run** `./configure --help` to see what `--enable` and `--with`
|
||||
options may be useful.
|
||||
|
||||
* **Run** `./configure` with the appropriate options and environment
|
||||
variable settings.
|
||||
|
||||
**Browse** or **edit** the following files that were created by the
|
||||
configuration process:
|
||||
|
||||
* `include/manconfig.h` regarding the default section list and other
|
||||
specific definitions.
|
||||
|
||||
* `lib/compression.c` if the default compressor support is
|
||||
inadequate for your requirements. (Usually `.Z` [compress],
|
||||
`.z`, `.gz` [gzip].)
|
||||
|
||||
configure will determine your system's ability to use native language
|
||||
support (NLS) message catalogues. You may set the environment variable
|
||||
`LINGUAS` to limit the set of translations installed. `LINGUAS` should
|
||||
contain a space-separated list of two-letter language identifiers. To
|
||||
compile man-db with no support for message catalogues, simply pass the
|
||||
`--disable-nls` option to configure. N.B. This is not related to man's
|
||||
ability to display NLS manual pages, support for which is compiled in by
|
||||
default.
|
||||
|
||||
Build man-db:
|
||||
|
||||
* **Run** `make` to compile man-db with the set of translations chosen
|
||||
when running `./configure`.
|
||||
|
||||
Sort out the man-db configuration file.
|
||||
|
||||
* **Run** `./src/man -l man/man5/manpath.5` from the root of this
|
||||
distribution to read the man-db configuration file details.
|
||||
|
||||
* **Edit** `./src/man_db.conf` to your local requirements.
|
||||
|
||||
Install the package.
|
||||
|
||||
* (gain superuser privileges for the rest of the steps)
|
||||
|
||||
* **Run** `make install` to install the utilities and manual pages.
|
||||
|
||||
Initialise the index databases for all manpaths marked as global in the
|
||||
man-db configuration file.
|
||||
|
||||
* **Run** `mandb` (this step is equivalent to running straycats and
|
||||
makewhatis too).
|
||||
|
||||
The following steps are optional / dependent on local conventions.
|
||||
|
||||
* **Acknowledge** any warnings emitted by mandb. Bogus manual pages
|
||||
are not included in the database and may be a waste of space.
|
||||
Those pages without correctly formatted "whatis" lines are
|
||||
included, but will have a whatis entry of "(unknown)"
|
||||
|
||||
* `cd tools` and **run** `mkcatdirs -t` to see if you have all of the
|
||||
required cat directories. `mkcatdirs` without an option will
|
||||
display a usage message.
|
||||
|
||||
* `cd tools` and **run** `checkman` with an argument of colon-separated
|
||||
manual page hierarchies to cross check for duplicated manual
|
||||
pages. If no argument is given, your default `$MANPATH` will be
|
||||
used.
|
||||
|
||||
The output of `checkman` may be piped into a file and used as an
|
||||
argument to `rm`; the "is newer than" messages are directed to
|
||||
standard error. E.g. `checkman > dups`
|
||||
|
||||
If you are confident that the duplicates found are indeed
|
||||
duplicates, you can back them up and delete them to save space.
|
||||
|
||||
At this point, running `checkman` again may yield further duplicates
|
||||
that were ignored the first time.
|
||||
|
||||
* **Run** `catman` with appropriate options to create any/all cat files
|
||||
that you would like pre-formatted.
|
||||
|
||||
|
||||
## Multiple build directories
|
||||
|
||||
It is possible to build man-db in a directory other than the directory
|
||||
containing this file (and all of the program sources). This is particularly
|
||||
useful if compiling on multiple architectures or testing various
|
||||
configuration options as only a single copy of the sources is required.
|
||||
|
||||
To enable this support, simply change directory to where you would like to
|
||||
build the package and run the configure program in this directory
|
||||
*from there*. Further information about this support can be found in the
|
||||
generic install document `docs/INSTALL.autoconf`.
|
||||
|
||||
|
||||
## Makefile targets and variables
|
||||
|
||||
The standard GNU Makefile targets: `all`, `install`, `uninstall`,
|
||||
`mostlyclean`, `clean`, `distclean`, `realclean` and `TAGS` are available in
|
||||
every Makefile- supported directory. In addition, the master Makefile has
|
||||
the `dist` target to create a compressed and tarred distribution file.
|
||||
|
||||
During the configuration process, `configure` sets the installation
|
||||
variables, `prefix` and `exec_prefix`. These are then used to form other
|
||||
variables such as `bindir` and `sysconfdir`. To change any of these or
|
||||
other standard GNU install variables dynamically, issue the `make` command
|
||||
with variable expressions as arguments, eg. `make prefix=/usr/local/packages`
|
||||
|
||||
N.B. If `prefix=/usr` (either statically or dynamically), then
|
||||
`sysconfdir=/etc` instead of the usual `$(prefix)/etc`. To force
|
||||
`sysconfdir` to be `/usr/etc`, set it on the make command line.
|
||||
|
||||
|
||||
## Default preprocessors
|
||||
|
||||
man-db uses a manual page directed preprocessor system, that is, each manual
|
||||
page may request preprocessing by a selection of preprocessors. Some
|
||||
systems' manual pages do not come with this information built in. In such
|
||||
circumstances, it is advisable to set a default list of preprocessors that
|
||||
each manual page should be passed through, so that those requiring special
|
||||
processing are readable. To achieve this, set `DEFAULT_MANROFFSEQ` (found in
|
||||
`include/manconfig.h`) to the appropriate preprocessor string, after running
|
||||
configure, but prior to compilation. This is not necessary for the
|
||||
following systems whose default preprocessing requirements are known.
|
||||
|
||||
* Known not to require `DEFAULT_MANROFFSEQ`:
|
||||
|
||||
Linux, SunOS
|
||||
|
||||
* Known to require `#define DEFAULT_MANROFFSEQ "t"`:
|
||||
|
||||
Ultrix
|
||||
|
||||
* Known to require `#define DEFAULT_MANROFFSEQ "te"`:
|
||||
|
||||
HP-UX, OSF/1
|
||||
|
||||
If unsure of the default preprocessors required by a system, the standard
|
||||
system's man(1) manual page may provide an answer.
|
||||
|
||||
|
||||
## Contacting the maintainer
|
||||
|
||||
The current maintainer of man-db is Colin Watson <cjwatson@debian.org>.
|
||||
Please feel free to contact me with any queries or problems you may have.
|
||||
You can report bugs here:
|
||||
|
||||
https://gitlab.com/man-db/man-db/-/issues
|
||||
|
||||
Bugs from before the migration to GitLab may be found here:
|
||||
|
||||
https://savannah.nongnu.org/bugs/?group=man-db
|
2022
aclocal.m4
vendored
Normal file
2022
aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load diff
184
bootstrap.conf
Normal file
184
bootstrap.conf
Normal file
|
@ -0,0 +1,184 @@
|
|||
# Bootstrap configuration.
|
||||
|
||||
# Copyright (C) 2006-2018 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
GNULIB_REVISION=0ba13435a9362bec0ff5fd0830907b9fac723e41
|
||||
|
||||
# gnulib modules used by this package.
|
||||
gnulib_modules="
|
||||
argp
|
||||
array-list
|
||||
attribute
|
||||
c99
|
||||
canonicalize
|
||||
closedir
|
||||
dirent
|
||||
dirname
|
||||
error
|
||||
fcntl-h
|
||||
flock
|
||||
fnmatch-gnu
|
||||
fstat
|
||||
getline
|
||||
gettext-h
|
||||
gitlog-to-changelog
|
||||
glob
|
||||
gnupload
|
||||
hash-map
|
||||
hash-pjw-bare
|
||||
hash-set
|
||||
havelib
|
||||
idpriv-drop
|
||||
idpriv-droptemp
|
||||
lchown
|
||||
lib-ignore
|
||||
linkedhash-list
|
||||
localcharset
|
||||
manywarnings
|
||||
memmem
|
||||
minmax
|
||||
mkdtemp
|
||||
mkstemp
|
||||
nanosleep
|
||||
nonblocking
|
||||
nullptr
|
||||
openat
|
||||
opendir
|
||||
progname
|
||||
raise
|
||||
rbtree-list
|
||||
regex
|
||||
rename
|
||||
renameat
|
||||
setenv
|
||||
sigaction
|
||||
signal-h
|
||||
sigpipe
|
||||
sigprocmask
|
||||
stat-time
|
||||
stdbool
|
||||
stpcpy
|
||||
strcase
|
||||
strcasestr
|
||||
strerror
|
||||
strsep
|
||||
tempname
|
||||
termios
|
||||
timespec
|
||||
unlinkat
|
||||
utimens
|
||||
verror
|
||||
warnings
|
||||
xalloc
|
||||
xgetcwd
|
||||
xlist
|
||||
xmap
|
||||
xset
|
||||
xstdopen
|
||||
xstrndup
|
||||
xvasprintf
|
||||
year2038-recommended
|
||||
"
|
||||
|
||||
gnulib_tool_option_extras="\
|
||||
--no-conditional-dependencies \
|
||||
--libtool \
|
||||
--macro-prefix=gl \
|
||||
--no-vc-files \
|
||||
"
|
||||
|
||||
# bootstrap's --skip-po option really just controls its own downloads, but
|
||||
# it's somewhat useful to provide a way to skip the downloads performed by
|
||||
# gnulib-tool as well. Since we always suppress bootstrap's downloads due
|
||||
# to maintaining man-db's own translations manually, we need to parse the
|
||||
# command line ourselves to find out whether --skip-po was explicitly
|
||||
# passed.
|
||||
explicit_skip_po=
|
||||
for option; do
|
||||
case $option in
|
||||
--skip-po)
|
||||
explicit_skip_po=t
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$explicit_skip_po" ]; then
|
||||
gnulib_tool_option_extras="$gnulib_tool_option_extras --po-base=gl/ref-po --po-domain=man-db"
|
||||
fi
|
||||
|
||||
# This doesn't currently exist, but we set it to avoid confusion with 'gl'
|
||||
# as the local output directory.
|
||||
local_gl_dir=gnulib-local
|
||||
|
||||
gnulib_name=libgnu
|
||||
source_base=gl/lib
|
||||
m4_base=gl/m4
|
||||
|
||||
COPYRIGHT_HOLDER='Colin Watson <cjwatson@debian.org>'
|
||||
MSGID_BUGS_ADDRESS="$COPYRIGHT_HOLDER"
|
||||
|
||||
# Additional xgettext options to use. Use "\\\newline" to break lines.
|
||||
XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||
--from-code=UTF-8\\\
|
||||
--flag=debug:1:c-format\\\
|
||||
--flag=debug_error:1:c-format\\\
|
||||
--flag=fatal:2:c-format\\\
|
||||
'
|
||||
|
||||
checkout_only_file=
|
||||
copy=true
|
||||
vc_ignore=
|
||||
|
||||
SKIP_PO=t
|
||||
|
||||
# Build prerequisites
|
||||
buildreq="\
|
||||
autoconf 2.64
|
||||
automake 1.14
|
||||
autopoint 0.18.3
|
||||
gettext 0.18.3
|
||||
git 1.5.5
|
||||
tar -
|
||||
"
|
||||
|
||||
bootstrap_post_import_hook () {
|
||||
patch -s -p1 <patches/argp-domain.patch
|
||||
|
||||
if [ -z "$explicit_skip_po" ]; then
|
||||
# gnulib-tool installs its own versions of gettext infrastructure files
|
||||
# such as po/Makefile.in.in, which don't necessarily match our
|
||||
# configured AM_GNU_GETTEXT_VERSION. To cope with this, we tell
|
||||
# gnulib-tool to install into a temporary directory (using --po-base
|
||||
# above) and fix things up here.
|
||||
cp -a gl/ref-po/LINGUAS gl/ref-po/POTFILES.in gl/po/
|
||||
sed 's,^subdir *=.*,subdir = gl/po,' gl/ref-po/Makevars >gl/po/Makevars
|
||||
if ls gl/ref-po/*.po >/dev/null 2>&1; then
|
||||
cp -a gl/ref-po/*.po gl/po/
|
||||
fi
|
||||
rm -rf gl/ref-po
|
||||
fi
|
||||
}
|
||||
|
||||
bootstrap_epilogue () {
|
||||
# If --copy is not used, then INSTALL may be a symbolic link, in which
|
||||
# case a simple "mv" could leave it pointing to the wrong target. Arrange
|
||||
# (reasonably portably) for the target to end up as a regular file no
|
||||
# matter what.
|
||||
rm -f docs/INSTALL.autoconf
|
||||
cp -Lp INSTALL docs/INSTALL.autoconf
|
||||
rm -f INSTALL
|
||||
}
|
279
build-aux/ar-lib
Executable file
279
build-aux/ar-lib
Executable file
|
@ -0,0 +1,279 @@
|
|||
#! /bin/sh
|
||||
# Wrapper for Microsoft lib.exe
|
||||
|
||||
me=ar-lib
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
|
||||
# Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
# Written by Peter Rosin <peda@lysator.liu.se>.
|
||||
#
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
|
||||
# func_error message
|
||||
func_error ()
|
||||
{
|
||||
echo "$me: $1" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN* | MSYS*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv in
|
||||
mingw)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin | msys)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_at_file at_file operation archive
|
||||
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
|
||||
# for each of them.
|
||||
# When interpreting the content of the @FILE, do NOT use func_file_conv,
|
||||
# since the user would need to supply preconverted file names to
|
||||
# binutils ar, at least for MinGW.
|
||||
func_at_file ()
|
||||
{
|
||||
operation=$2
|
||||
archive=$3
|
||||
at_file_contents=`cat "$1"`
|
||||
eval set x "$at_file_contents"
|
||||
shift
|
||||
|
||||
for member
|
||||
do
|
||||
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
|
||||
done
|
||||
}
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
func_error "no command. Try '$0 --help' for more information."
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<EOF
|
||||
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
|
||||
|
||||
Members may be specified in a file named with @FILE.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
GNU Automake home page: <https://www.gnu.org/software/automake/>.
|
||||
General help using GNU software: <https://www.gnu.org/gethelp/>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "$me (GNU Automake) $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test $# -lt 3; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
|
||||
AR=$1
|
||||
shift
|
||||
while :
|
||||
do
|
||||
if test $# -lt 2; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
case $1 in
|
||||
-lib | -LIB \
|
||||
| -ltcg | -LTCG \
|
||||
| -machine* | -MACHINE* \
|
||||
| -subsystem* | -SUBSYSTEM* \
|
||||
| -verbose | -VERBOSE \
|
||||
| -wx* | -WX* )
|
||||
AR="$AR $1"
|
||||
shift
|
||||
;;
|
||||
-nologo | -NOLOGO)
|
||||
# We always invoke AR with -nologo, so don't need to add it again.
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
action=$1
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
orig_archive=$1
|
||||
shift
|
||||
func_file_conv "$orig_archive"
|
||||
archive=$file
|
||||
|
||||
# strip leading dash in $action
|
||||
action=${action#-}
|
||||
|
||||
delete=
|
||||
extract=
|
||||
list=
|
||||
quick=
|
||||
replace=
|
||||
index=
|
||||
create=
|
||||
|
||||
while test -n "$action"
|
||||
do
|
||||
case $action in
|
||||
d*) delete=yes ;;
|
||||
x*) extract=yes ;;
|
||||
t*) list=yes ;;
|
||||
q*) quick=yes ;;
|
||||
r*) replace=yes ;;
|
||||
s*) index=yes ;;
|
||||
S*) ;; # the index is always updated implicitly
|
||||
c*) create=yes ;;
|
||||
u*) ;; # TODO: don't ignore the update modifier
|
||||
v*) ;; # TODO: don't ignore the verbose modifier
|
||||
*)
|
||||
func_error "unknown action specified"
|
||||
;;
|
||||
esac
|
||||
action=${action#?}
|
||||
done
|
||||
|
||||
case $delete$extract$list$quick$replace,$index in
|
||||
yes,* | ,yes)
|
||||
;;
|
||||
yesyes*)
|
||||
func_error "more than one action specified"
|
||||
;;
|
||||
*)
|
||||
func_error "no action specified"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -n "$delete"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -REMOVE "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
elif test -n "$extract"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
if test $# -gt 0; then
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -EXTRACT "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
$AR -NOLOGO -LIST "$archive" | tr -d '\r' | sed -e 's/\\/\\\\/g' \
|
||||
| while read member
|
||||
do
|
||||
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
|
||||
done
|
||||
fi
|
||||
|
||||
elif test -n "$quick$replace"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
if test -z "$create"; then
|
||||
echo "$me: creating $orig_archive"
|
||||
fi
|
||||
orig_archive=
|
||||
else
|
||||
orig_archive=$archive
|
||||
fi
|
||||
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_file_conv "${1#@}"
|
||||
set x "$@" "@$file"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
set x "$@" "$file"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
shift
|
||||
done
|
||||
|
||||
if test -n "$orig_archive"; then
|
||||
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
|
||||
else
|
||||
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
|
||||
fi
|
||||
|
||||
elif test -n "$list"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
$AR -NOLOGO -LIST "$archive" || exit $?
|
||||
fi
|
351
build-aux/compile
Executable file
351
build-aux/compile
Executable file
|
@ -0,0 +1,351 @@
|
|||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
|
||||
# Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN* | MSYS*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/* | msys/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.lo | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
GNU Automake home page: <https://www.gnu.org/software/automake/>.
|
||||
General help using GNU software: <https://www.gnu.org/gethelp/>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile (GNU Automake) $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
|
||||
clang-cl | *[/\\]clang-cl | clang-cl.exe | *[/\\]clang-cl.exe | \
|
||||
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
1812
build-aux/config.guess
vendored
Executable file
1812
build-aux/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load diff
751
build-aux/config.rpath
Executable file
751
build-aux/config.rpath
Executable file
|
@ -0,0 +1,751 @@
|
|||
#! /bin/sh
|
||||
# Output a system dependent set of variables, describing how to set the
|
||||
# run time search path of shared libraries in a binary (executable or
|
||||
# shared library).
|
||||
#
|
||||
# Copyright 1996-2024 Free Software Foundation, Inc.
|
||||
# Taken from GNU libtool, 2001
|
||||
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# Known limitations:
|
||||
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
|
||||
# than 256 bytes, otherwise the compiler driver will dump core. The only
|
||||
# known workaround is to choose shorter directory names for the build
|
||||
# directory and/or the installation directory.
|
||||
|
||||
# func_usage
|
||||
# outputs to stdout the --help usage message.
|
||||
func_usage ()
|
||||
{
|
||||
echo "\
|
||||
Usage: config.rpath [OPTION] HOST
|
||||
|
||||
Prints shell variable assignments that describe how to hardcode a directory
|
||||
for the lookup of shared libraries into a binary (executable or shared library).
|
||||
|
||||
The first argument passed to this file is the canonical host specification,
|
||||
CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
|
||||
or
|
||||
CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
|
||||
|
||||
The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
|
||||
should be set by the caller.
|
||||
|
||||
The set of defined variables is at the end of this script.
|
||||
|
||||
Options:
|
||||
--help print this help and exit
|
||||
--version print version information and exit
|
||||
|
||||
Send patches and bug reports to <bug-gnulib@gnu.org>."
|
||||
}
|
||||
|
||||
# func_version
|
||||
# outputs to stdout the --version message.
|
||||
func_version ()
|
||||
{
|
||||
echo "config.rpath (GNU gnulib, module havelib)"
|
||||
echo "Copyright (C) 2024 Free Software Foundation, Inc.
|
||||
License: All-Permissive.
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law."
|
||||
echo
|
||||
printf 'Written by %s.\n' "Bruno Haible"
|
||||
}
|
||||
|
||||
# func_fatal_error message
|
||||
# outputs to stderr a fatal error message, and terminates the program.
|
||||
func_fatal_error ()
|
||||
{
|
||||
echo "config.rpath: *** $1" 1>&2
|
||||
echo "config.rpath: *** Stop." 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Command-line option processing.
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
--help | --hel | --he | --h )
|
||||
func_usage
|
||||
exit 0 ;;
|
||||
--version | --versio | --versi | --vers | --ver | --ve | --v )
|
||||
func_version
|
||||
exit 0 ;;
|
||||
-- ) # Stop option processing
|
||||
shift; break ;;
|
||||
-* )
|
||||
func_fatal_error "unrecognized option: $1"
|
||||
;;
|
||||
* )
|
||||
break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test $# -gt 1; then
|
||||
func_fatal_error "too many arguments"
|
||||
fi
|
||||
if test $# -lt 1; then
|
||||
func_fatal_error "too few arguments"
|
||||
fi
|
||||
|
||||
# All known linkers require a '.a' archive for static linking (except MSVC,
|
||||
# which needs '.lib').
|
||||
libext=a
|
||||
shrext=.so
|
||||
|
||||
host="$1"
|
||||
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
|
||||
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
|
||||
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
||||
|
||||
# Code taken from libtool.m4's _LT_CC_BASENAME.
|
||||
|
||||
for cc_temp in $CC""; do
|
||||
case $cc_temp in
|
||||
compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
|
||||
distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
|
||||
\-*) ;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
|
||||
|
||||
# Code taken from libtool.m4's _LT_COMPILER_PIC.
|
||||
|
||||
wl=
|
||||
if test "$GCC" = yes; then
|
||||
wl='-Wl,'
|
||||
else
|
||||
case "$host_os" in
|
||||
aix*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
mingw* | cygwin* | pw32* | os2* | cegcc*)
|
||||
;;
|
||||
hpux9* | hpux10* | hpux11*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
irix5* | irix6* | nonstopux*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
linux* | k*bsd*-gnu | kopensolaris*-gnu)
|
||||
case $cc_basename in
|
||||
ecc*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
icc* | ifort*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
lf95*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
nagfor*)
|
||||
wl='-Wl,-Wl,,'
|
||||
;;
|
||||
pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
ccc*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
xl* | bgxl* | bgf* | mpixl*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
como)
|
||||
wl='-lopt='
|
||||
;;
|
||||
*)
|
||||
case `$CC -V 2>&1 | sed 5q` in
|
||||
*Sun\ F* | *Sun*Fortran*)
|
||||
wl=
|
||||
;;
|
||||
*Sun\ C*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
newsos6)
|
||||
;;
|
||||
*nto* | *qnx*)
|
||||
;;
|
||||
osf3* | osf4* | osf5*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
rdos*)
|
||||
;;
|
||||
solaris*)
|
||||
case $cc_basename in
|
||||
f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
|
||||
wl='-Qoption ld '
|
||||
;;
|
||||
*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
sunos4*)
|
||||
wl='-Qoption ld '
|
||||
;;
|
||||
sysv4 | sysv4.2uw2* | sysv4.3*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
sysv4*MP*)
|
||||
;;
|
||||
sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
unicos*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
uts4*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Code taken from libtool.m4's _LT_LINKER_SHLIBS.
|
||||
|
||||
hardcode_libdir_flag_spec=
|
||||
hardcode_libdir_separator=
|
||||
hardcode_direct=no
|
||||
hardcode_minus_L=no
|
||||
|
||||
case "$host_os" in
|
||||
cygwin* | mingw* | pw32* | cegcc*)
|
||||
# FIXME: the MSVC++ port hasn't been tested in a loooong time
|
||||
# When not using gcc, we currently assume that we are using
|
||||
# Microsoft Visual C++.
|
||||
if test "$GCC" != yes; then
|
||||
with_gnu_ld=no
|
||||
fi
|
||||
;;
|
||||
interix*)
|
||||
# we just hope/assume this is gcc and not c89 (= MSVC++)
|
||||
with_gnu_ld=yes
|
||||
;;
|
||||
openbsd*)
|
||||
with_gnu_ld=no
|
||||
;;
|
||||
esac
|
||||
|
||||
ld_shlibs=yes
|
||||
if test "$with_gnu_ld" = yes; then
|
||||
# Set some defaults for GNU ld with shared library support. These
|
||||
# are reset later if shared libraries are not supported. Putting them
|
||||
# here allows them to be overridden if necessary.
|
||||
# Unlike libtool, we use -rpath here, not --rpath, since the documented
|
||||
# option of GNU ld is called -rpath, not --rpath.
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
case "$host_os" in
|
||||
aix[3-9]*)
|
||||
# On AIX/PPC, the GNU linker is very broken
|
||||
if test "$host_cpu" != ia64; then
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
amigaos*)
|
||||
case "$host_cpu" in
|
||||
powerpc)
|
||||
;;
|
||||
m68k)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
beos*)
|
||||
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
cygwin* | mingw* | pw32* | cegcc*)
|
||||
# hardcode_libdir_flag_spec is actually meaningless, as there is
|
||||
# no search path for DLLs.
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
haiku*)
|
||||
;;
|
||||
interix[3-9]*)
|
||||
hardcode_direct=no
|
||||
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
|
||||
;;
|
||||
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
|
||||
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
netbsd*)
|
||||
;;
|
||||
solaris*)
|
||||
if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
|
||||
ld_shlibs=no
|
||||
elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
|
||||
case `$LD -v 2>&1` in
|
||||
*\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
|
||||
ld_shlibs=no
|
||||
;;
|
||||
*)
|
||||
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
|
||||
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
sunos4*)
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
*)
|
||||
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if test "$ld_shlibs" = no; then
|
||||
hardcode_libdir_flag_spec=
|
||||
fi
|
||||
else
|
||||
case "$host_os" in
|
||||
aix3*)
|
||||
# Note: this linker hardcodes the directories in LIBPATH if there
|
||||
# are no directories specified by -L.
|
||||
hardcode_minus_L=yes
|
||||
if test "$GCC" = yes; then
|
||||
# Neither direct hardcoding nor static linking is supported with a
|
||||
# broken collect2.
|
||||
hardcode_direct=unsupported
|
||||
fi
|
||||
;;
|
||||
aix[4-9]*)
|
||||
if test "$host_cpu" = ia64; then
|
||||
# On IA64, the linker does run time linking by default, so we don't
|
||||
# have to do anything special.
|
||||
aix_use_runtimelinking=no
|
||||
else
|
||||
aix_use_runtimelinking=no
|
||||
# Test if we are trying to use run time linking or normal
|
||||
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
|
||||
# need to do runtime linking.
|
||||
case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
|
||||
for ld_flag in $LDFLAGS; do
|
||||
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
|
||||
aix_use_runtimelinking=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
hardcode_direct=yes
|
||||
hardcode_libdir_separator=':'
|
||||
if test "$GCC" = yes; then
|
||||
case $host_os in aix4.[012]|aix4.[012].*)
|
||||
collect2name=`${CC} -print-prog-name=collect2`
|
||||
if test -f "$collect2name" && \
|
||||
strings "$collect2name" | grep resolve_lib_name >/dev/null
|
||||
then
|
||||
# We have reworked collect2
|
||||
:
|
||||
else
|
||||
# We have old collect2
|
||||
hardcode_direct=unsupported
|
||||
hardcode_minus_L=yes
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_libdir_separator=
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
# Begin _LT_AC_SYS_LIBPATH_AIX.
|
||||
echo 'int main () { return 0; }' > conftest.c
|
||||
${CC} ${LDFLAGS} conftest.c -o conftest
|
||||
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
|
||||
}'`
|
||||
if test -z "$aix_libpath"; then
|
||||
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
|
||||
}'`
|
||||
fi
|
||||
if test -z "$aix_libpath"; then
|
||||
aix_libpath="/usr/lib:/lib"
|
||||
fi
|
||||
rm -f conftest.c conftest
|
||||
# End _LT_AC_SYS_LIBPATH_AIX.
|
||||
if test "$aix_use_runtimelinking" = yes; then
|
||||
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
|
||||
else
|
||||
if test "$host_cpu" = ia64; then
|
||||
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
|
||||
else
|
||||
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
amigaos*)
|
||||
case "$host_cpu" in
|
||||
powerpc)
|
||||
;;
|
||||
m68k)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
bsdi[45]*)
|
||||
;;
|
||||
cygwin* | mingw* | pw32* | cegcc*)
|
||||
# When not using gcc, we currently assume that we are using
|
||||
# Microsoft Visual C++.
|
||||
# hardcode_libdir_flag_spec is actually meaningless, as there is
|
||||
# no search path for DLLs.
|
||||
hardcode_libdir_flag_spec=' '
|
||||
libext=lib
|
||||
;;
|
||||
darwin* | rhapsody*)
|
||||
hardcode_direct=no
|
||||
if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
dgux*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
;;
|
||||
freebsd2.[01]*)
|
||||
hardcode_direct=yes
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
freebsd* | dragonfly* | midnightbsd*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
hpux9*)
|
||||
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
hardcode_direct=yes
|
||||
# hardcode_minus_L: Not really in the search PATH,
|
||||
# but as the default location of the library.
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
hpux10*)
|
||||
if test "$with_gnu_ld" = no; then
|
||||
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
hardcode_direct=yes
|
||||
# hardcode_minus_L: Not really in the search PATH,
|
||||
# but as the default location of the library.
|
||||
hardcode_minus_L=yes
|
||||
fi
|
||||
;;
|
||||
hpux11*)
|
||||
if test "$with_gnu_ld" = no; then
|
||||
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
case $host_cpu in
|
||||
hppa*64*|ia64*)
|
||||
hardcode_direct=no
|
||||
;;
|
||||
*)
|
||||
hardcode_direct=yes
|
||||
# hardcode_minus_L: Not really in the search PATH,
|
||||
# but as the default location of the library.
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
irix5* | irix6* | nonstopux*)
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
netbsd*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
newsos6)
|
||||
hardcode_direct=yes
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
*nto* | *qnx*)
|
||||
;;
|
||||
openbsd*)
|
||||
if test -f /usr/libexec/ld.so; then
|
||||
hardcode_direct=yes
|
||||
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
|
||||
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
|
||||
else
|
||||
case "$host_os" in
|
||||
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
;;
|
||||
*)
|
||||
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
os2*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
osf3*)
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
osf4* | osf5*)
|
||||
if test "$GCC" = yes; then
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
else
|
||||
# Both cc and cxx compiler support -rpath directly
|
||||
hardcode_libdir_flag_spec='-rpath $libdir'
|
||||
fi
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
solaris*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
;;
|
||||
sunos4*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_direct=yes
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
sysv4)
|
||||
case $host_vendor in
|
||||
sni)
|
||||
hardcode_direct=yes # is this really true???
|
||||
;;
|
||||
siemens)
|
||||
hardcode_direct=no
|
||||
;;
|
||||
motorola)
|
||||
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
sysv4.3*)
|
||||
;;
|
||||
sysv4*MP*)
|
||||
if test -d /usr/nec; then
|
||||
ld_shlibs=yes
|
||||
fi
|
||||
;;
|
||||
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
|
||||
;;
|
||||
sysv5* | sco3.2v5* | sco5v6*)
|
||||
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
|
||||
hardcode_libdir_separator=':'
|
||||
;;
|
||||
uts4*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
;;
|
||||
*)
|
||||
ld_shlibs=no
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Check dynamic linker characteristics
|
||||
# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER.
|
||||
# Unlike libtool.m4, here we don't care about _all_ names of the library, but
|
||||
# only about the one the linker finds when passed -lNAME. This is the last
|
||||
# element of library_names_spec in libtool.m4, or possibly two of them if the
|
||||
# linker has special search rules.
|
||||
library_names_spec= # the last element of library_names_spec in libtool.m4
|
||||
libname_spec='lib$name'
|
||||
case "$host_os" in
|
||||
aix3*)
|
||||
library_names_spec='$libname.a'
|
||||
;;
|
||||
aix[4-9]*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
amigaos*)
|
||||
case "$host_cpu" in
|
||||
powerpc*)
|
||||
library_names_spec='$libname$shrext' ;;
|
||||
m68k)
|
||||
library_names_spec='$libname.a' ;;
|
||||
esac
|
||||
;;
|
||||
beos*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
bsdi[45]*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
cygwin* | mingw* | pw32* | cegcc*)
|
||||
shrext=.dll
|
||||
library_names_spec='$libname.dll.a $libname.lib'
|
||||
;;
|
||||
darwin* | rhapsody*)
|
||||
shrext=.dylib
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
dgux*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
freebsd[23].*)
|
||||
library_names_spec='$libname$shrext$versuffix'
|
||||
;;
|
||||
freebsd* | dragonfly* | midnightbsd*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
gnu*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
haiku*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
hpux9* | hpux10* | hpux11*)
|
||||
case $host_cpu in
|
||||
ia64*)
|
||||
shrext=.so
|
||||
;;
|
||||
hppa*64*)
|
||||
shrext=.sl
|
||||
;;
|
||||
*)
|
||||
shrext=.sl
|
||||
;;
|
||||
esac
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
interix[3-9]*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
irix5* | irix6* | nonstopux*)
|
||||
library_names_spec='$libname$shrext'
|
||||
case "$host_os" in
|
||||
irix5* | nonstopux*)
|
||||
libsuff= shlibsuff=
|
||||
;;
|
||||
*)
|
||||
case $LD in
|
||||
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
|
||||
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
|
||||
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
|
||||
*) libsuff= shlibsuff= ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
linux*oldld* | linux*aout* | linux*coff*)
|
||||
;;
|
||||
linux* | k*bsd*-gnu | kopensolaris*-gnu)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
knetbsd*-gnu)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
netbsd*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
newsos6)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
*nto* | *qnx*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
openbsd*)
|
||||
library_names_spec='$libname$shrext$versuffix'
|
||||
;;
|
||||
os2*)
|
||||
libname_spec='$name'
|
||||
shrext=.dll
|
||||
library_names_spec='$libname.a'
|
||||
;;
|
||||
osf3* | osf4* | osf5*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
rdos*)
|
||||
;;
|
||||
solaris*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
sunos4*)
|
||||
library_names_spec='$libname$shrext$versuffix'
|
||||
;;
|
||||
sysv4 | sysv4.3*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
sysv4*MP*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
tpf*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
uts4*)
|
||||
library_names_spec='$libname$shrext'
|
||||
;;
|
||||
esac
|
||||
|
||||
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
|
||||
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
|
||||
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
|
||||
escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
|
||||
escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
|
||||
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
|
||||
|
||||
LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
|
||||
|
||||
# How to pass a linker flag through the compiler.
|
||||
wl="$escaped_wl"
|
||||
|
||||
# Static library suffix (normally "a").
|
||||
libext="$libext"
|
||||
|
||||
# Shared library suffix (normally "so").
|
||||
shlibext="$shlibext"
|
||||
|
||||
# Format of library name prefix.
|
||||
libname_spec="$escaped_libname_spec"
|
||||
|
||||
# Library names that the linker finds when passed -lNAME.
|
||||
library_names_spec="$escaped_library_names_spec"
|
||||
|
||||
# Flag to hardcode \$libdir into a binary during linking.
|
||||
# This must work even if \$libdir does not exist.
|
||||
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
|
||||
|
||||
# Whether we need a single -rpath flag with a separated argument.
|
||||
hardcode_libdir_separator="$hardcode_libdir_separator"
|
||||
|
||||
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
|
||||
# resulting binary.
|
||||
hardcode_direct="$hardcode_direct"
|
||||
|
||||
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
|
||||
# resulting binary.
|
||||
hardcode_minus_L="$hardcode_minus_L"
|
||||
|
||||
EOF
|
1971
build-aux/config.sub
vendored
Executable file
1971
build-aux/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load diff
792
build-aux/depcomp
Executable file
792
build-aux/depcomp
Executable file
|
@ -0,0 +1,792 @@
|
|||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
|
||||
# Copyright (C) 1999-2024 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by 'PROGRAMS ARGS'.
|
||||
object Object file output by 'PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
GNU Automake home page: <https://www.gnu.org/software/automake/>.
|
||||
General help using GNU software: <https://www.gnu.org/gethelp/>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp (GNU Automake) $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get the directory component of the given path, and save it in the
|
||||
# global variables '$dir'. Note that this directory component will
|
||||
# be either empty or ending with a '/' character. This is deliberate.
|
||||
set_dir_from ()
|
||||
{
|
||||
case $1 in
|
||||
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
|
||||
*) dir=;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Get the suffix-stripped basename of the given path, and save it the
|
||||
# global variable '$base'.
|
||||
set_base_from ()
|
||||
{
|
||||
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
|
||||
}
|
||||
|
||||
# If no dependency file was actually created by the compiler invocation,
|
||||
# we still have to create a dummy depfile, to avoid errors with the
|
||||
# Makefile "include basename.Plo" scheme.
|
||||
make_dummy_depfile ()
|
||||
{
|
||||
echo "#dummy" > "$depfile"
|
||||
}
|
||||
|
||||
# Factor out some common post-processing of the generated depfile.
|
||||
# Requires the auxiliary global variable '$tmpdepfile' to be set.
|
||||
aix_post_process_depfile ()
|
||||
{
|
||||
# If the compiler actually managed to produce a dependency file,
|
||||
# post-process it.
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form 'foo.o: dependency.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# $object: dependency.h
|
||||
# and one to simply output
|
||||
# dependency.h:
|
||||
# which is needed to avoid the deleted-header problem.
|
||||
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
|
||||
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
|
||||
} > "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
}
|
||||
|
||||
# A tabulation character.
|
||||
tab=' '
|
||||
# A newline character.
|
||||
nl='
|
||||
'
|
||||
# Character ranges might be problematic outside the C locale.
|
||||
# These definitions help.
|
||||
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
lower=abcdefghijklmnopqrstuvwxyz
|
||||
alpha=${upper}${lower}
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Avoid interference from the environment.
|
||||
gccflag= dashmflag=
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
if test "$depmode" = msvc7msys; then
|
||||
# This is just like msvc7 but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u='sed s,\\\\,/,g'
|
||||
depmode=msvc7
|
||||
fi
|
||||
|
||||
if test "$depmode" = xlc; then
|
||||
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
|
||||
gccflag=-qmakedep=gcc,-MF
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## Note that this doesn't just cater to obsolete pre-3.x GCC compilers.
|
||||
## but also to in-use compilers like IBM xlc/xlC and the HP C compiler.
|
||||
## (see the conditional assignment to $gccflag above).
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say). Also, it might not be
|
||||
## supported by the other compilers which use the 'gcc' depmode.
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The second -e expression handles DOS-style file names with drive
|
||||
# letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the "deleted header file" problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
## Some versions of gcc put a space before the ':'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well. hp depmode also adds that space, but also prefixes the VPATH
|
||||
## to the object. Take care to not repeat it in the output.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like '#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
|
||||
| tr "$nl" ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
xlc)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts '$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
tcc)
|
||||
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
|
||||
# FIXME: That version still under development at the moment of writing.
|
||||
# Make that this statement remains true also for stable, released
|
||||
# versions.
|
||||
# It will wrap lines (doesn't matter whether long or short) with a
|
||||
# trailing '\', as in:
|
||||
#
|
||||
# foo.o : \
|
||||
# foo.c \
|
||||
# foo.h \
|
||||
#
|
||||
# It will put a trailing '\' even on the last line, and will use leading
|
||||
# spaces rather than leading tabs (at least since its commit 0394caf7
|
||||
# "Emit spaces for -MD").
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
|
||||
# We have to change lines of the first kind to '$object: \'.
|
||||
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
|
||||
# And for each line of the second kind, we have to emit a 'dep.h:'
|
||||
# dummy dependency, to avoid the deleted-header problem.
|
||||
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
## The order of this option in the case statement is important, since the
|
||||
## shell code in configure will try each of these formats in the order
|
||||
## listed in this file. A plain '-MD' option would be understood by many
|
||||
## compilers, so we must ensure this comes after the gcc and icc options.
|
||||
pgcc)
|
||||
# Portland's C compiler understands '-MD'.
|
||||
# Will always output deps to 'file.d' where file is the root name of the
|
||||
# source file under compilation, even if file resides in a subdirectory.
|
||||
# The object file name does not affect the name of the '.d' file.
|
||||
# pgcc 10.2 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using '\' :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
set_dir_from "$object"
|
||||
# Use the source, not the object, to determine the base name, since
|
||||
# that's sadly what pgcc will do too.
|
||||
set_base_from "$source"
|
||||
tmpdepfile=$base.d
|
||||
|
||||
# For projects that build the same source file twice into different object
|
||||
# files, the pgcc approach of using the *source* file root name can cause
|
||||
# problems in parallel builds. Use a locking strategy to avoid stomping on
|
||||
# the same $tmpdepfile.
|
||||
lockdir=$base.d-lock
|
||||
trap "
|
||||
echo '$0: caught signal, cleaning up...' >&2
|
||||
rmdir '$lockdir'
|
||||
exit 1
|
||||
" 1 2 13 15
|
||||
numtries=100
|
||||
i=$numtries
|
||||
while test $i -gt 0; do
|
||||
# mkdir is a portable test-and-set.
|
||||
if mkdir "$lockdir" 2>/dev/null; then
|
||||
# This process acquired the lock.
|
||||
"$@" -MD
|
||||
stat=$?
|
||||
# Release the lock.
|
||||
rmdir "$lockdir"
|
||||
break
|
||||
else
|
||||
# If the lock is being held by a different process, wait
|
||||
# until the winning process is done or we timeout.
|
||||
while test -d "$lockdir" && test $i -gt 0; do
|
||||
sleep 1
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
fi
|
||||
i=`expr $i - 1`
|
||||
done
|
||||
trap - 1 2 13 15
|
||||
if test $i -le 0; then
|
||||
echo "$0: failed to acquire lock after $numtries attempts" >&2
|
||||
echo "$0: check lockdir '$lockdir'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add 'dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
make_dummy_depfile
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in 'foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
set_dir_from "$object"
|
||||
set_base_from "$object"
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# Libtool generates 2 separate objects for the 2 libraries. These
|
||||
# two compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
|
||||
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
# Same post-processing that is required for AIX mode.
|
||||
aix_post_process_depfile
|
||||
;;
|
||||
|
||||
msvc7)
|
||||
if test "$libtool" = yes; then
|
||||
showIncludes=-Wc,-showIncludes
|
||||
else
|
||||
showIncludes=-showIncludes
|
||||
fi
|
||||
"$@" $showIncludes > "$tmpdepfile"
|
||||
stat=$?
|
||||
grep -v '^Note: including file: ' "$tmpdepfile"
|
||||
if test $stat -ne 0; then
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
# The first sed program below extracts the file names and escapes
|
||||
# backslashes for cygpath. The second sed program outputs the file
|
||||
# name when reading, but also accumulates all include files in the
|
||||
# hold buffer in order to output them again at the end. This only
|
||||
# works with sed implementations that can handle large buffers.
|
||||
sed < "$tmpdepfile" -n '
|
||||
/^Note: including file: *\(.*\)/ {
|
||||
s//\1/
|
||||
s/\\/\\\\/g
|
||||
p
|
||||
}' | $cygpath_u | sort -u | sed -n '
|
||||
s/ /\\ /g
|
||||
s/\(.*\)/'"$tab"'\1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/'"$tab"'/
|
||||
G
|
||||
p
|
||||
}' >> "$depfile"
|
||||
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvc7msys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for ':'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this sed invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
tr ' ' "$nl" < "$tmpdepfile" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
# makedepend may prepend the VPATH from the source file name to the object.
|
||||
# No need to regex-escape $object, excess matching of '.' is harmless.
|
||||
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process the last invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed '1,2d' "$tmpdepfile" \
|
||||
| tr ' ' "$nl" \
|
||||
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove '-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E \
|
||||
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
| sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
|
||||
echo "$tab" >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
516
build-aux/gitlog-to-changelog
Executable file
516
build-aux/gitlog-to-changelog
Executable file
|
@ -0,0 +1,516 @@
|
|||
#!/bin/sh
|
||||
#! -*-perl-*-
|
||||
|
||||
# Convert git log output to ChangeLog format.
|
||||
|
||||
# Copyright (C) 2008-2024 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Written by Jim Meyering
|
||||
|
||||
# This is a prologue that allows running a perl script as an executable
|
||||
# on systems that are compliant to a POSIX version before POSIX:2017.
|
||||
# On such systems, the usual invocation of an executable through execlp()
|
||||
# or execvp() fails with ENOEXEC if it is a script that does not start
|
||||
# with a #! line. The script interpreter mentioned in the #! line has
|
||||
# to be /bin/sh, because on GuixSD systems that is the only program that
|
||||
# has a fixed file name. The second line is essential for perl and is
|
||||
# also useful for editing this file in Emacs. The next two lines below
|
||||
# are valid code in both sh and perl. When executed by sh, they re-execute
|
||||
# the script through the perl program found in $PATH. The '-x' option
|
||||
# is essential as well; without it, perl would re-execute the script
|
||||
# through /bin/sh. When executed by perl, the next two lines are a no-op.
|
||||
eval 'exec perl -wSx "$0" "$@"'
|
||||
if 0;
|
||||
|
||||
my $VERSION = '2023-06-24 21:59'; # UTC
|
||||
# The definition above must lie within the first 8 lines in order
|
||||
# for the Emacs time-stamp write hook (at end) to update it.
|
||||
# If you change this file with Emacs, please let the write hook
|
||||
# do its job. Otherwise, update this string manually.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
use POSIX qw(strftime);
|
||||
|
||||
(my $ME = $0) =~ s|.*/||;
|
||||
|
||||
# use File::Coda; # https://meyering.net/code/Coda/
|
||||
END {
|
||||
defined fileno STDOUT or return;
|
||||
close STDOUT and return;
|
||||
warn "$ME: failed to close standard output: $!\n";
|
||||
$? ||= 1;
|
||||
}
|
||||
|
||||
sub usage ($)
|
||||
{
|
||||
my ($exit_code) = @_;
|
||||
my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
|
||||
if ($exit_code != 0)
|
||||
{
|
||||
print $STREAM "Try '$ME --help' for more information.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print $STREAM <<EOF;
|
||||
Usage: $ME [OPTIONS] [ARGS]
|
||||
|
||||
Convert git log output to ChangeLog format. If present, any ARGS
|
||||
are passed to "git log". To avoid ARGS being parsed as options to
|
||||
$ME, they may be preceded by '--'.
|
||||
|
||||
OPTIONS:
|
||||
|
||||
--amend=FILE FILE maps from an SHA1 to perl code (i.e., s/old/new/) that
|
||||
makes a change to SHA1's commit log text or metadata.
|
||||
--append-dot append a dot to the first line of each commit message if
|
||||
there is no other punctuation or blank at the end.
|
||||
--no-cluster never cluster commit messages under the same date/author
|
||||
header; the default is to cluster adjacent commit messages
|
||||
if their headers are the same and neither commit message
|
||||
contains multiple paragraphs.
|
||||
--srcdir=DIR the root of the source tree, from which the .git/
|
||||
directory can be derived.
|
||||
--since=DATE convert only the logs since DATE;
|
||||
the default is to convert all log entries.
|
||||
--until=DATE convert only the logs older than DATE.
|
||||
--ignore-matching=PAT ignore commit messages whose first lines match PAT.
|
||||
--ignore-line=PAT ignore lines of commit messages that match PAT.
|
||||
--format=FMT set format string for commit subject and body;
|
||||
see 'man git-log' for the list of format metacharacters;
|
||||
the default is '%s%n%b%n'
|
||||
--strip-tab remove one additional leading TAB from commit message lines.
|
||||
--strip-cherry-pick remove data inserted by "git cherry-pick";
|
||||
this includes the "cherry picked from commit ..." line,
|
||||
and the possible final "Conflicts:" paragraph.
|
||||
--help display this help and exit
|
||||
--version output version information and exit
|
||||
|
||||
EXAMPLE:
|
||||
|
||||
$ME --since=2008-01-01 > ChangeLog
|
||||
$ME -- -n 5 foo > last-5-commits-to-branch-foo
|
||||
|
||||
SPECIAL SYNTAX:
|
||||
|
||||
The following types of strings are interpreted specially when they appear
|
||||
at the beginning of a log message line. They are not copied to the output.
|
||||
|
||||
Copyright-paperwork-exempt: Yes
|
||||
Append the "(tiny change)" notation to the usual "date name email"
|
||||
ChangeLog header to mark a change that does not require a copyright
|
||||
assignment.
|
||||
Co-authored-by: Joe User <user\@example.com>
|
||||
List the specified name and email address on a second
|
||||
ChangeLog header, denoting a co-author.
|
||||
Signed-off-by: Joe User <user\@example.com>
|
||||
These lines are simply elided.
|
||||
|
||||
In a FILE specified via --amend, comment lines (starting with "#") are ignored.
|
||||
FILE must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1 (alone on
|
||||
a line) referring to a commit in the current project, and CODE refers to one
|
||||
or more consecutive lines of Perl code. Pairs must be separated by one or
|
||||
more blank line.
|
||||
|
||||
Here is sample input for use with --amend=FILE, from coreutils:
|
||||
|
||||
3a169f4c5d9159283548178668d2fae6fced3030
|
||||
# fix typo in title:
|
||||
s/all tile types/all file types/
|
||||
|
||||
1379ed974f1fa39b12e2ffab18b3f7a607082202
|
||||
# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself.
|
||||
# Change the author to be Paul. Note the escaped "@":
|
||||
s,Jim .*>,Paul Eggert <eggert\\\@cs.ucla.edu>,
|
||||
|
||||
EOF
|
||||
}
|
||||
exit $exit_code;
|
||||
}
|
||||
|
||||
# If the string $S is a well-behaved file name, simply return it.
|
||||
# If it contains white space, quotes, etc., quote it, and return the new string.
|
||||
sub shell_quote($)
|
||||
{
|
||||
my ($s) = @_;
|
||||
if ($s =~ m![^\w+/.,-]!)
|
||||
{
|
||||
# Convert each single quote to '\''
|
||||
$s =~ s/\'/\'\\\'\'/g;
|
||||
# Then single quote the string.
|
||||
$s = "'$s'";
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
sub quoted_cmd(@)
|
||||
{
|
||||
return join (' ', map {shell_quote $_} @_);
|
||||
}
|
||||
|
||||
# Parse file F.
|
||||
# Comment lines (starting with "#") are ignored.
|
||||
# F must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1
|
||||
# (alone on a line) referring to a commit in the current project, and
|
||||
# CODE refers to one or more consecutive lines of Perl code.
|
||||
# Pairs must be separated by one or more blank line.
|
||||
sub parse_amend_file($)
|
||||
{
|
||||
my ($f) = @_;
|
||||
|
||||
open F, '<', $f
|
||||
or die "$ME: $f: failed to open for reading: $!\n";
|
||||
|
||||
my $fail;
|
||||
my $h = {};
|
||||
my $in_code = 0;
|
||||
my $sha;
|
||||
while (defined (my $line = <F>))
|
||||
{
|
||||
$line =~ /^\#/
|
||||
and next;
|
||||
chomp $line;
|
||||
$line eq ''
|
||||
and $in_code = 0, next;
|
||||
|
||||
if (!$in_code)
|
||||
{
|
||||
$line =~ /^([[:xdigit:]]{40})$/
|
||||
or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"),
|
||||
$fail = 1, next;
|
||||
$sha = lc $1;
|
||||
$in_code = 1;
|
||||
exists $h->{$sha}
|
||||
and (warn "$ME: $f:$.: duplicate SHA1\n"),
|
||||
$fail = 1, next;
|
||||
}
|
||||
else
|
||||
{
|
||||
$h->{$sha} ||= '';
|
||||
$h->{$sha} .= "$line\n";
|
||||
}
|
||||
}
|
||||
close F;
|
||||
|
||||
$fail
|
||||
and exit 1;
|
||||
|
||||
return $h;
|
||||
}
|
||||
|
||||
# git_dir_option $SRCDIR
|
||||
#
|
||||
# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR
|
||||
# is undef). Return as a list (0 or 1 element).
|
||||
sub git_dir_option($)
|
||||
{
|
||||
my ($srcdir) = @_;
|
||||
my @res = ();
|
||||
if (defined $srcdir)
|
||||
{
|
||||
my $qdir = shell_quote $srcdir;
|
||||
my $cmd = "cd $qdir && git rev-parse --show-toplevel";
|
||||
my $qcmd = shell_quote $cmd;
|
||||
my $git_dir = qx($cmd);
|
||||
defined $git_dir
|
||||
or die "$ME: cannot run $qcmd: $!\n";
|
||||
$? == 0
|
||||
or die "$ME: $qcmd had unexpected exit code or signal ($?)\n";
|
||||
chomp $git_dir;
|
||||
push @res, "--git-dir=$git_dir/.git";
|
||||
}
|
||||
@res;
|
||||
}
|
||||
|
||||
{
|
||||
my $since_date;
|
||||
my $until_date;
|
||||
my $format_string = '%s%n%b%n';
|
||||
my $amend_file;
|
||||
my $append_dot = 0;
|
||||
my $cluster = 1;
|
||||
my $ignore_matching;
|
||||
my $ignore_line;
|
||||
my $strip_tab = 0;
|
||||
my $strip_cherry_pick = 0;
|
||||
my $srcdir;
|
||||
GetOptions
|
||||
(
|
||||
help => sub { usage 0 },
|
||||
version => sub { print "$ME version $VERSION\n"; exit },
|
||||
'since=s' => \$since_date,
|
||||
'until=s' => \$until_date,
|
||||
'format=s' => \$format_string,
|
||||
'amend=s' => \$amend_file,
|
||||
'append-dot' => \$append_dot,
|
||||
'cluster!' => \$cluster,
|
||||
'ignore-matching=s' => \$ignore_matching,
|
||||
'ignore-line=s' => \$ignore_line,
|
||||
'strip-tab' => \$strip_tab,
|
||||
'strip-cherry-pick' => \$strip_cherry_pick,
|
||||
'srcdir=s' => \$srcdir,
|
||||
) or usage 1;
|
||||
|
||||
defined $since_date
|
||||
and unshift @ARGV, "--since=$since_date";
|
||||
defined $until_date
|
||||
and unshift @ARGV, "--until=$until_date";
|
||||
|
||||
# This is a hash that maps an SHA1 to perl code (i.e., s/old/new/)
|
||||
# that makes a correction in the log or attribution of that commit.
|
||||
my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {};
|
||||
|
||||
my @cmd = ('git',
|
||||
git_dir_option $srcdir,
|
||||
qw(log --log-size),
|
||||
'--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV);
|
||||
open PIPE, '-|', @cmd
|
||||
or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n"
|
||||
. "(Is your Git too old? Version 1.5.1 or later is required.)\n");
|
||||
|
||||
my $prev_multi_paragraph;
|
||||
my $prev_date_line = '';
|
||||
my @prev_coauthors = ();
|
||||
my @skipshas = ();
|
||||
while (1)
|
||||
{
|
||||
defined (my $in = <PIPE>)
|
||||
or last;
|
||||
$in =~ /^log size (\d+)$/
|
||||
or die "$ME:$.: Invalid line (expected log size):\n$in";
|
||||
my $log_nbytes = $1;
|
||||
|
||||
my $log;
|
||||
my $n_read = read PIPE, $log, $log_nbytes;
|
||||
$n_read == $log_nbytes
|
||||
or die "$ME:$.: unexpected EOF\n";
|
||||
|
||||
# Extract leading hash.
|
||||
my ($sha, $rest) = split ':', $log, 2;
|
||||
defined $sha
|
||||
or die "$ME:$.: malformed log entry\n";
|
||||
$sha =~ /^[[:xdigit:]]{40}$/
|
||||
or die "$ME:$.: invalid SHA1: $sha\n";
|
||||
|
||||
my $skipflag = 0;
|
||||
if (@skipshas)
|
||||
{
|
||||
foreach(@skipshas)
|
||||
{
|
||||
if ($sha =~ /^$_/)
|
||||
{
|
||||
$skipflag = $_;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# If this commit's log requires any transformation, do it now.
|
||||
my $code = $amend_code->{$sha};
|
||||
if (defined $code)
|
||||
{
|
||||
eval 'use Safe';
|
||||
my $s = new Safe;
|
||||
# Put the unpreprocessed entry into "$_".
|
||||
$_ = $rest;
|
||||
|
||||
# Let $code operate on it, safely.
|
||||
my $r = $s->reval("$code")
|
||||
or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n";
|
||||
|
||||
# Note that we've used this entry.
|
||||
delete $amend_code->{$sha};
|
||||
|
||||
# Update $rest upon success.
|
||||
$rest = $_;
|
||||
}
|
||||
|
||||
# Remove lines inserted by "git cherry-pick".
|
||||
if ($strip_cherry_pick)
|
||||
{
|
||||
$rest =~ s/^\s*Conflicts:\n.*//sm;
|
||||
$rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m;
|
||||
}
|
||||
|
||||
my @line = split /[ \t]*\n/, $rest;
|
||||
my $author_line = shift @line;
|
||||
defined $author_line
|
||||
or die "$ME:$.: unexpected EOF\n";
|
||||
$author_line =~ /^(\d+) (.*>)$/
|
||||
or die "$ME:$.: Invalid line "
|
||||
. "(expected date/author/email):\n$author_line\n";
|
||||
|
||||
# Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog
|
||||
# '(tiny change)' annotation.
|
||||
my $tiny = (grep (/^(?:Copyright-paperwork-exempt|Tiny-change):\s+[Yy]es$/, @line)
|
||||
? ' (tiny change)' : '');
|
||||
|
||||
my $date_line = sprintf "%s %s$tiny\n",
|
||||
strftime ("%Y-%m-%d", localtime ($1)), $2;
|
||||
|
||||
my @coauthors = grep /^Co-authored-by:.*$/, @line;
|
||||
# Omit meta-data lines we've already interpreted.
|
||||
@line = grep !/^(?:Signed-off-by:[ ].*>$
|
||||
|Co-authored-by:[ ]
|
||||
|Copyright-paperwork-exempt:[ ]
|
||||
|Tiny-change:[ ]
|
||||
)/x, @line;
|
||||
|
||||
# Remove leading and trailing blank lines.
|
||||
if (@line)
|
||||
{
|
||||
while ($line[0] =~ /^\s*$/) { shift @line; }
|
||||
while ($line[$#line] =~ /^\s*$/) { pop @line; }
|
||||
}
|
||||
|
||||
# Handle Emacs gitmerge.el "skipped" commits.
|
||||
# Yes, this should be controlled by an option. So sue me.
|
||||
if ( grep /^(; )?Merge from /, @line )
|
||||
{
|
||||
my $found = 0;
|
||||
foreach (@line)
|
||||
{
|
||||
if (grep /^The following commit.*skipped:$/, $_)
|
||||
{
|
||||
$found = 1;
|
||||
## Reset at each merge to reduce chance of false matches.
|
||||
@skipshas = ();
|
||||
next;
|
||||
}
|
||||
if ($found && $_ =~ /^([[:xdigit:]]{7,}) [^ ]/)
|
||||
{
|
||||
push ( @skipshas, $1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Ignore commits that match the --ignore-matching pattern, if specified.
|
||||
if (defined $ignore_matching && @line && $line[0] =~ /$ignore_matching/)
|
||||
{
|
||||
$skipflag = 1;
|
||||
}
|
||||
elsif ($skipflag)
|
||||
{
|
||||
## Perhaps only warn if a pattern matches more than once?
|
||||
warn "$ME: warning: skipping $sha due to $skipflag\n";
|
||||
}
|
||||
|
||||
if (! $skipflag)
|
||||
{
|
||||
if (defined $ignore_line && @line)
|
||||
{
|
||||
@line = grep ! /$ignore_line/, @line;
|
||||
while ($line[$#line] =~ /^\s*$/) { pop @line; }
|
||||
}
|
||||
|
||||
# Record whether there are two or more paragraphs.
|
||||
my $multi_paragraph = grep /^\s*$/, @line;
|
||||
|
||||
# Format 'Co-authored-by: A U Thor <email@example.com>' lines in
|
||||
# standard multi-author ChangeLog format.
|
||||
for (@coauthors)
|
||||
{
|
||||
s/^Co-authored-by:\s*/\t /;
|
||||
s/\s*</ </;
|
||||
|
||||
/<.*?@.*\..*>/
|
||||
or warn "$ME: warning: missing email address for "
|
||||
. substr ($_, 5) . "\n";
|
||||
}
|
||||
|
||||
# If clustering of commit messages has been disabled, if this header
|
||||
# would be different from the previous date/name/etc. header,
|
||||
# or if this or the previous entry consists of two or more paragraphs,
|
||||
# then print the header.
|
||||
if ( ! $cluster
|
||||
|| $date_line ne $prev_date_line
|
||||
|| "@coauthors" ne "@prev_coauthors"
|
||||
|| $multi_paragraph
|
||||
|| $prev_multi_paragraph)
|
||||
{
|
||||
$prev_date_line eq ''
|
||||
or print "\n";
|
||||
print $date_line;
|
||||
@coauthors
|
||||
and print join ("\n", @coauthors), "\n";
|
||||
}
|
||||
$prev_date_line = $date_line;
|
||||
@prev_coauthors = @coauthors;
|
||||
$prev_multi_paragraph = $multi_paragraph;
|
||||
|
||||
# If there were any lines
|
||||
if (@line == 0)
|
||||
{
|
||||
warn "$ME: warning: empty commit message:\n"
|
||||
. " commit $sha\n $date_line\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($append_dot)
|
||||
{
|
||||
# If the first line of the message has enough room, then
|
||||
if (length $line[0] < 72)
|
||||
{
|
||||
# append a dot if there is no other punctuation or blank
|
||||
# at the end.
|
||||
$line[0] =~ /[[:punct:]\s]$/
|
||||
or $line[0] .= '.';
|
||||
}
|
||||
}
|
||||
|
||||
# Remove one additional leading TAB from each line.
|
||||
$strip_tab
|
||||
and map { s/^\t// } @line;
|
||||
|
||||
# Prefix each non-empty line with a TAB.
|
||||
@line = map { length $_ ? "\t$_" : '' } @line;
|
||||
|
||||
print "\n", join ("\n", @line), "\n";
|
||||
}
|
||||
}
|
||||
|
||||
defined ($in = <PIPE>)
|
||||
or last;
|
||||
$in ne "\n"
|
||||
and die "$ME:$.: unexpected line:\n$in";
|
||||
}
|
||||
|
||||
close PIPE
|
||||
or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n";
|
||||
# FIXME-someday: include $PROCESS_STATUS in the diagnostic
|
||||
|
||||
# Complain about any unused entry in the --amend=F specified file.
|
||||
my $fail = 0;
|
||||
foreach my $sha (sort keys %$amend_code)
|
||||
{
|
||||
warn "$ME:$amend_file: unused entry: $sha\n";
|
||||
$fail = 1;
|
||||
}
|
||||
|
||||
exit $fail;
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# mode: perl
|
||||
# indent-tabs-mode: nil
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-line-limit: 50
|
||||
# time-stamp-start: "my $VERSION = '"
|
||||
# time-stamp-format: "%:y-%02m-%02d %02H:%02M"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "'; # UTC"
|
||||
# End:
|
480
build-aux/gnupload
Executable file
480
build-aux/gnupload
Executable file
|
@ -0,0 +1,480 @@
|
|||
#!/bin/sh
|
||||
# Sign files and upload them.
|
||||
|
||||
scriptversion=2022-01-27.18; # UTC
|
||||
|
||||
# Copyright (C) 2004-2024 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Originally written by Alexandre Duret-Lutz <adl@gnu.org>.
|
||||
# The master copy of this file is maintained in the gnulib Git repository.
|
||||
# Please send bug reports and feature requests to bug-gnulib@gnu.org.
|
||||
|
||||
set -e
|
||||
|
||||
GPG=gpg
|
||||
# Choose the proper version of gpg, so as to avoid a
|
||||
# "gpg-agent is not available in this session" error
|
||||
# when gpg-agent is version 2 but gpg is still version 1.
|
||||
# FIXME-2020: remove, once all major distros ship gpg version 2 as /usr/bin/gpg
|
||||
gpg_agent_version=`(gpg-agent --version) 2>/dev/null | sed -e '2,$d' -e 's/^[^0-9]*//'`
|
||||
case "$gpg_agent_version" in
|
||||
2.*)
|
||||
gpg_version=`(gpg --version) 2>/dev/null | sed -e '2,$d' -e 's/^[^0-9]*//'`
|
||||
case "$gpg_version" in
|
||||
1.*)
|
||||
if (type gpg2) >/dev/null 2>/dev/null; then
|
||||
# gpg2 is present.
|
||||
GPG=gpg2
|
||||
else
|
||||
# gpg2 is missing. Ubuntu users should install the package 'gnupg2'.
|
||||
echo "WARNING: Using 'gpg', which is too old. You should install 'gpg2'." 1>&2
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
GPG="${GPG} --batch --no-tty"
|
||||
conffile=.gnuploadrc
|
||||
to=
|
||||
dry_run=false
|
||||
replace=
|
||||
symlink_files=
|
||||
delete_files=
|
||||
delete_symlinks=
|
||||
collect_var=
|
||||
dbg=
|
||||
nl='
|
||||
'
|
||||
|
||||
usage="Usage: $0 [OPTION]... [CMD] FILE... [[CMD] FILE...]
|
||||
|
||||
Sign all FILES, and process them at the destinations specified with --to.
|
||||
If CMD is not given, it defaults to uploading. See examples below.
|
||||
|
||||
Commands:
|
||||
--delete delete FILES from destination
|
||||
--symlink create symbolic links
|
||||
--rmsymlink remove symbolic links
|
||||
-- treat the remaining arguments as files to upload
|
||||
|
||||
Options:
|
||||
--to DEST specify a destination DEST for FILES
|
||||
(multiple --to options are allowed)
|
||||
--user NAME sign with key NAME
|
||||
--replace allow replacements of existing files
|
||||
--symlink-regex[=EXPR] use sed script EXPR to compute symbolic link names
|
||||
-n, --dry-run do nothing, show what would have been done
|
||||
(including the constructed directive file)
|
||||
--version output version information and exit
|
||||
-h, --help print this help text and exit
|
||||
|
||||
If --symlink-regex is given without EXPR, then the link target name
|
||||
is created by replacing the version information with '-latest', e.g.:
|
||||
foo-1.3.4.tar.gz -> foo-latest.tar.gz
|
||||
|
||||
Recognized destinations are:
|
||||
alpha.gnu.org:DIRECTORY
|
||||
savannah.gnu.org:DIRECTORY
|
||||
savannah.nongnu.org:DIRECTORY
|
||||
ftp.gnu.org:DIRECTORY
|
||||
build directive files and upload files by FTP
|
||||
download.gnu.org.ua:{alpha|ftp}/DIRECTORY
|
||||
build directive files and upload files by SFTP
|
||||
[user@]host:DIRECTORY upload files with scp
|
||||
|
||||
Options and commands are applied in order. If the file $conffile exists
|
||||
in the current working directory, its contents are prepended to the
|
||||
actual command line options. Use this to keep your defaults. Comments
|
||||
(#) and empty lines in $conffile are allowed.
|
||||
|
||||
<https://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html>
|
||||
gives some further background.
|
||||
|
||||
Examples:
|
||||
1. Upload foobar-1.0.tar.gz to ftp.gnu.org:
|
||||
gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz
|
||||
|
||||
2. Upload foobar-1.0.tar.gz and foobar-1.0.tar.xz to ftp.gnu.org:
|
||||
gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz foobar-1.0.tar.xz
|
||||
|
||||
3. Same as above, and also create symbolic links to foobar-latest.tar.*:
|
||||
gnupload --to ftp.gnu.org:foobar \\
|
||||
--symlink-regex \\
|
||||
foobar-1.0.tar.gz foobar-1.0.tar.xz
|
||||
|
||||
4. Create a symbolic link foobar-latest.tar.gz -> foobar-1.0.tar.gz
|
||||
and likewise for the corresponding .sig file:
|
||||
gnupload --to ftp.gnu.org:foobar \\
|
||||
--symlink foobar-1.0.tar.gz foobar-latest.tar.gz \\
|
||||
foobar-1.0.tar.gz.sig foobar-latest.tar.gz.sig
|
||||
or (equivalent):
|
||||
gnupload --to ftp.gnu.org:foobar \\
|
||||
--symlink foobar-1.0.tar.gz foobar-latest.tar.gz \\
|
||||
--symlink foobar-1.0.tar.gz.sig foobar-latest.tar.gz.sig
|
||||
|
||||
5. Upload foobar-0.9.90.tar.gz to two sites:
|
||||
gnupload --to alpha.gnu.org:foobar \\
|
||||
--to sources.redhat.com:~ftp/pub/foobar \\
|
||||
foobar-0.9.90.tar.gz
|
||||
|
||||
6. Delete oopsbar-0.9.91.tar.gz and upload foobar-0.9.91.tar.gz
|
||||
(the -- terminates the list of files to delete):
|
||||
gnupload --to alpha.gnu.org:foobar \\
|
||||
--to sources.redhat.com:~ftp/pub/foobar \\
|
||||
--delete oopsbar-0.9.91.tar.gz \\
|
||||
-- foobar-0.9.91.tar.gz
|
||||
|
||||
gnupload executes a program ncftpput to do the transfers; if you don't
|
||||
happen to have an ncftp package installed, the ncftpput-ftp script in
|
||||
the build-aux/ directory of the gnulib package
|
||||
(https://savannah.gnu.org/projects/gnulib) may serve as a replacement.
|
||||
|
||||
Send patches and bug reports to <bug-gnulib@gnu.org>."
|
||||
|
||||
copyright_year=`echo "$scriptversion" | sed -e 's/[^0-9].*//'`
|
||||
copyright="Copyright (C) ${copyright_year} Free Software Foundation, Inc.
|
||||
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>.
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law."
|
||||
|
||||
# Read local configuration file
|
||||
if test -r "$conffile"; then
|
||||
echo "$0: Reading configuration file $conffile"
|
||||
conf=`sed 's/#.*$//;/^$/d' "$conffile" | tr "\015$nl" ' '`
|
||||
eval set x "$conf \"\$@\""
|
||||
shift
|
||||
fi
|
||||
|
||||
while test -n "$1"; do
|
||||
case $1 in
|
||||
-*)
|
||||
collect_var=
|
||||
case $1 in
|
||||
-h | --help)
|
||||
echo "$usage"
|
||||
exit $?
|
||||
;;
|
||||
--to)
|
||||
if test -z "$2"; then
|
||||
echo "$0: Missing argument for --to" 1>&2
|
||||
exit 1
|
||||
elif echo "$2" | grep 'ftp-upload\.gnu\.org' >/dev/null; then
|
||||
echo "$0: Use ftp.gnu.org:PKGNAME or alpha.gnu.org:PKGNAME" >&2
|
||||
echo "$0: for the destination, not ftp-upload.gnu.org (which" >&2
|
||||
echo "$0: is used for direct ftp uploads, not with gnupload)." >&2
|
||||
echo "$0: See --help and its examples if need be." >&2
|
||||
exit 1
|
||||
else
|
||||
to="$to $2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--user)
|
||||
if test -z "$2"; then
|
||||
echo "$0: Missing argument for --user" 1>&2
|
||||
exit 1
|
||||
else
|
||||
GPG="$GPG --local-user $2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--delete)
|
||||
collect_var=delete_files
|
||||
;;
|
||||
--replace)
|
||||
replace="replace: true"
|
||||
;;
|
||||
--rmsymlink)
|
||||
collect_var=delete_symlinks
|
||||
;;
|
||||
--symlink-regex=*)
|
||||
symlink_expr=`expr "$1" : '[^=]*=\(.*\)'`
|
||||
;;
|
||||
--symlink-regex)
|
||||
symlink_expr='s|-[0-9][0-9\.]*\(-[0-9][0-9]*\)\{0,1\}\.|-latest.|'
|
||||
;;
|
||||
--symlink)
|
||||
collect_var=symlink_files
|
||||
;;
|
||||
-n | --dry-run)
|
||||
dry_run=:
|
||||
;;
|
||||
--version)
|
||||
echo "gnupload $scriptversion"
|
||||
echo "$copyright"
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
echo "$0: Unknown option '$1', try '$0 --help'" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
if test -z "$collect_var"; then
|
||||
break
|
||||
else
|
||||
eval "$collect_var=\"\$$collect_var $1\""
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
dprint()
|
||||
{
|
||||
echo "Running $* ..."
|
||||
}
|
||||
|
||||
if $dry_run; then
|
||||
dbg=dprint
|
||||
fi
|
||||
|
||||
if test -z "$to"; then
|
||||
echo "$0: Missing destination sites" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -n "$symlink_files"; then
|
||||
x=`echo "$symlink_files" | sed 's/[^ ]//g;s/ //g'`
|
||||
if test -n "$x"; then
|
||||
echo "$0: Odd number of symlink arguments" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $# = 0; then
|
||||
if test -z "${symlink_files}${delete_files}${delete_symlinks}"; then
|
||||
echo "$0: No file to upload" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Make sure all files exist. We don't want to ask
|
||||
# for the passphrase if the script will fail.
|
||||
for file
|
||||
do
|
||||
if test ! -f $file; then
|
||||
echo "$0: Cannot find '$file'" 1>&2
|
||||
exit 1
|
||||
elif test -n "$symlink_expr"; then
|
||||
linkname=`echo $file | sed "$symlink_expr"`
|
||||
if test -z "$linkname"; then
|
||||
echo "$0: symlink expression produces empty results" >&2
|
||||
exit 1
|
||||
elif test "$linkname" = $file; then
|
||||
echo "$0: symlink expression does not alter file name" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Make sure passphrase is not exported in the environment.
|
||||
unset passphrase
|
||||
unset passphrase_fd_0
|
||||
GNUPGHOME=${GNUPGHOME:-$HOME/.gnupg}
|
||||
|
||||
# Reset PATH to be sure that echo is a built-in. We will later use
|
||||
# 'echo $passphrase' to output the passphrase, so it is important that
|
||||
# it is a built-in (third-party programs tend to appear in 'ps'
|
||||
# listings with their arguments...).
|
||||
# Remember this script runs with 'set -e', so if echo is not built-in
|
||||
# it will exit now.
|
||||
if $dry_run || grep -q "^use-agent" $GNUPGHOME/gpg.conf; then :; else
|
||||
PATH=/empty echo -n "Enter GPG passphrase: "
|
||||
stty -echo
|
||||
read -r passphrase
|
||||
stty echo
|
||||
echo
|
||||
passphrase_fd_0="--passphrase-fd 0"
|
||||
fi
|
||||
|
||||
if test $# -ne 0; then
|
||||
for file
|
||||
do
|
||||
echo "Signing $file ..."
|
||||
rm -f $file.sig
|
||||
echo "$passphrase" | $dbg $GPG $passphrase_fd_0 -ba -o $file.sig $file
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# mkdirective DESTDIR BASE FILE STMT
|
||||
# Arguments: See upload, below
|
||||
mkdirective ()
|
||||
{
|
||||
stmt="$4"
|
||||
if test -n "$3"; then
|
||||
stmt="
|
||||
filename: $3$stmt"
|
||||
fi
|
||||
|
||||
cat >${2}.directive<<EOF
|
||||
version: 1.2
|
||||
directory: $1
|
||||
comment: gnupload v. $scriptversion$stmt
|
||||
EOF
|
||||
if $dry_run; then
|
||||
echo "File ${2}.directive:"
|
||||
cat ${2}.directive
|
||||
echo "File ${2}.directive:" | sed 's/./-/g'
|
||||
fi
|
||||
}
|
||||
|
||||
mksymlink ()
|
||||
{
|
||||
while test $# -ne 0
|
||||
do
|
||||
echo "symlink: $1 $2"
|
||||
shift
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
# upload DEST DESTDIR BASE FILE STMT FILES
|
||||
# Arguments:
|
||||
# DEST Destination site;
|
||||
# DESTDIR Destination directory;
|
||||
# BASE Base name for the directive file;
|
||||
# FILE Name of the file to distribute (may be empty);
|
||||
# STMT Additional statements for the directive file;
|
||||
# FILES List of files to upload.
|
||||
upload ()
|
||||
{
|
||||
dest=$1
|
||||
destdir=$2
|
||||
base=$3
|
||||
file=$4
|
||||
stmt=$5
|
||||
files=$6
|
||||
|
||||
rm -f $base.directive $base.directive.asc
|
||||
case $dest in
|
||||
alpha.gnu.org:*)
|
||||
mkdirective "$destdir" "$base" "$file" "$stmt"
|
||||
echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive
|
||||
$dbg ncftpput ftp-upload.gnu.org /incoming/alpha $files $base.directive.asc
|
||||
;;
|
||||
ftp.gnu.org:*)
|
||||
mkdirective "$destdir" "$base" "$file" "$stmt"
|
||||
echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive
|
||||
$dbg ncftpput ftp-upload.gnu.org /incoming/ftp $files $base.directive.asc
|
||||
;;
|
||||
savannah.gnu.org:*)
|
||||
if test -z "$files"; then
|
||||
echo "$0: warning: standalone directives not applicable for $dest" >&2
|
||||
fi
|
||||
$dbg ncftpput savannah.gnu.org /incoming/savannah/$destdir $files
|
||||
;;
|
||||
savannah.nongnu.org:*)
|
||||
if test -z "$files"; then
|
||||
echo "$0: warning: standalone directives not applicable for $dest" >&2
|
||||
fi
|
||||
$dbg ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files
|
||||
;;
|
||||
download.gnu.org.ua:alpha/*|download.gnu.org.ua:ftp/*)
|
||||
destdir_p1=`echo "$destdir" | sed 's,^[^/]*/,,'`
|
||||
destdir_topdir=`echo "$destdir" | sed 's,/.*,,'`
|
||||
mkdirective "$destdir_p1" "$base" "$file" "$stmt"
|
||||
echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive
|
||||
for f in $files $base.directive.asc
|
||||
do
|
||||
echo put $f
|
||||
done | $dbg sftp -b - download.gnu.org.ua:/incoming/$destdir_topdir
|
||||
;;
|
||||
/*)
|
||||
dest_host=`echo "$dest" | sed 's,:.*,,'`
|
||||
mkdirective "$destdir" "$base" "$file" "$stmt"
|
||||
echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive
|
||||
$dbg cp $files $base.directive.asc $dest_host
|
||||
;;
|
||||
*)
|
||||
if test -z "$files"; then
|
||||
echo "$0: warning: standalone directives not applicable for $dest" >&2
|
||||
fi
|
||||
$dbg scp $files $dest
|
||||
;;
|
||||
esac
|
||||
rm -f $base.directive $base.directive.asc
|
||||
}
|
||||
|
||||
#####
|
||||
# Process any standalone directives
|
||||
stmt=
|
||||
if test -n "$symlink_files"; then
|
||||
stmt="$stmt
|
||||
`mksymlink $symlink_files`"
|
||||
fi
|
||||
|
||||
for file in $delete_files
|
||||
do
|
||||
stmt="$stmt
|
||||
archive: $file"
|
||||
done
|
||||
|
||||
for file in $delete_symlinks
|
||||
do
|
||||
stmt="$stmt
|
||||
rmsymlink: $file"
|
||||
done
|
||||
|
||||
if test -n "$stmt"; then
|
||||
for dest in $to
|
||||
do
|
||||
destdir=`echo $dest | sed 's/[^:]*://'`
|
||||
upload "$dest" "$destdir" "`hostname`-$$" "" "$stmt"
|
||||
done
|
||||
fi
|
||||
|
||||
# Process actual uploads
|
||||
for dest in $to
|
||||
do
|
||||
for file
|
||||
do
|
||||
echo "Uploading $file to $dest ..."
|
||||
stmt=
|
||||
#
|
||||
# allowing file replacement is all or nothing.
|
||||
if test -n "$replace"; then stmt="$stmt
|
||||
$replace"
|
||||
fi
|
||||
#
|
||||
files="$file $file.sig"
|
||||
destdir=`echo $dest | sed 's/[^:]*://'`
|
||||
if test -n "$symlink_expr"; then
|
||||
linkname=`echo $file | sed "$symlink_expr"`
|
||||
stmt="$stmt
|
||||
symlink: $file $linkname
|
||||
symlink: $file.sig $linkname.sig"
|
||||
fi
|
||||
upload "$dest" "$destdir" "$file" "$file" "$stmt" "$files"
|
||||
done
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
541
build-aux/install-sh
Executable file
541
build-aux/install-sh
Executable file
|
@ -0,0 +1,541 @@
|
|||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# 'make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
tab=' '
|
||||
nl='
|
||||
'
|
||||
IFS=" $tab$nl"
|
||||
|
||||
# Set DOITPROG to "echo" to test this script.
|
||||
|
||||
doit=${DOITPROG-}
|
||||
doit_exec=${doit:-exec}
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
# Create dirs (including intermediate dirs) using mode 755.
|
||||
# This is like GNU 'install' as of coreutils 8.32 (2020).
|
||||
mkdir_umask=22
|
||||
|
||||
backupsuffix=
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
is_target_a_directory=possibly
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-p pass -p to $cpprog.
|
||||
-s $stripprog installed files.
|
||||
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
|
||||
By default, rm is invoked with -f; when overridden with RMPROG,
|
||||
it's up to you to specify -f if you want it.
|
||||
|
||||
If -S is not specified, no backups are attempted.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
GNU Automake home page: <https://www.gnu.org/software/automake/>.
|
||||
General help using GNU software: <https://www.gnu.org/gethelp/>."
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-p) cpprog="$cpprog -p";;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-S) backupsuffix="$2"
|
||||
shift;;
|
||||
|
||||
-t)
|
||||
is_target_a_directory=always
|
||||
dst_arg=$2
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) is_target_a_directory=never;;
|
||||
|
||||
--version) echo "$0 (GNU Automake) $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# We allow the use of options -d and -T together, by making -d
|
||||
# take the precedence; this is for compatibility with GNU install.
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
if test -n "$dst_arg"; then
|
||||
echo "$0: target directory not allowed when installing a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call 'install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
||||
if test ! -d "$dst_arg"; then
|
||||
echo "$0: $dst_arg: Is not a directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names problematic for 'test' and other utilities.
|
||||
case $src in
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
# Don't chown directories that already exist.
|
||||
if test $dstdir_status = 0; then
|
||||
chowncmd=""
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
# If destination is a directory, append the input filename.
|
||||
if test -d "$dst"; then
|
||||
if test "$is_target_a_directory" = never; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dstbase=`basename "$src"`
|
||||
case $dst in
|
||||
*/) dst=$dst$dstbase;;
|
||||
*) dst=$dst/$dstbase;;
|
||||
esac
|
||||
dstdir_status=0
|
||||
else
|
||||
dstdir=`dirname "$dst"`
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
case $dstdir in
|
||||
*/) dstdirslash=$dstdir;;
|
||||
*) dstdirslash=$dstdir/;;
|
||||
esac
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
# The $RANDOM variable is not portable (e.g., dash). Use it
|
||||
# here however when possible just to lower collision chance.
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
|
||||
trap '
|
||||
ret=$?
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
|
||||
exit $ret
|
||||
' 0
|
||||
|
||||
# Because "mkdir -p" follows existing symlinks and we likely work
|
||||
# directly in world-writable /tmp, make sure that the '$tmpdir'
|
||||
# directory is successfully created first before we actually test
|
||||
# 'mkdir -p'.
|
||||
if (umask $mkdir_umask &&
|
||||
$mkdirprog $mkdir_mode "$tmpdir" &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibility with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
test_tmpdir="$tmpdir/a"
|
||||
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=${dstdirslash}_inst.$$_
|
||||
rmtmp=${dstdirslash}_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask &&
|
||||
{ test -z "$stripcmd" || {
|
||||
# Create $dsttmp read-write so that cp doesn't create it read-only,
|
||||
# which would cause strip to fail.
|
||||
if test -z "$doit"; then
|
||||
: >"$dsttmp" # No need to fork-exec 'touch'.
|
||||
else
|
||||
$doit touch "$dsttmp"
|
||||
fi
|
||||
}
|
||||
} &&
|
||||
$doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
set +f &&
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# If $backupsuffix is set, and the file being installed
|
||||
# already exists, attempt a backup. Don't worry if it fails,
|
||||
# e.g., if mv doesn't support -f.
|
||||
if test -n "$backupsuffix" && test -f "$dst"; then
|
||||
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
11523
build-aux/ltmain.sh
Executable file
11523
build-aux/ltmain.sh
Executable file
File diff suppressed because it is too large
Load diff
236
build-aux/missing
Executable file
236
build-aux/missing
Executable file
|
@ -0,0 +1,236 @@
|
|||
#! /bin/sh
|
||||
# Common wrapper for a few potentially missing GNU and other programs.
|
||||
|
||||
scriptversion=2024-06-07.14; # UTC
|
||||
|
||||
# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells
|
||||
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
|
||||
--is-lightweight)
|
||||
# Used by our autoconf macros to check whether the available missing
|
||||
# script is modern enough.
|
||||
exit 0
|
||||
;;
|
||||
|
||||
--run)
|
||||
# Back-compat with the calling convention used by older automake.
|
||||
shift
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
|
||||
to PROGRAM being missing or too old.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal autoconf autogen autoheader autom4te automake autoreconf
|
||||
bison flex help2man lex makeinfo perl yacc
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
|
||||
'g' are ignored when checking the name.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
GNU Automake home page: <https://www.gnu.org/software/automake/>.
|
||||
General help using GNU software: <https://www.gnu.org/gethelp/>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing (GNU Automake) $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: unknown '$1' option"
|
||||
echo 1>&2 "Try '$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# Run the given program, remember its exit status.
|
||||
"$@"; st=$?
|
||||
|
||||
# If it succeeded, we are done.
|
||||
test $st -eq 0 && exit 0
|
||||
|
||||
# Also exit now if we it failed (or wasn't found), and '--version' was
|
||||
# passed; such an option is passed most likely to detect whether the
|
||||
# program is present and works.
|
||||
case $2 in --version|--help) exit $st;; esac
|
||||
|
||||
# Exit code 63 means version mismatch. This often happens when the user
|
||||
# tries to use an ancient version of a tool on a file that requires a
|
||||
# minimum version.
|
||||
if test $st -eq 63; then
|
||||
msg="probably too old"
|
||||
elif test $st -eq 127; then
|
||||
# Program was missing.
|
||||
msg="missing on your system"
|
||||
else
|
||||
# Program was found and executed, but failed. Give up.
|
||||
exit $st
|
||||
fi
|
||||
|
||||
perl_URL=https://www.perl.org/
|
||||
flex_URL=https://github.com/westes/flex
|
||||
gnu_software_URL=https://www.gnu.org/software
|
||||
|
||||
program_details ()
|
||||
{
|
||||
case $1 in
|
||||
aclocal|automake|autoreconf)
|
||||
echo "The '$1' program is part of the GNU Automake package:"
|
||||
echo "<$gnu_software_URL/automake>"
|
||||
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/autoconf>"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
autoconf|autom4te|autoheader)
|
||||
echo "The '$1' program is part of the GNU Autoconf package:"
|
||||
echo "<$gnu_software_URL/autoconf/>"
|
||||
echo "It also requires GNU m4 and Perl in order to run:"
|
||||
echo "<$gnu_software_URL/m4/>"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
*)
|
||||
:
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
give_advice ()
|
||||
{
|
||||
# Normalize program name to check for.
|
||||
normalized_program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
printf '%s\n' "'$1' is $msg."
|
||||
|
||||
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
|
||||
autoheader_deps="'acconfig.h'"
|
||||
automake_deps="'Makefile.am'"
|
||||
aclocal_deps="'acinclude.m4'"
|
||||
case $normalized_program in
|
||||
aclocal*)
|
||||
echo "You should only need it if you modified $aclocal_deps or"
|
||||
echo "$configure_deps."
|
||||
;;
|
||||
autoconf*)
|
||||
echo "You should only need it if you modified $configure_deps."
|
||||
;;
|
||||
autogen*)
|
||||
echo "You should only need it if you modified a '.def' or '.tpl' file."
|
||||
echo "You may want to install the GNU AutoGen package:"
|
||||
echo "<$gnu_software_URL/autogen/>"
|
||||
;;
|
||||
autoheader*)
|
||||
echo "You should only need it if you modified $autoheader_deps or"
|
||||
echo "$configure_deps."
|
||||
;;
|
||||
automake*)
|
||||
echo "You should only need it if you modified $automake_deps or"
|
||||
echo "$configure_deps."
|
||||
;;
|
||||
autom4te*)
|
||||
echo "You might have modified some maintainer files that require"
|
||||
echo "the 'autom4te' program to be rebuilt."
|
||||
;;
|
||||
autoreconf*)
|
||||
echo "You should only need it if you modified $aclocal_deps or"
|
||||
echo "$automake_deps or $autoheader_deps or $automake_deps or"
|
||||
echo "$configure_deps."
|
||||
;;
|
||||
bison*|yacc*)
|
||||
echo "You should only need it if you modified a '.y' file."
|
||||
echo "You may want to install the GNU Bison package:"
|
||||
echo "<$gnu_software_URL/bison/>"
|
||||
;;
|
||||
help2man*)
|
||||
echo "You should only need it if you modified a dependency" \
|
||||
"of a man page."
|
||||
echo "You may want to install the GNU Help2man package:"
|
||||
echo "<$gnu_software_URL/help2man/>"
|
||||
;;
|
||||
lex*|flex*)
|
||||
echo "You should only need it if you modified a '.l' file."
|
||||
echo "You may want to install the Fast Lexical Analyzer package:"
|
||||
echo "<$flex_URL>"
|
||||
;;
|
||||
makeinfo*)
|
||||
echo "You should only need it if you modified a '.texi' file, or"
|
||||
echo "any other file indirectly affecting the aspect of the manual."
|
||||
echo "You might want to install the Texinfo package:"
|
||||
echo "<$gnu_software_URL/texinfo/>"
|
||||
echo "The spurious makeinfo call might also be the consequence of"
|
||||
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
|
||||
echo "want to install GNU make:"
|
||||
echo "<$gnu_software_URL/make/>"
|
||||
;;
|
||||
perl*)
|
||||
echo "You should only need it to run GNU Autoconf, GNU Automake, "
|
||||
echo " assorted other tools, or if you modified a Perl source file."
|
||||
echo "You may want to install the Perl 5 language interpreter:"
|
||||
echo "<$perl_URL>"
|
||||
;;
|
||||
*)
|
||||
echo "You might have modified some files without having the proper"
|
||||
echo "tools for further handling them. Check the 'README' file, it"
|
||||
echo "often tells you about the needed prerequisites for installing"
|
||||
echo "this package. You may also peek at any GNU archive site, in"
|
||||
echo "case some other package contains this missing '$1' program."
|
||||
;;
|
||||
esac
|
||||
program_details "$normalized_program"
|
||||
}
|
||||
|
||||
give_advice "$1" | sed -e '1s/^/WARNING: /' \
|
||||
-e '2,$s/^/ /' >&2
|
||||
|
||||
# Propagate the correct exit status (expected to be 127 for a program
|
||||
# not found, 63 for a program that failed due to version mismatch).
|
||||
exit $st
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
160
build-aux/test-driver
Executable file
160
build-aux/test-driver
Executable file
|
@ -0,0 +1,160 @@
|
|||
#! /bin/sh
|
||||
# test-driver - basic testsuite driver script.
|
||||
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
|
||||
# Copyright (C) 2011-2024 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
# Make unconditional expansion of undefined variables an error. This
|
||||
# helps a lot in preventing typo-related bugs.
|
||||
set -u
|
||||
|
||||
usage_error ()
|
||||
{
|
||||
echo "$0: $*" >&2
|
||||
print_usage >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
print_usage ()
|
||||
{
|
||||
cat <<END
|
||||
Usage:
|
||||
test-driver --test-name NAME --log-file PATH --trs-file PATH
|
||||
[--expect-failure {yes|no}] [--color-tests {yes|no}]
|
||||
[--collect-skipped-logs {yes|no}]
|
||||
[--enable-hard-errors {yes|no}] [--]
|
||||
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
|
||||
|
||||
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
|
||||
See the GNU Automake documentation for information.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
GNU Automake home page: <https://www.gnu.org/software/automake/>.
|
||||
General help using GNU software: <https://www.gnu.org/gethelp/>.
|
||||
END
|
||||
}
|
||||
|
||||
test_name= # Used for reporting.
|
||||
log_file= # Where to save the output of the test script.
|
||||
trs_file= # Where to save the metadata of the test run.
|
||||
expect_failure=no
|
||||
color_tests=no
|
||||
collect_skipped_logs=yes
|
||||
enable_hard_errors=yes
|
||||
while test $# -gt 0; do
|
||||
case $1 in
|
||||
--help) print_usage; exit $?;;
|
||||
--version) echo "test-driver (GNU Automake) $scriptversion"; exit $?;;
|
||||
--test-name) test_name=$2; shift;;
|
||||
--log-file) log_file=$2; shift;;
|
||||
--trs-file) trs_file=$2; shift;;
|
||||
--color-tests) color_tests=$2; shift;;
|
||||
--collect-skipped-logs) collect_skipped_logs=$2; shift;;
|
||||
--expect-failure) expect_failure=$2; shift;;
|
||||
--enable-hard-errors) enable_hard_errors=$2; shift;;
|
||||
--) shift; break;;
|
||||
-*) usage_error "invalid option: '$1'";;
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
missing_opts=
|
||||
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
|
||||
test x"$log_file" = x && missing_opts="$missing_opts --log-file"
|
||||
test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
|
||||
if test x"$missing_opts" != x; then
|
||||
usage_error "the following mandatory options are missing:$missing_opts"
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage_error "missing argument"
|
||||
fi
|
||||
|
||||
if test $color_tests = yes; then
|
||||
# Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
|
||||
red='[0;31m' # Red.
|
||||
grn='[0;32m' # Green.
|
||||
lgn='[1;32m' # Light green.
|
||||
blu='[1;34m' # Blue.
|
||||
mgn='[0;35m' # Magenta.
|
||||
std='[m' # No color.
|
||||
else
|
||||
red= grn= lgn= blu= mgn= std=
|
||||
fi
|
||||
|
||||
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
|
||||
trap "st=129; $do_exit" 1
|
||||
trap "st=130; $do_exit" 2
|
||||
trap "st=141; $do_exit" 13
|
||||
trap "st=143; $do_exit" 15
|
||||
|
||||
# Test script is run here. We create the file first, then append to it,
|
||||
# to ameliorate tests themselves also writing to the log file. Our tests
|
||||
# don't, but others can (automake bug#35762).
|
||||
: >"$log_file"
|
||||
"$@" >>"$log_file" 2>&1
|
||||
estatus=$?
|
||||
|
||||
if test $enable_hard_errors = no && test $estatus -eq 99; then
|
||||
tweaked_estatus=1
|
||||
else
|
||||
tweaked_estatus=$estatus
|
||||
fi
|
||||
|
||||
case $tweaked_estatus:$expect_failure in
|
||||
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
|
||||
0:*) col=$grn res=PASS recheck=no gcopy=no;;
|
||||
77:*) col=$blu res=SKIP recheck=no gcopy=$collect_skipped_logs;;
|
||||
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
|
||||
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
|
||||
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;
|
||||
esac
|
||||
|
||||
# Report the test outcome and exit status in the logs, so that one can
|
||||
# know whether the test passed or failed simply by looking at the '.log'
|
||||
# file, without the need of also peaking into the corresponding '.trs'
|
||||
# file (automake bug#11814).
|
||||
echo "$res $test_name (exit status: $estatus)" >>"$log_file"
|
||||
|
||||
# Report outcome to console.
|
||||
echo "${col}${res}${std}: $test_name"
|
||||
|
||||
# Register the test result, and other relevant metadata.
|
||||
echo ":test-result: $res" > $trs_file
|
||||
echo ":global-test-result: $res" >> $trs_file
|
||||
echo ":recheck: $recheck" >> $trs_file
|
||||
echo ":copy-in-global-log: $gcopy" >> $trs_file
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
245
build-aux/ylwrap
Executable file
245
build-aux/ylwrap
Executable file
|
@ -0,0 +1,245 @@
|
|||
#! /bin/sh
|
||||
# ylwrap - wrapper for lex/yacc invocations.
|
||||
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by Tom Tromey <tromey@cygnus.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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
get_dirname ()
|
||||
{
|
||||
case $1 in
|
||||
*/*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';;
|
||||
# Otherwise, we want the empty string (not ".").
|
||||
esac
|
||||
}
|
||||
|
||||
# guard FILE
|
||||
# ----------
|
||||
# The CPP macro used to guard inclusion of FILE.
|
||||
guard ()
|
||||
{
|
||||
printf '%s\n' "$1" \
|
||||
| sed \
|
||||
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
|
||||
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \
|
||||
-e 's/__*/_/g'
|
||||
}
|
||||
|
||||
# quote_for_sed [STRING]
|
||||
# ----------------------
|
||||
# Return STRING (or stdin) quoted to be used as a sed pattern.
|
||||
quote_for_sed ()
|
||||
{
|
||||
case $# in
|
||||
0) cat;;
|
||||
1) printf '%s\n' "$1";;
|
||||
esac \
|
||||
| sed -e 's|[][\\.*]|\\&|g'
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'')
|
||||
echo "$0: No files given. Try '$0 --help' for more information." 1>&2
|
||||
exit 1
|
||||
;;
|
||||
-h|--h*)
|
||||
cat <<\EOF
|
||||
Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
|
||||
|
||||
Wrapper for lex/yacc invocations, renaming files as desired.
|
||||
|
||||
INPUT is the input file
|
||||
OUTPUT is one file PROG generates
|
||||
DESIRED is the file we actually want instead of OUTPUT
|
||||
PROGRAM is program to run
|
||||
ARGS are passed to PROG
|
||||
|
||||
Any number of OUTPUT,DESIRED pairs may be used.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
GNU Automake home page: <https://www.gnu.org/software/automake/>.
|
||||
General help using GNU software: <https://www.gnu.org/gethelp/>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v|--v*)
|
||||
echo "ylwrap (GNU Automake) $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# The input.
|
||||
input=$1
|
||||
shift
|
||||
# We'll later need for a correct munging of "#line" directives.
|
||||
input_sub_rx=`get_dirname "$input" | quote_for_sed`
|
||||
case $input in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
# Absolute path; do nothing.
|
||||
;;
|
||||
*)
|
||||
# Relative path. Make it absolute.
|
||||
input=`pwd`/$input
|
||||
;;
|
||||
esac
|
||||
input_rx=`get_dirname "$input" | quote_for_sed`
|
||||
|
||||
# Since DOS filename conventions don't allow two dots,
|
||||
# the DOS version of Bison writes out y_tab.c instead of y.tab.c
|
||||
# and y_tab.h instead of y.tab.h. Test to see if this is the case.
|
||||
y_tab_nodot=false
|
||||
if test -f y_tab.c || test -f y_tab.h; then
|
||||
y_tab_nodot=true
|
||||
fi
|
||||
|
||||
# The parser itself, the first file, is the destination of the .y.c
|
||||
# rule in the Makefile.
|
||||
parser=$1
|
||||
|
||||
# A sed program to s/FROM/TO/g for all the FROM/TO so that, for
|
||||
# instance, we rename #include "y.tab.h" into #include "parse.h"
|
||||
# during the conversion from y.tab.c to parse.c.
|
||||
sed_fix_filenames=
|
||||
|
||||
# Also rename header guards, as Bison 2.7 for instance uses its header
|
||||
# guard in its implementation file.
|
||||
sed_fix_header_guards=
|
||||
|
||||
while test $# -ne 0; do
|
||||
if test x"$1" = x"--"; then
|
||||
shift
|
||||
break
|
||||
fi
|
||||
from=$1
|
||||
# Handle y_tab.c and y_tab.h output by DOS
|
||||
if $y_tab_nodot; then
|
||||
case $from in
|
||||
"y.tab.c") from=y_tab.c;;
|
||||
"y.tab.h") from=y_tab.h;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
to=$1
|
||||
shift
|
||||
sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;"
|
||||
sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;"
|
||||
done
|
||||
|
||||
# The program to run.
|
||||
prog=$1
|
||||
shift
|
||||
# Make any relative path in $prog absolute.
|
||||
case $prog in
|
||||
[\\/]* | ?:[\\/]*) ;;
|
||||
*[\\/]*) prog=`pwd`/$prog ;;
|
||||
esac
|
||||
|
||||
dirname=ylwrap$$
|
||||
do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
mkdir $dirname || exit 1
|
||||
|
||||
cd $dirname
|
||||
|
||||
case $# in
|
||||
0) "$prog" "$input" ;;
|
||||
*) "$prog" "$@" "$input" ;;
|
||||
esac
|
||||
ret=$?
|
||||
|
||||
if test $ret -eq 0; then
|
||||
for from in *
|
||||
do
|
||||
to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"`
|
||||
if test -f "$from"; then
|
||||
# If $2 is an absolute path name, then just use that,
|
||||
# otherwise prepend '../'.
|
||||
case $to in
|
||||
[\\/]* | ?:[\\/]*) target=$to;;
|
||||
*) target=../$to;;
|
||||
esac
|
||||
|
||||
# Do not overwrite unchanged header files to avoid useless
|
||||
# recompilations. Always update the parser itself: it is the
|
||||
# destination of the .y.c rule in the Makefile. Divert the
|
||||
# output of all other files to a temporary file so we can
|
||||
# compare them to existing versions.
|
||||
if test $from != $parser; then
|
||||
realtarget=$target
|
||||
target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'`
|
||||
fi
|
||||
|
||||
# Munge "#line" or "#" directives. Don't let the resulting
|
||||
# debug information point at an absolute srcdir. Use the real
|
||||
# output file name, not yy.lex.c for instance. Adjust the
|
||||
# include guards too.
|
||||
sed -e "/^#/!b" \
|
||||
-e "s|$input_rx|$input_sub_rx|" \
|
||||
-e "$sed_fix_filenames" \
|
||||
-e "$sed_fix_header_guards" \
|
||||
"$from" >"$target" || ret=$?
|
||||
|
||||
# Check whether files must be updated.
|
||||
if test "$from" != "$parser"; then
|
||||
if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
|
||||
echo "$to is unchanged"
|
||||
rm -f "$target"
|
||||
else
|
||||
echo "updating $to"
|
||||
mv -f "$target" "$realtarget"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# A missing file is only an error for the parser. This is a
|
||||
# blatant hack to let us support using "yacc -d". If -d is not
|
||||
# specified, don't fail when the header file is "missing".
|
||||
if test "$from" = "$parser"; then
|
||||
ret=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Remove the directory.
|
||||
cd ..
|
||||
rm -rf $dirname
|
||||
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
3300
config.h.in
Normal file
3300
config.h.in
Normal file
File diff suppressed because it is too large
Load diff
562
configure.ac
Normal file
562
configure.ac
Normal file
|
@ -0,0 +1,562 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
m4_pattern_forbid([^MAN_])
|
||||
|
||||
# Initialise and check we're in the correct directory.
|
||||
AC_INIT([man-db], [2.13.1], [cjwatson@debian.org])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AM_INIT_AUTOMAKE([1.14 -Wall -Wno-override -Werror foreign dist-xz no-dist-gzip parallel-tests])
|
||||
AM_SILENT_RULES([yes])
|
||||
AC_PREREQ([2.64])
|
||||
AC_CONFIG_SRCDIR([src/man.c])
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
MAN_TAR_SORT_NAME
|
||||
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
# Define below date and version information to be put into man pages etc.
|
||||
date=2025-05-02
|
||||
AC_SUBST([date])dnl
|
||||
roff_version=`echo AC_PACKAGE_VERSION | sed 's/-/\\-/g'`
|
||||
AC_SUBST([roff_version])dnl
|
||||
|
||||
# Explicitly check for pkg-config early on, since otherwise the conditional
|
||||
# calls in MAN_ARG_SYSTEMDTMPFILESDIR and MAN_ARG_SYSTEMDSYSTEMUNITDIR are
|
||||
# problematic.
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
# We have to be a bit naughty here and supply options.
|
||||
# The autoconf literature states that only features that can be separately
|
||||
# 'built' should use --enable and friends. Oh well...
|
||||
MAN_ARG_CACHE_OWNER
|
||||
MAN_ARG_SETUID
|
||||
MAN_ARG_UNDOC
|
||||
MAN_ARG_DEVICE
|
||||
MAN_ARG_DB
|
||||
MAN_ARG_CONFIG_FILE
|
||||
MAN_ARG_SECTIONS
|
||||
MAN_ARG_AUTOMATIC_CREATE
|
||||
MAN_ARG_AUTOMATIC_UPDATE
|
||||
MAN_ARG_CATS
|
||||
MAN_ARG_OVERRIDE_DIR
|
||||
MAN_ARG_SYSTEMDTMPFILESDIR
|
||||
MAN_ARG_SYSTEMDSYSTEMUNITDIR
|
||||
MAN_ARG_MANDIRS
|
||||
MAN_ARG_MANUAL
|
||||
MAN_ARG_SNAPDIR
|
||||
|
||||
# Check $PATH for the following programs and append suitable options.
|
||||
AC_PROG_CC
|
||||
gl_EARLY
|
||||
AC_PROG_CPP
|
||||
CFLAGS="$CFLAGS -Wall"
|
||||
case $host_os in
|
||||
ultrix4.3*)
|
||||
dnl When compiled for BSD environment, each running `man'
|
||||
dnl increases the system load as reported by uptime(1) by
|
||||
dnl one. The reason for this behaviour is currently
|
||||
dnl unknown, but the load increase does *not* reflect actual
|
||||
dnl resource usage. To avoid it, compile for POSIX
|
||||
dnl environment:
|
||||
CFLAGS="$CFLAGS -YPOSIX"
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_ARG_ENABLE([gcc-warnings],
|
||||
[AS_HELP_STRING([--enable-gcc-warnings=TYPE],
|
||||
[control generation of GCC warnings. The TYPE 'no' disables
|
||||
warnings; 'yes' generates cheap warnings if available (default);
|
||||
'expensive' in addition generates expensive-to-compute warnings
|
||||
if available])],
|
||||
[case $enableval in
|
||||
no|yes|expensive) ;;
|
||||
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
|
||||
esac
|
||||
man_gcc_warnings=$enableval],
|
||||
[man_gcc_warnings=yes]
|
||||
)
|
||||
if test "$man_gcc_warnings" != no; then
|
||||
# Enable all reasonable GCC warnings.
|
||||
gl_MANYWARN_ALL_GCC([warnings])
|
||||
nw=
|
||||
nw="$nw -Wsystem-headers"
|
||||
nw="$nw -Wmissing-field-initializers"
|
||||
nw="$nw -Winline"
|
||||
if test "$man_gcc_warnings" != expensive; then
|
||||
nw="$nw -fanalyzer"
|
||||
fi
|
||||
gl_MANYWARN_COMPLEMENT([warnings], [$warnings], [$nw])
|
||||
for w in $warnings; do
|
||||
gl_WARN_ADD([$w])
|
||||
done
|
||||
gl_WARN_ADD([-Wno-missing-field-initializers])
|
||||
# Disable use of VLAs by Gnulib to avoid tripping over -Wvla.
|
||||
AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs.])
|
||||
fi
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AM_PROG_AR
|
||||
LT_INIT([disable-static])
|
||||
|
||||
libman_export_ldflags=
|
||||
if test "$with_gnu_ld" = yes; then
|
||||
case $host_os in
|
||||
cygwin*|mingw*|pw32*|cegcc*)
|
||||
libman_export_ldflags='-Wl,--export-all-symbols'
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
AC_SUBST([LIBMAN_EXPORT_LDFLAGS], [$libman_export_ldflags])
|
||||
|
||||
AC_CHECK_PROGS([cat], [cat])
|
||||
AC_DEFINE_UNQUOTED([PROG_CAT], ["$cat"], [Program to use as cat.])
|
||||
MAN_CHECK_PROGS([browser], [BROWSER], [use BROWSER as default web browser], [www-browser lynx elinks w3m])
|
||||
test -n "$browser" && browser="exec $browser"
|
||||
AC_DEFINE_UNQUOTED([PROG_BROWSER], ["$browser"], [Program to use as browser.])
|
||||
AC_CHECK_PROGS([tr], [tr])
|
||||
AC_DEFINE_UNQUOTED([PROG_TR], ["$tr"], [Program to use as tr.])
|
||||
AC_CHECK_PROGS([grep], [grep])
|
||||
AC_DEFINE_UNQUOTED([PROG_GREP], ["$grep"], [Program to use as grep.])
|
||||
MAN_CHECK_PROGS([pager], [PAGER], [use PAGER as default pager], [pager less more])
|
||||
AC_DEFINE_UNQUOTED([PROG_PAGER], ["$pager"], [Program to use as pager.])
|
||||
|
||||
# Define below (in list of preference) *roff macros to check for.
|
||||
macros="andoc an doc"
|
||||
|
||||
# We have problems here, as different systems have different *roff
|
||||
# formatters and they accept different options and do different things :(
|
||||
MAN_CHECK_PROGS([nroff], [NROFF], [use NROFF as roff formatter for character devices], [nroff gnroff groff])
|
||||
if test -n "$nroff"
|
||||
then
|
||||
MAN_PROG_GNU_NROFF([$nroff])
|
||||
if test "$man_cv_prog_gnu_nroff" != "yes"
|
||||
then
|
||||
MAN_PROG_HEIRLOOM_NROFF([$nroff])
|
||||
fi
|
||||
if test -n "$nroff_device"
|
||||
then
|
||||
AC_MSG_CHECKING([that nroff works with argument$nroff_device])
|
||||
# We cannot cache this result as it can change between runs
|
||||
# of configure.
|
||||
if $nroff $nroff_device </dev/null >/dev/null 2>&1 3>&1
|
||||
then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([nroff does not work with argument$nroff_device])
|
||||
fi
|
||||
fi
|
||||
AC_MSG_CHECKING([for appropriate nroff macro])
|
||||
AC_CACHE_VAL([man_cv_prog_nroff_macro], [
|
||||
|
||||
for macro in $macros
|
||||
do
|
||||
if $nroff -m$macro $nroff_device </dev/null >/dev/null 2>&1 3>&1
|
||||
then
|
||||
man_cv_prog_nroff_macro=-m$macro
|
||||
break
|
||||
fi
|
||||
done])
|
||||
|
||||
if test -n "$man_cv_prog_nroff_macro"
|
||||
then
|
||||
if test "$man_cv_prog_heirloom_nroff" = "yes"
|
||||
then
|
||||
# Heirloom works best with some extra options:
|
||||
# -mg: groff compatibility
|
||||
# -msafe: disable privileged operations
|
||||
# -mpadj: clean up line breaking
|
||||
man_cv_prog_nroff_macro="-mg -msafe -mpadj ${man_cv_prog_nroff_macro}"
|
||||
fi
|
||||
nroff="$nroff ${man_cv_prog_nroff_macro}"
|
||||
dnl nroff="$nroff ${man_cv_prog_nroff_macro}${nroff_device}"
|
||||
AC_MSG_RESULT([$man_cv_prog_nroff_macro])
|
||||
else
|
||||
AC_MSG_RESULT([ambiguous])
|
||||
AC_MSG_WARN([please edit config.h and add nroff definition])
|
||||
fi
|
||||
else
|
||||
AC_MSG_WARN([Cannot find an nroff-like program, formatting of manual page source will not be supported.])
|
||||
nroff="(nroff not installed)"
|
||||
AC_DEFINE([NROFF_MISSING], [1], [Define if you don't have nroff.])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([PROG_NROFF], ["$nroff"], [Program to use as nroff.])
|
||||
|
||||
dnl It would be nice to use MAN_CHECK_PROGS here, but how do we determine
|
||||
dnl TROFF_IS_GROFF?
|
||||
AC_CHECK_PROGS([troff], [groff])
|
||||
if test -n "$troff"
|
||||
then
|
||||
troff_is_groff=yes
|
||||
AC_DEFINE([TROFF_IS_GROFF], [1], [Define if you are using groff as troff.])
|
||||
TROFF=groff
|
||||
else
|
||||
troff_is_groff=no
|
||||
AC_CHECK_PROGS([troff], [troff gtroff])
|
||||
TROFF=troff
|
||||
fi
|
||||
AC_SUBST([troff_is_groff])
|
||||
AC_SUBST([TROFF])
|
||||
if test -n "$troff"
|
||||
then
|
||||
AC_DEFINE([HAS_TROFF], [1], [Define if you have troff.])
|
||||
AC_MSG_CHECKING([for appropriate $TROFF options])
|
||||
AC_CACHE_VAL([man_cv_prog_troff_options], [
|
||||
# Do a quick test to see if -t works [AIX needs this], groff doesn't
|
||||
# as it indicates pre-process with tbl.
|
||||
test "$TROFF" = "troff" && $troff -t </dev/null >/dev/null 2>&1 3>&1 \
|
||||
&& troff_filter="-t "
|
||||
for macro in $macros
|
||||
do
|
||||
if $troff $troff_filter -m$macro </dev/null >/dev/null 2>&1 3>&1
|
||||
then
|
||||
man_cv_prog_troff_options="${troff_filter}-m${macro}"
|
||||
break
|
||||
fi
|
||||
done])
|
||||
if test -n "$man_cv_prog_troff_options"
|
||||
then
|
||||
if test "$man_cv_prog_heirloom_nroff" = "yes"
|
||||
then
|
||||
# Heirloom works best with some extra options:
|
||||
# -mg: groff compatibility
|
||||
# -msafe: disable privileged operations
|
||||
# -mpadj: clean up line breaking
|
||||
man_cv_prog_troff_options="-mg -msafe -mpadj ${man_cv_prog_troff_options}"
|
||||
fi
|
||||
troff="$troff $man_cv_prog_troff_options"
|
||||
AC_MSG_RESULT([$man_cv_prog_troff_options])
|
||||
else
|
||||
AC_MSG_RESULT([ambiguous])
|
||||
AC_MSG_WARN([please edit config.h and add troff definition])
|
||||
fi
|
||||
else
|
||||
troff="(troff not installed)"
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([PROG_TROFF], ["$troff"], [Program to use as troff.])
|
||||
dnl We want to end up with "-" written as "\-" in manual pages. This
|
||||
dnl requires additional \-escaping corresponding to the following quote
|
||||
dnl removal steps:
|
||||
dnl 1) the following sed command
|
||||
dnl 2) the following assignment
|
||||
dnl 2) sed running on the substituted version of man/replace.sin.in
|
||||
troff_as_troff_input=`echo "$troff" | sed 's/-/\\\\\\\\-/g'`
|
||||
AC_SUBST([troff_as_troff_input])
|
||||
|
||||
if test -n "$nroff"
|
||||
then
|
||||
AC_CACHE_CHECK([whether nroff supports warning control],
|
||||
[man_cv_prog_nroff_warnings], [
|
||||
if test "x$troff_is_groff" = xyes && \
|
||||
nroff -wmac </dev/null >/dev/null 2>&1
|
||||
then
|
||||
man_cv_prog_nroff_warnings=yes
|
||||
else
|
||||
man_cv_prog_nroff_warnings=no
|
||||
fi])
|
||||
if test "x$man_cv_prog_nroff_warnings" = xyes; then
|
||||
AC_DEFINE([NROFF_WARNINGS], [1],
|
||||
[Define if nroff supports warning control.])
|
||||
fi
|
||||
fi
|
||||
|
||||
MAN_CHECK_PROGS([eqn], [EQN], [use EQN to preprocess equations], [eqn geqn])
|
||||
AC_DEFINE_UNQUOTED([PROG_EQN], ["$eqn"], [Program to use as eqn.])
|
||||
MAN_CHECK_PROGS([neqn], [NEQN], [use NEQN to preprocess equations for character devices], [neqn gneqn])
|
||||
# If we fail to find an neqn, use eqn and try to force it to output for an
|
||||
# ascii device. As this is only relevant for equations (?), not using latin1
|
||||
# should be acceptable. -Tlatin1 is ignored by some eqn implementations.
|
||||
if test -z "$neqn"
|
||||
then
|
||||
test -n "$eqn" &&
|
||||
(test -n "$nroff_device" && neqn="$eqn -T$nroff_device" || neqn="$eqn -Tascii")
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([PROG_NEQN], ["$neqn"], [Program to use as neqn.])
|
||||
MAN_CHECK_PROGS([tbl], [TBL], [use TBL to preprocess tables], [tbl gtbl])
|
||||
AC_DEFINE_UNQUOTED([PROG_TBL], ["$tbl"], [Program to use as tbl.])
|
||||
TBL_X_FORMAT=
|
||||
if test -n "$tbl"
|
||||
then
|
||||
AC_CACHE_CHECK([whether tbl supports the 'x' format character],
|
||||
[man_cv_tbl_x_format], [
|
||||
if (echo .TS; echo ';'; echo lx.; echo SENTINEL; echo .TE) | \
|
||||
$tbl 2>/dev/null | grep SENTINEL >/dev/null 2>&1
|
||||
then
|
||||
man_cv_tbl_x_format=yes
|
||||
else
|
||||
man_cv_tbl_x_format=no
|
||||
fi])
|
||||
if test "x$man_cv_tbl_x_format" = xyes
|
||||
then
|
||||
TBL_X_FORMAT=x
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([TBL_X_FORMAT])
|
||||
MAN_CHECK_PROGS([col], [COL], [use COL to filter formatting characters from output], [col gcol])
|
||||
AC_DEFINE_UNQUOTED([PROG_COL], ["$col"], [Program to use as col.])
|
||||
MAN_CHECK_PROGS([vgrind], [VGRIND], [use VGRIND to preprocess program sources], [vgrind gvgrind])
|
||||
AC_DEFINE_UNQUOTED([PROG_VGRIND], ["$vgrind"], [Program to use as vgrind.])
|
||||
MAN_CHECK_PROGS([refer], [REFER], [use REFER to preprocess bibliographic references], [refer grefer])
|
||||
AC_DEFINE_UNQUOTED([PROG_REFER], ["$refer"], [Program to use as refer.])
|
||||
MAN_CHECK_PROGS([grap], [GRAP], [use GRAP to preprocess graphs], [grap])
|
||||
AC_DEFINE_UNQUOTED([PROG_GRAP], ["$grap"], [Program to use as grap.])
|
||||
MAN_CHECK_PROGS([pic], [PIC], [use PIC to preprocess pictures], [pic gpic])
|
||||
test -n "$pic" && pic="$pic -S"
|
||||
AC_DEFINE_UNQUOTED([PROG_PIC], ["$pic"], [Program to use as pic.])
|
||||
|
||||
MAN_CHECK_PROGS([gzip], [GZIP], [use GZIP as GNU compression utility], [gzip])
|
||||
if test -n "$gzip"
|
||||
then
|
||||
gunzip="$gzip -dc"
|
||||
compressor="$gzip -c7"
|
||||
compress_ext="gz"
|
||||
fi
|
||||
MAN_CHECK_PROGS([compress], [COMPRESS], [use COMPRESS as UNIX compression utility], [compress])
|
||||
if test -n "$compress"
|
||||
then
|
||||
uncompress="$compress -dc"
|
||||
if test -z "$gzip"
|
||||
then
|
||||
compressor="$compress -c"
|
||||
compress_ext="Z"
|
||||
fi
|
||||
fi
|
||||
MAN_CHECK_PROGS([bzip2], [BZIP2], [use BZIP2 as block-sorting compression utility], [bzip2])
|
||||
if test -n "$bzip2"
|
||||
then
|
||||
bunzip2="$bzip2 -dc"
|
||||
fi
|
||||
MAN_CHECK_PROGS([xz], [XZ], [use XZ as Lempel-Ziv-Markov chain-Algorithm compression utility], [xz])
|
||||
if test -n "$xz"
|
||||
then
|
||||
unxz="$xz -dc"
|
||||
unlzma=
|
||||
else
|
||||
dnl lzma not used/needed if we have xz
|
||||
MAN_CHECK_PROGS([lzma], [LZMA], [use LZMA as Lempel-Ziv-Markov chain-Algorithm compression utility], [lzma])
|
||||
if test -n "$lzma"
|
||||
then
|
||||
unlzma="$lzma -dc"
|
||||
fi
|
||||
fi
|
||||
MAN_CHECK_PROGS([lzip], [LZIP], [use LZIP as Lempel-Ziv-Markov chain-Algorithm compression utility], [lzip])
|
||||
if test -n "$lzip"
|
||||
then
|
||||
unlzip="$lzip -dc"
|
||||
fi
|
||||
MAN_CHECK_PROGS([zstd], [ZSTD], [use ZSTD as LZ77/entropy-coding compression utility], [zstd])
|
||||
if test -n "$zstd"
|
||||
then
|
||||
unzstd="$zstd -dc"
|
||||
fi
|
||||
if test -n "$compressor"
|
||||
then
|
||||
AC_DEFINE([COMP_CAT], [1], [Define if you have compressors and want to support compressed cat files.])
|
||||
fi
|
||||
dnl Compressors are used for compressing cat pages.
|
||||
AC_SUBST([compressor])
|
||||
AC_DEFINE_UNQUOTED(
|
||||
[PROG_COMPRESSOR], ["$compressor"],
|
||||
[Default compressor, used for compressing cat pages.])
|
||||
AC_DEFINE_UNQUOTED(
|
||||
[COMPRESS_EXT], ["$compress_ext"],
|
||||
[Default compression extension, used for compressing cat pages.])
|
||||
dnl Decompressors are used for decompressing cat pages and nroff source.
|
||||
dnl To add further decompressors, you will also need to edit
|
||||
dnl lib/compression.c.
|
||||
AC_DEFINE_UNQUOTED([PROG_GUNZIP], ["$gunzip"], [Program to use as gunzip.])
|
||||
AC_DEFINE_UNQUOTED(
|
||||
[PROG_UNCOMPRESS], ["$uncompress"], [Program to use as uncompress.])
|
||||
AC_DEFINE_UNQUOTED([PROG_BUNZIP2], ["$bunzip2"], [Program to use as bunzip2.])
|
||||
AC_DEFINE_UNQUOTED([PROG_UNLZMA], ["$unlzma"], [Program to use as unlzma.])
|
||||
AC_DEFINE_UNQUOTED([PROG_UNXZ], ["$unxz"], [Program to use as unxz.])
|
||||
AC_DEFINE_UNQUOTED([PROG_UNLZIP], ["$unlzip"], [Program to use as unlzip.])
|
||||
AC_DEFINE_UNQUOTED([PROG_UNZSTD], ["$unzstd"], [Program to use as unzstd.])
|
||||
MAN_COMPRESS_LIB([z], [gzopen])
|
||||
dnl To add more decompressors just follow the scheme above.
|
||||
|
||||
# Check for various header files and associated libraries.
|
||||
dnl The "noyywrap" argument is new in Autoconf 2.70, but this also works
|
||||
dnl fine with older versions that ignore the argument.
|
||||
AC_PROG_LEX([noyywrap])
|
||||
if test "$LEX" = ":" && (test ! -e $srcdir/src/lexgrog.c || test ! -e $srcdir/src/zsoelim.c)
|
||||
then
|
||||
AC_MSG_ERROR([flex is required when building from revision control])
|
||||
fi
|
||||
gl_INIT
|
||||
AC_CHECK_HEADERS([sys/file.h linux/fiemap.h])
|
||||
AC_CHECK_FUNCS([posix_fadvise])
|
||||
|
||||
# Internationalization support.
|
||||
AM_GNU_GETTEXT([external])
|
||||
AM_GNU_GETTEXT_VERSION([0.18.3])
|
||||
AC_SUBST([LINGUAS])
|
||||
AM_ICONV
|
||||
AC_SUBST([HAVE_ICONV], [$am_func_iconv])
|
||||
MAN_PO4A
|
||||
MAN_LINGUAS
|
||||
|
||||
# Checks for structures and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_C_INLINE
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_UID_T
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
dnl _nl_msg_cat_cntr is required for GNU gettext
|
||||
AC_MSG_CHECKING([for _nl_msg_cat_cntr])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM(
|
||||
[[#include <libintl.h>
|
||||
extern int _nl_msg_cat_cntr;]],
|
||||
[[++_nl_msg_cat_cntr;]])],
|
||||
AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_NL_MSG_CAT_CNTR], [], [_nl_msg_cat_cntr from GNU Gettext]),
|
||||
AC_MSG_RESULT([no]))
|
||||
|
||||
# Check for pipeline library.
|
||||
PKG_CHECK_MODULES([libpipeline], [libpipeline >= 1.5.0])
|
||||
|
||||
# Find a suitable database interface header and library.
|
||||
#
|
||||
# Check for GNU dbm routines.
|
||||
if test "$db" = "no" || test "$db" = "gdbm"
|
||||
then
|
||||
AC_CHECK_HEADER([gdbm.h], [
|
||||
for lib in gdbm c dbm
|
||||
do
|
||||
AC_CHECK_LIB([$lib], [gdbm_fetch],
|
||||
test "$lib" = "c" || DBLIBS="-l$lib"
|
||||
[AC_DEFINE([GDBM], [1], [Define if you have, and want to use, gdbm interface routines.])
|
||||
AC_SUBST([DBTYPE], [gdbm])]
|
||||
db=yes, db=no)
|
||||
if test "$db" = "yes"
|
||||
then
|
||||
man_save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $DBLIBS"
|
||||
AC_CHECK_FUNCS([gdbm_exists])
|
||||
LIBS="$man_save_LIBS"
|
||||
break
|
||||
fi
|
||||
done], db=no)
|
||||
fi
|
||||
|
||||
# Check for Berkeley db routines (first version API).
|
||||
MAN_CHECK_BDB([db5 db], [db5/db_185.h db_185.h], [db5 db-5])
|
||||
MAN_CHECK_BDB([db4 db], [db4/db_185.h db_185.h], [db4 db-4])
|
||||
MAN_CHECK_BDB([db3 db], [db3/db_185.h db_185.h], [db3])
|
||||
MAN_CHECK_BDB([db2 db], [db_185.h db2/db_185.h db2_185.h], [db2 db])
|
||||
MAN_CHECK_BDB([db1 db], [db/db.h db.h db1/db.h], [db db1 c])
|
||||
|
||||
dnl MAN_CHECK_BDB([db2], [db2_185.h], [db2 db c], [AC_DEFINE(DB_ON_LIBC)])
|
||||
dnl MAN_CHECK_BDB([db2], [db2/db_185.h], [db2 db c])
|
||||
|
||||
# Check for UNIX ndbm routines.
|
||||
if test "$db" = "no" || test "$db" = "ndbm"
|
||||
then
|
||||
AC_CHECK_HEADER([ndbm.h], [
|
||||
for lib in ndbm c dbm
|
||||
do
|
||||
AC_CHECK_LIB([$lib], [dbm_fetch],
|
||||
test "$lib" = "c" || DBLIBS="-l$lib"
|
||||
[AC_DEFINE([NDBM], [1], [Define if you have, and want to use, ndbm interface routines.])
|
||||
AC_SUBST([DBTYPE], [ndbm])]
|
||||
db=yes, db=no)
|
||||
test "$db" = "yes" && break
|
||||
done], db=no)
|
||||
if test "$db" = no
|
||||
then
|
||||
AC_CHECK_HEADER([gdbm-ndbm.h], [
|
||||
for lib in gdbm_compat c dbm
|
||||
do
|
||||
AC_CHECK_LIB([$lib], [dbm_fetch],
|
||||
test "$lib" = "c" || DBLIBS="-l$lib"
|
||||
[AC_DEFINE([NDBM], [1], [Define if you have, and want to use, ndbm interface routines.])
|
||||
AC_SUBST([DBTYPE], [ndbm])]
|
||||
db=yes, db=no)
|
||||
test "$db" = "yes" && break
|
||||
done], db=no)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$db" != "yes"
|
||||
then
|
||||
if test "$db" = "no"
|
||||
then
|
||||
AC_MSG_ERROR([Fatal: no supported database library/header found])
|
||||
else
|
||||
AC_MSG_ERROR([Fatal: $db: unsupported database library])
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([DBLIBS])
|
||||
|
||||
# Check for libseccomp library.
|
||||
MAN_LIBSECCOMP
|
||||
|
||||
dnl MAN_ECHO_VAR(ENV-VARIABLE)
|
||||
define([MAN_ECHO_VAR], [AC_MSG_NOTICE([default $1 = "$$1"])])dnl
|
||||
dnl
|
||||
MAN_ECHO_VAR([CC])
|
||||
MAN_ECHO_VAR([CPP])
|
||||
MAN_ECHO_VAR([CPPFLAGS])
|
||||
MAN_ECHO_VAR([CFLAGS])
|
||||
MAN_ECHO_VAR([LDFLAGS])
|
||||
MAN_ECHO_VAR([LIBS])
|
||||
MAN_ECHO_VAR([DBLIBS])
|
||||
|
||||
# Transformed versions of program names for use in Automake variables.
|
||||
MAN_TRANS_SUBST([apropos])
|
||||
MAN_TRANS_SUBST([catman])
|
||||
MAN_TRANS_SUBST([lexgrog])
|
||||
MAN_TRANS_SUBST([man])
|
||||
MAN_TRANS_SUBST([man-recode])
|
||||
MAN_TRANS_SUBST([manconv])
|
||||
MAN_TRANS_SUBST([mandb])
|
||||
MAN_TRANS_SUBST([manpath])
|
||||
MAN_TRANS_SUBST([whatis])
|
||||
MAN_TRANS_SUBST([zsoelim])
|
||||
|
||||
# If we're cross-compiling, tests won't work.
|
||||
AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" = xyes])
|
||||
|
||||
# Are Gnulib translations available?
|
||||
AM_CONDITIONAL([HAVE_GNULIB_PO], [test -f "$srcdir/gl/po/POTFILES.in"])
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
gl/lib/Makefile
|
||||
init/Makefile
|
||||
init/systemd/Makefile
|
||||
lib/Makefile
|
||||
src/Makefile
|
||||
src/man_db.conf
|
||||
src/tests/Makefile
|
||||
man/Makefile
|
||||
man/replace.sin
|
||||
man/po4a/Makefile
|
||||
man/da/Makefile
|
||||
man/de/Makefile
|
||||
man/es/Makefile
|
||||
man/fr/Makefile
|
||||
man/id/Makefile
|
||||
man/it/Makefile
|
||||
man/ja/Makefile
|
||||
man/ko/Makefile
|
||||
man/nl/Makefile
|
||||
man/pl/Makefile
|
||||
man/pt/Makefile
|
||||
man/pt_BR/Makefile
|
||||
man/ro/Makefile
|
||||
man/ru/Makefile
|
||||
man/sr/Makefile
|
||||
man/sv/Makefile
|
||||
man/tr/Makefile
|
||||
man/uk/Makefile
|
||||
man/zh_CN/Makefile
|
||||
manual/Makefile
|
||||
libdb/Makefile
|
||||
docs/Makefile
|
||||
tools/Makefile
|
||||
po/Makefile.in])
|
||||
if test -f "$srcdir/gl/po/Makefile.in.in"; then
|
||||
AC_CONFIG_FILES([gl/po/Makefile.in])
|
||||
fi
|
||||
AC_OUTPUT
|
339
docs/COPYING.GPLv2
Normal file
339
docs/COPYING.GPLv2
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
502
docs/COPYING.LIB
Normal file
502
docs/COPYING.LIB
Normal file
|
@ -0,0 +1,502 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library 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.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
169
docs/HACKING.md
Normal file
169
docs/HACKING.md
Normal file
|
@ -0,0 +1,169 @@
|
|||
Hacking on man-db
|
||||
=================
|
||||
|
||||
man-db is not a large or particularly complicated project, but there is
|
||||
still plenty for an interested developer to contribute. Here's a very brief
|
||||
guide on how to get started.
|
||||
|
||||
|
||||
Directory layout
|
||||
----------------
|
||||
|
||||
The source tree looks something like this, ignoring some directories added
|
||||
by autoconf, automake, gettext, and gnulib:
|
||||
|
||||
<dl>
|
||||
<dt><code>docs/</code></dt>
|
||||
<dd>Assorted documentation.</dd>
|
||||
|
||||
<dt><code>man/</code></dt>
|
||||
<dd>Man pages for man-db's programs.</dd>
|
||||
|
||||
<dt><code>manual/</code></dt>
|
||||
<dd>The man-db manual, written in <code>troff</code>.</dd>
|
||||
|
||||
<dt><code>include/</code></dt>
|
||||
<dd>Header files used throughout the package.</dd>
|
||||
|
||||
<dt><code>lib/</code></dt>
|
||||
<dd>
|
||||
Basic library files, some of which supplement inadequate C libraries on
|
||||
various systems and some of which implement utility functions used
|
||||
throughout the package.
|
||||
</dd>
|
||||
|
||||
<dt><code>libdb/</code></dt>
|
||||
<dd>
|
||||
The database access library. Code outside this directory should not know
|
||||
about specific back-end database implementations.
|
||||
</dd>
|
||||
|
||||
<dt><code>src/</code></dt>
|
||||
<dd>Source code to the man-db programs themselves.</dd>
|
||||
|
||||
<dt><code>tools/</code></dt>
|
||||
<dd>Miscellaneous add-on scripts.</dd>
|
||||
|
||||
<dt><code>po/</code></dt>
|
||||
<dd>Translations.</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
Coding style
|
||||
------------
|
||||
|
||||
`clang-format` enforces a consistent style, configured in `.clang-format`.
|
||||
You can ensure that this and other checks are applied to your git commits
|
||||
locally by installing the [`pre-commit`](https://pre-commit.com/) package
|
||||
and running `pre-commit install`. Whether you do this or not, if you push
|
||||
your changes to a fork on GitLab, then GitLab CI will run them for you.
|
||||
|
||||
|
||||
Facilities and portability
|
||||
--------------------------
|
||||
|
||||
man-db uses Gnulib to provide portability support and utility functions
|
||||
common to many GNU packages (although man-db is not itself a GNU package),
|
||||
while the `lib/` directory provides some other utility functions specific to
|
||||
man-db. Please make use of these facilities where available. In particular,
|
||||
there are various functions beginning with 'x' which check the return values
|
||||
from the system's memory allocation calls, which you should use instead of
|
||||
their non-'x' siblings.
|
||||
|
||||
`appendstr()` provides manageable string concatenation. Use it where
|
||||
appropriate. Remember to terminate its argument list with `nullptr`. In many
|
||||
cases, `xasprintf()` from Gnulib may be more readable.
|
||||
|
||||
If you're calling any of the `is*()` or `to*()` functions in `<ctype.h>`,
|
||||
please do so via the `CTYPE()` macro in `include/manconfig.h` to ensure that
|
||||
the argument type is correct.
|
||||
|
||||
You may assume C99.
|
||||
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
There is a small test suite in `src/tests/`, as well as basic tests in
|
||||
`man/` to ensure that man-db's own manual pages format without errors. Tests
|
||||
for new bug fixes are not *required*, but are generally a good idea.
|
||||
|
||||
Various test library facilities are available in `src/tests/testlib.sh`.
|
||||
Feel free to extend this as necessary.
|
||||
|
||||
|
||||
Things to do
|
||||
------------
|
||||
|
||||
`docs/TODO` has a number of outstanding projects. Things near the bottom are
|
||||
usually more detailed and accurate.
|
||||
|
||||
The Debian bug tracking system has a number of [outstanding reports on
|
||||
man-db](https://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=man-db;ordering=upstream).
|
||||
|
||||
Much of the work needed on man-db is for maintainability. Patches that take
|
||||
difficult-to-understand code with hairy memory allocation and replace it
|
||||
with clean, obvious, and reliable code are most welcome, especially if they
|
||||
introduce new abstractions which are of more general use. The replacement of
|
||||
`splitline()` with the `page_description` interface is a good example of
|
||||
this.
|
||||
|
||||
Work on porting to platforms other than GNU/Linux is welcome. It's been a
|
||||
while since serious effort in that direction has been invested in man-db.
|
||||
Most of the code should be quite portable, but the occasional teething
|
||||
problem would not be a surprise.
|
||||
|
||||
|
||||
Sending patches
|
||||
---------------
|
||||
|
||||
GitLab merge requests are preferred. Create an account on gitlab.com,
|
||||
[fork](https://gitlab.com/man-db/man-db/-/forks/new) the repository to your
|
||||
own account, push your branch, and create a merge request.
|
||||
|
||||
If you can't or don't want to use GitLab merge requests, then you can fall
|
||||
back to sending patches in unified diff format (use `git diff`, or GNU diff
|
||||
with the -u option) to man-db-devel@nongnu.org (see [subscription
|
||||
instructions](https://lists.nongnu.org/mailman/listinfo/man-db-devel)).
|
||||
|
||||
|
||||
Revision control
|
||||
----------------
|
||||
|
||||
man-db is revision-controlled using [git](https://git-scm.com/). The archive
|
||||
may be fetched from here using `git clone`, and merge requests are accepted
|
||||
in the usual way:
|
||||
|
||||
https://gitlab.com/man-db/man-db
|
||||
|
||||
Generated files should be added to `.gitignore` and should not be committed
|
||||
to revision control.
|
||||
|
||||
|
||||
Release process
|
||||
---------------
|
||||
|
||||
1. Update the `AC_INIT` version number in `configure.ac` to "x.y.z-pre1".
|
||||
Commit and tag.
|
||||
|
||||
2. Pushing the tag should cause the GitLab CI machinery to upload a
|
||||
preliminary tarball for translators to the [package
|
||||
registry](https://gitlab.com/man-db/man-db/-/packages). Send this to the
|
||||
Translation Project robot, to provide context for `po/man-db.pot`.
|
||||
|
||||
3. Wait a couple of weeks for a reasonable number of translation updates to
|
||||
arrive. During this time, test until your eyeballs fall out, but try to
|
||||
avoid changing any translated messages.
|
||||
|
||||
4. Once you're ready to release, update `NEWS.md`, and
|
||||
the `AC_INIT` version number and `date` in `configure.ac`. Commit and
|
||||
tag.
|
||||
|
||||
5. Pushing the tag should cause the GitLab CI machinery to upload the
|
||||
release tarball to the [package
|
||||
registry](https://gitlab.com/man-db/man-db/-/packages). GPG-sign that
|
||||
tarball, and upload the tarball and its signature to Savannah so that the
|
||||
URLs in the newly-created [GitLab release
|
||||
notes](https://gitlab.com/man-db/man-db/-/releases) are valid.
|
||||
|
||||
6. Announce to wherever seems appropriate.
|
365
docs/INSTALL.autoconf
Normal file
365
docs/INSTALL.autoconf
Normal file
|
@ -0,0 +1,365 @@
|
|||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
The following shell commands:
|
||||
|
||||
test -f configure || ./bootstrap
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
should configure, build, and install this package. The first line,
|
||||
which bootstraps, is intended for developers; when building from
|
||||
distribution tarballs it does nothing and can be skipped.
|
||||
|
||||
The following more-detailed instructions are generic; see the
|
||||
‘README’ file for instructions specific to this package. Some packages
|
||||
provide this ‘INSTALL’ file but do not implement all of the features
|
||||
documented below. The lack of an optional feature in a given package is
|
||||
not necessarily a bug. More recommendations for GNU packages can be
|
||||
found in the GNU Coding Standards.
|
||||
|
||||
Many packages have scripts meant for developers instead of ordinary
|
||||
builders, as they may use developer tools that are less commonly
|
||||
installed, or they may access the network, which has privacy
|
||||
implications. If the ‘bootstrap’ shell script exists, it attempts to
|
||||
build the ‘configure’ shell script and related files, possibly using
|
||||
developer tools or the network. Because the output of ‘bootstrap’ is
|
||||
system-independent, it is normally run by a package developer so that
|
||||
its output can be put into the distribution tarball and ordinary
|
||||
builders and users need not run ‘bootstrap’. Some packages have
|
||||
commands like ‘./autopull.sh’ and ‘./autogen.sh’ that you can run
|
||||
instead of ‘./bootstrap’, for more fine-grained control over
|
||||
bootstrapping.
|
||||
|
||||
The ‘configure’ shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a ‘Makefile’ in each directory of the package.
|
||||
It may also create one or more ‘.h’ files containing system-dependent
|
||||
definitions. Finally, it creates a shell script ‘config.status’ that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file ‘config.log’ containing output useful for debugging ‘configure’.
|
||||
|
||||
It can also use an optional file (typically called ‘config.cache’ and
|
||||
enabled with ‘--cache-file=config.cache’ or simply ‘-C’) that saves the
|
||||
results of its tests to speed up reconfiguring. Caching is disabled by
|
||||
default to prevent problems with accidental use of stale cache files.
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how ‘configure’ could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the ‘README’ so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point ‘config.cache’ contains results you don’t want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The ‘autoconf’ program generates ‘configure’ from the file
|
||||
‘configure.ac’. Normally you should edit ‘configure.ac’ instead of
|
||||
editing ‘configure’ directly.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. ‘cd’ to the directory containing the package’s source code.
|
||||
|
||||
2. If this is a developer checkout and file ‘configure’ does not yet
|
||||
exist, type ‘./bootstrap’ to create it. You may need special
|
||||
developer tools and network access to bootstrap, and the network
|
||||
access may have privacy implications.
|
||||
|
||||
3. Type ‘./configure’ to configure the package for your system. This
|
||||
might take a while. While running, ‘configure’ prints messages
|
||||
telling which features it is checking for.
|
||||
|
||||
4. Type ‘make’ to compile the package.
|
||||
|
||||
5. Optionally, type ‘make check’ to run any self-tests that come with
|
||||
the package, generally using the just-built uninstalled binaries.
|
||||
|
||||
6. Type ‘make install’ to install the programs and any data files and
|
||||
documentation. When installing into a prefix owned by root, it is
|
||||
recommended that the package be configured and built as a regular
|
||||
user, and only the ‘make install’ phase executed with root
|
||||
privileges.
|
||||
|
||||
7. Optionally, type ‘make installcheck’ to repeat any self-tests, but
|
||||
this time using the binaries in their final installed location.
|
||||
This target does not install anything. Running this target as a
|
||||
regular user, particularly if the prior ‘make install’ required
|
||||
root privileges, verifies that the installation completed
|
||||
correctly.
|
||||
|
||||
8. You can remove the program binaries and object files from the
|
||||
source code directory by typing ‘make clean’. To also remove the
|
||||
files that ‘configure’ created (so you can compile the package for
|
||||
a different kind of computer), type ‘make distclean’. There is
|
||||
also a ‘make maintainer-clean’ target, but that is intended mainly
|
||||
for the package’s developers. If you use it, you may have to
|
||||
bootstrap again.
|
||||
|
||||
9. If the package follows the GNU Coding Standards, you can type ‘make
|
||||
uninstall’ to remove the installed files.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the ‘configure’ script does not know about. Run ‘./configure --help’
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give ‘configure’ initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here is
|
||||
an example:
|
||||
|
||||
./configure CC=gcc CFLAGS=-g LIBS=-lposix
|
||||
|
||||
See “Defining Variables” for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each system in their own
|
||||
directory. To do this, you can use GNU ‘make’. ‘cd’ to the directory
|
||||
where you want the object files and executables to go and run the
|
||||
‘configure’ script. ‘configure’ automatically checks for the source
|
||||
code in the directory that ‘configure’ is in and in ‘..’. This is known
|
||||
as a “VPATH” build.
|
||||
|
||||
With a non-GNU ‘make’, it is safer to compile the package for one
|
||||
system at a time in the source code directory. After you have installed
|
||||
the package for one system, use ‘make distclean’ before reconfiguring
|
||||
for another system.
|
||||
|
||||
Some platforms, notably macOS, support “fat” or “universal” binaries,
|
||||
where a single binary can execute on different architectures. On these
|
||||
platforms you can configure and compile just once, with options specific
|
||||
to that platform.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, ‘make install’ installs the package’s commands under
|
||||
‘/usr/local/bin’, include files under ‘/usr/local/include’, etc. You
|
||||
can specify an installation prefix other than ‘/usr/local’ by giving
|
||||
‘configure’ the option ‘--prefix=PREFIX’, where PREFIX must be an
|
||||
absolute file name.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option ‘--exec-prefix=PREFIX’ to ‘configure’, the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like ‘--bindir=DIR’ to specify different values for particular
|
||||
kinds of files. Run ‘configure --help’ for a list of the directories
|
||||
you can set and what kinds of files go in them. In general, the default
|
||||
for these options is expressed in terms of ‘${prefix}’, so that
|
||||
specifying just ‘--prefix’ will affect all of the other directory
|
||||
specifications that were not explicitly provided.
|
||||
|
||||
The most portable way to affect installation locations is to pass the
|
||||
correct locations to ‘configure’; however, many packages provide one or
|
||||
both of the following shortcuts of passing variable assignments to the
|
||||
‘make install’ command line to change installation locations without
|
||||
having to reconfigure or recompile.
|
||||
|
||||
The first method involves providing an override variable for each
|
||||
affected directory. For example, ‘make install
|
||||
prefix=/alternate/directory’ will choose an alternate location for all
|
||||
directory configuration variables that were expressed in terms of
|
||||
‘${prefix}’. Any directories that were specified during ‘configure’,
|
||||
but not in terms of ‘${prefix}’, must each be overridden at install time
|
||||
for the entire installation to be relocated. The approach of makefile
|
||||
variable overrides for each directory variable is required by the GNU
|
||||
Coding Standards, and ideally causes no recompilation. However, some
|
||||
platforms have known limitations with the semantics of shared libraries
|
||||
that end up requiring recompilation when using this method, particularly
|
||||
noticeable in packages that use GNU Libtool.
|
||||
|
||||
The second method involves providing the ‘DESTDIR’ variable. For
|
||||
example, ‘make install DESTDIR=/alternate/directory’ will prepend
|
||||
‘/alternate/directory’ before all installation names. The approach of
|
||||
‘DESTDIR’ overrides is not required by the GNU Coding Standards, and
|
||||
does not work on platforms that have drive letters. On the other hand,
|
||||
it does better at avoiding recompilation issues, and works well even
|
||||
when some directory options were not specified in terms of ‘${prefix}’
|
||||
at ‘configure’ time.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving ‘configure’ the
|
||||
option ‘--program-prefix=PREFIX’ or ‘--program-suffix=SUFFIX’.
|
||||
|
||||
Some packages pay attention to ‘--enable-FEATURE’ and
|
||||
‘--disable-FEATURE’ options to ‘configure’, where FEATURE indicates an
|
||||
optional part of the package. They may also pay attention to
|
||||
‘--with-PACKAGE’ and ‘--without-PACKAGE’ options, where PACKAGE is
|
||||
something like ‘gnu-ld’. ‘./configure --help’ should mention the
|
||||
‘--enable-...’ and ‘--with-...’ options that the package recognizes.
|
||||
|
||||
Some packages offer the ability to configure how verbose the
|
||||
execution of ‘make’ will be. For these packages, running ‘./configure
|
||||
--enable-silent-rules’ sets the default to minimal output, which can be
|
||||
overridden with ‘make V=1’; while running ‘./configure
|
||||
--disable-silent-rules’ sets the default to verbose, which can be
|
||||
overridden with ‘make V=0’.
|
||||
|
||||
Specifying a System Type
|
||||
========================
|
||||
|
||||
By default ‘configure’ builds for the current system. To create
|
||||
binaries that can run on a different system type, specify a
|
||||
‘--host=TYPE’ option along with compiler variables that specify how to
|
||||
generate object code for TYPE. For example, to create binaries intended
|
||||
to run on a 64-bit ARM processor:
|
||||
|
||||
./configure --host=aarch64-linux-gnu \
|
||||
CC=aarch64-linux-gnu-gcc \
|
||||
CXX=aarch64-linux-gnu-g++
|
||||
|
||||
If done on a machine that can execute these binaries (e.g., via
|
||||
‘qemu-aarch64’, ‘$QEMU_LD_PREFIX’, and Linux’s ‘binfmt_misc’
|
||||
capability), the build behaves like a native build. Otherwise it is a
|
||||
cross-build: ‘configure’ will make cross-compilation guesses instead of
|
||||
running test programs, and ‘make check’ will not work.
|
||||
|
||||
A system type can either be a short name like ‘mingw64’, or a
|
||||
canonical name like ‘x86_64-pc-linux-gnu’. Canonical names have the
|
||||
form CPU-COMPANY-SYSTEM where SYSTEM is either OS or KERNEL-OS. To
|
||||
canonicalize and validate a system type, you can run the command
|
||||
‘config.sub’, which is often squirreled away in a subdirectory like
|
||||
‘build-aux’. For example:
|
||||
|
||||
$ build-aux/config.sub arm64-linux
|
||||
aarch64-unknown-linux-gnu
|
||||
$ build-aux/config.sub riscv-lnx
|
||||
Invalid configuration 'riscv-lnx': OS 'lnx' not recognized
|
||||
|
||||
You can look at the ‘config.sub’ file to see which types are recognized.
|
||||
If the file is absent, this package does not need the system type.
|
||||
|
||||
If ‘configure’ fails with the diagnostic “cannot guess build type”.
|
||||
‘config.sub’ did not recognize your system’s type. In this case, first
|
||||
fetch the newest versions of these files from the GNU config package
|
||||
(https://savannah.gnu.org/projects/config). If that fixes things,
|
||||
please report it to the maintainers of the package containing
|
||||
‘configure’. Otherwise, you can try the configure option ‘--build=TYPE’
|
||||
where TYPE comes close to your system type; also, please report the
|
||||
problem to <config-patches@gnu.org>.
|
||||
|
||||
For more details about configuring system types, see the Autoconf
|
||||
documentation.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for ‘configure’ scripts to share,
|
||||
you can create a site shell script called ‘config.site’ that gives
|
||||
default values for variables like ‘CC’, ‘cache_file’, and ‘prefix’.
|
||||
‘configure’ looks for ‘PREFIX/share/config.site’ if it exists, then
|
||||
‘PREFIX/etc/config.site’ if it exists. Or, you can set the
|
||||
‘CONFIG_SITE’ environment variable to the location of the site script.
|
||||
A warning: not all ‘configure’ scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to ‘configure’. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the ‘configure’ command line, using ‘VAR=value’. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified ‘gcc’ to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
Unfortunately, this technique does not work for ‘CONFIG_SHELL’ due to an
|
||||
Autoconf limitation. Until the limitation is lifted, you can use this
|
||||
workaround:
|
||||
|
||||
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
‘configure’ Invocation
|
||||
======================
|
||||
|
||||
‘configure’ recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
‘--help’
|
||||
‘-h’
|
||||
Print a summary of all of the options to ‘configure’, and exit.
|
||||
|
||||
‘--help=short’
|
||||
‘--help=recursive’
|
||||
Print a summary of the options unique to this package’s
|
||||
‘configure’, and exit. The ‘short’ variant lists options used only
|
||||
in the top level, while the ‘recursive’ variant lists options also
|
||||
present in any nested packages.
|
||||
|
||||
‘--version’
|
||||
‘-V’
|
||||
Print the version of Autoconf used to generate the ‘configure’
|
||||
script, and exit.
|
||||
|
||||
‘--cache-file=FILE’
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally ‘config.cache’. FILE defaults to ‘/dev/null’ to
|
||||
disable caching.
|
||||
|
||||
‘--config-cache’
|
||||
‘-C’
|
||||
Alias for ‘--cache-file=config.cache’.
|
||||
|
||||
‘--srcdir=DIR’
|
||||
Look for the package’s source code in directory DIR. Usually
|
||||
‘configure’ can determine that directory automatically.
|
||||
|
||||
‘--prefix=DIR’
|
||||
Use DIR as the installation prefix. See “Installation Names” for
|
||||
more details, including other options available for fine-tuning the
|
||||
installation locations.
|
||||
|
||||
‘--host=TYPE’
|
||||
Build binaries for system TYPE. See “Specifying a System Type”.
|
||||
|
||||
‘--enable-FEATURE’
|
||||
‘--disable-FEATURE’
|
||||
Enable or disable the optional FEATURE. See “Optional Features”.
|
||||
|
||||
‘--with-PACKAGE’
|
||||
‘--without-PACKAGE’
|
||||
Use or omit PACKAGE when building. See “Optional Features”.
|
||||
|
||||
‘--quiet’
|
||||
‘--silent’
|
||||
‘-q’
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to ‘/dev/null’ (any error
|
||||
messages will still be shown).
|
||||
|
||||
‘--no-create’
|
||||
‘-n’
|
||||
Run the configure checks, but stop before creating any output
|
||||
files.
|
||||
|
||||
‘configure’ also recognizes several environment variables, and accepts
|
||||
some other, less widely useful, options. Run ‘configure --help’ for
|
||||
more details.
|
||||
|
||||
Copyright notice
|
||||
================
|
||||
|
||||
Copyright © 1994–1996, 1999–2002, 2004–2017, 2020–2024 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. This file is offered as-is,
|
||||
without warranty of any kind.
|
49
docs/INSTALL.quick
Normal file
49
docs/INSTALL.quick
Normal file
|
@ -0,0 +1,49 @@
|
|||
Full installation details are included in ../README.md. If you are simply
|
||||
upgrading an old version of man-db and know that all of the defaults
|
||||
are correct (your config file will NOT be overwritten), you may follow
|
||||
the Quick install below.
|
||||
|
||||
man-db requires several external packages:
|
||||
|
||||
* libpipeline >= 1.5.0 (https://libpipeline.gitlab.io/libpipeline/)
|
||||
* flex >= 2.5.30 (https://github.com/westes/flex)
|
||||
* an nroff/troff formatter, one of:
|
||||
groff >= 1.21 (https://www.gnu.org/software/groff/)
|
||||
Heirloom Documentation Tools
|
||||
(https://n-t-roff.github.io/heirloom/doctools.html)
|
||||
* a database library, one of:
|
||||
GDBM (https://www.gnu.org.ua/software/gdbm/)
|
||||
Berkeley DB < 6
|
||||
NDBM
|
||||
|
||||
and on systems without GNU libc:
|
||||
|
||||
* libiconv >= 1.8 (https://www.gnu.org/software/libiconv/)
|
||||
|
||||
Some other packages are recommended and used if available:
|
||||
|
||||
* zlib (https://zlib.net/)
|
||||
* libseccomp (https://github.com/seccomp/libseccomp)
|
||||
|
||||
Quick INSTALL
|
||||
=============
|
||||
|
||||
* RUN `./configure <appropriate flags>'
|
||||
* EDIT configuration files/headers if necessary
|
||||
* RUN `make <appropriate variable definitions>'
|
||||
* RUN `make install <appropriate variable definitions>'
|
||||
|
||||
Note (1): If you don't know what <appropriate flags> or <appropriate
|
||||
variable definitions> mean, you should be reading/following the install
|
||||
procedure in ../README.md instead.
|
||||
|
||||
Note (2): You must not replace the `make install' step by copying the
|
||||
binaries to wherever you may want them. Various paths are hard coded
|
||||
into the binaries during `make' and unless you know exactly what you
|
||||
are doing, it is likely that run time errors will occur.
|
||||
|
||||
Note (3): If you run make with path/prefix/name_transformation variable
|
||||
definitions such as `make prefix=/tmp zsoelim=soelim', you must supply
|
||||
the same variable definitions to `make install'. In general it is
|
||||
better to run `./configure' with the appropriate options rather than
|
||||
waiting until the make stage of the build.
|
13
docs/Makefile.am
Normal file
13
docs/Makefile.am
Normal file
|
@ -0,0 +1,13 @@
|
|||
dist_noinst_DATA = \
|
||||
COPYING.GPLv2 \
|
||||
COPYING.LIB \
|
||||
HACKING.md \
|
||||
TODO \
|
||||
manpage.example \
|
||||
manpage.example.mdoc \
|
||||
manpage.example.pod \
|
||||
manpage.example.sgml
|
||||
|
||||
EXTRA_DIST = \
|
||||
INSTALL.autoconf \
|
||||
INSTALL.quick
|
2210
docs/Makefile.in
Normal file
2210
docs/Makefile.in
Normal file
File diff suppressed because it is too large
Load diff
20
docs/TODO
Normal file
20
docs/TODO
Normal file
|
@ -0,0 +1,20 @@
|
|||
In progress:
|
||||
|
||||
* store .so link in the db.
|
||||
* reduce wasted/duplicated text stored within the databases.
|
||||
10-20% database size reduction so far.
|
||||
* pipeline library:
|
||||
- make COMMAND_FUNCTION child reentrant, so it doesn't have to be a
|
||||
subprocess; will save lots of forks of zlib children in mandb
|
||||
|
||||
In need of attention:
|
||||
|
||||
* clear up the use of troff and/or groff
|
||||
* complete configuration file redesign to allow better dynamic determination
|
||||
of programs/paths/extensions etc.
|
||||
* multiple debug levels?
|
||||
|
||||
Case-insensitive lookup transition:
|
||||
|
||||
* Solaris layout is broken.
|
||||
* Need to make sure pointers trigger an exact-case lookup [done for whatis].
|
114
docs/manpage.example
Normal file
114
docs/manpage.example
Normal file
|
@ -0,0 +1,114 @@
|
|||
.\" In .TH, FOO should be all caps, SECTION should be 1-8, maybe w/ subsection
|
||||
.\" other parameters are allowed: see man(7), man(1)
|
||||
.\"
|
||||
.\" This template provided by Tom Christiansen <tchrist@jhereg.perl.com>.
|
||||
.\"
|
||||
.TH FOO SECTION
|
||||
.SH NAME
|
||||
foo, bar \- programs to do something
|
||||
.SH SYNOPSIS
|
||||
A short usage summary.
|
||||
.PP
|
||||
.B foo
|
||||
{
|
||||
.BR this | that
|
||||
}
|
||||
[
|
||||
.B -flags
|
||||
]
|
||||
[
|
||||
.B \-o
|
||||
.I option
|
||||
]
|
||||
.I argument
|
||||
[
|
||||
.I more...
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
.\" Putting a newline after each sentence can generate better output.
|
||||
Long drawn-out discussion of the program.
|
||||
It's a good idea to break this up into subsections using the .SS macro,
|
||||
like these:
|
||||
.SS "A Sample Subsection"
|
||||
.SS "Yet Another Sample Subsection"
|
||||
References to the
|
||||
.BR foo (SECTION)
|
||||
(or other) manual page should use the .BR macro as here.
|
||||
.PP
|
||||
Use the .PP macro to start a new paragraph within a section.
|
||||
.SH OPTIONS
|
||||
Some people make this separate from the description.
|
||||
The following style is typically used to document options:
|
||||
.TP
|
||||
.BR this | that
|
||||
The user MUST specify either
|
||||
.B this
|
||||
or
|
||||
.B that
|
||||
to run the program.
|
||||
The { and } braces mean one of the enclosed is required.
|
||||
The bar (|) separates exclusive options (i.e. you cannot have both at once).
|
||||
.TP
|
||||
.B \-o
|
||||
Pass the user-supplied
|
||||
.I option
|
||||
to
|
||||
.B foo
|
||||
to change its behaviour.
|
||||
The fact that
|
||||
.I option
|
||||
is underlined or in italics means that the user replaces it with a valid
|
||||
value for this option.
|
||||
The [ and ] brackets mean it isn't required.
|
||||
.IP
|
||||
Use \(oq\e-\(cq rather than \(oq-\(cq for dashes in command-line options.
|
||||
\(oq-\(cq means hyphen, and formats differently when using certain output
|
||||
devices.
|
||||
.TP
|
||||
.I argument
|
||||
The last
|
||||
.I argument
|
||||
is required, because it is not in brackets.
|
||||
.TP
|
||||
.I more
|
||||
means that the user can optionally specify additional arguments at the end.
|
||||
The ellipses (...) indicate one or more of this parameter is allowed.
|
||||
.SH "RETURN VALUE"
|
||||
What the program or function returns if successful.
|
||||
.SH ERRORS
|
||||
Return codes, either exit status or errno settings.
|
||||
.SH EXAMPLES
|
||||
Give some example uses of the program.
|
||||
.SH ENVIRONMENT
|
||||
Environment variables this program might care about.
|
||||
.SH FILES
|
||||
All files used by the program.
|
||||
Typical usage is like this:
|
||||
.br
|
||||
.nf
|
||||
.\" set tabstop to longest possible filename, plus a wee bit
|
||||
.ta \w'/usr/lib/perl/getopts.pl 'u
|
||||
\fI/usr/man\fR default man tree
|
||||
\fI/usr/man/man*/*.*\fR unformatted (nroff source) man pages
|
||||
.SH NOTES
|
||||
Miscellaneous commentary.
|
||||
.SH CAVEATS
|
||||
Things to take special care with, sometimes called WARNINGS.
|
||||
.SH DIAGNOSTICS
|
||||
All the possible error messages the program can print out,
|
||||
what they mean, and how to correct them if applicable.
|
||||
.SH BUGS
|
||||
Things that are broken or just don't work quite right.
|
||||
.SH RESTRICTIONS
|
||||
Bugs you don't plan to fix. :-)
|
||||
.SH AUTHOR
|
||||
Who wrote it (or AUTHORS if multiple).
|
||||
.SH HISTORY
|
||||
Programs derived from other sources sometimes have this.
|
||||
.SH "SEE ALSO"
|
||||
.\" Always quote multiple words for .SH
|
||||
Other man pages to check out, like
|
||||
.BR man (1),
|
||||
.BR man (7),
|
||||
.BR mandb (8),
|
||||
.BR catman (8).
|
134
docs/manpage.example.mdoc
Normal file
134
docs/manpage.example.mdoc
Normal file
|
@ -0,0 +1,134 @@
|
|||
.\" -mdoc is a groff macro package supporting logical formatting. The author
|
||||
.\" of this example considers it the best package available in groff for
|
||||
.\" writing manual pages. If you're used to the traditional Unix -man
|
||||
.\" macros, give this a try; it doesn't take long to learn. groff_mdoc(7) is
|
||||
.\" a complete reference manual.
|
||||
.\"
|
||||
.\" Many of the macros below stack, so ".Op Ar foo" means an optional
|
||||
.\" argument called "foo", while ".Ar foo" means an argument called "foo".
|
||||
.\" Where you see things like ".Ql .Fl" below, the second dot causes ".Fl"
|
||||
.\" to be interpreted as ordinary text rather than calling the .Fl macro.
|
||||
.Dd June 4, 2005
|
||||
.Os FooOS
|
||||
.Dt FOO 1
|
||||
.Sh NAME
|
||||
.Nm foo
|
||||
.Nd program to do something
|
||||
.Sh SYNOPSIS
|
||||
A short usage summary.
|
||||
.Pp
|
||||
.Nm
|
||||
.Brq Cm this | Cm that
|
||||
.Op Fl flags
|
||||
.Op Fl o Ar option
|
||||
.Ar argument
|
||||
.\" Punctuation is treated specially by -mdoc, and often gets pushed up
|
||||
.\" against whatever precedes it without the special formatting, so having
|
||||
.\" an underlined argument immediately followed by a normal comma is easy.
|
||||
.\" If you want to make sure this special handling isn't applied, put a
|
||||
.\" zero-width space, \&, before the punctuation.
|
||||
.Op Ar more \&...
|
||||
.Sh DESCRIPTION
|
||||
.\" Putting a newline after each sentence generates better output.
|
||||
Long drawn-out discussion of the program.
|
||||
It's a good idea to break this up into subsections using the
|
||||
.Ql .Ss
|
||||
macro, like these:
|
||||
.Ss A Sample Subsection
|
||||
.Ss Yet Another Sample Subsection
|
||||
.Pp
|
||||
References to the
|
||||
.Xr foo SECTION
|
||||
(or other) manual page should use the
|
||||
.Ql .Xr
|
||||
macro as here.
|
||||
References to the
|
||||
.Sx OPTIONS
|
||||
(or other) section within this manual page should use the
|
||||
.Ql .Sx
|
||||
macro as here.
|
||||
.Pp
|
||||
Use the
|
||||
.Ql .Pp
|
||||
macro to start a new paragraph within a section.
|
||||
.Sh OPTIONS
|
||||
Some people make this separate from the description.
|
||||
The following list style is typically used to document options:
|
||||
.Bl -tag -width 4n
|
||||
.It Cm this | Cm that
|
||||
The user MUST specify either
|
||||
.Cm this
|
||||
or
|
||||
.Cm that
|
||||
to run the program.
|
||||
The { and } braces (using the
|
||||
.Ql .Brq
|
||||
macro) mean one of the enclosed is required.
|
||||
The bar (|) separates exclusive options (i.e. you cannot have both at once).
|
||||
.It Fl o
|
||||
Pass the user-supplied
|
||||
.Ar option
|
||||
to
|
||||
.Nm
|
||||
to change its behaviour.
|
||||
The fact that
|
||||
.Ar option
|
||||
is underlined or in italics means that the user replaces it with a valid
|
||||
value for this option.
|
||||
The [ and ] brackets (using the
|
||||
.Ql .Op
|
||||
macro) mean it isn't required.
|
||||
.Pp
|
||||
Use the
|
||||
.Ql .Fl
|
||||
macro to render dashes in command-line option.
|
||||
.It Ar argument
|
||||
The last
|
||||
.Ar argument
|
||||
is required, because it is not in brackets.
|
||||
.It Ar more
|
||||
means that the user can optionally specify additional arguments at the end.
|
||||
The ellipses
|
||||
.Pf ( Ar ... )
|
||||
indicate one or more of this parameter is allowed.
|
||||
.\" Remember to close lists you open with .Bl.
|
||||
.El
|
||||
.Sh RETURN VALUE
|
||||
What the program or function returns if successful.
|
||||
.Sh ERRORS
|
||||
Return codes, either exit status or errno settings.
|
||||
.Sh EXAMPLES
|
||||
Give some example uses of the program.
|
||||
.Sh ENVIRONMENT
|
||||
Environment variables this program might care about.
|
||||
.Sh FILES
|
||||
All files used by the program.
|
||||
Typical usage is like this:
|
||||
.Pp
|
||||
.Bl -tag -width "/usr/man/man*/*.*" -compact
|
||||
.It Pa /usr/man
|
||||
default man tree
|
||||
.It Pa /usr/man/man*/*.*
|
||||
unformatted (nroff source) man pages
|
||||
.El
|
||||
.Sh NOTES
|
||||
Miscellaneous commentary.
|
||||
.Sh CAVEATS
|
||||
Things to take special care with, sometimes called WARNINGS.
|
||||
.Sh DIAGNOSTICS
|
||||
All the possible error messages the program can print out,
|
||||
what they mean, and how to correct them if applicable.
|
||||
.Sh BUGS
|
||||
Things that are broken or just don't work quite right.
|
||||
.Sh RESTRICTIONS
|
||||
Bugs you don't plan to fix. :-)
|
||||
.Sh AUTHOR
|
||||
Who wrote it (or AUTHORS if multiple).
|
||||
.Sh HISTORY
|
||||
Programs derived from other sources sometimes have this.
|
||||
.Sh SEE ALSO
|
||||
Other man pages to check out, like
|
||||
.Xr man 1 ,
|
||||
.Xr man 7 ,
|
||||
.Xr mandb 8 ,
|
||||
.Xr catman 8 .
|
126
docs/manpage.example.pod
Normal file
126
docs/manpage.example.pod
Normal file
|
@ -0,0 +1,126 @@
|
|||
=head1 NAME
|
||||
|
||||
foo, bar - programs to do something
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
A short usage summary.
|
||||
|
||||
B<foo> { B<this>|B<that> } [ B<-flags> ] [ B<-o> I<option> ] I<argument> [ I<more...> ]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Long drawn-out discussion of the program. It's a good idea to break this
|
||||
up into subsections using "=head2" directives, like these:
|
||||
|
||||
=head2 A Sample Subsection
|
||||
|
||||
=head2 Yet Another Sample Subsection
|
||||
|
||||
References to the foo(1) (or other) manual page should be written normally
|
||||
as here; B<pod2man> will usually guess the correct formatting. Use S<L><>
|
||||
(e.g. L<foo(SECTION)>) if you need to force this.
|
||||
|
||||
Paragraphs are separated by blank lines.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
Some people make this separate from the description.
|
||||
|
||||
The following style is typically used to document options:
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<this>|B<that>
|
||||
|
||||
The user MUST specify either B<this> or B<that> to run the program. The {
|
||||
and } braces mean one of the enclosed is required. The bar (|) separates
|
||||
exclusive options (i.e. you cannot have both at once).
|
||||
|
||||
=item B<-o>
|
||||
|
||||
Pass the user-supplied I<option> to B<foo> to change its behaviour. The
|
||||
fact that I<option> is underlined or in italics means that the user replaces
|
||||
it with a valid value for this option. The [ and ] brackets mean it isn't
|
||||
required.
|
||||
|
||||
=item I<argument>
|
||||
|
||||
The last I<argument> is required, because it is not in brackets.
|
||||
|
||||
=item I<more>
|
||||
|
||||
means that the user can optionally specify additional arguments at the end.
|
||||
The ellipses (...) indicate one or more of this parameter is allowed.
|
||||
|
||||
=back
|
||||
|
||||
=head1 RETURN VALUE
|
||||
|
||||
What the program or function returns if successful.
|
||||
|
||||
=head1 ERRORS
|
||||
|
||||
Return codes, either exit status or errno settings.
|
||||
|
||||
=head1 EXAMPLES
|
||||
|
||||
Give some example uses of the program.
|
||||
|
||||
=head1 ENVIRONMENT
|
||||
|
||||
Environment variables this program might care about.
|
||||
|
||||
=head1 FILES
|
||||
|
||||
All files used by the program. Typical usage is like this:
|
||||
|
||||
=over 8
|
||||
|
||||
=item F</usr/man>
|
||||
|
||||
default man tree
|
||||
|
||||
=item F</usr/man/man*/*.*>
|
||||
|
||||
unformatted (nroff source) man pages
|
||||
|
||||
=back
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
Miscellaneous commentary.
|
||||
|
||||
=head1 CAVEATS
|
||||
|
||||
Things to take special care with, sometimes called WARNINGS.
|
||||
|
||||
=head1 DIAGNOSTICS
|
||||
|
||||
All the possible error messages the program can print out, what they
|
||||
mean, and how to correct them if applicable.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
Things that are broken or just don't work quite right.
|
||||
|
||||
=head1 RESTRICTIONS
|
||||
|
||||
Bugs you don't plan to fix. :-)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Who wrote it (or AUTHORS if multiple).
|
||||
|
||||
This example was constructed by Colin Watson <S<cjwatson@debian.org>>
|
||||
from a template provided by Tom Christiansen <S<tchrist@jhereg.perl.com>>.
|
||||
|
||||
=head1 HISTORY
|
||||
|
||||
Programs derived from other sources sometimes have this.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
Other man pages to check out, like man(1), man(7), mandb(8), catman(8).
|
||||
|
||||
For this example, see pod2man(1) for more details.
|
232
docs/manpage.example.sgml
Normal file
232
docs/manpage.example.sgml
Normal file
|
@ -0,0 +1,232 @@
|
|||
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
|
||||
|
||||
<!-- Process this file with docbook-to-man to generate an nroff manual
|
||||
page: `docbook-to-man manpage.sgml > manpage.1'. You may view
|
||||
the manual page with: `docbook-to-man manpage.sgml | nroff -man |
|
||||
less'. A typical entry in a Makefile or Makefile.am is:
|
||||
|
||||
manpage.1: manpage.sgml
|
||||
docbook-to-man $< > $@
|
||||
-->
|
||||
|
||||
<!-- This example was constructed by Colin Watson
|
||||
<email>cjwatson@debian.org</email>, based on a man page template
|
||||
provided by Tom Christiansen <email>tchrist@jhereg.perl.com</email>
|
||||
and a DocBook man page example by Craig Small
|
||||
<email>csmall@debian.org</email>.
|
||||
-->
|
||||
|
||||
<!-- Fill in the various UPPER CASE things here. -->
|
||||
<!ENTITY manfirstname "<firstname>FIRSTNAME</firstname>">
|
||||
<!ENTITY mansurname "<surname>SURNAME</surname>">
|
||||
<!-- Please adjust the date whenever revising the manpage. -->
|
||||
<!ENTITY mandate "<date>DATE</date>">
|
||||
<!-- SECTION should be 1-8, maybe with subsection. Other parameters are
|
||||
allowed: see man(7), man(1). -->
|
||||
<!ENTITY mansection "<manvolnum>SECTION</manvolnum>">
|
||||
<!ENTITY manemail "<email>EMAIL</email>">
|
||||
<!ENTITY manusername "USERNAME">
|
||||
<!ENTITY manucpackage "<refentrytitle>UCPACKAGE</refentrytitle>">
|
||||
<!ENTITY manpackage "PACKAGE">
|
||||
]>
|
||||
|
||||
<refentry>
|
||||
<refentryinfo>
|
||||
<address>
|
||||
&manemail;
|
||||
</address>
|
||||
<author>
|
||||
&manfirstname;
|
||||
&mansurname;
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2002</year>
|
||||
<holder>&manusername;</holder>
|
||||
</copyright>
|
||||
&mandate;
|
||||
</refentryinfo>
|
||||
<refmeta>
|
||||
&manucpackage;
|
||||
|
||||
&mansection;
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>&manpackage;</refname>
|
||||
|
||||
<refpurpose>program to do something</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>&manpackage;</command>
|
||||
|
||||
<group choice="req"><arg>this</arg><arg>that</arg></group>
|
||||
<group choice="opt"><arg>-flags</arg></group>
|
||||
<group choice="opt">
|
||||
<arg>-o <replaceable>option</replaceable></arg>
|
||||
</group>
|
||||
<arg>argument</arg>
|
||||
<arg rep="repeat" choice="opt"><replaceable>more</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
<refsect1>
|
||||
<title>DESCRIPTION</title>
|
||||
|
||||
<para>Long drawn-out discussion of <command>&manpackage;</command>.
|
||||
It's a good idea to break this up into subsections, like these:</para>
|
||||
|
||||
<refsect2>
|
||||
<title>A Sample Subsection</title>
|
||||
<para></para>
|
||||
</refsect2>
|
||||
<refsect2>
|
||||
<title>Yet Another Sample Subsection</title>
|
||||
|
||||
<para>References to the
|
||||
<citerefentry>
|
||||
<refentrytitle>foo</refentrytitle><manvolnum>SECTION</manvolnum>
|
||||
</citerefentry> (or other) manual page should use the
|
||||
<markup><citerefentry></markup> element as here.
|
||||
</para>
|
||||
|
||||
<para>Each paragraph within a section is contained within a
|
||||
<markup><para></markup> tag.</para>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>OPTIONS</title>
|
||||
|
||||
<para>Some people make this separate from the description.</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>this</option>|<option>that</option></term>
|
||||
<listitem>
|
||||
<para>The user MUST specify either <option>this</option> or
|
||||
<option>that</option> to run the program. The { and } braces
|
||||
mean one of the enclosed is required. The bar (|) separates
|
||||
exclusive options (i.e. you cannot have both at once.)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-o</option></term>
|
||||
<listitem>
|
||||
<para>Pass the user-supplied <replaceable>option</replaceable> to
|
||||
<command>foo</command> to change its behaviour. The fact that
|
||||
<replaceable>option</replaceable> is underlined or in italics
|
||||
means that the user replaces it with a valid value for this
|
||||
option. The [ and ] brackets mean it isn't required.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>argument</option></term>
|
||||
<listitem>
|
||||
<para>The last <option>argument</option> is required, because it
|
||||
is not in brackets.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>more</option></term>
|
||||
<listitem>
|
||||
<para>means that the user can optionally specify additional
|
||||
arguments at the end. The ellipses (...) indicate one or more of
|
||||
this parameter is allowed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>RETURN VALUE</title>
|
||||
|
||||
<para>What the program or function returns if successful.</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>ERRORS</title>
|
||||
|
||||
<para>Return codes, either exit status or errno settings.</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>EXAMPLES</title>
|
||||
|
||||
<para>Give some example uses of the program.</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>ENVIRONMENT</title>
|
||||
|
||||
<para>Environment variables this program might care about.</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>FILES</title>
|
||||
|
||||
<para>All files used by the program. Typical usage is like this:</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><filename>/usr/man</filename></term>
|
||||
<listitem><para>default man tree</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><filename>/usr/man/man*/*.*</filename></term>
|
||||
<listitem><para>unformatted (nroff source) man pages</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>NOTES</title>
|
||||
|
||||
<para>Miscellaneous commentary.</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>CAVEATS</title>
|
||||
|
||||
<para>Things to take special care with, sometimes called WARNINGS.</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>DIAGNOSTICS</title>
|
||||
|
||||
<para>All the possible error messages the program can print out, what
|
||||
they mean, and how to correct them if applicable.</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>BUGS</title>
|
||||
|
||||
<para>Things that are broken or just don't work quite right.</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>RESTRICTIONS</title>
|
||||
|
||||
<para>Bugs you don't plan to fix. :-)</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>AUTHOR</title>
|
||||
|
||||
<para>Who wrote it (or AUTHORS if multiple).</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>HISTORY</title>
|
||||
|
||||
<para>Programs derived from other sources sometimes have this.</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>SEE ALSO</title>
|
||||
|
||||
<para>Other man pages to check out, like man(1), man(7), mandb(8),
|
||||
catman(8).</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:2
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:nil
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
4745
gl/lib/Makefile.am
Normal file
4745
gl/lib/Makefile.am
Normal file
File diff suppressed because it is too large
Load diff
8360
gl/lib/Makefile.in
Normal file
8360
gl/lib/Makefile.in
Normal file
File diff suppressed because it is too large
Load diff
50
gl/lib/_Noreturn.h
Normal file
50
gl/lib/_Noreturn.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* A C macro for declaring that a function does not return.
|
||||
Copyright (C) 2011-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _Noreturn
|
||||
# if (defined __cplusplus \
|
||||
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|
||||
|| (defined _MSC_VER && 1900 <= _MSC_VER)) \
|
||||
&& 0)
|
||||
/* [[noreturn]] is not practically usable, because with it the syntax
|
||||
extern _Noreturn void func (...);
|
||||
would not be valid; such a declaration would only be valid with 'extern'
|
||||
and '_Noreturn' swapped, or without the 'extern' keyword. However, some
|
||||
AIX system header files and several gnulib header files use precisely
|
||||
this syntax with 'extern'. */
|
||||
# define _Noreturn [[noreturn]]
|
||||
# elif (defined __clang__ && __clang_major__ < 16 \
|
||||
&& defined _GL_WORK_AROUND_LLVM_BUG_59792)
|
||||
/* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
|
||||
that rare LLVM bug, though you may get many false-alarm warnings. */
|
||||
# define _Noreturn
|
||||
# elif ((!defined __cplusplus || defined __clang__) \
|
||||
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|
||||
|| (!defined __STRICT_ANSI__ \
|
||||
&& (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
|
||||
|| (defined __apple_build_version__ \
|
||||
? 6000000 <= __apple_build_version__ \
|
||||
: 3 < __clang_major__ + (5 <= __clang_minor__))))))
|
||||
/* _Noreturn works as-is. */
|
||||
# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
|
||||
|| 0x5110 <= __SUNPRO_C)
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
|
||||
# define _Noreturn __declspec (noreturn)
|
||||
# else
|
||||
# define _Noreturn
|
||||
# endif
|
||||
#endif
|
167
gl/lib/alloca.c
Normal file
167
gl/lib/alloca.c
Normal file
|
@ -0,0 +1,167 @@
|
|||
/* alloca.c -- allocate automatically reclaimed memory
|
||||
This file is in the public domain. */
|
||||
|
||||
/* (Mostly) portable 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. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* If compiling with GCC or clang, this file is not needed. */
|
||||
#if !(defined __GNUC__ || defined __clang__)
|
||||
|
||||
/* If someone has defined alloca as a macro,
|
||||
there must be some other way alloca is supposed to work. */
|
||||
# ifndef alloca
|
||||
|
||||
/* 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 int
|
||||
find_stack_direction (int *addr, int depth)
|
||||
{
|
||||
int dir, dummy = 0;
|
||||
if (! addr)
|
||||
addr = &dummy;
|
||||
*addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
|
||||
dir = depth ? find_stack_direction (addr, depth - 1) : 0;
|
||||
return dir + dummy;
|
||||
}
|
||||
|
||||
# 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 = &probe;
|
||||
|
||||
# if STACK_DIRECTION == 0
|
||||
if (STACK_DIR == 0) /* Unknown growth direction. */
|
||||
STACK_DIR = find_stack_direction (NULL, (size & 1) + 20);
|
||||
# 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. */
|
||||
|
||||
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. */
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
# endif /* no alloca */
|
||||
#endif /* not GCC || clang */
|
72
gl/lib/alloca.in.h
Normal file
72
gl/lib/alloca.in.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/* Memory allocation on the stack.
|
||||
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2024 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
|
||||
means there is a real alloca function. */
|
||||
#ifndef _GL_ALLOCA_H
|
||||
#define _GL_ALLOCA_H
|
||||
|
||||
/* alloca (N) returns a pointer to N bytes of memory
|
||||
allocated on the stack, 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.
|
||||
*/
|
||||
|
||||
#ifndef alloca
|
||||
/* Some version of mingw have an <alloca.h> that causes trouble when
|
||||
included after 'alloca' gets defined as a macro. As a workaround,
|
||||
include this <alloca.h> first and define 'alloca' as a macro afterwards
|
||||
if needed. */
|
||||
# if defined __GNUC__ && (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
|
||||
# include_next <alloca.h>
|
||||
# endif
|
||||
#endif
|
||||
#ifndef alloca
|
||||
# if defined __GNUC__ || (__clang_major__ >= 4)
|
||||
# define alloca __builtin_alloca
|
||||
# elif defined _AIX
|
||||
# define alloca __alloca
|
||||
# elif defined _MSC_VER
|
||||
# include <malloc.h>
|
||||
# define alloca _alloca
|
||||
# elif defined __DECC && defined __VMS
|
||||
# define alloca __ALLOCA
|
||||
# elif defined __TANDEM && defined _TNS_E_TARGET
|
||||
# ifdef __cplusplus
|
||||
extern "C"
|
||||
# endif
|
||||
void *_alloca (unsigned short);
|
||||
# pragma intrinsic (_alloca)
|
||||
# define alloca _alloca
|
||||
# elif defined __MVS__
|
||||
# include <stdlib.h>
|
||||
# else
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C"
|
||||
# endif
|
||||
void *alloca (size_t);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _GL_ALLOCA_H */
|
26
gl/lib/arg-nonnull.h
Normal file
26
gl/lib/arg-nonnull.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* A C macro for declaring that specific arguments must not be NULL.
|
||||
Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
|
||||
that the values passed as arguments n, ..., m must be non-NULL pointers.
|
||||
n = 1 stands for the first argument, n = 2 for the second argument etc. */
|
||||
#ifndef _GL_ARG_NONNULL
|
||||
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
|
||||
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
|
||||
# else
|
||||
# define _GL_ARG_NONNULL(params)
|
||||
# endif
|
||||
#endif
|
34
gl/lib/argp-ba.c
Normal file
34
gl/lib/argp-ba.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
|
||||
Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* If set by the user program, it should point to string that is the
|
||||
bug-reporting address for the program. It will be printed by argp_help if
|
||||
the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
|
||||
messages), embedded in a sentence that says something like "Report bugs to
|
||||
ADDR." */
|
||||
const char *argp_program_bug_address
|
||||
/* This variable should be zero-initialized. On most systems, putting it into
|
||||
BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see
|
||||
<https://lists.gnu.org/r/bug-gnulib/2009-01/msg00329.html>
|
||||
<https://lists.gnu.org/r/bug-gnulib/2009-08/msg00096.html>. */
|
||||
#if defined __ELF__
|
||||
/* On ELF systems, variables in BSS behave well. */
|
||||
#else
|
||||
= (const char *) 0
|
||||
#endif
|
||||
;
|
30
gl/lib/argp-eexst.c
Normal file
30
gl/lib/argp-eexst.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Default definition for ARGP_ERR_EXIT_STATUS
|
||||
Copyright (C) 1997, 2009-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sysexits.h>
|
||||
|
||||
#include "argp.h"
|
||||
|
||||
/* The exit status that argp will use when exiting due to a parsing error.
|
||||
If not defined or set by the user program, this defaults to EX_USAGE from
|
||||
<sysexits.h>. */
|
||||
error_t argp_err_exit_status = EX_USAGE;
|
434
gl/lib/argp-fmtstream.c
Normal file
434
gl/lib/argp-fmtstream.c
Normal file
|
@ -0,0 +1,434 @@
|
|||
/* Word-wrapping and line-truncating streams
|
||||
Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* This package emulates glibc 'line_wrap_stream' semantics for systems that
|
||||
don't have that. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "argp-fmtstream.h"
|
||||
#include "argp-namefrob.h"
|
||||
|
||||
#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
|
||||
|
||||
#ifndef isblank
|
||||
#define isblank(ch) ((ch)==' ' || (ch)=='\t')
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <wchar.h>
|
||||
# include <libio/libioP.h>
|
||||
# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
|
||||
#endif
|
||||
|
||||
#define INIT_BUF_SIZE 200
|
||||
#define PRINTF_SIZE_GUESS 150
|
||||
|
||||
/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
|
||||
written on it with LMARGIN spaces and limits them to RMARGIN columns
|
||||
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
|
||||
replacing the whitespace before them with a newline and WMARGIN spaces.
|
||||
Otherwise, chars beyond RMARGIN are simply dropped until a newline.
|
||||
Returns NULL if there was an error. */
|
||||
argp_fmtstream_t
|
||||
__argp_make_fmtstream (FILE *stream,
|
||||
size_t lmargin, size_t rmargin, ssize_t wmargin)
|
||||
{
|
||||
argp_fmtstream_t fs;
|
||||
|
||||
fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
|
||||
if (fs != NULL)
|
||||
{
|
||||
fs->stream = stream;
|
||||
|
||||
fs->lmargin = lmargin;
|
||||
fs->rmargin = rmargin;
|
||||
fs->wmargin = wmargin;
|
||||
fs->point_col = 0;
|
||||
fs->point_offs = 0;
|
||||
|
||||
fs->buf = (char *) malloc (INIT_BUF_SIZE);
|
||||
if (! fs->buf)
|
||||
{
|
||||
free (fs);
|
||||
fs = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs->p = fs->buf;
|
||||
fs->end = fs->buf + INIT_BUF_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
return fs;
|
||||
}
|
||||
#if 0
|
||||
/* Not exported. */
|
||||
#ifdef weak_alias
|
||||
weak_alias (__argp_make_fmtstream, argp_make_fmtstream)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Flush FS to its stream, and free it (but don't close the stream). */
|
||||
void
|
||||
__argp_fmtstream_free (argp_fmtstream_t fs)
|
||||
{
|
||||
__argp_fmtstream_update (fs);
|
||||
if (fs->p > fs->buf)
|
||||
{
|
||||
#ifdef _LIBC
|
||||
__fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
|
||||
#else
|
||||
fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
|
||||
#endif
|
||||
}
|
||||
free (fs->buf);
|
||||
free (fs);
|
||||
}
|
||||
#if 0
|
||||
/* Not exported. */
|
||||
#ifdef weak_alias
|
||||
weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
|
||||
end of its buffer. This code is mostly from glibc stdio/linewrap.c. */
|
||||
void
|
||||
__argp_fmtstream_update (argp_fmtstream_t fs)
|
||||
{
|
||||
char *buf, *nl;
|
||||
size_t len;
|
||||
|
||||
/* Scan the buffer for newlines. */
|
||||
buf = fs->buf + fs->point_offs;
|
||||
while (buf < fs->p)
|
||||
{
|
||||
size_t r;
|
||||
|
||||
if (fs->point_col == 0 && fs->lmargin != 0)
|
||||
{
|
||||
/* We are starting a new line. Print spaces to the left margin. */
|
||||
const size_t pad = fs->lmargin;
|
||||
if (fs->p + pad < fs->end)
|
||||
{
|
||||
/* We can fit in them in the buffer by moving the
|
||||
buffer text up and filling in the beginning. */
|
||||
memmove (buf + pad, buf, fs->p - buf);
|
||||
fs->p += pad; /* Compensate for bigger buffer. */
|
||||
memset (buf, ' ', pad); /* Fill in the spaces. */
|
||||
buf += pad; /* Don't bother searching them. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No buffer space for spaces. Must flush. */
|
||||
size_t i;
|
||||
for (i = 0; i < pad; i++)
|
||||
{
|
||||
#ifdef _LIBC
|
||||
if (_IO_fwide (fs->stream, 0) > 0)
|
||||
putwc_unlocked (L' ', fs->stream);
|
||||
else
|
||||
#endif
|
||||
putc_unlocked (' ', fs->stream);
|
||||
}
|
||||
}
|
||||
fs->point_col = pad;
|
||||
}
|
||||
|
||||
len = fs->p - buf;
|
||||
nl = memchr (buf, '\n', len);
|
||||
|
||||
if (fs->point_col < 0)
|
||||
fs->point_col = 0;
|
||||
|
||||
if (!nl)
|
||||
{
|
||||
/* The buffer ends in a partial line. */
|
||||
|
||||
if (fs->point_col + len < fs->rmargin)
|
||||
{
|
||||
/* The remaining buffer text is a partial line and fits
|
||||
within the maximum line width. Advance point for the
|
||||
characters to be written and stop scanning. */
|
||||
fs->point_col += len;
|
||||
break;
|
||||
}
|
||||
else
|
||||
/* Set the end-of-line pointer for the code below to
|
||||
the end of the buffer. */
|
||||
nl = fs->p;
|
||||
}
|
||||
else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
|
||||
{
|
||||
/* The buffer contains a full line that fits within the maximum
|
||||
line width. Reset point and scan the next line. */
|
||||
fs->point_col = 0;
|
||||
buf = nl + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* This line is too long. */
|
||||
r = fs->rmargin - 1;
|
||||
|
||||
if (fs->wmargin < 0)
|
||||
{
|
||||
/* Truncate the line by overwriting the excess with the
|
||||
newline and anything after it in the buffer. */
|
||||
if (nl < fs->p)
|
||||
{
|
||||
memmove (buf + (r - fs->point_col), nl, fs->p - nl);
|
||||
fs->p -= buf + (r - fs->point_col) - nl;
|
||||
/* Reset point for the next line and start scanning it. */
|
||||
fs->point_col = 0;
|
||||
buf += r + 1; /* Skip full line plus \n. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The buffer ends with a partial line that is beyond the
|
||||
maximum line width. Advance point for the characters
|
||||
written, and discard those past the max from the buffer. */
|
||||
fs->point_col += len;
|
||||
fs->p -= fs->point_col - r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do word wrap. Go to the column just past the maximum line
|
||||
width and scan back for the beginning of the word there.
|
||||
Then insert a line break. */
|
||||
|
||||
char *p, *nextline;
|
||||
int i;
|
||||
|
||||
p = buf + (r + 1 - fs->point_col);
|
||||
while (p >= buf && !isblank ((unsigned char) *p))
|
||||
--p;
|
||||
nextline = p + 1; /* This will begin the next line. */
|
||||
|
||||
if (nextline > buf)
|
||||
{
|
||||
/* Swallow separating blanks. */
|
||||
if (p >= buf)
|
||||
do
|
||||
--p;
|
||||
while (p >= buf && isblank ((unsigned char) *p));
|
||||
nl = p + 1; /* The newline will replace the first blank. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A single word that is greater than the maximum line width.
|
||||
Oh well. Put it on an overlong line by itself. */
|
||||
p = buf + (r + 1 - fs->point_col);
|
||||
/* Find the end of the long word. */
|
||||
if (p < nl)
|
||||
do
|
||||
++p;
|
||||
while (p < nl && !isblank ((unsigned char) *p));
|
||||
if (p == nl)
|
||||
{
|
||||
/* It already ends a line. No fussing required. */
|
||||
fs->point_col = 0;
|
||||
buf = nl + 1;
|
||||
continue;
|
||||
}
|
||||
/* We will move the newline to replace the first blank. */
|
||||
nl = p;
|
||||
/* Swallow separating blanks. */
|
||||
do
|
||||
++p;
|
||||
while (isblank ((unsigned char) *p));
|
||||
/* The next line will start here. */
|
||||
nextline = p;
|
||||
}
|
||||
|
||||
/* Note: There are a bunch of tests below for
|
||||
NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall
|
||||
at the end of the buffer, and NEXTLINE is in fact empty (and so
|
||||
we need not be careful to maintain its contents). */
|
||||
|
||||
if ((nextline == buf + len + 1
|
||||
? fs->end - nl < fs->wmargin + 1
|
||||
: nextline - (nl + 1) < fs->wmargin)
|
||||
&& fs->p > nextline)
|
||||
{
|
||||
/* The margin needs more blanks than we removed. */
|
||||
if (fs->end - fs->p > fs->wmargin + 1)
|
||||
/* Make some space for them. */
|
||||
{
|
||||
size_t mv = fs->p - nextline;
|
||||
memmove (nl + 1 + fs->wmargin, nextline, mv);
|
||||
nextline = nl + 1 + fs->wmargin;
|
||||
len = nextline + mv - buf;
|
||||
*nl++ = '\n';
|
||||
}
|
||||
else
|
||||
/* Output the first line so we can use the space. */
|
||||
{
|
||||
#ifdef _LIBC
|
||||
__fxprintf (fs->stream, "%.*s\n",
|
||||
(int) (nl - fs->buf), fs->buf);
|
||||
#else
|
||||
if (nl > fs->buf)
|
||||
fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
|
||||
putc_unlocked ('\n', fs->stream);
|
||||
#endif
|
||||
|
||||
len += buf - fs->buf;
|
||||
nl = buf = fs->buf;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* We can fit the newline and blanks in before
|
||||
the next word. */
|
||||
*nl++ = '\n';
|
||||
|
||||
if (nextline - nl >= fs->wmargin
|
||||
|| (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin))
|
||||
/* Add blanks up to the wrap margin column. */
|
||||
for (i = 0; i < fs->wmargin; ++i)
|
||||
*nl++ = ' ';
|
||||
else
|
||||
for (i = 0; i < fs->wmargin; ++i)
|
||||
#ifdef _LIBC
|
||||
if (_IO_fwide (fs->stream, 0) > 0)
|
||||
putwc_unlocked (L' ', fs->stream);
|
||||
else
|
||||
#endif
|
||||
putc_unlocked (' ', fs->stream);
|
||||
|
||||
/* Copy the tail of the original buffer into the current buffer
|
||||
position. */
|
||||
if (nl < nextline)
|
||||
memmove (nl, nextline, buf + len - nextline);
|
||||
len -= nextline - buf;
|
||||
|
||||
/* Continue the scan on the remaining lines in the buffer. */
|
||||
buf = nl;
|
||||
|
||||
/* Restore bufp to include all the remaining text. */
|
||||
fs->p = nl + len;
|
||||
|
||||
/* Reset the counter of what has been output this line. If wmargin
|
||||
is 0, we want to avoid the lmargin getting added, so we set
|
||||
point_col to a magic value of -1 in that case. */
|
||||
fs->point_col = fs->wmargin ? fs->wmargin : -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remember that we've scanned as far as the end of the buffer. */
|
||||
fs->point_offs = fs->p - fs->buf;
|
||||
}
|
||||
|
||||
/* Ensure that FS has space for AMOUNT more bytes in its buffer, either by
|
||||
growing the buffer, or by flushing it. True is returned iff we succeed. */
|
||||
int
|
||||
__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
|
||||
{
|
||||
if ((size_t) (fs->end - fs->p) < amount)
|
||||
{
|
||||
ssize_t wrote;
|
||||
|
||||
/* Flush FS's buffer. */
|
||||
__argp_fmtstream_update (fs);
|
||||
|
||||
#ifdef _LIBC
|
||||
__fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
|
||||
wrote = fs->p - fs->buf;
|
||||
#else
|
||||
wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
|
||||
#endif
|
||||
if (wrote == fs->p - fs->buf)
|
||||
{
|
||||
fs->p = fs->buf;
|
||||
fs->point_offs = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs->p -= wrote;
|
||||
fs->point_offs -= wrote;
|
||||
memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((size_t) (fs->end - fs->buf) < amount)
|
||||
/* Gotta grow the buffer. */
|
||||
{
|
||||
size_t old_size = fs->end - fs->buf;
|
||||
size_t new_size = old_size + amount;
|
||||
char *new_buf;
|
||||
|
||||
if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
|
||||
{
|
||||
__set_errno (ENOMEM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fs->buf = new_buf;
|
||||
fs->end = new_buf + new_size;
|
||||
fs->p = fs->buf;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
|
||||
{
|
||||
int out;
|
||||
size_t avail;
|
||||
size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */
|
||||
|
||||
do
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (! __argp_fmtstream_ensure (fs, size_guess))
|
||||
return -1;
|
||||
|
||||
va_start (args, fmt);
|
||||
avail = fs->end - fs->p;
|
||||
out = __vsnprintf (fs->p, avail, fmt, args);
|
||||
va_end (args);
|
||||
if ((size_t) out >= avail)
|
||||
size_guess = out + 1;
|
||||
}
|
||||
while ((size_t) out >= avail);
|
||||
|
||||
fs->p += out;
|
||||
|
||||
return out;
|
||||
}
|
||||
#if 0
|
||||
/* Not exported. */
|
||||
#ifdef weak_alias
|
||||
weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */
|
303
gl/lib/argp-fmtstream.h
Normal file
303
gl/lib/argp-fmtstream.h
Normal file
|
@ -0,0 +1,303 @@
|
|||
/* Word-wrapping and line-truncating streams.
|
||||
Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* This package emulates glibc 'line_wrap_stream' semantics for systems that
|
||||
don't have that. If the system does have it, it is just a wrapper for
|
||||
that. This header file is only used internally while compiling argp, and
|
||||
shouldn't be installed. */
|
||||
|
||||
#ifndef _ARGP_FMTSTREAM_H
|
||||
#define _ARGP_FMTSTREAM_H
|
||||
|
||||
/* This file uses _GL_INLINE_HEADER_BEGIN, __GL_INLINE, _GL_ATTRIBUTE_DEALLOC,
|
||||
_GL_ATTRIBUTE_FORMAT. */
|
||||
#if !_LIBC && !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H)
|
||||
/* line_wrap_stream is available, so use that. */
|
||||
#define ARGP_FMTSTREAM_USE_LINEWRAP
|
||||
#endif
|
||||
|
||||
#ifdef ARGP_FMTSTREAM_USE_LINEWRAP
|
||||
/* Just be a simple wrapper for line_wrap_stream; the semantics are
|
||||
*slightly* different, as line_wrap_stream doesn't actually make a new
|
||||
object, it just modifies the given stream (reversibly) to do
|
||||
line-wrapping. Since we control who uses this code, it doesn't matter. */
|
||||
|
||||
#include <linewrap.h>
|
||||
|
||||
typedef FILE *argp_fmtstream_t;
|
||||
|
||||
#define argp_make_fmtstream line_wrap_stream
|
||||
#define __argp_make_fmtstream line_wrap_stream
|
||||
#define argp_fmtstream_free line_unwrap_stream
|
||||
#define __argp_fmtstream_free line_unwrap_stream
|
||||
|
||||
#define __argp_fmtstream_putc(fs,ch) putc(ch,fs)
|
||||
#define argp_fmtstream_putc(fs,ch) putc(ch,fs)
|
||||
#define __argp_fmtstream_puts(fs,str) fputs(str,fs)
|
||||
#define argp_fmtstream_puts(fs,str) fputs(str,fs)
|
||||
#define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
|
||||
#define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
|
||||
#define __argp_fmtstream_printf fprintf
|
||||
#define argp_fmtstream_printf fprintf
|
||||
|
||||
#define __argp_fmtstream_lmargin line_wrap_lmargin
|
||||
#define argp_fmtstream_lmargin line_wrap_lmargin
|
||||
#define __argp_fmtstream_set_lmargin line_wrap_set_lmargin
|
||||
#define argp_fmtstream_set_lmargin line_wrap_set_lmargin
|
||||
#define __argp_fmtstream_rmargin line_wrap_rmargin
|
||||
#define argp_fmtstream_rmargin line_wrap_rmargin
|
||||
#define __argp_fmtstream_set_rmargin line_wrap_set_rmargin
|
||||
#define argp_fmtstream_set_rmargin line_wrap_set_rmargin
|
||||
#define __argp_fmtstream_wmargin line_wrap_wmargin
|
||||
#define argp_fmtstream_wmargin line_wrap_wmargin
|
||||
#define __argp_fmtstream_set_wmargin line_wrap_set_wmargin
|
||||
#define argp_fmtstream_set_wmargin line_wrap_set_wmargin
|
||||
#define __argp_fmtstream_point line_wrap_point
|
||||
#define argp_fmtstream_point line_wrap_point
|
||||
|
||||
#else /* !ARGP_FMTSTREAM_USE_LINEWRAP */
|
||||
/* Guess we have to define our own version. */
|
||||
|
||||
|
||||
struct argp_fmtstream
|
||||
{
|
||||
FILE *stream; /* The stream we're outputting to. */
|
||||
|
||||
size_t lmargin, rmargin; /* Left and right margins. */
|
||||
ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */
|
||||
|
||||
/* Point in buffer to which we've processed for wrapping, but not output. */
|
||||
size_t point_offs;
|
||||
/* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */
|
||||
ssize_t point_col;
|
||||
|
||||
char *buf; /* Output buffer. */
|
||||
char *p; /* Current end of text in BUF. */
|
||||
char *end; /* Absolute end of BUF. */
|
||||
};
|
||||
|
||||
typedef struct argp_fmtstream *argp_fmtstream_t;
|
||||
|
||||
/* Flush __FS to its stream, and free it (but don't close the stream). */
|
||||
extern void __argp_fmtstream_free (argp_fmtstream_t __fs);
|
||||
extern void argp_fmtstream_free (argp_fmtstream_t __fs);
|
||||
|
||||
/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
|
||||
written on it with LMARGIN spaces and limits them to RMARGIN columns
|
||||
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
|
||||
replacing the whitespace before them with a newline and WMARGIN spaces.
|
||||
Otherwise, chars beyond RMARGIN are simply dropped until a newline.
|
||||
Returns NULL if there was an error. */
|
||||
extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream,
|
||||
size_t __lmargin,
|
||||
size_t __rmargin,
|
||||
ssize_t __wmargin)
|
||||
_GL_ATTRIBUTE_DEALLOC (__argp_fmtstream_free, 1);
|
||||
extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream,
|
||||
size_t __lmargin,
|
||||
size_t __rmargin,
|
||||
ssize_t __wmargin)
|
||||
_GL_ATTRIBUTE_DEALLOC (argp_fmtstream_free, 1);
|
||||
|
||||
extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
|
||||
const char *__fmt, ...)
|
||||
_GL_ATTRIBUTE_FORMAT ((printf, 2, 3));
|
||||
extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
|
||||
const char *__fmt, ...)
|
||||
_GL_ATTRIBUTE_FORMAT ((printf, 2, 3));
|
||||
|
||||
#if _LIBC
|
||||
extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
|
||||
extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
|
||||
|
||||
extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);
|
||||
extern int argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);
|
||||
|
||||
extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs,
|
||||
const char *__str, size_t __len);
|
||||
extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
|
||||
const char *__str, size_t __len);
|
||||
#endif
|
||||
|
||||
/* Access macros for various bits of state. */
|
||||
#define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
|
||||
#define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin)
|
||||
#define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin)
|
||||
#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
|
||||
#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
|
||||
#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
|
||||
|
||||
#if _LIBC
|
||||
/* Set __FS's left margin to LMARGIN and return the old value. */
|
||||
extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
|
||||
size_t __lmargin);
|
||||
extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
|
||||
size_t __lmargin);
|
||||
|
||||
/* Set __FS's right margin to __RMARGIN and return the old value. */
|
||||
extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
|
||||
size_t __rmargin);
|
||||
extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
|
||||
size_t __rmargin);
|
||||
|
||||
/* Set __FS's wrap margin to __WMARGIN and return the old value. */
|
||||
extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
|
||||
size_t __wmargin);
|
||||
extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
|
||||
size_t __wmargin);
|
||||
|
||||
/* Return the column number of the current output point in __FS. */
|
||||
extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
|
||||
extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);
|
||||
#endif
|
||||
|
||||
/* Internal routines. */
|
||||
extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
|
||||
extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
|
||||
extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
|
||||
extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
|
||||
|
||||
#if !_LIBC || defined __OPTIMIZE__
|
||||
/* Inline versions of above routines. */
|
||||
|
||||
#if !_LIBC
|
||||
#define __argp_fmtstream_putc argp_fmtstream_putc
|
||||
#define __argp_fmtstream_puts argp_fmtstream_puts
|
||||
#define __argp_fmtstream_write argp_fmtstream_write
|
||||
#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
|
||||
#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
|
||||
#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
|
||||
#define __argp_fmtstream_point argp_fmtstream_point
|
||||
#define __argp_fmtstream_update _argp_fmtstream_update
|
||||
#define __argp_fmtstream_ensure _argp_fmtstream_ensure
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
#ifndef ARGP_FS_EI
|
||||
# define ARGP_FS_EI _GL_INLINE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ARGP_FS_EI
|
||||
#define ARGP_FS_EI extern inline
|
||||
#endif
|
||||
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_write (argp_fmtstream_t __fs, const char *__str, size_t __len)
|
||||
{
|
||||
if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
|
||||
{
|
||||
memcpy (__fs->p, __str, __len);
|
||||
__fs->p += __len;
|
||||
return __len;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
ARGP_FS_EI int
|
||||
__argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str)
|
||||
{
|
||||
size_t __len = strlen (__str);
|
||||
if (__len)
|
||||
{
|
||||
size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
|
||||
return __wrote == __len ? 0 : -1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
ARGP_FS_EI int
|
||||
__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
|
||||
{
|
||||
if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
|
||||
return *__fs->p++ = __ch;
|
||||
else
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Set __FS's left margin to __LMARGIN and return the old value. */
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
|
||||
{
|
||||
size_t __old;
|
||||
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||
__argp_fmtstream_update (__fs);
|
||||
__old = __fs->lmargin;
|
||||
__fs->lmargin = __lmargin;
|
||||
return __old;
|
||||
}
|
||||
|
||||
/* Set __FS's right margin to __RMARGIN and return the old value. */
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
|
||||
{
|
||||
size_t __old;
|
||||
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||
__argp_fmtstream_update (__fs);
|
||||
__old = __fs->rmargin;
|
||||
__fs->rmargin = __rmargin;
|
||||
return __old;
|
||||
}
|
||||
|
||||
/* Set FS's wrap margin to __WMARGIN and return the old value. */
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
|
||||
{
|
||||
size_t __old;
|
||||
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||
__argp_fmtstream_update (__fs);
|
||||
__old = __fs->wmargin;
|
||||
__fs->wmargin = __wmargin;
|
||||
return __old;
|
||||
}
|
||||
|
||||
/* Return the column number of the current output point in __FS. */
|
||||
ARGP_FS_EI size_t
|
||||
__argp_fmtstream_point (argp_fmtstream_t __fs)
|
||||
{
|
||||
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||
__argp_fmtstream_update (__fs);
|
||||
return __fs->point_col >= 0 ? __fs->point_col : 0;
|
||||
}
|
||||
|
||||
#if !_LIBC
|
||||
#undef __argp_fmtstream_putc
|
||||
#undef __argp_fmtstream_puts
|
||||
#undef __argp_fmtstream_write
|
||||
#undef __argp_fmtstream_set_lmargin
|
||||
#undef __argp_fmtstream_set_rmargin
|
||||
#undef __argp_fmtstream_set_wmargin
|
||||
#undef __argp_fmtstream_point
|
||||
#undef __argp_fmtstream_update
|
||||
#undef __argp_fmtstream_ensure
|
||||
_GL_INLINE_HEADER_END
|
||||
#endif
|
||||
|
||||
#endif /* !_LIBC || __OPTIMIZE__ */
|
||||
|
||||
#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
|
||||
|
||||
#endif /* argp-fmtstream.h */
|
46
gl/lib/argp-fs-xinl.c
Normal file
46
gl/lib/argp-fs-xinl.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* Real definitions for extern inline functions in argp-fmtstream.h
|
||||
Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# define ARGP_FS_EI
|
||||
#else
|
||||
# define ARGP_FS_EI _GL_EXTERN_INLINE
|
||||
#endif
|
||||
#undef __OPTIMIZE__
|
||||
#define __OPTIMIZE__ 1
|
||||
#include "argp-fmtstream.h"
|
||||
|
||||
#if 0
|
||||
/* Not exported. */
|
||||
/* Add weak aliases. */
|
||||
#if _LIBC - 0 && !defined (ARGP_FMTSTREAM_USE_LINEWRAP) && defined (weak_alias)
|
||||
|
||||
weak_alias (__argp_fmtstream_putc, argp_fmtstream_putc)
|
||||
weak_alias (__argp_fmtstream_puts, argp_fmtstream_puts)
|
||||
weak_alias (__argp_fmtstream_write, argp_fmtstream_write)
|
||||
weak_alias (__argp_fmtstream_set_lmargin, argp_fmtstream_set_lmargin)
|
||||
weak_alias (__argp_fmtstream_set_rmargin, argp_fmtstream_set_rmargin)
|
||||
weak_alias (__argp_fmtstream_set_wmargin, argp_fmtstream_set_wmargin)
|
||||
weak_alias (__argp_fmtstream_point, argp_fmtstream_point)
|
||||
|
||||
#endif
|
||||
#endif
|
2038
gl/lib/argp-help.c
Normal file
2038
gl/lib/argp-help.c
Normal file
File diff suppressed because it is too large
Load diff
170
gl/lib/argp-namefrob.h
Normal file
170
gl/lib/argp-namefrob.h
Normal file
|
@ -0,0 +1,170 @@
|
|||
/* Name frobnication for compiling argp outside of glibc
|
||||
Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#if !_LIBC
|
||||
/* This code is written for inclusion in gnu-libc, and uses names in the
|
||||
namespace reserved for libc. If we're not compiling in libc, define those
|
||||
names to be the normal ones instead. */
|
||||
|
||||
/* argp-parse functions */
|
||||
#undef __argp_parse
|
||||
#define __argp_parse argp_parse
|
||||
#undef __option_is_end
|
||||
#define __option_is_end _option_is_end
|
||||
#undef __option_is_short
|
||||
#define __option_is_short _option_is_short
|
||||
#undef __argp_input
|
||||
#define __argp_input _argp_input
|
||||
|
||||
/* argp-help functions */
|
||||
#undef __argp_help
|
||||
#define __argp_help argp_help
|
||||
#undef __argp_error
|
||||
#define __argp_error argp_error
|
||||
#undef __argp_failure
|
||||
#define __argp_failure argp_failure
|
||||
#undef __argp_state_help
|
||||
#define __argp_state_help argp_state_help
|
||||
#undef __argp_usage
|
||||
#define __argp_usage argp_usage
|
||||
|
||||
/* argp-fmtstream functions */
|
||||
#undef __argp_make_fmtstream
|
||||
#define __argp_make_fmtstream argp_make_fmtstream
|
||||
#undef __argp_fmtstream_free
|
||||
#define __argp_fmtstream_free argp_fmtstream_free
|
||||
#undef __argp_fmtstream_putc
|
||||
#define __argp_fmtstream_putc argp_fmtstream_putc
|
||||
#undef __argp_fmtstream_puts
|
||||
#define __argp_fmtstream_puts argp_fmtstream_puts
|
||||
#undef __argp_fmtstream_write
|
||||
#define __argp_fmtstream_write argp_fmtstream_write
|
||||
#undef __argp_fmtstream_printf
|
||||
#define __argp_fmtstream_printf argp_fmtstream_printf
|
||||
#undef __argp_fmtstream_set_lmargin
|
||||
#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
|
||||
#undef __argp_fmtstream_set_rmargin
|
||||
#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
|
||||
#undef __argp_fmtstream_set_wmargin
|
||||
#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
|
||||
#undef __argp_fmtstream_point
|
||||
#define __argp_fmtstream_point argp_fmtstream_point
|
||||
#undef __argp_fmtstream_update
|
||||
#define __argp_fmtstream_update _argp_fmtstream_update
|
||||
#undef __argp_fmtstream_ensure
|
||||
#define __argp_fmtstream_ensure _argp_fmtstream_ensure
|
||||
#undef __argp_fmtstream_lmargin
|
||||
#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
|
||||
#undef __argp_fmtstream_rmargin
|
||||
#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
|
||||
#undef __argp_fmtstream_wmargin
|
||||
#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
|
||||
|
||||
/* normal libc functions we call */
|
||||
#undef __flockfile
|
||||
#define __flockfile flockfile
|
||||
#undef __funlockfile
|
||||
#define __funlockfile funlockfile
|
||||
#undef __mempcpy
|
||||
#define __mempcpy mempcpy
|
||||
#undef __sleep
|
||||
#define __sleep sleep
|
||||
#undef __strcasecmp
|
||||
#define __strcasecmp strcasecmp
|
||||
#undef __strchrnul
|
||||
#define __strchrnul strchrnul
|
||||
#undef __strerror_r
|
||||
#define __strerror_r strerror_r
|
||||
#undef __strndup
|
||||
#define __strndup strndup
|
||||
#undef __vsnprintf
|
||||
#define __vsnprintf vsnprintf
|
||||
|
||||
#if (defined HAVE_DECL_CLEARERR_UNLOCKED && !HAVE_DECL_CLEARERR_UNLOCKED \
|
||||
&& !defined clearerr_unlocked)
|
||||
# define clearerr_unlocked(x) clearerr (x)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_FEOF_UNLOCKED && !HAVE_DECL_FEOF_UNLOCKED \
|
||||
&& !defined feof_unlocked)
|
||||
# define feof_unlocked(x) feof (x)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_FERROR_UNLOCKED && !HAVE_DECL_FERROR_UNLOCKED \
|
||||
&& !defined ferror_unlocked)
|
||||
# define ferror_unlocked(x) ferror (x)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_FFLUSH_UNLOCKED && !HAVE_DECL_FFLUSH_UNLOCKED \
|
||||
&& !defined fflush_unlocked)
|
||||
# define fflush_unlocked(x) fflush (x)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_FGETS_UNLOCKED && !HAVE_DECL_FGETS_UNLOCKED \
|
||||
&& !defined fgets_unlocked)
|
||||
# define fgets_unlocked(x,y,z) fgets (x,y,z)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_FPUTC_UNLOCKED && !HAVE_DECL_FPUTC_UNLOCKED \
|
||||
&& !defined fputc_unlocked)
|
||||
# define fputc_unlocked(x,y) fputc (x,y)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_FPUTS_UNLOCKED && !HAVE_DECL_FPUTS_UNLOCKED \
|
||||
&& !defined fputs_unlocked)
|
||||
# define fputs_unlocked(x,y) fputs (x,y)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_FREAD_UNLOCKED && !HAVE_DECL_FREAD_UNLOCKED \
|
||||
&& !defined fread_unlocked)
|
||||
# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_FWRITE_UNLOCKED && !HAVE_DECL_FWRITE_UNLOCKED \
|
||||
&& !defined fwrite_unlocked)
|
||||
# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_GETC_UNLOCKED && !HAVE_DECL_GETC_UNLOCKED \
|
||||
&& !defined getc_unlocked)
|
||||
# define getc_unlocked(x) getc (x)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_GETCHAR_UNLOCKED && !HAVE_DECL_GETCHAR_UNLOCKED \
|
||||
&& !defined getchar_unlocked)
|
||||
# define getchar_unlocked() getchar ()
|
||||
#endif
|
||||
#if (defined HAVE_DECL_PUTC_UNLOCKED && !HAVE_DECL_PUTC_UNLOCKED \
|
||||
&& !defined putc_unlocked)
|
||||
# define putc_unlocked(x,y) putc (x,y)
|
||||
#endif
|
||||
#if (defined HAVE_DECL_PUTCHAR_UNLOCKED && !HAVE_DECL_PUTCHAR_UNLOCKED \
|
||||
&& !defined putchar_unlocked)
|
||||
# define putchar_unlocked(x) putchar (x)
|
||||
#endif
|
||||
|
||||
#endif /* !_LIBC */
|
||||
|
||||
#ifndef __set_errno
|
||||
#define __set_errno(e) (errno = (e))
|
||||
#endif
|
||||
|
||||
#if defined GNULIB_ARGP_DISABLE_DIRNAME
|
||||
# define __argp_base_name(arg) arg
|
||||
#elif defined GNULIB_ARGP_EXTERN_BASENAME
|
||||
extern char *__argp_base_name (const char *arg);
|
||||
#else
|
||||
# include "basename-lgpl.h"
|
||||
# define __argp_base_name last_component
|
||||
#endif
|
||||
|
||||
#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
||||
# define __argp_short_program_name() (program_invocation_short_name)
|
||||
#else
|
||||
extern char *__argp_short_program_name (void);
|
||||
#endif
|
967
gl/lib/argp-parse.c
Normal file
967
gl/lib/argp-parse.c
Normal file
|
@ -0,0 +1,967 @@
|
|||
/* Hierarchical argument parsing, layered over getopt
|
||||
Copyright (C) 1995-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <alloca.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <getopt.h>
|
||||
#include <getopt_int.h>
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <libintl.h>
|
||||
# undef dgettext
|
||||
# define dgettext(domain, msgid) \
|
||||
__dcgettext (domain, msgid, LC_MESSAGES)
|
||||
#else
|
||||
# include "gettext.h"
|
||||
#endif
|
||||
#define N_(msgid) msgid
|
||||
|
||||
#ifdef _LIBC
|
||||
# define ARGP_TEXT_DOMAIN "libc"
|
||||
#else
|
||||
# ifdef DEFAULT_TEXT_DOMAIN
|
||||
# define ARGP_TEXT_DOMAIN DEFAULT_TEXT_DOMAIN
|
||||
# else
|
||||
# define ARGP_TEXT_DOMAIN NULL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "argp.h"
|
||||
#include "argp-namefrob.h"
|
||||
|
||||
#define alignto(n, d) ((((n) + (d) - 1) / (d)) * (d))
|
||||
|
||||
/* Getopt return values. */
|
||||
#define KEY_END (-1) /* The end of the options. */
|
||||
#define KEY_ARG 1 /* A non-option argument. */
|
||||
#define KEY_ERR '?' /* An error parsing the options. */
|
||||
|
||||
/* The meta-argument used to prevent any further arguments being interpreted
|
||||
as options. */
|
||||
#define QUOTE "--"
|
||||
|
||||
/* The number of bits we steal in a long-option value for our own use. */
|
||||
#define GROUP_BITS CHAR_BIT
|
||||
|
||||
/* The number of bits available for the user value. */
|
||||
#define USER_BITS ((sizeof ((struct option *)0)->val * CHAR_BIT) - GROUP_BITS)
|
||||
#define USER_MASK ((1 << USER_BITS) - 1)
|
||||
|
||||
/* EZ alias for ARGP_ERR_UNKNOWN. */
|
||||
#define EBADKEY ARGP_ERR_UNKNOWN
|
||||
|
||||
/* Default options. */
|
||||
|
||||
/* When argp is given the --HANG switch, _ARGP_HANG is set and argp will sleep
|
||||
for one second intervals, decrementing _ARGP_HANG until it's zero. Thus
|
||||
you can force the program to continue by attaching a debugger and setting
|
||||
it to 0 yourself. */
|
||||
static volatile int _argp_hang;
|
||||
|
||||
#define OPT_PROGNAME -2
|
||||
#define OPT_USAGE -3
|
||||
#define OPT_HANG -4
|
||||
|
||||
static const struct argp_option argp_default_options[] =
|
||||
{
|
||||
{"help", '?', 0, 0, N_("give this help list"), -1},
|
||||
{"usage", OPT_USAGE, 0, 0, N_("give a short usage message"), 0},
|
||||
{"program-name",OPT_PROGNAME, N_("NAME"), OPTION_HIDDEN,
|
||||
N_("set the program name"), 0},
|
||||
{"HANG", OPT_HANG, N_("SECS"), OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
|
||||
N_("hang for SECS seconds (default 3600)"), 0},
|
||||
{NULL, 0, 0, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static error_t
|
||||
argp_default_parser (int key, char *arg, struct argp_state *state)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case '?':
|
||||
__argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP);
|
||||
break;
|
||||
case OPT_USAGE:
|
||||
__argp_state_help (state, state->out_stream,
|
||||
ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
|
||||
break;
|
||||
|
||||
case OPT_PROGNAME: /* Set the program name. */
|
||||
#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_NAME
|
||||
program_invocation_name = arg;
|
||||
#endif
|
||||
/* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka
|
||||
__PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined
|
||||
to be that, so we have to be a bit careful here.] */
|
||||
|
||||
/* Update what we use for messages. */
|
||||
state->name = __argp_base_name (arg);
|
||||
|
||||
#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
||||
program_invocation_short_name = state->name;
|
||||
#endif
|
||||
|
||||
if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS))
|
||||
== ARGP_PARSE_ARGV0)
|
||||
/* Update what getopt uses too. */
|
||||
state->argv[0] = arg;
|
||||
|
||||
break;
|
||||
|
||||
case OPT_HANG:
|
||||
_argp_hang = atoi (arg ? arg : "3600");
|
||||
while (_argp_hang-- > 0)
|
||||
__sleep (1);
|
||||
break;
|
||||
|
||||
default:
|
||||
return EBADKEY;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct argp argp_default_argp =
|
||||
{argp_default_options, &argp_default_parser, NULL, NULL, NULL, NULL,
|
||||
ARGP_TEXT_DOMAIN};
|
||||
|
||||
|
||||
static const struct argp_option argp_version_options[] =
|
||||
{
|
||||
{"version", 'V', 0, 0, N_("print program version"), -1},
|
||||
{NULL, 0, 0, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static error_t
|
||||
argp_version_parser (int key, char *arg, struct argp_state *state)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 'V':
|
||||
if (argp_program_version_hook)
|
||||
(*argp_program_version_hook) (state->out_stream, state);
|
||||
else if (argp_program_version)
|
||||
fprintf (state->out_stream, "%s\n", argp_program_version);
|
||||
else
|
||||
__argp_error (state, "%s",
|
||||
dgettext (ARGP_TEXT_DOMAIN,
|
||||
"(PROGRAM ERROR) No version known!?"));
|
||||
if (! (state->flags & ARGP_NO_EXIT))
|
||||
exit (0);
|
||||
break;
|
||||
default:
|
||||
return EBADKEY;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct argp argp_version_argp =
|
||||
{argp_version_options, &argp_version_parser, NULL, NULL, NULL, NULL,
|
||||
ARGP_TEXT_DOMAIN};
|
||||
|
||||
/* Returns the offset into the getopt long options array LONG_OPTIONS of a
|
||||
long option with called NAME, or -1 if none is found. Passing NULL as
|
||||
NAME will return the number of options. */
|
||||
static int
|
||||
find_long_option (struct option *long_options, const char *name)
|
||||
{
|
||||
struct option *l = long_options;
|
||||
while (l->name != NULL)
|
||||
if (name != NULL && strcmp (l->name, name) == 0)
|
||||
return l - long_options;
|
||||
else
|
||||
l++;
|
||||
if (name == NULL)
|
||||
return l - long_options;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* The state of a "group" during parsing. Each group corresponds to a
|
||||
particular argp structure from the tree of such descending from the top
|
||||
level argp passed to argp_parse. */
|
||||
struct group
|
||||
{
|
||||
/* This group's parsing function. */
|
||||
argp_parser_t parser;
|
||||
|
||||
/* Which argp this group is from. */
|
||||
const struct argp *argp;
|
||||
|
||||
/* Points to the point in SHORT_OPTS corresponding to the end of the short
|
||||
options for this group. We use it to determine from which group a
|
||||
particular short options is from. */
|
||||
char *short_end;
|
||||
|
||||
/* The number of non-option args successfully handled by this parser. */
|
||||
unsigned args_processed;
|
||||
|
||||
/* This group's parser's parent's group. */
|
||||
struct group *parent;
|
||||
unsigned parent_index; /* And the our position in the parent. */
|
||||
|
||||
/* These fields are swapped into and out of the state structure when
|
||||
calling this group's parser. */
|
||||
void *input, **child_inputs;
|
||||
void *hook;
|
||||
};
|
||||
|
||||
/* Call GROUP's parser with KEY and ARG, swapping any group-specific info
|
||||
from STATE before calling, and back into state afterwards. If GROUP has
|
||||
no parser, EBADKEY is returned. */
|
||||
static error_t
|
||||
group_parse (struct group *group, struct argp_state *state, int key, char *arg)
|
||||
{
|
||||
if (group->parser)
|
||||
{
|
||||
error_t err;
|
||||
state->hook = group->hook;
|
||||
state->input = group->input;
|
||||
state->child_inputs = group->child_inputs;
|
||||
state->arg_num = group->args_processed;
|
||||
err = (*group->parser)(key, arg, state);
|
||||
group->hook = state->hook;
|
||||
return err;
|
||||
}
|
||||
else
|
||||
return EBADKEY;
|
||||
}
|
||||
|
||||
struct parser
|
||||
{
|
||||
const struct argp *argp;
|
||||
|
||||
/* SHORT_OPTS is the getopt short options string for the union of all the
|
||||
groups of options. */
|
||||
char *short_opts;
|
||||
/* LONG_OPTS is the array of getop long option structures for the union of
|
||||
all the groups of options. */
|
||||
struct option *long_opts;
|
||||
/* OPT_DATA is the getopt data used for the reentrant getopt. */
|
||||
struct _getopt_data opt_data;
|
||||
|
||||
/* States of the various parsing groups. */
|
||||
struct group *groups;
|
||||
/* The end of the GROUPS array. */
|
||||
struct group *egroup;
|
||||
/* A vector containing storage for the CHILD_INPUTS field in all groups. */
|
||||
void **child_inputs;
|
||||
|
||||
/* True if we think using getopt is still useful; if false, then
|
||||
remaining arguments are just passed verbatim with ARGP_KEY_ARG. This is
|
||||
cleared whenever getopt returns KEY_END, but may be set again if the user
|
||||
moves the next argument pointer backwards. */
|
||||
int try_getopt;
|
||||
|
||||
/* State block supplied to parsing routines. */
|
||||
struct argp_state state;
|
||||
|
||||
/* Memory used by this parser. */
|
||||
void *storage;
|
||||
};
|
||||
|
||||
/* The next usable entries in the various parser tables being filled in by
|
||||
convert_options. */
|
||||
struct parser_convert_state
|
||||
{
|
||||
struct parser *parser;
|
||||
char *short_end;
|
||||
struct option *long_end;
|
||||
void **child_inputs_end;
|
||||
};
|
||||
|
||||
/* Converts all options in ARGP (which is put in GROUP) and ancestors
|
||||
into getopt options stored in SHORT_OPTS and LONG_OPTS; SHORT_END and
|
||||
CVT->LONG_END are the points at which new options are added. Returns the
|
||||
next unused group entry. CVT holds state used during the conversion. */
|
||||
static struct group *
|
||||
convert_options (const struct argp *argp,
|
||||
struct group *parent, unsigned parent_index,
|
||||
struct group *group, struct parser_convert_state *cvt)
|
||||
{
|
||||
/* REAL is the most recent non-alias value of OPT. */
|
||||
const struct argp_option *real = argp->options;
|
||||
const struct argp_child *children = argp->children;
|
||||
|
||||
if (real || argp->parser)
|
||||
{
|
||||
const struct argp_option *opt;
|
||||
|
||||
if (real)
|
||||
for (opt = real; !__option_is_end (opt); opt++)
|
||||
{
|
||||
if (! (opt->flags & OPTION_ALIAS))
|
||||
/* OPT isn't an alias, so we can use values from it. */
|
||||
real = opt;
|
||||
|
||||
if (! (real->flags & OPTION_DOC))
|
||||
/* A real option (not just documentation). */
|
||||
{
|
||||
if (__option_is_short (opt))
|
||||
/* OPT can be used as a short option. */
|
||||
{
|
||||
*cvt->short_end++ = opt->key;
|
||||
if (real->arg)
|
||||
{
|
||||
*cvt->short_end++ = ':';
|
||||
if (real->flags & OPTION_ARG_OPTIONAL)
|
||||
*cvt->short_end++ = ':';
|
||||
}
|
||||
*cvt->short_end = '\0'; /* keep 0 terminated */
|
||||
}
|
||||
|
||||
if (opt->name
|
||||
&& find_long_option (cvt->parser->long_opts, opt->name) < 0)
|
||||
/* OPT can be used as a long option. */
|
||||
{
|
||||
cvt->long_end->name = opt->name;
|
||||
cvt->long_end->has_arg =
|
||||
(real->arg
|
||||
? (real->flags & OPTION_ARG_OPTIONAL
|
||||
? optional_argument
|
||||
: required_argument)
|
||||
: no_argument);
|
||||
cvt->long_end->flag = 0;
|
||||
/* we add a disambiguating code to all the user's
|
||||
values (which is removed before we actually call
|
||||
the function to parse the value); this means that
|
||||
the user loses use of the high 8 bits in all his
|
||||
values (the sign of the lower bits is preserved
|
||||
however)... */
|
||||
cvt->long_end->val =
|
||||
((opt->key ? opt->key : real->key) & USER_MASK)
|
||||
+ (((group - cvt->parser->groups) + 1) << USER_BITS);
|
||||
|
||||
/* Keep the LONG_OPTS list terminated. */
|
||||
(++cvt->long_end)->name = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group->parser = argp->parser;
|
||||
group->argp = argp;
|
||||
group->short_end = cvt->short_end;
|
||||
group->args_processed = 0;
|
||||
group->parent = parent;
|
||||
group->parent_index = parent_index;
|
||||
group->input = NULL;
|
||||
group->hook = NULL;
|
||||
group->child_inputs = NULL;
|
||||
|
||||
if (children)
|
||||
/* Assign GROUP's CHILD_INPUTS field some space from
|
||||
CVT->child_inputs_end.*/
|
||||
{
|
||||
unsigned num_children = 0;
|
||||
while (children[num_children].argp)
|
||||
num_children++;
|
||||
group->child_inputs = cvt->child_inputs_end;
|
||||
cvt->child_inputs_end += num_children;
|
||||
}
|
||||
|
||||
parent = group++;
|
||||
}
|
||||
else
|
||||
parent = NULL;
|
||||
|
||||
if (children)
|
||||
{
|
||||
unsigned index = 0;
|
||||
while (children->argp)
|
||||
group =
|
||||
convert_options (children++->argp, parent, index++, group, cvt);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
/* Find the merged set of getopt options, with keys appropriately prefixed. */
|
||||
static void
|
||||
parser_convert (struct parser *parser, const struct argp *argp, int flags)
|
||||
{
|
||||
struct parser_convert_state cvt;
|
||||
|
||||
cvt.parser = parser;
|
||||
cvt.short_end = parser->short_opts;
|
||||
cvt.long_end = parser->long_opts;
|
||||
cvt.child_inputs_end = parser->child_inputs;
|
||||
|
||||
if (flags & ARGP_IN_ORDER)
|
||||
*cvt.short_end++ = '-';
|
||||
else if (flags & ARGP_NO_ARGS)
|
||||
*cvt.short_end++ = '+';
|
||||
*cvt.short_end = '\0';
|
||||
|
||||
cvt.long_end->name = NULL;
|
||||
|
||||
parser->argp = argp;
|
||||
|
||||
if (argp)
|
||||
parser->egroup = convert_options (argp, 0, 0, parser->groups, &cvt);
|
||||
else
|
||||
parser->egroup = parser->groups; /* No parsers at all! */
|
||||
}
|
||||
|
||||
/* Lengths of various parser fields which we will allocated. */
|
||||
struct parser_sizes
|
||||
{
|
||||
size_t short_len; /* Getopt short options string. */
|
||||
size_t long_len; /* Getopt long options vector. */
|
||||
size_t num_groups; /* Group structures we allocate. */
|
||||
size_t num_child_inputs; /* Child input slots. */
|
||||
};
|
||||
|
||||
/* For ARGP, increments the NUM_GROUPS field in SZS by the total number of
|
||||
argp structures descended from it, and the SHORT_LEN & LONG_LEN fields by
|
||||
the maximum lengths of the resulting merged getopt short options string and
|
||||
long-options array, respectively. */
|
||||
static void
|
||||
calc_sizes (const struct argp *argp, struct parser_sizes *szs)
|
||||
{
|
||||
const struct argp_child *child = argp->children;
|
||||
const struct argp_option *opt = argp->options;
|
||||
|
||||
if (opt || argp->parser)
|
||||
{
|
||||
szs->num_groups++;
|
||||
if (opt)
|
||||
{
|
||||
int num_opts = 0;
|
||||
while (!__option_is_end (opt++))
|
||||
num_opts++;
|
||||
szs->short_len += num_opts * 3; /* opt + up to 2 ':'s */
|
||||
szs->long_len += num_opts;
|
||||
}
|
||||
}
|
||||
|
||||
if (child)
|
||||
while (child->argp)
|
||||
{
|
||||
calc_sizes ((child++)->argp, szs);
|
||||
szs->num_child_inputs++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initializes PARSER to parse ARGP in a manner described by FLAGS. */
|
||||
static error_t
|
||||
parser_init (struct parser *parser, const struct argp *argp,
|
||||
int argc, char **argv, int flags, void *input)
|
||||
{
|
||||
error_t err = 0;
|
||||
struct group *group;
|
||||
struct parser_sizes szs;
|
||||
struct _getopt_data opt_data = _GETOPT_DATA_INITIALIZER;
|
||||
char *storage;
|
||||
size_t glen, gsum;
|
||||
size_t clen, csum;
|
||||
size_t llen, lsum;
|
||||
size_t slen, ssum;
|
||||
|
||||
szs.short_len = (flags & ARGP_NO_ARGS) ? 0 : 1;
|
||||
szs.long_len = 0;
|
||||
szs.num_groups = 0;
|
||||
szs.num_child_inputs = 0;
|
||||
|
||||
if (argp)
|
||||
calc_sizes (argp, &szs);
|
||||
|
||||
/* Lengths of the various bits of storage used by PARSER. */
|
||||
glen = (szs.num_groups + 1) * sizeof (struct group);
|
||||
clen = szs.num_child_inputs * sizeof (void *);
|
||||
llen = (szs.long_len + 1) * sizeof (struct option);
|
||||
slen = szs.short_len + 1;
|
||||
|
||||
/* Sums of previous lengths, properly aligned. There's no need to
|
||||
align gsum, since struct group is aligned at least as strictly as
|
||||
void * (since it contains a void * member). And there's no need
|
||||
to align lsum, since struct option is aligned at least as
|
||||
strictly as char. */
|
||||
gsum = glen;
|
||||
csum = alignto (gsum + clen, alignof (struct option));
|
||||
lsum = csum + llen;
|
||||
ssum = lsum + slen;
|
||||
|
||||
parser->storage = malloc (ssum);
|
||||
if (! parser->storage)
|
||||
return ENOMEM;
|
||||
|
||||
storage = parser->storage;
|
||||
parser->groups = parser->storage;
|
||||
parser->child_inputs = (void **) (storage + gsum);
|
||||
parser->long_opts = (struct option *) (storage + csum);
|
||||
parser->short_opts = storage + lsum;
|
||||
parser->opt_data = opt_data;
|
||||
|
||||
memset (parser->child_inputs, 0, clen);
|
||||
parser_convert (parser, argp, flags);
|
||||
|
||||
memset (&parser->state, 0, sizeof (struct argp_state));
|
||||
parser->state.root_argp = parser->argp;
|
||||
parser->state.argc = argc;
|
||||
parser->state.argv = argv;
|
||||
parser->state.flags = flags;
|
||||
parser->state.err_stream = stderr;
|
||||
parser->state.out_stream = stdout;
|
||||
parser->state.next = 0; /* Tell getopt to initialize. */
|
||||
parser->state.pstate = parser;
|
||||
|
||||
parser->try_getopt = 1;
|
||||
|
||||
/* Call each parser for the first time, giving it a chance to propagate
|
||||
values to child parsers. */
|
||||
if (parser->groups < parser->egroup)
|
||||
parser->groups->input = input;
|
||||
for (group = parser->groups;
|
||||
group < parser->egroup && (!err || err == EBADKEY);
|
||||
group++)
|
||||
{
|
||||
if (group->parent)
|
||||
/* If a child parser, get the initial input value from the parent. */
|
||||
group->input = group->parent->child_inputs[group->parent_index];
|
||||
|
||||
if (!group->parser
|
||||
&& group->argp->children && group->argp->children->argp)
|
||||
/* For the special case where no parsing function is supplied for an
|
||||
argp, propagate its input to its first child, if any (this just
|
||||
makes very simple wrapper argps more convenient). */
|
||||
group->child_inputs[0] = group->input;
|
||||
|
||||
err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0);
|
||||
}
|
||||
if (err == EBADKEY)
|
||||
err = 0; /* Some parser didn't understand. */
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (parser->state.flags & ARGP_NO_ERRS)
|
||||
{
|
||||
parser->opt_data.opterr = 0;
|
||||
if (parser->state.flags & ARGP_PARSE_ARGV0)
|
||||
/* getopt always skips ARGV[0], so we have to fake it out. As long
|
||||
as OPTERR is 0, then it shouldn't actually try to access it. */
|
||||
parser->state.argv--, parser->state.argc++;
|
||||
}
|
||||
else
|
||||
parser->opt_data.opterr = 1; /* Print error messages. */
|
||||
|
||||
if (parser->state.argv == argv && argv[0])
|
||||
/* There's an argv[0]; use it for messages. */
|
||||
parser->state.name = __argp_base_name (argv[0]);
|
||||
else
|
||||
parser->state.name = __argp_short_program_name ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Free any storage consumed by PARSER (but not PARSER itself). */
|
||||
static error_t
|
||||
parser_finalize (struct parser *parser,
|
||||
error_t err, int arg_ebadkey, int *end_index)
|
||||
{
|
||||
struct group *group;
|
||||
|
||||
if (err == EBADKEY && arg_ebadkey)
|
||||
/* Suppress errors generated by unparsed arguments. */
|
||||
err = 0;
|
||||
|
||||
if (! err)
|
||||
{
|
||||
if (parser->state.next == parser->state.argc)
|
||||
/* We successfully parsed all arguments! Call all the parsers again,
|
||||
just a few more times... */
|
||||
{
|
||||
for (group = parser->groups;
|
||||
group < parser->egroup && (!err || err==EBADKEY);
|
||||
group++)
|
||||
if (group->args_processed == 0)
|
||||
err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
|
||||
for (group = parser->egroup - 1;
|
||||
group >= parser->groups && (!err || err==EBADKEY);
|
||||
group--)
|
||||
err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
|
||||
|
||||
if (err == EBADKEY)
|
||||
err = 0; /* Some parser didn't understand. */
|
||||
|
||||
/* Tell the user that all arguments are parsed. */
|
||||
if (end_index)
|
||||
*end_index = parser->state.next;
|
||||
}
|
||||
else if (end_index)
|
||||
/* Return any remaining arguments to the user. */
|
||||
*end_index = parser->state.next;
|
||||
else
|
||||
/* No way to return the remaining arguments, they must be bogus. */
|
||||
{
|
||||
if (!(parser->state.flags & ARGP_NO_ERRS)
|
||||
&& parser->state.err_stream)
|
||||
fprintf (parser->state.err_stream,
|
||||
dgettext (ARGP_TEXT_DOMAIN, "%s: Too many arguments\n"),
|
||||
parser->state.name);
|
||||
err = EBADKEY;
|
||||
}
|
||||
}
|
||||
|
||||
/* Okay, we're all done, with either an error or success; call the parsers
|
||||
to indicate which one. */
|
||||
|
||||
if (err)
|
||||
{
|
||||
/* Maybe print an error message. */
|
||||
if (err == EBADKEY)
|
||||
/* An appropriate message describing what the error was should have
|
||||
been printed earlier. */
|
||||
__argp_state_help (&parser->state, parser->state.err_stream,
|
||||
ARGP_HELP_STD_ERR);
|
||||
|
||||
/* Since we didn't exit, give each parser an error indication. */
|
||||
for (group = parser->groups; group < parser->egroup; group++)
|
||||
group_parse (group, &parser->state, ARGP_KEY_ERROR, 0);
|
||||
}
|
||||
else
|
||||
/* Notify parsers of success, and propagate back values from parsers. */
|
||||
{
|
||||
/* We pass over the groups in reverse order so that child groups are
|
||||
given a chance to do there processing before passing back a value to
|
||||
the parent. */
|
||||
for (group = parser->egroup - 1
|
||||
; group >= parser->groups && (!err || err == EBADKEY)
|
||||
; group--)
|
||||
err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, 0);
|
||||
if (err == EBADKEY)
|
||||
err = 0; /* Some parser didn't understand. */
|
||||
}
|
||||
|
||||
/* Call parsers once more, to do any final cleanup. Errors are ignored. */
|
||||
for (group = parser->egroup - 1; group >= parser->groups; group--)
|
||||
group_parse (group, &parser->state, ARGP_KEY_FINI, 0);
|
||||
|
||||
if (err == EBADKEY)
|
||||
err = EINVAL;
|
||||
|
||||
free (parser->storage);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Call the user parsers to parse the non-option argument VAL, at the current
|
||||
position, returning any error. The state NEXT pointer is assumed to have
|
||||
been adjusted (by getopt) to point after this argument; this function will
|
||||
adjust it correctly to reflect however many args actually end up being
|
||||
consumed. */
|
||||
static error_t
|
||||
parser_parse_arg (struct parser *parser, char *val)
|
||||
{
|
||||
/* Save the starting value of NEXT, first adjusting it so that the arg
|
||||
we're parsing is again the front of the arg vector. */
|
||||
int index = --parser->state.next;
|
||||
error_t err = EBADKEY;
|
||||
struct group *group;
|
||||
int key = 0; /* Which of ARGP_KEY_ARG[S] we used. */
|
||||
|
||||
/* Try to parse the argument in each parser. */
|
||||
for (group = parser->groups
|
||||
; group < parser->egroup && err == EBADKEY
|
||||
; group++)
|
||||
{
|
||||
parser->state.next++; /* For ARGP_KEY_ARG, consume the arg. */
|
||||
key = ARGP_KEY_ARG;
|
||||
err = group_parse (group, &parser->state, key, val);
|
||||
|
||||
if (err == EBADKEY)
|
||||
/* This parser doesn't like ARGP_KEY_ARG; try ARGP_KEY_ARGS instead. */
|
||||
{
|
||||
parser->state.next--; /* For ARGP_KEY_ARGS, put back the arg. */
|
||||
key = ARGP_KEY_ARGS;
|
||||
err = group_parse (group, &parser->state, key, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (! err)
|
||||
{
|
||||
if (key == ARGP_KEY_ARGS)
|
||||
/* The default for ARGP_KEY_ARGS is to assume that if NEXT isn't
|
||||
changed by the user, *all* arguments should be considered
|
||||
consumed. */
|
||||
parser->state.next = parser->state.argc;
|
||||
|
||||
if (parser->state.next > index)
|
||||
/* Remember that we successfully processed a non-option
|
||||
argument -- but only if the user hasn't gotten tricky and set
|
||||
the clock back. */
|
||||
(--group)->args_processed += (parser->state.next - index);
|
||||
else
|
||||
/* The user wants to reparse some args, give getopt another try. */
|
||||
parser->try_getopt = 1;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Call the user parsers to parse the option OPT, with argument VAL, at the
|
||||
current position, returning any error. */
|
||||
static error_t
|
||||
parser_parse_opt (struct parser *parser, int opt, char *val)
|
||||
{
|
||||
/* The group key encoded in the high bits; 0 for short opts or
|
||||
group_number + 1 for long opts. */
|
||||
int group_key = opt >> USER_BITS;
|
||||
error_t err = EBADKEY;
|
||||
|
||||
if (group_key == 0)
|
||||
/* A short option. By comparing OPT's position in SHORT_OPTS to the
|
||||
various starting positions in each group's SHORT_END field, we can
|
||||
determine which group OPT came from. */
|
||||
{
|
||||
struct group *group;
|
||||
char *short_index = strchr (parser->short_opts, opt);
|
||||
|
||||
if (short_index)
|
||||
for (group = parser->groups; group < parser->egroup; group++)
|
||||
if (group->short_end > short_index)
|
||||
{
|
||||
err = group_parse (group, &parser->state, opt,
|
||||
parser->opt_data.optarg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* A long option. Preserve the sign in the user key, without
|
||||
invoking undefined behavior. Assume two's complement. */
|
||||
{
|
||||
int user_key =
|
||||
((opt & (1 << (USER_BITS - 1))) ? ~USER_MASK : 0) | (opt & USER_MASK);
|
||||
err =
|
||||
group_parse (&parser->groups[group_key - 1], &parser->state,
|
||||
user_key, parser->opt_data.optarg);
|
||||
}
|
||||
|
||||
if (err == EBADKEY)
|
||||
/* At least currently, an option not recognized is an error in the
|
||||
parser, because we pre-compute which parser is supposed to deal
|
||||
with each option. */
|
||||
{
|
||||
static const char bad_key_err[] =
|
||||
N_("(PROGRAM ERROR) Option should have been recognized!?");
|
||||
if (group_key == 0)
|
||||
__argp_error (&parser->state, "-%c: %s", opt,
|
||||
dgettext (ARGP_TEXT_DOMAIN, bad_key_err));
|
||||
else
|
||||
{
|
||||
struct option *long_opt = parser->long_opts;
|
||||
while (long_opt->val != opt && long_opt->name)
|
||||
long_opt++;
|
||||
__argp_error (&parser->state, "--%s: %s",
|
||||
long_opt->name ? long_opt->name : "???",
|
||||
dgettext (ARGP_TEXT_DOMAIN, bad_key_err));
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Parse the next argument in PARSER (as indicated by PARSER->state.next).
|
||||
Any error from the parsers is returned, and *ARGP_EBADKEY indicates
|
||||
whether a value of EBADKEY is due to an unrecognized argument (which is
|
||||
generally not fatal). */
|
||||
static error_t
|
||||
parser_parse_next (struct parser *parser, int *arg_ebadkey)
|
||||
{
|
||||
int opt;
|
||||
error_t err = 0;
|
||||
|
||||
if (parser->state.quoted && parser->state.next < parser->state.quoted)
|
||||
/* The next argument pointer has been moved to before the quoted
|
||||
region, so pretend we never saw the quoting "--", and give getopt
|
||||
another chance. If the user hasn't removed it, getopt will just
|
||||
process it again. */
|
||||
parser->state.quoted = 0;
|
||||
|
||||
if (parser->try_getopt && !parser->state.quoted)
|
||||
/* Give getopt a chance to parse this. */
|
||||
{
|
||||
/* Put it back in OPTIND for getopt. */
|
||||
parser->opt_data.optind = parser->state.next;
|
||||
/* Distinguish KEY_ERR from a real option. */
|
||||
parser->opt_data.optopt = KEY_END;
|
||||
if (parser->state.flags & ARGP_LONG_ONLY)
|
||||
opt = _getopt_long_only_r (parser->state.argc, parser->state.argv,
|
||||
parser->short_opts, parser->long_opts, 0,
|
||||
&parser->opt_data);
|
||||
else
|
||||
opt = _getopt_long_r (parser->state.argc, parser->state.argv,
|
||||
parser->short_opts, parser->long_opts, 0,
|
||||
&parser->opt_data);
|
||||
/* And see what getopt did. */
|
||||
parser->state.next = parser->opt_data.optind;
|
||||
|
||||
if (opt == KEY_END)
|
||||
/* Getopt says there are no more options, so stop using
|
||||
getopt; we'll continue if necessary on our own. */
|
||||
{
|
||||
parser->try_getopt = 0;
|
||||
if (parser->state.next > 1
|
||||
&& strcmp (parser->state.argv[parser->state.next - 1], QUOTE)
|
||||
== 0)
|
||||
/* Not only is this the end of the options, but it's a
|
||||
"quoted" region, which may have args that *look* like
|
||||
options, so we definitely shouldn't try to use getopt past
|
||||
here, whatever happens. */
|
||||
parser->state.quoted = parser->state.next;
|
||||
}
|
||||
else if (opt == KEY_ERR && parser->opt_data.optopt != KEY_END)
|
||||
/* KEY_ERR can have the same value as a valid user short
|
||||
option, but in the case of a real error, getopt sets OPTOPT
|
||||
to the offending character, which can never be KEY_END. */
|
||||
{
|
||||
*arg_ebadkey = 0;
|
||||
return EBADKEY;
|
||||
}
|
||||
}
|
||||
else
|
||||
opt = KEY_END;
|
||||
|
||||
if (opt == KEY_END)
|
||||
{
|
||||
/* We're past what getopt considers the options. */
|
||||
if (parser->state.next >= parser->state.argc
|
||||
|| (parser->state.flags & ARGP_NO_ARGS))
|
||||
/* Indicate that we're done. */
|
||||
{
|
||||
*arg_ebadkey = 1;
|
||||
return EBADKEY;
|
||||
}
|
||||
else
|
||||
/* A non-option arg; simulate what getopt might have done. */
|
||||
{
|
||||
opt = KEY_ARG;
|
||||
parser->opt_data.optarg = parser->state.argv[parser->state.next++];
|
||||
}
|
||||
}
|
||||
|
||||
if (opt == KEY_ARG)
|
||||
/* A non-option argument; try each parser in turn. */
|
||||
err = parser_parse_arg (parser, parser->opt_data.optarg);
|
||||
else
|
||||
err = parser_parse_opt (parser, opt, parser->opt_data.optarg);
|
||||
|
||||
if (err == EBADKEY)
|
||||
*arg_ebadkey = (opt == KEY_END || opt == KEY_ARG);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Parse the options strings in ARGC & ARGV according to the argp in ARGP.
|
||||
FLAGS is one of the ARGP_ flags above. If END_INDEX is non-NULL, the
|
||||
index in ARGV of the first unparsed option is returned in it. If an
|
||||
unknown option is present, EINVAL is returned; if some parser routine
|
||||
returned a non-zero value, it is returned; otherwise 0 is returned. */
|
||||
error_t
|
||||
__argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
|
||||
int *end_index, void *input)
|
||||
{
|
||||
error_t err;
|
||||
struct parser parser;
|
||||
|
||||
/* If true, then err == EBADKEY is a result of a non-option argument failing
|
||||
to be parsed (which in some cases isn't actually an error). */
|
||||
int arg_ebadkey = 0;
|
||||
|
||||
#ifndef _LIBC
|
||||
if (!(flags & ARGP_PARSE_ARGV0))
|
||||
{
|
||||
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
|
||||
if (!program_invocation_name)
|
||||
program_invocation_name = argv[0];
|
||||
#endif
|
||||
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
||||
if (!program_invocation_short_name)
|
||||
program_invocation_short_name = __argp_base_name (argv[0]);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! (flags & ARGP_NO_HELP))
|
||||
/* Add our own options. */
|
||||
{
|
||||
struct argp_child *child = alloca (4 * sizeof (struct argp_child));
|
||||
struct argp *top_argp = alloca (sizeof (struct argp));
|
||||
|
||||
/* TOP_ARGP has no options, it just serves to group the user & default
|
||||
argps. */
|
||||
memset (top_argp, 0, sizeof (*top_argp));
|
||||
top_argp->children = child;
|
||||
|
||||
memset (child, 0, 4 * sizeof (struct argp_child));
|
||||
|
||||
if (argp)
|
||||
(child++)->argp = argp;
|
||||
(child++)->argp = &argp_default_argp;
|
||||
if (argp_program_version || argp_program_version_hook)
|
||||
(child++)->argp = &argp_version_argp;
|
||||
child->argp = NULL;
|
||||
|
||||
argp = top_argp;
|
||||
}
|
||||
|
||||
/* Construct a parser for these arguments. */
|
||||
err = parser_init (&parser, argp, argc, argv, flags, input);
|
||||
|
||||
if (! err)
|
||||
/* Parse! */
|
||||
{
|
||||
while (! err)
|
||||
err = parser_parse_next (&parser, &arg_ebadkey);
|
||||
err = parser_finalize (&parser, err, arg_ebadkey, end_index);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__argp_parse, argp_parse)
|
||||
#endif
|
||||
|
||||
/* Return the input field for ARGP in the parser corresponding to STATE; used
|
||||
by the help routines. */
|
||||
void *
|
||||
__argp_input (const struct argp *argp, const struct argp_state *state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
struct group *group;
|
||||
struct parser *parser = state->pstate;
|
||||
|
||||
for (group = parser->groups; group < parser->egroup; group++)
|
||||
if (group->argp == argp)
|
||||
return group->input;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#ifdef weak_alias
|
||||
weak_alias (__argp_input, _argp_input)
|
||||
#endif
|
35
gl/lib/argp-pin.c
Normal file
35
gl/lib/argp-pin.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Full and short program names for argp module
|
||||
Copyright (C) 2005, 2009-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
|
||||
char *program_invocation_short_name = NULL;
|
||||
#endif
|
||||
#ifndef HAVE_PROGRAM_INVOCATION_NAME
|
||||
char *program_invocation_name = NULL;
|
||||
#endif
|
||||
|
||||
#if (defined HAVE_PROGRAM_INVOCATION_SHORT_NAME \
|
||||
&& defined HAVE_PROGRAM_INVOCATION_NAME)
|
||||
/* This declaration is solely to ensure that after preprocessing
|
||||
this file is never empty. */
|
||||
typedef int dummy;
|
||||
#endif
|
33
gl/lib/argp-pv.c
Normal file
33
gl/lib/argp-pv.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* Default definition for ARGP_PROGRAM_VERSION.
|
||||
Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* If set by the user program to a non-zero value, then a default option
|
||||
--version is added (unless the ARGP_NO_HELP flag is used), which will
|
||||
print this string followed by a newline and exit (unless the
|
||||
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
|
||||
const char *argp_program_version
|
||||
/* This variable should be zero-initialized. On most systems, putting it into
|
||||
BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see
|
||||
<https://lists.gnu.org/r/bug-gnulib/2009-01/msg00329.html>
|
||||
<https://lists.gnu.org/r/bug-gnulib/2009-08/msg00096.html>. */
|
||||
#if defined __ELF__
|
||||
/* On ELF systems, variables in BSS behave well. */
|
||||
#else
|
||||
= (const char *) 0
|
||||
#endif
|
||||
;
|
30
gl/lib/argp-pvh.c
Normal file
30
gl/lib/argp-pvh.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Default definition for ARGP_PROGRAM_VERSION_HOOK.
|
||||
Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "argp.h"
|
||||
|
||||
/* If set by the user program to a non-zero value, then a default option
|
||||
--version is added (unless the ARGP_NO_HELP flag is used), which calls
|
||||
this function with a stream to print the version to and a pointer to the
|
||||
current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
|
||||
used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
|
||||
void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) = NULL;
|
46
gl/lib/argp-xinl.c
Normal file
46
gl/lib/argp-xinl.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* Real definitions for extern inline functions in argp.h
|
||||
Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined _LIBC || defined HAVE_FEATURES_H
|
||||
# include <features.h>
|
||||
#endif
|
||||
|
||||
#ifndef __USE_EXTERN_INLINES
|
||||
# define __USE_EXTERN_INLINES 1
|
||||
#endif
|
||||
#ifdef _LIBC
|
||||
# define ARGP_EI
|
||||
#else
|
||||
# define ARGP_EI _GL_EXTERN_INLINE
|
||||
#endif
|
||||
#undef __OPTIMIZE__
|
||||
#define __OPTIMIZE__ 1
|
||||
#include "argp.h"
|
||||
|
||||
/* Add weak aliases. */
|
||||
#if _LIBC - 0 && defined (weak_alias)
|
||||
|
||||
weak_alias (__argp_usage, argp_usage)
|
||||
weak_alias (__option_is_short, _option_is_short)
|
||||
weak_alias (__option_is_end, _option_is_end)
|
||||
|
||||
#endif
|
645
gl/lib/argp.h
Normal file
645
gl/lib/argp.h
Normal file
|
@ -0,0 +1,645 @@
|
|||
/* Hierarchical argument parsing, layered over getopt.
|
||||
Copyright (C) 1995-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _ARGP_H
|
||||
#define _ARGP_H
|
||||
|
||||
/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_FORMAT. */
|
||||
#if !_LIBC && !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define __need_error_t
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef __THROW
|
||||
# define __THROW
|
||||
#endif
|
||||
#ifndef __NTH
|
||||
# define __NTH(fct) fct __THROW
|
||||
#endif
|
||||
|
||||
/* GCC 2.95 and later have "__restrict"; C99 compilers have
|
||||
"restrict", and "configure" may have defined "restrict".
|
||||
Other compilers use __restrict, __restrict__, and _Restrict, and
|
||||
'configure' might #define 'restrict' to those words. */
|
||||
#ifndef __restrict
|
||||
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__) \
|
||||
|| __clang_major__ >= 3)
|
||||
# if 199901L <= __STDC_VERSION__
|
||||
# define __restrict restrict
|
||||
# else
|
||||
# define __restrict
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __error_t_defined
|
||||
typedef int error_t;
|
||||
# define __error_t_defined
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Glibc documentation:
|
||||
https://www.gnu.org/software/libc/manual/html_node/Argp.html */
|
||||
|
||||
/* A description of a particular option. A pointer to an array of
|
||||
these is passed in the OPTIONS field of an argp structure. Each option
|
||||
entry can correspond to one long option and/or one short option; more
|
||||
names for the same option can be added by following an entry in an option
|
||||
array with options having the OPTION_ALIAS flag set. */
|
||||
struct argp_option
|
||||
{
|
||||
/* The long option name. For more than one name for the same option, you
|
||||
can use following options with the OPTION_ALIAS flag set. */
|
||||
const char *name;
|
||||
|
||||
/* What key is returned for this option. If > 0 and printable, then it's
|
||||
also accepted as a short option. */
|
||||
int key;
|
||||
|
||||
/* If non-NULL, this is the name of the argument associated with this
|
||||
option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */
|
||||
const char *arg;
|
||||
|
||||
/* OPTION_ flags. */
|
||||
int flags;
|
||||
|
||||
/* The doc string for this option. If both NAME and KEY are 0, This string
|
||||
will be printed outdented from the normal option column, making it
|
||||
useful as a group header (it will be the first thing printed in its
|
||||
group); in this usage, it's conventional to end the string with a ':'.
|
||||
|
||||
Write the initial value as N_("TEXT") if you want xgettext to collect
|
||||
it into a POT file. */
|
||||
const char *doc;
|
||||
|
||||
/* The group this option is in. In a long help message, options are sorted
|
||||
alphabetically within each group, and the groups presented in the order
|
||||
0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with
|
||||
if this field 0 will inherit the group number of the previous entry, or
|
||||
zero if it's the first one, unless its a group header (NAME and KEY both
|
||||
0), in which case, the previous entry + 1 is the default. Automagic
|
||||
options such as --help are put into group -1. */
|
||||
int group;
|
||||
};
|
||||
|
||||
/* The argument associated with this option is optional. */
|
||||
#define OPTION_ARG_OPTIONAL 0x1
|
||||
|
||||
/* This option isn't displayed in any help messages. */
|
||||
#define OPTION_HIDDEN 0x2
|
||||
|
||||
/* This option is an alias for the closest previous non-alias option. This
|
||||
means that it will be displayed in the same help entry, and will inherit
|
||||
fields other than NAME and KEY from the aliased option. */
|
||||
#define OPTION_ALIAS 0x4
|
||||
|
||||
/* This option isn't actually an option (and so should be ignored by the
|
||||
actual option parser), but rather an arbitrary piece of documentation that
|
||||
should be displayed in much the same manner as the options. If this flag
|
||||
is set, then the option NAME field is displayed unmodified (e.g., no '--'
|
||||
prefix is added) at the left-margin (where a *short* option would normally
|
||||
be displayed), and the documentation string in the normal place. The NAME
|
||||
field will be translated using gettext, unless OPTION_NO_TRANS is set (see
|
||||
below). For purposes of sorting, any leading whitespace and punctuation is
|
||||
ignored, except that if the first non-whitespace character is not '-', this
|
||||
entry is displayed after all options (and OPTION_DOC entries with a leading
|
||||
'-') in the same group. */
|
||||
#define OPTION_DOC 0x8
|
||||
|
||||
/* This option shouldn't be included in "long" usage messages (but is still
|
||||
included in help messages). This is mainly intended for options that are
|
||||
completely documented in an argp's ARGS_DOC field, in which case including
|
||||
the option in the generic usage list would be redundant. For instance,
|
||||
if ARGS_DOC is "FOO BAR\n-x BLAH", and the '-x' option's purpose is to
|
||||
distinguish these two cases, -x should probably be marked
|
||||
OPTION_NO_USAGE. */
|
||||
#define OPTION_NO_USAGE 0x10
|
||||
|
||||
/* Valid only in conjunction with OPTION_DOC. This option disables translation
|
||||
of option name. */
|
||||
#define OPTION_NO_TRANS 0x20
|
||||
|
||||
struct argp; /* fwd declare this type */
|
||||
struct argp_state; /* " */
|
||||
struct argp_child; /* " */
|
||||
|
||||
/* The type of a pointer to an argp parsing function. */
|
||||
typedef error_t (*argp_parser_t) (int __key, char *__arg,
|
||||
struct argp_state *__state);
|
||||
|
||||
/* What to return for unrecognized keys. For special ARGP_KEY_ keys, such
|
||||
returns will simply be ignored. For user keys, this error will be turned
|
||||
into EINVAL (if the call to argp_parse is such that errors are propagated
|
||||
back to the user instead of exiting); returning EINVAL itself would result
|
||||
in an immediate stop to parsing in *all* cases. */
|
||||
#define ARGP_ERR_UNKNOWN E2BIG /* Hurd should never need E2BIG. XXX */
|
||||
|
||||
/* Special values for the KEY argument to an argument parsing function.
|
||||
ARGP_ERR_UNKNOWN should be returned if they aren't understood.
|
||||
|
||||
The sequence of keys to a parsing function is either (where each
|
||||
uppercased word should be prefixed by 'ARGP_KEY_' and opt is a user key):
|
||||
|
||||
INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all
|
||||
or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed
|
||||
or INIT (opt | ARG)... SUCCESS -- Some non-option arg unrecognized
|
||||
|
||||
The third case is where every parser returned ARGP_KEY_UNKNOWN for an
|
||||
argument, in which case parsing stops at that argument (returning the
|
||||
unparsed arguments to the caller of argp_parse if requested, or stopping
|
||||
with an error message if not).
|
||||
|
||||
If an error occurs (either detected by argp, or because the parsing
|
||||
function returned an error value), then the parser is called with
|
||||
ARGP_KEY_ERROR, and no further calls are made. */
|
||||
|
||||
/* This is not an option at all, but rather a command line argument. If a
|
||||
parser receiving this key returns success, the fact is recorded, and the
|
||||
ARGP_KEY_NO_ARGS case won't be used. HOWEVER, if while processing the
|
||||
argument, a parser function decrements the NEXT field of the state it's
|
||||
passed, the option won't be considered processed; this is to allow you to
|
||||
actually modify the argument (perhaps into an option), and have it
|
||||
processed again. */
|
||||
#define ARGP_KEY_ARG 0
|
||||
/* There are remaining arguments not parsed by any parser, which may be found
|
||||
starting at (STATE->argv + STATE->next). If success is returned, but
|
||||
STATE->next left untouched, it's assumed that all arguments were consume,
|
||||
otherwise, the parser should adjust STATE->next to reflect any arguments
|
||||
consumed. */
|
||||
#define ARGP_KEY_ARGS 0x1000006
|
||||
/* There are no more command line arguments at all. */
|
||||
#define ARGP_KEY_END 0x1000001
|
||||
/* Because it's common to want to do some special processing if there aren't
|
||||
any non-option args, user parsers are called with this key if they didn't
|
||||
successfully process any non-option arguments. Called just before
|
||||
ARGP_KEY_END (where more general validity checks on previously parsed
|
||||
arguments can take place). */
|
||||
#define ARGP_KEY_NO_ARGS 0x1000002
|
||||
/* Passed in before any parsing is done. Afterwards, the values of each
|
||||
element of the CHILD_INPUT field, if any, in the state structure is
|
||||
copied to each child's state to be the initial value of the INPUT field. */
|
||||
#define ARGP_KEY_INIT 0x1000003
|
||||
/* Use after all other keys, including SUCCESS & END. */
|
||||
#define ARGP_KEY_FINI 0x1000007
|
||||
/* Passed in when parsing has successfully been completed (even if there are
|
||||
still arguments remaining). */
|
||||
#define ARGP_KEY_SUCCESS 0x1000004
|
||||
/* Passed in if an error occurs. */
|
||||
#define ARGP_KEY_ERROR 0x1000005
|
||||
|
||||
/* An argp structure contains a set of options declarations, a function to
|
||||
deal with parsing one, documentation string, a possible vector of child
|
||||
argp's, and perhaps a function to filter help output. When actually
|
||||
parsing options, getopt is called with the union of all the argp
|
||||
structures chained together through their CHILD pointers, with conflicts
|
||||
being resolved in favor of the first occurrence in the chain. */
|
||||
struct argp
|
||||
{
|
||||
/* An array of argp_option structures, terminated by an entry with both
|
||||
NAME and KEY having a value of 0. */
|
||||
const struct argp_option *options;
|
||||
|
||||
/* What to do with an option from this structure. KEY is the key
|
||||
associated with the option, and ARG is any associated argument (NULL if
|
||||
none was supplied). If KEY isn't understood, ARGP_ERR_UNKNOWN should be
|
||||
returned. If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then
|
||||
parsing is stopped immediately, and that value is returned from
|
||||
argp_parse(). For special (non-user-supplied) values of KEY, see the
|
||||
ARGP_KEY_ definitions below. */
|
||||
argp_parser_t parser;
|
||||
|
||||
/* If non-NULL, a string describing what other arguments are wanted by this
|
||||
program. It is only used by argp_usage to print the "Usage:" message.
|
||||
If it contains newlines, the strings separated by them are considered
|
||||
alternative usage patterns, and printed on separate lines (lines after
|
||||
the first are prefix by " or: " instead of "Usage:"). */
|
||||
const char *args_doc;
|
||||
|
||||
/* If non-NULL, a string containing extra text to be printed before and
|
||||
after the options in a long help message (separated by a vertical tab
|
||||
'\v' character).
|
||||
Write the initial value as N_("BEFORE-TEXT") "\v" N_("AFTER-TEXT") if
|
||||
you want xgettext to collect the two pieces of text into a POT file. */
|
||||
const char *doc;
|
||||
|
||||
/* A vector of argp_children structures, terminated by a member with a 0
|
||||
argp field, pointing to child argps should be parsed with this one. Any
|
||||
conflicts are resolved in favor of this argp, or early argps in the
|
||||
CHILDREN list. This field is useful if you use libraries that supply
|
||||
their own argp structure, which you want to use in conjunction with your
|
||||
own. */
|
||||
const struct argp_child *children;
|
||||
|
||||
/* If non-zero, this should be a function to filter the output of help
|
||||
messages. KEY is either a key from an option, in which case TEXT is
|
||||
that option's help text, or a special key from the ARGP_KEY_HELP_
|
||||
defines, below, describing which other help text TEXT is. The function
|
||||
should return either TEXT, if it should be used as-is, a replacement
|
||||
string, which should be malloced, and will be freed by argp, or NULL,
|
||||
meaning "print nothing". The value for TEXT is *after* any translation
|
||||
has been done, so if any of the replacement text also needs translation,
|
||||
that should be done by the filter function. INPUT is either the input
|
||||
supplied to argp_parse, or NULL, if argp_help was called directly. */
|
||||
char *(*help_filter) (int __key, const char *__text, void *__input);
|
||||
|
||||
/* If non-zero the strings used in the argp library are translated using
|
||||
the domain described by this string. Otherwise the currently installed
|
||||
default domain is used. */
|
||||
const char *argp_domain;
|
||||
};
|
||||
|
||||
/* Possible KEY arguments to a help filter function. */
|
||||
#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceding options. */
|
||||
#define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */
|
||||
#define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */
|
||||
#define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation;
|
||||
TEXT is NULL for this key. */
|
||||
/* Explanatory note emitted when duplicate option arguments have been
|
||||
suppressed. */
|
||||
#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
|
||||
#define ARGP_KEY_HELP_ARGS_DOC 0x2000006 /* Argument doc string. */
|
||||
|
||||
/* When an argp has a non-zero CHILDREN field, it should point to a vector of
|
||||
argp_child structures, each of which describes a subsidiary argp. */
|
||||
struct argp_child
|
||||
{
|
||||
/* The child parser. */
|
||||
const struct argp *argp;
|
||||
|
||||
/* Flags for this child. */
|
||||
int flags;
|
||||
|
||||
/* If non-zero, an optional header to be printed in help output before the
|
||||
child options. As a side-effect, a non-zero value forces the child
|
||||
options to be grouped together; to achieve this effect without actually
|
||||
printing a header string, use a value of "". */
|
||||
const char *header;
|
||||
|
||||
/* Where to group the child options relative to the other ("consolidated")
|
||||
options in the parent argp; the values are the same as the GROUP field
|
||||
in argp_option structs, but all child-groupings follow parent options at
|
||||
a particular group level. If both this field and HEADER are zero, then
|
||||
they aren't grouped at all, but rather merged with the parent options
|
||||
(merging the child's grouping levels with the parents). */
|
||||
int group;
|
||||
};
|
||||
|
||||
/* Parsing state. This is provided to parsing functions called by argp,
|
||||
which may examine and, as noted, modify fields. */
|
||||
struct argp_state
|
||||
{
|
||||
/* The top level ARGP being parsed. */
|
||||
const struct argp *root_argp;
|
||||
|
||||
/* The argument vector being parsed. May be modified. */
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
/* The index in ARGV of the next arg that to be parsed. May be modified. */
|
||||
int next;
|
||||
|
||||
/* The flags supplied to argp_parse. May be modified. */
|
||||
unsigned flags;
|
||||
|
||||
/* While calling a parsing function with a key of ARGP_KEY_ARG, this is the
|
||||
number of the current arg, starting at zero, and incremented after each
|
||||
such call returns. At all other times, this is the number of such
|
||||
arguments that have been processed. */
|
||||
unsigned arg_num;
|
||||
|
||||
/* If non-zero, the index in ARGV of the first argument following a special
|
||||
'--' argument (which prevents anything following being interpreted as an
|
||||
option). Only set once argument parsing has proceeded past this point. */
|
||||
int quoted;
|
||||
|
||||
/* An arbitrary pointer passed in from the user. */
|
||||
void *input;
|
||||
/* Values to pass to child parsers. This vector will be the same length as
|
||||
the number of children for the current parser. */
|
||||
void **child_inputs;
|
||||
|
||||
/* For the parser's use. Initialized to 0. */
|
||||
void *hook;
|
||||
|
||||
/* The name used when printing messages. This is initialized to ARGV[0],
|
||||
or PROGRAM_INVOCATION_NAME if that is unavailable. */
|
||||
char *name;
|
||||
|
||||
/* Streams used when argp prints something. */
|
||||
FILE *err_stream; /* For errors; initialized to stderr. */
|
||||
FILE *out_stream; /* For information; initialized to stdout. */
|
||||
|
||||
void *pstate; /* Private, for use by argp. */
|
||||
};
|
||||
|
||||
/* Flags for argp_parse (note that the defaults are those that are
|
||||
convenient for program command line parsing): */
|
||||
|
||||
/* Don't ignore the first element of ARGV. Normally (and always unless
|
||||
ARGP_NO_ERRS is set) the first element of the argument vector is
|
||||
skipped for option parsing purposes, as it corresponds to the program name
|
||||
in a command line. */
|
||||
#define ARGP_PARSE_ARGV0 0x01
|
||||
|
||||
/* Don't print error messages for unknown options to stderr; unless this flag
|
||||
is set, ARGP_PARSE_ARGV0 is ignored, as ARGV[0] is used as the program
|
||||
name in the error messages. This flag implies ARGP_NO_EXIT (on the
|
||||
assumption that silent exiting upon errors is bad behaviour). */
|
||||
#define ARGP_NO_ERRS 0x02
|
||||
|
||||
/* Don't parse any non-option args. Normally non-option args are parsed by
|
||||
calling the parse functions with a key of ARGP_KEY_ARG, and the actual arg
|
||||
as the value. Since it's impossible to know which parse function wants to
|
||||
handle it, each one is called in turn, until one returns 0 or an error
|
||||
other than ARGP_ERR_UNKNOWN; if an argument is handled by no one, the
|
||||
argp_parse returns prematurely (but with a return value of 0). If all
|
||||
args have been parsed without error, all parsing functions are called one
|
||||
last time with a key of ARGP_KEY_END. This flag needn't normally be set,
|
||||
as the normal behavior is to stop parsing as soon as some argument can't
|
||||
be handled. */
|
||||
#define ARGP_NO_ARGS 0x04
|
||||
|
||||
/* Parse options and arguments in the same order they occur on the command
|
||||
line -- normally they're rearranged so that all options come first. */
|
||||
#define ARGP_IN_ORDER 0x08
|
||||
|
||||
/* Don't provide the standard long option --help, which causes usage and
|
||||
option help information to be output to stdout, and exit (0) called. */
|
||||
#define ARGP_NO_HELP 0x10
|
||||
|
||||
/* Don't exit on errors (they may still result in error messages). */
|
||||
#define ARGP_NO_EXIT 0x20
|
||||
|
||||
/* Use the gnu getopt "long-only" rules for parsing arguments. */
|
||||
#define ARGP_LONG_ONLY 0x40
|
||||
|
||||
/* Turns off any message-printing/exiting options. */
|
||||
#define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP)
|
||||
|
||||
/* Parse the options strings in ARGC & ARGV according to the options in ARGP.
|
||||
FLAGS is one of the ARGP_ flags above. If ARG_INDEX is non-NULL, the
|
||||
index in ARGV of the first unparsed option is returned in it. If an
|
||||
unknown option is present, ARGP_ERR_UNKNOWN is returned; if some parser
|
||||
routine returned a non-zero value, it is returned; otherwise 0 is
|
||||
returned. This function may also call exit unless the ARGP_NO_HELP flag
|
||||
is set. INPUT is a pointer to a value to be passed to the parser. */
|
||||
extern error_t argp_parse (const struct argp *__restrict __argp,
|
||||
int /*argc*/, char **__restrict /*argv*/,
|
||||
unsigned __flags, int *__restrict __arg_index,
|
||||
void *__restrict __input);
|
||||
extern error_t __argp_parse (const struct argp *__restrict __argp,
|
||||
int /*argc*/, char **__restrict /*argv*/,
|
||||
unsigned __flags, int *__restrict __arg_index,
|
||||
void *__restrict __input);
|
||||
|
||||
/* Global variables. */
|
||||
|
||||
/* GNULIB makes sure both program_invocation_name and
|
||||
program_invocation_short_name are available */
|
||||
#ifdef GNULIB_PROGRAM_INVOCATION_NAME
|
||||
extern char *program_invocation_name;
|
||||
# undef HAVE_DECL_PROGRAM_INVOCATION_NAME
|
||||
# define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME
|
||||
extern char *program_invocation_short_name;
|
||||
# undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
||||
# define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1
|
||||
#endif
|
||||
|
||||
/* If defined or set by the user program to a non-zero value, then a default
|
||||
option --version is added (unless the ARGP_NO_HELP flag is used), which
|
||||
will print this string followed by a newline and exit (unless the
|
||||
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
|
||||
extern const char *argp_program_version;
|
||||
|
||||
/* If defined or set by the user program to a non-zero value, then a default
|
||||
option --version is added (unless the ARGP_NO_HELP flag is used), which
|
||||
calls this function with a stream to print the version to and a pointer to
|
||||
the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
|
||||
used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
|
||||
extern void (*argp_program_version_hook) (FILE *__restrict __stream,
|
||||
struct argp_state *__restrict
|
||||
__state);
|
||||
|
||||
/* If defined or set by the user program, it should point to string that is
|
||||
the bug-reporting address for the program. It will be printed by
|
||||
argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various
|
||||
standard help messages), embedded in a sentence that says something like
|
||||
"Report bugs to ADDR." */
|
||||
extern const char *argp_program_bug_address;
|
||||
|
||||
/* The exit status that argp will use when exiting due to a parsing error.
|
||||
If not defined or set by the user program, this defaults to EX_USAGE from
|
||||
<sysexits.h>. */
|
||||
extern error_t argp_err_exit_status;
|
||||
|
||||
/* Flags for argp_help. */
|
||||
#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */
|
||||
#define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */
|
||||
#define ARGP_HELP_SEE 0x04 /* a "Try ... for more help" message. */
|
||||
#define ARGP_HELP_LONG 0x08 /* a long help message. */
|
||||
#define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */
|
||||
#define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */
|
||||
#define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC)
|
||||
#define ARGP_HELP_BUG_ADDR 0x40 /* bug report address */
|
||||
#define ARGP_HELP_LONG_ONLY 0x80 /* modify output appropriately to
|
||||
reflect ARGP_LONG_ONLY mode. */
|
||||
|
||||
/* These ARGP_HELP flags are only understood by argp_state_help. */
|
||||
#define ARGP_HELP_EXIT_ERR 0x100 /* Call exit(1) instead of returning. */
|
||||
#define ARGP_HELP_EXIT_OK 0x200 /* Call exit(0) instead of returning. */
|
||||
|
||||
/* The standard thing to do after a program command line parsing error, if an
|
||||
error message has already been printed. */
|
||||
#define ARGP_HELP_STD_ERR \
|
||||
(ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
|
||||
/* The standard thing to do after a program command line parsing error, if no
|
||||
more specific error message has been printed. */
|
||||
#define ARGP_HELP_STD_USAGE \
|
||||
(ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
|
||||
/* The standard thing to do in response to a --help option. */
|
||||
#define ARGP_HELP_STD_HELP \
|
||||
(ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \
|
||||
| ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR)
|
||||
|
||||
/* Output a usage message for ARGP to STREAM. FLAGS are from the set
|
||||
ARGP_HELP_*. */
|
||||
extern void argp_help (const struct argp *__restrict __argp,
|
||||
FILE *__restrict __stream,
|
||||
unsigned __flags, char *__restrict __name);
|
||||
extern void __argp_help (const struct argp *__restrict __argp,
|
||||
FILE *__restrict __stream, unsigned __flags,
|
||||
char *__name);
|
||||
|
||||
/* The following routines are intended to be called from within an argp
|
||||
parsing routine (thus taking an argp_state structure as the first
|
||||
argument). They may or may not print an error message and exit, depending
|
||||
on the flags in STATE -- in any case, the caller should be prepared for
|
||||
them *not* to exit, and should return an appropriate error after calling
|
||||
them. [argp_usage & argp_error should probably be called argp_state_...,
|
||||
but they're used often enough that they should be short] */
|
||||
|
||||
/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
|
||||
from the set ARGP_HELP_*. */
|
||||
extern void argp_state_help (const struct argp_state *__restrict __state,
|
||||
FILE *__restrict __stream,
|
||||
unsigned int __flags);
|
||||
extern void __argp_state_help (const struct argp_state *__restrict __state,
|
||||
FILE *__restrict __stream,
|
||||
unsigned int __flags);
|
||||
|
||||
#if _LIBC
|
||||
/* Possibly output the standard usage message for ARGP to stderr and exit. */
|
||||
extern void argp_usage (const struct argp_state *__state);
|
||||
extern void __argp_usage (const struct argp_state *__state);
|
||||
#endif
|
||||
|
||||
/* If appropriate, print the printf string FMT and following args, preceded
|
||||
by the program name and ':', to stderr, and followed by a "Try ... --help"
|
||||
message, then exit (1). */
|
||||
extern void argp_error (const struct argp_state *__restrict __state,
|
||||
const char *__restrict __fmt, ...)
|
||||
#if GNULIB_VFPRINTF_POSIX
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 2, 3))
|
||||
#else
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 2, 3))
|
||||
#endif
|
||||
;
|
||||
extern void __argp_error (const struct argp_state *__restrict __state,
|
||||
const char *__restrict __fmt, ...)
|
||||
#if GNULIB_VFPRINTF_POSIX
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 2, 3))
|
||||
#else
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 2, 3))
|
||||
#endif
|
||||
;
|
||||
|
||||
/* Similar to the standard gnu error-reporting function error(), but will
|
||||
respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
|
||||
to STATE->err_stream. This is useful for argument parsing code that is
|
||||
shared between program startup (when exiting is desired) and runtime
|
||||
option parsing (when typically an error code is returned instead). The
|
||||
difference between this function and argp_error is that the latter is for
|
||||
*parsing errors*, and the former is for other problems that occur during
|
||||
parsing but don't reflect a (syntactic) problem with the input. */
|
||||
extern void argp_failure (const struct argp_state *__restrict __state,
|
||||
int __status, int __errnum,
|
||||
const char *__restrict __fmt, ...)
|
||||
#if GNULIB_VFPRINTF_POSIX
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 4, 5))
|
||||
#else
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 4, 5))
|
||||
#endif
|
||||
;
|
||||
extern void __argp_failure (const struct argp_state *__restrict __state,
|
||||
int __status, int __errnum,
|
||||
const char *__restrict __fmt, ...)
|
||||
#if GNULIB_VFPRINTF_POSIX
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 4, 5))
|
||||
#else
|
||||
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 4, 5))
|
||||
#endif
|
||||
;
|
||||
|
||||
#if _LIBC
|
||||
/* Returns true if the option OPT is a valid short option. */
|
||||
extern int _option_is_short (const struct argp_option *__opt) __THROW;
|
||||
extern int __option_is_short (const struct argp_option *__opt) __THROW;
|
||||
|
||||
/* Returns true if the option OPT is in fact the last (unused) entry in an
|
||||
options array. */
|
||||
extern int _option_is_end (const struct argp_option *__opt) __THROW;
|
||||
extern int __option_is_end (const struct argp_option *__opt) __THROW;
|
||||
#endif
|
||||
|
||||
/* Return the input field for ARGP in the parser corresponding to STATE; used
|
||||
by the help routines. */
|
||||
extern void *_argp_input (const struct argp *__restrict __argp,
|
||||
const struct argp_state *__restrict __state)
|
||||
__THROW;
|
||||
extern void *__argp_input (const struct argp *__restrict __argp,
|
||||
const struct argp_state *__restrict __state)
|
||||
__THROW;
|
||||
|
||||
#if !_LIBC || defined __USE_EXTERN_INLINES
|
||||
|
||||
# if !_LIBC
|
||||
# define __argp_usage argp_usage
|
||||
# define __argp_state_help argp_state_help
|
||||
# define __option_is_short _option_is_short
|
||||
# define __option_is_end _option_is_end
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
# ifndef ARGP_EI
|
||||
# define ARGP_EI _GL_INLINE
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef ARGP_EI
|
||||
# define ARGP_EI __extern_inline
|
||||
# endif
|
||||
|
||||
ARGP_EI void
|
||||
__argp_usage (const struct argp_state *__state)
|
||||
{
|
||||
__argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
|
||||
}
|
||||
|
||||
ARGP_EI int
|
||||
__NTH (__option_is_short (const struct argp_option *__opt))
|
||||
{
|
||||
if (__opt->flags & OPTION_DOC)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
int __key = __opt->key;
|
||||
return __key > 0 && __key <= UCHAR_MAX && isprint (__key);
|
||||
}
|
||||
}
|
||||
|
||||
ARGP_EI int
|
||||
__NTH (__option_is_end (const struct argp_option *__opt))
|
||||
{
|
||||
return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
|
||||
}
|
||||
|
||||
# if !_LIBC
|
||||
# undef __argp_usage
|
||||
# undef __argp_state_help
|
||||
# undef __option_is_short
|
||||
# undef __option_is_end
|
||||
_GL_INLINE_HEADER_END
|
||||
# endif
|
||||
#endif /* Use extern inlines. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* argp.h */
|
34
gl/lib/asnprintf.c
Normal file
34
gl/lib/asnprintf.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* Formatted output to strings.
|
||||
Copyright (C) 1999, 2002, 2006, 2009-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "vasnprintf.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
char *
|
||||
asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
char *result;
|
||||
|
||||
va_start (args, format);
|
||||
result = vasnprintf (resultbuf, lengthp, format, args);
|
||||
va_end (args);
|
||||
return result;
|
||||
}
|
27
gl/lib/assert.in.h
Normal file
27
gl/lib/assert.in.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* Substitute for and wrapper around <assert.h>
|
||||
Copyright (C) 2011-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Do not guard the include, since <assert.h> is supposed to define
|
||||
the assert macro each time it is included. */
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#@INCLUDE_NEXT@ @NEXT_ASSERT_H@
|
||||
|
||||
/* The definition of static_assert is copied here. */
|
57
gl/lib/assure.h
Normal file
57
gl/lib/assure.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* Run-time assert-like macros.
|
||||
|
||||
Copyright (C) 2014-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#ifndef _GL_ASSURE_H
|
||||
#define _GL_ASSURE_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "verify.h"
|
||||
|
||||
/* Evaluate an assertion E that is guaranteed to be true.
|
||||
If NDEBUG is not defined, abort the program if E is false.
|
||||
If NDEBUG is defined, the compiler can assume E and behavior is
|
||||
undefined if E is false, fails to evaluate, or has side effects.
|
||||
|
||||
Unlike standard 'assert', this macro evaluates E even when NDEBUG
|
||||
is defined, so as to catch typos, avoid some GCC warnings, and
|
||||
improve performance when E is simple enough.
|
||||
|
||||
Also see the documentation for 'assume' in verify.h. */
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define affirm(E) assume (E)
|
||||
#else
|
||||
# define affirm(E) assert (E)
|
||||
#endif
|
||||
|
||||
/* Check E's value at runtime, and report an error and abort if not.
|
||||
However, do nothing if NDEBUG is defined.
|
||||
|
||||
Unlike standard 'assert', this macro compiles E even when NDEBUG
|
||||
is defined, so as to catch typos and avoid some GCC warnings.
|
||||
Unlike 'affirm', it is OK for E to use hard-to-optimize features,
|
||||
since E is not executed if NDEBUG is defined. */
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define assure(E) ((void) (0 && (E)))
|
||||
#else
|
||||
# define assure(E) assert (E)
|
||||
#endif
|
||||
|
||||
#endif
|
34
gl/lib/aszprintf.c
Normal file
34
gl/lib/aszprintf.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* Formatted output to strings.
|
||||
Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
ptrdiff_t
|
||||
aszprintf (char **resultp, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
ptrdiff_t result;
|
||||
|
||||
va_start (args, format);
|
||||
result = vaszprintf (resultp, format, args);
|
||||
va_end (args);
|
||||
return result;
|
||||
}
|
146
gl/lib/at-func.c
Normal file
146
gl/lib/at-func.c
Normal file
|
@ -0,0 +1,146 @@
|
|||
/* Define at-style functions like fstatat, unlinkat, fchownat, etc.
|
||||
Copyright (C) 2006, 2009-2024 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#include "filename.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
|
||||
|
||||
#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD
|
||||
# include <errno.h>
|
||||
# ifndef ENOTSUP
|
||||
# define ENOTSUP EINVAL
|
||||
# endif
|
||||
#else
|
||||
# include "openat.h"
|
||||
# include "openat-priv.h"
|
||||
# include "save-cwd.h"
|
||||
#endif
|
||||
|
||||
#ifdef AT_FUNC_USE_F1_COND
|
||||
# define CALL_FUNC(F) \
|
||||
(flag == AT_FUNC_USE_F1_COND \
|
||||
? AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS) \
|
||||
: AT_FUNC_F2 (F AT_FUNC_POST_FILE_ARGS))
|
||||
# define VALIDATE_FLAG(F) \
|
||||
if (flag & ~AT_FUNC_USE_F1_COND) \
|
||||
{ \
|
||||
errno = EINVAL; \
|
||||
return FUNC_FAIL; \
|
||||
}
|
||||
#else
|
||||
# define CALL_FUNC(F) (AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS))
|
||||
# define VALIDATE_FLAG(F) /* empty */
|
||||
#endif
|
||||
|
||||
#ifdef AT_FUNC_RESULT
|
||||
# define FUNC_RESULT AT_FUNC_RESULT
|
||||
#else
|
||||
# define FUNC_RESULT int
|
||||
#endif
|
||||
|
||||
#ifdef AT_FUNC_FAIL
|
||||
# define FUNC_FAIL AT_FUNC_FAIL
|
||||
#else
|
||||
# define FUNC_FAIL -1
|
||||
#endif
|
||||
|
||||
/* Call AT_FUNC_F1 to operate on FILE, which is in the directory
|
||||
open on descriptor FD. If AT_FUNC_USE_F1_COND is defined to a value,
|
||||
AT_FUNC_POST_FILE_PARAM_DECLS must include a parameter named flag;
|
||||
call AT_FUNC_F2 if FLAG is 0 or fail if FLAG contains more bits than
|
||||
AT_FUNC_USE_F1_COND. Return int and fail with -1 unless AT_FUNC_RESULT
|
||||
or AT_FUNC_FAIL are defined. If possible, do it without changing the
|
||||
working directory. Otherwise, resort to using save_cwd/fchdir,
|
||||
then AT_FUNC_F?/restore_cwd. If either the save_cwd or the restore_cwd
|
||||
fails, then give a diagnostic and exit nonzero. */
|
||||
FUNC_RESULT
|
||||
AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
|
||||
{
|
||||
VALIDATE_FLAG (flag);
|
||||
|
||||
if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
|
||||
return CALL_FUNC (file);
|
||||
|
||||
#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD
|
||||
errno = ENOTSUP;
|
||||
return FUNC_FAIL;
|
||||
#else
|
||||
{
|
||||
/* Be careful to choose names unlikely to conflict with
|
||||
AT_FUNC_POST_FILE_PARAM_DECLS. */
|
||||
struct saved_cwd saved_cwd;
|
||||
int saved_errno;
|
||||
FUNC_RESULT err;
|
||||
|
||||
{
|
||||
char proc_buf[OPENAT_BUFFER_SIZE];
|
||||
char *proc_file = openat_proc_name (proc_buf, fd, file);
|
||||
if (proc_file)
|
||||
{
|
||||
FUNC_RESULT proc_result = CALL_FUNC (proc_file);
|
||||
int proc_errno = errno;
|
||||
if (proc_file != proc_buf)
|
||||
free (proc_file);
|
||||
/* If the syscall succeeds, or if it fails with an unexpected
|
||||
errno value, then return right away. Otherwise, fall through
|
||||
and resort to using save_cwd/restore_cwd. */
|
||||
if (FUNC_FAIL != proc_result)
|
||||
return proc_result;
|
||||
if (! EXPECTED_ERRNO (proc_errno))
|
||||
{
|
||||
errno = proc_errno;
|
||||
return proc_result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (save_cwd (&saved_cwd) != 0)
|
||||
openat_save_fail (errno);
|
||||
if (0 <= fd && fd == saved_cwd.desc)
|
||||
{
|
||||
/* If saving the working directory collides with the user's
|
||||
requested fd, then the user's fd must have been closed to
|
||||
begin with. */
|
||||
free_cwd (&saved_cwd);
|
||||
errno = EBADF;
|
||||
return FUNC_FAIL;
|
||||
}
|
||||
|
||||
if (fchdir (fd) != 0)
|
||||
{
|
||||
saved_errno = errno;
|
||||
free_cwd (&saved_cwd);
|
||||
errno = saved_errno;
|
||||
return FUNC_FAIL;
|
||||
}
|
||||
|
||||
err = CALL_FUNC (file);
|
||||
saved_errno = (err == FUNC_FAIL ? errno : 0);
|
||||
|
||||
if (restore_cwd (&saved_cwd) != 0)
|
||||
openat_restore_fail (errno);
|
||||
|
||||
free_cwd (&saved_cwd);
|
||||
|
||||
if (saved_errno)
|
||||
errno = saved_errno;
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#undef CALL_FUNC
|
||||
#undef FUNC_RESULT
|
||||
#undef FUNC_FAIL
|
289
gl/lib/at-func2.c
Normal file
289
gl/lib/at-func2.c
Normal file
|
@ -0,0 +1,289 @@
|
|||
/* Define 2-FD at-style functions like linkat or renameat.
|
||||
Copyright (C) 2006, 2009-2024 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Jim Meyering and Eric Blake */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "openat-priv.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "filename.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
|
||||
#include "filenamecat.h"
|
||||
#include "openat.h"
|
||||
#include "same-inode.h"
|
||||
#include "save-cwd.h"
|
||||
|
||||
/* Call FUNC to operate on a pair of files, where FILE1 is relative to FD1,
|
||||
and FILE2 is relative to FD2. If possible, do it without changing the
|
||||
working directory. Otherwise, resort to using save_cwd/fchdir,
|
||||
FUNC, restore_cwd (up to two times). If either the save_cwd or the
|
||||
restore_cwd fails, then give a diagnostic and exit nonzero. */
|
||||
int
|
||||
at_func2 (int fd1, char const *file1,
|
||||
int fd2, char const *file2,
|
||||
int (*func) (char const *file1, char const *file2))
|
||||
{
|
||||
struct saved_cwd saved_cwd;
|
||||
int saved_errno;
|
||||
int err;
|
||||
char *file1_alt;
|
||||
char *file2_alt;
|
||||
struct stat st1;
|
||||
struct stat st2;
|
||||
|
||||
/* There are 16 possible scenarios, based on whether an fd is
|
||||
AT_FDCWD or real, and whether a file is absolute or relative:
|
||||
|
||||
fd1 file1 fd2 file2 action
|
||||
0 cwd abs cwd abs direct call
|
||||
1 cwd abs cwd rel direct call
|
||||
2 cwd abs fd abs direct call
|
||||
3 cwd abs fd rel chdir to fd2
|
||||
4 cwd rel cwd abs direct call
|
||||
5 cwd rel cwd rel direct call
|
||||
6 cwd rel fd abs direct call
|
||||
7 cwd rel fd rel convert file1 to abs, then case 3
|
||||
8 fd abs cwd abs direct call
|
||||
9 fd abs cwd rel direct call
|
||||
10 fd abs fd abs direct call
|
||||
11 fd abs fd rel chdir to fd2
|
||||
12 fd rel cwd abs chdir to fd1
|
||||
13 fd rel cwd rel convert file2 to abs, then case 12
|
||||
14 fd rel fd abs chdir to fd1
|
||||
15a fd1 rel fd1 rel chdir to fd1
|
||||
15b fd1 rel fd2 rel chdir to fd1, then case 7
|
||||
|
||||
Try some optimizations to reduce fd to AT_FDCWD, or to at least
|
||||
avoid converting an absolute name or doing a double chdir. */
|
||||
|
||||
if ((fd1 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file1))
|
||||
&& (fd2 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file2)))
|
||||
return func (file1, file2); /* Case 0-2, 4-6, 8-10. */
|
||||
|
||||
/* If /proc/self/fd works, we don't need any stat or chdir. */
|
||||
{
|
||||
char proc_buf1[OPENAT_BUFFER_SIZE];
|
||||
char *proc_file1 = ((fd1 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file1))
|
||||
? (char *) file1
|
||||
: openat_proc_name (proc_buf1, fd1, file1));
|
||||
if (proc_file1)
|
||||
{
|
||||
char proc_buf2[OPENAT_BUFFER_SIZE];
|
||||
char *proc_file2 = ((fd2 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file2))
|
||||
? (char *) file2
|
||||
: openat_proc_name (proc_buf2, fd2, file2));
|
||||
if (proc_file2)
|
||||
{
|
||||
int proc_result = func (proc_file1, proc_file2);
|
||||
int proc_errno = errno;
|
||||
if (proc_file1 != proc_buf1 && proc_file1 != file1)
|
||||
free (proc_file1);
|
||||
if (proc_file2 != proc_buf2 && proc_file2 != file2)
|
||||
free (proc_file2);
|
||||
/* If the syscall succeeds, or if it fails with an unexpected
|
||||
errno value, then return right away. Otherwise, fall through
|
||||
and resort to using save_cwd/restore_cwd. */
|
||||
if (0 <= proc_result)
|
||||
return proc_result;
|
||||
if (! EXPECTED_ERRNO (proc_errno))
|
||||
{
|
||||
errno = proc_errno;
|
||||
return proc_result;
|
||||
}
|
||||
}
|
||||
else if (proc_file1 != proc_buf1 && proc_file1 != file1)
|
||||
free (proc_file1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Cases 3, 7, 11-15 remain. Time to normalize directory fds, if
|
||||
possible. */
|
||||
if (IS_ABSOLUTE_FILE_NAME (file1))
|
||||
fd1 = AT_FDCWD; /* Case 11 reduced to 3. */
|
||||
else if (IS_ABSOLUTE_FILE_NAME (file2))
|
||||
fd2 = AT_FDCWD; /* Case 14 reduced to 12. */
|
||||
|
||||
/* Cases 3, 7, 12, 13, 15 remain. */
|
||||
|
||||
if (fd1 == AT_FDCWD) /* Cases 3, 7. */
|
||||
{
|
||||
if (stat (".", &st1) == -1 || fstat (fd2, &st2) == -1)
|
||||
return -1;
|
||||
if (!S_ISDIR (st2.st_mode))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
if (psame_inode (&st1, &st2)) /* Reduced to cases 1, 5. */
|
||||
return func (file1, file2);
|
||||
}
|
||||
else if (fd2 == AT_FDCWD) /* Cases 12, 13. */
|
||||
{
|
||||
if (stat (".", &st2) == -1 || fstat (fd1, &st1) == -1)
|
||||
return -1;
|
||||
if (!S_ISDIR (st1.st_mode))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
if (psame_inode (&st1, &st2)) /* Reduced to cases 4, 5. */
|
||||
return func (file1, file2);
|
||||
}
|
||||
else if (fd1 != fd2) /* Case 15b. */
|
||||
{
|
||||
if (fstat (fd1, &st1) == -1 || fstat (fd2, &st2) == -1)
|
||||
return -1;
|
||||
if (!S_ISDIR (st1.st_mode) || !S_ISDIR (st2.st_mode))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
if (psame_inode (&st1, &st2)) /* Reduced to case 15a. */
|
||||
{
|
||||
fd2 = fd1;
|
||||
if (stat (".", &st1) == 0 && psame_inode (&st1, &st2))
|
||||
return func (file1, file2); /* Further reduced to case 5. */
|
||||
}
|
||||
}
|
||||
else /* Case 15a. */
|
||||
{
|
||||
if (fstat (fd1, &st1) == -1)
|
||||
return -1;
|
||||
if (!S_ISDIR (st1.st_mode))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
if (stat (".", &st2) == 0 && psame_inode (&st1, &st2))
|
||||
return func (file1, file2); /* Reduced to case 5. */
|
||||
}
|
||||
|
||||
/* Catch invalid arguments before changing directories. */
|
||||
if (file1[0] == '\0' || file2[0] == '\0')
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Cases 3, 7, 12, 13, 15a, 15b remain. With all reductions in
|
||||
place, it is time to start changing directories. */
|
||||
|
||||
if (save_cwd (&saved_cwd) != 0)
|
||||
openat_save_fail (errno);
|
||||
|
||||
if (fd1 != AT_FDCWD && fd2 != AT_FDCWD && fd1 != fd2) /* Case 15b. */
|
||||
{
|
||||
if (fchdir (fd1) != 0)
|
||||
{
|
||||
saved_errno = errno;
|
||||
free_cwd (&saved_cwd);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
fd1 = AT_FDCWD; /* Reduced to case 7. */
|
||||
}
|
||||
|
||||
/* Cases 3, 7, 12, 13, 15a remain. Convert one relative name to
|
||||
absolute, if necessary. */
|
||||
|
||||
file1_alt = (char *) file1;
|
||||
file2_alt = (char *) file2;
|
||||
|
||||
if (fd1 == AT_FDCWD && !IS_ABSOLUTE_FILE_NAME (file1)) /* Case 7. */
|
||||
{
|
||||
/* It would be nicer to use:
|
||||
file1_alt = file_name_concat (xgetcwd (), file1, NULL);
|
||||
but libraries should not call xalloc_die. */
|
||||
char *cwd = getcwd (NULL, 0);
|
||||
if (!cwd)
|
||||
{
|
||||
saved_errno = errno;
|
||||
free_cwd (&saved_cwd);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
file1_alt = mfile_name_concat (cwd, file1, NULL);
|
||||
if (!file1_alt)
|
||||
{
|
||||
saved_errno = errno;
|
||||
free (cwd);
|
||||
free_cwd (&saved_cwd);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
free (cwd); /* Reduced to case 3. */
|
||||
}
|
||||
else if (fd2 == AT_FDCWD && !IS_ABSOLUTE_FILE_NAME (file2)) /* Case 13. */
|
||||
{
|
||||
char *cwd = getcwd (NULL, 0);
|
||||
if (!cwd)
|
||||
{
|
||||
saved_errno = errno;
|
||||
free_cwd (&saved_cwd);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
file2_alt = mfile_name_concat (cwd, file2, NULL);
|
||||
if (!file2_alt)
|
||||
{
|
||||
saved_errno = errno;
|
||||
free (cwd);
|
||||
free_cwd (&saved_cwd);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
free (cwd); /* Reduced to case 12. */
|
||||
}
|
||||
|
||||
/* Cases 3, 12, 15a remain. Change to the correct directory. */
|
||||
if (fchdir (fd1 == AT_FDCWD ? fd2 : fd1) != 0)
|
||||
{
|
||||
saved_errno = errno;
|
||||
free_cwd (&saved_cwd);
|
||||
if (file1 != file1_alt)
|
||||
free (file1_alt);
|
||||
else if (file2 != file2_alt)
|
||||
free (file2_alt);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Finally safe to perform the user's function, then clean up. */
|
||||
|
||||
err = func (file1_alt, file2_alt);
|
||||
saved_errno = (err < 0 ? errno : 0);
|
||||
|
||||
if (file1 != file1_alt)
|
||||
free (file1_alt);
|
||||
else if (file2 != file2_alt)
|
||||
free (file2_alt);
|
||||
|
||||
if (restore_cwd (&saved_cwd) != 0)
|
||||
openat_restore_fail (errno);
|
||||
|
||||
free_cwd (&saved_cwd);
|
||||
|
||||
if (saved_errno)
|
||||
errno = saved_errno;
|
||||
return err;
|
||||
}
|
||||
#undef CALL_FUNC
|
||||
#undef FUNC_RESULT
|
283
gl/lib/attribute.h
Normal file
283
gl/lib/attribute.h
Normal file
|
@ -0,0 +1,283 @@
|
|||
/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
|
||||
|
||||
Copyright 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_*
|
||||
macros used within Gnulib. */
|
||||
|
||||
/* These attributes can be placed in two ways:
|
||||
- At the start of a declaration (i.e. even before storage-class
|
||||
specifiers!); then they apply to all entities that are declared
|
||||
by the declaration.
|
||||
- Immediately after the name of an entity being declared by the
|
||||
declaration; then they apply to that entity only. */
|
||||
|
||||
#ifndef _GL_ATTRIBUTE_H
|
||||
#define _GL_ATTRIBUTE_H
|
||||
|
||||
|
||||
/* This file defines two types of attributes:
|
||||
* C23 standard attributes. These have macro names that do not begin with
|
||||
'ATTRIBUTE_'.
|
||||
* Selected GCC attributes; see:
|
||||
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
|
||||
https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
|
||||
https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html
|
||||
These names begin with 'ATTRIBUTE_' to avoid name clashes. */
|
||||
|
||||
|
||||
/* This file uses _GL_ATTRIBUTE_ALLOC_SIZE, _GL_ATTRIBUTE_ALWAYS_INLINE,
|
||||
_GL_ATTRIBUTE_ARTIFICIAL, _GL_ATTRIBUTE_COLD, _GL_ATTRIBUTE_CONST,
|
||||
_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR,
|
||||
_GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE,
|
||||
_GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_LEAF,
|
||||
_GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_MAY_ALIAS, _GL_ATTRIBUTE_MAYBE_UNUSED,
|
||||
_GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE, _GL_ATTRIBUTE_NONNULL,
|
||||
_GL_ATTRIBUTE_NONSTRING, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED,
|
||||
_GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_REPRODUCIBLE,
|
||||
_GL_ATTRIBUTE_RETURNS_NONNULL, _GL_ATTRIBUTE_SENTINEL,
|
||||
_GL_ATTRIBUTE_UNSEQUENCED. */
|
||||
#if !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
||||
|
||||
/* =============== Attributes for specific kinds of functions =============== */
|
||||
|
||||
/* Attributes for functions that should not be used. */
|
||||
|
||||
/* Warn if the entity is used. */
|
||||
/* Applies to:
|
||||
- function, variable,
|
||||
- struct, union, struct/union member,
|
||||
- enumeration, enumeration item,
|
||||
- typedef,
|
||||
in C++ also: namespace, class, template specialization. */
|
||||
#define DEPRECATED _GL_ATTRIBUTE_DEPRECATED
|
||||
|
||||
/* If a function call is not optimized way, warn with MSG. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg)
|
||||
|
||||
/* If a function call is not optimized way, report an error with MSG. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg)
|
||||
|
||||
|
||||
/* Attributes for memory-allocating functions. */
|
||||
|
||||
/* The function returns a pointer to freshly allocated memory. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC
|
||||
|
||||
/* ATTRIBUTE_ALLOC_SIZE ((N)) - The Nth argument of the function
|
||||
is the size of the returned memory block.
|
||||
ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments
|
||||
to determine the size of the returned memory block. */
|
||||
/* Applies to: functions, pointer to functions, function types. */
|
||||
#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
|
||||
|
||||
/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
|
||||
that can be freed by passing them as the Ith argument to the
|
||||
function F.
|
||||
ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
|
||||
can be freed via 'free'; it can be used only after declaring 'free'. */
|
||||
/* Applies to: functions. Cannot be used on inline functions. */
|
||||
#define ATTRIBUTE_DEALLOC(f, i) _GL_ATTRIBUTE_DEALLOC(f, i)
|
||||
#define ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC_FREE
|
||||
|
||||
/* Attributes for variadic functions. */
|
||||
|
||||
/* The variadic function expects a trailing NULL argument.
|
||||
ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
|
||||
ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos)
|
||||
|
||||
|
||||
/* ================== Attributes for compiler diagnostics ================== */
|
||||
|
||||
/* Attributes that help the compiler diagnose programmer mistakes.
|
||||
Some of them may also help for some compiler optimizations. */
|
||||
|
||||
/* ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) -
|
||||
The STRING-INDEXth function argument is a format string of style
|
||||
ARCHETYPE, which is one of:
|
||||
printf, gnu_printf
|
||||
scanf, gnu_scanf,
|
||||
strftime, gnu_strftime,
|
||||
strfmon,
|
||||
or the same thing prefixed and suffixed with '__'.
|
||||
If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
|
||||
are suitable for the format string. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec)
|
||||
|
||||
/* ATTRIBUTE_NONNULL ((N1, N2,...)) - Arguments N1, N2,... must not be NULL.
|
||||
ATTRIBUTE_NONNULL () - All pointer arguments must not be null. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args)
|
||||
|
||||
/* The function's return value is a non-NULL pointer. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL
|
||||
|
||||
/* Warn if the caller does not use the return value,
|
||||
unless the caller uses something like ignore_value. */
|
||||
/* Applies to: function, enumeration, class. */
|
||||
#define NODISCARD _GL_ATTRIBUTE_NODISCARD
|
||||
|
||||
|
||||
/* Attributes that disable false alarms when the compiler diagnoses
|
||||
programmer "mistakes". */
|
||||
|
||||
/* Do not warn if the entity is not used. */
|
||||
/* Applies to:
|
||||
- function, variable,
|
||||
- struct, union, struct/union member,
|
||||
- enumeration, enumeration item,
|
||||
- typedef,
|
||||
in C++ also: class. */
|
||||
#define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
|
||||
|
||||
/* The contents of a character array is not meant to be NUL-terminated. */
|
||||
/* Applies to: struct/union members and variables that are arrays of element
|
||||
type '[[un]signed] char'. */
|
||||
#define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING
|
||||
|
||||
/* Do not warn if control flow falls through to the immediately
|
||||
following 'case' or 'default' label. */
|
||||
/* Applies to: Empty statement (;), inside a 'switch' statement. */
|
||||
#define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH
|
||||
|
||||
|
||||
/* ================== Attributes for debugging information ================== */
|
||||
|
||||
/* Attributes regarding debugging information emitted by the compiler. */
|
||||
|
||||
/* Omit the function from stack traces when debugging. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
|
||||
|
||||
/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */
|
||||
/* Applies to: functions, variables. */
|
||||
#define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
|
||||
|
||||
|
||||
/* ========== Attributes that mainly direct compiler optimizations ========== */
|
||||
|
||||
/* The function does not throw exceptions. */
|
||||
/* Applies to: functions. */
|
||||
/* After a function's parameter list, this attribute must come first, before
|
||||
other attributes. */
|
||||
#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW
|
||||
|
||||
/* Do not inline the function. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE
|
||||
|
||||
/* Always inline the function, and report an error if the compiler
|
||||
cannot inline. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
|
||||
|
||||
/* It is OK for a compiler to move calls to the function and to omit
|
||||
calls to the function if another call has the same arguments or the
|
||||
result is not used.
|
||||
This attribute is safe for a function that neither depends on
|
||||
nor affects state, and always returns exactly once -
|
||||
e.g., does not raise an exception, call longjmp, or loop forever.
|
||||
(This attribute is stricter than ATTRIBUTE_PURE because the
|
||||
function cannot observe state. It is stricter than UNSEQUENCED
|
||||
because the function must return exactly once and cannot depend on
|
||||
state addressed by its arguments.) */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
|
||||
|
||||
/* It is OK for a compiler to move calls to the function and to omit duplicate
|
||||
calls to the function with the same arguments, so long as the state
|
||||
addressed by its arguments is the same.
|
||||
This attribute is safe for a function that is effectless, idempotent,
|
||||
stateless, and independent; see ISO C 23 § 6.7.12.7 for a definition of
|
||||
these terms.
|
||||
(This attribute is stricter than REPRODUCIBLE because the function
|
||||
must be stateless and independent. It is looser than ATTRIBUTE_CONST
|
||||
because the function need not return exactly once and can depend
|
||||
on state addressed by its arguments.)
|
||||
See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
|
||||
<https://stackoverflow.com/questions/76847905/>. */
|
||||
/* Applies to: functions, pointer to functions, function type. */
|
||||
#define UNSEQUENCED _GL_ATTRIBUTE_UNSEQUENCED
|
||||
|
||||
/* It is OK for a compiler to move calls to the function and to omit
|
||||
calls to the function if another call has the same arguments or the
|
||||
result is not used, and if observable state is the same.
|
||||
This attribute is safe for a function that does not affect observable state
|
||||
and always returns exactly once.
|
||||
(This attribute is looser than ATTRIBUTE_CONST because the function
|
||||
can depend on observable state. It is stricter than REPRODUCIBLE
|
||||
because the function must return exactly once and cannot affect
|
||||
state addressed by its arguments.) */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
|
||||
|
||||
/* It is OK for a compiler to move calls to the function and to omit duplicate
|
||||
calls to the function with the same arguments, so long as the state
|
||||
addressed by its arguments is the same and is updated in time for
|
||||
the rest of the program.
|
||||
This attribute is safe for a function that is effectless and idempotent; see
|
||||
ISO C 23 § 6.7.12.7 for a definition of these terms.
|
||||
(This attribute is looser than UNSEQUENCED because the function need
|
||||
not be stateless and idempotent. It is looser than ATTRIBUTE_PURE
|
||||
because the function need not return exactly once and can affect
|
||||
state addressed by its arguments.)
|
||||
See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
|
||||
<https://stackoverflow.com/questions/76847905/>. */
|
||||
/* Applies to: functions, pointer to functions, function type. */
|
||||
#define REPRODUCIBLE _GL_ATTRIBUTE_REPRODUCIBLE
|
||||
|
||||
/* The function is rarely executed. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
|
||||
|
||||
/* If called from some other compilation unit, the function executes
|
||||
code from that unit only by return or by exception handling,
|
||||
letting the compiler optimize that unit more aggressively. */
|
||||
/* Applies to: functions. */
|
||||
#define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF
|
||||
|
||||
/* For struct members: The member has the smallest possible alignment.
|
||||
For struct, union, class: All members have the smallest possible alignment,
|
||||
minimizing the memory required. */
|
||||
/* Applies to: struct members, struct, union,
|
||||
in C++ also: class. */
|
||||
#define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED
|
||||
|
||||
|
||||
/* ================ Attributes that make invalid code valid ================ */
|
||||
|
||||
/* Attributes that prevent fatal compiler optimizations for code that is not
|
||||
fully ISO C compliant. */
|
||||
|
||||
/* Pointers to the type may point to the same storage as pointers to
|
||||
other types, thus disabling strict aliasing optimization. */
|
||||
/* Applies to: types. */
|
||||
#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS
|
||||
|
||||
|
||||
#endif /* _GL_ATTRIBUTE_H */
|
70
gl/lib/basename-lgpl.c
Normal file
70
gl/lib/basename-lgpl.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* basename.c -- return the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "basename-lgpl.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "filename.h"
|
||||
|
||||
char *
|
||||
last_component (char const *name)
|
||||
{
|
||||
char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
|
||||
char const *p;
|
||||
bool last_was_slash = false;
|
||||
|
||||
while (ISSLASH (*base))
|
||||
base++;
|
||||
|
||||
for (p = base; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
last_was_slash = true;
|
||||
else if (last_was_slash)
|
||||
{
|
||||
base = p;
|
||||
last_was_slash = false;
|
||||
}
|
||||
}
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
size_t
|
||||
base_len (char const *name)
|
||||
{
|
||||
size_t len;
|
||||
size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
|
||||
|
||||
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
|
||||
continue;
|
||||
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1
|
||||
&& ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
|
||||
return 2;
|
||||
|
||||
if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
|
||||
&& len == prefix_len && ISSLASH (name[prefix_len]))
|
||||
return prefix_len + 1;
|
||||
|
||||
return len;
|
||||
}
|
83
gl/lib/basename-lgpl.h
Normal file
83
gl/lib/basename-lgpl.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/* Extract the last component (base name) of a file name.
|
||||
|
||||
Copyright (C) 1998, 2001, 2003-2006, 2009-2024 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _BASENAME_LGPL_H
|
||||
#define _BASENAME_LGPL_H
|
||||
|
||||
/* This file uses _GL_ATTRIBUTE_PURE. */
|
||||
#if !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||
# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Return the address of the last file name component of FILENAME.
|
||||
If FILENAME has some trailing slash(es), they are considered to be
|
||||
part of the last component.
|
||||
If FILENAME has no relative file name components because it is a file
|
||||
system root, return the empty string.
|
||||
Examples:
|
||||
FILENAME RESULT
|
||||
"foo.c" "foo.c"
|
||||
"foo/bar.c" "bar.c"
|
||||
"/foo/bar.c" "bar.c"
|
||||
"foo/bar/" "bar/"
|
||||
"foo/bar//" "bar//"
|
||||
"/" ""
|
||||
"//" ""
|
||||
"" ""
|
||||
The return value is a tail of the given FILENAME; do NOT free() it! */
|
||||
|
||||
/* This function was traditionally called 'basename', but we avoid this
|
||||
function name because
|
||||
* Various platforms have different functions in their libc.
|
||||
In particular, the glibc basename(), defined in <string.h>, does
|
||||
not consider trailing slashes to be part of the component:
|
||||
FILENAME RESULT
|
||||
"foo/bar/" ""
|
||||
"foo/bar//" ""
|
||||
* The 'basename' command eliminates trailing slashes and for a root
|
||||
produces a non-empty result:
|
||||
FILENAME RESULT
|
||||
"foo/bar/" "bar"
|
||||
"foo/bar//" "bar"
|
||||
"/" "/"
|
||||
"//" "/"
|
||||
*/
|
||||
extern char *last_component (char const *filename) _GL_ATTRIBUTE_PURE;
|
||||
|
||||
/* Return the length of the basename FILENAME.
|
||||
Typically FILENAME is the value returned by base_name or last_component.
|
||||
Act like strlen (FILENAME), except omit all trailing slashes. */
|
||||
extern size_t base_len (char const *filename) _GL_ATTRIBUTE_PURE;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _BASENAME_LGPL_H */
|
64
gl/lib/basename.c
Normal file
64
gl/lib/basename.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* basename.c -- return the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "xalloc.h"
|
||||
|
||||
char *
|
||||
base_name (char const *name)
|
||||
{
|
||||
char const *base = last_component (name);
|
||||
idx_t length;
|
||||
int dotslash_len;
|
||||
if (*base)
|
||||
{
|
||||
length = base_len (base);
|
||||
|
||||
/* Collapse a sequence of trailing slashes into one. */
|
||||
length += ISSLASH (base[length]);
|
||||
|
||||
/* On systems with drive letters, "a/b:c" must return "./b:c" rather
|
||||
than "b:c" to avoid confusion with a drive letter. On systems
|
||||
with pure POSIX semantics, this is not an issue. */
|
||||
dotslash_len = FILE_SYSTEM_PREFIX_LEN (base) != 0 ? 2 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There is no last component, so NAME is a file system root or
|
||||
the empty string. */
|
||||
base = name;
|
||||
length = base_len (base);
|
||||
dotslash_len = 0;
|
||||
}
|
||||
|
||||
char *p = ximalloc (dotslash_len + length + 1);
|
||||
if (dotslash_len)
|
||||
{
|
||||
p[0] = '.';
|
||||
p[1] = '/';
|
||||
}
|
||||
|
||||
/* Finally, copy the basename. */
|
||||
memcpy (p + dotslash_len, base, length);
|
||||
p[dotslash_len + length] = '\0';
|
||||
return p;
|
||||
}
|
21
gl/lib/bitrotate.c
Normal file
21
gl/lib/bitrotate.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* Rotate bits in integers.
|
||||
|
||||
Copyright (C) 2012-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define BITROTATE_INLINE _GL_EXTERN_INLINE
|
||||
#include "bitrotate.h"
|
150
gl/lib/bitrotate.h
Normal file
150
gl/lib/bitrotate.h
Normal file
|
@ -0,0 +1,150 @@
|
|||
/* bitrotate.h - Rotate bits in integers
|
||||
Copyright (C) 2008-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Simon Josefsson <simon@josefsson.org>, 2008. */
|
||||
|
||||
#ifndef _GL_BITROTATE_H
|
||||
#define _GL_BITROTATE_H
|
||||
|
||||
/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE. */
|
||||
#if !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
#ifndef BITROTATE_INLINE
|
||||
# define BITROTATE_INLINE _GL_INLINE
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef UINT64_MAX
|
||||
/* Given an unsigned 64-bit argument X, return the value corresponding
|
||||
to rotating the bits N steps to the left. N must be between 1 and
|
||||
63 inclusive. */
|
||||
BITROTATE_INLINE uint64_t
|
||||
rotl64 (uint64_t x, int n)
|
||||
{
|
||||
return ((x << n) | (x >> (64 - n))) & UINT64_MAX;
|
||||
}
|
||||
|
||||
/* Given an unsigned 64-bit argument X, return the value corresponding
|
||||
to rotating the bits N steps to the right. N must be between 1 to
|
||||
63 inclusive.*/
|
||||
BITROTATE_INLINE uint64_t
|
||||
rotr64 (uint64_t x, int n)
|
||||
{
|
||||
return ((x >> n) | (x << (64 - n))) & UINT64_MAX;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Given an unsigned 32-bit argument X, return the value corresponding
|
||||
to rotating the bits N steps to the left. N must be between 1 and
|
||||
31 inclusive. */
|
||||
BITROTATE_INLINE uint32_t
|
||||
rotl32 (uint32_t x, int n)
|
||||
{
|
||||
return ((x << n) | (x >> (32 - n))) & UINT32_MAX;
|
||||
}
|
||||
|
||||
/* Given an unsigned 32-bit argument X, return the value corresponding
|
||||
to rotating the bits N steps to the right. N must be between 1 to
|
||||
31 inclusive.*/
|
||||
BITROTATE_INLINE uint32_t
|
||||
rotr32 (uint32_t x, int n)
|
||||
{
|
||||
return ((x >> n) | (x << (32 - n))) & UINT32_MAX;
|
||||
}
|
||||
|
||||
/* Given a size_t argument X, return the value corresponding
|
||||
to rotating the bits N steps to the left. N must be between 1 and
|
||||
(CHAR_BIT * sizeof (size_t) - 1) inclusive. */
|
||||
BITROTATE_INLINE size_t
|
||||
rotl_sz (size_t x, int n)
|
||||
{
|
||||
return ((x << n) | (x >> ((CHAR_BIT * sizeof x) - n))) & SIZE_MAX;
|
||||
}
|
||||
|
||||
/* Given a size_t argument X, return the value corresponding
|
||||
to rotating the bits N steps to the right. N must be between 1 to
|
||||
(CHAR_BIT * sizeof (size_t) - 1) inclusive. */
|
||||
BITROTATE_INLINE size_t
|
||||
rotr_sz (size_t x, int n)
|
||||
{
|
||||
return ((x >> n) | (x << ((CHAR_BIT * sizeof x) - n))) & SIZE_MAX;
|
||||
}
|
||||
|
||||
/* Given an unsigned 16-bit argument X, return the value corresponding
|
||||
to rotating the bits N steps to the left. N must be between 1 to
|
||||
15 inclusive, but on most relevant targets N can also be 0 and 16
|
||||
because 'int' is at least 32 bits and the arguments must widen
|
||||
before shifting. */
|
||||
BITROTATE_INLINE uint16_t
|
||||
rotl16 (uint16_t x, int n)
|
||||
{
|
||||
return (((unsigned int) x << n) | ((unsigned int) x >> (16 - n)))
|
||||
& UINT16_MAX;
|
||||
}
|
||||
|
||||
/* Given an unsigned 16-bit argument X, return the value corresponding
|
||||
to rotating the bits N steps to the right. N must be in 1 to 15
|
||||
inclusive, but on most relevant targets N can also be 0 and 16
|
||||
because 'int' is at least 32 bits and the arguments must widen
|
||||
before shifting. */
|
||||
BITROTATE_INLINE uint16_t
|
||||
rotr16 (uint16_t x, int n)
|
||||
{
|
||||
return (((unsigned int) x >> n) | ((unsigned int) x << (16 - n)))
|
||||
& UINT16_MAX;
|
||||
}
|
||||
|
||||
/* Given an unsigned 8-bit argument X, return the value corresponding
|
||||
to rotating the bits N steps to the left. N must be between 1 to 7
|
||||
inclusive, but on most relevant targets N can also be 0 and 8
|
||||
because 'int' is at least 32 bits and the arguments must widen
|
||||
before shifting. */
|
||||
BITROTATE_INLINE uint8_t
|
||||
rotl8 (uint8_t x, int n)
|
||||
{
|
||||
return (((unsigned int) x << n) | ((unsigned int) x >> (8 - n))) & UINT8_MAX;
|
||||
}
|
||||
|
||||
/* Given an unsigned 8-bit argument X, return the value corresponding
|
||||
to rotating the bits N steps to the right. N must be in 1 to 7
|
||||
inclusive, but on most relevant targets N can also be 0 and 8
|
||||
because 'int' is at least 32 bits and the arguments must widen
|
||||
before shifting. */
|
||||
BITROTATE_INLINE uint8_t
|
||||
rotr8 (uint8_t x, int n)
|
||||
{
|
||||
return (((unsigned int) x >> n) | ((unsigned int) x << (8 - n))) & UINT8_MAX;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
_GL_INLINE_HEADER_END
|
||||
|
||||
#endif /* _GL_BITROTATE_H */
|
68
gl/lib/btoc32.c
Normal file
68
gl/lib/btoc32.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* Convert unibyte character to 32-bit wide character.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2020. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_BTOC32
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#if GL_CHAR32_T_IS_UNICODE
|
||||
# include "lc-charset-unicode.h"
|
||||
#endif
|
||||
|
||||
#if _GL_WCHAR_T_IS_UCS4
|
||||
_GL_EXTERN_INLINE
|
||||
#endif
|
||||
wint_t
|
||||
btoc32 (int c)
|
||||
{
|
||||
#if HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB && !_GL_WCHAR_T_IS_UCS4
|
||||
/* The char32_t encoding of a multibyte character may be different than its
|
||||
wchar_t encoding. */
|
||||
if (c != EOF)
|
||||
{
|
||||
mbstate_t state;
|
||||
char s[1];
|
||||
char32_t wc;
|
||||
|
||||
mbszero (&state);
|
||||
s[0] = (unsigned char) c;
|
||||
if (mbrtoc32 (&wc, s, 1, &state) <= 1)
|
||||
return wc;
|
||||
}
|
||||
return WEOF;
|
||||
#else
|
||||
/* In all known locale encodings, unibyte characters correspond only to
|
||||
characters in the BMP. */
|
||||
wint_t wc = btowc (c);
|
||||
# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
|
||||
if (wc != WEOF && wc != 0)
|
||||
{
|
||||
wc = locale_encoding_to_unicode (wc);
|
||||
if (wc == 0)
|
||||
return WEOF;
|
||||
}
|
||||
# endif
|
||||
return wc;
|
||||
#endif
|
||||
}
|
47
gl/lib/btowc.c
Normal file
47
gl/lib/btowc.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* Convert unibyte character to wide character.
|
||||
Copyright (C) 2008, 2010-2024 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <wchar.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
wint_t
|
||||
btowc (int c)
|
||||
{
|
||||
if (c != EOF)
|
||||
{
|
||||
char buf[1];
|
||||
wchar_t wc;
|
||||
|
||||
buf[0] = c;
|
||||
#if HAVE_MBRTOWC
|
||||
mbstate_t state;
|
||||
mbszero (&state);
|
||||
size_t ret = mbrtowc (&wc, buf, 1, &state);
|
||||
if (!(ret == (size_t)(-1) || ret == (size_t)(-2)))
|
||||
#else
|
||||
if (mbtowc (&wc, buf, 1) >= 0)
|
||||
#endif
|
||||
return wc;
|
||||
}
|
||||
return WEOF;
|
||||
}
|
337
gl/lib/c++defs.h
Normal file
337
gl/lib/c++defs.h
Normal file
|
@ -0,0 +1,337 @@
|
|||
/* C++ compatible function declaration macros.
|
||||
Copyright (C) 2010-2024 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published
|
||||
by the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GL_CXXDEFS_H
|
||||
#define _GL_CXXDEFS_H
|
||||
|
||||
/* Begin/end the GNULIB_NAMESPACE namespace. */
|
||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
|
||||
# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
|
||||
# define _GL_END_NAMESPACE }
|
||||
#else
|
||||
# define _GL_BEGIN_NAMESPACE
|
||||
# define _GL_END_NAMESPACE
|
||||
#endif
|
||||
|
||||
/* The three most frequent use cases of these macros are:
|
||||
|
||||
* For providing a substitute for a function that is missing on some
|
||||
platforms, but is declared and works fine on the platforms on which
|
||||
it exists:
|
||||
|
||||
#if @GNULIB_FOO@
|
||||
# if !@HAVE_FOO@
|
||||
_GL_FUNCDECL_SYS (foo, ...);
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (foo, ...);
|
||||
_GL_CXXALIASWARN (foo);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
...
|
||||
#endif
|
||||
|
||||
* For providing a replacement for a function that exists on all platforms,
|
||||
but is broken/insufficient and needs to be replaced on some platforms:
|
||||
|
||||
#if @GNULIB_FOO@
|
||||
# if @REPLACE_FOO@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef foo
|
||||
# define foo rpl_foo
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (foo, ...);
|
||||
_GL_CXXALIAS_RPL (foo, ...);
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (foo, ...);
|
||||
# endif
|
||||
_GL_CXXALIASWARN (foo);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
...
|
||||
#endif
|
||||
|
||||
* For providing a replacement for a function that exists on some platforms
|
||||
but is broken/insufficient and needs to be replaced on some of them and
|
||||
is additionally either missing or undeclared on some other platforms:
|
||||
|
||||
#if @GNULIB_FOO@
|
||||
# if @REPLACE_FOO@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef foo
|
||||
# define foo rpl_foo
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (foo, ...);
|
||||
_GL_CXXALIAS_RPL (foo, ...);
|
||||
# else
|
||||
# if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
|
||||
_GL_FUNCDECL_SYS (foo, ...);
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (foo, ...);
|
||||
# endif
|
||||
_GL_CXXALIASWARN (foo);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
...
|
||||
#endif
|
||||
*/
|
||||
|
||||
/* _GL_EXTERN_C declaration;
|
||||
performs the declaration with C linkage. */
|
||||
#if defined __cplusplus
|
||||
# define _GL_EXTERN_C extern "C"
|
||||
#else
|
||||
# define _GL_EXTERN_C extern
|
||||
#endif
|
||||
|
||||
/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
|
||||
declares a replacement function, named rpl_func, with the given prototype,
|
||||
consisting of return type, parameters, and attributes.
|
||||
Example:
|
||||
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
|
||||
Note: Attributes, such as _GL_ATTRIBUTE_DEPRECATED, are supported in front
|
||||
of a _GL_FUNCDECL_RPL invocation only in C mode, not in C++ mode. (That's
|
||||
because
|
||||
[[...]] extern "C" <declaration>;
|
||||
is invalid syntax in C++.)
|
||||
*/
|
||||
#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
|
||||
_GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
|
||||
#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
|
||||
_GL_EXTERN_C rettype rpl_func parameters_and_attributes
|
||||
|
||||
/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
|
||||
declares the system function, named func, with the given prototype,
|
||||
consisting of return type, parameters, and attributes.
|
||||
Example:
|
||||
_GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
*/
|
||||
#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
|
||||
_GL_EXTERN_C rettype func parameters_and_attributes
|
||||
|
||||
/* _GL_CXXALIAS_RPL (func, rettype, parameters);
|
||||
declares a C++ alias called GNULIB_NAMESPACE::func
|
||||
that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
|
||||
Example:
|
||||
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
|
||||
|
||||
Wrapping rpl_func in an object with an inline conversion operator
|
||||
avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
|
||||
actually used in the program. */
|
||||
#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
|
||||
_GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
|
||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
|
||||
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
|
||||
namespace GNULIB_NAMESPACE \
|
||||
{ \
|
||||
static const struct _gl_ ## func ## _wrapper \
|
||||
{ \
|
||||
typedef rettype (*type) parameters; \
|
||||
\
|
||||
inline operator type () const \
|
||||
{ \
|
||||
return ::rpl_func; \
|
||||
} \
|
||||
} func = {}; \
|
||||
} \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#else
|
||||
# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#endif
|
||||
|
||||
/* _GL_CXXALIAS_MDA (func, rettype, parameters);
|
||||
is to be used when func is a Microsoft deprecated alias, on native Windows.
|
||||
It declares a C++ alias called GNULIB_NAMESPACE::func
|
||||
that redirects to _func, if GNULIB_NAMESPACE is defined.
|
||||
Example:
|
||||
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
|
||||
*/
|
||||
#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
|
||||
_GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
|
||||
|
||||
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
|
||||
is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
|
||||
except that the C function rpl_func may have a slightly different
|
||||
declaration. A cast is used to silence the "invalid conversion" error
|
||||
that would otherwise occur. */
|
||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
|
||||
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
|
||||
namespace GNULIB_NAMESPACE \
|
||||
{ \
|
||||
static const struct _gl_ ## func ## _wrapper \
|
||||
{ \
|
||||
typedef rettype (*type) parameters; \
|
||||
\
|
||||
inline operator type () const \
|
||||
{ \
|
||||
return reinterpret_cast<type>(::rpl_func); \
|
||||
} \
|
||||
} func = {}; \
|
||||
} \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#else
|
||||
# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#endif
|
||||
|
||||
/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
|
||||
is like _GL_CXXALIAS_MDA (func, rettype, parameters);
|
||||
except that the C function func may have a slightly different declaration.
|
||||
A cast is used to silence the "invalid conversion" error that would
|
||||
otherwise occur. */
|
||||
#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
|
||||
_GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
|
||||
|
||||
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
|
||||
declares a C++ alias called GNULIB_NAMESPACE::func
|
||||
that redirects to the system provided function func, if GNULIB_NAMESPACE
|
||||
is defined.
|
||||
Example:
|
||||
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
|
||||
|
||||
Wrapping func in an object with an inline conversion operator
|
||||
avoids a reference to func unless GNULIB_NAMESPACE::func is
|
||||
actually used in the program. */
|
||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
|
||||
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
|
||||
namespace GNULIB_NAMESPACE \
|
||||
{ \
|
||||
static const struct _gl_ ## func ## _wrapper \
|
||||
{ \
|
||||
typedef rettype (*type) parameters; \
|
||||
\
|
||||
inline operator type () const \
|
||||
{ \
|
||||
return ::func; \
|
||||
} \
|
||||
} func = {}; \
|
||||
} \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#else
|
||||
# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#endif
|
||||
|
||||
/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
|
||||
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
|
||||
except that the C function func may have a slightly different declaration.
|
||||
A cast is used to silence the "invalid conversion" error that would
|
||||
otherwise occur. */
|
||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
|
||||
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
|
||||
namespace GNULIB_NAMESPACE \
|
||||
{ \
|
||||
static const struct _gl_ ## func ## _wrapper \
|
||||
{ \
|
||||
typedef rettype (*type) parameters; \
|
||||
\
|
||||
inline operator type () const \
|
||||
{ \
|
||||
return reinterpret_cast<type>(::func); \
|
||||
} \
|
||||
} func = {}; \
|
||||
} \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#else
|
||||
# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#endif
|
||||
|
||||
/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
|
||||
is like _GL_CXXALIAS_SYS (func, rettype, parameters);
|
||||
except that the C function is picked among a set of overloaded functions,
|
||||
namely the one with rettype2 and parameters2. Two consecutive casts
|
||||
are used to silence the "cannot find a match" and "invalid conversion"
|
||||
errors that would otherwise occur. */
|
||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
|
||||
/* The outer cast must be a reinterpret_cast.
|
||||
The inner cast: When the function is defined as a set of overloaded
|
||||
functions, it works as a static_cast<>, choosing the designated variant.
|
||||
When the function is defined as a single variant, it works as a
|
||||
reinterpret_cast<>. The parenthesized cast syntax works both ways. */
|
||||
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
|
||||
namespace GNULIB_NAMESPACE \
|
||||
{ \
|
||||
static const struct _gl_ ## func ## _wrapper \
|
||||
{ \
|
||||
typedef rettype (*type) parameters; \
|
||||
\
|
||||
inline operator type () const \
|
||||
{ \
|
||||
return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
|
||||
} \
|
||||
} func = {}; \
|
||||
} \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#else
|
||||
# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#endif
|
||||
|
||||
/* _GL_CXXALIASWARN (func);
|
||||
causes a warning to be emitted when ::func is used but not when
|
||||
GNULIB_NAMESPACE::func is used. func must be defined without overloaded
|
||||
variants. */
|
||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
|
||||
# define _GL_CXXALIASWARN(func) \
|
||||
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
|
||||
# define _GL_CXXALIASWARN_1(func,namespace) \
|
||||
_GL_CXXALIASWARN_2 (func, namespace)
|
||||
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
|
||||
we enable the warning only when not optimizing. */
|
||||
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
|
||||
# define _GL_CXXALIASWARN_2(func,namespace) \
|
||||
_GL_WARN_ON_USE (func, \
|
||||
"The symbol ::" #func " refers to the system function. " \
|
||||
"Use " #namespace "::" #func " instead.")
|
||||
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
|
||||
# define _GL_CXXALIASWARN_2(func,namespace) \
|
||||
extern __typeof__ (func) func
|
||||
# else
|
||||
# define _GL_CXXALIASWARN_2(func,namespace) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
# endif
|
||||
#else
|
||||
# define _GL_CXXALIASWARN(func) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#endif
|
||||
|
||||
/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
|
||||
causes a warning to be emitted when the given overloaded variant of ::func
|
||||
is used but not when GNULIB_NAMESPACE::func is used. */
|
||||
#if defined __cplusplus && defined GNULIB_NAMESPACE
|
||||
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
|
||||
_GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
|
||||
GNULIB_NAMESPACE)
|
||||
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
|
||||
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
|
||||
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
|
||||
we enable the warning only when not optimizing. */
|
||||
# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
|
||||
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
|
||||
_GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
|
||||
"The symbol ::" #func " refers to the system function. " \
|
||||
"Use " #namespace "::" #func " instead.")
|
||||
# else
|
||||
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
# endif
|
||||
#else
|
||||
# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
|
||||
_GL_EXTERN_C int _gl_cxxalias_dummy
|
||||
#endif
|
||||
|
||||
#endif /* _GL_CXXDEFS_H */
|
39
gl/lib/c32_apply_type_test.c
Normal file
39
gl/lib/c32_apply_type_test.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Apply a 32-bit wide character property test.
|
||||
Copyright (C) 2011-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32_APPLY_TYPE_TEST
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#if _GL_WCHAR_T_IS_UCS4
|
||||
_GL_EXTERN_INLINE
|
||||
#endif
|
||||
int
|
||||
c32_apply_type_test (wint_t wc, c32_type_test_t property)
|
||||
{
|
||||
#if _GL_WCHAR_T_IS_UCS4
|
||||
return iswctype (wc, property);
|
||||
#else
|
||||
return property (wc);
|
||||
#endif
|
||||
}
|
113
gl/lib/c32_get_type_test.c
Normal file
113
gl/lib/c32_get_type_test.c
Normal file
|
@ -0,0 +1,113 @@
|
|||
/* Get descriptor for a 32-bit wide character property.
|
||||
Copyright (C) 2011-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32_GET_TYPE_TEST
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#if _GL_WCHAR_T_IS_UCS4
|
||||
_GL_EXTERN_INLINE
|
||||
#endif
|
||||
c32_type_test_t
|
||||
c32_get_type_test (const char *name)
|
||||
{
|
||||
#if _GL_WCHAR_T_IS_UCS4
|
||||
return wctype (name);
|
||||
#else
|
||||
switch (name[0])
|
||||
{
|
||||
case 'a':
|
||||
switch (name[1])
|
||||
{
|
||||
case 'l':
|
||||
switch (name[2])
|
||||
{
|
||||
case 'n':
|
||||
if (strcmp (name + 3, "um") == 0)
|
||||
return c32isalnum;
|
||||
break;
|
||||
case 'p':
|
||||
if (strcmp (name + 3, "ha") == 0)
|
||||
return c32isalpha;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
if (strcmp (name + 1, "lank") == 0)
|
||||
return c32isblank;
|
||||
break;
|
||||
case 'c':
|
||||
if (strcmp (name + 1, "ntrl") == 0)
|
||||
return c32iscntrl;
|
||||
break;
|
||||
case 'd':
|
||||
if (strcmp (name + 1, "igit") == 0)
|
||||
return c32isdigit;
|
||||
break;
|
||||
case 'g':
|
||||
if (strcmp (name + 1, "raph") == 0)
|
||||
return c32isgraph;
|
||||
break;
|
||||
case 'l':
|
||||
if (strcmp (name + 1, "ower") == 0)
|
||||
return c32islower;
|
||||
break;
|
||||
case 'p':
|
||||
switch (name[1])
|
||||
{
|
||||
case 'r':
|
||||
if (strcmp (name + 2, "int") == 0)
|
||||
return c32isprint;
|
||||
break;
|
||||
case 'u':
|
||||
if (strcmp (name + 2, "nct") == 0)
|
||||
return c32ispunct;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if (strcmp (name + 1, "pace") == 0)
|
||||
return c32isspace;
|
||||
break;
|
||||
case 'u':
|
||||
if (strcmp (name + 1, "pper") == 0)
|
||||
return c32isupper;
|
||||
break;
|
||||
case 'x':
|
||||
if (strcmp (name + 1, "digit") == 0)
|
||||
return c32isxdigit;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (c32_type_test_t) 0;
|
||||
#endif
|
||||
}
|
105
gl/lib/c32is-impl.h
Normal file
105
gl/lib/c32is-impl.h
Normal file
|
@ -0,0 +1,105 @@
|
|||
/* Test whether a 32-bit wide character belongs to a specific character class.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2020. */
|
||||
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
# include <cygwin/version.h>
|
||||
#endif
|
||||
|
||||
#if GNULIB_defined_mbstate_t
|
||||
# include "localcharset.h"
|
||||
# include "streq.h"
|
||||
#endif
|
||||
|
||||
#if GL_CHAR32_T_IS_UNICODE
|
||||
# include "lc-charset-unicode.h"
|
||||
#endif
|
||||
|
||||
#include "unictype.h"
|
||||
|
||||
#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t
|
||||
_GL_EXTERN_INLINE
|
||||
#endif
|
||||
int
|
||||
FUNC (wint_t wc)
|
||||
{
|
||||
/* The char32_t encoding of a multibyte character is defined by the way
|
||||
mbrtoc32() is defined. */
|
||||
|
||||
#if GNULIB_defined_mbstate_t /* AIX, IRIX */
|
||||
/* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
|
||||
and directly for the UTF-8 locales. */
|
||||
if (wc != WEOF)
|
||||
{
|
||||
const char *encoding = locale_charset ();
|
||||
if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
return UCS_FUNC (wc);
|
||||
else
|
||||
return WCHAR_FUNC (wc);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
#elif HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB /* glibc, Android */
|
||||
/* mbrtoc32() is essentially defined by the system libc. */
|
||||
|
||||
# if _GL_WCHAR_T_IS_UCS4
|
||||
/* The char32_t encoding of a multibyte character is known to be the same as
|
||||
the wchar_t encoding. */
|
||||
return WCHAR_FUNC (wc);
|
||||
# else
|
||||
/* The char32_t encoding of a multibyte character is known to be UCS-4,
|
||||
different from the wchar_t encoding. */
|
||||
if (wc != WEOF)
|
||||
return UCS_FUNC (wc);
|
||||
else
|
||||
return 0;
|
||||
# endif
|
||||
|
||||
#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */
|
||||
/* The wchar_t encoding is UTF-16.
|
||||
The char32_t encoding is UCS-4. */
|
||||
|
||||
# if defined __CYGWIN__ && CYGWIN_VERSION_DLL_MAJOR >= 1007
|
||||
/* As an extension to POSIX, the iswalnum() function of Cygwin >= 1.7
|
||||
supports also wc arguments outside the Unicode BMP, that is, outside
|
||||
the 'wchar_t' range. See
|
||||
<https://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00019.html>
|
||||
= <https://cygwin.com/ml/cygwin/2011-02/msg00044.html>. */
|
||||
return WCHAR_FUNC (wc);
|
||||
# else
|
||||
if (wc == WEOF || wc == (wchar_t) wc)
|
||||
/* wc is in the range for the isw* functions. */
|
||||
return WCHAR_FUNC (wc);
|
||||
else
|
||||
return UCS_FUNC (wc);
|
||||
# endif
|
||||
|
||||
#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
|
||||
/* char32_t and wchar_t are equivalent. */
|
||||
static_assert (sizeof (char32_t) == sizeof (wchar_t));
|
||||
|
||||
# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
|
||||
return UCS_FUNC (wc);
|
||||
# else
|
||||
return WCHAR_FUNC (wc);
|
||||
# endif
|
||||
#endif
|
||||
}
|
26
gl/lib/c32isalnum.c
Normal file
26
gl/lib/c32isalnum.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being alphanumeric.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISALNUM
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isalnum
|
||||
#define WCHAR_FUNC iswalnum
|
||||
#define UCS_FUNC uc_is_alnum
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32isalpha.c
Normal file
26
gl/lib/c32isalpha.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being alphabetic.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISALPHA
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isalpha
|
||||
#define WCHAR_FUNC iswalpha
|
||||
#define UCS_FUNC uc_is_alpha
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32isblank.c
Normal file
26
gl/lib/c32isblank.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being blank.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISBLANK
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isblank
|
||||
#define WCHAR_FUNC iswblank
|
||||
#define UCS_FUNC uc_is_blank
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32iscntrl.c
Normal file
26
gl/lib/c32iscntrl.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being a control character.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISCNTRL
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32iscntrl
|
||||
#define WCHAR_FUNC iswcntrl
|
||||
#define UCS_FUNC uc_is_cntrl
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32isdigit.c
Normal file
26
gl/lib/c32isdigit.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being a digit.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISDIGIT
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isdigit
|
||||
#define WCHAR_FUNC iswdigit
|
||||
#define UCS_FUNC uc_is_digit
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32isgraph.c
Normal file
26
gl/lib/c32isgraph.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being graphic.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISGRAPH
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isgraph
|
||||
#define WCHAR_FUNC iswgraph
|
||||
#define UCS_FUNC uc_is_graph
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32islower.c
Normal file
26
gl/lib/c32islower.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being lowercase.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISLOWER
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32islower
|
||||
#define WCHAR_FUNC iswlower
|
||||
#define UCS_FUNC uc_is_lower
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32isprint.c
Normal file
26
gl/lib/c32isprint.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being printable.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISPRINT
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isprint
|
||||
#define WCHAR_FUNC iswprint
|
||||
#define UCS_FUNC uc_is_print
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32ispunct.c
Normal file
26
gl/lib/c32ispunct.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being a punctuation or symbol character.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISPUNCT
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32ispunct
|
||||
#define WCHAR_FUNC iswpunct
|
||||
#define UCS_FUNC uc_is_punct
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32isspace.c
Normal file
26
gl/lib/c32isspace.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being white-space.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISSPACE
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isspace
|
||||
#define WCHAR_FUNC iswspace
|
||||
#define UCS_FUNC uc_is_space
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32isupper.c
Normal file
26
gl/lib/c32isupper.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being uppercase.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISUPPER
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isupper
|
||||
#define WCHAR_FUNC iswupper
|
||||
#define UCS_FUNC uc_is_upper
|
||||
#include "c32is-impl.h"
|
26
gl/lib/c32isxdigit.c
Normal file
26
gl/lib/c32isxdigit.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test 32-bit wide character for being a hexadecimal digit.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32ISXDIGIT
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32isxdigit
|
||||
#define WCHAR_FUNC iswxdigit
|
||||
#define UCS_FUNC uc_is_xdigit
|
||||
#include "c32is-impl.h"
|
92
gl/lib/c32to-impl.h
Normal file
92
gl/lib/c32to-impl.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* Case mapping of a 32-bit wide character.
|
||||
Copyright (C) 2020-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
|
||||
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#if GNULIB_defined_mbstate_t
|
||||
# include "localcharset.h"
|
||||
# include "streq.h"
|
||||
#endif
|
||||
|
||||
#if GL_CHAR32_T_IS_UNICODE
|
||||
# include "lc-charset-unicode.h"
|
||||
#endif
|
||||
|
||||
#include "unicase.h"
|
||||
|
||||
#if _GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t
|
||||
_GL_EXTERN_INLINE
|
||||
#endif
|
||||
wint_t
|
||||
FUNC (wint_t wc)
|
||||
{
|
||||
/* The char32_t encoding of a multibyte character is defined by the way
|
||||
mbrtoc32() is defined. */
|
||||
|
||||
#if GNULIB_defined_mbstate_t /* AIX, IRIX */
|
||||
/* mbrtoc32() is defined on top of mbtowc() for the non-UTF-8 locales
|
||||
and directly for the UTF-8 locales. */
|
||||
if (wc != WEOF)
|
||||
{
|
||||
const char *encoding = locale_charset ();
|
||||
if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
return UCS_FUNC (wc);
|
||||
else
|
||||
return WCHAR_FUNC (wc);
|
||||
}
|
||||
else
|
||||
return wc;
|
||||
|
||||
#elif HAVE_WORKING_MBRTOC32 && HAVE_WORKING_C32RTOMB /* glibc, Android */
|
||||
/* mbrtoc32() is essentially defined by the system libc. */
|
||||
|
||||
# if _GL_WCHAR_T_IS_UCS4
|
||||
/* The char32_t encoding of a multibyte character is known to be the same as
|
||||
the wchar_t encoding. */
|
||||
return WCHAR_FUNC (wc);
|
||||
# else
|
||||
/* The char32_t encoding of a multibyte character is known to be UCS-4,
|
||||
different from the wchar_t encoding. */
|
||||
if (wc != WEOF)
|
||||
return UCS_FUNC (wc);
|
||||
else
|
||||
return wc;
|
||||
# endif
|
||||
|
||||
#elif _GL_SMALL_WCHAR_T /* Cygwin, mingw, MSVC */
|
||||
/* The wchar_t encoding is UTF-16.
|
||||
The char32_t encoding is UCS-4. */
|
||||
|
||||
if (wc == WEOF || wc == (wchar_t) wc)
|
||||
/* wc is in the range for the tow* functions. */
|
||||
return WCHAR_FUNC (wc);
|
||||
else
|
||||
return UCS_FUNC (wc);
|
||||
|
||||
#else /* macOS, FreeBSD, NetBSD, OpenBSD, HP-UX, Solaris, Minix, Android */
|
||||
/* char32_t and wchar_t are equivalent. */
|
||||
static_assert (sizeof (char32_t) == sizeof (wchar_t));
|
||||
|
||||
# if GL_CHAR32_T_IS_UNICODE && GL_CHAR32_T_VS_WCHAR_T_NEEDS_CONVERSION
|
||||
return UCS_FUNC (wc);
|
||||
# else
|
||||
return WCHAR_FUNC (wc);
|
||||
# endif
|
||||
#endif
|
||||
}
|
26
gl/lib/c32tolower.c
Normal file
26
gl/lib/c32tolower.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Map a 32-bit wide character to lowercase.
|
||||
Copyright (C) 2023-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define IN_C32TOLOWER
|
||||
/* Specification. */
|
||||
#include <uchar.h>
|
||||
|
||||
#define FUNC c32tolower
|
||||
#define WCHAR_FUNC towlower
|
||||
#define UCS_FUNC uc_tolower
|
||||
#include "c32to-impl.h"
|
55
gl/lib/calloc.c
Normal file
55
gl/lib/calloc.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* calloc() function that is glibc compatible.
|
||||
This wrapper function is required at least on Tru64 UNIX 5.1 and mingw.
|
||||
Copyright (C) 2004-2007, 2009-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Jim Meyering and Bruno Haible */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "xalloc-oversized.h"
|
||||
|
||||
/* Call the system's calloc below. */
|
||||
#undef calloc
|
||||
|
||||
/* Allocate and zero-fill an NxS-byte block of memory from the heap,
|
||||
even if N or S is zero. */
|
||||
|
||||
void *
|
||||
rpl_calloc (size_t n, size_t s)
|
||||
{
|
||||
if (n == 0 || s == 0)
|
||||
n = s = 1;
|
||||
|
||||
if (xalloc_oversized (n, s))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *result = calloc (n, s);
|
||||
|
||||
#if !HAVE_MALLOC_POSIX
|
||||
if (result == NULL)
|
||||
errno = ENOMEM;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
469
gl/lib/canonicalize-lgpl.c
Normal file
469
gl/lib/canonicalize-lgpl.c
Normal file
|
@ -0,0 +1,469 @@
|
|||
/* Return the canonical absolute name of a given file.
|
||||
Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _LIBC
|
||||
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
|
||||
optimizes away the name == NULL test below. */
|
||||
# define _GL_ARG_NONNULL(params)
|
||||
|
||||
# include <libc-config.h>
|
||||
#endif
|
||||
|
||||
/* Specification. */
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <eloop-threshold.h>
|
||||
#include <filename.h>
|
||||
#include <idx.h>
|
||||
#include <intprops.h>
|
||||
#include <scratch_buffer.h>
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <shlib-compat.h>
|
||||
# define GCC_LINT 1
|
||||
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||
#else
|
||||
# define __canonicalize_file_name canonicalize_file_name
|
||||
# define __realpath realpath
|
||||
# define __strdup strdup
|
||||
# include "pathmax.h"
|
||||
# define __faccessat faccessat
|
||||
# if defined _WIN32 && !defined __CYGWIN__
|
||||
# define __getcwd _getcwd
|
||||
# elif HAVE_GETCWD
|
||||
# if IN_RELOCWRAPPER
|
||||
/* When building the relocatable program wrapper, use the system's getcwd
|
||||
function, not the gnulib override, otherwise we would get a link error.
|
||||
*/
|
||||
# undef getcwd
|
||||
# endif
|
||||
# if defined VMS && !defined getcwd
|
||||
/* We want the directory in Unix syntax, not in VMS syntax.
|
||||
The gnulib override of 'getcwd' takes 2 arguments; the original VMS
|
||||
'getcwd' takes 3 arguments. */
|
||||
# define __getcwd(buf, max) getcwd (buf, max, 0)
|
||||
# else
|
||||
# define __getcwd getcwd
|
||||
# endif
|
||||
# else
|
||||
# define __getcwd(buf, max) getwd (buf)
|
||||
# endif
|
||||
# define __mempcpy mempcpy
|
||||
# define __pathconf pathconf
|
||||
# define __rawmemchr rawmemchr
|
||||
# define __readlink readlink
|
||||
# if IN_RELOCWRAPPER
|
||||
/* When building the relocatable program wrapper, use the system's memmove
|
||||
function, not the gnulib override, otherwise we would get a link error.
|
||||
*/
|
||||
# undef memmove
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Suppress bogus GCC -Wmaybe-uninitialized warnings. */
|
||||
#if defined GCC_LINT || defined lint
|
||||
# define IF_LINT(Code) Code
|
||||
#else
|
||||
# define IF_LINT(Code) /* empty */
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||
# define DOUBLE_SLASH_IS_DISTINCT_ROOT false
|
||||
#endif
|
||||
|
||||
#if defined _LIBC || !FUNC_REALPATH_WORKS
|
||||
|
||||
/* Return true if FILE's existence can be shown, false (setting errno)
|
||||
otherwise. Follow symbolic links. */
|
||||
static bool
|
||||
file_accessible (char const *file)
|
||||
{
|
||||
# if defined _LIBC || HAVE_FACCESSAT
|
||||
return __faccessat (AT_FDCWD, file, F_OK, AT_EACCESS) == 0;
|
||||
# else
|
||||
struct stat st;
|
||||
return stat (file, &st) == 0 || errno == EOVERFLOW;
|
||||
# endif
|
||||
}
|
||||
|
||||
/* True if concatenating END as a suffix to a file name means that the
|
||||
code needs to check that the file name is that of a searchable
|
||||
directory, since the canonicalize_filename_mode_stk code won't
|
||||
check this later anyway when it checks an ordinary file name
|
||||
component within END. END must either be empty, or start with a
|
||||
slash. */
|
||||
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
suffix_requires_dir_check (char const *end)
|
||||
{
|
||||
/* If END does not start with a slash, the suffix is OK. */
|
||||
while (ISSLASH (*end))
|
||||
{
|
||||
/* Two or more slashes act like a single slash. */
|
||||
do
|
||||
end++;
|
||||
while (ISSLASH (*end));
|
||||
|
||||
switch (*end++)
|
||||
{
|
||||
default: return false; /* An ordinary file name component is OK. */
|
||||
case '\0': return true; /* Trailing "/" is trouble. */
|
||||
case '.': break; /* Possibly "." or "..". */
|
||||
}
|
||||
/* Trailing "/.", or "/.." even if not trailing, is trouble. */
|
||||
if (!*end || (*end == '.' && (!end[1] || ISSLASH (end[1]))))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Append this to a file name to test whether it is a searchable directory.
|
||||
On POSIX platforms "/" suffices, but "/./" is sometimes needed on
|
||||
macOS 10.13 <https://bugs.gnu.org/30350>, and should also work on
|
||||
platforms like AIX 7.2 that need at least "/.". */
|
||||
|
||||
# if defined _LIBC || defined LSTAT_FOLLOWS_SLASHED_SYMLINK
|
||||
static char const dir_suffix[] = "/";
|
||||
# else
|
||||
static char const dir_suffix[] = "/./";
|
||||
# endif
|
||||
|
||||
/* Return true if DIR is a searchable dir, false (setting errno) otherwise.
|
||||
DIREND points to the NUL byte at the end of the DIR string.
|
||||
Store garbage into DIREND[0 .. strlen (dir_suffix)]. */
|
||||
|
||||
static bool
|
||||
dir_check (char *dir, char *dirend)
|
||||
{
|
||||
strcpy (dirend, dir_suffix);
|
||||
return file_accessible (dir);
|
||||
}
|
||||
|
||||
static idx_t
|
||||
get_path_max (void)
|
||||
{
|
||||
# ifdef PATH_MAX
|
||||
long int path_max = PATH_MAX;
|
||||
# else
|
||||
/* The caller invoked realpath with a null RESOLVED, even though
|
||||
PATH_MAX is not defined as a constant. The glibc manual says
|
||||
programs should not do this, and POSIX says the behavior is undefined.
|
||||
Historically, glibc here used the result of pathconf, or 1024 if that
|
||||
failed; stay consistent with this (dubious) historical practice. */
|
||||
int err = errno;
|
||||
long int path_max = __pathconf ("/", _PC_PATH_MAX);
|
||||
__set_errno (err);
|
||||
# endif
|
||||
return path_max < 0 ? 1024 : path_max <= IDX_MAX ? path_max : IDX_MAX;
|
||||
}
|
||||
|
||||
/* Scratch buffers used by realpath_stk and managed by __realpath. */
|
||||
struct realpath_bufs
|
||||
{
|
||||
struct scratch_buffer rname;
|
||||
struct scratch_buffer extra;
|
||||
struct scratch_buffer link;
|
||||
};
|
||||
|
||||
static char *
|
||||
realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
|
||||
{
|
||||
char *dest;
|
||||
char const *start;
|
||||
char const *end;
|
||||
int num_links = 0;
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
/* As per Single Unix Specification V2 we must return an error if
|
||||
either parameter is a null pointer. We extend this to allow
|
||||
the RESOLVED parameter to be NULL in case the we are expected to
|
||||
allocate the room for the return value. */
|
||||
__set_errno (EINVAL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (name[0] == '\0')
|
||||
{
|
||||
/* As per Single Unix Specification V2 we must return an error if
|
||||
the name argument points to an empty string. */
|
||||
__set_errno (ENOENT);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *rname = bufs->rname.data;
|
||||
bool end_in_extra_buffer = false;
|
||||
bool failed = true;
|
||||
|
||||
/* This is always zero for Posix hosts, but can be 2 for MS-Windows
|
||||
and MS-DOS X:/foo/bar file names. */
|
||||
idx_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
|
||||
|
||||
if (!IS_ABSOLUTE_FILE_NAME (name))
|
||||
{
|
||||
while (!__getcwd (bufs->rname.data, bufs->rname.length))
|
||||
{
|
||||
if (errno != ERANGE)
|
||||
{
|
||||
dest = rname;
|
||||
goto error;
|
||||
}
|
||||
if (!scratch_buffer_grow (&bufs->rname))
|
||||
return NULL;
|
||||
rname = bufs->rname.data;
|
||||
}
|
||||
dest = __rawmemchr (rname, '\0');
|
||||
start = name;
|
||||
prefix_len = FILE_SYSTEM_PREFIX_LEN (rname);
|
||||
}
|
||||
else
|
||||
{
|
||||
dest = __mempcpy (rname, name, prefix_len);
|
||||
*dest++ = '/';
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
|
||||
{
|
||||
if (prefix_len == 0 /* implies ISSLASH (name[0]) */
|
||||
&& ISSLASH (name[1]) && !ISSLASH (name[2]))
|
||||
*dest++ = '/';
|
||||
*dest = '\0';
|
||||
}
|
||||
start = name + prefix_len;
|
||||
}
|
||||
|
||||
for ( ; *start; start = end)
|
||||
{
|
||||
/* Skip sequence of multiple file name separators. */
|
||||
while (ISSLASH (*start))
|
||||
++start;
|
||||
|
||||
/* Find end of component. */
|
||||
for (end = start; *end && !ISSLASH (*end); ++end)
|
||||
/* Nothing. */;
|
||||
|
||||
/* Length of this file name component; it can be zero if a file
|
||||
name ends in '/'. */
|
||||
idx_t startlen = end - start;
|
||||
|
||||
if (startlen == 0)
|
||||
break;
|
||||
else if (startlen == 1 && start[0] == '.')
|
||||
/* nothing */;
|
||||
else if (startlen == 2 && start[0] == '.' && start[1] == '.')
|
||||
{
|
||||
/* Back up to previous component, ignore if at root already. */
|
||||
if (dest > rname + prefix_len + 1)
|
||||
for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest)
|
||||
continue;
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||
&& dest == rname + 1 && !prefix_len
|
||||
&& ISSLASH (*dest) && !ISSLASH (dest[1]))
|
||||
dest++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ISSLASH (dest[-1]))
|
||||
*dest++ = '/';
|
||||
|
||||
while (rname + bufs->rname.length - dest
|
||||
< startlen + sizeof dir_suffix)
|
||||
{
|
||||
idx_t dest_offset = dest - rname;
|
||||
if (!scratch_buffer_grow_preserve (&bufs->rname))
|
||||
return NULL;
|
||||
rname = bufs->rname.data;
|
||||
dest = rname + dest_offset;
|
||||
}
|
||||
|
||||
dest = __mempcpy (dest, start, startlen);
|
||||
*dest = '\0';
|
||||
|
||||
char *buf;
|
||||
ssize_t n;
|
||||
while (true)
|
||||
{
|
||||
buf = bufs->link.data;
|
||||
idx_t bufsize = bufs->link.length;
|
||||
n = __readlink (rname, buf, bufsize - 1);
|
||||
if (n < bufsize - 1)
|
||||
break;
|
||||
if (!scratch_buffer_grow (&bufs->link))
|
||||
return NULL;
|
||||
}
|
||||
if (0 <= n)
|
||||
{
|
||||
if (++num_links > __eloop_threshold ())
|
||||
{
|
||||
__set_errno (ELOOP);
|
||||
goto error;
|
||||
}
|
||||
|
||||
buf[n] = '\0';
|
||||
|
||||
char *extra_buf = bufs->extra.data;
|
||||
idx_t end_idx IF_LINT (= 0);
|
||||
if (end_in_extra_buffer)
|
||||
end_idx = end - extra_buf;
|
||||
size_t len = strlen (end);
|
||||
if (INT_ADD_OVERFLOW (len, n))
|
||||
{
|
||||
__set_errno (ENOMEM);
|
||||
return NULL;
|
||||
}
|
||||
while (bufs->extra.length <= len + n)
|
||||
{
|
||||
if (!scratch_buffer_grow_preserve (&bufs->extra))
|
||||
return NULL;
|
||||
extra_buf = bufs->extra.data;
|
||||
}
|
||||
if (end_in_extra_buffer)
|
||||
end = extra_buf + end_idx;
|
||||
|
||||
/* Careful here, end may be a pointer into extra_buf... */
|
||||
memmove (&extra_buf[n], end, len + 1);
|
||||
name = end = memcpy (extra_buf, buf, n);
|
||||
end_in_extra_buffer = true;
|
||||
|
||||
if (IS_ABSOLUTE_FILE_NAME (buf))
|
||||
{
|
||||
idx_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf);
|
||||
|
||||
dest = __mempcpy (rname, buf, pfxlen);
|
||||
*dest++ = '/'; /* It's an absolute symlink */
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
|
||||
{
|
||||
if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen)
|
||||
*dest++ = '/';
|
||||
*dest = '\0';
|
||||
}
|
||||
/* Install the new prefix to be in effect hereafter. */
|
||||
prefix_len = pfxlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Back up to previous component, ignore if at root
|
||||
already: */
|
||||
if (dest > rname + prefix_len + 1)
|
||||
for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest)
|
||||
continue;
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1
|
||||
&& ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len)
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
else if (! (suffix_requires_dir_check (end)
|
||||
? dir_check (rname, dest)
|
||||
: errno == EINVAL))
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1]))
|
||||
--dest;
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 && !prefix_len
|
||||
&& ISSLASH (*dest) && !ISSLASH (dest[1]))
|
||||
dest++;
|
||||
failed = false;
|
||||
|
||||
error:
|
||||
*dest++ = '\0';
|
||||
if (resolved != NULL)
|
||||
{
|
||||
/* Copy the full result on success or partial result if failure was due
|
||||
to the path not existing or not being accessible. */
|
||||
if ((!failed || errno == ENOENT || errno == EACCES)
|
||||
&& dest - rname <= get_path_max ())
|
||||
{
|
||||
strcpy (resolved, rname);
|
||||
if (failed)
|
||||
return NULL;
|
||||
else
|
||||
return resolved;
|
||||
}
|
||||
if (!failed)
|
||||
__set_errno (ENAMETOOLONG);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (failed)
|
||||
return NULL;
|
||||
else
|
||||
return __strdup (bufs->rname.data);
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the canonical absolute name of file NAME. A canonical name
|
||||
does not contain any ".", ".." components nor any repeated file name
|
||||
separators ('/') or symlinks. All file name components must exist. If
|
||||
RESOLVED is null, the result is malloc'd; otherwise, if the
|
||||
canonical name is PATH_MAX chars or more, returns null with 'errno'
|
||||
set to ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
|
||||
returns the name in RESOLVED. If the name cannot be resolved and
|
||||
RESOLVED is non-NULL, it contains the name of the first component
|
||||
that cannot be resolved. If the name can be resolved, RESOLVED
|
||||
holds the same value as the value returned. */
|
||||
|
||||
char *
|
||||
__realpath (const char *name, char *resolved)
|
||||
{
|
||||
struct realpath_bufs bufs;
|
||||
scratch_buffer_init (&bufs.rname);
|
||||
scratch_buffer_init (&bufs.extra);
|
||||
scratch_buffer_init (&bufs.link);
|
||||
char *result = realpath_stk (name, resolved, &bufs);
|
||||
scratch_buffer_free (&bufs.link);
|
||||
scratch_buffer_free (&bufs.extra);
|
||||
scratch_buffer_free (&bufs.rname);
|
||||
return result;
|
||||
}
|
||||
libc_hidden_def (__realpath)
|
||||
versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);
|
||||
|
||||
#endif /* defined _LIBC || !FUNC_REALPATH_WORKS */
|
||||
|
||||
|
||||
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3)
|
||||
char *
|
||||
attribute_compat_text_section
|
||||
__old_realpath (const char *name, char *resolved)
|
||||
{
|
||||
if (resolved == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return __realpath (name, resolved);
|
||||
}
|
||||
compat_symbol (libc, __old_realpath, realpath, GLIBC_2_0);
|
||||
#endif
|
||||
|
||||
|
||||
char *
|
||||
__canonicalize_file_name (const char *name)
|
||||
{
|
||||
return __realpath (name, NULL);
|
||||
}
|
||||
weak_alias (__canonicalize_file_name, canonicalize_file_name)
|
469
gl/lib/canonicalize.c
Normal file
469
gl/lib/canonicalize.c
Normal file
|
@ -0,0 +1,469 @@
|
|||
/* Return the canonical absolute name of a given file.
|
||||
Copyright (C) 1996-2024 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "canonicalize.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <filename.h>
|
||||
#include <idx.h>
|
||||
#include <intprops.h>
|
||||
#include <scratch_buffer.h>
|
||||
|
||||
#include "attribute.h"
|
||||
#include "file-set.h"
|
||||
#include "hash-triple.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||
# define DOUBLE_SLASH_IS_DISTINCT_ROOT false
|
||||
#endif
|
||||
|
||||
#if ISSLASH ('\\')
|
||||
# define SLASHES "/\\"
|
||||
#else
|
||||
# define SLASHES "/"
|
||||
#endif
|
||||
|
||||
/* Avoid false GCC warning "'end_idx' may be used uninitialized". */
|
||||
#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4
|
||||
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
#endif
|
||||
|
||||
/* Return true if FILE's existence can be shown, false (setting errno)
|
||||
otherwise. Follow symbolic links. */
|
||||
static bool
|
||||
file_accessible (char const *file)
|
||||
{
|
||||
# if HAVE_FACCESSAT
|
||||
return faccessat (AT_FDCWD, file, F_OK, AT_EACCESS) == 0;
|
||||
# else
|
||||
struct stat st;
|
||||
return stat (file, &st) == 0 || errno == EOVERFLOW;
|
||||
# endif
|
||||
}
|
||||
|
||||
/* True if concatenating END as a suffix to a file name means that the
|
||||
code needs to check that the file name is that of a searchable
|
||||
directory, since the canonicalize_filename_mode_stk code won't
|
||||
check this later anyway when it checks an ordinary file name
|
||||
component within END. END must either be empty, or start with a
|
||||
slash. */
|
||||
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
suffix_requires_dir_check (char const *end)
|
||||
{
|
||||
/* If END does not start with a slash, the suffix is OK. */
|
||||
while (ISSLASH (*end))
|
||||
{
|
||||
/* Two or more slashes act like a single slash. */
|
||||
do
|
||||
end++;
|
||||
while (ISSLASH (*end));
|
||||
|
||||
switch (*end++)
|
||||
{
|
||||
default: return false; /* An ordinary file name component is OK. */
|
||||
case '\0': return true; /* Trailing "/" is trouble. */
|
||||
case '.': break; /* Possibly "." or "..". */
|
||||
}
|
||||
/* Trailing "/.", or "/.." even if not trailing, is trouble. */
|
||||
if (!*end || (*end == '.' && (!end[1] || ISSLASH (end[1]))))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Append this to a file name to test whether it is a searchable directory.
|
||||
On POSIX platforms "/" suffices, but "/./" is sometimes needed on
|
||||
macOS 10.13 <https://bugs.gnu.org/30350>, and should also work on
|
||||
platforms like AIX 7.2 that need at least "/.". */
|
||||
|
||||
#ifdef LSTAT_FOLLOWS_SLASHED_SYMLINK
|
||||
static char const dir_suffix[] = "/";
|
||||
#else
|
||||
static char const dir_suffix[] = "/./";
|
||||
#endif
|
||||
|
||||
/* Return true if DIR is a searchable dir, false (setting errno) otherwise.
|
||||
DIREND points to the NUL byte at the end of the DIR string.
|
||||
Store garbage into DIREND[0 .. strlen (dir_suffix)]. */
|
||||
|
||||
static bool
|
||||
dir_check (char *dir, char *dirend)
|
||||
{
|
||||
strcpy (dirend, dir_suffix);
|
||||
return file_accessible (dir);
|
||||
}
|
||||
|
||||
#if !((HAVE_CANONICALIZE_FILE_NAME && FUNC_REALPATH_WORKS) \
|
||||
|| GNULIB_CANONICALIZE_LGPL)
|
||||
/* Return the canonical absolute name of file NAME. A canonical name
|
||||
does not contain any ".", ".." components nor any repeated file name
|
||||
separators ('/') or symlinks. All components must exist.
|
||||
The result is malloc'd. */
|
||||
|
||||
char *
|
||||
canonicalize_file_name (const char *name)
|
||||
{
|
||||
return canonicalize_filename_mode (name, CAN_EXISTING);
|
||||
}
|
||||
#endif /* !HAVE_CANONICALIZE_FILE_NAME */
|
||||
|
||||
static bool
|
||||
multiple_bits_set (canonicalize_mode_t i)
|
||||
{
|
||||
return (i & (i - 1)) != 0;
|
||||
}
|
||||
|
||||
/* Return true if we've already seen the triple, <FILENAME, dev, ino>.
|
||||
If *HT is not initialized, initialize it. */
|
||||
static bool
|
||||
seen_triple (Hash_table **ht, char const *filename, struct stat const *st)
|
||||
{
|
||||
if (*ht == NULL)
|
||||
{
|
||||
idx_t initial_capacity = 7;
|
||||
*ht = hash_initialize (initial_capacity,
|
||||
NULL,
|
||||
triple_hash,
|
||||
triple_compare_ino_str,
|
||||
triple_free);
|
||||
if (*ht == NULL)
|
||||
xalloc_die ();
|
||||
}
|
||||
|
||||
if (seen_file (*ht, filename, st))
|
||||
return true;
|
||||
|
||||
record_file (*ht, filename, st);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Scratch buffers used by canonicalize_filename_mode_stk and managed
|
||||
by __realpath. */
|
||||
struct realpath_bufs
|
||||
{
|
||||
struct scratch_buffer rname;
|
||||
struct scratch_buffer extra;
|
||||
struct scratch_buffer link;
|
||||
};
|
||||
|
||||
static char *
|
||||
canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
|
||||
struct realpath_bufs *bufs)
|
||||
{
|
||||
char *dest;
|
||||
char const *start;
|
||||
char const *end;
|
||||
Hash_table *ht = NULL;
|
||||
bool logical = (can_mode & CAN_NOLINKS) != 0;
|
||||
int num_links = 0;
|
||||
|
||||
canonicalize_mode_t can_exist = can_mode & CAN_MODE_MASK;
|
||||
if (multiple_bits_set (can_exist))
|
||||
{
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (name[0] == '\0')
|
||||
{
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *rname = bufs->rname.data;
|
||||
bool end_in_extra_buffer = false;
|
||||
bool failed = true;
|
||||
|
||||
/* This is always zero for Posix hosts, but can be 2 for MS-Windows
|
||||
and MS-DOS X:/foo/bar file names. */
|
||||
idx_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
|
||||
|
||||
if (!IS_ABSOLUTE_FILE_NAME (name))
|
||||
{
|
||||
while (!getcwd (bufs->rname.data, bufs->rname.length))
|
||||
{
|
||||
switch (errno)
|
||||
{
|
||||
case ERANGE:
|
||||
if (scratch_buffer_grow (&bufs->rname))
|
||||
break;
|
||||
FALLTHROUGH;
|
||||
case ENOMEM:
|
||||
xalloc_die ();
|
||||
|
||||
default:
|
||||
dest = rname;
|
||||
goto error;
|
||||
}
|
||||
rname = bufs->rname.data;
|
||||
}
|
||||
dest = rawmemchr (rname, '\0');
|
||||
start = name;
|
||||
prefix_len = FILE_SYSTEM_PREFIX_LEN (rname);
|
||||
}
|
||||
else
|
||||
{
|
||||
dest = mempcpy (rname, name, prefix_len);
|
||||
*dest++ = '/';
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
|
||||
{
|
||||
if (prefix_len == 0 /* implies ISSLASH (name[0]) */
|
||||
&& ISSLASH (name[1]) && !ISSLASH (name[2]))
|
||||
{
|
||||
*dest++ = '/';
|
||||
#if defined _WIN32 && !defined __CYGWIN__
|
||||
/* For UNC file names '\\server\path\to\file', extend the prefix
|
||||
to include the server: '\\server\'. */
|
||||
{
|
||||
idx_t i;
|
||||
for (i = 2; name[i] != '\0' && !ISSLASH (name[i]); )
|
||||
i++;
|
||||
if (name[i] != '\0' /* implies ISSLASH (name[i]) */
|
||||
&& i + 1 < bufs->rname.length)
|
||||
{
|
||||
prefix_len = i;
|
||||
memcpy (dest, name + 2, i - 2 + 1);
|
||||
dest += i - 2 + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Either name = '\\server'; this is an invalid file name.
|
||||
Or name = '\\server\...' and server is more than
|
||||
bufs->rname.length - 4 bytes long. In either
|
||||
case, stop the UNC processing. */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
*dest = '\0';
|
||||
}
|
||||
start = name + prefix_len;
|
||||
}
|
||||
|
||||
for ( ; *start; start = end)
|
||||
{
|
||||
/* Skip sequence of multiple file name separators. */
|
||||
while (ISSLASH (*start))
|
||||
++start;
|
||||
|
||||
/* Find end of component. */
|
||||
for (end = start; *end && !ISSLASH (*end); ++end)
|
||||
/* Nothing. */;
|
||||
|
||||
/* Length of this file name component; it can be zero if a file
|
||||
name ends in '/'. */
|
||||
idx_t startlen = end - start;
|
||||
|
||||
if (startlen == 0)
|
||||
break;
|
||||
else if (startlen == 1 && start[0] == '.')
|
||||
/* nothing */;
|
||||
else if (startlen == 2 && start[0] == '.' && start[1] == '.')
|
||||
{
|
||||
/* Back up to previous component, ignore if at root already. */
|
||||
if (dest > rname + prefix_len + 1)
|
||||
for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest)
|
||||
continue;
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||
&& dest == rname + 1 && !prefix_len
|
||||
&& ISSLASH (*dest) && !ISSLASH (dest[1]))
|
||||
dest++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ISSLASH (dest[-1]))
|
||||
*dest++ = '/';
|
||||
|
||||
while (rname + bufs->rname.length - dest
|
||||
< startlen + sizeof dir_suffix)
|
||||
{
|
||||
idx_t dest_offset = dest - rname;
|
||||
if (!scratch_buffer_grow_preserve (&bufs->rname))
|
||||
xalloc_die ();
|
||||
rname = bufs->rname.data;
|
||||
dest = rname + dest_offset;
|
||||
}
|
||||
|
||||
dest = mempcpy (dest, start, startlen);
|
||||
*dest = '\0';
|
||||
|
||||
char *buf;
|
||||
ssize_t n = -1;
|
||||
if (!logical)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
buf = bufs->link.data;
|
||||
idx_t bufsize = bufs->link.length;
|
||||
n = readlink (rname, buf, bufsize - 1);
|
||||
if (n < bufsize - 1)
|
||||
break;
|
||||
if (!scratch_buffer_grow (&bufs->link))
|
||||
xalloc_die ();
|
||||
}
|
||||
}
|
||||
if (0 <= n)
|
||||
{
|
||||
/* A physical traversal and RNAME is a symbolic link. */
|
||||
|
||||
if (num_links < 20)
|
||||
num_links++;
|
||||
else if (*start)
|
||||
{
|
||||
/* Enough symlinks have been seen that it is time to
|
||||
worry about being in a symlink cycle.
|
||||
Get the device and inode of the parent directory, as
|
||||
pre-2017 POSIX says this info is not reliable for
|
||||
symlinks. */
|
||||
struct stat st;
|
||||
dest[- startlen] = '\0';
|
||||
if (stat (*rname ? rname : ".", &st) != 0)
|
||||
goto error;
|
||||
dest[- startlen] = *start;
|
||||
|
||||
/* Detect loops. We cannot use the cycle-check module here,
|
||||
since it's possible to encounter the same parent
|
||||
directory more than once in a given traversal. However,
|
||||
encountering the same (parentdir, START) pair twice does
|
||||
indicate a loop. */
|
||||
if (seen_triple (&ht, start, &st))
|
||||
{
|
||||
if (can_exist == CAN_MISSING)
|
||||
continue;
|
||||
errno = ELOOP;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
buf[n] = '\0';
|
||||
|
||||
char *extra_buf = bufs->extra.data;
|
||||
idx_t end_idx;
|
||||
if (end_in_extra_buffer)
|
||||
end_idx = end - extra_buf;
|
||||
size_t len = strlen (end);
|
||||
if (INT_ADD_OVERFLOW (len, n))
|
||||
xalloc_die ();
|
||||
while (bufs->extra.length <= len + n)
|
||||
{
|
||||
if (!scratch_buffer_grow_preserve (&bufs->extra))
|
||||
xalloc_die ();
|
||||
extra_buf = bufs->extra.data;
|
||||
}
|
||||
if (end_in_extra_buffer)
|
||||
end = extra_buf + end_idx;
|
||||
|
||||
/* Careful here, end may be a pointer into extra_buf... */
|
||||
memmove (&extra_buf[n], end, len + 1);
|
||||
name = end = memcpy (extra_buf, buf, n);
|
||||
end_in_extra_buffer = true;
|
||||
|
||||
if (IS_ABSOLUTE_FILE_NAME (buf))
|
||||
{
|
||||
idx_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf);
|
||||
|
||||
dest = mempcpy (rname, buf, pfxlen);
|
||||
*dest++ = '/'; /* It's an absolute symlink */
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
|
||||
{
|
||||
if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen)
|
||||
*dest++ = '/';
|
||||
*dest = '\0';
|
||||
}
|
||||
/* Install the new prefix to be in effect hereafter. */
|
||||
prefix_len = pfxlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Back up to previous component, ignore if at root
|
||||
already: */
|
||||
if (dest > rname + prefix_len + 1)
|
||||
for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest)
|
||||
continue;
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1
|
||||
&& ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len)
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
else if (! (can_exist == CAN_MISSING
|
||||
|| (suffix_requires_dir_check (end)
|
||||
? dir_check (rname, dest)
|
||||
: !logical
|
||||
? errno == EINVAL
|
||||
: *end || file_accessible (rname))
|
||||
|| (can_exist == CAN_ALL_BUT_LAST
|
||||
&& errno == ENOENT
|
||||
&& !end[strspn (end, SLASHES)])))
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1]))
|
||||
--dest;
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 && !prefix_len
|
||||
&& ISSLASH (*dest) && !ISSLASH (dest[1]))
|
||||
dest++;
|
||||
failed = false;
|
||||
|
||||
error:
|
||||
if (ht)
|
||||
hash_free (ht);
|
||||
|
||||
if (failed)
|
||||
return NULL;
|
||||
|
||||
*dest++ = '\0';
|
||||
char *result = malloc (dest - rname);
|
||||
if (!result)
|
||||
xalloc_die ();
|
||||
return memcpy (result, rname, dest - rname);
|
||||
}
|
||||
|
||||
/* Return the canonical absolute name of file NAME, while treating
|
||||
missing elements according to CAN_MODE. A canonical name
|
||||
does not contain any ".", ".." components nor any repeated file name
|
||||
separators ('/') or, depending on other CAN_MODE flags, symlinks.
|
||||
Whether components must exist or not depends on canonicalize mode.
|
||||
The result is malloc'd. */
|
||||
|
||||
char *
|
||||
canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode)
|
||||
{
|
||||
struct realpath_bufs bufs;
|
||||
scratch_buffer_init (&bufs.rname);
|
||||
scratch_buffer_init (&bufs.extra);
|
||||
scratch_buffer_init (&bufs.link);
|
||||
char *result = canonicalize_filename_mode_stk (name, can_mode, &bufs);
|
||||
scratch_buffer_free (&bufs.link);
|
||||
scratch_buffer_free (&bufs.extra);
|
||||
scratch_buffer_free (&bufs.rname);
|
||||
return result;
|
||||
}
|
63
gl/lib/canonicalize.h
Normal file
63
gl/lib/canonicalize.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* Return the canonical absolute name of a given file.
|
||||
Copyright (C) 1996-2007, 2009-2024 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef CANONICALIZE_H_
|
||||
# define CANONICALIZE_H_
|
||||
|
||||
/* This file uses _GL_ATTRIBUTE_MALLOC. */
|
||||
#if !_GL_CONFIG_H_INCLUDED
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* for canonicalize_file_name */
|
||||
|
||||
#define CAN_MODE_MASK (CAN_EXISTING | CAN_ALL_BUT_LAST | CAN_MISSING)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum canonicalize_mode_t
|
||||
{
|
||||
/* All components must exist. */
|
||||
CAN_EXISTING = 0,
|
||||
|
||||
/* All components excluding last one must exist. */
|
||||
CAN_ALL_BUT_LAST = 1,
|
||||
|
||||
/* No requirements on components existence. */
|
||||
CAN_MISSING = 2,
|
||||
|
||||
/* Don't expand symlinks. */
|
||||
CAN_NOLINKS = 4
|
||||
};
|
||||
typedef enum canonicalize_mode_t canonicalize_mode_t;
|
||||
|
||||
/* Return the canonical absolute name of file NAME, while treating
|
||||
missing elements according to CAN_MODE. A canonical name
|
||||
does not contain any `.', `..' components nor any repeated file name
|
||||
separators ('/') or, depending on other CAN_MODE flags, symlinks.
|
||||
Whether components must exist or not depends on canonicalize mode.
|
||||
The result is malloc'd.
|
||||
Upon failure, return NULL with errno set. */
|
||||
char *canonicalize_filename_mode (const char *, canonicalize_mode_t)
|
||||
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !CANONICALIZE_H_ */
|
715
gl/lib/cdefs.h
Normal file
715
gl/lib/cdefs.h
Normal file
|
@ -0,0 +1,715 @@
|
|||
/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
|
||||
Copyright The GNU Toolchain Authors.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _SYS_CDEFS_H
|
||||
#define _SYS_CDEFS_H 1
|
||||
|
||||
/* We are almost always included from features.h. */
|
||||
#ifndef _FEATURES_H
|
||||
# include <features.h>
|
||||
#endif
|
||||
|
||||
/* The GNU libc does not support any K&R compilers or the traditional mode
|
||||
of ISO C compilers anymore. Check for some of the combinations not
|
||||
supported anymore. */
|
||||
#if defined __GNUC__ && !defined __STDC__
|
||||
# error "You need a ISO C conforming compiler to use the glibc headers"
|
||||
#endif
|
||||
|
||||
/* Some user header file might have defined this before. */
|
||||
#undef __P
|
||||
#undef __PMT
|
||||
|
||||
/* Compilers that lack __has_attribute may object to
|
||||
#if defined __has_attribute && __has_attribute (...)
|
||||
even though they do not need to evaluate the right-hand side of the &&.
|
||||
Similarly for __has_builtin, etc. */
|
||||
#if (defined __has_attribute \
|
||||
&& (!defined __clang_minor__ \
|
||||
|| (defined __apple_build_version__ \
|
||||
? 7000000 <= __apple_build_version__ \
|
||||
: 5 <= __clang_major__)))
|
||||
# define __glibc_has_attribute(attr) __has_attribute (attr)
|
||||
#else
|
||||
# define __glibc_has_attribute(attr) 0
|
||||
#endif
|
||||
#ifdef __has_builtin
|
||||
# define __glibc_has_builtin(name) __has_builtin (name)
|
||||
#else
|
||||
# define __glibc_has_builtin(name) 0
|
||||
#endif
|
||||
#ifdef __has_extension
|
||||
# define __glibc_has_extension(ext) __has_extension (ext)
|
||||
#else
|
||||
# define __glibc_has_extension(ext) 0
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ || defined __clang__
|
||||
|
||||
/* All functions, except those with callbacks or those that
|
||||
synchronize memory, are leaf functions. */
|
||||
# if __GNUC_PREREQ (4, 6) && !defined _LIBC
|
||||
# define __LEAF , __leaf__
|
||||
# define __LEAF_ATTR __attribute__ ((__leaf__))
|
||||
# else
|
||||
# define __LEAF
|
||||
# define __LEAF_ATTR
|
||||
# endif
|
||||
|
||||
/* GCC can always grok prototypes. For C++ programs we add throw()
|
||||
to help it optimize the function calls. But this only works with
|
||||
gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions
|
||||
as non-throwing using a function attribute since programs can use
|
||||
the -fexceptions options for C code as well. */
|
||||
# if !defined __cplusplus \
|
||||
&& (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
|
||||
# define __THROW __attribute__ ((__nothrow__ __LEAF))
|
||||
# define __THROWNL __attribute__ ((__nothrow__))
|
||||
# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
|
||||
# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
|
||||
# else
|
||||
# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
|
||||
# if __cplusplus >= 201103L
|
||||
# define __THROW noexcept (true)
|
||||
# else
|
||||
# define __THROW throw ()
|
||||
# endif
|
||||
# define __THROWNL __THROW
|
||||
# define __NTH(fct) __LEAF_ATTR fct __THROW
|
||||
# define __NTHNL(fct) fct __THROW
|
||||
# else
|
||||
# define __THROW
|
||||
# define __THROWNL
|
||||
# define __NTH(fct) fct
|
||||
# define __NTHNL(fct) fct
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#else /* Not GCC or clang. */
|
||||
|
||||
# if (defined __cplusplus \
|
||||
|| (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
|
||||
# define __inline inline
|
||||
# else
|
||||
# define __inline /* No inline functions. */
|
||||
# endif
|
||||
|
||||
# define __THROW
|
||||
# define __THROWNL
|
||||
# define __NTH(fct) fct
|
||||
|
||||
#endif /* GCC || clang. */
|
||||
|
||||
/* These two macros are not used in glibc anymore. They are kept here
|
||||
only because some other projects expect the macros to be defined. */
|
||||
#define __P(args) args
|
||||
#define __PMT(args) args
|
||||
|
||||
/* For these things, GCC behaves the ANSI way normally,
|
||||
and the non-ANSI way under -traditional. */
|
||||
|
||||
#define __CONCAT(x,y) x ## y
|
||||
#define __STRING(x) #x
|
||||
|
||||
/* This is not a typedef so `const __ptr_t' does the right thing. */
|
||||
#define __ptr_t void *
|
||||
|
||||
|
||||
/* C++ needs to know that types and declarations are C, not C++. */
|
||||
#ifdef __cplusplus
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# define __END_DECLS }
|
||||
#else
|
||||
# define __BEGIN_DECLS
|
||||
# define __END_DECLS
|
||||
#endif
|
||||
|
||||
|
||||
/* Gnulib avoids these definitions, as they don't work on non-glibc platforms.
|
||||
In particular, __bos and __bos0 are defined differently in the Android libc.
|
||||
*/
|
||||
#ifndef __GNULIB_CDEFS
|
||||
|
||||
/* Fortify support. */
|
||||
# define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
|
||||
# define __bos0(ptr) __builtin_object_size (ptr, 0)
|
||||
|
||||
/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
|
||||
# if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
|
||||
|| __GNUC_PREREQ (12, 0))
|
||||
# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
|
||||
# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
|
||||
# else
|
||||
# define __glibc_objsize0(__o) __bos0 (__o)
|
||||
# define __glibc_objsize(__o) __bos (__o)
|
||||
# endif
|
||||
|
||||
/* Compile time conditions to choose between the regular, _chk and _chk_warn
|
||||
variants. These conditions should get evaluated to constant and optimized
|
||||
away. */
|
||||
|
||||
# define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
|
||||
# define __glibc_unsigned_or_positive(__l) \
|
||||
((__typeof (__l)) 0 < (__typeof (__l)) -1 \
|
||||
|| (__builtin_constant_p (__l) && (__l) > 0))
|
||||
|
||||
/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
|
||||
condition can be folded to a constant and if it is true, or unknown (-1) */
|
||||
# define __glibc_safe_or_unknown_len(__l, __s, __osz) \
|
||||
((__osz) == (__SIZE_TYPE__) -1 \
|
||||
|| (__glibc_unsigned_or_positive (__l) \
|
||||
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
|
||||
(__s), (__osz))) \
|
||||
&& __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
|
||||
|
||||
/* Conversely, we know at compile time that the length is unsafe if the
|
||||
__L * __S <= __OBJSZ condition can be folded to a constant and if it is
|
||||
false. */
|
||||
# define __glibc_unsafe_len(__l, __s, __osz) \
|
||||
(__glibc_unsigned_or_positive (__l) \
|
||||
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
|
||||
__s, __osz)) \
|
||||
&& !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
|
||||
|
||||
/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
|
||||
declared. */
|
||||
|
||||
# define __glibc_fortify(f, __l, __s, __osz, ...) \
|
||||
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
|
||||
? __ ## f ## _alias (__VA_ARGS__) \
|
||||
: (__glibc_unsafe_len (__l, __s, __osz) \
|
||||
? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
|
||||
: __ ## f ## _chk (__VA_ARGS__, __osz))) \
|
||||
|
||||
/* Fortify function f, where object size argument passed to f is the number of
|
||||
elements and not total size. */
|
||||
|
||||
# define __glibc_fortify_n(f, __l, __s, __osz, ...) \
|
||||
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
|
||||
? __ ## f ## _alias (__VA_ARGS__) \
|
||||
: (__glibc_unsafe_len (__l, __s, __osz) \
|
||||
? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
|
||||
: __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if __GNUC_PREREQ (4,3)
|
||||
# define __warnattr(msg) __attribute__((__warning__ (msg)))
|
||||
# define __errordecl(name, msg) \
|
||||
extern void name (void) __attribute__((__error__ (msg)))
|
||||
#else
|
||||
# define __warnattr(msg)
|
||||
# define __errordecl(name, msg) extern void name (void)
|
||||
#endif
|
||||
|
||||
/* Support for flexible arrays.
|
||||
Headers that should use flexible arrays only if they're "real"
|
||||
(e.g. only if they won't affect sizeof()) should test
|
||||
#if __glibc_c99_flexarr_available. */
|
||||
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
|
||||
# define __flexarr []
|
||||
# define __glibc_c99_flexarr_available 1
|
||||
#elif __GNUC_PREREQ (2,97) || defined __clang__
|
||||
/* GCC 2.97 and clang support C99 flexible array members as an extension,
|
||||
even when in C89 mode or compiling C++ (any version). */
|
||||
# define __flexarr []
|
||||
# define __glibc_c99_flexarr_available 1
|
||||
#elif defined __GNUC__
|
||||
/* Pre-2.97 GCC did not support C99 flexible arrays but did have
|
||||
an equivalent extension with slightly different notation. */
|
||||
# define __flexarr [0]
|
||||
# define __glibc_c99_flexarr_available 1
|
||||
#else
|
||||
/* Some other non-C99 compiler. Approximate with [1]. */
|
||||
# define __flexarr [1]
|
||||
# define __glibc_c99_flexarr_available 0
|
||||
#endif
|
||||
|
||||
|
||||
/* __asm__ ("xyz") is used throughout the headers to rename functions
|
||||
at the assembly language level. This is wrapped by the __REDIRECT
|
||||
macro, in order to support compilers that can do this some other
|
||||
way. When compilers don't support asm-names at all, we have to do
|
||||
preprocessor tricks instead (which don't have exactly the right
|
||||
semantics, but it's the best we can do).
|
||||
|
||||
Example:
|
||||
int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
|
||||
|
||||
#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
|
||||
|
||||
# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
|
||||
# ifdef __cplusplus
|
||||
# define __REDIRECT_NTH(name, proto, alias) \
|
||||
name proto __THROW __asm__ (__ASMNAME (#alias))
|
||||
# define __REDIRECT_NTHNL(name, proto, alias) \
|
||||
name proto __THROWNL __asm__ (__ASMNAME (#alias))
|
||||
# else
|
||||
# define __REDIRECT_NTH(name, proto, alias) \
|
||||
name proto __asm__ (__ASMNAME (#alias)) __THROW
|
||||
# define __REDIRECT_NTHNL(name, proto, alias) \
|
||||
name proto __asm__ (__ASMNAME (#alias)) __THROWNL
|
||||
# endif
|
||||
# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
|
||||
# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
|
||||
|
||||
/*
|
||||
#elif __SOME_OTHER_COMPILER__
|
||||
|
||||
# define __REDIRECT(name, proto, alias) name proto; \
|
||||
_Pragma("let " #name " = " #alias)
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* GCC and clang have various useful declarations that can be made with
|
||||
the '__attribute__' syntax. All of the ways we use this do fine if
|
||||
they are omitted for compilers that don't understand it. */
|
||||
#if !(defined __GNUC__ || defined __clang__)
|
||||
# define __attribute__(xyz) /* Ignore */
|
||||
#endif
|
||||
|
||||
/* At some point during the gcc 2.96 development the `malloc' attribute
|
||||
for functions was introduced. We don't want to use it unconditionally
|
||||
(although this would be possible) since it generates warnings. */
|
||||
#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
|
||||
# define __attribute_malloc__ __attribute__ ((__malloc__))
|
||||
#else
|
||||
# define __attribute_malloc__ /* Ignore */
|
||||
#endif
|
||||
|
||||
/* Tell the compiler which arguments to an allocation function
|
||||
indicate the size of the allocation. */
|
||||
#if __GNUC_PREREQ (4, 3)
|
||||
# define __attribute_alloc_size__(params) \
|
||||
__attribute__ ((__alloc_size__ params))
|
||||
#else
|
||||
# define __attribute_alloc_size__(params) /* Ignore. */
|
||||
#endif
|
||||
|
||||
/* Tell the compiler which argument to an allocation function
|
||||
indicates the alignment of the allocation. */
|
||||
#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
|
||||
# define __attribute_alloc_align__(param) \
|
||||
__attribute__ ((__alloc_align__ param))
|
||||
#else
|
||||
# define __attribute_alloc_align__(param) /* Ignore. */
|
||||
#endif
|
||||
|
||||
/* At some point during the gcc 2.96 development the `pure' attribute
|
||||
for functions was introduced. We don't want to use it unconditionally
|
||||
(although this would be possible) since it generates warnings. */
|
||||
#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
|
||||
# define __attribute_pure__ __attribute__ ((__pure__))
|
||||
#else
|
||||
# define __attribute_pure__ /* Ignore */
|
||||
#endif
|
||||
|
||||
/* This declaration tells the compiler that the value is constant. */
|
||||
#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
|
||||
# define __attribute_const__ __attribute__ ((__const__))
|
||||
#else
|
||||
# define __attribute_const__ /* Ignore */
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
|
||||
# define __attribute_maybe_unused__ __attribute__ ((__unused__))
|
||||
#else
|
||||
# define __attribute_maybe_unused__ /* Ignore */
|
||||
#endif
|
||||
|
||||
/* At some point during the gcc 3.1 development the `used' attribute
|
||||
for functions was introduced. We don't want to use it unconditionally
|
||||
(although this would be possible) since it generates warnings. */
|
||||
#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
|
||||
# define __attribute_used__ __attribute__ ((__used__))
|
||||
# define __attribute_noinline__ __attribute__ ((__noinline__))
|
||||
#else
|
||||
# define __attribute_used__ __attribute__ ((__unused__))
|
||||
# define __attribute_noinline__ /* Ignore */
|
||||
#endif
|
||||
|
||||
/* Since version 3.2, gcc allows marking deprecated functions. */
|
||||
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
|
||||
# define __attribute_deprecated__ __attribute__ ((__deprecated__))
|
||||
#else
|
||||
# define __attribute_deprecated__ /* Ignore */
|
||||
#endif
|
||||
|
||||
/* Since version 4.5, gcc also allows one to specify the message printed
|
||||
when a deprecated function is used. clang claims to be gcc 4.2, but
|
||||
may also support this feature. */
|
||||
#if __GNUC_PREREQ (4,5) \
|
||||
|| __glibc_has_extension (__attribute_deprecated_with_message__)
|
||||
# define __attribute_deprecated_msg__(msg) \
|
||||
__attribute__ ((__deprecated__ (msg)))
|
||||
#else
|
||||
# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
|
||||
#endif
|
||||
|
||||
/* At some point during the gcc 2.8 development the `format_arg' attribute
|
||||
for functions was introduced. We don't want to use it unconditionally
|
||||
(although this would be possible) since it generates warnings.
|
||||
If several `format_arg' attributes are given for the same function, in
|
||||
gcc-3.0 and older, all but the last one are ignored. In newer gccs,
|
||||
all designated arguments are considered. */
|
||||
#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
|
||||
# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
|
||||
#else
|
||||
# define __attribute_format_arg__(x) /* Ignore */
|
||||
#endif
|
||||
|
||||
/* At some point during the gcc 2.97 development the `strfmon' format
|
||||
attribute for functions was introduced. We don't want to use it
|
||||
unconditionally (although this would be possible) since it
|
||||
generates warnings. */
|
||||
#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
|
||||
# define __attribute_format_strfmon__(a,b) \
|
||||
__attribute__ ((__format__ (__strfmon__, a, b)))
|
||||
#else
|
||||
# define __attribute_format_strfmon__(a,b) /* Ignore */
|
||||
#endif
|
||||
|
||||
/* The nonnull function attribute marks pointer parameters that
|
||||
must not be NULL. This has the name __nonnull in glibc,
|
||||
and __attribute_nonnull__ in files shared with Gnulib to avoid
|
||||
collision with a different __nonnull in DragonFlyBSD 5.9. */
|
||||
#ifndef __attribute_nonnull__
|
||||
# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
|
||||
# define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
|
||||
# else
|
||||
# define __attribute_nonnull__(params)
|
||||
# endif
|
||||
#endif
|
||||
#ifndef __nonnull
|
||||
# define __nonnull(params) __attribute_nonnull__ (params)
|
||||
#endif
|
||||
|
||||
/* The returns_nonnull function attribute marks the return type of the function
|
||||
as always being non-null. */
|
||||
#ifndef __returns_nonnull
|
||||
# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
|
||||
# define __returns_nonnull __attribute__ ((__returns_nonnull__))
|
||||
# else
|
||||
# define __returns_nonnull
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If fortification mode, we warn about unused results of certain
|
||||
function calls which can lead to problems. */
|
||||
#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
|
||||
# define __attribute_warn_unused_result__ \
|
||||
__attribute__ ((__warn_unused_result__))
|
||||
# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
|
||||
# define __wur __attribute_warn_unused_result__
|
||||
# endif
|
||||
#else
|
||||
# define __attribute_warn_unused_result__ /* empty */
|
||||
#endif
|
||||
#ifndef __wur
|
||||
# define __wur /* Ignore */
|
||||
#endif
|
||||
|
||||
/* Forces a function to be always inlined. */
|
||||
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
|
||||
/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
|
||||
it conflicts with this definition. Therefore undefine it first to
|
||||
allow either header to be included first. */
|
||||
# undef __always_inline
|
||||
# define __always_inline __inline __attribute__ ((__always_inline__))
|
||||
#else
|
||||
# undef __always_inline
|
||||
# define __always_inline __inline
|
||||
#endif
|
||||
|
||||
/* Associate error messages with the source location of the call site rather
|
||||
than with the source location inside the function. */
|
||||
#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
|
||||
# define __attribute_artificial__ __attribute__ ((__artificial__))
|
||||
#else
|
||||
# define __attribute_artificial__ /* Ignore */
|
||||
#endif
|
||||
|
||||
/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
|
||||
inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
|
||||
or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
|
||||
older than 4.3 may define these macros and still not guarantee GNU inlining
|
||||
semantics.
|
||||
|
||||
clang++ identifies itself as gcc-4.2, but has support for GNU inlining
|
||||
semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
|
||||
__GNUC_GNU_INLINE__ macro definitions. */
|
||||
#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
|
||||
|| (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
|
||||
|| defined __GNUC_GNU_INLINE__)))
|
||||
# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
|
||||
# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
|
||||
# define __extern_always_inline \
|
||||
extern __always_inline __attribute__ ((__gnu_inline__))
|
||||
# else
|
||||
# define __extern_inline extern __inline
|
||||
# define __extern_always_inline extern __always_inline
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __extern_always_inline
|
||||
# define __fortify_function __extern_always_inline __attribute_artificial__
|
||||
#endif
|
||||
|
||||
/* GCC 4.3 and above allow passing all anonymous arguments of an
|
||||
__extern_always_inline function to some other vararg function. */
|
||||
#if __GNUC_PREREQ (4,3)
|
||||
# define __va_arg_pack() __builtin_va_arg_pack ()
|
||||
# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
|
||||
#endif
|
||||
|
||||
/* It is possible to compile containing GCC extensions even if GCC is
|
||||
run in pedantic mode if the uses are carefully marked using the
|
||||
`__extension__' keyword. But this is not generally available before
|
||||
version 2.8. */
|
||||
#if !(__GNUC_PREREQ (2,8) || defined __clang__)
|
||||
# define __extension__ /* Ignore */
|
||||
#endif
|
||||
|
||||
/* __restrict is known in EGCS 1.2 and above, and in clang.
|
||||
It works also in C++ mode (outside of arrays), but only when spelled
|
||||
as '__restrict', not 'restrict'. */
|
||||
#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
|
||||
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
||||
# define __restrict restrict
|
||||
# else
|
||||
# define __restrict /* Ignore */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
|
||||
array_name[restrict]
|
||||
GCC 3.1 and clang support this.
|
||||
This syntax is not usable in C++ mode. */
|
||||
#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
|
||||
# define __restrict_arr __restrict
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# define __restrict_arr /* Not supported in old GCC. */
|
||||
# else
|
||||
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
||||
# define __restrict_arr restrict
|
||||
# else
|
||||
/* Some other non-C99 compiler. */
|
||||
# define __restrict_arr /* Not supported. */
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
|
||||
# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
|
||||
# define __glibc_likely(cond) __builtin_expect ((cond), 1)
|
||||
#else
|
||||
# define __glibc_unlikely(cond) (cond)
|
||||
# define __glibc_likely(cond) (cond)
|
||||
#endif
|
||||
|
||||
#if (!defined _Noreturn \
|
||||
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
|
||||
&& !(__GNUC_PREREQ (4,7) \
|
||||
|| (3 < __clang_major__ + (5 <= __clang_minor__))))
|
||||
# if __GNUC_PREREQ (2,8)
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
# else
|
||||
# define _Noreturn
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ (8, 0)
|
||||
/* Describes a char array whose address can safely be passed as the first
|
||||
argument to strncpy and strncat, as the char array is not necessarily
|
||||
a NUL-terminated string. */
|
||||
# define __attribute_nonstring__ __attribute__ ((__nonstring__))
|
||||
#else
|
||||
# define __attribute_nonstring__
|
||||
#endif
|
||||
|
||||
/* Undefine (also defined in libc-symbols.h). */
|
||||
#undef __attribute_copy__
|
||||
#if __GNUC_PREREQ (9, 0)
|
||||
/* Copies attributes from the declaration or type referenced by
|
||||
the argument. */
|
||||
# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
|
||||
#else
|
||||
# define __attribute_copy__(arg)
|
||||
#endif
|
||||
|
||||
#if (!defined _Static_assert && !defined __cplusplus \
|
||||
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
|
||||
&& (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
|
||||
|| defined __STRICT_ANSI__))
|
||||
# define _Static_assert(expr, diagnostic) \
|
||||
extern int (*__Static_assert_function (void)) \
|
||||
[!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
|
||||
#endif
|
||||
|
||||
/* Gnulib avoids including these, as they don't work on non-glibc or
|
||||
older glibc platforms. */
|
||||
#ifndef __GNULIB_CDEFS
|
||||
# include <bits/wordsize.h>
|
||||
# include <bits/long-double.h>
|
||||
#endif
|
||||
|
||||
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
|
||||
# ifdef __REDIRECT
|
||||
|
||||
/* Alias name defined automatically. */
|
||||
# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
|
||||
# define __LDBL_REDIR_DECL(name) \
|
||||
extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
|
||||
|
||||
/* Alias name defined automatically, with leading underscores. */
|
||||
# define __LDBL_REDIR2_DECL(name) \
|
||||
extern __typeof (__##name) __##name \
|
||||
__asm (__ASMNAME ("__" #name "ieee128"));
|
||||
|
||||
/* Alias name defined manually. */
|
||||
# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
|
||||
# define __LDBL_REDIR1_DECL(name, alias) \
|
||||
extern __typeof (name) name __asm (__ASMNAME (#alias));
|
||||
|
||||
# define __LDBL_REDIR1_NTH(name, proto, alias) \
|
||||
__REDIRECT_NTH (name, proto, alias)
|
||||
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
|
||||
__LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
|
||||
|
||||
/* Unused. */
|
||||
# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
|
||||
# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
|
||||
|
||||
# else
|
||||
_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
|
||||
# endif
|
||||
#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
|
||||
# define __LDBL_COMPAT 1
|
||||
# ifdef __REDIRECT
|
||||
# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
|
||||
# define __LDBL_REDIR(name, proto) \
|
||||
__LDBL_REDIR1 (name, proto, __nldbl_##name)
|
||||
# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
|
||||
# define __LDBL_REDIR_NTH(name, proto) \
|
||||
__LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
|
||||
# define __LDBL_REDIR2_DECL(name) \
|
||||
extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
|
||||
# define __LDBL_REDIR1_DECL(name, alias) \
|
||||
extern __typeof (name) name __asm (__ASMNAME (#alias));
|
||||
# define __LDBL_REDIR_DECL(name) \
|
||||
extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
|
||||
# define __REDIRECT_LDBL(name, proto, alias) \
|
||||
__LDBL_REDIR1 (name, proto, __nldbl_##alias)
|
||||
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
|
||||
__LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
|
||||
# endif
|
||||
#endif
|
||||
#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
|
||||
|| !defined __REDIRECT
|
||||
# define __LDBL_REDIR1(name, proto, alias) name proto
|
||||
# define __LDBL_REDIR(name, proto) name proto
|
||||
# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
|
||||
# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
|
||||
# define __LDBL_REDIR2_DECL(name)
|
||||
# define __LDBL_REDIR_DECL(name)
|
||||
# ifdef __REDIRECT
|
||||
# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
|
||||
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
|
||||
__REDIRECT_NTH (name, proto, alias)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
|
||||
intended for use in preprocessor macros.
|
||||
|
||||
Note: MESSAGE must be a _single_ string; concatenation of string
|
||||
literals is not supported. */
|
||||
#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
|
||||
# define __glibc_macro_warning1(message) _Pragma (#message)
|
||||
# define __glibc_macro_warning(message) \
|
||||
__glibc_macro_warning1 (GCC warning message)
|
||||
#else
|
||||
# define __glibc_macro_warning(msg)
|
||||
#endif
|
||||
|
||||
/* Generic selection (ISO C11) is a C-only feature, available in GCC
|
||||
since version 4.9. Previous versions do not provide generic
|
||||
selection, even though they might set __STDC_VERSION__ to 201112L,
|
||||
when in -std=c11 mode. Thus, we must check for !defined __GNUC__
|
||||
when testing __STDC_VERSION__ for generic selection support.
|
||||
On the other hand, Clang also defines __GNUC__, so a clang-specific
|
||||
check is required to enable the use of generic selection. */
|
||||
#if !defined __cplusplus \
|
||||
&& (__GNUC_PREREQ (4, 9) \
|
||||
|| __glibc_has_extension (c_generic_selections) \
|
||||
|| (!defined __GNUC__ && defined __STDC_VERSION__ \
|
||||
&& __STDC_VERSION__ >= 201112L))
|
||||
# define __HAVE_GENERIC_SELECTION 1
|
||||
#else
|
||||
# define __HAVE_GENERIC_SELECTION 0
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ (10, 0)
|
||||
/* Designates a 1-based positional argument ref-index of pointer type
|
||||
that can be used to access size-index elements of the pointed-to
|
||||
array according to access mode, or at least one element when
|
||||
size-index is not provided:
|
||||
access (access-mode, <ref-index> [, <size-index>]) */
|
||||
# define __attr_access(x) __attribute__ ((__access__ x))
|
||||
/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
|
||||
use the access attribute to get object sizes from function definition
|
||||
arguments, so we can't use them on functions we fortify. Drop the object
|
||||
size hints for such functions. */
|
||||
# if __USE_FORTIFY_LEVEL == 3
|
||||
# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
|
||||
# else
|
||||
# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
|
||||
# endif
|
||||
# if __GNUC_PREREQ (11, 0)
|
||||
# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
|
||||
# else
|
||||
# define __attr_access_none(argno)
|
||||
# endif
|
||||
#else
|
||||
# define __fortified_attr_access(a, o, s)
|
||||
# define __attr_access(x)
|
||||
# define __attr_access_none(argno)
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ (11, 0)
|
||||
/* Designates dealloc as a function to call to deallocate objects
|
||||
allocated by the declared function. */
|
||||
# define __attr_dealloc(dealloc, argno) \
|
||||
__attribute__ ((__malloc__ (dealloc, argno)))
|
||||
# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
|
||||
#else
|
||||
# define __attr_dealloc(dealloc, argno)
|
||||
# define __attr_dealloc_free
|
||||
#endif
|
||||
|
||||
/* Specify that a function such as setjmp or vfork may return
|
||||
twice. */
|
||||
#if __GNUC_PREREQ (4, 1)
|
||||
# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
|
||||
#else
|
||||
# define __attribute_returns_twice__ /* Ignore. */
|
||||
#endif
|
||||
|
||||
#endif /* sys/cdefs.h */
|
263
gl/lib/chdir-long.c
Normal file
263
gl/lib/chdir-long.c
Normal file
|
@ -0,0 +1,263 @@
|
|||
/* provide a chdir function that tries not to fail due to ENAMETOOLONG
|
||||
Copyright (C) 2004-2024 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "chdir-long.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "assure.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
# error "compile this file only if your system defines PATH_MAX"
|
||||
#endif
|
||||
|
||||
/* The results of openat() in this file are not leaked to any
|
||||
single-threaded code that could use stdio.
|
||||
FIXME - if the kernel ever adds support for multi-thread safety for
|
||||
avoiding standard fds, then we should use openat_safer. */
|
||||
|
||||
struct cd_buf
|
||||
{
|
||||
int fd;
|
||||
};
|
||||
|
||||
static void
|
||||
cdb_init (struct cd_buf *cdb)
|
||||
{
|
||||
cdb->fd = AT_FDCWD;
|
||||
}
|
||||
|
||||
static int
|
||||
cdb_fchdir (struct cd_buf const *cdb)
|
||||
{
|
||||
return fchdir (cdb->fd);
|
||||
}
|
||||
|
||||
static void
|
||||
cdb_free (struct cd_buf const *cdb)
|
||||
{
|
||||
if (0 <= cdb->fd)
|
||||
{
|
||||
bool close_fail = close (cdb->fd);
|
||||
assure (! close_fail);
|
||||
}
|
||||
}
|
||||
|
||||
/* Given a file descriptor of an open directory (or AT_FDCWD), CDB->fd,
|
||||
try to open the CDB->fd-relative directory, DIR. If the open succeeds,
|
||||
update CDB->fd with the resulting descriptor, close the incoming file
|
||||
descriptor, and return zero. Upon failure, return -1 and set errno. */
|
||||
static int
|
||||
cdb_advance_fd (struct cd_buf *cdb, char const *dir)
|
||||
{
|
||||
int new_fd = openat (cdb->fd, dir,
|
||||
O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
|
||||
if (new_fd < 0)
|
||||
return -1;
|
||||
|
||||
cdb_free (cdb);
|
||||
cdb->fd = new_fd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return a pointer to the first non-slash in S. */
|
||||
static char * _GL_ATTRIBUTE_PURE
|
||||
find_non_slash (char const *s)
|
||||
{
|
||||
size_t n_slash = strspn (s, "/");
|
||||
return (char *) s + n_slash;
|
||||
}
|
||||
|
||||
/* This is a function much like chdir, but without the PATH_MAX limitation
|
||||
on the length of the directory name. A significant difference is that
|
||||
it must be able to modify (albeit only temporarily) the directory
|
||||
name. It handles an arbitrarily long directory name by operating
|
||||
on manageable portions of the name. On systems without the openat
|
||||
syscall, this means changing the working directory to more and more
|
||||
"distant" points along the long directory name and then restoring
|
||||
the working directory. If any of those attempts to save or restore
|
||||
the working directory fails, this function exits nonzero.
|
||||
|
||||
Note that this function may still fail with errno == ENAMETOOLONG, but
|
||||
only if the specified directory name contains a component that is long
|
||||
enough to provoke such a failure all by itself (e.g. if the component
|
||||
has length PATH_MAX or greater on systems that define PATH_MAX). */
|
||||
|
||||
int
|
||||
chdir_long (char *dir)
|
||||
{
|
||||
int e = chdir (dir);
|
||||
if (e == 0 || errno != ENAMETOOLONG)
|
||||
return e;
|
||||
|
||||
{
|
||||
size_t len = strlen (dir);
|
||||
char *dir_end = dir + len;
|
||||
struct cd_buf cdb;
|
||||
size_t n_leading_slash;
|
||||
|
||||
cdb_init (&cdb);
|
||||
|
||||
/* If DIR is the empty string, then the chdir above
|
||||
must have failed and set errno to ENOENT. */
|
||||
assure (0 < len);
|
||||
assure (PATH_MAX <= len);
|
||||
|
||||
/* Count leading slashes. */
|
||||
n_leading_slash = strspn (dir, "/");
|
||||
|
||||
/* Handle any leading slashes as well as any name that matches
|
||||
the regular expression, m!^//hostname[/]*! . Handling this
|
||||
prefix separately usually results in a single additional
|
||||
cdb_advance_fd call, but it's worthwhile, since it makes the
|
||||
code in the following loop cleaner. */
|
||||
if (n_leading_slash == 2)
|
||||
{
|
||||
int err;
|
||||
/* Find next slash.
|
||||
We already know that dir[2] is neither a slash nor '\0'. */
|
||||
char *slash = memchr (dir + 3, '/', dir_end - (dir + 3));
|
||||
if (slash == NULL)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
*slash = '\0';
|
||||
err = cdb_advance_fd (&cdb, dir);
|
||||
*slash = '/';
|
||||
if (err != 0)
|
||||
goto Fail;
|
||||
dir = find_non_slash (slash + 1);
|
||||
}
|
||||
else if (n_leading_slash)
|
||||
{
|
||||
if (cdb_advance_fd (&cdb, "/") != 0)
|
||||
goto Fail;
|
||||
dir += n_leading_slash;
|
||||
}
|
||||
|
||||
assure (*dir != '/');
|
||||
assure (dir <= dir_end);
|
||||
|
||||
while (PATH_MAX <= dir_end - dir)
|
||||
{
|
||||
int err;
|
||||
/* Find a slash that is PATH_MAX or fewer bytes away from dir.
|
||||
I.e. see if there is a slash that will give us a name of
|
||||
length PATH_MAX-1 or less. */
|
||||
char *slash = memrchr (dir, '/', PATH_MAX);
|
||||
if (slash == NULL)
|
||||
{
|
||||
errno = ENAMETOOLONG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*slash = '\0';
|
||||
assure (slash - dir < PATH_MAX);
|
||||
err = cdb_advance_fd (&cdb, dir);
|
||||
*slash = '/';
|
||||
if (err != 0)
|
||||
goto Fail;
|
||||
|
||||
dir = find_non_slash (slash + 1);
|
||||
}
|
||||
|
||||
if (dir < dir_end)
|
||||
{
|
||||
if (cdb_advance_fd (&cdb, dir) != 0)
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
if (cdb_fchdir (&cdb) != 0)
|
||||
goto Fail;
|
||||
|
||||
cdb_free (&cdb);
|
||||
return 0;
|
||||
|
||||
Fail:
|
||||
{
|
||||
int saved_errno = errno;
|
||||
cdb_free (&cdb);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if TEST_CHDIR
|
||||
|
||||
# include "closeout.h"
|
||||
# include <error.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
char *line = NULL;
|
||||
size_t n = 0;
|
||||
int len;
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
len = getline (&line, &n, stdin);
|
||||
if (len < 0)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
if (feof (stdin))
|
||||
exit (0);
|
||||
|
||||
error (EXIT_FAILURE, saved_errno,
|
||||
"reading standard input");
|
||||
}
|
||||
else if (len == 0)
|
||||
exit (0);
|
||||
|
||||
if (line[len-1] == '\n')
|
||||
line[len-1] = '\0';
|
||||
|
||||
if (chdir_long (line) != 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
"chdir_long failed: %s", line);
|
||||
|
||||
if (argc <= 1)
|
||||
{
|
||||
/* Using 'pwd' here makes sense only if it is a robust implementation,
|
||||
like the one in coreutils after the 2004-04-19 changes. */
|
||||
char const *cmd = "pwd";
|
||||
execlp (cmd, (char *) NULL);
|
||||
error (EXIT_FAILURE, errno, "%s", cmd);
|
||||
}
|
||||
|
||||
fclose (stdin);
|
||||
fclose (stderr);
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
compile-command: "gcc -DTEST_CHDIR=1 -g -O -W -Wall chdir-long.c libcoreutils.a"
|
||||
End:
|
||||
*/
|
40
gl/lib/chdir-long.h
Normal file
40
gl/lib/chdir-long.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* provide a chdir function that tries not to fail due to ENAMETOOLONG
|
||||
Copyright (C) 2004-2005, 2009-2024 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Jim Meyering. */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "pathmax.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* On systems without PATH_MAX, presume that chdir accepts
|
||||
arbitrarily long directory names. */
|
||||
#ifndef PATH_MAX
|
||||
# define chdir_long(Dir) chdir (Dir)
|
||||
#else
|
||||
int chdir_long (char *dir);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
141
gl/lib/chown.c
Normal file
141
gl/lib/chown.c
Normal file
|
@ -0,0 +1,141 @@
|
|||
/* provide consistent interface to chown for systems that don't interpret
|
||||
an ID of -1 as meaning "don't change the corresponding ID".
|
||||
|
||||
Copyright (C) 1997, 2004-2007, 2009-2024 Free Software Foundation, Inc.
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <unistd.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if !HAVE_CHOWN
|
||||
|
||||
/* Simple stub that always fails with ENOSYS, for mingw. */
|
||||
int
|
||||
chown (_GL_UNUSED const char *file, _GL_UNUSED uid_t uid,
|
||||
_GL_UNUSED gid_t gid)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else /* HAVE_CHOWN */
|
||||
|
||||
/* Below we refer to the system's chown(). */
|
||||
# undef chown
|
||||
|
||||
/* Provide a more-closely POSIX-conforming version of chown on
|
||||
systems with one or both of the following problems:
|
||||
- chown doesn't treat an ID of -1 as meaning
|
||||
"don't change the corresponding ID".
|
||||
- chown doesn't dereference symlinks. */
|
||||
|
||||
int
|
||||
rpl_chown (const char *file, uid_t uid, gid_t gid)
|
||||
{
|
||||
# if (CHOWN_CHANGE_TIME_BUG || CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE \
|
||||
|| CHOWN_TRAILING_SLASH_BUG)
|
||||
struct stat st;
|
||||
bool stat_valid = false;
|
||||
# endif
|
||||
int result;
|
||||
|
||||
# if CHOWN_CHANGE_TIME_BUG /* OpenBSD 7.2 */
|
||||
if (gid != (gid_t) -1 || uid != (uid_t) -1)
|
||||
{
|
||||
if (stat (file, &st))
|
||||
return -1;
|
||||
stat_valid = true;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE /* some very old platforms */
|
||||
if (gid == (gid_t) -1 || uid == (uid_t) -1)
|
||||
{
|
||||
/* Stat file to get id(s) that should remain unchanged. */
|
||||
if (!stat_valid && stat (file, &st))
|
||||
return -1;
|
||||
if (gid == (gid_t) -1)
|
||||
gid = st.st_gid;
|
||||
if (uid == (uid_t) -1)
|
||||
uid = st.st_uid;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if CHOWN_MODIFIES_SYMLINK /* some very old platforms */
|
||||
/* The system-supplied chown function does not follow symlinks.
|
||||
If the file is a symlink, open the file (following symlinks), and
|
||||
fchown the resulting descriptor. Although the open might fail
|
||||
due to lack of permissions, it's the best we can easily do. */
|
||||
char linkbuf[1];
|
||||
if (0 <= readlink (file, linkbuf, sizeof linkbuf))
|
||||
{
|
||||
int open_flags = O_NONBLOCK | O_NOCTTY | O_CLOEXEC;
|
||||
int fd = open (file, O_RDONLY | open_flags);
|
||||
if (fd < 0
|
||||
&& (errno != EACCES
|
||||
|| ((fd = open (file, O_WRONLY | open_flags)) < 0))
|
||||
&& (errno != EACCES || O_EXEC == O_RDONLY
|
||||
|| ((fd = open (file, O_EXEC | open_flags)) < 0))
|
||||
&& (errno != EACCES || O_SEARCH == O_RDONLY || O_SEARCH == O_EXEC
|
||||
|| ((fd = open (file, O_SEARCH | open_flags)) < 0)))
|
||||
return fd;
|
||||
|
||||
int r = fchown (fd, uid, gid);
|
||||
int err = errno;
|
||||
close (fd);
|
||||
errno = err;
|
||||
return r;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if CHOWN_TRAILING_SLASH_BUG /* macOS 12.5, FreeBSD 7.2, AIX 7.3.1, Solaris 9 */
|
||||
if (!stat_valid)
|
||||
{
|
||||
size_t len = strlen (file);
|
||||
if (len && file[len - 1] == '/' && stat (file, &st))
|
||||
return -1;
|
||||
}
|
||||
# endif
|
||||
|
||||
result = chown (file, uid, gid);
|
||||
|
||||
# if CHOWN_CHANGE_TIME_BUG /* OpenBSD 7.2 */
|
||||
if (result == 0 && stat_valid
|
||||
&& (uid == st.st_uid || uid == (uid_t) -1)
|
||||
&& (gid == st.st_gid || gid == (gid_t) -1))
|
||||
{
|
||||
/* No change in ownership, but at least one argument was not -1,
|
||||
so we are required to update ctime. Since chown succeeded,
|
||||
we assume that chmod will do likewise. Fortunately, on all
|
||||
known systems where a 'no-op' chown skips the ctime update, a
|
||||
'no-op' chmod still does the trick. */
|
||||
result = chmod (file, st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO
|
||||
| S_ISUID | S_ISGID | S_ISVTX));
|
||||
}
|
||||
# endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif /* HAVE_CHOWN */
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue