commit
5cee127618
77
AUTHORS
Normal file
77
AUTHORS
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
This file lists people who have made significant contributions to the
|
||||||
|
nano editor. Please see the ChangeLog for specific changes by author.
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Chris Allegretta <chrisa@asty.org>
|
||||||
|
* Original program author and long-time maintainer.
|
||||||
|
|
||||||
|
Benno Schulenberg <bensberg@telfort.nl>
|
||||||
|
* An array of small bug fixes, the cut-word and block-jump
|
||||||
|
routines, text selection by holding Shift, macro recording
|
||||||
|
and replay, extra key bindings, the --indicator, --minibar,
|
||||||
|
and --zero options, and braced functions in string binds.
|
||||||
|
Current maintainer.
|
||||||
|
|
||||||
|
David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
|
* Former stable series maintainer. Multiple buffer support,
|
||||||
|
operating dir (-o) option, bug fixes for display routines,
|
||||||
|
wrapping code, spelling fixes, constantshow mode, parts of
|
||||||
|
UTF-8 support, softwrap overhaul, undoable (un)indentations,
|
||||||
|
undoable justifications, justifiable regions, and numerous
|
||||||
|
other fixes.
|
||||||
|
|
||||||
|
Jordi Mallach <jordi@gnu.org>
|
||||||
|
* Debian package maintainer, fellow bug squasher.
|
||||||
|
* Internationalization support head, ca.po maintainer.
|
||||||
|
|
||||||
|
Adam Rogoyski <rogoyski@cs.utexas.edu>
|
||||||
|
* New write_file() function, read_file() optimization, mouse
|
||||||
|
support, resize support, nohelp (-x) option, justify function,
|
||||||
|
follow symlink option and bugfixes, and much more.
|
||||||
|
|
||||||
|
Robert Siemborski <rjs3@andrew.cmu.edu>
|
||||||
|
* Miscellaneous cut, display, replace, and other bug fixes,
|
||||||
|
original and new "magic line" code, read_line() function,
|
||||||
|
new edit display routines.
|
||||||
|
|
||||||
|
Rocco Corsi <rocco.corsi@sympatico.ca>
|
||||||
|
* Internal spelling code, many optimizations and bug fixes for
|
||||||
|
findnextstr() and search-related functions, various display
|
||||||
|
and file handling fixes.
|
||||||
|
|
||||||
|
David Benbennick <dbenbenn@math.cornell.edu>
|
||||||
|
* Wrap and justify bugfixes/enhancements, new color syntax
|
||||||
|
code, memleak fixes, parts of the UTF-8 support, and other
|
||||||
|
miscellaneous fixes.
|
||||||
|
|
||||||
|
Mike Frysinger <vapier@gentoo.org>
|
||||||
|
* Gentoo package maintainer. Whitespace display mode,
|
||||||
|
--enable-utf8/--disable-utf8 configure options for ncurses,
|
||||||
|
many new color regexes and improvements to existing color
|
||||||
|
regexes in syntax/*.nanorc, the move from svn to git, the
|
||||||
|
conversion to gnulib, and miscellaneous bug fixes.
|
||||||
|
|
||||||
|
Mark Majeres <mark@engine12.com>
|
||||||
|
* A functional undo/redo system, and coloring nano's interface.
|
||||||
|
|
||||||
|
Mahyar Abbaspour <mahyar.abaspour@gmail.com>
|
||||||
|
* Improved handling of SIGWINCH.
|
||||||
|
|
||||||
|
Mike Scalora <mike@scalora.org>
|
||||||
|
* The comment/uncomment feature.
|
||||||
|
|
||||||
|
Faissal Bensefia <faissaloo@gmail.com>
|
||||||
|
* Line numbers.
|
||||||
|
|
||||||
|
Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
|
||||||
|
* The word-completion feature.
|
||||||
|
|
||||||
|
Rishabh Dave <rishabhddave@gmail.com>
|
||||||
|
* Searchable help.
|
||||||
|
|
||||||
|
Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
|
||||||
|
* Filtering text through an external command.
|
||||||
|
* Placing anchors (bookmarks) and jumping to them.
|
||||||
|
|
||||||
|
Brand Huntsman <alpha@qzx.com>
|
||||||
|
* The delayed parsing of syntax files.
|
676
COPYING
Normal file
676
COPYING
Normal file
|
@ -0,0 +1,676 @@
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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
|
||||||
|
<http://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
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
|
|
397
COPYING.DOC
Normal file
397
COPYING.DOC
Normal file
|
@ -0,0 +1,397 @@
|
||||||
|
GNU Free Documentation License
|
||||||
|
Version 1.2, November 2002
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
|
||||||
|
51 Franklin St, 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.
|
||||||
|
|
||||||
|
|
||||||
|
0. PREAMBLE
|
||||||
|
|
||||||
|
The purpose of this License is to make a manual, textbook, or other
|
||||||
|
functional and useful document "free" in the sense of freedom: to
|
||||||
|
assure everyone the effective freedom to copy and redistribute it,
|
||||||
|
with or without modifying it, either commercially or noncommercially.
|
||||||
|
Secondarily, this License preserves for the author and publisher a way
|
||||||
|
to get credit for their work, while not being considered responsible
|
||||||
|
for modifications made by others.
|
||||||
|
|
||||||
|
This License is a kind of "copyleft", which means that derivative
|
||||||
|
works of the document must themselves be free in the same sense. It
|
||||||
|
complements the GNU General Public License, which is a copyleft
|
||||||
|
license designed for free software.
|
||||||
|
|
||||||
|
We have designed this License in order to use it for manuals for free
|
||||||
|
software, because free software needs free documentation: a free
|
||||||
|
program should come with manuals providing the same freedoms that the
|
||||||
|
software does. But this License is not limited to software manuals;
|
||||||
|
it can be used for any textual work, regardless of subject matter or
|
||||||
|
whether it is published as a printed book. We recommend this License
|
||||||
|
principally for works whose purpose is instruction or reference.
|
||||||
|
|
||||||
|
|
||||||
|
1. APPLICABILITY AND DEFINITIONS
|
||||||
|
|
||||||
|
This License applies to any manual or other work, in any medium, that
|
||||||
|
contains a notice placed by the copyright holder saying it can be
|
||||||
|
distributed under the terms of this License. Such a notice grants a
|
||||||
|
world-wide, royalty-free license, unlimited in duration, to use that
|
||||||
|
work under the conditions stated herein. The "Document", below,
|
||||||
|
refers to any such manual or work. Any member of the public is a
|
||||||
|
licensee, and is addressed as "you". You accept the license if you
|
||||||
|
copy, modify or distribute the work in a way requiring permission
|
||||||
|
under copyright law.
|
||||||
|
|
||||||
|
A "Modified Version" of the Document means any work containing the
|
||||||
|
Document or a portion of it, either copied verbatim, or with
|
||||||
|
modifications and/or translated into another language.
|
||||||
|
|
||||||
|
A "Secondary Section" is a named appendix or a front-matter section of
|
||||||
|
the Document that deals exclusively with the relationship of the
|
||||||
|
publishers or authors of the Document to the Document's overall subject
|
||||||
|
(or to related matters) and contains nothing that could fall directly
|
||||||
|
within that overall subject. (Thus, if the Document is in part a
|
||||||
|
textbook of mathematics, a Secondary Section may not explain any
|
||||||
|
mathematics.) The relationship could be a matter of historical
|
||||||
|
connection with the subject or with related matters, or of legal,
|
||||||
|
commercial, philosophical, ethical or political position regarding
|
||||||
|
them.
|
||||||
|
|
||||||
|
The "Invariant Sections" are certain Secondary Sections whose titles
|
||||||
|
are designated, as being those of Invariant Sections, in the notice
|
||||||
|
that says that the Document is released under this License. If a
|
||||||
|
section does not fit the above definition of Secondary then it is not
|
||||||
|
allowed to be designated as Invariant. The Document may contain zero
|
||||||
|
Invariant Sections. If the Document does not identify any Invariant
|
||||||
|
Sections then there are none.
|
||||||
|
|
||||||
|
The "Cover Texts" are certain short passages of text that are listed,
|
||||||
|
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
||||||
|
the Document is released under this License. A Front-Cover Text may
|
||||||
|
be at most 5 words, and a Back-Cover Text may be at most 25 words.
|
||||||
|
|
||||||
|
A "Transparent" copy of the Document means a machine-readable copy,
|
||||||
|
represented in a format whose specification is available to the
|
||||||
|
general public, that is suitable for revising the document
|
||||||
|
straightforwardly with generic text editors or (for images composed of
|
||||||
|
pixels) generic paint programs or (for drawings) some widely available
|
||||||
|
drawing editor, and that is suitable for input to text formatters or
|
||||||
|
for automatic translation to a variety of formats suitable for input
|
||||||
|
to text formatters. A copy made in an otherwise Transparent file
|
||||||
|
format whose markup, or absence of markup, has been arranged to thwart
|
||||||
|
or discourage subsequent modification by readers is not Transparent.
|
||||||
|
An image format is not Transparent if used for any substantial amount
|
||||||
|
of text. A copy that is not "Transparent" is called "Opaque".
|
||||||
|
|
||||||
|
Examples of suitable formats for Transparent copies include plain
|
||||||
|
ASCII without markup, Texinfo input format, LaTeX input format, SGML
|
||||||
|
or XML using a publicly available DTD, and standard-conforming simple
|
||||||
|
HTML, PostScript or PDF designed for human modification. Examples of
|
||||||
|
transparent image formats include PNG, XCF and JPG. Opaque formats
|
||||||
|
include proprietary formats that can be read and edited only by
|
||||||
|
proprietary word processors, SGML or XML for which the DTD and/or
|
||||||
|
processing tools are not generally available, and the
|
||||||
|
machine-generated HTML, PostScript or PDF produced by some word
|
||||||
|
processors for output purposes only.
|
||||||
|
|
||||||
|
The "Title Page" means, for a printed book, the title page itself,
|
||||||
|
plus such following pages as are needed to hold, legibly, the material
|
||||||
|
this License requires to appear in the title page. For works in
|
||||||
|
formats which do not have any title page as such, "Title Page" means
|
||||||
|
the text near the most prominent appearance of the work's title,
|
||||||
|
preceding the beginning of the body of the text.
|
||||||
|
|
||||||
|
A section "Entitled XYZ" means a named subunit of the Document whose
|
||||||
|
title either is precisely XYZ or contains XYZ in parentheses following
|
||||||
|
text that translates XYZ in another language. (Here XYZ stands for a
|
||||||
|
specific section name mentioned below, such as "Acknowledgements",
|
||||||
|
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
|
||||||
|
of such a section when you modify the Document means that it remains a
|
||||||
|
section "Entitled XYZ" according to this definition.
|
||||||
|
|
||||||
|
The Document may include Warranty Disclaimers next to the notice which
|
||||||
|
states that this License applies to the Document. These Warranty
|
||||||
|
Disclaimers are considered to be included by reference in this
|
||||||
|
License, but only as regards disclaiming warranties: any other
|
||||||
|
implication that these Warranty Disclaimers may have is void and has
|
||||||
|
no effect on the meaning of this License.
|
||||||
|
|
||||||
|
|
||||||
|
2. VERBATIM COPYING
|
||||||
|
|
||||||
|
You may copy and distribute the Document in any medium, either
|
||||||
|
commercially or noncommercially, provided that this License, the
|
||||||
|
copyright notices, and the license notice saying this License applies
|
||||||
|
to the Document are reproduced in all copies, and that you add no other
|
||||||
|
conditions whatsoever to those of this License. You may not use
|
||||||
|
technical measures to obstruct or control the reading or further
|
||||||
|
copying of the copies you make or distribute. However, you may accept
|
||||||
|
compensation in exchange for copies. If you distribute a large enough
|
||||||
|
number of copies you must also follow the conditions in section 3.
|
||||||
|
|
||||||
|
You may also lend copies, under the same conditions stated above, and
|
||||||
|
you may publicly display copies.
|
||||||
|
|
||||||
|
|
||||||
|
3. COPYING IN QUANTITY
|
||||||
|
|
||||||
|
If you publish printed copies (or copies in media that commonly have
|
||||||
|
printed covers) of the Document, numbering more than 100, and the
|
||||||
|
Document's license notice requires Cover Texts, you must enclose the
|
||||||
|
copies in covers that carry, clearly and legibly, all these Cover
|
||||||
|
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
||||||
|
the back cover. Both covers must also clearly and legibly identify
|
||||||
|
you as the publisher of these copies. The front cover must present
|
||||||
|
the full title with all words of the title equally prominent and
|
||||||
|
visible. You may add other material on the covers in addition.
|
||||||
|
Copying with changes limited to the covers, as long as they preserve
|
||||||
|
the title of the Document and satisfy these conditions, can be treated
|
||||||
|
as verbatim copying in other respects.
|
||||||
|
|
||||||
|
If the required texts for either cover are too voluminous to fit
|
||||||
|
legibly, you should put the first ones listed (as many as fit
|
||||||
|
reasonably) on the actual cover, and continue the rest onto adjacent
|
||||||
|
pages.
|
||||||
|
|
||||||
|
If you publish or distribute Opaque copies of the Document numbering
|
||||||
|
more than 100, you must either include a machine-readable Transparent
|
||||||
|
copy along with each Opaque copy, or state in or with each Opaque copy
|
||||||
|
a computer-network location from which the general network-using
|
||||||
|
public has access to download using public-standard network protocols
|
||||||
|
a complete Transparent copy of the Document, free of added material.
|
||||||
|
If you use the latter option, you must take reasonably prudent steps,
|
||||||
|
when you begin distribution of Opaque copies in quantity, to ensure
|
||||||
|
that this Transparent copy will remain thus accessible at the stated
|
||||||
|
location until at least one year after the last time you distribute an
|
||||||
|
Opaque copy (directly or through your agents or retailers) of that
|
||||||
|
edition to the public.
|
||||||
|
|
||||||
|
It is requested, but not required, that you contact the authors of the
|
||||||
|
Document well before redistributing any large number of copies, to give
|
||||||
|
them a chance to provide you with an updated version of the Document.
|
||||||
|
|
||||||
|
|
||||||
|
4. MODIFICATIONS
|
||||||
|
|
||||||
|
You may copy and distribute a Modified Version of the Document under
|
||||||
|
the conditions of sections 2 and 3 above, provided that you release
|
||||||
|
the Modified Version under precisely this License, with the Modified
|
||||||
|
Version filling the role of the Document, thus licensing distribution
|
||||||
|
and modification of the Modified Version to whoever possesses a copy
|
||||||
|
of it. In addition, you must do these things in the Modified Version:
|
||||||
|
|
||||||
|
A. Use in the Title Page (and on the covers, if any) a title distinct
|
||||||
|
from that of the Document, and from those of previous versions
|
||||||
|
(which should, if there were any, be listed in the History section
|
||||||
|
of the Document). You may use the same title as a previous version
|
||||||
|
if the original publisher of that version gives permission.
|
||||||
|
B. List on the Title Page, as authors, one or more persons or entities
|
||||||
|
responsible for authorship of the modifications in the Modified
|
||||||
|
Version, together with at least five of the principal authors of the
|
||||||
|
Document (all of its principal authors, if it has fewer than five),
|
||||||
|
unless they release you from this requirement.
|
||||||
|
C. State on the Title page the name of the publisher of the
|
||||||
|
Modified Version, as the publisher.
|
||||||
|
D. Preserve all the copyright notices of the Document.
|
||||||
|
E. Add an appropriate copyright notice for your modifications
|
||||||
|
adjacent to the other copyright notices.
|
||||||
|
F. Include, immediately after the copyright notices, a license notice
|
||||||
|
giving the public permission to use the Modified Version under the
|
||||||
|
terms of this License, in the form shown in the Addendum below.
|
||||||
|
G. Preserve in that license notice the full lists of Invariant Sections
|
||||||
|
and required Cover Texts given in the Document's license notice.
|
||||||
|
H. Include an unaltered copy of this License.
|
||||||
|
I. Preserve the section Entitled "History", Preserve its Title, and add
|
||||||
|
to it an item stating at least the title, year, new authors, and
|
||||||
|
publisher of the Modified Version as given on the Title Page. If
|
||||||
|
there is no section Entitled "History" in the Document, create one
|
||||||
|
stating the title, year, authors, and publisher of the Document as
|
||||||
|
given on its Title Page, then add an item describing the Modified
|
||||||
|
Version as stated in the previous sentence.
|
||||||
|
J. Preserve the network location, if any, given in the Document for
|
||||||
|
public access to a Transparent copy of the Document, and likewise
|
||||||
|
the network locations given in the Document for previous versions
|
||||||
|
it was based on. These may be placed in the "History" section.
|
||||||
|
You may omit a network location for a work that was published at
|
||||||
|
least four years before the Document itself, or if the original
|
||||||
|
publisher of the version it refers to gives permission.
|
||||||
|
K. For any section Entitled "Acknowledgements" or "Dedications",
|
||||||
|
Preserve the Title of the section, and preserve in the section all
|
||||||
|
the substance and tone of each of the contributor acknowledgements
|
||||||
|
and/or dedications given therein.
|
||||||
|
L. Preserve all the Invariant Sections of the Document,
|
||||||
|
unaltered in their text and in their titles. Section numbers
|
||||||
|
or the equivalent are not considered part of the section titles.
|
||||||
|
M. Delete any section Entitled "Endorsements". Such a section
|
||||||
|
may not be included in the Modified Version.
|
||||||
|
N. Do not retitle any existing section to be Entitled "Endorsements"
|
||||||
|
or to conflict in title with any Invariant Section.
|
||||||
|
O. Preserve any Warranty Disclaimers.
|
||||||
|
|
||||||
|
If the Modified Version includes new front-matter sections or
|
||||||
|
appendices that qualify as Secondary Sections and contain no material
|
||||||
|
copied from the Document, you may at your option designate some or all
|
||||||
|
of these sections as invariant. To do this, add their titles to the
|
||||||
|
list of Invariant Sections in the Modified Version's license notice.
|
||||||
|
These titles must be distinct from any other section titles.
|
||||||
|
|
||||||
|
You may add a section Entitled "Endorsements", provided it contains
|
||||||
|
nothing but endorsements of your Modified Version by various
|
||||||
|
parties--for example, statements of peer review or that the text has
|
||||||
|
been approved by an organization as the authoritative definition of a
|
||||||
|
standard.
|
||||||
|
|
||||||
|
You may add a passage of up to five words as a Front-Cover Text, and a
|
||||||
|
passage of up to 25 words as a Back-Cover Text, to the end of the list
|
||||||
|
of Cover Texts in the Modified Version. Only one passage of
|
||||||
|
Front-Cover Text and one of Back-Cover Text may be added by (or
|
||||||
|
through arrangements made by) any one entity. If the Document already
|
||||||
|
includes a cover text for the same cover, previously added by you or
|
||||||
|
by arrangement made by the same entity you are acting on behalf of,
|
||||||
|
you may not add another; but you may replace the old one, on explicit
|
||||||
|
permission from the previous publisher that added the old one.
|
||||||
|
|
||||||
|
The author(s) and publisher(s) of the Document do not by this License
|
||||||
|
give permission to use their names for publicity for or to assert or
|
||||||
|
imply endorsement of any Modified Version.
|
||||||
|
|
||||||
|
|
||||||
|
5. COMBINING DOCUMENTS
|
||||||
|
|
||||||
|
You may combine the Document with other documents released under this
|
||||||
|
License, under the terms defined in section 4 above for modified
|
||||||
|
versions, provided that you include in the combination all of the
|
||||||
|
Invariant Sections of all of the original documents, unmodified, and
|
||||||
|
list them all as Invariant Sections of your combined work in its
|
||||||
|
license notice, and that you preserve all their Warranty Disclaimers.
|
||||||
|
|
||||||
|
The combined work need only contain one copy of this License, and
|
||||||
|
multiple identical Invariant Sections may be replaced with a single
|
||||||
|
copy. If there are multiple Invariant Sections with the same name but
|
||||||
|
different contents, make the title of each such section unique by
|
||||||
|
adding at the end of it, in parentheses, the name of the original
|
||||||
|
author or publisher of that section if known, or else a unique number.
|
||||||
|
Make the same adjustment to the section titles in the list of
|
||||||
|
Invariant Sections in the license notice of the combined work.
|
||||||
|
|
||||||
|
In the combination, you must combine any sections Entitled "History"
|
||||||
|
in the various original documents, forming one section Entitled
|
||||||
|
"History"; likewise combine any sections Entitled "Acknowledgements",
|
||||||
|
and any sections Entitled "Dedications". You must delete all sections
|
||||||
|
Entitled "Endorsements".
|
||||||
|
|
||||||
|
|
||||||
|
6. COLLECTIONS OF DOCUMENTS
|
||||||
|
|
||||||
|
You may make a collection consisting of the Document and other documents
|
||||||
|
released under this License, and replace the individual copies of this
|
||||||
|
License in the various documents with a single copy that is included in
|
||||||
|
the collection, provided that you follow the rules of this License for
|
||||||
|
verbatim copying of each of the documents in all other respects.
|
||||||
|
|
||||||
|
You may extract a single document from such a collection, and distribute
|
||||||
|
it individually under this License, provided you insert a copy of this
|
||||||
|
License into the extracted document, and follow this License in all
|
||||||
|
other respects regarding verbatim copying of that document.
|
||||||
|
|
||||||
|
|
||||||
|
7. AGGREGATION WITH INDEPENDENT WORKS
|
||||||
|
|
||||||
|
A compilation of the Document or its derivatives with other separate
|
||||||
|
and independent documents or works, in or on a volume of a storage or
|
||||||
|
distribution medium, is called an "aggregate" if the copyright
|
||||||
|
resulting from the compilation is not used to limit the legal rights
|
||||||
|
of the compilation's users beyond what the individual works permit.
|
||||||
|
When the Document is included in an aggregate, this License does not
|
||||||
|
apply to the other works in the aggregate which are not themselves
|
||||||
|
derivative works of the Document.
|
||||||
|
|
||||||
|
If the Cover Text requirement of section 3 is applicable to these
|
||||||
|
copies of the Document, then if the Document is less than one half of
|
||||||
|
the entire aggregate, the Document's Cover Texts may be placed on
|
||||||
|
covers that bracket the Document within the aggregate, or the
|
||||||
|
electronic equivalent of covers if the Document is in electronic form.
|
||||||
|
Otherwise they must appear on printed covers that bracket the whole
|
||||||
|
aggregate.
|
||||||
|
|
||||||
|
|
||||||
|
8. TRANSLATION
|
||||||
|
|
||||||
|
Translation is considered a kind of modification, so you may
|
||||||
|
distribute translations of the Document under the terms of section 4.
|
||||||
|
Replacing Invariant Sections with translations requires special
|
||||||
|
permission from their copyright holders, but you may include
|
||||||
|
translations of some or all Invariant Sections in addition to the
|
||||||
|
original versions of these Invariant Sections. You may include a
|
||||||
|
translation of this License, and all the license notices in the
|
||||||
|
Document, and any Warranty Disclaimers, provided that you also include
|
||||||
|
the original English version of this License and the original versions
|
||||||
|
of those notices and disclaimers. In case of a disagreement between
|
||||||
|
the translation and the original version of this License or a notice
|
||||||
|
or disclaimer, the original version will prevail.
|
||||||
|
|
||||||
|
If a section in the Document is Entitled "Acknowledgements",
|
||||||
|
"Dedications", or "History", the requirement (section 4) to Preserve
|
||||||
|
its Title (section 1) will typically require changing the actual
|
||||||
|
title.
|
||||||
|
|
||||||
|
|
||||||
|
9. TERMINATION
|
||||||
|
|
||||||
|
You may not copy, modify, sublicense, or distribute the Document except
|
||||||
|
as expressly provided for under this License. Any other attempt to
|
||||||
|
copy, modify, sublicense or distribute the Document is void, and will
|
||||||
|
automatically terminate your rights under this License. However,
|
||||||
|
parties who have received copies, or rights, from you under this
|
||||||
|
License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
|
||||||
|
10. FUTURE REVISIONS OF THIS LICENSE
|
||||||
|
|
||||||
|
The Free Software Foundation may publish new, revised versions
|
||||||
|
of the GNU Free Documentation License from time to time. Such new
|
||||||
|
versions will be similar in spirit to the present version, but may
|
||||||
|
differ in detail to address new problems or concerns. See
|
||||||
|
http://www.gnu.org/copyleft/.
|
||||||
|
|
||||||
|
Each version of the License is given a distinguishing version number.
|
||||||
|
If the Document specifies that a particular numbered version of this
|
||||||
|
License "or any later version" applies to it, you have the option of
|
||||||
|
following the terms and conditions either of that specified version or
|
||||||
|
of any later version that has been published (not as a draft) by the
|
||||||
|
Free Software Foundation. If the Document does not specify a version
|
||||||
|
number of this License, you may choose any version ever published (not
|
||||||
|
as a draft) by the Free Software Foundation.
|
||||||
|
|
||||||
|
|
||||||
|
ADDENDUM: How to use this License for your documents
|
||||||
|
|
||||||
|
To use this License in a document you have written, include a copy of
|
||||||
|
the License in the document and put the following copyright and
|
||||||
|
license notices just after the title page:
|
||||||
|
|
||||||
|
Copyright (c) YEAR YOUR NAME.
|
||||||
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.2
|
||||||
|
or any later version published by the Free Software Foundation;
|
||||||
|
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||||
|
A copy of the license is included in the section entitled "GNU
|
||||||
|
Free Documentation License".
|
||||||
|
|
||||||
|
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
|
||||||
|
replace the "with...Texts." line with this:
|
||||||
|
|
||||||
|
with the Invariant Sections being LIST THEIR TITLES, with the
|
||||||
|
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
|
||||||
|
|
||||||
|
If you have Invariant Sections without Cover Texts, or some other
|
||||||
|
combination of the three, merge those two alternatives to suit the
|
||||||
|
situation.
|
||||||
|
|
||||||
|
If your document contains nontrivial examples of program code, we
|
||||||
|
recommend releasing these examples in parallel under your choice of
|
||||||
|
free software license, such as the GNU General Public License,
|
||||||
|
to permit their use in free software.
|
217
IMPROVEMENTS
Normal file
217
IMPROVEMENTS
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
Improvements in GNU nano
|
||||||
|
========================
|
||||||
|
|
||||||
|
Since 7.0:
|
||||||
|
- String binds may contain bindable function names between braces.
|
||||||
|
- Word completion looks for candidates in all open buffers.
|
||||||
|
- Unicode codes can be entered without leading zeroes.
|
||||||
|
|
||||||
|
Since 6.0:
|
||||||
|
- Option --zero hides the interface and uses the whole terminal for editing.
|
||||||
|
- Colors can be given also in #rgb hexadecimal, to select the nearest color
|
||||||
|
from the 6x6x6 color-cube palette available on 256-color terminals.
|
||||||
|
- Fourteen new color names are available, from rosy to crimson.
|
||||||
|
|
||||||
|
Since 5.0:
|
||||||
|
- A search briefly spotlights the found text, in black on yellow by default.
|
||||||
|
- Option --minibar reduces the interface to a bottom bar with basic info.
|
||||||
|
- The cursor skips over combining characters, <Del> deletes them together
|
||||||
|
with the character they combine with, but <Bsp> deletes them separately.
|
||||||
|
- For using libmagic the option --magic or -! or 'set magic' is required.
|
||||||
|
- With --stateflags the state of some things is shown in the title bar.
|
||||||
|
- M-Bsp deletes a word leftward.
|
||||||
|
- With --indicator a "scrollbar" is shown, indicating position+portion.
|
||||||
|
- M-Ins places an anchor, M-PgUp/M-PgDn jump to the nearest anchor.
|
||||||
|
- Toggling help lines (M-X) and Refresh (^L) work nearly everywhere.
|
||||||
|
- Colors can be modified with the attributes "bold," and/or "italic,".
|
||||||
|
- Nine new color names: from pink and purple to orange and latte.
|
||||||
|
|
||||||
|
Since 4.0:
|
||||||
|
- Pasting from outside into nano suppresses auto-indentation.
|
||||||
|
- Such an external paste can be undone with a single M-U.
|
||||||
|
- Shift+Meta+letter key combos can be bound with 'bind Sh-M-letter ...'.
|
||||||
|
- A custom nanorc file may be specified with -f / --rcfile.
|
||||||
|
- What the <Tab> key produces can be specified per syntax with 'tabgives'.
|
||||||
|
- The ability to perform a search at startup with +/string or +?string.
|
||||||
|
- Comment characters are copied when automatic hard-wrapping occurs.
|
||||||
|
- The ability to both read from and write to a FIFO.
|
||||||
|
- Automatic hard-wrapping is no longer the default.
|
||||||
|
- Addition of --guidestripe to draw a helpful vertical bar.
|
||||||
|
- Meta-Up and Meta-Down scroll the screen linewise.
|
||||||
|
- Continuation is shown with a highlighted ">" instead of a plain "$".
|
||||||
|
- A marked region gets justified into a single, separate paragraph.
|
||||||
|
- Any number of justifications can be undone.
|
||||||
|
|
||||||
|
Since 3.0:
|
||||||
|
- Addition of --zap to make <Del> and <Bsp> obliterate marked text.
|
||||||
|
- <Ctrl+Delete> wipes next word and <Shift+Ctrl+Delete> preceding word.
|
||||||
|
- An external spell check can be undone.
|
||||||
|
|
||||||
|
Since 2.9.0:
|
||||||
|
- The ability to filter text through an external command.
|
||||||
|
- Better detection of paragraphs, allowing a less indented beginning.
|
||||||
|
- Option 'set afterends' for making Ctrl+Right stop at word ends.
|
||||||
|
- A crash handler that saves changed buffers in case of a crash.
|
||||||
|
- Addition of the color name "normal", meaning the default color.
|
||||||
|
- A key can be bound to a string -- any mix of text and control codes.
|
||||||
|
- Error messages are shown by default in bright white on red.
|
||||||
|
- <Tab> and <Shift+Tab> can be used to indent/unindent a marked region.
|
||||||
|
- Can snip trailing whitespace while typing, with 'set trimblanks'.
|
||||||
|
- The ability to record and replay a series of keystrokes (a macro).
|
||||||
|
- Assigned functions to ^S (save file) and ^Q (start backward search).
|
||||||
|
- Indenting and unindenting have been integrated into the undo system.
|
||||||
|
- Support for $XDG_CONFIG_HOME for the nanorc file, and $XDG_DATA_HOME
|
||||||
|
for the history files (of search strings and cursor positions).
|
||||||
|
|
||||||
|
Since 2.8.0:
|
||||||
|
- ^U pastes the first line of the cutbuffer at a prompt.
|
||||||
|
- Softwrapping can be done at whitespace (with --soft --atblanks).
|
||||||
|
- The ^G help texts have become searchable (with ^W and M-W).
|
||||||
|
- Ctrl+Home and Ctrl+End jump to start and end of file.
|
||||||
|
- In softwrap mode the cursor now moves per visual row instead of
|
||||||
|
per logical line, and the screen will scroll per row.
|
||||||
|
|
||||||
|
Since 2.7.0:
|
||||||
|
- The keystroke ^] to complete a fragment to an existing full word.
|
||||||
|
- The ability to display line numbers in front of the text (M-#).
|
||||||
|
|
||||||
|
Since 2.6.0:
|
||||||
|
- Shift plus the cursor keys can be used for selecting text.
|
||||||
|
- Ctrl+Arrow should now work also on a Linux virtual console.
|
||||||
|
- Ctrl+Up and Ctrl+Down jump to previous or next block of text.
|
||||||
|
- Feedback during Unicode Input (M-V followed by six digits).
|
||||||
|
- The option 'wordchars' for specifying extra word characters.
|
||||||
|
- Hi-bit control characters are shown in a more readable manner.
|
||||||
|
- The ability to use negative numbers at the Go To Line prompt.
|
||||||
|
- The ability to comment/uncomment lines with a single keystroke (M-3).
|
||||||
|
- The ability to refresh the file list in the browser (^L).
|
||||||
|
- The ability to abort re-searches (^C after an M-W).
|
||||||
|
- Better feedback at startup when opening large or multiple files.
|
||||||
|
|
||||||
|
Since 2.5.0:
|
||||||
|
- The option 'justifytrim' for snipping whitespace from justified lines.
|
||||||
|
- The ability to discard a buffer (^O ^Q) when --tempfile is used.
|
||||||
|
- On most terminals Ctrl+Left / Ctrl+Right now work for PrevWord/NextWord.
|
||||||
|
- When in the middle of a word, PrevWord now jumps to the start of this
|
||||||
|
word (like Pico does) instead of to the start of the preceding word.
|
||||||
|
- The ability to delete whole words with 'cutwordleft' and 'cutwordright'.
|
||||||
|
- The ability to save a file without prompting for its name ('savefile').
|
||||||
|
- The ability to search backward without having to toggle the direction.
|
||||||
|
|
||||||
|
Since 2.4.0:
|
||||||
|
- Replacing things in a marked region now takes place in situ, in context,
|
||||||
|
instead of changing the view to only the marked text.
|
||||||
|
- Invalid byte sequences are properly displayed and not mistakenly found.
|
||||||
|
- Resizing the window does not exit from help viewer nor file browser.
|
||||||
|
|
||||||
|
Since 2.3.0:
|
||||||
|
- System syntaxes can be improved upon with the 'extendsyntax' command.
|
||||||
|
- Whitespace display (M-P) does not require configuration to be useful.
|
||||||
|
- Undo/redo is enabled by default (M-U/M-E) and works nearly everywhere
|
||||||
|
-- just not yet for justifying and indenting/unindenting.
|
||||||
|
- The ability to color the title bar, the status bar and the help lines.
|
||||||
|
- The ability to run a linter or formatter (^T) on the current buffer.
|
||||||
|
- The ability to only write to named pipes with --noread.
|
||||||
|
- Determination of the applicable syntax through libmagic -- when the
|
||||||
|
file extension nor the first line give an answer.
|
||||||
|
- The option 'positionlog' for saving/restoring the cursor position.
|
||||||
|
- The ability to read and write vim-style lock files.
|
||||||
|
|
||||||
|
Since 2.0.0:
|
||||||
|
- The ability to rebind keys, via a nanorc file.
|
||||||
|
- The ability to read standard input like a pager ("nano -").
|
||||||
|
- Color syntax highlighting can be set by the first line of a file.
|
||||||
|
- The ability to silence nanorc error messages (-q).
|
||||||
|
- Undo/redo operations (M-U/M-E, enabled with -u).
|
||||||
|
- Soft wrapping of text (-$).
|
||||||
|
- Better handling of backup files: if nano can't write a backup file,
|
||||||
|
it won't try to write the original file afterward.
|
||||||
|
- Emergency savefiles retain ownerships and permissions when possible.
|
||||||
|
- Performance improvements in color syntax highlighting.
|
||||||
|
|
||||||
|
Since 1.2.0:
|
||||||
|
- Support for UTF-8.
|
||||||
|
- Moving to a specified line and column of a file, instead of just a
|
||||||
|
line (+LINE,COLUMN).
|
||||||
|
- Smart home key (-A).
|
||||||
|
- Creation of unique backup files in a specified directory (-C <dir>).
|
||||||
|
- Insertion of spaces instead of a tab when Tab is pressed (-E).
|
||||||
|
- The long option for -K is now --rebindkeypad.
|
||||||
|
- Regular expression searching can now be toggled when nano is built
|
||||||
|
with --enable-tiny, so -R now means something else (see next item).
|
||||||
|
- Restricted mode that provides more security than -o (-R).
|
||||||
|
- Blanking of the statusbar after 1 keystroke instead of 25 (-U).
|
||||||
|
- Word searches can optionally skip over punctuation (-W).
|
||||||
|
- Workaround for Delete's acting like Backspace (-d).
|
||||||
|
- Many more options are supported in the nanorc.
|
||||||
|
- Improvements to color syntax highlighting support: case insensitive
|
||||||
|
matching, the ability to include color syntaxes in separate files,
|
||||||
|
the ability to specify background colors without foreground colors...
|
||||||
|
- Insertion of single-byte characters via Esc Esc <000-255>.
|
||||||
|
- Insertion of any character via Meta-V, "Verbatim Input".
|
||||||
|
- Workaround for the "NumLock glitch".
|
||||||
|
- Meta-W now repeats the last search. Wrapping is toggled via Meta-L.
|
||||||
|
- Replacing and spell checking only selected text.
|
||||||
|
- Indenting lines with one keystroke.
|
||||||
|
- Copying text into the cutbuffer without cutting it.
|
||||||
|
- Scrolling the text up and down single lines without moving the cursor.
|
||||||
|
- PageUp and PageDown work more smoothly when using -S.
|
||||||
|
- Scrolling the help text up and down single lines.
|
||||||
|
- Cutting all text from the current position to the end of the file
|
||||||
|
with one keystroke (Meta-T).
|
||||||
|
- Justifying the entire file with one keystroke (Meta-J).
|
||||||
|
- Justifying without removing spaces from the ends of lines.
|
||||||
|
- Unjustifying after justifying and immediately resizing.
|
||||||
|
- Going to the first or last line of the current paragraph.
|
||||||
|
- Going to the first or last line of the file without having to go to
|
||||||
|
the "Search" prompt.
|
||||||
|
- Searching for filenames in the file browser.
|
||||||
|
- Spaces and tabs are shown differently to make it easier to tell them apart.
|
||||||
|
- Many more functions are available at the prompt: moving to the next or
|
||||||
|
previous word, searching for matching brackets, "Verbatim Input"...
|
||||||
|
- "To Line" (^W^T) and "Read from Command" (^R^X) return to their parent
|
||||||
|
menu when their keystroke is entered again (^W^T^T and ^R^X^X).
|
||||||
|
- Automatic adding of newlines to the ends of files without them can
|
||||||
|
now be disabled (-L).
|
||||||
|
- Converting from and to DOS/Mac file format is now toggled only at the
|
||||||
|
"Write File" prompt, via Meta-D and Meta-M, and the default file format
|
||||||
|
to save in is now set depending on what format the file was originally
|
||||||
|
in. -D now makes nano use bold text instead of reverse video text,
|
||||||
|
and Meta-D at the edit window now does a word/line/character count.
|
||||||
|
-O now makes the unused second line of the screen part of the edit
|
||||||
|
window, and Meta-O now toggles this behavior while editing.
|
||||||
|
- Converting files that contain a mix of DOS and Mac format lines.
|
||||||
|
- Automatic switching on of -N with binary files has been removed, as
|
||||||
|
it causes problems with UTF-8 support.
|
||||||
|
|
||||||
|
Since 1.0
|
||||||
|
- Complete Pico compatibility (option --pico has been removed,
|
||||||
|
and -p now means something else, see below).
|
||||||
|
- Support for nanorc files.
|
||||||
|
- Smooth scrolling (-S).
|
||||||
|
- Jumping to the matching brace, bracket, etc.
|
||||||
|
- Help for all editor features.
|
||||||
|
- Color syntax highlighting support.
|
||||||
|
- Quote string support, useful for mail agents, etc. (-Q).
|
||||||
|
- Insertion of output of external commands.
|
||||||
|
- Optional enabling of XON and XOFF control characters (-p).
|
||||||
|
- Option -o (--operatingdir) implements a chroot of sorts.
|
||||||
|
- Mouse support (-m) also allows clicking on shortcuts.
|
||||||
|
- Option -r allows a negative argument.
|
||||||
|
- Overwriting and appending or prepending to files.
|
||||||
|
- Writing marked text to separate files.
|
||||||
|
- Multiple file buffers (-F).
|
||||||
|
- Converting from and to DOS/Mac file format (-D/-M, -N to disable).
|
||||||
|
- Better control character handling.
|
||||||
|
- Creation of backup files (-B).
|
||||||
|
- Search/replace history (-H).
|
||||||
|
|
||||||
|
Available in 1.0:
|
||||||
|
- Spell checking (^T).
|
||||||
|
- Justification (^J) and unjustification (^U).
|
||||||
|
- Internationalization (more translations are welcome).
|
||||||
|
- Help texts (^G).
|
||||||
|
- Resizing in X.
|
||||||
|
- On PageUp/Down, the cursor is put on the first screen line (like Pico).
|
||||||
|
- Tab completion at the prompt (for filenames and ~user).
|
||||||
|
- Cut-to-end-of-line option (-k).
|
368
INSTALL
Normal file
368
INSTALL
Normal file
|
@ -0,0 +1,368 @@
|
||||||
|
Installation Instructions
|
||||||
|
*************************
|
||||||
|
|
||||||
|
Copyright (C) 1994-1996, 1999-2002, 2004-2016 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.
|
||||||
|
|
||||||
|
Basic Installation
|
||||||
|
==================
|
||||||
|
|
||||||
|
Briefly, the shell command './configure && make && make install'
|
||||||
|
should configure, build, and install this package. 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 *note Makefile Conventions: (standards)Makefile Conventions.
|
||||||
|
|
||||||
|
The 'configure' shell script attempts to guess correct values for
|
||||||
|
various system-dependent variables used during compilation. It uses
|
||||||
|
those values to create a 'Makefile' in each directory of the package.
|
||||||
|
It may also create one or more '.h' files containing system-dependent
|
||||||
|
definitions. Finally, it creates a shell script 'config.status' that
|
||||||
|
you can run in the future to recreate the current configuration, and a
|
||||||
|
file 'config.log' containing compiler output (useful mainly for
|
||||||
|
debugging 'configure').
|
||||||
|
|
||||||
|
It can also use an optional file (typically called 'config.cache' and
|
||||||
|
enabled with '--cache-file=config.cache' or simply '-C') that saves the
|
||||||
|
results of its tests to speed up reconfiguring. Caching is disabled by
|
||||||
|
default to prevent problems with accidental use of stale cache files.
|
||||||
|
|
||||||
|
If you need to do unusual things to compile the package, please try
|
||||||
|
to figure out how 'configure' could check whether to do them, and mail
|
||||||
|
diffs or instructions to the address given in the 'README' so they can
|
||||||
|
be considered for the next release. If you are using the cache, and at
|
||||||
|
some point 'config.cache' contains results you don't want to keep, you
|
||||||
|
may remove or edit it.
|
||||||
|
|
||||||
|
The file 'configure.ac' (or 'configure.in') is used to create
|
||||||
|
'configure' by a program called 'autoconf'. You need 'configure.ac' if
|
||||||
|
you want to change it or regenerate 'configure' using a newer version of
|
||||||
|
'autoconf'.
|
||||||
|
|
||||||
|
The simplest way to compile this package is:
|
||||||
|
|
||||||
|
1. 'cd' to the directory containing the package's source code and type
|
||||||
|
'./configure' to configure the package for your system.
|
||||||
|
|
||||||
|
Running 'configure' might take a while. While running, it prints
|
||||||
|
some messages telling which features it is checking for.
|
||||||
|
|
||||||
|
2. Type 'make' to compile the package.
|
||||||
|
|
||||||
|
3. Optionally, type 'make check' to run any self-tests that come with
|
||||||
|
the package, generally using the just-built uninstalled binaries.
|
||||||
|
|
||||||
|
4. 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.
|
||||||
|
|
||||||
|
5. 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.
|
||||||
|
|
||||||
|
6. You can remove the program binaries and object files from the
|
||||||
|
source code directory by typing 'make clean'. To also remove the
|
||||||
|
files that 'configure' created (so you can compile the package for
|
||||||
|
a different kind of computer), type 'make distclean'. There is
|
||||||
|
also a 'make maintainer-clean' target, but that is intended mainly
|
||||||
|
for the package's developers. If you use it, you may have to get
|
||||||
|
all sorts of other programs in order to regenerate files that came
|
||||||
|
with the distribution.
|
||||||
|
|
||||||
|
7. Often, you can also type 'make uninstall' to remove the installed
|
||||||
|
files again. In practice, not all packages have tested that
|
||||||
|
uninstallation works correctly, even though it is required by the
|
||||||
|
GNU Coding Standards.
|
||||||
|
|
||||||
|
8. Some packages, particularly those that use Automake, provide 'make
|
||||||
|
distcheck', which can by used by developers to test that all other
|
||||||
|
targets like 'make install' and 'make uninstall' work correctly.
|
||||||
|
This target is generally not run by end users.
|
||||||
|
|
||||||
|
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=c99 CFLAGS=-g LIBS=-lposix
|
||||||
|
|
||||||
|
*Note Defining Variables::, for more details.
|
||||||
|
|
||||||
|
Compiling For Multiple Architectures
|
||||||
|
====================================
|
||||||
|
|
||||||
|
You can compile the package for more than one kind of computer at the
|
||||||
|
same time, by placing the object files for each architecture in their
|
||||||
|
own directory. To do this, you 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
|
||||||
|
architecture at a time in the source code directory. After you have
|
||||||
|
installed the package for one architecture, use 'make distclean' before
|
||||||
|
reconfiguring for another architecture.
|
||||||
|
|
||||||
|
On MacOS X 10.5 and later systems, you can create libraries and
|
||||||
|
executables that work on multiple system types--known as "fat" or
|
||||||
|
"universal" binaries--by specifying multiple '-arch' options to the
|
||||||
|
compiler but only a single '-arch' option to the preprocessor. Like
|
||||||
|
this:
|
||||||
|
|
||||||
|
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||||
|
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||||
|
CPP="gcc -E" CXXCPP="g++ -E"
|
||||||
|
|
||||||
|
This is not guaranteed to produce working output in all cases, you
|
||||||
|
may have to build one architecture at a time and combine the results
|
||||||
|
using the 'lipo' tool if you have problems.
|
||||||
|
|
||||||
|
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' options to
|
||||||
|
'configure', where FEATURE indicates an optional part of the package.
|
||||||
|
They may also pay attention to '--with-PACKAGE' options, where PACKAGE
|
||||||
|
is something like 'gnu-as' or 'x' (for the X Window System). The
|
||||||
|
'README' should mention any '--enable-' and '--with-' options that the
|
||||||
|
package recognizes.
|
||||||
|
|
||||||
|
For packages that use the X Window System, 'configure' can usually
|
||||||
|
find the X include and library files automatically, but if it doesn't,
|
||||||
|
you can use the 'configure' options '--x-includes=DIR' and
|
||||||
|
'--x-libraries=DIR' to specify their locations.
|
||||||
|
|
||||||
|
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'.
|
||||||
|
|
||||||
|
Particular systems
|
||||||
|
==================
|
||||||
|
|
||||||
|
On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC
|
||||||
|
is not installed, it is recommended to use the following options in
|
||||||
|
order to use an ANSI C compiler:
|
||||||
|
|
||||||
|
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
|
||||||
|
|
||||||
|
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||||
|
|
||||||
|
HP-UX 'make' updates targets which have the same time stamps as their
|
||||||
|
prerequisites, which makes it generally unusable when shipped generated
|
||||||
|
files such as 'configure' are involved. Use GNU 'make' instead.
|
||||||
|
|
||||||
|
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
|
||||||
|
parse its '<wchar.h>' header file. The option '-nodtk' can be used as a
|
||||||
|
workaround. If GNU CC is not installed, it is therefore recommended to
|
||||||
|
try
|
||||||
|
|
||||||
|
./configure CC="cc"
|
||||||
|
|
||||||
|
and if that doesn't work, try
|
||||||
|
|
||||||
|
./configure CC="cc -nodtk"
|
||||||
|
|
||||||
|
On Solaris, don't put '/usr/ucb' early in your 'PATH'. This
|
||||||
|
directory contains several dysfunctional programs; working variants of
|
||||||
|
these programs are available in '/usr/bin'. So, if you need '/usr/ucb'
|
||||||
|
in your 'PATH', put it _after_ '/usr/bin'.
|
||||||
|
|
||||||
|
On Haiku, software installed for all users goes in '/boot/common',
|
||||||
|
not '/usr/local'. It is recommended to use the following options:
|
||||||
|
|
||||||
|
./configure --prefix=/boot/common
|
||||||
|
|
||||||
|
Specifying the System Type
|
||||||
|
==========================
|
||||||
|
|
||||||
|
There may be some features 'configure' cannot figure out
|
||||||
|
automatically, but needs to determine by the type of machine the package
|
||||||
|
will run on. Usually, assuming the package is built to be run on the
|
||||||
|
_same_ architectures, 'configure' can figure that out, but if it prints
|
||||||
|
a message saying it cannot guess the machine type, give it the
|
||||||
|
'--build=TYPE' option. TYPE can either be a short name for the system
|
||||||
|
type, such as 'sun4', or a canonical name which has the form:
|
||||||
|
|
||||||
|
CPU-COMPANY-SYSTEM
|
||||||
|
|
||||||
|
where SYSTEM can have one of these forms:
|
||||||
|
|
||||||
|
OS
|
||||||
|
KERNEL-OS
|
||||||
|
|
||||||
|
See the file 'config.sub' for the possible values of each field. If
|
||||||
|
'config.sub' isn't included in this package, then this package doesn't
|
||||||
|
need to know the machine type.
|
||||||
|
|
||||||
|
If you are _building_ compiler tools for cross-compiling, you should
|
||||||
|
use the option '--target=TYPE' to select the type of system they will
|
||||||
|
produce code for.
|
||||||
|
|
||||||
|
If you want to _use_ a cross compiler, that generates code for a
|
||||||
|
platform different from the build platform, you should specify the
|
||||||
|
"host" platform (i.e., that on which the generated programs will
|
||||||
|
eventually be run) with '--host=TYPE'.
|
||||||
|
|
||||||
|
Sharing Defaults
|
||||||
|
================
|
||||||
|
|
||||||
|
If you want to set default values for 'configure' scripts to share,
|
||||||
|
you can create a site shell script called 'config.site' that gives
|
||||||
|
default values for variables like 'CC', 'cache_file', and 'prefix'.
|
||||||
|
'configure' looks for 'PREFIX/share/config.site' if it exists, then
|
||||||
|
'PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||||
|
'CONFIG_SITE' environment variable to the location of the site script.
|
||||||
|
A warning: not all 'configure' scripts look for a site script.
|
||||||
|
|
||||||
|
Defining Variables
|
||||||
|
==================
|
||||||
|
|
||||||
|
Variables not defined in a site shell script can be set in the
|
||||||
|
environment passed to 'configure'. However, some packages may run
|
||||||
|
configure again during the build, and the customized values of these
|
||||||
|
variables may be lost. In order to avoid this problem, you should set
|
||||||
|
them in the 'configure' command line, using 'VAR=value'. For example:
|
||||||
|
|
||||||
|
./configure CC=/usr/local2/bin/gcc
|
||||||
|
|
||||||
|
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'.
|
||||||
|
|
||||||
|
'--quiet'
|
||||||
|
'--silent'
|
||||||
|
'-q'
|
||||||
|
Do not print messages saying which checks are being made. To
|
||||||
|
suppress all normal output, redirect it to '/dev/null' (any error
|
||||||
|
messages will still be shown).
|
||||||
|
|
||||||
|
'--srcdir=DIR'
|
||||||
|
Look for the package's source code in directory DIR. Usually
|
||||||
|
'configure' can determine that directory automatically.
|
||||||
|
|
||||||
|
'--prefix=DIR'
|
||||||
|
Use DIR as the installation prefix. *note Installation Names:: for
|
||||||
|
more details, including other options available for fine-tuning the
|
||||||
|
installation locations.
|
||||||
|
|
||||||
|
'--no-create'
|
||||||
|
'-n'
|
||||||
|
Run the configure checks, but stop before creating any output
|
||||||
|
files.
|
||||||
|
|
||||||
|
'configure' also accepts some other, not widely useful, options. Run
|
||||||
|
'configure --help' for more details.
|
17
Makefile.am
Normal file
17
Makefile.am
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
AUTOMAKE_OPTIONS = gnu no-dependencies
|
||||||
|
|
||||||
|
SUBDIRS = doc lib m4 po src
|
||||||
|
|
||||||
|
if USE_COLOR
|
||||||
|
SUBDIRS += syntax
|
||||||
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST = IMPROVEMENTS
|
||||||
|
|
||||||
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
|
showinfo:
|
||||||
|
@ echo
|
||||||
|
@ echo " The global nanorc file is: @sysconfdir@/nanorc"
|
||||||
|
@ echo " Syntaxes get installed in: @PKGDATADIR@/"
|
||||||
|
@ echo
|
2209
Makefile.in
Normal file
2209
Makefile.in
Normal file
File diff suppressed because it is too large
Load diff
122
README
Normal file
122
README
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
|
||||||
|
GNU nano -- a simple editor, inspired by Pico
|
||||||
|
|
||||||
|
Purpose
|
||||||
|
|
||||||
|
Nano is a small and simple text editor for use on the terminal.
|
||||||
|
It copied the interface and key bindings of the Pico editor but
|
||||||
|
added several missing features: undo/redo, syntax highlighting,
|
||||||
|
line numbers, softwrapping, multiple buffers, selecting text by
|
||||||
|
holding Shift, search-and-replace with regular expressions, and
|
||||||
|
several other conveniences.
|
||||||
|
|
||||||
|
Appearance
|
||||||
|
|
||||||
|
In rough ASCII graphics, this is what nano's screen looks like:
|
||||||
|
|
||||||
|
____________________________________________________________________
|
||||||
|
| GNU nano 7.2 filename Modified |
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
| This is the text window, displaying the contents of a 'buffer', |
|
||||||
|
| the contents of the file you are editing. |
|
||||||
|
| |
|
||||||
|
| The top row of the screen is the 'title bar'; it shows nano's |
|
||||||
|
| version, the name of the file, and whether you modified it. |
|
||||||
|
| The two bottom rows display the most important shortcuts; in |
|
||||||
|
| those lines ^ means Ctrl. The third row from the bottom shows |
|
||||||
|
| some feedback message, or gets replaced with a prompt bar when |
|
||||||
|
| you tell nano to do something that requires extra input. |
|
||||||
|
| |
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
| [ Some status message ] |
|
||||||
|
|^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute |
|
||||||
|
|^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify |
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
|
Origin
|
||||||
|
|
||||||
|
The nano project was started in 1999 because of a few "problems"
|
||||||
|
with the wonderfully easy-to-use and friendly Pico text editor.
|
||||||
|
|
||||||
|
First and foremost was its license: the Pine suite does not use
|
||||||
|
the GPL, and (before using the Apache License) it had unclear
|
||||||
|
restrictions on redistribution. Because of this, Pine and Pico
|
||||||
|
were not included in many GNU/Linux distributions. Furthermore,
|
||||||
|
some features (like go-to-line-number or search-and-replace) were
|
||||||
|
unavailable for a long time or require a command-line flag. Yuck.
|
||||||
|
|
||||||
|
Nano aimed to solve these problems by: 1) being truly free software
|
||||||
|
by using the GPL, 2) emulating the functionality of Pico as closely
|
||||||
|
as is reasonable, and 3) including extra functionality by default.
|
||||||
|
|
||||||
|
Nowadays, nano wants to be a generally useful editor with sensible
|
||||||
|
defaults (linewise scrolling, no automatic line breaking).
|
||||||
|
|
||||||
|
The nano editor is an official GNU package. For more information on
|
||||||
|
GNU and the Free Software Foundation, please see https://www.gnu.org/.
|
||||||
|
|
||||||
|
License
|
||||||
|
|
||||||
|
Nano's code and documentation are covered by the GPL version 3 or
|
||||||
|
(at your option) any later version, except for two functions that
|
||||||
|
were copied from busybox which are under a BSD license. Nano's
|
||||||
|
documentation is additionally covered by the GNU Free Documentation
|
||||||
|
License version 1.2 or (at your option) any later version. See the
|
||||||
|
files COPYING and COPYING.DOC for the full text of these licenses.
|
||||||
|
|
||||||
|
When in any file of this package a copyright notice mentions a
|
||||||
|
year range (such as 1999-2011), it is a shorthand for a list of
|
||||||
|
all the years in that interval.
|
||||||
|
|
||||||
|
How to compile and install nano
|
||||||
|
|
||||||
|
Download the latest nano source tarball, and then:
|
||||||
|
|
||||||
|
tar -xvf nano-x.y.tar.gz
|
||||||
|
cd nano-x.y
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
|
||||||
|
You will need the header files of ncurses installed for ./configure
|
||||||
|
to succeed -- get them from libncurses-dev (Debian) or ncurses-devel
|
||||||
|
(Fedora) or a similarly named package. Use --prefix with ./configure
|
||||||
|
to override the default installation directory of /usr/local.
|
||||||
|
|
||||||
|
After installation you may want to copy the doc/sample.nanorc file
|
||||||
|
to your home directory, rename it to ".nanorc", and then edit it
|
||||||
|
according to your taste.
|
||||||
|
|
||||||
|
Web Page
|
||||||
|
|
||||||
|
https://nano-editor.org/
|
||||||
|
|
||||||
|
Mailing Lists
|
||||||
|
|
||||||
|
There are three nano-related mailing-lists.
|
||||||
|
|
||||||
|
* <info-nano@gnu.org> is a very low traffic list used to announce
|
||||||
|
new nano versions or other important info about the project.
|
||||||
|
|
||||||
|
* <help-nano@gnu.org> is for those seeking to get help without
|
||||||
|
wanting to hear about the technical details of its development.
|
||||||
|
|
||||||
|
* <nano-devel@gnu.org> is the list used by the people that make nano
|
||||||
|
and a general development discussion list, with moderate traffic.
|
||||||
|
|
||||||
|
To subscribe, send email to <name>-request@gnu.org with a subject
|
||||||
|
of "subscribe", where <name> is the list you want to subscribe to.
|
||||||
|
|
||||||
|
The archives of the development and help mailing lists are here:
|
||||||
|
|
||||||
|
https://lists.gnu.org/archive/html/nano-devel/
|
||||||
|
https://lists.gnu.org/archive/html/help-nano/
|
||||||
|
|
||||||
|
Bug Reports
|
||||||
|
|
||||||
|
If you find a bug, please file a detailed description of the problem
|
||||||
|
on nano's issue tracker: https://savannah.gnu.org/bugs/?group=nano
|
||||||
|
(you will need an account to be able to do so), or send an email
|
||||||
|
to the nano-devel list (no need to subscribe, but mention it if
|
||||||
|
you want to be CC'ed on an answer).
|
||||||
|
|
106
THANKS
Normal file
106
THANKS
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
The following people have helped GNU nano in some way or another.
|
||||||
|
If we missed you here, let us know!
|
||||||
|
|
||||||
|
|
||||||
|
Translations:
|
||||||
|
============
|
||||||
|
Pedro Albuquerque <palbuquerque73@gmail.com> Portuguese
|
||||||
|
Josef Andersson <josef.andersson@fripost.org> Swedish
|
||||||
|
Mario Blättermann <mario.blaettermann@gmail.com> German
|
||||||
|
Besnik Bleta <besnik@programeshqip.org> Albanian
|
||||||
|
Laurențiu Buzdugan <buzdugan@voyager.net> Romanian
|
||||||
|
Ricardo Cárdenes Medina <ricardo@conisys.com> Spanish
|
||||||
|
Antonio Ceballos <aceballos@gmail.com> Spanish
|
||||||
|
Wei-Lun CHAO <chaoweilun@pcmail.com.tw> Chinese (traditional)
|
||||||
|
Seong-ho Cho <darkcircle.0426@gmail.com> Korean
|
||||||
|
Yuri Chornoivan <yurchor@ukr.net> Ukrainian
|
||||||
|
Marco Colombo <magicdice@inwind.it> Italian
|
||||||
|
Mihai Cristescu <mihai.cristescu@archlinux.info> Romanian
|
||||||
|
Yavor Doganov <yavor@doganov.org> Bulgarian
|
||||||
|
Karl Eichwalder <keichwa@gmx.net> German
|
||||||
|
A. Murat EREN <meren@comu.edu.tr> Turkish
|
||||||
|
Sveinn í Felli <sv1@fellsnet.is> Icelandic
|
||||||
|
Marek Felšöci <marek@felsoci.sk> Slovak
|
||||||
|
Doruk Fisek <dfisek@fisek.com.tr> Turkish
|
||||||
|
Rafael Fontenelle <rffontenelle@gmail.com> Brazilian Portuguese
|
||||||
|
Pavel Fric <pavelfric@seznam.cz> Czech
|
||||||
|
Jorge González <aloriel@gmail.com> Spanish
|
||||||
|
Jean-Philippe Guérard <jean-philippe.guerard@laposte.net> French
|
||||||
|
Václav Haisman <V.Haisman@sh.cvut.cz> Czech
|
||||||
|
Takeshi Hamasaki <hmatrjp@users.sourceforge.jp> Japanese
|
||||||
|
Geir Helland <pjallabais@users.sourceforge.net> Norwegian Bokmål
|
||||||
|
Tedi Heriyanto <tedi_h@gmx.net> Indonesian
|
||||||
|
Kjetil Torgrim Homme <kjetilho@linpro.no> Norwegian Nynorsk
|
||||||
|
Szabolcs Horvath <horvaths@janus.gimsz.sulinet.hu> Hungarian
|
||||||
|
Jorma Karvonen <karvonen.jorma@gmail.com> Finnish
|
||||||
|
Mehmet Kececi <mkececi@mehmetkececi.com> Turkish
|
||||||
|
Gabor Kelemen <kelemeng@gnome.hu> Hungarian
|
||||||
|
Kalle Kivimaa <kalle.kivimaa@iki.fi> Finnish
|
||||||
|
Eivind Kjørstad <ekj@vestdata.no> Norwegian Nynorsk
|
||||||
|
Florian König <floki@bigfoot.com> German
|
||||||
|
Klemen Košir <klemen913@gmail.com> Slovenian
|
||||||
|
Wojciech Kotwica <wkotwica@post.pl> Polish
|
||||||
|
Clement Laforet <clem_laf@wanadoo.fr> French
|
||||||
|
Ask Hjorth Larsen <asklarsen@gmail.com> Danish
|
||||||
|
LI Daobing <lidaobing@gmail.com> Chinese (simplified)
|
||||||
|
Jordi Mallach <jordi@gnu.org> Catalan
|
||||||
|
João Victor Duarte Martins <jvdm@sdf.lonestar.org> Brazilian Portuguese
|
||||||
|
Pavel Maryanov <acid@jack.kiev.ua> Russian
|
||||||
|
Daniele Medri <madrid@linux.it> Italian
|
||||||
|
Gergely Nagy <algernon@debian.org> Hungarian
|
||||||
|
Claudio Neves <cneves@nextis.com> Brazilian Portuguese
|
||||||
|
Kalle Olavi Niemitalo <kon@iki.fi> Finnish
|
||||||
|
Мирослав Николић <miroslavnikolic@rocketmail.com> Serbian
|
||||||
|
Lauri Nurmi <lanurmi@iki.fi> Finnish
|
||||||
|
Daniel Nylander <po@danielnylander.se> Swedish
|
||||||
|
Mikel Olasagasti <hey_neken@mundurat.net> Basque
|
||||||
|
Yi-Jyun Pan <pan93412@gmail.com> Chinese (traditional)
|
||||||
|
Michael Piefel <piefel@informatik.hu-berlin.de> German
|
||||||
|
Sergey Poznyakoff <gray@gnu.org> Polish
|
||||||
|
Božidar Putanec <bozidarp@yahoo.com> Croatian
|
||||||
|
Trần Ngọc Quân <vnwildman@gmail.com> Vietnamese
|
||||||
|
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com> Malay
|
||||||
|
Sergey A. Ribalchenko <fisher@obu.ck.ua> Ukrainian and Russian
|
||||||
|
Michel Robitaille <robitail@IRO.UMontreal.CA> French
|
||||||
|
Christian Rose <menthos@menthos.com> Swedish
|
||||||
|
Dimitriy Ryazantcev <DJm00n@mail.ru> Russian
|
||||||
|
Stig E Sandø <stig@ii.uib.no> Norwegian Bokmål
|
||||||
|
Kevin Patrick Scannell <kscanne@gmail.com> Irish
|
||||||
|
Benno Schulenberg <benno@vertaalt.nl> Dutch and Esperanto
|
||||||
|
Danilo Segan <dsegan@gmx.net> Serbian
|
||||||
|
Clytie Siddall <clytie@riverland.net.au> Vietnamese
|
||||||
|
Keld Simonsen <keld@dkuug.dk> Danish
|
||||||
|
Guus Sliepen <guus@nl.linux.org> Dutch
|
||||||
|
Cezary Sliwa <sliwa@cft.edu.pl> Polish
|
||||||
|
Johnny A. Solbu <johnny@solbu.net> Norwegian Bokmål
|
||||||
|
Pierre Tane <tanep@bigfoot.com> French
|
||||||
|
Yasuaki Taniguchi <yasuakit@gmail.com> Japanese
|
||||||
|
Jacobo Tarrío <jtarrio@trasno.net> Galician
|
||||||
|
Andika Triwidada <andika@gmail.com> Indonesian
|
||||||
|
Francisco Javier Tsao Santín <tsao@members.fsf.org> Galician
|
||||||
|
Balázs Úr <urbalazs@gmail.com> Hungarian
|
||||||
|
Miquel Vidal <miquel@sindominio.net> Catalan
|
||||||
|
Phan Vinh Thinh <teppi82@gmail.com> Vietnamese
|
||||||
|
Pauli Virtanen <pauli.virtanen@saunalahti.fi> Finnish
|
||||||
|
Aron Xu <happyaron.xu@gmail.com> Chinese (simplified)
|
||||||
|
Boyuan Yang <073plan@gmail.com> Chinese (simplified)
|
||||||
|
Peio Ziarsolo <peio@sindominio.net> Basque
|
||||||
|
Anton Zinoviev <zinoviev@debian.org> Bulgarian
|
||||||
|
|
||||||
|
|
||||||
|
Other stuff:
|
||||||
|
===========
|
||||||
|
Ben Armstrong <synrg@sanctuary.nslug.ns.ca> Negative -r value idea, code
|
||||||
|
Thomas Dickey <dickey@herndon4.his.com> Curses help and advice
|
||||||
|
Kamil Dudka <kdudka@redhat.com> Several small bug fixes
|
||||||
|
Sven Guckes <guckes@math.fu-berlin.de> Advice and advocacy
|
||||||
|
Thijs Kinkhorst <thijs@kinkhorst.com> rnano.1 manpage
|
||||||
|
Jim Knoble <jmknoble@pobox.com> Pico compat for browser
|
||||||
|
Ryan Krebs <fluffy@highwire.stanford.edu> Many bug fixes and testing
|
||||||
|
Roy Lanek <lanek@ranahminang.net> Advice and advocacy
|
||||||
|
Chuck Mead <csm@MoonGroup.com> Feedback and RPM stuff
|
||||||
|
Mike Melanson <melanson@pcisys.net> Bug reports
|
||||||
|
Neil Parks <nparks@acsmail.com> Bug reports and fixes
|
||||||
|
Jeremy Robichaud <robicj@yahoo.com> Beta tester
|
||||||
|
Bill Soudan <wes0472@rit.edu> Regex code, etc
|
||||||
|
Ken Tyler <kent@werple.net.au> Search fixes and more
|
5
TODO
Normal file
5
TODO
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
For a list of open bugs and requested features see:
|
||||||
|
|
||||||
|
https://savannah.gnu.org/bugs/?group=nano
|
||||||
|
|
1622
aclocal.m4
vendored
Normal file
1622
aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load diff
348
compile
Normal file
348
compile
Normal file
|
@ -0,0 +1,348 @@
|
||||||
|
#! /bin/sh
|
||||||
|
# Wrapper for compilers which do not understand '-c -o'.
|
||||||
|
|
||||||
|
scriptversion=2018-03-07.03; # UTC
|
||||||
|
|
||||||
|
# Copyright (C) 1999-2020 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 | *.[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>.
|
||||||
|
EOF
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
-v | --v*)
|
||||||
|
echo "compile $scriptversion"
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
cl | *[/\\]cl | cl.exe | *[/\\]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:
|
1480
config.guess
vendored
Normal file
1480
config.guess
vendored
Normal file
File diff suppressed because it is too large
Load diff
2385
config.h.in
Normal file
2385
config.h.in
Normal file
File diff suppressed because it is too large
Load diff
690
config.rpath
Normal file
690
config.rpath
Normal file
|
@ -0,0 +1,690 @@
|
||||||
|
#! /bin/sh
|
||||||
|
# Output a system dependent set of variables, describing how to set the
|
||||||
|
# run time search path of shared libraries in an executable.
|
||||||
|
#
|
||||||
|
# Copyright 1996-2013 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.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# 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.2*)
|
||||||
|
hardcode_libdir_flag_spec='-R$libdir'
|
||||||
|
hardcode_direct=yes
|
||||||
|
;;
|
||||||
|
freebsd2*)
|
||||||
|
hardcode_direct=yes
|
||||||
|
hardcode_minus_L=yes
|
||||||
|
;;
|
||||||
|
freebsd* | dragonfly*)
|
||||||
|
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* | dragonfly*)
|
||||||
|
case "$host_os" in
|
||||||
|
freebsd[123]*)
|
||||||
|
library_names_spec='$libname$shrext$versuffix' ;;
|
||||||
|
*)
|
||||||
|
library_names_spec='$libname$shrext' ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
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
|
1801
config.sub
vendored
Normal file
1801
config.sub
vendored
Normal file
File diff suppressed because it is too large
Load diff
600
configure.ac
Normal file
600
configure.ac
Normal file
|
@ -0,0 +1,600 @@
|
||||||
|
# Configuration for GNU nano - a small and user-friendly text editor
|
||||||
|
#
|
||||||
|
# Copyright (C) 1999-2011, 2013-2023 Free Software Foundation, Inc.
|
||||||
|
# Copyright (C) 2014, 2017 Mike Frysinger
|
||||||
|
#
|
||||||
|
# GNU nano 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.
|
||||||
|
#
|
||||||
|
# GNU nano is distributed in the hope that 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/.
|
||||||
|
|
||||||
|
AC_INIT([GNU nano], [7.2], [nano-devel@gnu.org], [nano])
|
||||||
|
AC_CONFIG_SRCDIR([src/nano.c])
|
||||||
|
AC_CANONICAL_HOST
|
||||||
|
AM_INIT_AUTOMAKE([1.14])
|
||||||
|
AM_MAINTAINER_MODE([enable])
|
||||||
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
||||||
|
dnl Make sure the ONCE macros are available.
|
||||||
|
|
||||||
|
AC_PREREQ([2.69])
|
||||||
|
|
||||||
|
dnl Lie about gnulib features we don't use to speed up & shrink down.
|
||||||
|
|
||||||
|
gl_cv_func_printf_directive_n=yes
|
||||||
|
gl_cv_func_printf_infinite_long_double=yes
|
||||||
|
gl_cv_func_printf_long_double=yes
|
||||||
|
gl_cv_func_snprintf_directive_n=yes
|
||||||
|
gl_cv_glob_lists_symlinks=yes
|
||||||
|
|
||||||
|
dnl Checks for programs.
|
||||||
|
|
||||||
|
AC_USE_SYSTEM_EXTENSIONS
|
||||||
|
AC_PROG_CC
|
||||||
|
gl_EARLY
|
||||||
|
gl_INIT
|
||||||
|
AC_PROG_LN_S
|
||||||
|
AC_SEARCH_LIBS([strerror], [cposix])
|
||||||
|
AC_SYS_LARGEFILE
|
||||||
|
PKG_PROG_PKG_CONFIG
|
||||||
|
|
||||||
|
dnl Internationalization macros.
|
||||||
|
|
||||||
|
AM_GNU_GETTEXT_VERSION([0.18.3])
|
||||||
|
AM_GNU_GETTEXT([external], [need-ngettext])
|
||||||
|
AM_CONDITIONAL(USE_NLS, test x$USE_NLS = xyes)
|
||||||
|
|
||||||
|
dnl Data location.
|
||||||
|
|
||||||
|
pkgdatadir=${datadir}/${PACKAGE}
|
||||||
|
AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
|
||||||
|
|
||||||
|
dnl Whether this is a git repository.
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether building from git])
|
||||||
|
if test -f "$srcdir/roll-a-release.sh" ; then
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
from_git=yes
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
from_git=no
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
|
||||||
|
|
||||||
|
dnl Checks for pkg-config and gettext when building from git.
|
||||||
|
|
||||||
|
if test x$from_git = xyes; then
|
||||||
|
if test ! -f $(aclocal --print-ac-dir)/pkg.m4; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** The pkg.m4 macros are missing.
|
||||||
|
*** The pkg-config package needs to be installed when building from git.
|
||||||
|
*** After fixing this problem, rerun ./autogen.sh.])
|
||||||
|
fi
|
||||||
|
if test "$ac_cv_path_MSGFMT" = ":"; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** The msgfmt program is missing.
|
||||||
|
*** The gettext package needs to be installed when building from git.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Checks for header files.
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
|
||||||
|
|
||||||
|
dnl Checks for options.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(browser,
|
||||||
|
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_browser" != xyes; then
|
||||||
|
enable_browser=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_browser" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_BROWSER, 1, [Define this to enable the built-in file browser.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(color,
|
||||||
|
AS_HELP_STRING([--disable-color], [Disable color and syntax highlighting]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_color" = xyes; then
|
||||||
|
if test "x$enable_nanorc" != xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-color needs --enable-nanorc to work])
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
enable_color=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_nanorc" = xno; then
|
||||||
|
if test "x$enable_color" = xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-color cannot work with --disable-nanorc])
|
||||||
|
else
|
||||||
|
# Disabling nanorc silently disables color support.
|
||||||
|
enable_color=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_color" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_COLOR, 1, [Define this to have syntax highlighting.])
|
||||||
|
color_support=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(comment,
|
||||||
|
AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_comment" = xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-comment cannot work with --enable-tiny])
|
||||||
|
else
|
||||||
|
enable_comment=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_comment" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to enable the comment/uncomment function.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(extra,
|
||||||
|
AS_HELP_STRING([--disable-extra], [Disable the Easter egg]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_extra" != xyes; then
|
||||||
|
enable_extra=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_extra" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_EXTRA, 1, [Define this to have an Easter egg.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(formatter,
|
||||||
|
AS_HELP_STRING([--disable-formatter], [Disable the formatting tool]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_formatter" = xyes; then
|
||||||
|
if test "x$enable_color" != xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-formatter needs both --enable-color and --enable-nanorc to work])
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
enable_formatter=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_color" = xno; then
|
||||||
|
if test "x$enable_formatter" = xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-formatter cannot work with --disable-color nor --disable-nanorc])
|
||||||
|
else
|
||||||
|
enable_formatter=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_formatter" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_FORMATTER, 1, [Define this to have access to a formatter.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(help,
|
||||||
|
AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_help" = xyes; then
|
||||||
|
if test "x$enable_multibuffer" != xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-help needs --enable-multibuffer to work])
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
enable_help=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_multibuffer" = xno; then
|
||||||
|
if test "x$enable_help" = xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-help cannot work with --disable-multibuffer])
|
||||||
|
else
|
||||||
|
# Disabling multibuffer silently disables the help texts.
|
||||||
|
enable_help=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_help" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_HELP, 1, [Define this to enable the Ctrl+G help texts.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(histories,
|
||||||
|
AS_HELP_STRING([--disable-histories], [Disable search and position histories]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_histories" != xyes; then
|
||||||
|
enable_histories=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_histories" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_HISTORIES, 1, [Define this to have search and position histories.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(justify,
|
||||||
|
AS_HELP_STRING([--disable-justify], [Disable the justify/unjustify functions]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_justify" != xyes; then
|
||||||
|
enable_justify=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_justify" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_JUSTIFY, 1, [Define this to have the routines for justifying.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(libmagic,
|
||||||
|
AS_HELP_STRING([--disable-libmagic], [Disable detection of file types via libmagic]))
|
||||||
|
if test "x$enable_libmagic" = xyes; then
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_color" != xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-libmagic needs both --enable-color and --enable-nanorc to work])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_color" = xno; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-libmagic cannot work with --disable-color nor --disable-nanorc])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(linter,
|
||||||
|
AS_HELP_STRING([--disable-linter], [Disable the linting tool]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_linter" = xyes; then
|
||||||
|
if test "x$enable_color" != xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-linter needs both --enable-color and --enable-nanorc to work])
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
enable_linter=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_color" = xno; then
|
||||||
|
if test "x$enable_linter" = xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-linter cannot work with --disable-color nor --disable-nanorc])
|
||||||
|
else
|
||||||
|
enable_linter=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_linter" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_LINTER, 1, [Define this to have access to a linter.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(linenumbers,
|
||||||
|
AS_HELP_STRING([--disable-linenumbers], [Disable line numbering]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_linenumbers" != xyes; then
|
||||||
|
enable_linenumbers=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_linenumbers" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_LINENUMBERS, 1, [Define this to enable line numbering.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(mouse,
|
||||||
|
AS_HELP_STRING([--disable-mouse], [Disable mouse support]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_mouse" != xyes; then
|
||||||
|
enable_mouse=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_mouse" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_MOUSE, 1, [Define this to enable mouse support.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(multibuffer,
|
||||||
|
AS_HELP_STRING([--disable-multibuffer], [Disable multiple file buffers]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_multibuffer" != xyes; then
|
||||||
|
enable_multibuffer=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_multibuffer" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(nanorc,
|
||||||
|
AS_HELP_STRING([--disable-nanorc], [Disable the use of .nanorc files]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_nanorc" != xyes; then
|
||||||
|
enable_nanorc=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_nanorc" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_NANORC, 1, [Define this to enable the use of .nanorc files.])
|
||||||
|
nanorc_support=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(operatingdir,
|
||||||
|
AS_HELP_STRING([--disable-operatingdir], [Disable the setting of an operating directory]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_operatingdir" != xyes; then
|
||||||
|
enable_operatingdir=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_operatingdir" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_OPERATINGDIR, 1, [Define this to allow setting an operating directory (a chroot of sorts).])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(speller,
|
||||||
|
AS_HELP_STRING([--disable-speller], [Disable the spell-checking tool]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_speller" != xyes; then
|
||||||
|
enable_speller=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_speller" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_SPELLER, 1, [Define this to have access to a spell checker.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(tabcomp,
|
||||||
|
AS_HELP_STRING([--disable-tabcomp], [Disable the tab-completion functions]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_tabcomp" != xyes; then
|
||||||
|
enable_tabcomp=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_tabcomp" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_TABCOMP, 1, [Define this to have tab completion for filenames and search strings.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(wordcomp,
|
||||||
|
AS_HELP_STRING([--disable-wordcomp], [Disable the word-completion function]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_wordcomp" = xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** --enable-wordcomp cannot work with --enable-tiny])
|
||||||
|
else
|
||||||
|
enable_wordcomp=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_wordcomp" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word-completion function.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(wrapping,
|
||||||
|
AS_HELP_STRING([--disable-wrapping], [Disable all hard-wrapping of text]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
if test "x$enable_wrapping" != xyes; then
|
||||||
|
enable_wrapping=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_wrapping" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_WRAPPING, 1, [Define this to have hard text wrapping.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(debug,
|
||||||
|
AS_HELP_STRING([--enable-debug], [Enable debugging (disabled by default)]))
|
||||||
|
if test "x$enable_debug" = xyes; then
|
||||||
|
AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and abortion on failing asserts.])
|
||||||
|
else
|
||||||
|
AC_DEFINE(NDEBUG, 1, [Shut up assert warnings :-)])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(tiny,
|
||||||
|
AS_HELP_STRING([--enable-tiny], [Disable features for the sake of size]))
|
||||||
|
if test "x$enable_tiny" = xyes; then
|
||||||
|
AC_DEFINE(NANO_TINY, 1, [Define this to make the nano executable as small as possible.])
|
||||||
|
if test "x$enable_libmagic" != xyes; then
|
||||||
|
enable_libmagic=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
AM_CONDITIONAL(USE_COLOR, test x$color_support = xyes)
|
||||||
|
AM_CONDITIONAL(USE_NANORC, test x$nanorc_support = xyes)
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether to enable UTF-8 support])
|
||||||
|
AC_ARG_ENABLE(utf8, AS_HELP_STRING([--enable-utf8], [Enable UTF-8 support]))
|
||||||
|
AC_MSG_RESULT(${enable_utf8:-auto})
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(altrcname,
|
||||||
|
AS_HELP_STRING([--enable-altrcname], [Specify an alternate rcfile name (default: .nanorc)]),
|
||||||
|
[if test x$enableval != no; then
|
||||||
|
AC_DEFINE_UNQUOTED(RCFILE_NAME, "$enableval", [Specify an alternate rcfile name (default: .nanorc).]) rcfilename=$enableval
|
||||||
|
fi])
|
||||||
|
|
||||||
|
dnl Checks for functions.
|
||||||
|
|
||||||
|
if test "x$enable_utf8" != xno; then
|
||||||
|
AC_CHECK_FUNCS(iswalpha iswalnum iswpunct mbstowcs wctomb)
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS_ONCE(chmod chown fchmod fchown flockfile funlockfile
|
||||||
|
fork fsync geteuid pipe wait waitpid)
|
||||||
|
|
||||||
|
dnl Checks for available flags.
|
||||||
|
|
||||||
|
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])
|
||||||
|
|
||||||
|
dnl Checks for libraries.
|
||||||
|
|
||||||
|
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||||
|
if test "x$enable_utf8" != xno; then
|
||||||
|
PKG_CHECK_MODULES([NCURSESW], [ncursesw], [
|
||||||
|
CURSES_LIB=$NCURSESW_LIBS
|
||||||
|
CPPFLAGS="$NCURSESW_CFLAGS $CPPFLAGS"
|
||||||
|
CURSES_LIB_NAME=ncursesw
|
||||||
|
CURSES_LIB_WIDE=yes
|
||||||
|
], [:])
|
||||||
|
else
|
||||||
|
PKG_CHECK_MODULES([NCURSES], [ncurses], [
|
||||||
|
CURSES_LIB=$NCURSES_LIBS
|
||||||
|
CPPFLAGS="$NCURSES_CFLAGS $CPPFLAGS"
|
||||||
|
CURSES_LIB_NAME=ncurses
|
||||||
|
], [:])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||||
|
AC_CHECK_HEADERS(ncurses.h)
|
||||||
|
|
||||||
|
if test "x$enable_utf8" != xno; then
|
||||||
|
OLDLIBS="$LIBS"
|
||||||
|
AC_CHECK_TOOL(NCURSESW_CONFIG, ncursesw5-config, no)
|
||||||
|
if test "x$NCURSESW_CONFIG" != xno; then
|
||||||
|
CURSES_LIB=`$NCURSESW_CONFIG --libs`
|
||||||
|
LIBS="$CURSES_LIB $LIBS"
|
||||||
|
CPPFLAGS="`$NCURSESW_CONFIG --cflags` $CPPFLAGS"
|
||||||
|
AC_CHECK_LIB(ncursesw, wget_wch, [CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
|
||||||
|
else
|
||||||
|
AC_CHECK_LIB(ncursesw, wget_wch, [CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
|
||||||
|
fi
|
||||||
|
LIBS="$OLDLIBS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||||
|
AC_CHECK_LIB(ncurses, initscr, [CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||||
|
AC_CHECK_HEADERS(curses.h)
|
||||||
|
|
||||||
|
if test "x$enable_utf8" != xno; then
|
||||||
|
AC_CHECK_LIB(curses, wget_wch, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses CURSES_LIB_WIDE=yes])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||||
|
AC_CHECK_LIB(curses, initscr, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** No curses lib was found. Please install the curses header files
|
||||||
|
*** from libncurses-dev (Debian), ncurses-devel (Fedora), or similar.
|
||||||
|
*** (Or install ncurses from https://ftp.gnu.org/gnu/ncurses/.)])
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT([ The curses library to be used is: $CURSES_LIB_NAME])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
|
||||||
|
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() function.])],
|
||||||
|
[], [$CURSES_LIB])
|
||||||
|
AC_CHECK_LIB([$CURSES_LIB_NAME], [set_escdelay],
|
||||||
|
[AC_DEFINE(HAVE_SET_ESCDELAY, 1, [Define this if your curses library has the set_escdelay() function.])],
|
||||||
|
[], [$CURSES_LIB])
|
||||||
|
AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
|
||||||
|
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() function.])],
|
||||||
|
[], [$CURSES_LIB])
|
||||||
|
|
||||||
|
LIBS="$LIBS $CURSES_LIB"
|
||||||
|
|
||||||
|
AC_SUBST(CURSES_LIB)
|
||||||
|
|
||||||
|
if test "x$enable_utf8" != xno && \
|
||||||
|
test x$CURSES_LIB_WIDE = xyes && \
|
||||||
|
test x$ac_cv_func_iswalpha = xyes && \
|
||||||
|
test x$ac_cv_func_iswalnum = xyes && \
|
||||||
|
test x$ac_cv_func_iswpunct = xyes && \
|
||||||
|
test x$ac_cv_func_mbstowcs = xyes && \
|
||||||
|
test x$ac_cv_func_wctomb = xyes; then
|
||||||
|
AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support.])
|
||||||
|
else
|
||||||
|
if test "x$enable_utf8" = xyes; then
|
||||||
|
AC_MSG_ERROR([
|
||||||
|
*** UTF-8 support was requested, but insufficient support was
|
||||||
|
*** detected in your curses and/or C libraries. Please verify
|
||||||
|
*** that both your curses library and your C library were built
|
||||||
|
*** with wide-character support.])
|
||||||
|
elif test "x$enable_utf8" != xno; then
|
||||||
|
AC_MSG_WARN([
|
||||||
|
*** Insufficient UTF-8 support was detected in your curses
|
||||||
|
*** and/or C libraries. If you want UTF-8 support, please
|
||||||
|
*** verify that both your curses library and your C library
|
||||||
|
*** were built with wide-character support.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([for enhanced regular expression flag], nano_cv_flag_reg_enhanced,
|
||||||
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <regex.h>]],
|
||||||
|
[[
|
||||||
|
#ifndef REG_ENHANCED
|
||||||
|
error: No REG_ENHANCED support!
|
||||||
|
#endif
|
||||||
|
]])],
|
||||||
|
[nano_cv_flag_reg_enhanced=yes],
|
||||||
|
[nano_cv_flag_reg_enhanced=no])])
|
||||||
|
dnl The bundled gnulib regex module doesn't support REG_ENHANCED.
|
||||||
|
if test "$ac_use_included_regex" = "yes"; then
|
||||||
|
nano_cv_flag_reg_enhanced="no"
|
||||||
|
fi
|
||||||
|
if test "$nano_cv_flag_reg_enhanced" = "yes"; then
|
||||||
|
nano_reg_extended="REG_EXTENDED | REG_ENHANCED"
|
||||||
|
else
|
||||||
|
nano_reg_extended="REG_EXTENDED"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_reg_extended,
|
||||||
|
[Flag(s) to use to get the full range of extended regular expressions])
|
||||||
|
|
||||||
|
if test x$color_support = xyes; then
|
||||||
|
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
|
||||||
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||||
|
#include <curses.h>
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int testcolor = COLOR_WHITE;
|
||||||
|
return 0;
|
||||||
|
}]])],
|
||||||
|
AC_MSG_RESULT(no),
|
||||||
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||||
|
#ifndef _XOPEN_SOURCE_EXTENDED
|
||||||
|
#define _XOPEN_SOURCE_EXTENDED 1
|
||||||
|
#endif
|
||||||
|
#include <curses.h>
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int testcolor = COLOR_WHITE;
|
||||||
|
return 0;
|
||||||
|
}]])],
|
||||||
|
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support.])
|
||||||
|
AC_MSG_RESULT(yes),
|
||||||
|
AC_MSG_RESULT(not sure)
|
||||||
|
AC_MSG_WARN([
|
||||||
|
*** Couldn't successfully compile basic color test with or without
|
||||||
|
*** _XOPEN_SOURCE_EXTENDED. This build may not compile. Consider
|
||||||
|
*** configuring with --disable-color or installing ncurses.])),
|
||||||
|
AC_MSG_WARN([
|
||||||
|
*** Can't check need for _XOPEN_SOURCE_EXTENDED when cross-compiling.]))
|
||||||
|
fi
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_libmagic" != "xno"], [
|
||||||
|
AC_CHECK_HEADERS([magic.h])
|
||||||
|
AC_CHECK_LIB(magic, magic_open)
|
||||||
|
AC_CHECK_HEADERS([zlib.h])
|
||||||
|
AC_CHECK_LIB(z, inflate)
|
||||||
|
])
|
||||||
|
|
||||||
|
# Check for groff html support.
|
||||||
|
AC_MSG_CHECKING([for HTML support in groff])
|
||||||
|
groff -t -mandoc -Thtml </dev/null >/dev/null
|
||||||
|
if test $? -ne 0 ; then
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
AC_MSG_WARN([
|
||||||
|
*** Will not generate HTML version of man pages. Consider
|
||||||
|
*** installing a newer version of groff with HTML support.])
|
||||||
|
groff_html_support=no
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
groff_html_support=yes
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)
|
||||||
|
|
||||||
|
AC_CONFIG_FILES([
|
||||||
|
Makefile
|
||||||
|
doc/Makefile
|
||||||
|
doc/sample.nanorc
|
||||||
|
lib/Makefile
|
||||||
|
m4/Makefile
|
||||||
|
po/Makefile.in
|
||||||
|
src/Makefile
|
||||||
|
syntax/Makefile
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_OUTPUT
|
||||||
|
|
||||||
|
make showinfo
|
791
depcomp
Normal file
791
depcomp
Normal file
|
@ -0,0 +1,791 @@
|
||||||
|
#! /bin/sh
|
||||||
|
# depcomp - compile a program generating dependencies as side-effects
|
||||||
|
|
||||||
|
scriptversion=2018-03-07.03; # UTC
|
||||||
|
|
||||||
|
# Copyright (C) 1999-2020 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>.
|
||||||
|
EOF
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
-v | --v*)
|
||||||
|
echo "depcomp $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
|
||||||
|
digits=0123456789
|
||||||
|
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 interferences 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 obsosete pre-3.x GCC compilers.
|
||||||
|
## but also to in-use compilers like IMB 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:
|
33
doc/Makefile.am
Normal file
33
doc/Makefile.am
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
SUBDIRS =
|
||||||
|
BUILT_SOURCES =
|
||||||
|
|
||||||
|
dist_html_DATA = faq.html
|
||||||
|
|
||||||
|
dist_man_MANS = nano.1 rnano.1
|
||||||
|
html_pages = nano.1.html rnano.1.html
|
||||||
|
|
||||||
|
if USE_NANORC
|
||||||
|
dist_man_MANS += nanorc.5
|
||||||
|
html_pages += nanorc.5.html
|
||||||
|
endif
|
||||||
|
|
||||||
|
nano.1.html: nano.1
|
||||||
|
groff -t -mandoc -Thtml < $? > $@
|
||||||
|
nanorc.5.html: nanorc.5
|
||||||
|
groff -t -mandoc -Thtml < $? > $@
|
||||||
|
rnano.1.html: rnano.1
|
||||||
|
groff -t -mandoc -Thtml < $? > $@
|
||||||
|
|
||||||
|
if GROFF_HTML
|
||||||
|
BUILT_SOURCES += $(html_pages)
|
||||||
|
dist_html_DATA += $(html_pages)
|
||||||
|
endif
|
||||||
|
|
||||||
|
info_TEXINFOS = nano.texi
|
||||||
|
|
||||||
|
BUILT_SOURCES += nano.html
|
||||||
|
dist_html_DATA += nano.html
|
||||||
|
|
||||||
|
AM_MAKEINFOHTMLFLAGS = --no-split -c HEADERS=0
|
||||||
|
|
||||||
|
EXTRA_DIST = $(BUILT_SOURCES) $(info_TEXINFOS)
|
2458
doc/Makefile.in
Normal file
2458
doc/Makefile.in
Normal file
File diff suppressed because it is too large
Load diff
288
doc/faq.html
Normal file
288
doc/faq.html
Normal file
|
@ -0,0 +1,288 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>The GNU nano editor FAQ</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="description" content="The genesis story of the nano editor, plus the solution to some common problems.">
|
||||||
|
<style>
|
||||||
|
.indented { margin-left: 2em; font-family: courier; font-size: 110%; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
|
||||||
|
|
||||||
|
<h1>The GNU nano editor FAQ</h1>
|
||||||
|
<h3>Table of Contents</h3>
|
||||||
|
<h3><a href="#1">1. General</a></h3>
|
||||||
|
<blockquote><p>
|
||||||
|
<a href="#1.1">1.1. What is GNU nano?</a><br>
|
||||||
|
<a href="#1.2">1.2. What is the history behind nano?</a><br>
|
||||||
|
<a href="#1.3">1.3. Why the name change from TIP?</a><br>
|
||||||
|
<a href="#1.4">1.4. What is the current version of nano?</a><br>
|
||||||
|
<a href="#1.5">1.5. I want to read the manpage without having to download the program!</a>
|
||||||
|
</p></blockquote>
|
||||||
|
<h3><a href="#2">2. Where to get GNU nano.</a></h3>
|
||||||
|
<blockquote><p>
|
||||||
|
<a href="#2.1">2.1. FTP and WWW sites that carry nano.</a><br>
|
||||||
|
<a href="#2.2">2.2. RedHat and derivatives (.rpm) packages.</a><br>
|
||||||
|
<a href="#2.3">2.3. Debian (.deb) packages.</a><br>
|
||||||
|
<a href="#2.4">2.4. By git (for the brave).</a>
|
||||||
|
</p></blockquote>
|
||||||
|
<h3><a href="#3">3. Installation and Configuration</a></h3>
|
||||||
|
<blockquote><p>
|
||||||
|
<a href="#3.1">3.1. How do I install the RPM or DEB package?</a><br>
|
||||||
|
<a href="#3.2">3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</a><br>
|
||||||
|
<a href="#3.3">3.3. Why does everything go into /usr/local?</a><br>
|
||||||
|
<a href="#3.4">3.4. nano should automatically run strip on the binary when installing it!</a><br>
|
||||||
|
<a href="#3.5">3.5. How can I make the executable smaller? This is too bloated!</a><br>
|
||||||
|
<a href="#3.6">3.6. Tell me more about this multibuffer stuff!</a><br>
|
||||||
|
<a href="#3.7">3.7. Tell me more about this verbatim input stuff!</a><br>
|
||||||
|
<a href="#3.8">3.8. How do I make a .nanorc file that nano will read when I start it?</a><br>
|
||||||
|
<a href="#3.9">3.9. Why does my self-compiled nano not read /etc/nanorc?</a><br>
|
||||||
|
</p></blockquote>
|
||||||
|
<h3><a href="#4">4. Running</a></h3>
|
||||||
|
<blockquote><p>
|
||||||
|
<a href="#4.1">4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</a><br>
|
||||||
|
<a href="#4.2">4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</a><br>
|
||||||
|
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
|
||||||
|
<a href="#4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</a><br>
|
||||||
|
<a href="#4.5">4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</a><br>
|
||||||
|
<a href="#4.6">4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</a><br>
|
||||||
|
<a href="#4.7">4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</a><br>
|
||||||
|
<a href="#4.8">4.8. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
|
||||||
|
<a href="#4.9">4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||||
|
</p></blockquote>
|
||||||
|
<h3><a href="#5">5. Internationalization</a></h3>
|
||||||
|
<blockquote><p>
|
||||||
|
<a href="#5.1">5.1. There's no translation for my language!</a><br>
|
||||||
|
<a href="#5.2">5.2. I don't like the translation for <x> in my language. How can I fix it?</a><br>
|
||||||
|
<a href="#5.3">5.3. What is the status of Unicode support?</a>
|
||||||
|
</p></blockquote>
|
||||||
|
<h3><a href="#6">6. Advocacy and Licensing</a></h3>
|
||||||
|
<blockquote><p>
|
||||||
|
<a href="#6.1">6.1. Why should I use nano instead of Pico?</a><br>
|
||||||
|
<a href="#6.2">6.2. Why should I use Pico instead of nano?</a><br>
|
||||||
|
<a href="#6.3">6.3. What is so bad about the older Pine license?</a><br>
|
||||||
|
<a href="#6.4">6.4. Okay, well, what mail program should I use then?</a>
|
||||||
|
</p></blockquote>
|
||||||
|
<h3><a href="#7">7. Miscellaneous</a></h3>
|
||||||
|
<blockquote><p>
|
||||||
|
<a href="#7.1">7.1. Where can I ask questions or send suggestions?</a><br>
|
||||||
|
<a href="#7.2">7.2. How do I submit a bug report or patch?</a><br>
|
||||||
|
<a href="#7.3">7.3. I want to send the development team a big load of cash (or just a thank you).</a><br>
|
||||||
|
<a href="#7.4">7.4. How do I join the development team?</a><br>
|
||||||
|
<a href="#7.5">7.5. Can I have write access to the git tree?</a>
|
||||||
|
</p></blockquote>
|
||||||
|
<hr width="100%">
|
||||||
|
|
||||||
|
<h1><a name="1"></a>1. General</h1>
|
||||||
|
<h3><a name="1.1"></a>1.1. What is GNU nano?</h3>
|
||||||
|
<blockquote><p>GNU nano was designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aimed to "emulate Pico as closely as is reasonable and then include extra functionality".</p></blockquote>
|
||||||
|
<h3><a name="1.2"></a>1.2. What is the history behind nano?</h3>
|
||||||
|
<blockquote><p>Funny you should ask!</p>
|
||||||
|
<p><b>In the beginning...</b></p>
|
||||||
|
<p>For years Pine was THE program used to read email on a Unix system. The Pico text editor is the portion of the program one would use to compose his or her mail messages. Many beginners to Unix flocked to Pico and Pine because of their well organized, easy to use interfaces. With the proliferation of GNU/Linux in the mid to late 90's, many University students became intimately familiar with the strengths (and weaknesses) of Pine and Pico.</p>
|
||||||
|
<p><b>Then came Debian...</b></p>
|
||||||
|
<p>The <a href="https://www.debian.org/">Debian GNU/Linux</a> distribution, known for its strict standards in distributing truly "free" software (i.e. software with no restrictions on redistribution), would not include a binary package for Pine or Pico. Many people had a serious dilemma: they loved these programs, but the versions available at the time were not truly free software in the <a href="https://www.gnu.org/philosophy/free-sw.html">GNU</a> sense of the word.</p>
|
||||||
|
<p><b>The event...</b></p>
|
||||||
|
<p>It was in late 1999 when Chris Allegretta (our hero) was yet again complaining to himself about the less-than-perfect license Pico was distributed under, the 1000 makefiles that came with it and how just a few small improvements could make it the Best Editor in the World (TM). Having been a convert from Slackware to Debian, he missed having a simple binary package that included Pine and Pico, and had grown tired of downloading them himself.</p>
|
||||||
|
<p>Finally something snapped inside and Chris coded and hacked like a madman for many hours straight one weekend to make a (barely usable) Pico clone, at the time called TIP (Tip Isn't Pico). The program could not be invoked without a filename, could not save files, had no help text display, spell checker, and so forth. But over time it improved, and with the help of a few great coders it matured to the (hopefully) stable state it is in today.</p>
|
||||||
|
<p>In February 2001, nano was declared an official GNU program by Richard Stallman. nano also reached its first production release on March 22, 2001.</p></blockquote>
|
||||||
|
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
|
||||||
|
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program "establishes a full duplex terminal connection to a remote host", and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
|
||||||
|
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
|
||||||
|
<blockquote><p>The current version of nano <i>should</i> be <b>7.2</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||||
|
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
|
||||||
|
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
|
||||||
|
<hr width="100%">
|
||||||
|
|
||||||
|
<h1><a name="2"></a>2. Where to get GNU nano.</h1>
|
||||||
|
<h3><a name="2.1"></a>2.1. Web sites that carry nano.</h3>
|
||||||
|
<blockquote><p>The nano source tarballs can be downloaded from the following web sites:</p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://nano-editor.org/dist/latest/">https://nano-editor.org/dist/latest/</a></li>
|
||||||
|
<li><a href="https://ftpmirror.gnu.org/gnu/nano/">https://ftpmirror.gnu.org/gnu/nano/</a></li>
|
||||||
|
</ul>
|
||||||
|
</blockquote>
|
||||||
|
<h3><a name="2.2"></a>2.2. RPM packages (RedHat, OpenSuse, and derivatives).</h3>
|
||||||
|
<blockquote>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://kojipkgs.fedoraproject.org//packages/nano/">https://kojipkgs.fedoraproject.org//packages/nano/</a></li>
|
||||||
|
<li><a href="https://software.opensuse.org/package/nano">https://software.opensuse.org/package/nano</a></li>
|
||||||
|
</ul>
|
||||||
|
</blockquote>
|
||||||
|
<h3><a name="2.3"></a>2.3. Deb packages (Debian and derivatives):</h3>
|
||||||
|
<blockquote><p>Debian users can check out the current nano packages for:</p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://packages.debian.org/stable/editors/nano">stable</a></li>
|
||||||
|
<li><a href="https://packages.debian.org/testing/editors/nano">testing</a></li>
|
||||||
|
<li><a href="https://packages.debian.org/unstable/editors/nano">unstable</a></li>
|
||||||
|
</ul>
|
||||||
|
<p>You can also have a look at the <a href="http://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
|
||||||
|
</blockquote>
|
||||||
|
<h3><a name="2.4"></a>2.4. By git (for the brave).</h3>
|
||||||
|
<blockquote><p>For the "bleeding edge" current version of nano, you can use <b>git</b> to download the current source code. <i>Note:</i> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://git.savannah.gnu.org/cgit/nano.git/tree/README.hacking">the hacking document</a> for info on getting and building nano from git.</p></blockquote>
|
||||||
|
<hr width="100%">
|
||||||
|
|
||||||
|
<h1><a name="3"></a>3. Installation and Configuration</h1>
|
||||||
|
<h3><a name="3.1"></a>3.1. How do I install the RPM or DEB package?</h3>
|
||||||
|
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y-1*.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y-1*.deb</b> if you have a Debian-ish system, where <b>x.y</b> is the version number of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
|
||||||
|
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
|
||||||
|
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
|
||||||
|
<p class="indented"><b>tar -xvf nano-x.y.tar.gz</b></p>
|
||||||
|
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
|
||||||
|
<p>The average case is this:</p>
|
||||||
|
<p class="indented"><b>cd nano-x.y/</b><br>
|
||||||
|
<b>./configure</b><br>
|
||||||
|
<b>make</b><br>
|
||||||
|
<b>make install</b> #(as root, of course)</p></blockquote>
|
||||||
|
<h3><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h3>
|
||||||
|
<blockquote><p>Well, that's what the <b>configure</b> script defaults to. If you wish to change this, simply do this:</p>
|
||||||
|
<p class="indented"><b>./configure --prefix=/usr</b></p>
|
||||||
|
<p>This will put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
|
||||||
|
<h3><a name="3.4"></a>3.4. nano should automatically run strip on the binary when installing it!</h3>
|
||||||
|
<blockquote><p>It does when you use <b>make install-strip</b>. The default <b>make install</b> does not, and will not, run strip automatically.</p></blockquote>
|
||||||
|
<h3><a name="3.5"></a>3.5. How can I make the executable smaller? This is too bloated!</h3>
|
||||||
|
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
|
||||||
|
<pre>
|
||||||
|
<b>--disable-browser</b> Disable the built-in file browser
|
||||||
|
<b>--disable-color</b> Disable color and syntax highlighting
|
||||||
|
<b>--disable-comment</b> Disable the comment/uncomment function
|
||||||
|
<b>--disable-extra</b> Disable the easter egg
|
||||||
|
<b>--disable-formatter</b> Disable the formatting tool
|
||||||
|
<b>--disable-help</b> Disable the built-in help texts
|
||||||
|
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
|
||||||
|
<b>--disable-justify</b> Disable the justify/unjustify functions
|
||||||
|
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
|
||||||
|
<b>--disable-linenumbers</b> Disable line numbering
|
||||||
|
<b>--disable-linter</b> Disable the linting tool
|
||||||
|
<b>--disable-mouse</b> Disable mouse support
|
||||||
|
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
|
||||||
|
<b>--disable-nanorc</b> Disable the use of .nanorc files
|
||||||
|
<b>--disable-operatingdir</b> Disable the setting of an operating directory
|
||||||
|
<b>--disable-speller</b> Disable the spell-checking tool
|
||||||
|
<b>--disable-tabcomp</b> Disable the tab-completion functions
|
||||||
|
<b>--disable-wordcomp</b> Disable the word-completion function
|
||||||
|
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
|
||||||
|
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the undo/redo code and the code for selecting text). Also, if you know you don't need other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few kilobytes. And finally, there's always good old <b>strip</b> to remove all unneeded symbols.</p>
|
||||||
|
</blockquote>
|
||||||
|
<h3><a name="3.6"></a>3.6. Tell me more about this multibuffer stuff!</h3>
|
||||||
|
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b> after typing <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>-F</b> or <b>--multibuffer</b> flag when you invoke nano, or add <b>set multibuffer</b> to your .nanorc file.</p>
|
||||||
|
<p>You can move between the buffers you have open with the <b>Meta-<</b> and <b>Meta-></b> keys, or more easily without holding Shift: <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one buffer open, the ^X shortcut will say "Close", instead of "Exit".</p></blockquote>
|
||||||
|
<h3><a name="3.7"></a>3.7. Tell me more about this verbatim input stuff!</h3>
|
||||||
|
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message "Verbatim Input" on the status bar), then press the key(s) that generate the character you want.</p>
|
||||||
|
<p>Alternatively, if Unicode support is enabled (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code (from 000000 to 10FFFF, case-insensitive), and the character with the corresponding value will be inserted. The status bar will change to "Unicode Input: ......" when you do this.</p></blockquote>
|
||||||
|
<h3><a name="3.8"></a>3.8. How do I make a .nanorc file that will be read when I start nano?</h3>
|
||||||
|
<blockquote><p>It's not hard at all! Simply copy the <b>sample.nanorc</b> from the doc/ directory in the nano source package (or from /usr/doc/nano on your system) to <b>.nanorc</b> in your home directory, and then edit it. If you didn't get a sample nanorc, the syntax of the file is simple: features are turned on and off by using the words <b>set</b> and <b>unset</b> followed by the long option name of the feature (see <b>man nanorc</b> for the full list of options). For example, "set quickblank" or "set smarthome". Of course, for this to work, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>.</p></blockquote>
|
||||||
|
<h3><a name="3.9"></a>3.9. Why does my self-compiled nano not read /etc/nanorc?</h3>
|
||||||
|
<blockquote><p>By default (see <a href="#3.3">3.3</a>), nano gets installed into /usr/local. This also means that, at startup, nano will read <b>/usr/local/etc/nanorc</b> instead of <b>/etc/nanorc</b>. You can make a symlink from the former to the latter if you want your self-compiled nano to read the same nanorc as the system-installed nano. Or you can configure your nano to overwrite the system nano (again, see <a href="#3.3">3.3</a>).</p></blockquote>
|
||||||
|
<hr width="100%">
|
||||||
|
|
||||||
|
<h1><a name="4"></a>4. Running</h1>
|
||||||
|
<h3><a name="4.1"></a>4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</h3>
|
||||||
|
<blockquote><p>On Debian and its derivatives, the <b>Alt+Up</b> keystroke on a Linux console
|
||||||
|
produces by default a 'KeyboardSignal', which normally does absolutely nothing and is useless
|
||||||
|
for the average user. To get the keystroke to do what it ought to do (scroll the viewport
|
||||||
|
one row up), run this in a Linux console:</p>
|
||||||
|
<p class="indented"><b>dumpkeys --full | sed s/KeyboardSignal/Up/ | sudo loadkeys -</b></p>
|
||||||
|
<p>You will need to run this command whenever you first switch to a Linux console.</p>
|
||||||
|
<p>Or you can (as root) execute the following little script just once:</p>
|
||||||
|
<p class="indented"><b>for file in /etc/console-setup/cached*.kmap.gz; do<br>
|
||||||
|
gunzip $file;<br>
|
||||||
|
sed -i 's/KeyboardSignal/Up/' ${file%.gz};<br>
|
||||||
|
gzip ${file%.gz};<br>
|
||||||
|
done</b></p></blockquote>
|
||||||
|
<h3><a name="4.2"></a>4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</h3>
|
||||||
|
<blockquote><p>The urxvt terminal emulator produces non-standard escape sequences for the modified cursor keys. These deviant sequences are not listed in the terminfo database, which means that ncurses does not recognize them. The easiest way around this is to tell urxvt to produce xterm-compatible escape sequences for the relevant keystrokes. To achieve this, add the following lines to your ~/.Xresources file:</p>
|
||||||
|
<pre>
|
||||||
|
URxvt.iso14755_52: False
|
||||||
|
|
||||||
|
URxvt.keysym.C-S-Up: \033[1;6A
|
||||||
|
URxvt.keysym.C-S-Down: \033[1;6B
|
||||||
|
URxvt.keysym.C-S-Right: \033[1;6C
|
||||||
|
URxvt.keysym.C-S-Left: \033[1;6D
|
||||||
|
|
||||||
|
URxvt.keysym.M-Up: \033[1;3A
|
||||||
|
URxvt.keysym.M-Down: \033[1;3B
|
||||||
|
URxvt.keysym.M-Right: \033[1;3C
|
||||||
|
URxvt.keysym.M-Left: \033[1;3D
|
||||||
|
|
||||||
|
URxvt.keysym.M-Insert: \033[2;3~
|
||||||
|
URxvt.keysym.M-Delete: \033[3;3~
|
||||||
|
|
||||||
|
URxvt.keysym.M-Page_Up: \033[5;3~
|
||||||
|
URxvt.keysym.M-Page_Down: \033[6;3~</pre>
|
||||||
|
<p>Then run <b>xrdb ~/.Xresources</b> and restart your urxvt terminal. Now <b>Ctrl+Shift+Left</b> and <b>Ctrl+Shift+Right</b> will select words, <b>Alt+Up</b> and <b>Alt+Down</b> will scroll the text without moving the cursor, and several such things more.</p></blockquote>
|
||||||
|
<h3><a name="4.3"></a>4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</h3>
|
||||||
|
<blockquote><p>You can use the <b>-K</b> or <b>--rawsequences</b> option on the command line, or add the line <b>set rawsequences</b> to your .nanorc. However, nano's mouse support will be disabled if you do any of these things.</p></blockquote>
|
||||||
|
<h3><a name="4.4"></a>4.4. With what keystroke can I paste text from the clipboard into nano?</h3>
|
||||||
|
<blockquote><p>In most desktop environments <b>Shift+Insert</b> will paste the contents of the clipboard.</p></blockquote>
|
||||||
|
<h3><a name="4.5"></a>4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</h3>
|
||||||
|
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
|
||||||
|
<h3><a name="4.6"></a>4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</h3>
|
||||||
|
<blockquote><p>You have the <i>autoindent</i> feature turned on. Hit <b>Meta-I</b> to turn it off, paste your text, and then hit <b>Meta-I</b> again to turn it back on.</p>
|
||||||
|
<p><i>Update:</i> Since version 4.8, nano will suppress auto-indentation during a paste, so you no longer need to toggle it off and on manually.</p></blockquote>
|
||||||
|
<h3><a name="4.7"></a>4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h3>
|
||||||
|
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, which make nano justify (rewrap) the current paragraph. To prevent these linefeeds from causing these unwanted justifications, add this line to your .nanorc on the remote Linux box: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p>
|
||||||
|
<p><i>Update:</i> Since version 4.8, nano will ignore linefeed characters in a paste, so you no longer need the above workaround.</p></blockquote>
|
||||||
|
<h3><a name="4.8"></a>4.8. I've compiled nano with color support, but I don't see any color when I run it!</h3>
|
||||||
|
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9">3.9</a>.</p></blockquote>
|
||||||
|
<h3><a name="4.9"></a>4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
|
||||||
|
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
|
||||||
|
<p class="indented"><b>export EDITOR=/usr/local/bin/nano</b></p>
|
||||||
|
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
|
||||||
|
<p class="indented"><b>setenv EDITOR /usr/local/bin/nano</b></p>
|
||||||
|
<p>Change /usr/local/bin/nano to wherever nano is installed on your system. Type "which nano" to find out. This will not take effect until the next time you log in. So log out and back in again.</p>
|
||||||
|
<p>Then, on top of that, if you use Pine, you must go into setup (type <b>S</b> at the main menu), and then configure (type <b>C</b>). Hit Enter on the lines that say:</p>
|
||||||
|
<p class="indented"><b>[ ] enable-alternate-editor-cmd</b><br>
|
||||||
|
<b>[ ] enable-alternate-editor-implicitly</b></p>
|
||||||
|
<p>Then exit (<b>E</b>) and select Yes (<b>Y</b>).</p>
|
||||||
|
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
|
||||||
|
<p class="indented"><b>my_hdr X-Composer: nano-x.y</b></p>
|
||||||
|
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
|
||||||
|
<hr width="100%">
|
||||||
|
|
||||||
|
<h1><a name="5"></a>5. Internationalization</h1>
|
||||||
|
<h3><a name="5.1"></a>5.1. There's no translation for my language!</h3>
|
||||||
|
<blockquote><p>In June 2001, GNU nano entered the <a href="https://translationproject.org/html/welcome.html">Translation Project</a> and since then, translations should be managed from there.</p>
|
||||||
|
<p>If there isn't a translation for your language, you could ask <a href="https://translationproject.org/team/">your language team</a> to translate nano, or better still, join that team and do it yourself. Joining a team is easy. You just need to ask the team leader to add you, and then send a <a href="https://translationproject.org/disclaim.txt">translation disclaimer to the FSF</a> (this is necessary as nano is an official GNU package, but it does <b>not</b> mean that you transfer the rights of your work to the FSF, it's just so the FSF can legally manage them).</p>
|
||||||
|
<p>In any case, translating nano is easy. Just grab the latest <b>nano.pot</b> file listed on <a href="https://translationproject.org/domain/nano.html">nano's page</a> at the TP, and translate each <b>msgid</b> line into your native language on the <b>msgstr</b> line. When you're done, you should send it to the TP's central PO-file repository.</p></blockquote>
|
||||||
|
<h3><a name="5.2"></a>5.2. I don't like the translation for <x> in my language. How can I fix it?</h3>
|
||||||
|
<blockquote><p>The best way is to send an e-mail with your suggested corrections to the team's mailing list. The address is mentioned in the <code>Language-Team:</code> field in the relevant PO file. The team leader or the assigned translator can then make the changes reach the nano-devel list.</p></blockquote>
|
||||||
|
<h3><a name="5.3"></a>5.3. What is the status of Unicode support?</h3>
|
||||||
|
<blockquote><p>Unicode should be fully usable nowadays. When the encoding of your terminal is set to UTF-8, and your locale (mainly the LANG environment variable) is UTF-8 too, then you should be able to read, enter and save Unicode text.</p></blockquote>
|
||||||
|
<hr width="100%">
|
||||||
|
|
||||||
|
<h1><a name="6"></a>6. Advocacy and Licensing</h1>
|
||||||
|
<h3><a name="6.1"></a>6.1. Why should I use nano instead of Pico?</h3>
|
||||||
|
<blockquote><p>If you want features like undo/redo, syntax highlighting, line numbers, soft-wrapping, opening multiple files at once, an interface localized to your language, or search and replace with support for regular expressions, then you want nano.</p></blockquote>
|
||||||
|
<h3><a name="6.2"></a>6.2. Why should I use Pico instead of nano?</h3>
|
||||||
|
<blockquote><p>If you use your editor only to write emails or other texts and have no need for the above-mentioned features, then Pico will do fine for you.</p></blockquote>
|
||||||
|
<h3><a name="6.3"></a>6.3. What is so bad about the older Pine license?</h3>
|
||||||
|
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="https://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
|
||||||
|
<h3><a name="6.4"></a>6.4. Okay, well, what mail program should I use then?</h3>
|
||||||
|
<blockquote><p>If you are looking to use a Free Software program similar to Pine, and Emacs is not your thing, you should definitely take a look at <a href="http://www.mutt.org/">mutt</a>. It is a full-screen, console based mail program that actually has a lot more flexibility than Pine, but has a keymap included in the distribution that allows you to use the same keystrokes as Pine would to send and receive mail. It's also under the GNU General Public License, version 2.0.</p>
|
||||||
|
<p>Of course, due to the license change you can now use the <a href="http://www.washington.edu/alpine/">Alpine distribution</a> of PINE as it is now considered Free Software, but you would be sacrificing many of nano's features to do so.</p></blockquote>
|
||||||
|
<hr width="100%">
|
||||||
|
|
||||||
|
<h1><a name="7"></a>7. Miscellaneous</h1>
|
||||||
|
<h3><a name="7.1"></a>7.1. Where can I ask questions or send suggestions?</h3>
|
||||||
|
<blockquote><p>There are three mailing lists for nano hosted at <a href="https://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
|
||||||
|
<p>info-nano - <a href="https://lists.gnu.org/mailman/listinfo/info-nano/">https://lists.gnu.org/mailman/listinfo/info-nano/</a><br>
|
||||||
|
help-nano - <a href="https://lists.gnu.org/mailman/listinfo/help-nano/">https://lists.gnu.org/mailman/listinfo/help-nano/</a><br>
|
||||||
|
nano-devel - <a href="https://lists.gnu.org/mailman/listinfo/nano-devel/">https://lists.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
|
||||||
|
<h3><a name="7.2"></a>7.3. How do I submit a bug report or patch?</h3>
|
||||||
|
<blockquote>
|
||||||
|
<p>The best way to submit bugs is through the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a>, as you can check whether the bug you are reporting has already been submitted, and it makes it easier for the maintainers to keep track of them.
|
||||||
|
<p>You can submit patches for nano via <a href="https://savannah.gnu.org/patch/?group=nano">Savannah's patch manager</a>.</p></blockquote>
|
||||||
|
<h3><a name="7.3"></a>7.3. I want to send the development team a big load of cash (or just a thank you).</h3>
|
||||||
|
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/latest/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
|
||||||
|
<h3><a name="7.4"></a>7.4. How do I join the development team?</h3>
|
||||||
|
<blockquote><p>The easiest way is to consistently send in good patches that add some needed functionality, fix a bug or two, and/or make the program more optimized/efficient. Then ask nicely and you will probably be added to the Savannah development list and be given write access after a while. There is a lot of responsibility that goes along with being a team member, so don't think it's just something to add to your resume.</p></blockquote>
|
||||||
|
<h3><a name="7.5"></a>7.5. Can I have write access to the git tree?</h3>
|
||||||
|
<blockquote><p>Re-read section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
|
||||||
|
<hr width="100%">
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
427
doc/nano.1
Normal file
427
doc/nano.1
Normal file
|
@ -0,0 +1,427 @@
|
||||||
|
.\" Copyright (C) 1999-2011, 2013-2023 Free Software Foundation, Inc.
|
||||||
|
.\"
|
||||||
|
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||||
|
.\" under the terms of either of the following licenses:
|
||||||
|
.\"
|
||||||
|
.\" * The GNU General Public License, as published by the Free Software
|
||||||
|
.\" Foundation, version 3 or (at your option) any later version. You
|
||||||
|
.\" should have received a copy of the GNU General Public License
|
||||||
|
.\" along with this program. If not, see
|
||||||
|
.\" <https://www.gnu.org/licenses/>.
|
||||||
|
.\"
|
||||||
|
.\" * The GNU Free Documentation License, as published by the Free
|
||||||
|
.\" Software Foundation, version 1.2 or (at your option) any later
|
||||||
|
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
|
||||||
|
.\" Back-Cover Texts. You should have received a copy of the GNU Free
|
||||||
|
.\" Documentation License along with this program. If not, see
|
||||||
|
.\" <https://www.gnu.org/licenses/>.
|
||||||
|
.\"
|
||||||
|
.TH NANO 1 "version 7.2" "January 2023"
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
nano \- Nano's ANOther editor, inspired by Pico
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B nano
|
||||||
|
.RI [ options "] [[\fB+" line [\fB, column "]] " file ]...
|
||||||
|
.sp
|
||||||
|
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
\fBnano\fP is a small and friendly editor. It copies the look and feel
|
||||||
|
of Pico, but is free software, and implements several features that Pico
|
||||||
|
lacks, such as: opening multiple files, scrolling per line, undo/redo,
|
||||||
|
syntax coloring, line numbering, and soft-wrapping overlong lines.
|
||||||
|
.sp
|
||||||
|
When giving a filename on the command line, the cursor can be put on a
|
||||||
|
specific line by adding the line number with a plus sign (\fB+\fR) before
|
||||||
|
the filename, and even in a specific column by adding it with a comma.
|
||||||
|
(Negative numbers count from the end of the file or line.)
|
||||||
|
The cursor can be put on the first or last occurrence of a specific string
|
||||||
|
by specifying that string after \fB+/\fR or \fB+?\fR before the filename.
|
||||||
|
The string can be made case sensitive and/or caused to be interpreted as a
|
||||||
|
regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
|
||||||
|
These search modes can be explicitly disabled by using the uppercase variant
|
||||||
|
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
|
||||||
|
it needs to be enclosed in quotes. To give an example: to open a file at
|
||||||
|
the first occurrence of the word "Foo", you would do:
|
||||||
|
.sp
|
||||||
|
.RS 4
|
||||||
|
.BI "nano +c/Foo " file
|
||||||
|
.RE
|
||||||
|
.sp
|
||||||
|
As a special case: if instead of a filename a dash (\fB\-\fR) is given,
|
||||||
|
\fBnano\fR will read data from standard input.
|
||||||
|
|
||||||
|
.SH EDITING
|
||||||
|
Entering text and moving around in a file is straightforward: typing the
|
||||||
|
letters and using the normal cursor movement keys. Commands are entered
|
||||||
|
by using the Control (^) and the Alt or Meta (M\-) keys.
|
||||||
|
Typing \fB^K\fR deletes the current line and puts it in the cutbuffer.
|
||||||
|
Consecutive \fB^K\fRs will put all deleted lines together in the cutbuffer.
|
||||||
|
Any cursor movement or executing any other command will cause the next
|
||||||
|
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
|
||||||
|
contents of the cutbuffer at the current cursor position.
|
||||||
|
.sp
|
||||||
|
When a more precise piece of text needs to be cut or copied, you can mark
|
||||||
|
its start with \fB^6\fR, move the cursor to its end (the marked text will be
|
||||||
|
highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
|
||||||
|
cutbuffer. You can also save the marked text to a file with \fB^O\fR, or
|
||||||
|
spell check it with \fB^T^T\fR.
|
||||||
|
.sp
|
||||||
|
On some terminals, text can be selected also by holding down Shift while
|
||||||
|
using the arrow keys. Holding down the Ctrl or Alt key too will increase
|
||||||
|
the stride.
|
||||||
|
Any cursor movement without Shift being held will cancel such a selection.
|
||||||
|
.sp
|
||||||
|
Any valid Unicode code point can be inserted into the buffer by typing
|
||||||
|
\fBM\-V\fR followed by the hexadecimal digits of the code point (concluded
|
||||||
|
with \fB<Space>\fR or \fB<Enter>\fR when it are fewer than six digits).
|
||||||
|
A literal control code (except \fB^J\fR) can be inserted by typing
|
||||||
|
\fBM\-V\fR followed by the pertinent keystroke.
|
||||||
|
.sp
|
||||||
|
The two lines at the bottom of the screen show some important commands;
|
||||||
|
the built-in help (\fB^G\fR) lists all the available ones.
|
||||||
|
The default key bindings can be changed via a \fInanorc\fR file -- see
|
||||||
|
.BR nanorc (5).
|
||||||
|
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.BR \-A ", " \-\-smarthome
|
||||||
|
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||||
|
very beginning of non-whitespace characters on a line, the cursor will
|
||||||
|
jump to that beginning (either forwards or backwards). If the cursor is
|
||||||
|
already at that position, it will jump to the true beginning of the
|
||||||
|
line.
|
||||||
|
.TP
|
||||||
|
.BR \-B ", " \-\-backup
|
||||||
|
When saving a file, back up the previous version of it, using the current
|
||||||
|
filename suffixed with a tilde (\fB~\fP).
|
||||||
|
.TP
|
||||||
|
.BR \-C\ \fIdirectory ", " \-\-backupdir= \fIdirectory
|
||||||
|
Make and keep not just one backup file, but make and keep a uniquely
|
||||||
|
numbered one every time a file is saved -- when backups are enabled (\fB\-B\fR).
|
||||||
|
The uniquely numbered files are stored in the specified \fIdirectory\fR.
|
||||||
|
.TP
|
||||||
|
.BR \-D ", " \-\-boldtext
|
||||||
|
For the interface, use bold instead of reverse video. This will be overridden
|
||||||
|
by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
|
||||||
|
\fBfunctioncolor\fP, \fBnumbercolor\fP, and/or \fBselectedcolor\fP in your
|
||||||
|
nanorc file. See \fBnanorc\fR(5).
|
||||||
|
.TP
|
||||||
|
.BR \-E ", " \-\-tabstospaces
|
||||||
|
Convert each typed tab to spaces -- to the number of spaces
|
||||||
|
that a tab at that position would take up.
|
||||||
|
.TP
|
||||||
|
.BR \-F ", " \-\-multibuffer
|
||||||
|
Read a file into a new buffer by default.
|
||||||
|
.TP
|
||||||
|
.BR \-G ", " \-\-locking
|
||||||
|
Use vim-style file locking when editing files.
|
||||||
|
.TP
|
||||||
|
.BR \-H ", " \-\-historylog
|
||||||
|
Save the last hundred search strings and replacement strings and
|
||||||
|
executed commands, so they can be easily reused in later sessions.
|
||||||
|
.TP
|
||||||
|
.BR \-I ", " \-\-ignorercfiles
|
||||||
|
Don't look at the system's \fInanorc\fR nor at the user's \fInanorc\fR.
|
||||||
|
.TP
|
||||||
|
.BR \-J\ \fInumber ", " \-\-guidestripe= \fInumber
|
||||||
|
Draw a vertical stripe at the given column, to help judge the width of the
|
||||||
|
text. (The color of the stripe can be changed with \fBset stripecolor\fR
|
||||||
|
in your \fInanorc\fR file.)
|
||||||
|
.TP
|
||||||
|
.BR \-K ", " \-\-rawsequences
|
||||||
|
Interpret escape sequences directly, instead of asking \fBncurses\fR
|
||||||
|
to translate them. (If you need this option to get some keys to work
|
||||||
|
properly, it means that the terminfo terminal description that is used
|
||||||
|
does not fully match the actual behavior of your terminal. This can
|
||||||
|
happen when you ssh into a BSD machine, for example.)
|
||||||
|
Using this option disables \fBnano\fR's mouse support.
|
||||||
|
.TP
|
||||||
|
.BR \-L ", " \-\-nonewlines
|
||||||
|
Don't automatically add a newline when a text does not end with one.
|
||||||
|
(This can cause you to save non-POSIX text files.)
|
||||||
|
.TP
|
||||||
|
.BR \-M ", " \-\-trimblanks
|
||||||
|
Snip trailing whitespace from the wrapped line when automatic
|
||||||
|
hard-wrapping occurs or when text is justified.
|
||||||
|
.TP
|
||||||
|
.BR \-N ", " \-\-noconvert
|
||||||
|
Disable automatic conversion of files from DOS/Mac format.
|
||||||
|
.TP
|
||||||
|
.BR \-O ", " \-\-bookstyle
|
||||||
|
When justifying, treat any line that starts with whitespace as the
|
||||||
|
beginning of a paragraph (unless auto-indenting is on).
|
||||||
|
.TP
|
||||||
|
.BR \-P ", " \-\-positionlog
|
||||||
|
For the 200 most recent files, log the last position of the cursor,
|
||||||
|
and place it at that position again upon reopening such a file.
|
||||||
|
.TP
|
||||||
|
.BR "\-Q ""\fIregex\fB""" ", " "\-\-quotestr=""" \fIregex """
|
||||||
|
Set the regular expression for matching the quoting part of a line.
|
||||||
|
The default value is "\fB^([\ \\t]*([!#%:;>|}]|//))+\fR".
|
||||||
|
(Note that \fB\\t\fP stands for an actual Tab.)
|
||||||
|
This makes it possible to rejustify blocks of quoted text when composing
|
||||||
|
email, and to rewrap blocks of line comments when writing source code.
|
||||||
|
.TP
|
||||||
|
.BR \-R ", " \-\-restricted
|
||||||
|
Restricted mode: don't read or write to any file not specified on the
|
||||||
|
command line. This means: don't read or write history files;
|
||||||
|
don't allow suspending; don't allow spell checking;
|
||||||
|
don't allow a file to be appended to, prepended to, or saved under a
|
||||||
|
different name if it already has one; and don't make backup files.
|
||||||
|
Restricted mode can also be activated by invoking \fBnano\fP
|
||||||
|
with any name beginning with 'r' (e.g. "rnano").
|
||||||
|
.TP
|
||||||
|
.BR \-S ", " \-\-softwrap
|
||||||
|
Display over multiple screen rows lines that exceed the screen's width.
|
||||||
|
(You can make this soft-wrapping occur at whitespace instead of rudely at
|
||||||
|
the screen's edge, by using also \fB\-\-atblanks\fR.)
|
||||||
|
(The old short option, \fB\-$\fR, is deprecated.)
|
||||||
|
.TP
|
||||||
|
.BR \-T\ \fInumber ", " \-\-tabsize= \fInumber
|
||||||
|
Set the size (width) of a tab to \fInumber\fP columns. The value of
|
||||||
|
\fInumber\fR must be greater than 0. The default value is \fB8\fR.
|
||||||
|
.TP
|
||||||
|
.BR \-U ", " \-\-quickblank
|
||||||
|
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||||
|
Note that option \fB\-c\fR (\fB\-\-constantshow\fR) overrides this.
|
||||||
|
When option \fB\-\-minibar\fR or \fB\-\-zero\fR is in effect,
|
||||||
|
\fB\-\-quickblank\fR makes a message disappear after
|
||||||
|
0.8 seconds instead of after the default 1.5 seconds.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
.BR \-V ", " \-\-version
|
||||||
|
Show the current version number and exit.
|
||||||
|
.TP
|
||||||
|
.BR \-W ", " \-\-wordbounds
|
||||||
|
Detect word boundaries differently by treating punctuation
|
||||||
|
characters as part of a word.
|
||||||
|
.TP
|
||||||
|
.BR "\-X ""\fIcharacters\fB""" ", " "\-\-wordchars=""" \fIcharacters """
|
||||||
|
Specify which other characters (besides the normal alphanumeric ones)
|
||||||
|
should be considered as part of a word. When using this option, you
|
||||||
|
probably want to omit \fB\-W\fR (\fB\-\-wordbounds\fR).
|
||||||
|
.TP
|
||||||
|
.BR \-Y\ \fIname ", " \-\-syntax= \fIname
|
||||||
|
Specify the name of the syntax highlighting to use from among the ones
|
||||||
|
defined in the \fInanorc\fP files.
|
||||||
|
.TP
|
||||||
|
.BR \-Z ", " \-\-zap
|
||||||
|
Let an unmodified Backspace or Delete erase the marked region
|
||||||
|
(instead of a single character, and without affecting the cutbuffer).
|
||||||
|
.TP
|
||||||
|
.BR \-a ", " \-\-atblanks
|
||||||
|
When doing soft line wrapping, wrap lines at whitespace
|
||||||
|
instead of always at the edge of the screen.
|
||||||
|
.TP
|
||||||
|
.BR \-b ", " \-\-breaklonglines
|
||||||
|
Automatically hard-wrap the current line when it becomes overlong.
|
||||||
|
(This option is the opposite of \fB\-w\fR (\fB\-\-nowrap\fR) --
|
||||||
|
the last one given takes effect.)
|
||||||
|
.TP
|
||||||
|
.BR \-c ", " \-\-constantshow
|
||||||
|
Constantly show the cursor position on the status bar.
|
||||||
|
Note that this overrides option \fB\-U\fR (\fB\-\-quickblank\fR).
|
||||||
|
.TP
|
||||||
|
.BR \-d ", " \-\-rebinddelete
|
||||||
|
Interpret the Delete and Backspace keys differently so that both Backspace
|
||||||
|
and Delete work properly. You should only use this option when on your
|
||||||
|
system either Backspace acts like Delete or Delete acts like Backspace.
|
||||||
|
.TP
|
||||||
|
.BR \-e ", " \-\-emptyline
|
||||||
|
Do not use the line below the title bar, leaving it entirely blank.
|
||||||
|
.TP
|
||||||
|
.BR \-f\ \fIfile ", " \-\-rcfile= \fIfile
|
||||||
|
Read only this \fIfile\fR for setting nano's options, instead of reading
|
||||||
|
both the system-wide and the user's nanorc files.
|
||||||
|
.TP
|
||||||
|
.BR \-g ", " \-\-showcursor
|
||||||
|
Make the cursor visible in the file browser (putting it on the
|
||||||
|
highlighted item) and in the help viewer. Useful for braille users
|
||||||
|
and people with poor vision.
|
||||||
|
.TP
|
||||||
|
.BR \-h ", " \-\-help
|
||||||
|
Show a summary of the available command-line options and exit.
|
||||||
|
.TP
|
||||||
|
.BR \-i ", " \-\-autoindent
|
||||||
|
Automatically indent a newly created line to the same number of tabs
|
||||||
|
and/or spaces as the previous line (or as the next line if the previous
|
||||||
|
line is the beginning of a paragraph).
|
||||||
|
.TP
|
||||||
|
.BR \-j ", " \-\-jumpyscrolling
|
||||||
|
Scroll the buffer contents per half-screen instead of per line.
|
||||||
|
.TP
|
||||||
|
.BR \-k ", " \-\-cutfromcursor
|
||||||
|
Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
|
||||||
|
position to the end of the line, instead of cutting the entire line.
|
||||||
|
.TP
|
||||||
|
.BR \-l ", " \-\-linenumbers
|
||||||
|
Display line numbers to the left of the text area.
|
||||||
|
(Any line with an anchor additionally gets a mark in the margin.)
|
||||||
|
.TP
|
||||||
|
.BR \-m ", " \-\-mouse
|
||||||
|
Enable mouse support, if available for your system. When enabled, mouse
|
||||||
|
clicks can be used to place the cursor, set the mark (with a double
|
||||||
|
click), and execute shortcuts. The mouse will work in the X Window
|
||||||
|
System, and on the console when gpm is running. Text can still be
|
||||||
|
selected through dragging by holding down the Shift key.
|
||||||
|
.TP
|
||||||
|
.BR \-n ", " \-\-noread
|
||||||
|
Treat any name given on the command line as a new file. This allows
|
||||||
|
\fBnano\fR to write to named pipes: it will start with a blank buffer,
|
||||||
|
and will write to the pipe when the user saves the "file". This way
|
||||||
|
\fBnano\fR can be used as an editor in combination with for instance
|
||||||
|
\fBgpg\fR without having to write sensitive data to disk first.
|
||||||
|
.TP
|
||||||
|
.BR \-o\ \fIdirectory ", " \-\-operatingdir= \fIdirectory
|
||||||
|
Set the operating directory. This makes \fBnano\fP set up something
|
||||||
|
similar to a chroot.
|
||||||
|
.TP
|
||||||
|
.BR \-p ", " \-\-preserve
|
||||||
|
Preserve the XON and XOFF sequences (\fB^Q\fR and \fB^S\fR) so they
|
||||||
|
will be caught by the terminal.
|
||||||
|
.TP
|
||||||
|
.BR \-q ", " \-\-indicator
|
||||||
|
Display a "scrollbar" on the righthand side of the edit window.
|
||||||
|
It shows the position of the viewport in the buffer
|
||||||
|
and how much of the buffer is covered by the viewport.
|
||||||
|
.TP
|
||||||
|
.BR \-r\ \fInumber ", " \-\-fill= \fInumber
|
||||||
|
Set the target width for justifying and automatic hard-wrapping at this
|
||||||
|
\fInumber\fR of columns. If the value is 0 or less, wrapping will occur
|
||||||
|
at the width of the screen minus \fInumber\fR columns, allowing the wrap
|
||||||
|
point to vary along with the width of the screen if the screen is resized.
|
||||||
|
The default value is \fB\-8\fR.
|
||||||
|
.TP
|
||||||
|
.B "\-s ""\fIprogram\fR [\fIargument \fR...]\fB""\fR, \fB\-\-speller=""\fIprogram\fR [\fIargument \fR...]\fB"""
|
||||||
|
Use this command to perform spell checking and correcting, instead of
|
||||||
|
using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
|
||||||
|
.TP
|
||||||
|
.BR \-t ", " \-\-saveonexit
|
||||||
|
Save a changed buffer without prompting (when exiting with \fB^X\fR).
|
||||||
|
.TP
|
||||||
|
.BR \-u ", " \-\-unix
|
||||||
|
Save a file by default in Unix format. This overrides nano's
|
||||||
|
default behavior of saving a file in the format that it had.
|
||||||
|
(This option has no effect when you also use \fB\-\-noconvert\fR.)
|
||||||
|
.TP
|
||||||
|
.BR \-v ", " \-\-view
|
||||||
|
Just view the file and disallow editing: read-only mode.
|
||||||
|
This mode allows the user to open also other files for viewing,
|
||||||
|
unless \fB\-\-restricted\fR is given too.
|
||||||
|
.TP
|
||||||
|
.BR \-w ", " \-\-nowrap
|
||||||
|
Do not automatically hard-wrap the current line when it becomes overlong.
|
||||||
|
This is the default. (This option is the opposite of \fB\-b\fR
|
||||||
|
(\fB\-\-breaklonglines\fR) -- the last one given takes effect.)
|
||||||
|
.TP
|
||||||
|
.BR \-x ", " \-\-nohelp
|
||||||
|
Don't show the two help lines at the bottom of the screen.
|
||||||
|
.TP
|
||||||
|
.BR \-y ", " \-\-afterends
|
||||||
|
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
|
||||||
|
.TP
|
||||||
|
.BR \-! ", " \-\-magic
|
||||||
|
When neither the file's name nor its first line give a clue,
|
||||||
|
try using libmagic to determine the applicable syntax.
|
||||||
|
.TP
|
||||||
|
.BR \-% ", " \-\-stateflags
|
||||||
|
Use the top-right corner of the screen for showing some state flags:
|
||||||
|
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
|
||||||
|
hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
|
||||||
|
and \fBS\fR when soft-wrapping.
|
||||||
|
When the buffer is modified, a star (\fB*\fR) is shown after the
|
||||||
|
filename in the center of the title bar.
|
||||||
|
.TP
|
||||||
|
.BR \-_ ", " \-\-minibar
|
||||||
|
Suppress the title bar and instead show information about
|
||||||
|
the current buffer at the bottom of the screen, in the space
|
||||||
|
for the status bar. In this "minibar" the filename is shown
|
||||||
|
on the left, followed by an asterisk if the buffer has been modified.
|
||||||
|
On the right are displayed the current line and column number, the
|
||||||
|
code of the character under the cursor (in Unicode format: U+xxxx),
|
||||||
|
the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
|
||||||
|
that expresses how far the cursor is into the file (linewise).
|
||||||
|
When a file is loaded or saved, and also when switching between buffers,
|
||||||
|
the number of lines in the buffer is displayed after the filename.
|
||||||
|
This number is cleared upon the next keystroke, or replaced with an
|
||||||
|
[i/n] counter when multiple buffers are open.
|
||||||
|
The line plus column numbers and the character code are displayed only when
|
||||||
|
\fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM\-C\fR.
|
||||||
|
The state flags are displayed only when \fB\-\-stateflags\fR is used.
|
||||||
|
.TP
|
||||||
|
.BR \-0 ", " \-\-zero
|
||||||
|
Hide all elements of the interface (title bar, status bar, and help lines)
|
||||||
|
and use all rows of the terminal for showing the contents of the buffer.
|
||||||
|
The status bar appears only when there is a significant message,
|
||||||
|
and disappears after 1.5 seconds or upon the next keystroke.
|
||||||
|
With \fBM\-Z\fR the title bar plus status bar can be toggled.
|
||||||
|
With \fBM\-X\fR the help lines.
|
||||||
|
|
||||||
|
.SH TOGGLES
|
||||||
|
Several of the above options can be switched on and off also while
|
||||||
|
\fBnano\fR is running. For example, \fBM\-L\fR toggles the
|
||||||
|
hard-wrapping of long lines, \fBM\-S\fR toggles soft-wrapping,
|
||||||
|
\fBM\-N\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
|
||||||
|
\fBM\-I\fR auto-indentation, and \fBM\-X\fR the help lines.
|
||||||
|
See at the end of the \fB^G\fR help text for a complete list.
|
||||||
|
.sp
|
||||||
|
The \fBM\-X\fR toggle is special: it works in all menus except
|
||||||
|
the help viewer and the linter. All other toggles work in
|
||||||
|
the main menu only.
|
||||||
|
|
||||||
|
.SH FILES
|
||||||
|
When \fB\-\-rcfile\fR is given, \fBnano\fR will read just the specified file
|
||||||
|
for setting its options and syntaxes and key bindings. Without that option,
|
||||||
|
\fBnano\fR will read two configuration files: first the system's
|
||||||
|
\fInanorc\fR (if it exists), and then the user's \fInanorc\fR (if it
|
||||||
|
exists), either \fI~/.nanorc\fR or \fI$XDG_CONFIG_HOME/nano/nanorc\fR
|
||||||
|
or \fI~/.config/nano/nanorc\fR, whichever is encountered first. See
|
||||||
|
.BR nanorc (5)
|
||||||
|
for more information on the possible contents of those files.
|
||||||
|
.sp
|
||||||
|
See \fI/usr/share/nano/\fR and \fI/usr/share/nano/extra/\fR
|
||||||
|
for available syntax-coloring definitions.
|
||||||
|
|
||||||
|
.SH NOTES
|
||||||
|
Option \fB\-z\fR (\fB\-\-suspendable\fR) has been removed.
|
||||||
|
Suspension is enabled by default, reachable via \fB^T^Z\fR.
|
||||||
|
(If you want a plain \fB^Z\fR to suspend nano, add
|
||||||
|
\fBbind ^Z suspend main\fR to your nanorc.)
|
||||||
|
.sp
|
||||||
|
If no alternative spell checker command is specified on the command
|
||||||
|
line nor in one of the \fInanorc\fP files, \fBnano\fP will check the
|
||||||
|
\fBSPELL\fP environment variable for one.
|
||||||
|
.sp
|
||||||
|
In some cases \fBnano\fP will try to dump the buffer into an emergency
|
||||||
|
file. This will happen mainly if \fBnano\fP receives a SIGHUP or
|
||||||
|
SIGTERM or runs out of memory. It will write the buffer into a file
|
||||||
|
named \fInano.save\fP if the buffer didn't have a name already, or will
|
||||||
|
add a ".save" suffix to the current filename. If an emergency file with
|
||||||
|
that name already exists in the current directory, it will add ".save"
|
||||||
|
plus a number (e.g.\& ".save.1") to the current filename in order to make
|
||||||
|
it unique. In multibuffer mode, \fBnano\fP will write all the open
|
||||||
|
buffers to their respective emergency files.
|
||||||
|
|
||||||
|
.SH BUGS
|
||||||
|
The recording and playback of keyboard macros works correctly only on a
|
||||||
|
terminal emulator, not on a Linux console (VT), because the latter does
|
||||||
|
not by default distinguish modified from unmodified arrow keys.
|
||||||
|
.sp
|
||||||
|
Please report any other bugs that you encounter via:
|
||||||
|
.br
|
||||||
|
.IR https://savannah.gnu.org/bugs/?group=nano .
|
||||||
|
.sp
|
||||||
|
When nano crashes, it will save any modified buffers to emergency .save files.
|
||||||
|
If you are able to reproduce the crash and you want to get a backtrace, define
|
||||||
|
the environment variable \fBNANO_NOCATCH\fR.
|
||||||
|
|
||||||
|
.SH HOMEPAGE
|
||||||
|
.I https://nano\-editor.org/
|
||||||
|
|
||||||
|
.SH SEE ALSO
|
||||||
|
.BR nanorc (5)
|
||||||
|
.sp
|
||||||
|
\fI/usr/share/doc/nano/\fP (or equivalent on your system)
|
707
doc/nano.1.html
Normal file
707
doc/nano.1.html
Normal file
|
@ -0,0 +1,707 @@
|
||||||
|
<!-- Creator : groff version 1.22.4 -->
|
||||||
|
<!-- CreationDate: Wed Jan 18 08:46:05 2023 -->
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="generator" content="groff -Thtml, see www.gnu.org">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||||
|
<meta name="Content-Style" content="text/css">
|
||||||
|
<style type="text/css">
|
||||||
|
p { margin-top: 0; margin-bottom: 0; vertical-align: top }
|
||||||
|
pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
|
||||||
|
table { margin-top: 0; margin-bottom: 0; vertical-align: top }
|
||||||
|
h1 { text-align: center }
|
||||||
|
</style>
|
||||||
|
<title>NANO</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1 align="center">NANO</h1>
|
||||||
|
|
||||||
|
<a href="#NAME">NAME</a><br>
|
||||||
|
<a href="#SYNOPSIS">SYNOPSIS</a><br>
|
||||||
|
<a href="#DESCRIPTION">DESCRIPTION</a><br>
|
||||||
|
<a href="#EDITING">EDITING</a><br>
|
||||||
|
<a href="#OPTIONS">OPTIONS</a><br>
|
||||||
|
<a href="#TOGGLES">TOGGLES</a><br>
|
||||||
|
<a href="#FILES">FILES</a><br>
|
||||||
|
<a href="#NOTES">NOTES</a><br>
|
||||||
|
<a href="#BUGS">BUGS</a><br>
|
||||||
|
<a href="#HOMEPAGE">HOMEPAGE</a><br>
|
||||||
|
<a href="#SEE ALSO">SEE ALSO</a><br>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>NAME
|
||||||
|
<a name="NAME"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">nano -
|
||||||
|
Nano’s ANOther editor, inspired by Pico</p>
|
||||||
|
|
||||||
|
<h2>SYNOPSIS
|
||||||
|
<a name="SYNOPSIS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><b>nano</b>
|
||||||
|
[<i>options</i>]
|
||||||
|
[[<b>+</b><i>line</i>[<b>,</b><i>column</i>]]
|
||||||
|
<i>file</i>]...</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><b>nano</b>
|
||||||
|
[<i>options</i>]
|
||||||
|
[[<b>+</b>[<b>crCR</b>](<b>/</b>|<b>?</b>)<i>string</i>]
|
||||||
|
<i>file</i>]...</p>
|
||||||
|
|
||||||
|
<h2>DESCRIPTION
|
||||||
|
<a name="DESCRIPTION"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><b>nano</b> is
|
||||||
|
a small and friendly editor. It copies the look and feel of
|
||||||
|
Pico, but is free software, and implements several features
|
||||||
|
that Pico lacks, such as: opening multiple files, scrolling
|
||||||
|
per line, undo/redo, syntax coloring, line numbering, and
|
||||||
|
soft-wrapping overlong lines.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">When giving a
|
||||||
|
filename on the command line, the cursor can be put on a
|
||||||
|
specific line by adding the line number with a plus sign
|
||||||
|
(<b>+</b>) before the filename, and even in a specific
|
||||||
|
column by adding it with a comma. (Negative numbers count
|
||||||
|
from the end of the file or line.) The cursor can be put on
|
||||||
|
the first or last occurrence of a specific string by
|
||||||
|
specifying that string after <b>+/</b> or <b>+?</b> before
|
||||||
|
the filename. The string can be made case sensitive and/or
|
||||||
|
caused to be interpreted as a regular expression by
|
||||||
|
inserting <b>c</b> and/or <b>r</b> after the <b>+</b> sign.
|
||||||
|
These search modes can be explicitly disabled by using the
|
||||||
|
uppercase variant of those letters: <b>C</b> and/or
|
||||||
|
<b>R</b>. When the string contains spaces, it needs to be
|
||||||
|
enclosed in quotes. To give an example: to open a file at
|
||||||
|
the first occurrence of the word "Foo", you would
|
||||||
|
do:</p>
|
||||||
|
|
||||||
|
<p style="margin-left:17%; margin-top: 1em"><b>nano
|
||||||
|
+c/Foo</b> <i>file</i></p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">As a special
|
||||||
|
case: if instead of a filename a dash (<b>-</b>) is given,
|
||||||
|
<b>nano</b> will read data from standard input.</p>
|
||||||
|
|
||||||
|
<h2>EDITING
|
||||||
|
<a name="EDITING"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">Entering text
|
||||||
|
and moving around in a file is straightforward: typing the
|
||||||
|
letters and using the normal cursor movement keys. Commands
|
||||||
|
are entered by using the Control (^) and the Alt or Meta
|
||||||
|
(M-) keys. Typing <b>^K</b> deletes the current line and
|
||||||
|
puts it in the cutbuffer. Consecutive <b>^K</b>s will put
|
||||||
|
all deleted lines together in the cutbuffer. Any cursor
|
||||||
|
movement or executing any other command will cause the next
|
||||||
|
<b>^K</b> to overwrite the cutbuffer. A <b>^U</b> will paste
|
||||||
|
the current contents of the cutbuffer at the current cursor
|
||||||
|
position.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">When a more
|
||||||
|
precise piece of text needs to be cut or copied, you can
|
||||||
|
mark its start with <b>^6</b>, move the cursor to its end
|
||||||
|
(the marked text will be highlighted), and then use
|
||||||
|
<b>^K</b> to cut it, or <b>M-6</b> to copy it to the
|
||||||
|
cutbuffer. You can also save the marked text to a file with
|
||||||
|
<b>^O</b>, or spell check it with <b>^T^T</b>.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">On some
|
||||||
|
terminals, text can be selected also by holding down Shift
|
||||||
|
while using the arrow keys. Holding down the Ctrl or Alt key
|
||||||
|
too will increase the stride. Any cursor movement without
|
||||||
|
Shift being held will cancel such a selection.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">Any valid
|
||||||
|
Unicode code point can be inserted into the buffer by typing
|
||||||
|
<b>M-V</b> followed by the hexadecimal digits of the code
|
||||||
|
point (concluded with <b><Space></b> or
|
||||||
|
<b><Enter></b> when it are fewer than six digits). A
|
||||||
|
literal control code (except <b>^J</b>) can be inserted by
|
||||||
|
typing <b>M-V</b> followed by the pertinent keystroke.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">The two lines
|
||||||
|
at the bottom of the screen show some important commands;
|
||||||
|
the built-in help (<b>^G</b>) lists all the available ones.
|
||||||
|
The default key bindings can be changed via a <i>nanorc</i>
|
||||||
|
file -- see <b>nanorc</b>(5).</p>
|
||||||
|
|
||||||
|
<h2>OPTIONS
|
||||||
|
<a name="OPTIONS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><b>-A</b>,
|
||||||
|
<b>--smarthome</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Make the Home key smarter. When
|
||||||
|
Home is pressed anywhere but at the very beginning of
|
||||||
|
non-whitespace characters on a line, the cursor will jump to
|
||||||
|
that beginning (either forwards or backwards). If the cursor
|
||||||
|
is already at that position, it will jump to the true
|
||||||
|
beginning of the line.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-B</b>, <b>--backup</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">When saving a file, back up the
|
||||||
|
previous version of it, using the current filename suffixed
|
||||||
|
with a tilde (<b>~</b>).</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-C </b><i>directory</i>,
|
||||||
|
<b>--backupdir=</b><i>directory</i></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Make and keep not just one
|
||||||
|
backup file, but make and keep a uniquely numbered one every
|
||||||
|
time a file is saved -- when backups are enabled
|
||||||
|
(<b>-B</b>). The uniquely numbered files are stored in the
|
||||||
|
specified <i>directory</i>.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-D</b>,
|
||||||
|
<b>--boldtext</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">For the interface, use bold
|
||||||
|
instead of reverse video. This will be overridden by setting
|
||||||
|
the options <b>titlecolor</b>, <b>statuscolor</b>,
|
||||||
|
<b>keycolor</b>, <b>functioncolor</b>, <b>numbercolor</b>,
|
||||||
|
and/or <b>selectedcolor</b> in your nanorc file. See
|
||||||
|
<b>nanorc</b>(5).</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-E</b>,
|
||||||
|
<b>--tabstospaces</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Convert each typed tab to
|
||||||
|
spaces -- to the number of spaces that a tab at that
|
||||||
|
position would take up.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-F</b>,
|
||||||
|
<b>--multibuffer</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Read a file into a new buffer
|
||||||
|
by default.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-G</b>, <b>--locking</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Use vim-style file locking when
|
||||||
|
editing files.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-H</b>,
|
||||||
|
<b>--historylog</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Save the last hundred search
|
||||||
|
strings and replacement strings and executed commands, so
|
||||||
|
they can be easily reused in later sessions.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-I</b>,
|
||||||
|
<b>--ignorercfiles</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Don’t look at the
|
||||||
|
system’s <i>nanorc</i> nor at the user’s
|
||||||
|
<i>nanorc</i>.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-J </b><i>number</i>,
|
||||||
|
<b>--guidestripe=</b><i>number</i></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Draw a vertical stripe at the
|
||||||
|
given column, to help judge the width of the text. (The
|
||||||
|
color of the stripe can be changed with <b>set
|
||||||
|
stripecolor</b> in your <i>nanorc</i> file.)</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-K</b>,
|
||||||
|
<b>--rawsequences</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Interpret escape sequences
|
||||||
|
directly, instead of asking <b>ncurses</b> to translate
|
||||||
|
them. (If you need this option to get some keys to work
|
||||||
|
properly, it means that the terminfo terminal description
|
||||||
|
that is used does not fully match the actual behavior of
|
||||||
|
your terminal. This can happen when you ssh into a BSD
|
||||||
|
machine, for example.) Using this option disables
|
||||||
|
<b>nano</b>’s mouse support.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-L</b>,
|
||||||
|
<b>--nonewlines</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Don’t automatically add a
|
||||||
|
newline when a text does not end with one. (This can cause
|
||||||
|
you to save non-POSIX text files.)</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-M</b>,
|
||||||
|
<b>--trimblanks</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Snip trailing whitespace from
|
||||||
|
the wrapped line when automatic hard-wrapping occurs or when
|
||||||
|
text is justified.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-N</b>,
|
||||||
|
<b>--noconvert</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Disable automatic conversion of
|
||||||
|
files from DOS/Mac format.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-O</b>,
|
||||||
|
<b>--bookstyle</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">When justifying, treat any line
|
||||||
|
that starts with whitespace as the beginning of a paragraph
|
||||||
|
(unless auto-indenting is on).</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-P</b>,
|
||||||
|
<b>--positionlog</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">For the 200 most recent files,
|
||||||
|
log the last position of the cursor, and place it at that
|
||||||
|
position again upon reopening such a file.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-Q
|
||||||
|
"</b><i>regex</i><b>"</b>,
|
||||||
|
<b>--quotestr="</b><i>regex</i><b>"</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Set the regular expression for
|
||||||
|
matching the quoting part of a line. The default value is
|
||||||
|
"<b>^([ \t]*([!#%:;>|}]|//))+</b>". (Note
|
||||||
|
that <b>\t</b> stands for an actual Tab.) This makes it
|
||||||
|
possible to rejustify blocks of quoted text when composing
|
||||||
|
email, and to rewrap blocks of line comments when writing
|
||||||
|
source code.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-R</b>,
|
||||||
|
<b>--restricted</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Restricted mode: don’t
|
||||||
|
read or write to any file not specified on the command line.
|
||||||
|
This means: don’t read or write history files;
|
||||||
|
don’t allow suspending; don’t allow spell
|
||||||
|
checking; don’t allow a file to be appended to,
|
||||||
|
prepended to, or saved under a different name if it already
|
||||||
|
has one; and don’t make backup files. Restricted mode
|
||||||
|
can also be activated by invoking <b>nano</b> with any name
|
||||||
|
beginning with ’r’ (e.g. "rnano").</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-S</b>,
|
||||||
|
<b>--softwrap</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Display over multiple screen
|
||||||
|
rows lines that exceed the screen’s width. (You can
|
||||||
|
make this soft-wrapping occur at whitespace instead of
|
||||||
|
rudely at the screen’s edge, by using also
|
||||||
|
<b>--atblanks</b>.) (The old short option, <b>-$</b>, is
|
||||||
|
deprecated.)</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-T </b><i>number</i>,
|
||||||
|
<b>--tabsize=</b><i>number</i></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Set the size (width) of a tab
|
||||||
|
to <i>number</i> columns. The value of <i>number</i> must be
|
||||||
|
greater than 0. The default value is <b>8</b>.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-U</b>,
|
||||||
|
<b>--quickblank</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Make status-bar messages
|
||||||
|
disappear after 1 keystroke instead of after 20. Note that
|
||||||
|
option <b>-c</b> (<b>--constantshow</b>) overrides this.
|
||||||
|
When option <b>--minibar</b> or <b>--zero</b> is in effect,
|
||||||
|
<b>--quickblank</b> makes a message disappear after 0.8
|
||||||
|
seconds instead of after the default 1.5 seconds.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-V</b>, <b>--version</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Show the current version number
|
||||||
|
and exit.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-W</b>,
|
||||||
|
<b>--wordbounds</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Detect word boundaries
|
||||||
|
differently by treating punctuation characters as part of a
|
||||||
|
word.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-X
|
||||||
|
"</b><i>characters</i><b>"</b>,
|
||||||
|
<b>--wordchars="</b><i>characters</i><b>"</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Specify which other characters
|
||||||
|
(besides the normal alphanumeric ones) should be considered
|
||||||
|
as part of a word. When using this option, you probably want
|
||||||
|
to omit <b>-W</b> (<b>--wordbounds</b>).</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-Y </b><i>name</i>,
|
||||||
|
<b>--syntax=</b><i>name</i></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Specify the name of the syntax
|
||||||
|
highlighting to use from among the ones defined in the
|
||||||
|
<i>nanorc</i> files.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-Z</b>, <b>--zap</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Let an unmodified Backspace or
|
||||||
|
Delete erase the marked region (instead of a single
|
||||||
|
character, and without affecting the cutbuffer).</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-a</b>,
|
||||||
|
<b>--atblanks</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">When doing soft line wrapping,
|
||||||
|
wrap lines at whitespace instead of always at the edge of
|
||||||
|
the screen.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-b</b>,
|
||||||
|
<b>--breaklonglines</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Automatically hard-wrap the
|
||||||
|
current line when it becomes overlong. (This option is the
|
||||||
|
opposite of <b>-w</b> (<b>--nowrap</b>) -- the last one
|
||||||
|
given takes effect.)</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-c</b>,
|
||||||
|
<b>--constantshow</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Constantly show the cursor
|
||||||
|
position on the status bar. Note that this overrides option
|
||||||
|
<b>-U</b> (<b>--quickblank</b>).</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-d</b>,
|
||||||
|
<b>--rebinddelete</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Interpret the Delete and
|
||||||
|
Backspace keys differently so that both Backspace and Delete
|
||||||
|
work properly. You should only use this option when on your
|
||||||
|
system either Backspace acts like Delete or Delete acts like
|
||||||
|
Backspace.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-e</b>,
|
||||||
|
<b>--emptyline</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Do not use the line below the
|
||||||
|
title bar, leaving it entirely blank.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-f </b><i>file</i>,
|
||||||
|
<b>--rcfile=</b><i>file</i></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Read only this <i>file</i> for
|
||||||
|
setting nano’s options, instead of reading both the
|
||||||
|
system-wide and the user’s nanorc files.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-g</b>,
|
||||||
|
<b>--showcursor</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Make the cursor visible in the
|
||||||
|
file browser (putting it on the highlighted item) and in the
|
||||||
|
help viewer. Useful for braille users and people with poor
|
||||||
|
vision.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-h</b>, <b>--help</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Show a summary of the available
|
||||||
|
command-line options and exit.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-i</b>,
|
||||||
|
<b>--autoindent</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Automatically indent a newly
|
||||||
|
created line to the same number of tabs and/or spaces as the
|
||||||
|
previous line (or as the next line if the previous line is
|
||||||
|
the beginning of a paragraph).</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-j</b>,
|
||||||
|
<b>--jumpyscrolling</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Scroll the buffer contents per
|
||||||
|
half-screen instead of per line.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-k</b>,
|
||||||
|
<b>--cutfromcursor</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Make the ’Cut Text’
|
||||||
|
command (normally <b>^K</b>) cut from the current cursor
|
||||||
|
position to the end of the line, instead of cutting the
|
||||||
|
entire line.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-l</b>,
|
||||||
|
<b>--linenumbers</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Display line numbers to the
|
||||||
|
left of the text area. (Any line with an anchor additionally
|
||||||
|
gets a mark in the margin.)</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-m</b>, <b>--mouse</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Enable mouse support, if
|
||||||
|
available for your system. When enabled, mouse clicks can be
|
||||||
|
used to place the cursor, set the mark (with a double
|
||||||
|
click), and execute shortcuts. The mouse will work in the X
|
||||||
|
Window System, and on the console when gpm is running. Text
|
||||||
|
can still be selected through dragging by holding down the
|
||||||
|
Shift key.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-n</b>, <b>--noread</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Treat any name given on the
|
||||||
|
command line as a new file. This allows <b>nano</b> to write
|
||||||
|
to named pipes: it will start with a blank buffer, and will
|
||||||
|
write to the pipe when the user saves the "file".
|
||||||
|
This way <b>nano</b> can be used as an editor in combination
|
||||||
|
with for instance <b>gpg</b> without having to write
|
||||||
|
sensitive data to disk first.</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-o </b><i>directory</i>,
|
||||||
|
<b>--operatingdir=</b><i>directory</i></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Set the operating directory.
|
||||||
|
This makes <b>nano</b> set up something similar to a
|
||||||
|
chroot.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-p</b>,
|
||||||
|
<b>--preserve</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Preserve the XON and XOFF
|
||||||
|
sequences (<b>^Q</b> and <b>^S</b>) so they will be caught
|
||||||
|
by the terminal.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-q</b>,
|
||||||
|
<b>--indicator</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Display a "scrollbar"
|
||||||
|
on the righthand side of the edit window. It shows the
|
||||||
|
position of the viewport in the buffer and how much of the
|
||||||
|
buffer is covered by the viewport.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-r </b><i>number</i>,
|
||||||
|
<b>--fill=</b><i>number</i></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Set the target width for
|
||||||
|
justifying and automatic hard-wrapping at this <i>number</i>
|
||||||
|
of columns. If the value is 0 or less, wrapping will occur
|
||||||
|
at the width of the screen minus <i>number</i> columns,
|
||||||
|
allowing the wrap point to vary along with the width of the
|
||||||
|
screen if the screen is resized. The default value is
|
||||||
|
<b>-8</b>.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-s "</b><i>program</i>
|
||||||
|
[<i>argument</i> ...]<b>"</b>,
|
||||||
|
<b>--speller="</b><i>program</i> [<i>argument</i>
|
||||||
|
...]<b>"</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Use this command to perform
|
||||||
|
spell checking and correcting, instead of using the built-in
|
||||||
|
corrector that calls <b>hunspell</b>(1) or
|
||||||
|
<b>spell</b>(1).</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-t</b>,
|
||||||
|
<b>--saveonexit</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Save a changed buffer without
|
||||||
|
prompting (when exiting with <b>^X</b>).</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-u</b>, <b>--unix</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Save a file by default in Unix
|
||||||
|
format. This overrides nano’s default behavior of
|
||||||
|
saving a file in the format that it had. (This option has no
|
||||||
|
effect when you also use <b>--noconvert</b>.)</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-v</b>, <b>--view</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Just view the file and disallow
|
||||||
|
editing: read-only mode. This mode allows the user to open
|
||||||
|
also other files for viewing, unless <b>--restricted</b> is
|
||||||
|
given too.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-w</b>, <b>--nowrap</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Do not automatically hard-wrap
|
||||||
|
the current line when it becomes overlong. This is the
|
||||||
|
default. (This option is the opposite of <b>-b</b>
|
||||||
|
(<b>--breaklonglines</b>) -- the last one given takes
|
||||||
|
effect.)</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-x</b>, <b>--nohelp</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Don’t show the two help
|
||||||
|
lines at the bottom of the screen.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-y</b>,
|
||||||
|
<b>--afterends</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Make Ctrl+Right and Ctrl+Delete
|
||||||
|
stop at word ends instead of beginnings.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-!</b>, <b>--magic</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">When neither the file’s
|
||||||
|
name nor its first line give a clue, try using libmagic to
|
||||||
|
determine the applicable syntax.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-%</b>,
|
||||||
|
<b>--stateflags</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Use the top-right corner of the
|
||||||
|
screen for showing some state flags: <b>I</b> when
|
||||||
|
auto-indenting, <b>M</b> when the mark is on, <b>L</b> when
|
||||||
|
hard-wrapping (breaking long lines), <b>R</b> when recording
|
||||||
|
a macro, and <b>S</b> when soft-wrapping. When the buffer is
|
||||||
|
modified, a star (<b>*</b>) is shown after the filename in
|
||||||
|
the center of the title bar.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-_</b>, <b>--minibar</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Suppress the title bar and
|
||||||
|
instead show information about the current buffer at the
|
||||||
|
bottom of the screen, in the space for the status bar. In
|
||||||
|
this "minibar" the filename is shown on the left,
|
||||||
|
followed by an asterisk if the buffer has been modified. On
|
||||||
|
the right are displayed the current line and column number,
|
||||||
|
the code of the character under the cursor (in Unicode
|
||||||
|
format: U+xxxx), the same flags as are shown by
|
||||||
|
<b>--stateflags</b>, and a percentage that expresses how far
|
||||||
|
the cursor is into the file (linewise). When a file is
|
||||||
|
loaded or saved, and also when switching between buffers,
|
||||||
|
the number of lines in the buffer is displayed after the
|
||||||
|
filename. This number is cleared upon the next keystroke, or
|
||||||
|
replaced with an [i/n] counter when multiple buffers are
|
||||||
|
open. The line plus column numbers and the character code
|
||||||
|
are displayed only when <b>--constantshow</b> is used, and
|
||||||
|
can be toggled on and off with <b>M-C</b>. The state flags
|
||||||
|
are displayed only when <b>--stateflags</b> is used.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%;"><b>-0</b>, <b>--zero</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Hide all elements of the
|
||||||
|
interface (title bar, status bar, and help lines) and use
|
||||||
|
all rows of the terminal for showing the contents of the
|
||||||
|
buffer. The status bar appears only when there is a
|
||||||
|
significant message, and disappears after 1.5 seconds or
|
||||||
|
upon the next keystroke. With <b>M-Z</b> the title bar plus
|
||||||
|
status bar can be toggled. With <b>M-X</b> the help
|
||||||
|
lines.</p>
|
||||||
|
|
||||||
|
<h2>TOGGLES
|
||||||
|
<a name="TOGGLES"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">Several of the
|
||||||
|
above options can be switched on and off also while
|
||||||
|
<b>nano</b> is running. For example, <b>M-L</b> toggles the
|
||||||
|
hard-wrapping of long lines, <b>M-S</b> toggles
|
||||||
|
soft-wrapping, <b>M-N</b> toggles line numbers, <b>M-M</b>
|
||||||
|
toggles the mouse, <b>M-I</b> auto-indentation, and
|
||||||
|
<b>M-X</b> the help lines. See at the end of the <b>^G</b>
|
||||||
|
help text for a complete list.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">The <b>M-X</b>
|
||||||
|
toggle is special: it works in all menus except the help
|
||||||
|
viewer and the linter. All other toggles work in the main
|
||||||
|
menu only.</p>
|
||||||
|
|
||||||
|
<h2>FILES
|
||||||
|
<a name="FILES"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">When
|
||||||
|
<b>--rcfile</b> is given, <b>nano</b> will read just the
|
||||||
|
specified file for setting its options and syntaxes and key
|
||||||
|
bindings. Without that option, <b>nano</b> will read two
|
||||||
|
configuration files: first the system’s <i>nanorc</i>
|
||||||
|
(if it exists), and then the user’s <i>nanorc</i> (if
|
||||||
|
it exists), either <i>~/.nanorc</i> or
|
||||||
|
<i>$XDG_CONFIG_HOME/nano/nanorc</i> or
|
||||||
|
<i>~/.config/nano/nanorc</i>, whichever is encountered
|
||||||
|
first. See <b>nanorc</b>(5) for more information on the
|
||||||
|
possible contents of those files.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">See
|
||||||
|
<i>/usr/share/nano/</i> and <i>/usr/share/nano/extra/</i>
|
||||||
|
for available syntax-coloring definitions.</p>
|
||||||
|
|
||||||
|
<h2>NOTES
|
||||||
|
<a name="NOTES"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">Option
|
||||||
|
<b>-z</b> (<b>--suspendable</b>) has been removed.
|
||||||
|
Suspension is enabled by default, reachable via <b>^T^Z</b>.
|
||||||
|
(If you want a plain <b>^Z</b> to suspend nano, add <b>bind
|
||||||
|
^Z suspend main</b> to your nanorc.)</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">If no
|
||||||
|
alternative spell checker command is specified on the
|
||||||
|
command line nor in one of the <i>nanorc</i> files,
|
||||||
|
<b>nano</b> will check the <b>SPELL</b> environment variable
|
||||||
|
for one.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">In some cases
|
||||||
|
<b>nano</b> will try to dump the buffer into an emergency
|
||||||
|
file. This will happen mainly if <b>nano</b> receives a
|
||||||
|
SIGHUP or SIGTERM or runs out of memory. It will write the
|
||||||
|
buffer into a file named <i>nano.save</i> if the buffer
|
||||||
|
didn’t have a name already, or will add a
|
||||||
|
".save" suffix to the current filename. If an
|
||||||
|
emergency file with that name already exists in the current
|
||||||
|
directory, it will add ".save" plus a number (e.g.
|
||||||
|
".save.1") to the current filename in order to
|
||||||
|
make it unique. In multibuffer mode, <b>nano</b> will write
|
||||||
|
all the open buffers to their respective emergency
|
||||||
|
files.</p>
|
||||||
|
|
||||||
|
<h2>BUGS
|
||||||
|
<a name="BUGS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">The recording
|
||||||
|
and playback of keyboard macros works correctly only on a
|
||||||
|
terminal emulator, not on a Linux console (VT), because the
|
||||||
|
latter does not by default distinguish modified from
|
||||||
|
unmodified arrow keys.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">Please report
|
||||||
|
any other bugs that you encounter via: <i><br>
|
||||||
|
https://savannah.gnu.org/bugs/?group=nano</i>.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">When nano
|
||||||
|
crashes, it will save any modified buffers to emergency
|
||||||
|
.save files. If you are able to reproduce the crash and you
|
||||||
|
want to get a backtrace, define the environment variable
|
||||||
|
<b>NANO_NOCATCH</b>.</p>
|
||||||
|
|
||||||
|
<h2>HOMEPAGE
|
||||||
|
<a name="HOMEPAGE"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><i>https://nano-editor.org/</i></p>
|
||||||
|
|
||||||
|
<h2>SEE ALSO
|
||||||
|
<a name="SEE ALSO"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><i><b>nanorc</b></i>(5)</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><i>/usr/share/doc/nano/</i>
|
||||||
|
(or equivalent on your system)</p>
|
||||||
|
<hr>
|
||||||
|
</body>
|
||||||
|
</html>
|
2355
doc/nano.html
Normal file
2355
doc/nano.html
Normal file
File diff suppressed because it is too large
Load diff
2034
doc/nano.info
Normal file
2034
doc/nano.info
Normal file
File diff suppressed because it is too large
Load diff
2082
doc/nano.texi
Normal file
2082
doc/nano.texi
Normal file
File diff suppressed because it is too large
Load diff
1057
doc/nanorc.5
Normal file
1057
doc/nanorc.5
Normal file
File diff suppressed because it is too large
Load diff
1645
doc/nanorc.5.html
Normal file
1645
doc/nanorc.5.html
Normal file
File diff suppressed because it is too large
Load diff
60
doc/rnano.1
Normal file
60
doc/rnano.1
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
.\" Copyright (C) 2002-2007, 2014-2023 Free Software Foundation, Inc.
|
||||||
|
.\"
|
||||||
|
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||||
|
.\" under the terms of either of the following licenses:
|
||||||
|
.\"
|
||||||
|
.\" * The GNU General Public License, as published by the Free Software
|
||||||
|
.\" Foundation, version 3 or (at your option) any later version. You
|
||||||
|
.\" should have received a copy of the GNU General Public License
|
||||||
|
.\" along with this program. If not, see
|
||||||
|
.\" <https://www.gnu.org/licenses/>.
|
||||||
|
.\"
|
||||||
|
.\" * The GNU Free Documentation License, as published by the Free
|
||||||
|
.\" Software Foundation, version 1.2 or (at your option) any later
|
||||||
|
.\" version, with no Invariant Sections, no Front-Cover Texts, and no
|
||||||
|
.\" Back-Cover Texts. You should have received a copy of the GNU Free
|
||||||
|
.\" Documentation License along with this program. If not, see
|
||||||
|
.\" <https://www.gnu.org/licenses/>.
|
||||||
|
.\"
|
||||||
|
.TH RNANO 1 "version 7.2" "January 2023"
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
rnano \- a restricted nano
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B rnano
|
||||||
|
.RI [ options "] [[+" line [, column "]]\ " file "]..."
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
\fBrnano\fR runs the \fBnano\fR editor in restricted mode. This allows
|
||||||
|
editing only the specified file or files, and doesn't allow the user
|
||||||
|
access to the filesystem nor to a command shell.
|
||||||
|
.sp
|
||||||
|
In restricted mode, \fBnano\fR will:
|
||||||
|
.IP \[bu] 2
|
||||||
|
not allow suspending;
|
||||||
|
.IP \[bu]
|
||||||
|
not allow saving the current buffer under a different name;
|
||||||
|
.IP \[bu]
|
||||||
|
not allow inserting another file or opening a new buffer;
|
||||||
|
.IP \[bu]
|
||||||
|
not allow appending or prepending to any file;
|
||||||
|
.IP \[bu]
|
||||||
|
not make backup files nor do spell checking.
|
||||||
|
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.BR \-h ", " \-\-help
|
||||||
|
Show the available command-line options and exit.
|
||||||
|
.P
|
||||||
|
For all existing options, see the \fBnano\fR(1) man page.
|
||||||
|
|
||||||
|
.SH BUGS
|
||||||
|
Please report bugs via
|
||||||
|
.IR https://savannah.gnu.org/bugs/?group=nano .
|
||||||
|
|
||||||
|
.SH HOMEPAGE
|
||||||
|
.I https://nano-editor.org/
|
||||||
|
|
||||||
|
.SH SEE ALSO
|
||||||
|
.BR nano (1)
|
166
doc/rnano.1.html
Normal file
166
doc/rnano.1.html
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
<!-- Creator : groff version 1.22.4 -->
|
||||||
|
<!-- CreationDate: Wed Jan 18 08:46:05 2023 -->
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="generator" content="groff -Thtml, see www.gnu.org">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||||
|
<meta name="Content-Style" content="text/css">
|
||||||
|
<style type="text/css">
|
||||||
|
p { margin-top: 0; margin-bottom: 0; vertical-align: top }
|
||||||
|
pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
|
||||||
|
table { margin-top: 0; margin-bottom: 0; vertical-align: top }
|
||||||
|
h1 { text-align: center }
|
||||||
|
</style>
|
||||||
|
<title>RNANO</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1 align="center">RNANO</h1>
|
||||||
|
|
||||||
|
<a href="#NAME">NAME</a><br>
|
||||||
|
<a href="#SYNOPSIS">SYNOPSIS</a><br>
|
||||||
|
<a href="#DESCRIPTION">DESCRIPTION</a><br>
|
||||||
|
<a href="#OPTIONS">OPTIONS</a><br>
|
||||||
|
<a href="#BUGS">BUGS</a><br>
|
||||||
|
<a href="#HOMEPAGE">HOMEPAGE</a><br>
|
||||||
|
<a href="#SEE ALSO">SEE ALSO</a><br>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>NAME
|
||||||
|
<a name="NAME"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">rnano - a
|
||||||
|
restricted nano</p>
|
||||||
|
|
||||||
|
<h2>SYNOPSIS
|
||||||
|
<a name="SYNOPSIS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><b>rnano</b>
|
||||||
|
[<i>options</i>]
|
||||||
|
[[+<i>line</i>[,<i>column</i>]] <i>file</i>]...</p>
|
||||||
|
|
||||||
|
<h2>DESCRIPTION
|
||||||
|
<a name="DESCRIPTION"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><b>rnano</b>
|
||||||
|
runs the <b>nano</b> editor in restricted mode. This allows
|
||||||
|
editing only the specified file or files, and doesn’t
|
||||||
|
allow the user access to the filesystem nor to a command
|
||||||
|
shell.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">In restricted
|
||||||
|
mode, <b>nano</b> will:</p>
|
||||||
|
|
||||||
|
<table width="100%" border="0" rules="none" frame="void"
|
||||||
|
cellspacing="0" cellpadding="0">
|
||||||
|
<tr valign="top" align="left">
|
||||||
|
<td width="11%"></td>
|
||||||
|
<td width="1%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>•</p></td>
|
||||||
|
<td width="2%"></td>
|
||||||
|
<td width="86%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>not allow suspending;</p></td></tr>
|
||||||
|
<tr valign="top" align="left">
|
||||||
|
<td width="11%"></td>
|
||||||
|
<td width="1%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>•</p></td>
|
||||||
|
<td width="2%"></td>
|
||||||
|
<td width="86%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>not allow saving the current buffer under a different
|
||||||
|
name;</p> </td></tr>
|
||||||
|
<tr valign="top" align="left">
|
||||||
|
<td width="11%"></td>
|
||||||
|
<td width="1%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>•</p></td>
|
||||||
|
<td width="2%"></td>
|
||||||
|
<td width="86%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>not allow inserting another file or opening a new
|
||||||
|
buffer;</p> </td></tr>
|
||||||
|
<tr valign="top" align="left">
|
||||||
|
<td width="11%"></td>
|
||||||
|
<td width="1%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>•</p></td>
|
||||||
|
<td width="2%"></td>
|
||||||
|
<td width="86%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>not allow appending or prepending to any file;</p></td></tr>
|
||||||
|
<tr valign="top" align="left">
|
||||||
|
<td width="11%"></td>
|
||||||
|
<td width="1%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>•</p></td>
|
||||||
|
<td width="2%"></td>
|
||||||
|
<td width="86%">
|
||||||
|
|
||||||
|
|
||||||
|
<p>not make backup files nor do spell checking.</p></td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>OPTIONS
|
||||||
|
<a name="OPTIONS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><b>-h</b>,
|
||||||
|
<b>--help</b></p>
|
||||||
|
|
||||||
|
<p style="margin-left:22%;">Show the available command-line
|
||||||
|
options and exit.</p>
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">For all
|
||||||
|
existing options, see the <b>nano</b>(1) man page.</p>
|
||||||
|
|
||||||
|
<h2>BUGS
|
||||||
|
<a name="BUGS"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em">Please report
|
||||||
|
bugs via
|
||||||
|
<i>https://savannah.gnu.org/bugs/?group=nano</i>.</p>
|
||||||
|
|
||||||
|
<h2>HOMEPAGE
|
||||||
|
<a name="HOMEPAGE"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><i>https://nano-editor.org/</i></p>
|
||||||
|
|
||||||
|
<h2>SEE ALSO
|
||||||
|
<a name="SEE ALSO"></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p style="margin-left:11%; margin-top: 1em"><i><b>nano</b></i>(1)</p>
|
||||||
|
<hr>
|
||||||
|
</body>
|
||||||
|
</html>
|
331
doc/sample.nanorc.in
Normal file
331
doc/sample.nanorc.in
Normal file
|
@ -0,0 +1,331 @@
|
||||||
|
## Sample initialization file for GNU nano.
|
||||||
|
##
|
||||||
|
## For the options that take parameters, the default value is shown.
|
||||||
|
## Other options are unset by default. To make sure that an option
|
||||||
|
## is disabled, you can use "unset <option>".
|
||||||
|
##
|
||||||
|
## Characters that are special in a shell should not be escaped here.
|
||||||
|
## Inside string parameters, quotes should not be escaped -- the last
|
||||||
|
## double quote on the line will be seen as the closing quote.
|
||||||
|
|
||||||
|
## Make 'nextword' (Ctrl+Right) and 'chopwordright' (Ctrl+Delete)
|
||||||
|
## stop at word ends instead of at beginnings.
|
||||||
|
# set afterends
|
||||||
|
|
||||||
|
## When soft line wrapping is enabled, make it wrap lines at blanks
|
||||||
|
## (tabs and spaces) instead of always at the edge of the screen.
|
||||||
|
# set atblanks
|
||||||
|
|
||||||
|
## Automatically indent a newly created line to the same number of
|
||||||
|
## tabs and/or spaces as the preceding line -- or as the next line
|
||||||
|
## if the preceding line is the beginning of a paragraph.
|
||||||
|
# set autoindent
|
||||||
|
|
||||||
|
## Back up files to the current filename plus a tilde.
|
||||||
|
# set backup
|
||||||
|
|
||||||
|
## The directory to put unique backup files in.
|
||||||
|
# set backupdir ""
|
||||||
|
|
||||||
|
## Use bold text instead of reverse video text.
|
||||||
|
# set boldtext
|
||||||
|
|
||||||
|
## Treat any line with leading whitespace as the beginning of a paragraph.
|
||||||
|
# set bookstyle
|
||||||
|
|
||||||
|
## The characters treated as closing brackets when justifying paragraphs.
|
||||||
|
## This may not include any blank characters. Only closing punctuation,
|
||||||
|
## optionally followed by these closing brackets, can end sentences.
|
||||||
|
# set brackets ""')>]}"
|
||||||
|
|
||||||
|
## Automatically hard-wrap the current line when it becomes overlong.
|
||||||
|
# set breaklonglines
|
||||||
|
|
||||||
|
## Do case-sensitive searches by default.
|
||||||
|
# set casesensitive
|
||||||
|
|
||||||
|
## Constantly display the cursor position in the status bar or minibar.
|
||||||
|
# set constantshow
|
||||||
|
|
||||||
|
## Use cut-from-cursor-to-end-of-line by default.
|
||||||
|
# set cutfromcursor
|
||||||
|
|
||||||
|
## Do not use the line below the title bar, leaving it entirely blank.
|
||||||
|
# set emptyline
|
||||||
|
|
||||||
|
## Set the target width for automatic hard-wrapping and for justifying
|
||||||
|
## paragraphs. If the specified value is 0 or less, the wrapping point
|
||||||
|
## will be the terminal's width minus this number.
|
||||||
|
# set fill -8
|
||||||
|
|
||||||
|
## Draw a vertical stripe at the given column, to help judge text width.
|
||||||
|
## (This option does not have a default value.)
|
||||||
|
# set guidestripe 75
|
||||||
|
|
||||||
|
## Remember the used search/replace strings for the next session.
|
||||||
|
# set historylog
|
||||||
|
|
||||||
|
## Display a "scrollbar" on the righthand side of the edit window.
|
||||||
|
# set indicator
|
||||||
|
|
||||||
|
## Scroll the buffer contents per half-screen instead of per line.
|
||||||
|
# set jumpyscrolling
|
||||||
|
|
||||||
|
## Display line numbers to the left (and any anchors in the margin).
|
||||||
|
# set linenumbers
|
||||||
|
|
||||||
|
## Enable vim-style lock-files. This is just to let a vim user know you
|
||||||
|
## are editing a file [s]he is trying to edit and vice versa. There are
|
||||||
|
## no plans to implement vim-style undo state in these files.
|
||||||
|
# set locking
|
||||||
|
|
||||||
|
## Fall back to slow libmagic to try and determine an applicable syntax.
|
||||||
|
# set magic
|
||||||
|
|
||||||
|
## The opening and closing brackets that are found by a matching-bracket
|
||||||
|
## search. This may not contain blank characters. The opening brackets
|
||||||
|
## must come before the closing ones, and they must be in the same order.
|
||||||
|
# set matchbrackets "(<[{)>]}"
|
||||||
|
|
||||||
|
## Suppress the title bar and show the filename plus a cursor-position
|
||||||
|
## percentage in the space of the status bar.
|
||||||
|
# set minibar
|
||||||
|
|
||||||
|
## Enable mouse support, if available for your system. When enabled,
|
||||||
|
## mouse clicks can be used to place the cursor, set the mark (with a
|
||||||
|
## double click), and execute shortcuts. The mouse will work in the
|
||||||
|
## X Window System, and on the console when gpm is running.
|
||||||
|
# set mouse
|
||||||
|
|
||||||
|
## Switch on multiple file buffers (inserting a file will put it into
|
||||||
|
## a separate buffer).
|
||||||
|
# set multibuffer
|
||||||
|
|
||||||
|
## Don't convert files from DOS/Mac format.
|
||||||
|
# set noconvert
|
||||||
|
|
||||||
|
## Don't display the helpful shortcut lists at the bottom of the screen.
|
||||||
|
# set nohelp
|
||||||
|
|
||||||
|
## Don't automatically add a newline when a file does not end with one.
|
||||||
|
# set nonewlines
|
||||||
|
|
||||||
|
## Set operating directory. nano will not read or write files outside
|
||||||
|
## this directory and its subdirectories. Also, the current directory
|
||||||
|
## is changed to here, so any files are inserted from this dir. A blank
|
||||||
|
## string means the operating-directory feature is turned off.
|
||||||
|
# set operatingdir ""
|
||||||
|
|
||||||
|
## Remember the cursor position in each file for the next editing session.
|
||||||
|
# set positionlog
|
||||||
|
|
||||||
|
## Preserve the XON and XOFF keys (^Q and ^S).
|
||||||
|
# set preserve
|
||||||
|
|
||||||
|
## The characters treated as closing punctuation when justifying paragraphs.
|
||||||
|
## This may not contain blank characters. Only these closing punctuations,
|
||||||
|
## optionally followed by closing brackets, can end sentences.
|
||||||
|
# set punct "!.?"
|
||||||
|
|
||||||
|
## Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||||
|
# set quickblank
|
||||||
|
|
||||||
|
## The regular expression that matches quoting characters in email
|
||||||
|
## or line-comment introducers in source code. The default is:
|
||||||
|
# set quotestr "^([ ]*([!#%:;>|}]|//))+"
|
||||||
|
|
||||||
|
## Try to work around a mismatching terminfo terminal description.
|
||||||
|
# set rawsequences
|
||||||
|
|
||||||
|
## Fix Backspace/Delete confusion problem.
|
||||||
|
# set rebinddelete
|
||||||
|
|
||||||
|
## Do regular-expression searches by default.
|
||||||
|
## Regular expressions are of the extended type (ERE).
|
||||||
|
# set regexp
|
||||||
|
|
||||||
|
## Save a changed buffer automatically on exit; don't prompt.
|
||||||
|
# set saveonexit
|
||||||
|
|
||||||
|
## Put the cursor on the highlighted item in the file browser, and
|
||||||
|
## show the cursor in the help viewer; useful for people who use a
|
||||||
|
## braille display and people with poor vision.
|
||||||
|
# set showcursor
|
||||||
|
|
||||||
|
## Make the Home key smarter: when Home is pressed anywhere but at the
|
||||||
|
## very beginning of non-whitespace characters on a line, the cursor
|
||||||
|
## will jump to that beginning (either forwards or backwards). If the
|
||||||
|
## cursor is already at that position, it will jump to the true start
|
||||||
|
## of the line (the left edge).
|
||||||
|
# set smarthome
|
||||||
|
|
||||||
|
## Spread overlong lines over multiple screen lines.
|
||||||
|
# set softwrap
|
||||||
|
|
||||||
|
## Use this spelling checker instead of the internal one. This option
|
||||||
|
## does not have a default value.
|
||||||
|
# set speller "aspell -x -c"
|
||||||
|
|
||||||
|
## Use the end of the title bar for some state flags: I = auto-indenting,
|
||||||
|
## M = mark, L = hard-wrapping long lines, R = recording, S = soft-wrapping.
|
||||||
|
# set stateflags
|
||||||
|
|
||||||
|
## Use this tab size instead of the default; it must be greater than 0.
|
||||||
|
# set tabsize 8
|
||||||
|
|
||||||
|
## Convert each typed tab to the fitting number of spaces.
|
||||||
|
# set tabstospaces
|
||||||
|
|
||||||
|
## Snip whitespace at the end of lines when justifying or hard-wrapping.
|
||||||
|
# set trimblanks
|
||||||
|
|
||||||
|
## Save files by default in Unix format (also when they were DOS or Mac).
|
||||||
|
# set unix
|
||||||
|
|
||||||
|
## The two single-column characters used to display the first characters
|
||||||
|
## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode) and 183 in
|
||||||
|
## ISO-8859-1 (0000B7 in Unicode) seem to be good values for these.
|
||||||
|
## The default when in a UTF-8 locale:
|
||||||
|
# set whitespace "»·"
|
||||||
|
## The default otherwise:
|
||||||
|
# set whitespace ">."
|
||||||
|
|
||||||
|
## Detect word boundaries differently by treating punctuation
|
||||||
|
## characters as parts of words.
|
||||||
|
# set wordbounds
|
||||||
|
|
||||||
|
## The characters (besides alphanumeric ones) that should be considered
|
||||||
|
## as parts of words. This option does not have a default value. When
|
||||||
|
## set, it overrides option 'set wordbounds'.
|
||||||
|
# set wordchars "<_>."
|
||||||
|
|
||||||
|
## Let an unmodified Backspace or Delete erase the marked region (instead
|
||||||
|
## of a single character, and without affecting the cutbuffer).
|
||||||
|
# set zap
|
||||||
|
|
||||||
|
## Hide the bars plus help lines and use the whole terminal as edit area.
|
||||||
|
# set zero
|
||||||
|
|
||||||
|
|
||||||
|
## Paint the interface elements of nano. These are examples; there are
|
||||||
|
## no colors by default, except for errorcolor and spotlightcolor.
|
||||||
|
# set titlecolor bold,white,blue
|
||||||
|
# set promptcolor lightwhite,grey
|
||||||
|
# set statuscolor bold,white,green
|
||||||
|
# set errorcolor bold,white,red
|
||||||
|
# set spotlightcolor black,lightyellow
|
||||||
|
# set selectedcolor lightwhite,magenta
|
||||||
|
# set stripecolor ,yellow
|
||||||
|
# set scrollercolor cyan
|
||||||
|
# set numbercolor cyan
|
||||||
|
# set keycolor cyan
|
||||||
|
# set functioncolor green
|
||||||
|
|
||||||
|
## In root's .nanorc you might want to use:
|
||||||
|
# set titlecolor bold,white,magenta
|
||||||
|
# set promptcolor black,yellow
|
||||||
|
# set statuscolor bold,white,magenta
|
||||||
|
# set errorcolor bold,white,red
|
||||||
|
# set spotlightcolor black,orange
|
||||||
|
# set selectedcolor lightwhite,cyan
|
||||||
|
# set stripecolor ,yellow
|
||||||
|
# set scrollercolor magenta
|
||||||
|
# set numbercolor magenta
|
||||||
|
# set keycolor lightmagenta
|
||||||
|
# set functioncolor magenta
|
||||||
|
|
||||||
|
|
||||||
|
## === Syntax coloring ===
|
||||||
|
## For all details, see 'man nanorc', section SYNTAX HIGHLIGHTING.
|
||||||
|
|
||||||
|
## To include most of the existing syntax definitions, you can do:
|
||||||
|
# include "@PKGDATADIR@/*.nanorc"
|
||||||
|
|
||||||
|
## Or you can select just the ones you need. For example:
|
||||||
|
# include "@PKGDATADIR@/html.nanorc"
|
||||||
|
# include "@PKGDATADIR@/python.nanorc"
|
||||||
|
# include "@PKGDATADIR@/sh.nanorc"
|
||||||
|
|
||||||
|
## In @PKGDATADIR@/extra/ you can find some syntaxes that are
|
||||||
|
## specific for certain distros or for some less common languages.
|
||||||
|
|
||||||
|
|
||||||
|
## If <Tab> should always produce four spaces when editing a Python file,
|
||||||
|
## independent of the settings of 'tabsize' and 'tabstospaces':
|
||||||
|
# extendsyntax python tabgives " "
|
||||||
|
|
||||||
|
## If <Tab> should always produce an actual TAB when editing a Makefile:
|
||||||
|
# extendsyntax makefile tabgives " "
|
||||||
|
|
||||||
|
|
||||||
|
## === Key bindings ===
|
||||||
|
## For all details, see 'man nanorc', section REBINDING KEYS.
|
||||||
|
|
||||||
|
## If you want to suspend nano with one keystroke (instead of with ^T^Z):
|
||||||
|
# bind ^Z suspend main
|
||||||
|
|
||||||
|
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
|
||||||
|
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
|
||||||
|
## the ASCII character for backspace, so it is bound by default to the
|
||||||
|
## backspace function. The <Backspace> key itself produces a different
|
||||||
|
## keycode, which is hard-bound to the backspace function. So, if you
|
||||||
|
## normally use <Backspace> for backspacing and not ^H, you can make
|
||||||
|
## <Ctrl+Backspace> delete the word to the left of the cursor with:
|
||||||
|
# bind ^H chopwordleft main
|
||||||
|
|
||||||
|
## For a more mnemonic Comment keystroke (overriding Cut-from-cursor):
|
||||||
|
# bind M-K comment main
|
||||||
|
|
||||||
|
## If you want ^L to just refresh the screen and not center the cursor:
|
||||||
|
# bind ^L refresh main
|
||||||
|
|
||||||
|
## When you sometimes type M-J instead of M-K, or M-T instead of M-R:
|
||||||
|
# unbind M-J main
|
||||||
|
# unbind M-T main
|
||||||
|
## (Those functions are still accessible through ^T^J and ^T^V.)
|
||||||
|
|
||||||
|
## For quickly uppercasing or lowercasing the word under or after the cursor.
|
||||||
|
## (These effectively select a word and pipe it through a sed command.)
|
||||||
|
#bind Sh-M-U "{nextword}{mark}{prevword}{execute}|sed 's/.*/\U&/'{enter}" main
|
||||||
|
#bind Sh-M-L "{nextword}{mark}{prevword}{execute}|sed 's/.*/\L&/'{enter}" main
|
||||||
|
|
||||||
|
## For copying a marked region to the system clipboard:
|
||||||
|
# bind Sh-M-T "{execute}|xsel -ib{enter}{undo}" main
|
||||||
|
|
||||||
|
## For snipping trailing blanks when you save a file:
|
||||||
|
# bind ^S "{execute}| sed 's/\s\+$//' {enter}{savefile}" main
|
||||||
|
|
||||||
|
## If you would like nano to have keybindings that are more "usual",
|
||||||
|
## such as ^O for Open, ^F for Find, ^H for Help, and ^Q for Quit,
|
||||||
|
## then uncomment these:
|
||||||
|
#bind ^X cut main
|
||||||
|
#bind ^C copy main
|
||||||
|
#bind ^V paste all
|
||||||
|
#bind ^Q exit all
|
||||||
|
#bind ^S savefile main
|
||||||
|
#bind ^W writeout main
|
||||||
|
#bind ^O insert main
|
||||||
|
#set multibuffer
|
||||||
|
#bind ^H help all
|
||||||
|
#bind ^H exit help
|
||||||
|
#bind ^F whereis all
|
||||||
|
#bind ^G findnext all
|
||||||
|
#bind ^B wherewas all
|
||||||
|
#bind ^D findprevious all
|
||||||
|
#bind ^R replace main
|
||||||
|
#unbind ^U all
|
||||||
|
#unbind ^N main
|
||||||
|
#unbind ^Y all
|
||||||
|
#unbind M-J main
|
||||||
|
#unbind M-T main
|
||||||
|
#bind ^A mark main
|
||||||
|
#bind ^P location main
|
||||||
|
#bind ^T gotoline main
|
||||||
|
#bind ^T gotodir browser
|
||||||
|
#bind ^T cutrestoffile execute
|
||||||
|
#bind ^L linter execute
|
||||||
|
#bind ^E execute main
|
||||||
|
#bind ^K "{mark}{end}{zap}" main
|
||||||
|
#bind ^U "{mark}{home}{zap}" main
|
||||||
|
#bind ^Z undo main
|
||||||
|
#bind ^Y redo main
|
11772
doc/texinfo.tex
Normal file
11772
doc/texinfo.tex
Normal file
File diff suppressed because it is too large
Load diff
541
install-sh
Normal file
541
install-sh
Normal file
|
@ -0,0 +1,541 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# install - install a program, script, or datafile
|
||||||
|
|
||||||
|
scriptversion=2020-11-14.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.
|
||||||
|
|
||||||
|
Email bug reports to bug-automake@gnu.org.
|
||||||
|
Automake home page: https://www.gnu.org/software/automake/
|
||||||
|
"
|
||||||
|
|
||||||
|
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 $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-writeable /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 incompatibilities 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:
|
3337
lib/Makefile.am
Normal file
3337
lib/Makefile.am
Normal file
File diff suppressed because it is too large
Load diff
6984
lib/Makefile.in
Normal file
6984
lib/Makefile.in
Normal file
File diff suppressed because it is too large
Load diff
45
lib/_Noreturn.h
Normal file
45
lib/_Noreturn.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/* A C macro for declaring that a function does not return.
|
||||||
|
Copyright (C) 2011-2023 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 __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
lib/alloca.c
Normal file
167
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
lib/alloca.in.h
Normal file
72
lib/alloca.in.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/* Memory allocation on the stack.
|
||||||
|
|
||||||
|
Copyright (C) 1995, 1999, 2001-2004, 2006-2023 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
lib/arg-nonnull.h
Normal file
26
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-2023 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
lib/asnprintf.c
Normal file
34
lib/asnprintf.c
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* Formatted output to strings.
|
||||||
|
Copyright (C) 1999, 2002, 2006, 2009-2023 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
lib/assert.in.h
Normal file
27
lib/assert.in.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/* Substitute for and wrapper around <assert.h>
|
||||||
|
Copyright (C) 2011-2023 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
lib/assure.h
Normal file
57
lib/assure.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/* Run-time assert-like macros.
|
||||||
|
|
||||||
|
Copyright (C) 2014-2023 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
|
146
lib/at-func.c
Normal file
146
lib/at-func.c
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
/* Define at-style functions like fstatat, unlinkat, fchownat, etc.
|
||||||
|
Copyright (C) 2006, 2009-2023 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
|
226
lib/attribute.h
Normal file
226
lib/attribute.h
Normal file
|
@ -0,0 +1,226 @@
|
||||||
|
/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
|
||||||
|
|
||||||
|
Copyright 2020-2023 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. */
|
||||||
|
|
||||||
|
|
||||||
|
/* =============== 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: function, pointer to function, 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: function. */
|
||||||
|
#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. */
|
||||||
|
#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: function. */
|
||||||
|
#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
|
||||||
|
|
||||||
|
/* It is OK for a compiler to omit duplicate calls with the same arguments.
|
||||||
|
This attribute is safe for a function that neither depends on
|
||||||
|
nor affects observable state, and always returns exactly once -
|
||||||
|
e.g., does not loop forever, and does not call longjmp.
|
||||||
|
(This attribute is stricter than ATTRIBUTE_PURE.) */
|
||||||
|
/* Applies to: functions. */
|
||||||
|
#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
|
||||||
|
|
||||||
|
/* It is OK for a compiler to omit duplicate calls with the same
|
||||||
|
arguments if observable state is not changed between calls.
|
||||||
|
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.) */
|
||||||
|
/* Applies to: functions. */
|
||||||
|
#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
|
||||||
|
|
||||||
|
/* 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
lib/basename-lgpl.c
Normal file
70
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-2023 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;
|
||||||
|
}
|
78
lib/basename-lgpl.h
Normal file
78
lib/basename-lgpl.h
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
/* Extract the last component (base name) of a file name.
|
||||||
|
|
||||||
|
Copyright (C) 1998, 2001, 2003-2006, 2009-2023 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
|
||||||
|
|
||||||
|
#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 */
|
39
lib/btowc.c
Normal file
39
lib/btowc.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/* Convert unibyte character to wide character.
|
||||||
|
Copyright (C) 2008, 2010-2023 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>
|
||||||
|
|
||||||
|
wint_t
|
||||||
|
btowc (int c)
|
||||||
|
{
|
||||||
|
if (c != EOF)
|
||||||
|
{
|
||||||
|
char buf[1];
|
||||||
|
wchar_t wc;
|
||||||
|
|
||||||
|
buf[0] = c;
|
||||||
|
if (mbtowc (&wc, buf, 1) >= 0)
|
||||||
|
return wc;
|
||||||
|
}
|
||||||
|
return WEOF;
|
||||||
|
}
|
331
lib/c++defs.h
Normal file
331
lib/c++defs.h
Normal file
|
@ -0,0 +1,331 @@
|
||||||
|
/* C++ compatible function declaration macros.
|
||||||
|
Copyright (C) 2010-2023 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)));
|
||||||
|
*/
|
||||||
|
#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 */
|
707
lib/cdefs.h
Normal file
707
lib/cdefs.h
Normal file
|
@ -0,0 +1,707 @@
|
||||||
|
/* Copyright (C) 1992-2023 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__ \
|
||||||
|
? 6000000 <= __apple_build_version__ \
|
||||||
|
: 3 < __clang_major__ + (5 <= __clang_minor__))))
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
/* 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)))) \
|
||||||
|
|
||||||
|
#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
lib/chdir-long.c
Normal file
263
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-2023 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:
|
||||||
|
*/
|
30
lib/chdir-long.h
Normal file
30
lib/chdir-long.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/* provide a chdir function that tries not to fail due to ENAMETOOLONG
|
||||||
|
Copyright (C) 2004-2005, 2009-2023 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"
|
||||||
|
|
||||||
|
/* 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
|
83
lib/cloexec.c
Normal file
83
lib/cloexec.c
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
/* cloexec.c - set or clear the close-on-exec descriptor flag
|
||||||
|
|
||||||
|
Copyright (C) 1991, 2004-2006, 2009-2023 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/>. */
|
||||||
|
|
||||||
|
/* The code is taken from glibc/manual/llio.texi */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "cloexec.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
|
||||||
|
or clear the flag if VALUE is false.
|
||||||
|
Return 0 on success, or -1 on error with 'errno' set.
|
||||||
|
|
||||||
|
Note that on MingW, this function does NOT protect DESC from being
|
||||||
|
inherited into spawned children. Instead, either use dup_cloexec
|
||||||
|
followed by closing the original DESC, or use interfaces such as
|
||||||
|
open or pipe2 that accept flags like O_CLOEXEC to create DESC
|
||||||
|
non-inheritable in the first place. */
|
||||||
|
|
||||||
|
int
|
||||||
|
set_cloexec_flag (int desc, bool value)
|
||||||
|
{
|
||||||
|
#ifdef F_SETFD
|
||||||
|
|
||||||
|
int flags = fcntl (desc, F_GETFD, 0);
|
||||||
|
|
||||||
|
if (0 <= flags)
|
||||||
|
{
|
||||||
|
int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
|
||||||
|
|
||||||
|
if (flags == newflags
|
||||||
|
|| fcntl (desc, F_SETFD, newflags) != -1)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
#else /* !F_SETFD */
|
||||||
|
|
||||||
|
/* Use dup2 to reject invalid file descriptors; the cloexec flag
|
||||||
|
will be unaffected. */
|
||||||
|
if (desc < 0)
|
||||||
|
{
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (dup2 (desc, desc) < 0)
|
||||||
|
/* errno is EBADF here. */
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* There is nothing we can do on this kind of platform. Punt. */
|
||||||
|
return 0;
|
||||||
|
#endif /* !F_SETFD */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Duplicates a file handle FD, while marking the copy to be closed
|
||||||
|
prior to exec or spawn. Returns -1 and sets errno if FD could not
|
||||||
|
be duplicated. */
|
||||||
|
|
||||||
|
int
|
||||||
|
dup_cloexec (int fd)
|
||||||
|
{
|
||||||
|
return fcntl (fd, F_DUPFD_CLOEXEC, 0);
|
||||||
|
}
|
34
lib/cloexec.h
Normal file
34
lib/cloexec.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* cloexec.c - set or clear the close-on-exec descriptor flag
|
||||||
|
|
||||||
|
Copyright (C) 2004, 2009-2023 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/>. */
|
||||||
|
|
||||||
|
/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
|
||||||
|
or clear the flag if VALUE is false.
|
||||||
|
Return 0 on success, or -1 on error with 'errno' set.
|
||||||
|
|
||||||
|
Note that on MingW, this function does NOT protect DESC from being
|
||||||
|
inherited into spawned children. Instead, either use dup_cloexec
|
||||||
|
followed by closing the original DESC, or use interfaces such as
|
||||||
|
open or pipe2 that accept flags like O_CLOEXEC to create DESC
|
||||||
|
non-inheritable in the first place. */
|
||||||
|
|
||||||
|
int set_cloexec_flag (int desc, bool value);
|
||||||
|
|
||||||
|
/* Duplicates a file handle FD, while marking the copy to be closed
|
||||||
|
prior to exec or spawn. Returns -1 and sets errno if FD could not
|
||||||
|
be duplicated. */
|
||||||
|
|
||||||
|
int dup_cloexec (int fd);
|
75
lib/close.c
Normal file
75
lib/close.c
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/* close replacement.
|
||||||
|
Copyright (C) 2008-2023 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 <unistd.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "fd-hook.h"
|
||||||
|
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
|
||||||
|
# include "msvc-inval.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef close
|
||||||
|
|
||||||
|
#if defined _WIN32 && !defined __CYGWIN__
|
||||||
|
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
|
||||||
|
static int
|
||||||
|
close_nothrow (int fd)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
TRY_MSVC_INVAL
|
||||||
|
{
|
||||||
|
result = _close (fd);
|
||||||
|
}
|
||||||
|
CATCH_MSVC_INVAL
|
||||||
|
{
|
||||||
|
result = -1;
|
||||||
|
errno = EBADF;
|
||||||
|
}
|
||||||
|
DONE_MSVC_INVAL;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
# define close_nothrow _close
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define close_nothrow close
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Override close() to call into other gnulib modules. */
|
||||||
|
|
||||||
|
int
|
||||||
|
rpl_close (int fd)
|
||||||
|
{
|
||||||
|
#if WINDOWS_SOCKETS
|
||||||
|
int retval = execute_all_close_hooks (close_nothrow, fd);
|
||||||
|
#else
|
||||||
|
int retval = close_nothrow (fd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if REPLACE_FCHDIR
|
||||||
|
if (retval >= 0)
|
||||||
|
_gl_unregister_fd (fd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
71
lib/closedir.c
Normal file
71
lib/closedir.c
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/* Stop reading the entries of a directory.
|
||||||
|
Copyright (C) 2006-2023 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 <dirent.h>
|
||||||
|
|
||||||
|
#if REPLACE_FCHDIR
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_CLOSEDIR
|
||||||
|
|
||||||
|
/* Override closedir(), to keep track of the open file descriptors.
|
||||||
|
Needed because there is a function dirfd(). */
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# include <stdlib.h>
|
||||||
|
|
||||||
|
# include "dirent-private.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
closedir (DIR *dirp)
|
||||||
|
{
|
||||||
|
# if REPLACE_FCHDIR || REPLACE_DIRFD
|
||||||
|
int fd = dirfd (dirp);
|
||||||
|
# endif
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
#if HAVE_CLOSEDIR
|
||||||
|
# undef closedir
|
||||||
|
|
||||||
|
retval = closedir (dirp);
|
||||||
|
|
||||||
|
# ifdef __KLIBC__
|
||||||
|
if (!retval)
|
||||||
|
_gl_unregister_dirp_fd (fd);
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
|
||||||
|
if (dirp->current != INVALID_HANDLE_VALUE)
|
||||||
|
FindClose (dirp->current);
|
||||||
|
free (dirp);
|
||||||
|
|
||||||
|
retval = 0;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if REPLACE_FCHDIR
|
||||||
|
if (retval >= 0)
|
||||||
|
_gl_unregister_fd (fd);
|
||||||
|
#endif
|
||||||
|
return retval;
|
||||||
|
}
|
57
lib/ctype.in.h
Normal file
57
lib/ctype.in.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/* A substitute for ISO C99 <ctype.h>, for platforms on which it is incomplete.
|
||||||
|
|
||||||
|
Copyright (C) 2009-2023 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. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ISO C 99 <ctype.h> for platforms on which it is incomplete.
|
||||||
|
* <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _@GUARD_PREFIX@_CTYPE_H
|
||||||
|
|
||||||
|
#if __GNUC__ >= 3
|
||||||
|
@PRAGMA_SYSTEM_HEADER@
|
||||||
|
#endif
|
||||||
|
@PRAGMA_COLUMNS@
|
||||||
|
|
||||||
|
/* Include the original <ctype.h>. */
|
||||||
|
/* The include_next requires a split double-inclusion guard. */
|
||||||
|
#@INCLUDE_NEXT@ @NEXT_CTYPE_H@
|
||||||
|
|
||||||
|
#ifndef _@GUARD_PREFIX@_CTYPE_H
|
||||||
|
#define _@GUARD_PREFIX@_CTYPE_H
|
||||||
|
|
||||||
|
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||||
|
|
||||||
|
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||||
|
|
||||||
|
/* Return non-zero if c is a blank, i.e. a space or tab character. */
|
||||||
|
#if @GNULIB_ISBLANK@
|
||||||
|
# if !@HAVE_ISBLANK@
|
||||||
|
_GL_EXTERN_C int isblank (int c);
|
||||||
|
# endif
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef isblank
|
||||||
|
# if HAVE_RAW_DECL_ISBLANK
|
||||||
|
_GL_WARN_ON_USE (isblank, "isblank is unportable - "
|
||||||
|
"use gnulib module isblank for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _@GUARD_PREFIX@_CTYPE_H */
|
||||||
|
#endif /* _@GUARD_PREFIX@_CTYPE_H */
|
44
lib/dirent-private.h
Normal file
44
lib/dirent-private.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/* Private details of the DIR type.
|
||||||
|
Copyright (C) 2011-2023 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 _DIRENT_PRIVATE_H
|
||||||
|
#define _DIRENT_PRIVATE_H 1
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
/* Don't assume that UNICODE is not defined. */
|
||||||
|
#undef WIN32_FIND_DATA
|
||||||
|
#define WIN32_FIND_DATA WIN32_FIND_DATAA
|
||||||
|
|
||||||
|
struct gl_directory
|
||||||
|
{
|
||||||
|
/* Status, or error code to produce in next readdir() call.
|
||||||
|
-2 means the end of the directory is already reached,
|
||||||
|
-1 means the entry was already filled by FindFirstFile,
|
||||||
|
0 means the entry needs to be filled using FindNextFile.
|
||||||
|
A positive value is an error code. */
|
||||||
|
int status;
|
||||||
|
/* Handle, reading the directory, at current position. */
|
||||||
|
HANDLE current;
|
||||||
|
/* Found directory entry. */
|
||||||
|
WIN32_FIND_DATA entry;
|
||||||
|
/* Argument to pass to FindFirstFile. It consists of the absolutized
|
||||||
|
directory name, followed by a directory separator and the wildcards. */
|
||||||
|
char dir_name_mask[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _DIRENT_PRIVATE_H */
|
321
lib/dirent.in.h
Normal file
321
lib/dirent.in.h
Normal file
|
@ -0,0 +1,321 @@
|
||||||
|
/* A GNU-like <dirent.h>.
|
||||||
|
Copyright (C) 2006-2023 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 _@GUARD_PREFIX@_DIRENT_H
|
||||||
|
|
||||||
|
#if __GNUC__ >= 3
|
||||||
|
@PRAGMA_SYSTEM_HEADER@
|
||||||
|
#endif
|
||||||
|
@PRAGMA_COLUMNS@
|
||||||
|
|
||||||
|
/* The include_next requires a split double-inclusion guard. */
|
||||||
|
#if @HAVE_DIRENT_H@
|
||||||
|
# @INCLUDE_NEXT@ @NEXT_DIRENT_H@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _@GUARD_PREFIX@_DIRENT_H
|
||||||
|
#define _@GUARD_PREFIX@_DIRENT_H
|
||||||
|
|
||||||
|
/* Get ino_t. Needed on some systems, including glibc 2.8. */
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#if !@HAVE_DIRENT_H@
|
||||||
|
/* Define types DIR and 'struct dirent'. */
|
||||||
|
# if !GNULIB_defined_struct_dirent
|
||||||
|
struct dirent
|
||||||
|
{
|
||||||
|
char d_type;
|
||||||
|
char d_name[1];
|
||||||
|
};
|
||||||
|
/* Possible values for 'd_type'. */
|
||||||
|
# define DT_UNKNOWN 0
|
||||||
|
# define DT_FIFO 1 /* FIFO */
|
||||||
|
# define DT_CHR 2 /* character device */
|
||||||
|
# define DT_DIR 4 /* directory */
|
||||||
|
# define DT_BLK 6 /* block device */
|
||||||
|
# define DT_REG 8 /* regular file */
|
||||||
|
# define DT_LNK 10 /* symbolic link */
|
||||||
|
# define DT_SOCK 12 /* socket */
|
||||||
|
# define DT_WHT 14 /* whiteout */
|
||||||
|
typedef struct gl_directory DIR;
|
||||||
|
# define GNULIB_defined_struct_dirent 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* _GL_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. */
|
||||||
|
#ifndef _GL_ATTRIBUTE_DEALLOC
|
||||||
|
# if __GNUC__ >= 11
|
||||||
|
# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
|
||||||
|
# else
|
||||||
|
# define _GL_ATTRIBUTE_DEALLOC(f, i)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
|
||||||
|
allocated memory. */
|
||||||
|
/* Applies to: functions. */
|
||||||
|
#ifndef _GL_ATTRIBUTE_MALLOC
|
||||||
|
# if __GNUC__ >= 3 || defined __clang__
|
||||||
|
# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
||||||
|
# else
|
||||||
|
# define _GL_ATTRIBUTE_MALLOC
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The __attribute__ feature is available in gcc versions 2.5 and later.
|
||||||
|
The attribute __pure__ was added in gcc 2.96. */
|
||||||
|
#ifndef _GL_ATTRIBUTE_PURE
|
||||||
|
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
|
||||||
|
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||||
|
# else
|
||||||
|
# define _GL_ATTRIBUTE_PURE /* empty */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||||
|
|
||||||
|
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||||
|
|
||||||
|
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Declare overridden functions. */
|
||||||
|
|
||||||
|
#if @GNULIB_CLOSEDIR@
|
||||||
|
# if @REPLACE_CLOSEDIR@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef closedir
|
||||||
|
# define closedir rpl_closedir
|
||||||
|
# define GNULIB_defined_closedir 1
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
|
||||||
|
_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
|
||||||
|
# else
|
||||||
|
# if !@HAVE_CLOSEDIR@
|
||||||
|
_GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (closedir, int, (DIR *dirp));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIASWARN (closedir);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef closedir
|
||||||
|
# if HAVE_RAW_DECL_CLOSEDIR
|
||||||
|
_GL_WARN_ON_USE (closedir, "closedir is not portable - "
|
||||||
|
"use gnulib module closedir for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_OPENDIR@
|
||||||
|
# if @REPLACE_OPENDIR@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef opendir
|
||||||
|
# define opendir rpl_opendir
|
||||||
|
# define GNULIB_defined_opendir 1
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (opendir, DIR *,
|
||||||
|
(const char *dir_name)
|
||||||
|
_GL_ARG_NONNULL ((1))
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
|
||||||
|
_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
|
||||||
|
# else
|
||||||
|
# if !@HAVE_OPENDIR@ || __GNUC__ >= 11
|
||||||
|
_GL_FUNCDECL_SYS (opendir, DIR *,
|
||||||
|
(const char *dir_name)
|
||||||
|
_GL_ARG_NONNULL ((1))
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIASWARN (opendir);
|
||||||
|
#else
|
||||||
|
# if @GNULIB_CLOSEDIR@ && __GNUC__ >= 11 && !defined opendir
|
||||||
|
/* For -Wmismatched-dealloc: Associate opendir with closedir or
|
||||||
|
rpl_closedir. */
|
||||||
|
_GL_FUNCDECL_SYS (opendir, DIR *,
|
||||||
|
(const char *dir_name)
|
||||||
|
_GL_ARG_NONNULL ((1))
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
|
||||||
|
# endif
|
||||||
|
# if defined GNULIB_POSIXCHECK
|
||||||
|
# undef opendir
|
||||||
|
# if HAVE_RAW_DECL_OPENDIR
|
||||||
|
_GL_WARN_ON_USE (opendir, "opendir is not portable - "
|
||||||
|
"use gnulib module opendir for portability");
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_READDIR@
|
||||||
|
# if !@HAVE_READDIR@
|
||||||
|
_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
|
||||||
|
_GL_CXXALIASWARN (readdir);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef readdir
|
||||||
|
# if HAVE_RAW_DECL_READDIR
|
||||||
|
_GL_WARN_ON_USE (readdir, "readdir is not portable - "
|
||||||
|
"use gnulib module readdir for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_REWINDDIR@
|
||||||
|
# if !@HAVE_REWINDDIR@
|
||||||
|
_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
|
||||||
|
_GL_CXXALIASWARN (rewinddir);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef rewinddir
|
||||||
|
# if HAVE_RAW_DECL_REWINDDIR
|
||||||
|
_GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
|
||||||
|
"use gnulib module rewinddir for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_DIRFD@
|
||||||
|
/* Return the file descriptor associated with the given directory stream,
|
||||||
|
or -1 if none exists. */
|
||||||
|
# if @REPLACE_DIRFD@
|
||||||
|
/* On kLIBC, dirfd() is a macro that does not work. Undefine it. */
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) || defined dirfd
|
||||||
|
# undef dirfd
|
||||||
|
# define dirfd rpl_dirfd
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
|
||||||
|
_GL_CXXALIAS_RPL (dirfd, int, (DIR *));
|
||||||
|
|
||||||
|
# ifdef __KLIBC__
|
||||||
|
/* Gnulib internal hooks needed to maintain the dirfd metadata. */
|
||||||
|
_GL_EXTERN_C int _gl_register_dirp_fd (int fd, DIR *dirp)
|
||||||
|
_GL_ARG_NONNULL ((2));
|
||||||
|
_GL_EXTERN_C void _gl_unregister_dirp_fd (int fd);
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
|
||||||
|
/* dirfd is defined as a macro and not as a function.
|
||||||
|
Turn it into a function and get rid of the macro. */
|
||||||
|
static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
|
||||||
|
# undef dirfd
|
||||||
|
# endif
|
||||||
|
# if !(@HAVE_DECL_DIRFD@ || defined dirfd)
|
||||||
|
_GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (dirfd, int, (DIR *));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIASWARN (dirfd);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef dirfd
|
||||||
|
# if HAVE_RAW_DECL_DIRFD
|
||||||
|
_GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
|
||||||
|
"use gnulib module dirfd for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_FDOPENDIR@
|
||||||
|
/* Open a directory stream visiting the given directory file
|
||||||
|
descriptor. Return NULL and set errno if fd is not visiting a
|
||||||
|
directory. On success, this function consumes fd (it will be
|
||||||
|
implicitly closed either by this function or by a subsequent
|
||||||
|
closedir). */
|
||||||
|
# if @REPLACE_FDOPENDIR@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef fdopendir
|
||||||
|
# define fdopendir rpl_fdopendir
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (fdopendir, DIR *,
|
||||||
|
(int fd)
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
|
||||||
|
_GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
|
||||||
|
# else
|
||||||
|
# if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@ || __GNUC__ >= 11
|
||||||
|
_GL_FUNCDECL_SYS (fdopendir, DIR *,
|
||||||
|
(int fd)
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIASWARN (fdopendir);
|
||||||
|
#else
|
||||||
|
# if @GNULIB_CLOSEDIR@ && __GNUC__ >= 11 && !defined fdopendir
|
||||||
|
/* For -Wmismatched-dealloc: Associate fdopendir with closedir or
|
||||||
|
rpl_closedir. */
|
||||||
|
_GL_FUNCDECL_SYS (fdopendir, DIR *,
|
||||||
|
(int fd)
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
|
||||||
|
# endif
|
||||||
|
# if defined GNULIB_POSIXCHECK
|
||||||
|
# undef fdopendir
|
||||||
|
# if HAVE_RAW_DECL_FDOPENDIR
|
||||||
|
_GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
|
||||||
|
"use gnulib module fdopendir for portability");
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_SCANDIR@
|
||||||
|
/* Scan the directory DIR, calling FILTER on each directory entry.
|
||||||
|
Entries for which FILTER returns nonzero are individually malloc'd,
|
||||||
|
sorted using qsort with CMP, and collected in a malloc'd array in
|
||||||
|
*NAMELIST. Returns the number of entries selected, or -1 on error. */
|
||||||
|
# if !@HAVE_SCANDIR@
|
||||||
|
_GL_FUNCDECL_SYS (scandir, int,
|
||||||
|
(const char *dir, struct dirent ***namelist,
|
||||||
|
int (*filter) (const struct dirent *),
|
||||||
|
int (*cmp) (const struct dirent **, const struct dirent **))
|
||||||
|
_GL_ARG_NONNULL ((1, 2, 4)));
|
||||||
|
# endif
|
||||||
|
/* Need to cast, because on glibc systems, the fourth parameter is
|
||||||
|
int (*cmp) (const void *, const void *). */
|
||||||
|
_GL_CXXALIAS_SYS_CAST (scandir, int,
|
||||||
|
(const char *dir, struct dirent ***namelist,
|
||||||
|
int (*filter) (const struct dirent *),
|
||||||
|
int (*cmp) (const struct dirent **, const struct dirent **)));
|
||||||
|
_GL_CXXALIASWARN (scandir);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef scandir
|
||||||
|
# if HAVE_RAW_DECL_SCANDIR
|
||||||
|
_GL_WARN_ON_USE (scandir, "scandir is unportable - "
|
||||||
|
"use gnulib module scandir for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_ALPHASORT@
|
||||||
|
/* Compare two 'struct dirent' entries alphabetically. */
|
||||||
|
# if !@HAVE_ALPHASORT@
|
||||||
|
_GL_FUNCDECL_SYS (alphasort, int,
|
||||||
|
(const struct dirent **, const struct dirent **)
|
||||||
|
_GL_ATTRIBUTE_PURE
|
||||||
|
_GL_ARG_NONNULL ((1, 2)));
|
||||||
|
# endif
|
||||||
|
/* Need to cast, because on glibc systems, the parameters are
|
||||||
|
(const void *, const void *). */
|
||||||
|
_GL_CXXALIAS_SYS_CAST (alphasort, int,
|
||||||
|
(const struct dirent **, const struct dirent **));
|
||||||
|
_GL_CXXALIASWARN (alphasort);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef alphasort
|
||||||
|
# if HAVE_RAW_DECL_ALPHASORT
|
||||||
|
_GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
|
||||||
|
"use gnulib module alphasort for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _@GUARD_PREFIX@_DIRENT_H */
|
||||||
|
#endif /* _@GUARD_PREFIX@_DIRENT_H */
|
98
lib/dirfd.c
Normal file
98
lib/dirfd.c
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
/* dirfd.c -- return the file descriptor associated with an open DIR*
|
||||||
|
|
||||||
|
Copyright (C) 2001, 2006, 2008-2023 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>
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifdef __KLIBC__
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <io.h>
|
||||||
|
|
||||||
|
static struct dirp_fd_list
|
||||||
|
{
|
||||||
|
DIR *dirp;
|
||||||
|
int fd;
|
||||||
|
struct dirp_fd_list *next;
|
||||||
|
} *dirp_fd_start = NULL;
|
||||||
|
|
||||||
|
/* Register fd associated with dirp to dirp_fd_list. */
|
||||||
|
int
|
||||||
|
_gl_register_dirp_fd (int fd, DIR *dirp)
|
||||||
|
{
|
||||||
|
struct dirp_fd_list *new_dirp_fd = malloc (sizeof *new_dirp_fd);
|
||||||
|
if (!new_dirp_fd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
new_dirp_fd->dirp = dirp;
|
||||||
|
new_dirp_fd->fd = fd;
|
||||||
|
new_dirp_fd->next = dirp_fd_start;
|
||||||
|
|
||||||
|
dirp_fd_start = new_dirp_fd;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unregister fd from dirp_fd_list with closing it */
|
||||||
|
void
|
||||||
|
_gl_unregister_dirp_fd (int fd)
|
||||||
|
{
|
||||||
|
struct dirp_fd_list *dirp_fd;
|
||||||
|
struct dirp_fd_list *dirp_fd_prev;
|
||||||
|
|
||||||
|
for (dirp_fd_prev = NULL, dirp_fd = dirp_fd_start; dirp_fd;
|
||||||
|
dirp_fd_prev = dirp_fd, dirp_fd = dirp_fd->next)
|
||||||
|
{
|
||||||
|
if (dirp_fd->fd == fd)
|
||||||
|
{
|
||||||
|
if (dirp_fd_prev)
|
||||||
|
dirp_fd_prev->next = dirp_fd->next;
|
||||||
|
else /* dirp_fd == dirp_fd_start */
|
||||||
|
dirp_fd_start = dirp_fd_start->next;
|
||||||
|
|
||||||
|
close (fd);
|
||||||
|
free (dirp_fd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
dirfd (DIR *dir_p)
|
||||||
|
{
|
||||||
|
int fd = DIR_TO_FD (dir_p);
|
||||||
|
if (fd == -1)
|
||||||
|
#ifndef __KLIBC__
|
||||||
|
errno = ENOTSUP;
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
struct dirp_fd_list *dirp_fd;
|
||||||
|
|
||||||
|
for (dirp_fd = dirp_fd_start; dirp_fd; dirp_fd = dirp_fd->next)
|
||||||
|
if (dirp_fd->dirp == dir_p)
|
||||||
|
return dirp_fd->fd;
|
||||||
|
|
||||||
|
errno = EINVAL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
86
lib/dirname-lgpl.c
Normal file
86
lib/dirname-lgpl.c
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/* dirname.c -- return all but the last element in a file name
|
||||||
|
|
||||||
|
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 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>
|
||||||
|
|
||||||
|
#include "dirname.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* Return the length of the prefix of FILE that will be used by
|
||||||
|
dir_name. If FILE is in the working directory, this returns zero
|
||||||
|
even though 'dir_name (FILE)' will return ".". Works properly even
|
||||||
|
if there are trailing slashes (by effectively ignoring them). */
|
||||||
|
|
||||||
|
size_t
|
||||||
|
dir_len (char const *file)
|
||||||
|
{
|
||||||
|
size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
|
||||||
|
size_t length;
|
||||||
|
|
||||||
|
/* Advance prefix_length beyond important leading slashes. */
|
||||||
|
prefix_length += (prefix_length != 0
|
||||||
|
? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||||
|
&& ISSLASH (file[prefix_length]))
|
||||||
|
: (ISSLASH (file[0])
|
||||||
|
? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||||
|
&& ISSLASH (file[1]) && ! ISSLASH (file[2])
|
||||||
|
? 2 : 1))
|
||||||
|
: 0));
|
||||||
|
|
||||||
|
/* Strip the basename and any redundant slashes before it. */
|
||||||
|
for (length = last_component (file) - file;
|
||||||
|
prefix_length < length; length--)
|
||||||
|
if (! ISSLASH (file[length - 1]))
|
||||||
|
break;
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* In general, we can't use the builtin 'dirname' function if available,
|
||||||
|
since it has different meanings in different environments.
|
||||||
|
In some environments the builtin 'dirname' modifies its argument.
|
||||||
|
|
||||||
|
Return the leading directories part of FILE, allocated with malloc.
|
||||||
|
Works properly even if there are trailing slashes (by effectively
|
||||||
|
ignoring them). Return NULL on failure.
|
||||||
|
|
||||||
|
If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
|
||||||
|
lstat (base_name (FILE)); } will access the same file. Likewise,
|
||||||
|
if the sequence { chdir (dir_name (FILE));
|
||||||
|
rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
|
||||||
|
to "foo" in the same directory FILE was in. */
|
||||||
|
|
||||||
|
char *
|
||||||
|
mdir_name (char const *file)
|
||||||
|
{
|
||||||
|
size_t length = dir_len (file);
|
||||||
|
bool append_dot = (length == 0
|
||||||
|
|| (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||||
|
&& length == FILE_SYSTEM_PREFIX_LEN (file)
|
||||||
|
&& file[2] != '\0' && ! ISSLASH (file[2])));
|
||||||
|
char *dir = malloc (length + append_dot + 1);
|
||||||
|
if (!dir)
|
||||||
|
return NULL;
|
||||||
|
memcpy (dir, file, length);
|
||||||
|
if (append_dot)
|
||||||
|
dir[length++] = '.';
|
||||||
|
dir[length] = '\0';
|
||||||
|
return dir;
|
||||||
|
}
|
53
lib/dirname.h
Normal file
53
lib/dirname.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/* Take file names apart into directory and base names.
|
||||||
|
|
||||||
|
Copyright (C) 1998, 2001, 2003-2006, 2009-2023 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 DIRNAME_H_
|
||||||
|
# define DIRNAME_H_ 1
|
||||||
|
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include "filename.h"
|
||||||
|
# include "basename-lgpl.h"
|
||||||
|
|
||||||
|
# ifndef DIRECTORY_SEPARATOR
|
||||||
|
# define DIRECTORY_SEPARATOR '/'
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# if GNULIB_DIRNAME
|
||||||
|
char *base_name (char const *file)
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
|
||||||
|
_GL_ATTRIBUTE_RETURNS_NONNULL;
|
||||||
|
char *dir_name (char const *file)
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
|
||||||
|
_GL_ATTRIBUTE_RETURNS_NONNULL;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
char *mdir_name (char const *file)
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
|
||||||
|
size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
|
||||||
|
|
||||||
|
bool strip_trailing_slashes (char *file);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* not DIRNAME_H_ */
|
38
lib/dup-safer-flag.c
Normal file
38
lib/dup-safer-flag.c
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/* Duplicate a file descriptor result, avoiding clobbering
|
||||||
|
STD{IN,OUT,ERR}_FILENO, with specific flags.
|
||||||
|
|
||||||
|
Copyright (C) 2001, 2004-2006, 2009-2023 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 Paul Eggert and Eric Blake. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
#include "unistd-safer.h"
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or
|
||||||
|
STDERR_FILENO. If FLAG contains O_CLOEXEC, behave like
|
||||||
|
fcntl(F_DUPFD_CLOEXEC) rather than fcntl(F_DUPFD). */
|
||||||
|
|
||||||
|
int
|
||||||
|
dup_safer_flag (int fd, int flag)
|
||||||
|
{
|
||||||
|
return fcntl (fd, (flag & O_CLOEXEC) ? F_DUPFD_CLOEXEC : F_DUPFD,
|
||||||
|
STDERR_FILENO + 1);
|
||||||
|
}
|
34
lib/dup-safer.c
Normal file
34
lib/dup-safer.c
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* Invoke dup, but avoid some glitches.
|
||||||
|
|
||||||
|
Copyright (C) 2001, 2004-2006, 2009-2023 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 Paul Eggert. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "unistd-safer.h"
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or
|
||||||
|
STDERR_FILENO. */
|
||||||
|
|
||||||
|
int
|
||||||
|
dup_safer (int fd)
|
||||||
|
{
|
||||||
|
return fcntl (fd, F_DUPFD, STDERR_FILENO + 1);
|
||||||
|
}
|
189
lib/dup2.c
Normal file
189
lib/dup2.c
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
/* Duplicate an open file descriptor to a specified file descriptor.
|
||||||
|
|
||||||
|
Copyright (C) 1999, 2004-2007, 2009-2023 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 */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#undef dup2
|
||||||
|
|
||||||
|
#if defined _WIN32 && ! defined __CYGWIN__
|
||||||
|
|
||||||
|
/* Get declarations of the native Windows API functions. */
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h>
|
||||||
|
|
||||||
|
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
|
||||||
|
# include "msvc-inval.h"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Get _get_osfhandle. */
|
||||||
|
# if GNULIB_MSVC_NOTHROW
|
||||||
|
# include "msvc-nothrow.h"
|
||||||
|
# else
|
||||||
|
# include <io.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
|
||||||
|
static int
|
||||||
|
dup2_nothrow (int fd, int desired_fd)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
TRY_MSVC_INVAL
|
||||||
|
{
|
||||||
|
result = _dup2 (fd, desired_fd);
|
||||||
|
}
|
||||||
|
CATCH_MSVC_INVAL
|
||||||
|
{
|
||||||
|
errno = EBADF;
|
||||||
|
result = -1;
|
||||||
|
}
|
||||||
|
DONE_MSVC_INVAL;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
# define dup2_nothrow _dup2
|
||||||
|
# endif
|
||||||
|
|
||||||
|
static int
|
||||||
|
ms_windows_dup2 (int fd, int desired_fd)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
/* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open,
|
||||||
|
dup2 (fd, fd) returns 0, but all further attempts to use fd in
|
||||||
|
future dup2 calls will hang. */
|
||||||
|
if (fd == desired_fd)
|
||||||
|
{
|
||||||
|
if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
|
||||||
|
https://bugs.winehq.org/show_bug.cgi?id=21289 */
|
||||||
|
if (desired_fd < 0)
|
||||||
|
{
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = dup2_nothrow (fd, desired_fd);
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
|
result = desired_fd;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
# define dup2 ms_windows_dup2
|
||||||
|
|
||||||
|
#elif defined __KLIBC__
|
||||||
|
|
||||||
|
# include <InnoTekLIBC/backend.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
klibc_dup2dirfd (int fd, int desired_fd)
|
||||||
|
{
|
||||||
|
int tempfd;
|
||||||
|
int dupfd;
|
||||||
|
|
||||||
|
tempfd = open ("NUL", O_RDONLY);
|
||||||
|
if (tempfd == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (tempfd == desired_fd)
|
||||||
|
{
|
||||||
|
close (tempfd);
|
||||||
|
|
||||||
|
char path[_MAX_PATH];
|
||||||
|
if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return open(path, O_RDONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
dupfd = klibc_dup2dirfd (fd, desired_fd);
|
||||||
|
|
||||||
|
close (tempfd);
|
||||||
|
|
||||||
|
return dupfd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
klibc_dup2 (int fd, int desired_fd)
|
||||||
|
{
|
||||||
|
int dupfd;
|
||||||
|
struct stat sbuf;
|
||||||
|
|
||||||
|
dupfd = dup2 (fd, desired_fd);
|
||||||
|
if (dupfd == -1 && errno == ENOTSUP \
|
||||||
|
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
|
||||||
|
{
|
||||||
|
close (desired_fd);
|
||||||
|
|
||||||
|
return klibc_dup2dirfd (fd, desired_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dupfd;
|
||||||
|
}
|
||||||
|
|
||||||
|
# define dup2 klibc_dup2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
rpl_dup2 (int fd, int desired_fd)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
#ifdef F_GETFL
|
||||||
|
/* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
|
||||||
|
On Cygwin 1.5.x, dup2 (1, 1) returns 0.
|
||||||
|
On Cygwin 1.7.17, dup2 (1, -1) dumps core.
|
||||||
|
On Cygwin 1.7.25, dup2 (1, 256) can dump core.
|
||||||
|
On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */
|
||||||
|
# if HAVE_SETDTABLESIZE
|
||||||
|
setdtablesize (desired_fd + 1);
|
||||||
|
# endif
|
||||||
|
if (desired_fd < 0)
|
||||||
|
fd = desired_fd;
|
||||||
|
if (fd == desired_fd)
|
||||||
|
return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
result = dup2 (fd, desired_fd);
|
||||||
|
|
||||||
|
/* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */
|
||||||
|
if (result == -1 && errno == EMFILE)
|
||||||
|
errno = EBADF;
|
||||||
|
#if REPLACE_FCHDIR
|
||||||
|
if (fd != desired_fd && result != -1)
|
||||||
|
result = _gl_register_dup (fd, result);
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
284
lib/dynarray.h
Normal file
284
lib/dynarray.h
Normal file
|
@ -0,0 +1,284 @@
|
||||||
|
/* Type-safe arrays which grow dynamically.
|
||||||
|
Copyright 2021-2023 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 and Bruno Haible, 2021. */
|
||||||
|
|
||||||
|
#ifndef _GL_DYNARRAY_H
|
||||||
|
#define _GL_DYNARRAY_H
|
||||||
|
|
||||||
|
/* Before including this file, you need to define:
|
||||||
|
|
||||||
|
DYNARRAY_STRUCT
|
||||||
|
The struct tag of dynamic array to be defined.
|
||||||
|
|
||||||
|
DYNARRAY_ELEMENT
|
||||||
|
The type name of the element type. Elements are copied
|
||||||
|
as if by memcpy, and can change address as the dynamic
|
||||||
|
array grows.
|
||||||
|
|
||||||
|
DYNARRAY_PREFIX
|
||||||
|
The prefix of the functions which are defined.
|
||||||
|
|
||||||
|
The following parameters are optional:
|
||||||
|
|
||||||
|
DYNARRAY_ELEMENT_FREE
|
||||||
|
DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
|
||||||
|
contents of elements. E is of type DYNARRAY_ELEMENT *.
|
||||||
|
|
||||||
|
DYNARRAY_ELEMENT_INIT
|
||||||
|
DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
|
||||||
|
element. E is of type DYNARRAY_ELEMENT *.
|
||||||
|
If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
|
||||||
|
defined, new elements are automatically zero-initialized.
|
||||||
|
Otherwise, new elements have undefined contents.
|
||||||
|
|
||||||
|
DYNARRAY_INITIAL_SIZE
|
||||||
|
The size of the statically allocated array (default:
|
||||||
|
at least 2, more elements if they fit into 128 bytes).
|
||||||
|
Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
|
||||||
|
there is no statically allocated array at, and all non-empty
|
||||||
|
arrays are heap-allocated.
|
||||||
|
|
||||||
|
DYNARRAY_FINAL_TYPE
|
||||||
|
The name of the type which holds the final array. If not
|
||||||
|
defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
|
||||||
|
must be a struct type, with members of type DYNARRAY_ELEMENT and
|
||||||
|
size_t at the start (in this order).
|
||||||
|
|
||||||
|
These macros are undefined after this header file has been
|
||||||
|
included.
|
||||||
|
|
||||||
|
The following types are provided (their members are private to the
|
||||||
|
dynarray implementation):
|
||||||
|
|
||||||
|
struct DYNARRAY_STRUCT
|
||||||
|
|
||||||
|
The following functions are provided:
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Initialize a dynamic array object. This must be called before any
|
||||||
|
use of the object. */
|
||||||
|
#if 0
|
||||||
|
static void
|
||||||
|
DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Deallocate the dynamic array and its elements. */
|
||||||
|
#if 0
|
||||||
|
static void
|
||||||
|
DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return true if the dynamic array is in an error state. */
|
||||||
|
#if 0
|
||||||
|
static bool
|
||||||
|
DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Mark the dynamic array as failed. All elements are deallocated as
|
||||||
|
a side effect. */
|
||||||
|
#if 0
|
||||||
|
static void
|
||||||
|
DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return the number of elements which have been added to the dynamic
|
||||||
|
array. */
|
||||||
|
#if 0
|
||||||
|
static size_t
|
||||||
|
DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return a pointer to the first array element, if any. For a
|
||||||
|
zero-length array, the pointer can be NULL even though the dynamic
|
||||||
|
array has not entered the failure state. */
|
||||||
|
#if 0
|
||||||
|
static DYNARRAY_ELEMENT *
|
||||||
|
DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return a pointer one element past the last array element. For a
|
||||||
|
zero-length array, the pointer can be NULL even though the dynamic
|
||||||
|
array has not entered the failure state. */
|
||||||
|
#if 0
|
||||||
|
static DYNARRAY_ELEMENT *
|
||||||
|
DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return a pointer to the array element at INDEX. Terminate the
|
||||||
|
process if INDEX is out of bounds. */
|
||||||
|
#if 0
|
||||||
|
static DYNARRAY_ELEMENT *
|
||||||
|
DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *list, size_t index);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Add ITEM at the end of the array, enlarging it by one element.
|
||||||
|
Mark *LIST as failed if the dynamic array allocation size cannot be
|
||||||
|
increased. */
|
||||||
|
#if 0
|
||||||
|
static void
|
||||||
|
DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *list,
|
||||||
|
DYNARRAY_ELEMENT item);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Allocate a place for a new element in *LIST and return a pointer to
|
||||||
|
it. The pointer can be NULL if the dynamic array cannot be
|
||||||
|
enlarged due to a memory allocation failure. */
|
||||||
|
#if 0
|
||||||
|
static DYNARRAY_ELEMENT *
|
||||||
|
DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Change the size of *LIST to SIZE. If SIZE is larger than the
|
||||||
|
existing size, new elements are added (which can be initialized).
|
||||||
|
Otherwise, the list is truncated, and elements are freed. Return
|
||||||
|
false on memory allocation failure (and mark *LIST as failed). */
|
||||||
|
#if 0
|
||||||
|
static bool
|
||||||
|
DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *list, size_t size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Remove the last element of LIST if it is present. */
|
||||||
|
#if 0
|
||||||
|
static void
|
||||||
|
DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Remove all elements from the list. The elements are freed, but the
|
||||||
|
list itself is not. */
|
||||||
|
#if 0
|
||||||
|
static void
|
||||||
|
DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined DYNARRAY_FINAL_TYPE
|
||||||
|
/* Transfer the dynamic array to a permanent location at *RESULT.
|
||||||
|
Returns true on success on false on allocation failure. In either
|
||||||
|
case, *LIST is re-initialized and can be reused. A NULL pointer is
|
||||||
|
stored in *RESULT if LIST refers to an empty list. On success, the
|
||||||
|
pointer in *RESULT is heap-allocated and must be deallocated using
|
||||||
|
free. */
|
||||||
|
#if 0
|
||||||
|
static bool
|
||||||
|
DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list,
|
||||||
|
DYNARRAY_FINAL_TYPE *result);
|
||||||
|
#endif
|
||||||
|
#else /* !defined DYNARRAY_FINAL_TYPE */
|
||||||
|
/* Transfer the dynamic array to a heap-allocated array and return a
|
||||||
|
pointer to it. The pointer is NULL if memory allocation fails, or
|
||||||
|
if the array is empty, so this function should be used only for
|
||||||
|
arrays which are known not be empty (usually because they always
|
||||||
|
have a sentinel at the end). If LENGTHP is not NULL, the array
|
||||||
|
length is written to *LENGTHP. *LIST is re-initialized and can be
|
||||||
|
reused. */
|
||||||
|
#if 0
|
||||||
|
static DYNARRAY_ELEMENT *
|
||||||
|
DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list,
|
||||||
|
size_t *lengthp);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* A minimal example which provides a growing list of integers can be
|
||||||
|
defined like this:
|
||||||
|
|
||||||
|
struct int_array
|
||||||
|
{
|
||||||
|
// Pointer to result array followed by its length,
|
||||||
|
// as required by DYNARRAY_FINAL_TYPE.
|
||||||
|
int *array;
|
||||||
|
size_t length;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define DYNARRAY_STRUCT dynarray_int
|
||||||
|
#define DYNARRAY_ELEMENT int
|
||||||
|
#define DYNARRAY_PREFIX dynarray_int_
|
||||||
|
#define DYNARRAY_FINAL_TYPE struct int_array
|
||||||
|
#include <malloc/dynarray-skeleton.c>
|
||||||
|
|
||||||
|
To create a three-element array with elements 1, 2, 3, use this
|
||||||
|
code:
|
||||||
|
|
||||||
|
struct dynarray_int dyn;
|
||||||
|
dynarray_int_init (&dyn);
|
||||||
|
for (int i = 1; i <= 3; ++i)
|
||||||
|
{
|
||||||
|
int *place = dynarray_int_emplace (&dyn);
|
||||||
|
assert (place != NULL);
|
||||||
|
*place = i;
|
||||||
|
}
|
||||||
|
struct int_array result;
|
||||||
|
bool ok = dynarray_int_finalize (&dyn, &result);
|
||||||
|
assert (ok);
|
||||||
|
assert (result.length == 3);
|
||||||
|
assert (result.array[0] == 1);
|
||||||
|
assert (result.array[1] == 2);
|
||||||
|
assert (result.array[2] == 3);
|
||||||
|
free (result.array);
|
||||||
|
|
||||||
|
If the elements contain resources which must be freed, define
|
||||||
|
DYNARRAY_ELEMENT_FREE appropriately, like this:
|
||||||
|
|
||||||
|
struct str_array
|
||||||
|
{
|
||||||
|
char **array;
|
||||||
|
size_t length;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define DYNARRAY_STRUCT dynarray_str
|
||||||
|
#define DYNARRAY_ELEMENT char *
|
||||||
|
#define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
|
||||||
|
#define DYNARRAY_PREFIX dynarray_str_
|
||||||
|
#define DYNARRAY_FINAL_TYPE struct str_array
|
||||||
|
#include <malloc/dynarray-skeleton.c>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* The implementation is imported from glibc. */
|
||||||
|
|
||||||
|
/* Avoid possible conflicts with symbols exported by the GNU libc. */
|
||||||
|
#define __libc_dynarray_at_failure gl_dynarray_at_failure
|
||||||
|
#define __libc_dynarray_emplace_enlarge gl_dynarray_emplace_enlarge
|
||||||
|
#define __libc_dynarray_finalize gl_dynarray_finalize
|
||||||
|
#define __libc_dynarray_resize_clear gl_dynarray_resize_clear
|
||||||
|
#define __libc_dynarray_resize gl_dynarray_resize
|
||||||
|
|
||||||
|
#if defined DYNARRAY_STRUCT || defined DYNARRAY_ELEMENT || defined DYNARRAY_PREFIX
|
||||||
|
|
||||||
|
# ifndef _GL_LIKELY
|
||||||
|
/* Rely on __builtin_expect, as provided by the module 'builtin-expect'. */
|
||||||
|
# define _GL_LIKELY(cond) __builtin_expect ((cond), 1)
|
||||||
|
# define _GL_UNLIKELY(cond) __builtin_expect ((cond), 0)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Define auxiliary structs and declare auxiliary functions, common to all
|
||||||
|
instantiations of dynarray. */
|
||||||
|
# include <malloc/dynarray.gl.h>
|
||||||
|
|
||||||
|
/* Define the instantiation, specified through
|
||||||
|
DYNARRAY_STRUCT
|
||||||
|
DYNARRAY_ELEMENT
|
||||||
|
DYNARRAY_PREFIX
|
||||||
|
etc. */
|
||||||
|
# include <malloc/dynarray-skeleton.gl.h>
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* This file is being included from one of the malloc/dynarray_*.c files. */
|
||||||
|
# include <malloc/dynarray.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _GL_DYNARRAY_H */
|
279
lib/errno.in.h
Normal file
279
lib/errno.in.h
Normal file
|
@ -0,0 +1,279 @@
|
||||||
|
/* A POSIX-like <errno.h>.
|
||||||
|
|
||||||
|
Copyright (C) 2008-2023 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 _@GUARD_PREFIX@_ERRNO_H
|
||||||
|
|
||||||
|
#if __GNUC__ >= 3
|
||||||
|
@PRAGMA_SYSTEM_HEADER@
|
||||||
|
#endif
|
||||||
|
@PRAGMA_COLUMNS@
|
||||||
|
|
||||||
|
/* The include_next requires a split double-inclusion guard. */
|
||||||
|
#@INCLUDE_NEXT@ @NEXT_ERRNO_H@
|
||||||
|
|
||||||
|
#ifndef _@GUARD_PREFIX@_ERRNO_H
|
||||||
|
#define _@GUARD_PREFIX@_ERRNO_H
|
||||||
|
|
||||||
|
|
||||||
|
/* On native Windows platforms, many macros are not defined. */
|
||||||
|
# if defined _WIN32 && ! defined __CYGWIN__
|
||||||
|
|
||||||
|
/* These are the same values as defined by MSVC 10, for interoperability. */
|
||||||
|
|
||||||
|
# ifndef ENOMSG
|
||||||
|
# define ENOMSG 122
|
||||||
|
# define GNULIB_defined_ENOMSG 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EIDRM
|
||||||
|
# define EIDRM 111
|
||||||
|
# define GNULIB_defined_EIDRM 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ENOLINK
|
||||||
|
# define ENOLINK 121
|
||||||
|
# define GNULIB_defined_ENOLINK 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EPROTO
|
||||||
|
# define EPROTO 134
|
||||||
|
# define GNULIB_defined_EPROTO 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EBADMSG
|
||||||
|
# define EBADMSG 104
|
||||||
|
# define GNULIB_defined_EBADMSG 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EOVERFLOW
|
||||||
|
# define EOVERFLOW 132
|
||||||
|
# define GNULIB_defined_EOVERFLOW 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ENOTSUP
|
||||||
|
# define ENOTSUP 129
|
||||||
|
# define GNULIB_defined_ENOTSUP 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ENETRESET
|
||||||
|
# define ENETRESET 117
|
||||||
|
# define GNULIB_defined_ENETRESET 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ECONNABORTED
|
||||||
|
# define ECONNABORTED 106
|
||||||
|
# define GNULIB_defined_ECONNABORTED 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ECANCELED
|
||||||
|
# define ECANCELED 105
|
||||||
|
# define GNULIB_defined_ECANCELED 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EOWNERDEAD
|
||||||
|
# define EOWNERDEAD 133
|
||||||
|
# define GNULIB_defined_EOWNERDEAD 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ENOTRECOVERABLE
|
||||||
|
# define ENOTRECOVERABLE 127
|
||||||
|
# define GNULIB_defined_ENOTRECOVERABLE 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EINPROGRESS
|
||||||
|
# define EINPROGRESS 112
|
||||||
|
# define EALREADY 103
|
||||||
|
# define ENOTSOCK 128
|
||||||
|
# define EDESTADDRREQ 109
|
||||||
|
# define EMSGSIZE 115
|
||||||
|
# define EPROTOTYPE 136
|
||||||
|
# define ENOPROTOOPT 123
|
||||||
|
# define EPROTONOSUPPORT 135
|
||||||
|
# define EOPNOTSUPP 130
|
||||||
|
# define EAFNOSUPPORT 102
|
||||||
|
# define EADDRINUSE 100
|
||||||
|
# define EADDRNOTAVAIL 101
|
||||||
|
# define ENETDOWN 116
|
||||||
|
# define ENETUNREACH 118
|
||||||
|
# define ECONNRESET 108
|
||||||
|
# define ENOBUFS 119
|
||||||
|
# define EISCONN 113
|
||||||
|
# define ENOTCONN 126
|
||||||
|
# define ETIMEDOUT 138
|
||||||
|
# define ECONNREFUSED 107
|
||||||
|
# define ELOOP 114
|
||||||
|
# define EHOSTUNREACH 110
|
||||||
|
# define EWOULDBLOCK 140
|
||||||
|
# define GNULIB_defined_ESOCK 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ETXTBSY
|
||||||
|
# define ETXTBSY 139
|
||||||
|
# define ENODATA 120 /* not required by POSIX */
|
||||||
|
# define ENOSR 124 /* not required by POSIX */
|
||||||
|
# define ENOSTR 125 /* not required by POSIX */
|
||||||
|
# define ETIME 137 /* not required by POSIX */
|
||||||
|
# define EOTHER 131 /* not required by POSIX */
|
||||||
|
# define GNULIB_defined_ESTREAMS 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* These are intentionally the same values as the WSA* error numbers, defined
|
||||||
|
in <winsock2.h>. */
|
||||||
|
# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */
|
||||||
|
# define EPFNOSUPPORT 10046 /* not required by POSIX */
|
||||||
|
# define ESHUTDOWN 10058 /* not required by POSIX */
|
||||||
|
# define ETOOMANYREFS 10059 /* not required by POSIX */
|
||||||
|
# define EHOSTDOWN 10064 /* not required by POSIX */
|
||||||
|
# define EPROCLIM 10067 /* not required by POSIX */
|
||||||
|
# define EUSERS 10068 /* not required by POSIX */
|
||||||
|
# define EDQUOT 10069
|
||||||
|
# define ESTALE 10070
|
||||||
|
# define EREMOTE 10071 /* not required by POSIX */
|
||||||
|
# define GNULIB_defined_EWINSOCK 1
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
|
||||||
|
EMULTIHOP, ENOLINK, EOVERFLOW are not defined. */
|
||||||
|
# if @EMULTIHOP_HIDDEN@
|
||||||
|
# define EMULTIHOP @EMULTIHOP_VALUE@
|
||||||
|
# define GNULIB_defined_EMULTIHOP 1
|
||||||
|
# endif
|
||||||
|
# if @ENOLINK_HIDDEN@
|
||||||
|
# define ENOLINK @ENOLINK_VALUE@
|
||||||
|
# define GNULIB_defined_ENOLINK 1
|
||||||
|
# endif
|
||||||
|
# if @EOVERFLOW_HIDDEN@
|
||||||
|
# define EOVERFLOW @EOVERFLOW_VALUE@
|
||||||
|
# define GNULIB_defined_EOVERFLOW 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
|
||||||
|
EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
|
||||||
|
Likewise, on NonStop Kernel, EDQUOT is not defined.
|
||||||
|
Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151,
|
||||||
|
HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
|
||||||
|
|
||||||
|
Note: When one of these systems defines some of these macros some day,
|
||||||
|
binaries will have to be recompiled so that they recognizes the new
|
||||||
|
errno values from the system. */
|
||||||
|
|
||||||
|
# ifndef ENOMSG
|
||||||
|
# define ENOMSG 2000
|
||||||
|
# define GNULIB_defined_ENOMSG 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EIDRM
|
||||||
|
# define EIDRM 2001
|
||||||
|
# define GNULIB_defined_EIDRM 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ENOLINK
|
||||||
|
# define ENOLINK 2002
|
||||||
|
# define GNULIB_defined_ENOLINK 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EPROTO
|
||||||
|
# define EPROTO 2003
|
||||||
|
# define GNULIB_defined_EPROTO 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EMULTIHOP
|
||||||
|
# define EMULTIHOP 2004
|
||||||
|
# define GNULIB_defined_EMULTIHOP 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EBADMSG
|
||||||
|
# define EBADMSG 2005
|
||||||
|
# define GNULIB_defined_EBADMSG 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EOVERFLOW
|
||||||
|
# define EOVERFLOW 2006
|
||||||
|
# define GNULIB_defined_EOVERFLOW 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ENOTSUP
|
||||||
|
# define ENOTSUP 2007
|
||||||
|
# define GNULIB_defined_ENOTSUP 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ENETRESET
|
||||||
|
# define ENETRESET 2011
|
||||||
|
# define GNULIB_defined_ENETRESET 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ECONNABORTED
|
||||||
|
# define ECONNABORTED 2012
|
||||||
|
# define GNULIB_defined_ECONNABORTED 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ESTALE
|
||||||
|
# define ESTALE 2009
|
||||||
|
# define GNULIB_defined_ESTALE 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EDQUOT
|
||||||
|
# define EDQUOT 2010
|
||||||
|
# define GNULIB_defined_EDQUOT 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ECANCELED
|
||||||
|
# define ECANCELED 2008
|
||||||
|
# define GNULIB_defined_ECANCELED 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not
|
||||||
|
defined. */
|
||||||
|
|
||||||
|
# ifndef EOWNERDEAD
|
||||||
|
# if defined __sun
|
||||||
|
/* Use the same values as defined for Solaris >= 8, for
|
||||||
|
interoperability. */
|
||||||
|
# define EOWNERDEAD 58
|
||||||
|
# define ENOTRECOVERABLE 59
|
||||||
|
# elif defined _WIN32 && ! defined __CYGWIN__
|
||||||
|
/* We have a conflict here: pthreads-win32 defines these values
|
||||||
|
differently than MSVC 10. It's hairy to decide which one to use. */
|
||||||
|
# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
|
||||||
|
/* Use the same values as defined by pthreads-win32, for
|
||||||
|
interoperability. */
|
||||||
|
# define EOWNERDEAD 43
|
||||||
|
# define ENOTRECOVERABLE 44
|
||||||
|
# else
|
||||||
|
/* Use the same values as defined by MSVC 10, for
|
||||||
|
interoperability. */
|
||||||
|
# define EOWNERDEAD 133
|
||||||
|
# define ENOTRECOVERABLE 127
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define EOWNERDEAD 2013
|
||||||
|
# define ENOTRECOVERABLE 2014
|
||||||
|
# endif
|
||||||
|
# define GNULIB_defined_EOWNERDEAD 1
|
||||||
|
# define GNULIB_defined_ENOTRECOVERABLE 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef EILSEQ
|
||||||
|
# define EILSEQ 2015
|
||||||
|
# define GNULIB_defined_EILSEQ 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif /* _@GUARD_PREFIX@_ERRNO_H */
|
||||||
|
#endif /* _@GUARD_PREFIX@_ERRNO_H */
|
411
lib/error.c
Normal file
411
lib/error.c
Normal file
|
@ -0,0 +1,411 @@
|
||||||
|
/* Error handler for noninteractive utilities
|
||||||
|
Copyright (C) 1990-1998, 2000-2007, 2009-2023 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
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 David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||||
|
|
||||||
|
#if !_LIBC
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if !_LIBC && ENABLE_NLS
|
||||||
|
# include "gettext.h"
|
||||||
|
# define _(msgid) gettext (msgid)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# include <libintl.h>
|
||||||
|
# include <stdbool.h>
|
||||||
|
# include <stdint.h>
|
||||||
|
# include <wchar.h>
|
||||||
|
# define mbsrtowcs __mbsrtowcs
|
||||||
|
# define USE_UNLOCKED_IO 0
|
||||||
|
# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b)
|
||||||
|
# define _GL_ARG_NONNULL(a)
|
||||||
|
#else
|
||||||
|
# include "getprogname.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_UNLOCKED_IO
|
||||||
|
# include "unlocked-io.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _
|
||||||
|
# define _(String) String
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If NULL, error will flush stdout, then print on stderr the program
|
||||||
|
name, a colon and a space. Otherwise, error will call this
|
||||||
|
function without parameters instead. */
|
||||||
|
void (*error_print_progname) (void);
|
||||||
|
|
||||||
|
/* This variable is incremented each time 'error' is called. */
|
||||||
|
unsigned int error_message_count;
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
/* In the GNU C library, there is a predefined variable for this. */
|
||||||
|
|
||||||
|
# define program_name program_invocation_name
|
||||||
|
# include <errno.h>
|
||||||
|
# include <limits.h>
|
||||||
|
# include <libio/libioP.h>
|
||||||
|
|
||||||
|
/* In GNU libc we want do not want to use the common name 'error' directly.
|
||||||
|
Instead make it a weak alias. */
|
||||||
|
extern void __error (int status, int errnum, const char *message, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
|
extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||||
|
unsigned int line_number, const char *message,
|
||||||
|
...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 5, 6)));
|
||||||
|
# define error __error
|
||||||
|
# define error_at_line __error_at_line
|
||||||
|
|
||||||
|
# include <libio/iolibio.h>
|
||||||
|
# define fflush(s) _IO_fflush (s)
|
||||||
|
# undef putc
|
||||||
|
# define putc(c, fp) _IO_putc (c, fp)
|
||||||
|
|
||||||
|
# include <bits/libc-lock.h>
|
||||||
|
|
||||||
|
#else /* not _LIBC */
|
||||||
|
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
|
||||||
|
# if defined _WIN32 && ! defined __CYGWIN__
|
||||||
|
/* Get declarations of the native Windows API functions. */
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h>
|
||||||
|
/* Get _get_osfhandle. */
|
||||||
|
# if GNULIB_MSVC_NOTHROW
|
||||||
|
# include "msvc-nothrow.h"
|
||||||
|
# else
|
||||||
|
# include <io.h>
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* The gnulib override of fcntl is not needed in this file. */
|
||||||
|
# undef fcntl
|
||||||
|
|
||||||
|
# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R)
|
||||||
|
# ifndef HAVE_DECL_STRERROR_R
|
||||||
|
"this configure-time declaration test was not run"
|
||||||
|
# endif
|
||||||
|
# if STRERROR_R_CHAR_P
|
||||||
|
char *strerror_r (int errnum, char *buf, size_t buflen);
|
||||||
|
# else
|
||||||
|
int strerror_r (int errnum, char *buf, size_t buflen);
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define program_name getprogname ()
|
||||||
|
|
||||||
|
# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
|
||||||
|
# define __strerror_r strerror_r
|
||||||
|
# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
|
||||||
|
#endif /* not _LIBC */
|
||||||
|
|
||||||
|
#if !_LIBC
|
||||||
|
/* Return non-zero if FD is open. */
|
||||||
|
static int
|
||||||
|
is_open (int fd)
|
||||||
|
{
|
||||||
|
# if defined _WIN32 && ! defined __CYGWIN__
|
||||||
|
/* On native Windows: The initial state of unassigned standard file
|
||||||
|
descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
|
||||||
|
There is no fcntl, and the gnulib replacement fcntl does not support
|
||||||
|
F_GETFL. */
|
||||||
|
return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
|
||||||
|
# else
|
||||||
|
# ifndef F_GETFL
|
||||||
|
# error Please port fcntl to your platform
|
||||||
|
# endif
|
||||||
|
return 0 <= fcntl (fd, F_GETFL);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
flush_stdout (void)
|
||||||
|
{
|
||||||
|
#if !_LIBC
|
||||||
|
int stdout_fd;
|
||||||
|
|
||||||
|
# if GNULIB_FREOPEN_SAFER
|
||||||
|
/* Use of gnulib's freopen-safer module normally ensures that
|
||||||
|
fileno (stdout) == 1
|
||||||
|
whenever stdout is open. */
|
||||||
|
stdout_fd = STDOUT_FILENO;
|
||||||
|
# else
|
||||||
|
/* POSIX states that fileno (stdout) after fclose is unspecified. But in
|
||||||
|
practice it is not a problem, because stdout is statically allocated and
|
||||||
|
the fd of a FILE stream is stored as a field in its allocated memory. */
|
||||||
|
stdout_fd = fileno (stdout);
|
||||||
|
# endif
|
||||||
|
/* POSIX states that fflush (stdout) after fclose is unspecified; it
|
||||||
|
is safe in glibc, but not on all other platforms. fflush (NULL)
|
||||||
|
is always defined, but too draconian. */
|
||||||
|
if (0 <= stdout_fd && is_open (stdout_fd))
|
||||||
|
#endif
|
||||||
|
fflush (stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_errno_message (int errnum)
|
||||||
|
{
|
||||||
|
char const *s;
|
||||||
|
|
||||||
|
#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R
|
||||||
|
char errbuf[1024];
|
||||||
|
# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P)
|
||||||
|
s = __strerror_r (errnum, errbuf, sizeof errbuf);
|
||||||
|
# else
|
||||||
|
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
|
||||||
|
s = errbuf;
|
||||||
|
else
|
||||||
|
s = 0;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
s = strerror (errnum);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !_LIBC
|
||||||
|
if (! s)
|
||||||
|
s = _("Unknown system error");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _LIBC
|
||||||
|
__fxprintf (NULL, ": %s", s);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, ": %s", s);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))
|
||||||
|
error_tail (int status, int errnum, const char *message, va_list args)
|
||||||
|
{
|
||||||
|
#if _LIBC
|
||||||
|
if (_IO_fwide (stderr, 0) > 0)
|
||||||
|
{
|
||||||
|
size_t len = strlen (message) + 1;
|
||||||
|
wchar_t *wmessage = NULL;
|
||||||
|
mbstate_t st;
|
||||||
|
size_t res;
|
||||||
|
const char *tmp;
|
||||||
|
bool use_malloc = false;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (__libc_use_alloca (len * sizeof (wchar_t)))
|
||||||
|
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!use_malloc)
|
||||||
|
wmessage = NULL;
|
||||||
|
|
||||||
|
wchar_t *p = (wchar_t *) realloc (wmessage,
|
||||||
|
len * sizeof (wchar_t));
|
||||||
|
if (p == NULL)
|
||||||
|
{
|
||||||
|
free (wmessage);
|
||||||
|
fputws_unlocked (L"out of memory\n", stderr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wmessage = p;
|
||||||
|
use_malloc = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset (&st, '\0', sizeof (st));
|
||||||
|
tmp = message;
|
||||||
|
|
||||||
|
res = mbsrtowcs (wmessage, &tmp, len, &st);
|
||||||
|
if (res != len)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0))
|
||||||
|
{
|
||||||
|
/* This really should not happen if everything is fine. */
|
||||||
|
res = (size_t) -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
len *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == (size_t) -1)
|
||||||
|
{
|
||||||
|
/* The string cannot be converted. */
|
||||||
|
if (use_malloc)
|
||||||
|
{
|
||||||
|
free (wmessage);
|
||||||
|
use_malloc = false;
|
||||||
|
}
|
||||||
|
wmessage = (wchar_t *) L"???";
|
||||||
|
}
|
||||||
|
|
||||||
|
__vfwprintf (stderr, wmessage, args);
|
||||||
|
|
||||||
|
if (use_malloc)
|
||||||
|
free (wmessage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
vfprintf (stderr, message, args);
|
||||||
|
|
||||||
|
++error_message_count;
|
||||||
|
if (errnum)
|
||||||
|
print_errno_message (errnum);
|
||||||
|
#if _LIBC
|
||||||
|
__fxprintf (NULL, "\n");
|
||||||
|
#else
|
||||||
|
putc ('\n', stderr);
|
||||||
|
#endif
|
||||||
|
fflush (stderr);
|
||||||
|
if (status)
|
||||||
|
exit (status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||||
|
format string with optional args.
|
||||||
|
If ERRNUM is nonzero, print its corresponding system error message.
|
||||||
|
Exit with status STATUS if it is nonzero. */
|
||||||
|
void
|
||||||
|
error (int status, int errnum, const char *message, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
#if defined _LIBC && defined __libc_ptf_call
|
||||||
|
/* We do not want this call to be cut short by a thread
|
||||||
|
cancellation. Therefore disable cancellation for now. */
|
||||||
|
int state = PTHREAD_CANCEL_ENABLE;
|
||||||
|
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||||
|
0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
flush_stdout ();
|
||||||
|
#ifdef _LIBC
|
||||||
|
_IO_flockfile (stderr);
|
||||||
|
#endif
|
||||||
|
if (error_print_progname)
|
||||||
|
(*error_print_progname) ();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if _LIBC
|
||||||
|
__fxprintf (NULL, "%s: ", program_name);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, "%s: ", program_name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
va_start (args, message);
|
||||||
|
error_tail (status, errnum, message, args);
|
||||||
|
va_end (args);
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
_IO_funlockfile (stderr);
|
||||||
|
# ifdef __libc_ptf_call
|
||||||
|
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sometimes we want to have at most one error per line. This
|
||||||
|
variable controls whether this mode is selected or not. */
|
||||||
|
int error_one_per_line;
|
||||||
|
|
||||||
|
void
|
||||||
|
error_at_line (int status, int errnum, const char *file_name,
|
||||||
|
unsigned int line_number, const char *message, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
if (error_one_per_line)
|
||||||
|
{
|
||||||
|
static const char *old_file_name;
|
||||||
|
static unsigned int old_line_number;
|
||||||
|
|
||||||
|
if (old_line_number == line_number
|
||||||
|
&& (file_name == old_file_name
|
||||||
|
|| (old_file_name != NULL
|
||||||
|
&& file_name != NULL
|
||||||
|
&& strcmp (old_file_name, file_name) == 0)))
|
||||||
|
|
||||||
|
/* Simply return and print nothing. */
|
||||||
|
return;
|
||||||
|
|
||||||
|
old_file_name = file_name;
|
||||||
|
old_line_number = line_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined _LIBC && defined __libc_ptf_call
|
||||||
|
/* We do not want this call to be cut short by a thread
|
||||||
|
cancellation. Therefore disable cancellation for now. */
|
||||||
|
int state = PTHREAD_CANCEL_ENABLE;
|
||||||
|
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||||
|
0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
flush_stdout ();
|
||||||
|
#ifdef _LIBC
|
||||||
|
_IO_flockfile (stderr);
|
||||||
|
#endif
|
||||||
|
if (error_print_progname)
|
||||||
|
(*error_print_progname) ();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if _LIBC
|
||||||
|
__fxprintf (NULL, "%s:", program_name);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, "%s:", program_name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if _LIBC
|
||||||
|
__fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ",
|
||||||
|
file_name, line_number);
|
||||||
|
#else
|
||||||
|
fprintf (stderr, file_name != NULL ? "%s:%u: " : " ",
|
||||||
|
file_name, line_number);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
va_start (args, message);
|
||||||
|
error_tail (status, errnum, message, args);
|
||||||
|
va_end (args);
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
_IO_funlockfile (stderr);
|
||||||
|
# ifdef __libc_ptf_call
|
||||||
|
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
/* Make the weak alias. */
|
||||||
|
# undef error
|
||||||
|
# undef error_at_line
|
||||||
|
weak_alias (__error, error)
|
||||||
|
weak_alias (__error_at_line, error_at_line)
|
||||||
|
#endif
|
104
lib/error.in.h
Normal file
104
lib/error.in.h
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/* Declarations for error-reporting functions.
|
||||||
|
Copyright (C) 1995-1997, 2003, 2006, 2008-2023 Free Software Foundation,
|
||||||
|
Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
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 _ERROR_H
|
||||||
|
#define _ERROR_H 1
|
||||||
|
|
||||||
|
/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||||
|
|
||||||
|
#if GNULIB_VFPRINTF_POSIX
|
||||||
|
# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
|
||||||
|
#else
|
||||||
|
# define _GL_ATTRIBUTE_SPEC_PRINTF_ERROR _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Print a message with 'fprintf (stderr, FORMAT, ...)';
|
||||||
|
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||||
|
If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
|
||||||
|
#if @REPLACE_ERROR@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef error
|
||||||
|
# define error rpl_error
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (error, void,
|
||||||
|
(int __status, int __errnum, const char *__format, ...)
|
||||||
|
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)));
|
||||||
|
_GL_CXXALIAS_RPL (error, void,
|
||||||
|
(int __status, int __errnum, const char *__format, ...));
|
||||||
|
#else
|
||||||
|
# if ! @HAVE_ERROR@
|
||||||
|
_GL_FUNCDECL_SYS (error, void,
|
||||||
|
(int __status, int __errnum, const char *__format, ...)
|
||||||
|
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 3, 4)));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (error, void,
|
||||||
|
(int __status, int __errnum, const char *__format, ...));
|
||||||
|
#endif
|
||||||
|
_GL_CXXALIASWARN (error);
|
||||||
|
|
||||||
|
/* Likewise. If FILENAME is non-NULL, include FILENAME:LINENO: in the
|
||||||
|
message. */
|
||||||
|
#if @REPLACE_ERROR_AT_LINE@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef error_at_line
|
||||||
|
# define error_at_line rpl_error_at_line
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (error_at_line, void,
|
||||||
|
(int __status, int __errnum, const char *__filename,
|
||||||
|
unsigned int __lineno, const char *__format, ...)
|
||||||
|
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)));
|
||||||
|
_GL_CXXALIAS_RPL (error_at_line, void,
|
||||||
|
(int __status, int __errnum, const char *__filename,
|
||||||
|
unsigned int __lineno, const char *__format, ...));
|
||||||
|
#else
|
||||||
|
# if ! @HAVE_ERROR_AT_LINE@
|
||||||
|
_GL_FUNCDECL_SYS (error_at_line, void,
|
||||||
|
(int __status, int __errnum, const char *__filename,
|
||||||
|
unsigned int __lineno, const char *__format, ...)
|
||||||
|
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_ERROR, 5, 6)));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (error_at_line, void,
|
||||||
|
(int __status, int __errnum, const char *__filename,
|
||||||
|
unsigned int __lineno, const char *__format, ...));
|
||||||
|
#endif
|
||||||
|
_GL_CXXALIASWARN (error_at_line);
|
||||||
|
|
||||||
|
/* If NULL, error will flush stdout, then print on stderr the program
|
||||||
|
name, a colon and a space. Otherwise, error will call this
|
||||||
|
function without parameters instead. */
|
||||||
|
extern void (*error_print_progname) (void);
|
||||||
|
|
||||||
|
/* This variable is incremented each time 'error' is called. */
|
||||||
|
extern unsigned int error_message_count;
|
||||||
|
|
||||||
|
/* Sometimes we want to have at most one error per line. This
|
||||||
|
variable controls whether this mode is selected or not. */
|
||||||
|
extern int error_one_per_line;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* error.h */
|
24
lib/exitfail.c
Normal file
24
lib/exitfail.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/* Failure exit status
|
||||||
|
|
||||||
|
Copyright (C) 2002-2003, 2005-2007, 2009-2023 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>
|
||||||
|
|
||||||
|
#include "exitfail.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int volatile exit_failure = EXIT_FAILURE;
|
18
lib/exitfail.h
Normal file
18
lib/exitfail.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/* Failure exit status
|
||||||
|
|
||||||
|
Copyright (C) 2002, 2009-2023 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/>. */
|
||||||
|
|
||||||
|
extern int volatile exit_failure;
|
205
lib/fchdir.c
Normal file
205
lib/fchdir.c
Normal file
|
@ -0,0 +1,205 @@
|
||||||
|
/* fchdir replacement.
|
||||||
|
Copyright (C) 2006-2023 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/>. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "assure.h"
|
||||||
|
#include "filename.h"
|
||||||
|
#include "filenamecat.h"
|
||||||
|
|
||||||
|
#ifndef REPLACE_OPEN_DIRECTORY
|
||||||
|
# define REPLACE_OPEN_DIRECTORY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This replacement assumes that a directory is not renamed while opened
|
||||||
|
through a file descriptor.
|
||||||
|
|
||||||
|
FIXME: On mingw, this would be possible to enforce if we were to
|
||||||
|
also open a HANDLE to each directory currently visited by a file
|
||||||
|
descriptor, since mingw refuses to rename any in-use file system
|
||||||
|
object. */
|
||||||
|
|
||||||
|
/* Array of file descriptors opened. If REPLACE_OPEN_DIRECTORY or if it points
|
||||||
|
to a directory, it stores info about this directory. */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char *name; /* Absolute name of the directory, or NULL. */
|
||||||
|
/* FIXME - add a DIR* member to make dirfd possible on mingw? */
|
||||||
|
} dir_info_t;
|
||||||
|
static dir_info_t *dirs;
|
||||||
|
static size_t dirs_allocated;
|
||||||
|
|
||||||
|
/* Try to ensure dirs has enough room for a slot at index fd; free any
|
||||||
|
contents already in that slot. Return false and set errno to
|
||||||
|
ENOMEM on allocation failure. */
|
||||||
|
static bool
|
||||||
|
ensure_dirs_slot (size_t fd)
|
||||||
|
{
|
||||||
|
if (fd < dirs_allocated)
|
||||||
|
free (dirs[fd].name);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t new_allocated;
|
||||||
|
dir_info_t *new_dirs;
|
||||||
|
|
||||||
|
new_allocated = 2 * dirs_allocated + 1;
|
||||||
|
if (new_allocated <= fd)
|
||||||
|
new_allocated = fd + 1;
|
||||||
|
new_dirs =
|
||||||
|
(dirs != NULL
|
||||||
|
? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs)
|
||||||
|
: (dir_info_t *) malloc (new_allocated * sizeof *dirs));
|
||||||
|
if (new_dirs == NULL)
|
||||||
|
return false;
|
||||||
|
memset (new_dirs + dirs_allocated, 0,
|
||||||
|
(new_allocated - dirs_allocated) * sizeof *dirs);
|
||||||
|
dirs = new_dirs;
|
||||||
|
dirs_allocated = new_allocated;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return an absolute name of DIR in malloc'd storage.
|
||||||
|
Upon failure, return NULL with errno set. */
|
||||||
|
static char *
|
||||||
|
get_name (char const *dir)
|
||||||
|
{
|
||||||
|
char *cwd;
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
if (IS_ABSOLUTE_FILE_NAME (dir))
|
||||||
|
return strdup (dir);
|
||||||
|
|
||||||
|
/* We often encounter "."; treat it as a special case. */
|
||||||
|
cwd = getcwd (NULL, 0);
|
||||||
|
if (!cwd || (dir[0] == '.' && dir[1] == '\0'))
|
||||||
|
return cwd;
|
||||||
|
|
||||||
|
result = mfile_name_concat (cwd, dir, NULL);
|
||||||
|
free (cwd);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hook into the gnulib replacements for open() and close() to keep track
|
||||||
|
of the open file descriptors. */
|
||||||
|
|
||||||
|
/* Close FD, cleaning up any fd to name mapping if fd was visiting a
|
||||||
|
directory. */
|
||||||
|
void
|
||||||
|
_gl_unregister_fd (int fd)
|
||||||
|
{
|
||||||
|
if (fd >= 0 && fd < dirs_allocated)
|
||||||
|
{
|
||||||
|
free (dirs[fd].name);
|
||||||
|
dirs[fd].name = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mark FD as visiting FILENAME. FD must be non-negative, and refer
|
||||||
|
to an open file descriptor. If REPLACE_OPEN_DIRECTORY is non-zero,
|
||||||
|
this should only be called if FD is visiting a directory. Close FD
|
||||||
|
and return -1 with errno set if there is insufficient memory to track
|
||||||
|
the directory name; otherwise return FD. */
|
||||||
|
int
|
||||||
|
_gl_register_fd (int fd, const char *filename)
|
||||||
|
{
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
|
assure (0 <= fd);
|
||||||
|
if (REPLACE_OPEN_DIRECTORY
|
||||||
|
|| (fstat (fd, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)))
|
||||||
|
{
|
||||||
|
if (!ensure_dirs_slot (fd)
|
||||||
|
|| (dirs[fd].name = get_name (filename)) == NULL)
|
||||||
|
{
|
||||||
|
int saved_errno = errno;
|
||||||
|
close (fd);
|
||||||
|
errno = saved_errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mark NEWFD as a duplicate of OLDFD; useful from dup, dup2, dup3,
|
||||||
|
and fcntl. Both arguments must be valid and distinct file
|
||||||
|
descriptors. Close NEWFD and return -1 if OLDFD is tracking a
|
||||||
|
directory, but there is insufficient memory to track the same
|
||||||
|
directory in NEWFD; otherwise return NEWFD. */
|
||||||
|
int
|
||||||
|
_gl_register_dup (int oldfd, int newfd)
|
||||||
|
{
|
||||||
|
assure (0 <= oldfd && 0 <= newfd && oldfd != newfd);
|
||||||
|
if (oldfd < dirs_allocated && dirs[oldfd].name)
|
||||||
|
{
|
||||||
|
/* Duplicated a directory; must ensure newfd is allocated. */
|
||||||
|
if (!ensure_dirs_slot (newfd)
|
||||||
|
|| (dirs[newfd].name = strdup (dirs[oldfd].name)) == NULL)
|
||||||
|
{
|
||||||
|
int saved_errno = errno;
|
||||||
|
close (newfd);
|
||||||
|
errno = saved_errno;
|
||||||
|
newfd = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (newfd < dirs_allocated)
|
||||||
|
{
|
||||||
|
/* Duplicated a non-directory; ensure newfd is cleared. */
|
||||||
|
free (dirs[newfd].name);
|
||||||
|
dirs[newfd].name = NULL;
|
||||||
|
}
|
||||||
|
return newfd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If FD is currently visiting a directory, then return the name of
|
||||||
|
that directory. Otherwise, return NULL and set errno. */
|
||||||
|
const char *
|
||||||
|
_gl_directory_name (int fd)
|
||||||
|
{
|
||||||
|
if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL)
|
||||||
|
return dirs[fd].name;
|
||||||
|
/* At this point, fd is either invalid, or open but not a directory.
|
||||||
|
If dup2 fails, errno is correctly EBADF. */
|
||||||
|
if (0 <= fd)
|
||||||
|
{
|
||||||
|
if (dup2 (fd, fd) == fd)
|
||||||
|
errno = ENOTDIR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
errno = EBADF;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Implement fchdir() in terms of chdir(). */
|
||||||
|
|
||||||
|
int
|
||||||
|
fchdir (int fd)
|
||||||
|
{
|
||||||
|
const char *name = _gl_directory_name (fd);
|
||||||
|
return name ? chdir (name) : -1;
|
||||||
|
}
|
629
lib/fcntl.c
Normal file
629
lib/fcntl.c
Normal file
|
@ -0,0 +1,629 @@
|
||||||
|
/* Provide file descriptor control.
|
||||||
|
|
||||||
|
Copyright (C) 2009-2023 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 Eric Blake <ebb9@byu.net>. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef __KLIBC__
|
||||||
|
# define INCL_DOS
|
||||||
|
# include <os2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _WIN32 && ! defined __CYGWIN__
|
||||||
|
/* Get declarations of the native Windows API functions. */
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h>
|
||||||
|
|
||||||
|
/* Get _get_osfhandle. */
|
||||||
|
# if GNULIB_MSVC_NOTHROW
|
||||||
|
# include "msvc-nothrow.h"
|
||||||
|
# else
|
||||||
|
# include <io.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
|
||||||
|
# define OPEN_MAX_MAX 0x10000
|
||||||
|
|
||||||
|
/* Duplicate OLDFD into the first available slot of at least NEWFD,
|
||||||
|
which must be positive, with FLAGS determining whether the duplicate
|
||||||
|
will be inheritable. */
|
||||||
|
static int
|
||||||
|
dupfd (int oldfd, int newfd, int flags)
|
||||||
|
{
|
||||||
|
/* Mingw has no way to create an arbitrary fd. Iterate until all
|
||||||
|
file descriptors less than newfd are filled up. */
|
||||||
|
HANDLE curr_process = GetCurrentProcess ();
|
||||||
|
HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
|
||||||
|
unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
|
||||||
|
unsigned int fds_to_close_bound = 0;
|
||||||
|
int result;
|
||||||
|
BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
|
||||||
|
int mode;
|
||||||
|
|
||||||
|
if (newfd < 0 || getdtablesize () <= newfd)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (old_handle == INVALID_HANDLE_VALUE
|
||||||
|
|| (mode = _setmode (oldfd, O_BINARY)) == -1)
|
||||||
|
{
|
||||||
|
/* oldfd is not open, or is an unassigned standard file
|
||||||
|
descriptor. */
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
_setmode (oldfd, mode);
|
||||||
|
flags |= mode;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
HANDLE new_handle;
|
||||||
|
int duplicated_fd;
|
||||||
|
unsigned int index;
|
||||||
|
|
||||||
|
if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
|
||||||
|
old_handle, /* SourceHandle */
|
||||||
|
curr_process, /* TargetProcessHandle */
|
||||||
|
(PHANDLE) &new_handle, /* TargetHandle */
|
||||||
|
(DWORD) 0, /* DesiredAccess */
|
||||||
|
inherit, /* InheritHandle */
|
||||||
|
DUPLICATE_SAME_ACCESS)) /* Options */
|
||||||
|
{
|
||||||
|
switch (GetLastError ())
|
||||||
|
{
|
||||||
|
case ERROR_TOO_MANY_OPEN_FILES:
|
||||||
|
errno = EMFILE;
|
||||||
|
break;
|
||||||
|
case ERROR_INVALID_HANDLE:
|
||||||
|
case ERROR_INVALID_TARGET_HANDLE:
|
||||||
|
case ERROR_DIRECT_ACCESS_HANDLE:
|
||||||
|
errno = EBADF;
|
||||||
|
break;
|
||||||
|
case ERROR_INVALID_PARAMETER:
|
||||||
|
case ERROR_INVALID_FUNCTION:
|
||||||
|
case ERROR_INVALID_ACCESS:
|
||||||
|
errno = EINVAL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errno = EACCES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags);
|
||||||
|
if (duplicated_fd < 0)
|
||||||
|
{
|
||||||
|
CloseHandle (new_handle);
|
||||||
|
result = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (newfd <= duplicated_fd)
|
||||||
|
{
|
||||||
|
result = duplicated_fd;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the bit duplicated_fd in fds_to_close[]. */
|
||||||
|
index = (unsigned int) duplicated_fd / CHAR_BIT;
|
||||||
|
if (fds_to_close_bound <= index)
|
||||||
|
{
|
||||||
|
if (sizeof fds_to_close <= index)
|
||||||
|
/* Need to increase OPEN_MAX_MAX. */
|
||||||
|
abort ();
|
||||||
|
memset (fds_to_close + fds_to_close_bound, '\0',
|
||||||
|
index + 1 - fds_to_close_bound);
|
||||||
|
fds_to_close_bound = index + 1;
|
||||||
|
}
|
||||||
|
fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the previous fds that turned out to be too small. */
|
||||||
|
{
|
||||||
|
int saved_errno = errno;
|
||||||
|
unsigned int duplicated_fd;
|
||||||
|
|
||||||
|
for (duplicated_fd = 0;
|
||||||
|
duplicated_fd < fds_to_close_bound * CHAR_BIT;
|
||||||
|
duplicated_fd++)
|
||||||
|
if ((fds_to_close[duplicated_fd / CHAR_BIT]
|
||||||
|
>> (duplicated_fd % CHAR_BIT))
|
||||||
|
& 1)
|
||||||
|
close (duplicated_fd);
|
||||||
|
|
||||||
|
errno = saved_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
# if REPLACE_FCHDIR
|
||||||
|
if (0 <= result)
|
||||||
|
result = _gl_register_dup (oldfd, result);
|
||||||
|
# endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif /* W32 */
|
||||||
|
|
||||||
|
/* Forward declarations, because we '#undef fcntl' in the middle of this
|
||||||
|
compilation unit. */
|
||||||
|
/* Our implementation of fcntl (fd, F_DUPFD, target). */
|
||||||
|
static int rpl_fcntl_DUPFD (int fd, int target);
|
||||||
|
/* Our implementation of fcntl (fd, F_DUPFD_CLOEXEC, target). */
|
||||||
|
static int rpl_fcntl_DUPFD_CLOEXEC (int fd, int target);
|
||||||
|
#ifdef __KLIBC__
|
||||||
|
/* Adds support for fcntl on directories. */
|
||||||
|
static int klibc_fcntl (int fd, int action, /* arg */...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Perform the specified ACTION on the file descriptor FD, possibly
|
||||||
|
using the argument ARG further described below. This replacement
|
||||||
|
handles the following actions, and forwards all others on to the
|
||||||
|
native fcntl. An unrecognized ACTION returns -1 with errno set to
|
||||||
|
EINVAL.
|
||||||
|
|
||||||
|
F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
|
||||||
|
If successful, return the duplicate, which will be inheritable;
|
||||||
|
otherwise return -1 and set errno.
|
||||||
|
|
||||||
|
F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
|
||||||
|
target fd. If successful, return the duplicate, which will not be
|
||||||
|
inheritable; otherwise return -1 and set errno.
|
||||||
|
|
||||||
|
F_GETFD - ARG need not be present. If successful, return a
|
||||||
|
non-negative value containing the descriptor flags of FD (only
|
||||||
|
FD_CLOEXEC is portable, but other flags may be present); otherwise
|
||||||
|
return -1 and set errno. */
|
||||||
|
|
||||||
|
int
|
||||||
|
fcntl (int fd, int action, /* arg */...)
|
||||||
|
#undef fcntl
|
||||||
|
#ifdef __KLIBC__
|
||||||
|
# define fcntl klibc_fcntl
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
va_list arg;
|
||||||
|
int result = -1;
|
||||||
|
va_start (arg, action);
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case F_DUPFD:
|
||||||
|
{
|
||||||
|
int target = va_arg (arg, int);
|
||||||
|
result = rpl_fcntl_DUPFD (fd, target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case F_DUPFD_CLOEXEC:
|
||||||
|
{
|
||||||
|
int target = va_arg (arg, int);
|
||||||
|
result = rpl_fcntl_DUPFD_CLOEXEC (fd, target);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !HAVE_FCNTL
|
||||||
|
case F_GETFD:
|
||||||
|
{
|
||||||
|
# if defined _WIN32 && ! defined __CYGWIN__
|
||||||
|
HANDLE handle = (HANDLE) _get_osfhandle (fd);
|
||||||
|
DWORD flags;
|
||||||
|
if (handle == INVALID_HANDLE_VALUE
|
||||||
|
|| GetHandleInformation (handle, &flags) == 0)
|
||||||
|
errno = EBADF;
|
||||||
|
else
|
||||||
|
result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
|
||||||
|
# else /* !W32 */
|
||||||
|
/* Use dup2 to reject invalid file descriptors. No way to
|
||||||
|
access this information, so punt. */
|
||||||
|
if (0 <= dup2 (fd, fd))
|
||||||
|
result = 0;
|
||||||
|
# endif /* !W32 */
|
||||||
|
break;
|
||||||
|
} /* F_GETFD */
|
||||||
|
#endif /* !HAVE_FCNTL */
|
||||||
|
|
||||||
|
/* Implementing F_SETFD on mingw is not trivial - there is no
|
||||||
|
API for changing the O_NOINHERIT bit on an fd, and merely
|
||||||
|
changing the HANDLE_FLAG_INHERIT bit on the underlying handle
|
||||||
|
can lead to odd state. It may be possible by duplicating the
|
||||||
|
handle, using _open_osfhandle with the right flags, then
|
||||||
|
using dup2 to move the duplicate onto the original, but that
|
||||||
|
is not supported for now. */
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
#if HAVE_FCNTL
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
#ifdef F_BARRIERFSYNC /* macOS */
|
||||||
|
case F_BARRIERFSYNC:
|
||||||
|
#endif
|
||||||
|
#ifdef F_CHKCLEAN /* macOS */
|
||||||
|
case F_CHKCLEAN:
|
||||||
|
#endif
|
||||||
|
#ifdef F_CLOSEM /* NetBSD, HP-UX */
|
||||||
|
case F_CLOSEM:
|
||||||
|
#endif
|
||||||
|
#ifdef F_FLUSH_DATA /* macOS */
|
||||||
|
case F_FLUSH_DATA:
|
||||||
|
#endif
|
||||||
|
#ifdef F_FREEZE_FS /* macOS */
|
||||||
|
case F_FREEZE_FS:
|
||||||
|
#endif
|
||||||
|
#ifdef F_FULLFSYNC /* macOS */
|
||||||
|
case F_FULLFSYNC:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETCONFINED /* macOS */
|
||||||
|
case F_GETCONFINED:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETDEFAULTPROTLEVEL /* macOS */
|
||||||
|
case F_GETDEFAULTPROTLEVEL:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETFD /* POSIX */
|
||||||
|
case F_GETFD:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETFL /* POSIX */
|
||||||
|
case F_GETFL:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETLEASE /* Linux */
|
||||||
|
case F_GETLEASE:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETNOSIGPIPE /* macOS */
|
||||||
|
case F_GETNOSIGPIPE:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETOWN /* POSIX */
|
||||||
|
case F_GETOWN:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETPIPE_SZ /* Linux */
|
||||||
|
case F_GETPIPE_SZ:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETPROTECTIONCLASS /* macOS */
|
||||||
|
case F_GETPROTECTIONCLASS:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETPROTECTIONLEVEL /* macOS */
|
||||||
|
case F_GETPROTECTIONLEVEL:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GET_SEALS /* Linux */
|
||||||
|
case F_GET_SEALS:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETSIG /* Linux */
|
||||||
|
case F_GETSIG:
|
||||||
|
#endif
|
||||||
|
#ifdef F_MAXFD /* NetBSD */
|
||||||
|
case F_MAXFD:
|
||||||
|
#endif
|
||||||
|
#ifdef F_RECYCLE /* macOS */
|
||||||
|
case F_RECYCLE:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETFIFOENH /* HP-UX */
|
||||||
|
case F_SETFIFOENH:
|
||||||
|
#endif
|
||||||
|
#ifdef F_THAW_FS /* macOS */
|
||||||
|
case F_THAW_FS:
|
||||||
|
#endif
|
||||||
|
/* These actions take no argument. */
|
||||||
|
result = fcntl (fd, action);
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef F_ADD_SEALS /* Linux */
|
||||||
|
case F_ADD_SEALS:
|
||||||
|
#endif
|
||||||
|
#ifdef F_BADFD /* Solaris */
|
||||||
|
case F_BADFD:
|
||||||
|
#endif
|
||||||
|
#ifdef F_CHECK_OPENEVT /* macOS */
|
||||||
|
case F_CHECK_OPENEVT:
|
||||||
|
#endif
|
||||||
|
#ifdef F_DUP2FD /* FreeBSD, AIX, Solaris */
|
||||||
|
case F_DUP2FD:
|
||||||
|
#endif
|
||||||
|
#ifdef F_DUP2FD_CLOEXEC /* FreeBSD, Solaris */
|
||||||
|
case F_DUP2FD_CLOEXEC:
|
||||||
|
#endif
|
||||||
|
#ifdef F_DUP2FD_CLOFORK /* Solaris */
|
||||||
|
case F_DUP2FD_CLOFORK:
|
||||||
|
#endif
|
||||||
|
#ifdef F_DUPFD /* POSIX */
|
||||||
|
case F_DUPFD:
|
||||||
|
#endif
|
||||||
|
#ifdef F_DUPFD_CLOEXEC /* POSIX */
|
||||||
|
case F_DUPFD_CLOEXEC:
|
||||||
|
#endif
|
||||||
|
#ifdef F_DUPFD_CLOFORK /* Solaris */
|
||||||
|
case F_DUPFD_CLOFORK:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GETXFL /* Solaris */
|
||||||
|
case F_GETXFL:
|
||||||
|
#endif
|
||||||
|
#ifdef F_GLOBAL_NOCACHE /* macOS */
|
||||||
|
case F_GLOBAL_NOCACHE:
|
||||||
|
#endif
|
||||||
|
#ifdef F_MAKECOMPRESSED /* macOS */
|
||||||
|
case F_MAKECOMPRESSED:
|
||||||
|
#endif
|
||||||
|
#ifdef F_MOVEDATAEXTENTS /* macOS */
|
||||||
|
case F_MOVEDATAEXTENTS:
|
||||||
|
#endif
|
||||||
|
#ifdef F_NOCACHE /* macOS */
|
||||||
|
case F_NOCACHE:
|
||||||
|
#endif
|
||||||
|
#ifdef F_NODIRECT /* macOS */
|
||||||
|
case F_NODIRECT:
|
||||||
|
#endif
|
||||||
|
#ifdef F_NOTIFY /* Linux */
|
||||||
|
case F_NOTIFY:
|
||||||
|
#endif
|
||||||
|
#ifdef F_OPLKACK /* IRIX */
|
||||||
|
case F_OPLKACK:
|
||||||
|
#endif
|
||||||
|
#ifdef F_OPLKREG /* IRIX */
|
||||||
|
case F_OPLKREG:
|
||||||
|
#endif
|
||||||
|
#ifdef F_RDAHEAD /* macOS */
|
||||||
|
case F_RDAHEAD:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETBACKINGSTORE /* macOS */
|
||||||
|
case F_SETBACKINGSTORE:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETCONFINED /* macOS */
|
||||||
|
case F_SETCONFINED:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETFD /* POSIX */
|
||||||
|
case F_SETFD:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETFL /* POSIX */
|
||||||
|
case F_SETFL:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETLEASE /* Linux */
|
||||||
|
case F_SETLEASE:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETNOSIGPIPE /* macOS */
|
||||||
|
case F_SETNOSIGPIPE:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETOWN /* POSIX */
|
||||||
|
case F_SETOWN:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETPIPE_SZ /* Linux */
|
||||||
|
case F_SETPIPE_SZ:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETPROTECTIONCLASS /* macOS */
|
||||||
|
case F_SETPROTECTIONCLASS:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SETSIG /* Linux */
|
||||||
|
case F_SETSIG:
|
||||||
|
#endif
|
||||||
|
#ifdef F_SINGLE_WRITER /* macOS */
|
||||||
|
case F_SINGLE_WRITER:
|
||||||
|
#endif
|
||||||
|
/* These actions take an 'int' argument. */
|
||||||
|
{
|
||||||
|
int x = va_arg (arg, int);
|
||||||
|
result = fcntl (fd, action, x);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* Other actions take a pointer argument. */
|
||||||
|
{
|
||||||
|
void *p = va_arg (arg, void *);
|
||||||
|
result = fcntl (fd, action, p);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
errno = EINVAL;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
va_end (arg);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
rpl_fcntl_DUPFD (int fd, int target)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
#if !HAVE_FCNTL
|
||||||
|
result = dupfd (fd, target, 0);
|
||||||
|
#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
|
||||||
|
/* Detect invalid target; needed for cygwin 1.5.x. */
|
||||||
|
if (target < 0 || getdtablesize () <= target)
|
||||||
|
{
|
||||||
|
result = -1;
|
||||||
|
errno = EINVAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Haiku alpha 2 loses fd flags on original. */
|
||||||
|
int flags = fcntl (fd, F_GETFD);
|
||||||
|
if (flags < 0)
|
||||||
|
result = -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = fcntl (fd, F_DUPFD, target);
|
||||||
|
if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
|
||||||
|
{
|
||||||
|
int saved_errno = errno;
|
||||||
|
close (result);
|
||||||
|
result = -1;
|
||||||
|
errno = saved_errno;
|
||||||
|
}
|
||||||
|
# if REPLACE_FCHDIR
|
||||||
|
if (0 <= result)
|
||||||
|
result = _gl_register_dup (fd, result);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
result = fcntl (fd, F_DUPFD, target);
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
#if !HAVE_FCNTL
|
||||||
|
result = dupfd (fd, target, O_CLOEXEC);
|
||||||
|
#else /* HAVE_FCNTL */
|
||||||
|
# if defined __NetBSD__ || defined __HAIKU__
|
||||||
|
/* On NetBSD 9.0, the system fcntl (fd, F_DUPFD_CLOEXEC, target)
|
||||||
|
has only the same effect as fcntl (fd, F_DUPFD, target). */
|
||||||
|
/* On Haiku, the system fcntl (fd, F_DUPFD_CLOEXEC, target) sets
|
||||||
|
the FD_CLOEXEC flag on fd, not on target. Therefore avoid the
|
||||||
|
system fcntl in this case. */
|
||||||
|
# define have_dupfd_cloexec -1
|
||||||
|
# else
|
||||||
|
/* Try the system call first, if the headers claim it exists
|
||||||
|
(that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
|
||||||
|
may be running with a glibc that has the macro but with an
|
||||||
|
older kernel that does not support it. Cache the
|
||||||
|
information on whether the system call really works, but
|
||||||
|
avoid caching failure if the corresponding F_DUPFD fails
|
||||||
|
for any reason. 0 = unknown, 1 = yes, -1 = no. */
|
||||||
|
static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
|
||||||
|
if (0 <= have_dupfd_cloexec)
|
||||||
|
{
|
||||||
|
result = fcntl (fd, F_DUPFD_CLOEXEC, target);
|
||||||
|
if (0 <= result || errno != EINVAL)
|
||||||
|
{
|
||||||
|
have_dupfd_cloexec = 1;
|
||||||
|
# if REPLACE_FCHDIR
|
||||||
|
if (0 <= result)
|
||||||
|
result = _gl_register_dup (fd, result);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = rpl_fcntl_DUPFD (fd, target);
|
||||||
|
if (result >= 0)
|
||||||
|
have_dupfd_cloexec = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
# endif
|
||||||
|
result = rpl_fcntl_DUPFD (fd, target);
|
||||||
|
if (0 <= result && have_dupfd_cloexec == -1)
|
||||||
|
{
|
||||||
|
int flags = fcntl (result, F_GETFD);
|
||||||
|
if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
|
||||||
|
{
|
||||||
|
int saved_errno = errno;
|
||||||
|
close (result);
|
||||||
|
errno = saved_errno;
|
||||||
|
result = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* HAVE_FCNTL */
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef fcntl
|
||||||
|
|
||||||
|
#ifdef __KLIBC__
|
||||||
|
|
||||||
|
static int
|
||||||
|
klibc_fcntl (int fd, int action, /* arg */...)
|
||||||
|
{
|
||||||
|
va_list arg_ptr;
|
||||||
|
int arg;
|
||||||
|
struct stat sbuf;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
va_start (arg_ptr, action);
|
||||||
|
arg = va_arg (arg_ptr, int);
|
||||||
|
result = fcntl (fd, action, arg);
|
||||||
|
/* EPERM for F_DUPFD, ENOTSUP for others */
|
||||||
|
if (result == -1 && (errno == EPERM || errno == ENOTSUP)
|
||||||
|
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
|
||||||
|
{
|
||||||
|
ULONG ulMode;
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case F_DUPFD:
|
||||||
|
/* Find available fd */
|
||||||
|
while (fcntl (arg, F_GETFL) != -1 || errno != EBADF)
|
||||||
|
arg++;
|
||||||
|
|
||||||
|
result = dup2 (fd, arg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Using underlying APIs is right ? */
|
||||||
|
case F_GETFD:
|
||||||
|
if (DosQueryFHState (fd, &ulMode))
|
||||||
|
break;
|
||||||
|
|
||||||
|
result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_SETFD:
|
||||||
|
if (arg & ~FD_CLOEXEC)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (DosQueryFHState (fd, &ulMode))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (arg & FD_CLOEXEC)
|
||||||
|
ulMode |= OPEN_FLAGS_NOINHERIT;
|
||||||
|
else
|
||||||
|
ulMode &= ~OPEN_FLAGS_NOINHERIT;
|
||||||
|
|
||||||
|
/* Filter supported flags. */
|
||||||
|
ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
|
||||||
|
| OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT);
|
||||||
|
|
||||||
|
if (DosSetFHState (fd, ulMode))
|
||||||
|
break;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_GETFL:
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case F_SETFL:
|
||||||
|
if (arg != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
errno = EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end (arg_ptr);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
445
lib/fcntl.in.h
Normal file
445
lib/fcntl.in.h
Normal file
|
@ -0,0 +1,445 @@
|
||||||
|
/* Like <fcntl.h>, but with non-working flags defined to 0.
|
||||||
|
|
||||||
|
Copyright (C) 2006-2023 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 */
|
||||||
|
|
||||||
|
#if __GNUC__ >= 3
|
||||||
|
@PRAGMA_SYSTEM_HEADER@
|
||||||
|
#endif
|
||||||
|
@PRAGMA_COLUMNS@
|
||||||
|
|
||||||
|
#if defined __need_system_fcntl_h
|
||||||
|
/* Special invocation convention. */
|
||||||
|
|
||||||
|
/* Needed before <sys/stat.h>.
|
||||||
|
May also define off_t to a 64-bit type on native Windows. */
|
||||||
|
#include <sys/types.h>
|
||||||
|
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
|
||||||
|
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
|
||||||
|
But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
|
||||||
|
extern "C" { ... } block, which leads to errors in C++ mode with the
|
||||||
|
overridden <sys/stat.h> from gnulib. These errors are known to be gone
|
||||||
|
with g++ version >= 4.3. */
|
||||||
|
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
|
||||||
|
# include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
|
||||||
|
|
||||||
|
/* Native Windows platforms declare open(), creat() in <io.h>. */
|
||||||
|
#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
|
||||||
|
&& (defined _WIN32 && ! defined __CYGWIN__)
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* Normal invocation convention. */
|
||||||
|
|
||||||
|
#ifndef _@GUARD_PREFIX@_FCNTL_H
|
||||||
|
|
||||||
|
/* Needed before <sys/stat.h>.
|
||||||
|
May also define off_t to a 64-bit type on native Windows. */
|
||||||
|
#include <sys/types.h>
|
||||||
|
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
|
||||||
|
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
|
||||||
|
But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
|
||||||
|
extern "C" { ... } block, which leads to errors in C++ mode with the
|
||||||
|
overridden <sys/stat.h> from gnulib. These errors are known to be gone
|
||||||
|
with g++ version >= 4.3. */
|
||||||
|
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
|
||||||
|
# include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
/* The include_next requires a split double-inclusion guard. */
|
||||||
|
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
|
||||||
|
|
||||||
|
/* Native Windows platforms declare open(), creat() in <io.h>. */
|
||||||
|
#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
|
||||||
|
&& (defined _WIN32 && ! defined __CYGWIN__)
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _@GUARD_PREFIX@_FCNTL_H
|
||||||
|
#define _@GUARD_PREFIX@_FCNTL_H
|
||||||
|
|
||||||
|
#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||||
|
|
||||||
|
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||||
|
|
||||||
|
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Declare overridden functions. */
|
||||||
|
|
||||||
|
#if @GNULIB_CREAT@
|
||||||
|
# if @REPLACE_CREAT@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef creat
|
||||||
|
# define creat rpl_creat
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
|
||||||
|
_GL_ARG_NONNULL ((1)));
|
||||||
|
_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
|
||||||
|
# elif defined _WIN32 && !defined __CYGWIN__
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef creat
|
||||||
|
# define creat _creat
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode));
|
||||||
|
# else
|
||||||
|
_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIASWARN (creat);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef creat
|
||||||
|
/* Assume creat is always declared. */
|
||||||
|
_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
|
||||||
|
"use gnulib module creat for portability");
|
||||||
|
#elif @GNULIB_MDA_CREAT@
|
||||||
|
/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
|
||||||
|
required. In C++ with GNULIB_NAMESPACE, avoid differences between
|
||||||
|
platforms by defining GNULIB_NAMESPACE::creat always. */
|
||||||
|
# if defined _WIN32 && !defined __CYGWIN__
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef creat
|
||||||
|
# define creat _creat
|
||||||
|
# endif
|
||||||
|
/* Need to cast, because in mingw the last argument is 'int mode'. */
|
||||||
|
_GL_CXXALIAS_MDA_CAST (creat, int, (const char *filename, mode_t mode));
|
||||||
|
# else
|
||||||
|
_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIASWARN (creat);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_FCNTL@
|
||||||
|
# if @REPLACE_FCNTL@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef fcntl
|
||||||
|
# define fcntl rpl_fcntl
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
|
||||||
|
_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
|
||||||
|
# if !GNULIB_defined_rpl_fcntl
|
||||||
|
# define GNULIB_defined_rpl_fcntl 1
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# if !@HAVE_FCNTL@
|
||||||
|
_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
|
||||||
|
# if !GNULIB_defined_fcntl
|
||||||
|
# define GNULIB_defined_fcntl 1
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIASWARN (fcntl);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef fcntl
|
||||||
|
# if HAVE_RAW_DECL_FCNTL
|
||||||
|
_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
|
||||||
|
"use gnulib module fcntl for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_OPEN@
|
||||||
|
# if @REPLACE_OPEN@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef open
|
||||||
|
# define open rpl_open
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
|
||||||
|
_GL_ARG_NONNULL ((1)));
|
||||||
|
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
|
||||||
|
# elif defined _WIN32 && !defined __CYGWIN__
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef open
|
||||||
|
# define open _open
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
|
||||||
|
# else
|
||||||
|
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
|
||||||
|
# endif
|
||||||
|
/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
|
||||||
|
default argument. _GL_CXXALIASWARN does not work in this case. */
|
||||||
|
# if !defined __hpux
|
||||||
|
_GL_CXXALIASWARN (open);
|
||||||
|
# endif
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef open
|
||||||
|
/* Assume open is always declared. */
|
||||||
|
_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
|
||||||
|
"use gnulib module open for portability");
|
||||||
|
#elif @GNULIB_MDA_OPEN@
|
||||||
|
/* On native Windows, map 'open' to '_open', so that -loldnames is not
|
||||||
|
required. In C++ with GNULIB_NAMESPACE, avoid differences between
|
||||||
|
platforms by defining GNULIB_NAMESPACE::open always. */
|
||||||
|
# if defined _WIN32 && !defined __CYGWIN__
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef open
|
||||||
|
# define open _open
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
|
||||||
|
# else
|
||||||
|
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
|
||||||
|
# endif
|
||||||
|
# if !defined __hpux
|
||||||
|
_GL_CXXALIASWARN (open);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @GNULIB_OPENAT@
|
||||||
|
# if @REPLACE_OPENAT@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# undef openat
|
||||||
|
# define openat rpl_openat
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (openat, int,
|
||||||
|
(int fd, char const *file, int flags, /* mode_t mode */ ...)
|
||||||
|
_GL_ARG_NONNULL ((2)));
|
||||||
|
_GL_CXXALIAS_RPL (openat, int,
|
||||||
|
(int fd, char const *file, int flags, /* mode_t mode */ ...));
|
||||||
|
# else
|
||||||
|
# if !@HAVE_OPENAT@
|
||||||
|
_GL_FUNCDECL_SYS (openat, int,
|
||||||
|
(int fd, char const *file, int flags, /* mode_t mode */ ...)
|
||||||
|
_GL_ARG_NONNULL ((2)));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (openat, int,
|
||||||
|
(int fd, char const *file, int flags, /* mode_t mode */ ...));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIASWARN (openat);
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef openat
|
||||||
|
# if HAVE_RAW_DECL_OPENAT
|
||||||
|
_GL_WARN_ON_USE (openat, "openat is not portable - "
|
||||||
|
"use gnulib module openat for portability");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Fix up the FD_* macros, only known to be missing on mingw. */
|
||||||
|
|
||||||
|
#ifndef FD_CLOEXEC
|
||||||
|
# define FD_CLOEXEC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Fix up the supported F_* macros. Intentionally leave other F_*
|
||||||
|
macros undefined. Only known to be missing on mingw. */
|
||||||
|
|
||||||
|
#ifndef F_DUPFD_CLOEXEC
|
||||||
|
# define F_DUPFD_CLOEXEC 0x40000000
|
||||||
|
/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
|
||||||
|
# define GNULIB_defined_F_DUPFD_CLOEXEC 1
|
||||||
|
#else
|
||||||
|
# define GNULIB_defined_F_DUPFD_CLOEXEC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef F_DUPFD
|
||||||
|
# define F_DUPFD 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef F_GETFD
|
||||||
|
# define F_GETFD 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Fix up the O_* macros. */
|
||||||
|
|
||||||
|
/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
|
||||||
|
to values outside 'int' range, so omit these misdefinitions.
|
||||||
|
But avoid namespace pollution on non-AIX systems. */
|
||||||
|
#ifdef _AIX
|
||||||
|
# include <limits.h>
|
||||||
|
# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
|
||||||
|
# undef O_CLOEXEC
|
||||||
|
# endif
|
||||||
|
# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
|
||||||
|
# undef O_NOFOLLOW
|
||||||
|
# endif
|
||||||
|
# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
|
||||||
|
# undef O_TTY_INIT
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined O_DIRECT && defined O_DIRECTIO
|
||||||
|
/* Tru64 spells it 'O_DIRECTIO'. */
|
||||||
|
# define O_DIRECT O_DIRECTIO
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined O_CLOEXEC && defined O_NOINHERIT
|
||||||
|
/* Mingw spells it 'O_NOINHERIT'. */
|
||||||
|
# define O_CLOEXEC O_NOINHERIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_CLOEXEC
|
||||||
|
# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */
|
||||||
|
# define GNULIB_defined_O_CLOEXEC 1
|
||||||
|
#else
|
||||||
|
# define GNULIB_defined_O_CLOEXEC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_DIRECT
|
||||||
|
# define O_DIRECT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_DIRECTORY
|
||||||
|
# define O_DIRECTORY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_DSYNC
|
||||||
|
# define O_DSYNC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_EXEC
|
||||||
|
# define O_EXEC O_RDONLY /* This is often close enough in older systems. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_IGNORE_CTTY
|
||||||
|
# define O_IGNORE_CTTY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_NDELAY
|
||||||
|
# define O_NDELAY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_NOATIME
|
||||||
|
# define O_NOATIME 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_NONBLOCK
|
||||||
|
# define O_NONBLOCK O_NDELAY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
|
||||||
|
value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
|
||||||
|
or to 0 as fallback. */
|
||||||
|
#if @GNULIB_NONBLOCKING@
|
||||||
|
# if O_NONBLOCK
|
||||||
|
# define GNULIB_defined_O_NONBLOCK 0
|
||||||
|
# else
|
||||||
|
# define GNULIB_defined_O_NONBLOCK 1
|
||||||
|
# undef O_NONBLOCK
|
||||||
|
# define O_NONBLOCK 0x40000000
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_NOCTTY
|
||||||
|
# define O_NOCTTY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_NOFOLLOW
|
||||||
|
# define O_NOFOLLOW 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_NOLINK
|
||||||
|
# define O_NOLINK 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_NOLINKS
|
||||||
|
# define O_NOLINKS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_NOTRANS
|
||||||
|
# define O_NOTRANS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_RSYNC
|
||||||
|
# define O_RSYNC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_SEARCH
|
||||||
|
# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_SYNC
|
||||||
|
# define O_SYNC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_TTY_INIT
|
||||||
|
# define O_TTY_INIT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
|
||||||
|
# undef O_ACCMODE
|
||||||
|
# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* For systems that distinguish between text and binary I/O.
|
||||||
|
O_BINARY is usually declared in fcntl.h */
|
||||||
|
#if !defined O_BINARY && defined _O_BINARY
|
||||||
|
/* For MSC-compatible compilers. */
|
||||||
|
# define O_BINARY _O_BINARY
|
||||||
|
# define O_TEXT _O_TEXT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined __BEOS__ || defined __HAIKU__
|
||||||
|
/* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
|
||||||
|
# undef O_BINARY
|
||||||
|
# undef O_TEXT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_BINARY
|
||||||
|
# define O_BINARY 0
|
||||||
|
# define O_TEXT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Fix up the AT_* macros. */
|
||||||
|
|
||||||
|
/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
|
||||||
|
value exceeds INT_MAX, so its use as an int doesn't conform to the
|
||||||
|
C standard, and GCC and Sun C complain in some cases. If the bug
|
||||||
|
is present, undef AT_FDCWD here, so it can be redefined below. */
|
||||||
|
#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
|
||||||
|
# undef AT_FDCWD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Use the same bit pattern as Solaris 9, but with the proper
|
||||||
|
signedness. The bit pattern is important, in case this actually is
|
||||||
|
Solaris with the above workaround. */
|
||||||
|
#ifndef AT_FDCWD
|
||||||
|
# define AT_FDCWD (-3041965)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Use the same values as Solaris 9. This shouldn't matter, but
|
||||||
|
there's no real reason to differ. */
|
||||||
|
#ifndef AT_SYMLINK_NOFOLLOW
|
||||||
|
# define AT_SYMLINK_NOFOLLOW 4096
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef AT_REMOVEDIR
|
||||||
|
# define AT_REMOVEDIR 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Solaris 9 lacks these two, so just pick unique values. */
|
||||||
|
#ifndef AT_SYMLINK_FOLLOW
|
||||||
|
# define AT_SYMLINK_FOLLOW 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef AT_EACCESS
|
||||||
|
# define AT_EACCESS 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Ignore this flag if not supported. */
|
||||||
|
#ifndef AT_NO_AUTOMOUNT
|
||||||
|
# define AT_NO_AUTOMOUNT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _@GUARD_PREFIX@_FCNTL_H */
|
||||||
|
#endif /* _@GUARD_PREFIX@_FCNTL_H */
|
||||||
|
#endif
|
116
lib/fd-hook.c
Normal file
116
lib/fd-hook.c
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
/* Hook for making file descriptor functions close(), ioctl() extensible.
|
||||||
|
Copyright (C) 2009-2023 Free Software Foundation, Inc.
|
||||||
|
Written by Bruno Haible <bruno@clisp.org>, 2009.
|
||||||
|
|
||||||
|
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 "fd-hook.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/* Currently, this entire code is only needed for the handling of sockets
|
||||||
|
on native Windows platforms. */
|
||||||
|
#if WINDOWS_SOCKETS
|
||||||
|
|
||||||
|
/* The first and last link in the doubly linked list.
|
||||||
|
Initially the list is empty. */
|
||||||
|
static struct fd_hook anchor = { &anchor, &anchor, NULL, NULL };
|
||||||
|
|
||||||
|
int
|
||||||
|
execute_close_hooks (const struct fd_hook *remaining_list, gl_close_fn primary,
|
||||||
|
int fd)
|
||||||
|
{
|
||||||
|
if (remaining_list == &anchor)
|
||||||
|
/* End of list reached. */
|
||||||
|
return primary (fd);
|
||||||
|
else
|
||||||
|
return remaining_list->private_close_fn (remaining_list->private_next,
|
||||||
|
primary, fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
execute_all_close_hooks (gl_close_fn primary, int fd)
|
||||||
|
{
|
||||||
|
return execute_close_hooks (anchor.private_next, primary, fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
execute_ioctl_hooks (const struct fd_hook *remaining_list, gl_ioctl_fn primary,
|
||||||
|
int fd, int request, void *arg)
|
||||||
|
{
|
||||||
|
if (remaining_list == &anchor)
|
||||||
|
/* End of list reached. */
|
||||||
|
return primary (fd, request, arg);
|
||||||
|
else
|
||||||
|
return remaining_list->private_ioctl_fn (remaining_list->private_next,
|
||||||
|
primary, fd, request, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
execute_all_ioctl_hooks (gl_ioctl_fn primary,
|
||||||
|
int fd, int request, void *arg)
|
||||||
|
{
|
||||||
|
return execute_ioctl_hooks (anchor.private_next, primary, fd, request, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook, struct fd_hook *link)
|
||||||
|
{
|
||||||
|
if (close_hook == NULL)
|
||||||
|
close_hook = execute_close_hooks;
|
||||||
|
if (ioctl_hook == NULL)
|
||||||
|
ioctl_hook = execute_ioctl_hooks;
|
||||||
|
|
||||||
|
if (link->private_next == NULL && link->private_prev == NULL)
|
||||||
|
{
|
||||||
|
/* Add the link to the doubly linked list. */
|
||||||
|
link->private_next = anchor.private_next;
|
||||||
|
link->private_prev = &anchor;
|
||||||
|
link->private_close_fn = close_hook;
|
||||||
|
link->private_ioctl_fn = ioctl_hook;
|
||||||
|
anchor.private_next->private_prev = link;
|
||||||
|
anchor.private_next = link;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The link is already in use. */
|
||||||
|
if (link->private_close_fn != close_hook
|
||||||
|
|| link->private_ioctl_fn != ioctl_hook)
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
unregister_fd_hook (struct fd_hook *link)
|
||||||
|
{
|
||||||
|
struct fd_hook *next = link->private_next;
|
||||||
|
struct fd_hook *prev = link->private_prev;
|
||||||
|
|
||||||
|
if (next != NULL && prev != NULL)
|
||||||
|
{
|
||||||
|
/* The link is in use. Remove it from the doubly linked list. */
|
||||||
|
prev->private_next = next;
|
||||||
|
next->private_prev = prev;
|
||||||
|
/* Clear the link, to mark it unused. */
|
||||||
|
link->private_next = NULL;
|
||||||
|
link->private_prev = NULL;
|
||||||
|
link->private_close_fn = NULL;
|
||||||
|
link->private_ioctl_fn = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
119
lib/fd-hook.h
Normal file
119
lib/fd-hook.h
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
/* Hook for making file descriptor functions close(), ioctl() extensible.
|
||||||
|
Copyright (C) 2009-2023 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 FD_HOOK_H
|
||||||
|
#define FD_HOOK_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Currently, this entire code is only needed for the handling of sockets
|
||||||
|
on native Windows platforms. */
|
||||||
|
#if WINDOWS_SOCKETS
|
||||||
|
|
||||||
|
|
||||||
|
/* Type of function that closes FD. */
|
||||||
|
typedef int (*gl_close_fn) (int fd);
|
||||||
|
|
||||||
|
/* Type of function that applies a control request to FD. */
|
||||||
|
typedef int (*gl_ioctl_fn) (int fd, int request, void *arg);
|
||||||
|
|
||||||
|
/* An element of the list of file descriptor hooks.
|
||||||
|
In CLOS (Common Lisp Object System) speak, it consists of an "around"
|
||||||
|
method for the close() function and an "around" method for the ioctl()
|
||||||
|
function.
|
||||||
|
The fields of this structure are considered private. */
|
||||||
|
struct fd_hook
|
||||||
|
{
|
||||||
|
/* Doubly linked list. */
|
||||||
|
struct fd_hook *private_next;
|
||||||
|
struct fd_hook *private_prev;
|
||||||
|
/* Function that treats the types of FD that it knows about and calls
|
||||||
|
execute_close_hooks (REMAINING_LIST, PRIMARY, FD) as a fallback. */
|
||||||
|
int (*private_close_fn) (const struct fd_hook *remaining_list,
|
||||||
|
gl_close_fn primary,
|
||||||
|
int fd);
|
||||||
|
/* Function that treats the types of FD that it knows about and calls
|
||||||
|
execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG) as a
|
||||||
|
fallback. */
|
||||||
|
int (*private_ioctl_fn) (const struct fd_hook *remaining_list,
|
||||||
|
gl_ioctl_fn primary,
|
||||||
|
int fd, int request, void *arg);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* This type of function closes FD, applying special knowledge for the FD
|
||||||
|
types it knows about, and calls
|
||||||
|
execute_close_hooks (REMAINING_LIST, PRIMARY, FD)
|
||||||
|
for the other FD types.
|
||||||
|
In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
|
||||||
|
and PRIMARY is the "primary" method for close(). */
|
||||||
|
typedef int (*close_hook_fn) (const struct fd_hook *remaining_list,
|
||||||
|
gl_close_fn primary,
|
||||||
|
int fd);
|
||||||
|
|
||||||
|
/* Execute the close hooks in REMAINING_LIST, with PRIMARY as "primary" method.
|
||||||
|
Return 0 or -1, like close() would do. */
|
||||||
|
extern int execute_close_hooks (const struct fd_hook *remaining_list,
|
||||||
|
gl_close_fn primary,
|
||||||
|
int fd);
|
||||||
|
|
||||||
|
/* Execute all close hooks, with PRIMARY as "primary" method.
|
||||||
|
Return 0 or -1, like close() would do. */
|
||||||
|
extern int execute_all_close_hooks (gl_close_fn primary, int fd);
|
||||||
|
|
||||||
|
/* This type of function applies a control request to FD, applying special
|
||||||
|
knowledge for the FD types it knows about, and calls
|
||||||
|
execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG)
|
||||||
|
for the other FD types.
|
||||||
|
In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
|
||||||
|
and PRIMARY is the "primary" method for ioctl(). */
|
||||||
|
typedef int (*ioctl_hook_fn) (const struct fd_hook *remaining_list,
|
||||||
|
gl_ioctl_fn primary,
|
||||||
|
int fd, int request, void *arg);
|
||||||
|
|
||||||
|
/* Execute the ioctl hooks in REMAINING_LIST, with PRIMARY as "primary" method.
|
||||||
|
Return 0 or -1, like ioctl() would do. */
|
||||||
|
extern int execute_ioctl_hooks (const struct fd_hook *remaining_list,
|
||||||
|
gl_ioctl_fn primary,
|
||||||
|
int fd, int request, void *arg);
|
||||||
|
|
||||||
|
/* Execute all ioctl hooks, with PRIMARY as "primary" method.
|
||||||
|
Return 0 or -1, like ioctl() would do. */
|
||||||
|
extern int execute_all_ioctl_hooks (gl_ioctl_fn primary,
|
||||||
|
int fd, int request, void *arg);
|
||||||
|
|
||||||
|
/* Add a function pair to the list of file descriptor hooks.
|
||||||
|
CLOSE_HOOK and IOCTL_HOOK may be NULL, indicating no change.
|
||||||
|
The LINK variable points to a piece of memory which is guaranteed to be
|
||||||
|
accessible until the corresponding call to unregister_fd_hook. */
|
||||||
|
extern void register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook,
|
||||||
|
struct fd_hook *link);
|
||||||
|
|
||||||
|
/* Removes a hook from the list of file descriptor hooks. */
|
||||||
|
extern void unregister_fd_hook (struct fd_hook *link);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* FD_HOOK_H */
|
52
lib/fd-safer-flag.c
Normal file
52
lib/fd-safer-flag.c
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/* Adjust a file descriptor result so that it avoids clobbering
|
||||||
|
STD{IN,OUT,ERR}_FILENO, with specific flags.
|
||||||
|
|
||||||
|
Copyright (C) 2005-2006, 2009-2023 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 Paul Eggert and Eric Blake. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
#include "unistd-safer.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* Return FD, unless FD would be a copy of standard input, output, or
|
||||||
|
error; in that case, return a duplicate of FD, closing FD. If FLAG
|
||||||
|
contains O_CLOEXEC, the returned FD will have close-on-exec
|
||||||
|
semantics. On failure to duplicate, close FD, set errno, and
|
||||||
|
return -1. Preserve errno if FD is negative, so that the caller
|
||||||
|
can always inspect errno when the returned value is negative.
|
||||||
|
|
||||||
|
This function is usefully wrapped around functions that return file
|
||||||
|
descriptors, e.g., fd_safer_flag (open ("file", O_RDONLY | flag), flag). */
|
||||||
|
|
||||||
|
int
|
||||||
|
fd_safer_flag (int fd, int flag)
|
||||||
|
{
|
||||||
|
if (STDIN_FILENO <= fd && fd <= STDERR_FILENO)
|
||||||
|
{
|
||||||
|
int f = dup_safer_flag (fd, flag);
|
||||||
|
int e = errno;
|
||||||
|
close (fd);
|
||||||
|
errno = e;
|
||||||
|
fd = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
49
lib/fd-safer.c
Normal file
49
lib/fd-safer.c
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/* Return a safer copy of a file descriptor.
|
||||||
|
|
||||||
|
Copyright (C) 2005-2006, 2009-2023 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 Paul Eggert. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "unistd-safer.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* Return FD, unless FD would be a copy of standard input, output, or
|
||||||
|
error; in that case, return a duplicate of FD, closing FD. On
|
||||||
|
failure to duplicate, close FD, set errno, and return -1. Preserve
|
||||||
|
errno if FD is negative, so that the caller can always inspect
|
||||||
|
errno when the returned value is negative.
|
||||||
|
|
||||||
|
This function is usefully wrapped around functions that return file
|
||||||
|
descriptors, e.g., fd_safer (open ("file", O_RDONLY)). */
|
||||||
|
|
||||||
|
int
|
||||||
|
fd_safer (int fd)
|
||||||
|
{
|
||||||
|
if (STDIN_FILENO <= fd && fd <= STDERR_FILENO)
|
||||||
|
{
|
||||||
|
int f = dup_safer (fd);
|
||||||
|
int e = errno;
|
||||||
|
close (fd);
|
||||||
|
errno = e;
|
||||||
|
fd = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
112
lib/filename.h
Normal file
112
lib/filename.h
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
/* Basic filename support macros.
|
||||||
|
Copyright (C) 2001-2023 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/>. */
|
||||||
|
|
||||||
|
/* From Paul Eggert and Jim Meyering. */
|
||||||
|
|
||||||
|
#ifndef _FILENAME_H
|
||||||
|
#define _FILENAME_H
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Filename support.
|
||||||
|
ISSLASH(C) tests whether C is a directory separator
|
||||||
|
character.
|
||||||
|
HAS_DEVICE(Filename) tests whether Filename contains a device
|
||||||
|
specification.
|
||||||
|
FILE_SYSTEM_PREFIX_LEN(Filename) length of the device specification
|
||||||
|
at the beginning of Filename,
|
||||||
|
index of the part consisting of
|
||||||
|
alternating components and slashes.
|
||||||
|
FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||||
|
1 when a non-empty device specification
|
||||||
|
can be followed by an empty or relative
|
||||||
|
part,
|
||||||
|
0 when a non-empty device specification
|
||||||
|
must be followed by a slash,
|
||||||
|
0 when device specification don't exist.
|
||||||
|
IS_ABSOLUTE_FILE_NAME(Filename)
|
||||||
|
tests whether Filename is independent of
|
||||||
|
any notion of "current directory".
|
||||||
|
IS_RELATIVE_FILE_NAME(Filename)
|
||||||
|
tests whether Filename may be concatenated
|
||||||
|
to a directory filename.
|
||||||
|
Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a
|
||||||
|
relative file name!
|
||||||
|
IS_FILE_NAME_WITH_DIR(Filename) tests whether Filename contains a device
|
||||||
|
or directory specification.
|
||||||
|
*/
|
||||||
|
#if defined _WIN32 || defined __CYGWIN__ \
|
||||||
|
|| defined __EMX__ || defined __MSDOS__ || defined __DJGPP__
|
||||||
|
/* Native Windows, Cygwin, OS/2, DOS */
|
||||||
|
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
|
||||||
|
/* Internal macro: Tests whether a character is a drive letter. */
|
||||||
|
# define _IS_DRIVE_LETTER(C) \
|
||||||
|
(((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z'))
|
||||||
|
/* Help the compiler optimizing it. This assumes ASCII. */
|
||||||
|
# undef _IS_DRIVE_LETTER
|
||||||
|
# define _IS_DRIVE_LETTER(C) \
|
||||||
|
(((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a')
|
||||||
|
# define HAS_DEVICE(Filename) \
|
||||||
|
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':')
|
||||||
|
# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0)
|
||||||
|
# ifdef __CYGWIN__
|
||||||
|
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
|
||||||
|
# else
|
||||||
|
/* On native Windows, OS/2, DOS, the system has the notion of a
|
||||||
|
"current directory" on each drive. */
|
||||||
|
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
|
||||||
|
# endif
|
||||||
|
# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||||
|
# define IS_ABSOLUTE_FILE_NAME(Filename) \
|
||||||
|
ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)])
|
||||||
|
# else
|
||||||
|
# define IS_ABSOLUTE_FILE_NAME(Filename) \
|
||||||
|
(ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))
|
||||||
|
# endif
|
||||||
|
# define IS_RELATIVE_FILE_NAME(Filename) \
|
||||||
|
(! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)))
|
||||||
|
# define IS_FILE_NAME_WITH_DIR(Filename) \
|
||||||
|
(strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \
|
||||||
|
|| HAS_DEVICE (Filename))
|
||||||
|
#else
|
||||||
|
/* Unix */
|
||||||
|
# define ISSLASH(C) ((C) == '/')
|
||||||
|
# define HAS_DEVICE(Filename) ((void) (Filename), 0)
|
||||||
|
# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0)
|
||||||
|
# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
|
||||||
|
# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0])
|
||||||
|
# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0]))
|
||||||
|
# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Deprecated macros. For backward compatibility with old users of the
|
||||||
|
'filename' module. */
|
||||||
|
#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME
|
||||||
|
#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _FILENAME_H */
|
90
lib/filenamecat-lgpl.c
Normal file
90
lib/filenamecat-lgpl.c
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
/* Concatenate two arbitrary file names.
|
||||||
|
|
||||||
|
Copyright (C) 1996-2007, 2009-2023 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 "filenamecat.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "basename-lgpl.h"
|
||||||
|
#include "filename.h"
|
||||||
|
|
||||||
|
#if ! HAVE_MEMPCPY && ! defined mempcpy
|
||||||
|
# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Concatenate two file name components, DIR and BASE, in
|
||||||
|
newly-allocated storage and return the result.
|
||||||
|
The resulting file name F is such that the commands "ls F" and "(cd
|
||||||
|
DIR; ls ./BASE)" refer to the same file. If necessary, put
|
||||||
|
a separator between DIR and BASE in the result. Typically this
|
||||||
|
separator is "/", but in rare cases it might be ".".
|
||||||
|
In any case, if BASE_IN_RESULT is non-NULL, set
|
||||||
|
*BASE_IN_RESULT to point to the copy of BASE at the end of the
|
||||||
|
returned concatenation.
|
||||||
|
|
||||||
|
If malloc fails, return NULL with errno set. */
|
||||||
|
|
||||||
|
char *
|
||||||
|
mfile_name_concat (char const *dir, char const *base, char **base_in_result)
|
||||||
|
{
|
||||||
|
char const *dirbase = last_component (dir);
|
||||||
|
size_t dirbaselen = base_len (dirbase);
|
||||||
|
size_t dirlen = dirbase - dir + dirbaselen;
|
||||||
|
size_t baselen = strlen (base);
|
||||||
|
char sep = '\0';
|
||||||
|
if (dirbaselen)
|
||||||
|
{
|
||||||
|
/* DIR is not a file system root, so separate with / if needed. */
|
||||||
|
if (! ISSLASH (dir[dirlen - 1]) && ! ISSLASH (*base))
|
||||||
|
sep = '/';
|
||||||
|
}
|
||||||
|
else if (ISSLASH (*base))
|
||||||
|
{
|
||||||
|
/* DIR is a file system root and BASE begins with a slash, so
|
||||||
|
separate with ".". For example, if DIR is "/" and BASE is
|
||||||
|
"/foo" then return "/./foo", as "//foo" would be wrong on
|
||||||
|
some POSIX systems. A fancier algorithm could omit "." in
|
||||||
|
some cases but is not worth the trouble. */
|
||||||
|
sep = '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
char *p_concat = malloc (dirlen + (sep != '\0') + baselen + 1);
|
||||||
|
if (p_concat == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
p = mempcpy (p_concat, dir, dirlen);
|
||||||
|
*p = sep;
|
||||||
|
p += sep != '\0';
|
||||||
|
|
||||||
|
if (base_in_result)
|
||||||
|
*base_in_result = p;
|
||||||
|
|
||||||
|
p = mempcpy (p, base, baselen);
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return p_concat;
|
||||||
|
}
|
32
lib/filenamecat.h
Normal file
32
lib/filenamecat.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/* Concatenate two arbitrary file names.
|
||||||
|
|
||||||
|
Copyright (C) 1996-1997, 2003, 2005, 2007, 2009-2023 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 <stdlib.h>
|
||||||
|
|
||||||
|
#if GNULIB_FILENAMECAT
|
||||||
|
char *file_name_concat (char const *dir, char const *base,
|
||||||
|
char **base_in_result)
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
|
||||||
|
_GL_ATTRIBUTE_RETURNS_NONNULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char *mfile_name_concat (char const *dir, char const *base,
|
||||||
|
char **base_in_result)
|
||||||
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
|
60
lib/flexmember.h
Normal file
60
lib/flexmember.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/* Sizes of structs with flexible array members.
|
||||||
|
|
||||||
|
Copyright 2016-2023 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/>.
|
||||||
|
|
||||||
|
Written by Paul Eggert. */
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below.
|
||||||
|
On older platforms without _Alignof, use a pessimistic bound that is
|
||||||
|
safe in practice even if FLEXIBLE_ARRAY_MEMBER is 1.
|
||||||
|
On newer platforms, use _Alignof to get a tighter bound. */
|
||||||
|
|
||||||
|
#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
|
||||||
|
# define FLEXALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1))
|
||||||
|
#else
|
||||||
|
# define FLEXALIGNOF(type) _Alignof (type)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Yield a properly aligned upper bound on the size of a struct of
|
||||||
|
type TYPE with a flexible array member named MEMBER that is
|
||||||
|
followed by N bytes of other data. The result is suitable as an
|
||||||
|
argument to malloc. For example:
|
||||||
|
|
||||||
|
struct s { int n; char d[FLEXIBLE_ARRAY_MEMBER]; };
|
||||||
|
struct s *p = malloc (FLEXSIZEOF (struct s, d, n * sizeof (char)));
|
||||||
|
|
||||||
|
FLEXSIZEOF (TYPE, MEMBER, N) is not simply (sizeof (TYPE) + N),
|
||||||
|
since FLEXIBLE_ARRAY_MEMBER may be 1 on pre-C11 platforms. Nor is
|
||||||
|
it simply (offsetof (TYPE, MEMBER) + N), as that might yield a size
|
||||||
|
that causes malloc to yield a pointer that is not properly aligned
|
||||||
|
for TYPE; for example, if sizeof (int) == alignof (int) == 4,
|
||||||
|
malloc (offsetof (struct s, d) + 3 * sizeof (char)) is equivalent
|
||||||
|
to malloc (7) and might yield a pointer that is not a multiple of 4
|
||||||
|
(which means the pointer is not properly aligned for struct s),
|
||||||
|
whereas malloc (FLEXSIZEOF (struct s, d, 3 * sizeof (char))) is
|
||||||
|
equivalent to malloc (8) and must yield a pointer that is a
|
||||||
|
multiple of 4.
|
||||||
|
|
||||||
|
Yield a value less than N if and only if arithmetic overflow occurs. */
|
||||||
|
|
||||||
|
#define FLEXSIZEOF(type, member, n) \
|
||||||
|
((offsetof (type, member) + FLEXALIGNOF (type) - 1 + (n)) \
|
||||||
|
& ~ (FLEXALIGNOF (type) - 1))
|
147
lib/float+.h
Normal file
147
lib/float+.h
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
/* Supplemental information about the floating-point formats.
|
||||||
|
Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
|
||||||
|
Written by Bruno Haible <bruno@clisp.org>, 2007.
|
||||||
|
|
||||||
|
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 _FLOATPLUS_H
|
||||||
|
#define _FLOATPLUS_H
|
||||||
|
|
||||||
|
#include <float.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
/* Number of bits in the mantissa of a floating-point number, including the
|
||||||
|
"hidden bit". */
|
||||||
|
#if FLT_RADIX == 2
|
||||||
|
# define FLT_MANT_BIT FLT_MANT_DIG
|
||||||
|
# define DBL_MANT_BIT DBL_MANT_DIG
|
||||||
|
# define LDBL_MANT_BIT LDBL_MANT_DIG
|
||||||
|
#elif FLT_RADIX == 4
|
||||||
|
# define FLT_MANT_BIT (FLT_MANT_DIG * 2)
|
||||||
|
# define DBL_MANT_BIT (DBL_MANT_DIG * 2)
|
||||||
|
# define LDBL_MANT_BIT (LDBL_MANT_DIG * 2)
|
||||||
|
#elif FLT_RADIX == 16
|
||||||
|
# define FLT_MANT_BIT (FLT_MANT_DIG * 4)
|
||||||
|
# define DBL_MANT_BIT (DBL_MANT_DIG * 4)
|
||||||
|
# define LDBL_MANT_BIT (LDBL_MANT_DIG * 4)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Bit mask that can be used to mask the exponent, as an unsigned number. */
|
||||||
|
#define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7)
|
||||||
|
#define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
|
||||||
|
#define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7)
|
||||||
|
|
||||||
|
/* Number of bits used for the exponent of a floating-point number, including
|
||||||
|
the exponent's sign. */
|
||||||
|
#define FLT_EXP_BIT \
|
||||||
|
(FLT_EXP_MASK < 0x100 ? 8 : \
|
||||||
|
FLT_EXP_MASK < 0x200 ? 9 : \
|
||||||
|
FLT_EXP_MASK < 0x400 ? 10 : \
|
||||||
|
FLT_EXP_MASK < 0x800 ? 11 : \
|
||||||
|
FLT_EXP_MASK < 0x1000 ? 12 : \
|
||||||
|
FLT_EXP_MASK < 0x2000 ? 13 : \
|
||||||
|
FLT_EXP_MASK < 0x4000 ? 14 : \
|
||||||
|
FLT_EXP_MASK < 0x8000 ? 15 : \
|
||||||
|
FLT_EXP_MASK < 0x10000 ? 16 : \
|
||||||
|
FLT_EXP_MASK < 0x20000 ? 17 : \
|
||||||
|
FLT_EXP_MASK < 0x40000 ? 18 : \
|
||||||
|
FLT_EXP_MASK < 0x80000 ? 19 : \
|
||||||
|
FLT_EXP_MASK < 0x100000 ? 20 : \
|
||||||
|
FLT_EXP_MASK < 0x200000 ? 21 : \
|
||||||
|
FLT_EXP_MASK < 0x400000 ? 22 : \
|
||||||
|
FLT_EXP_MASK < 0x800000 ? 23 : \
|
||||||
|
FLT_EXP_MASK < 0x1000000 ? 24 : \
|
||||||
|
FLT_EXP_MASK < 0x2000000 ? 25 : \
|
||||||
|
FLT_EXP_MASK < 0x4000000 ? 26 : \
|
||||||
|
FLT_EXP_MASK < 0x8000000 ? 27 : \
|
||||||
|
FLT_EXP_MASK < 0x10000000 ? 28 : \
|
||||||
|
FLT_EXP_MASK < 0x20000000 ? 29 : \
|
||||||
|
FLT_EXP_MASK < 0x40000000 ? 30 : \
|
||||||
|
FLT_EXP_MASK <= 0x7fffffff ? 31 : \
|
||||||
|
32)
|
||||||
|
#define DBL_EXP_BIT \
|
||||||
|
(DBL_EXP_MASK < 0x100 ? 8 : \
|
||||||
|
DBL_EXP_MASK < 0x200 ? 9 : \
|
||||||
|
DBL_EXP_MASK < 0x400 ? 10 : \
|
||||||
|
DBL_EXP_MASK < 0x800 ? 11 : \
|
||||||
|
DBL_EXP_MASK < 0x1000 ? 12 : \
|
||||||
|
DBL_EXP_MASK < 0x2000 ? 13 : \
|
||||||
|
DBL_EXP_MASK < 0x4000 ? 14 : \
|
||||||
|
DBL_EXP_MASK < 0x8000 ? 15 : \
|
||||||
|
DBL_EXP_MASK < 0x10000 ? 16 : \
|
||||||
|
DBL_EXP_MASK < 0x20000 ? 17 : \
|
||||||
|
DBL_EXP_MASK < 0x40000 ? 18 : \
|
||||||
|
DBL_EXP_MASK < 0x80000 ? 19 : \
|
||||||
|
DBL_EXP_MASK < 0x100000 ? 20 : \
|
||||||
|
DBL_EXP_MASK < 0x200000 ? 21 : \
|
||||||
|
DBL_EXP_MASK < 0x400000 ? 22 : \
|
||||||
|
DBL_EXP_MASK < 0x800000 ? 23 : \
|
||||||
|
DBL_EXP_MASK < 0x1000000 ? 24 : \
|
||||||
|
DBL_EXP_MASK < 0x2000000 ? 25 : \
|
||||||
|
DBL_EXP_MASK < 0x4000000 ? 26 : \
|
||||||
|
DBL_EXP_MASK < 0x8000000 ? 27 : \
|
||||||
|
DBL_EXP_MASK < 0x10000000 ? 28 : \
|
||||||
|
DBL_EXP_MASK < 0x20000000 ? 29 : \
|
||||||
|
DBL_EXP_MASK < 0x40000000 ? 30 : \
|
||||||
|
DBL_EXP_MASK <= 0x7fffffff ? 31 : \
|
||||||
|
32)
|
||||||
|
#define LDBL_EXP_BIT \
|
||||||
|
(LDBL_EXP_MASK < 0x100 ? 8 : \
|
||||||
|
LDBL_EXP_MASK < 0x200 ? 9 : \
|
||||||
|
LDBL_EXP_MASK < 0x400 ? 10 : \
|
||||||
|
LDBL_EXP_MASK < 0x800 ? 11 : \
|
||||||
|
LDBL_EXP_MASK < 0x1000 ? 12 : \
|
||||||
|
LDBL_EXP_MASK < 0x2000 ? 13 : \
|
||||||
|
LDBL_EXP_MASK < 0x4000 ? 14 : \
|
||||||
|
LDBL_EXP_MASK < 0x8000 ? 15 : \
|
||||||
|
LDBL_EXP_MASK < 0x10000 ? 16 : \
|
||||||
|
LDBL_EXP_MASK < 0x20000 ? 17 : \
|
||||||
|
LDBL_EXP_MASK < 0x40000 ? 18 : \
|
||||||
|
LDBL_EXP_MASK < 0x80000 ? 19 : \
|
||||||
|
LDBL_EXP_MASK < 0x100000 ? 20 : \
|
||||||
|
LDBL_EXP_MASK < 0x200000 ? 21 : \
|
||||||
|
LDBL_EXP_MASK < 0x400000 ? 22 : \
|
||||||
|
LDBL_EXP_MASK < 0x800000 ? 23 : \
|
||||||
|
LDBL_EXP_MASK < 0x1000000 ? 24 : \
|
||||||
|
LDBL_EXP_MASK < 0x2000000 ? 25 : \
|
||||||
|
LDBL_EXP_MASK < 0x4000000 ? 26 : \
|
||||||
|
LDBL_EXP_MASK < 0x8000000 ? 27 : \
|
||||||
|
LDBL_EXP_MASK < 0x10000000 ? 28 : \
|
||||||
|
LDBL_EXP_MASK < 0x20000000 ? 29 : \
|
||||||
|
LDBL_EXP_MASK < 0x40000000 ? 30 : \
|
||||||
|
LDBL_EXP_MASK <= 0x7fffffff ? 31 : \
|
||||||
|
32)
|
||||||
|
|
||||||
|
/* Number of bits used for a floating-point number: the mantissa (not
|
||||||
|
counting the "hidden bit", since it may or may not be explicit), the
|
||||||
|
exponent, and the sign. */
|
||||||
|
#define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1)
|
||||||
|
#define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1)
|
||||||
|
#define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1)
|
||||||
|
|
||||||
|
/* Number of bytes used for a floating-point number.
|
||||||
|
This can be smaller than the 'sizeof'. For example, on i386 systems,
|
||||||
|
'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence
|
||||||
|
LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but
|
||||||
|
sizeof (long double) = 12 or = 16. */
|
||||||
|
#define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
|
||||||
|
#define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
|
||||||
|
#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
|
||||||
|
|
||||||
|
/* Verify that SIZEOF_FLT <= sizeof (float) etc. */
|
||||||
|
typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
|
||||||
|
typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
|
||||||
|
typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];
|
||||||
|
|
||||||
|
#endif /* _FLOATPLUS_H */
|
33
lib/float.c
Normal file
33
lib/float.c
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/* Auxiliary definitions for <float.h>.
|
||||||
|
Copyright (C) 2011-2023 Free Software Foundation, Inc.
|
||||||
|
Written by Bruno Haible <bruno@clisp.org>, 2011.
|
||||||
|
|
||||||
|
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 <float.h>
|
||||||
|
|
||||||
|
#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
|
||||||
|
const union gl_long_double_union gl_LDBL_MAX =
|
||||||
|
{ { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } };
|
||||||
|
#elif defined __i386__
|
||||||
|
const union gl_long_double_union gl_LDBL_MAX =
|
||||||
|
{ { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } };
|
||||||
|
#else
|
||||||
|
/* This declaration is solely to ensure that after preprocessing
|
||||||
|
this file is never empty. */
|
||||||
|
typedef int dummy;
|
||||||
|
#endif
|
194
lib/float.in.h
Normal file
194
lib/float.in.h
Normal file
|
@ -0,0 +1,194 @@
|
||||||
|
/* A correct <float.h>.
|
||||||
|
|
||||||
|
Copyright (C) 2007-2023 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 _@GUARD_PREFIX@_FLOAT_H
|
||||||
|
|
||||||
|
#if __GNUC__ >= 3
|
||||||
|
@PRAGMA_SYSTEM_HEADER@
|
||||||
|
#endif
|
||||||
|
@PRAGMA_COLUMNS@
|
||||||
|
|
||||||
|
/* The include_next requires a split double-inclusion guard. */
|
||||||
|
#@INCLUDE_NEXT@ @NEXT_FLOAT_H@
|
||||||
|
|
||||||
|
#ifndef _@GUARD_PREFIX@_FLOAT_H
|
||||||
|
#define _@GUARD_PREFIX@_FLOAT_H
|
||||||
|
|
||||||
|
/* 'long double' properties. */
|
||||||
|
|
||||||
|
#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
|
||||||
|
/* Number of mantissa units, in base FLT_RADIX. */
|
||||||
|
# undef LDBL_MANT_DIG
|
||||||
|
# define LDBL_MANT_DIG 64
|
||||||
|
/* Number of decimal digits that is sufficient for representing a number. */
|
||||||
|
# undef LDBL_DIG
|
||||||
|
# define LDBL_DIG 18
|
||||||
|
/* x-1 where x is the smallest representable number > 1. */
|
||||||
|
# undef LDBL_EPSILON
|
||||||
|
# define LDBL_EPSILON 1.0842021724855044340E-19L
|
||||||
|
/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */
|
||||||
|
# undef LDBL_MIN_EXP
|
||||||
|
# define LDBL_MIN_EXP (-16381)
|
||||||
|
/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */
|
||||||
|
# undef LDBL_MAX_EXP
|
||||||
|
# define LDBL_MAX_EXP 16384
|
||||||
|
/* Minimum positive normalized number. */
|
||||||
|
# undef LDBL_MIN
|
||||||
|
# define LDBL_MIN 3.3621031431120935063E-4932L
|
||||||
|
/* Maximum representable finite number. */
|
||||||
|
# undef LDBL_MAX
|
||||||
|
# define LDBL_MAX 1.1897314953572317650E+4932L
|
||||||
|
/* Minimum e such that 10^e is in the range of normalized numbers. */
|
||||||
|
# undef LDBL_MIN_10_EXP
|
||||||
|
# define LDBL_MIN_10_EXP (-4931)
|
||||||
|
/* Maximum e such that 10^e is in the range of representable finite numbers. */
|
||||||
|
# undef LDBL_MAX_10_EXP
|
||||||
|
# define LDBL_MAX_10_EXP 4932
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
|
||||||
|
precision in the compiler but 64 bits of precision at runtime. See
|
||||||
|
<https://lists.gnu.org/r/bug-gnulib/2008-07/msg00063.html>. */
|
||||||
|
#if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
|
||||||
|
/* Number of mantissa units, in base FLT_RADIX. */
|
||||||
|
# undef LDBL_MANT_DIG
|
||||||
|
# define LDBL_MANT_DIG 64
|
||||||
|
/* Number of decimal digits that is sufficient for representing a number. */
|
||||||
|
# undef LDBL_DIG
|
||||||
|
# define LDBL_DIG 18
|
||||||
|
/* x-1 where x is the smallest representable number > 1. */
|
||||||
|
# undef LDBL_EPSILON
|
||||||
|
# define LDBL_EPSILON 1.084202172485504434007452800869941711426e-19L /* 2^-63 */
|
||||||
|
/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */
|
||||||
|
# undef LDBL_MIN_EXP
|
||||||
|
# define LDBL_MIN_EXP (-16381)
|
||||||
|
/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */
|
||||||
|
# undef LDBL_MAX_EXP
|
||||||
|
# define LDBL_MAX_EXP 16384
|
||||||
|
/* Minimum positive normalized number. */
|
||||||
|
# undef LDBL_MIN
|
||||||
|
# define LDBL_MIN 3.362103143112093506262677817321752E-4932L /* = 0x1p-16382L */
|
||||||
|
/* Maximum representable finite number. */
|
||||||
|
# undef LDBL_MAX
|
||||||
|
/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
|
||||||
|
But the largest literal that GCC allows us to write is
|
||||||
|
0x0.fffffffffffff8p16384L = { 0xFFFFF800, 0xFFFFFFFF, 32766 }.
|
||||||
|
So, define it like this through a reference to an external variable
|
||||||
|
|
||||||
|
const unsigned int LDBL_MAX[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 32766 };
|
||||||
|
extern const long double LDBL_MAX;
|
||||||
|
|
||||||
|
Unfortunately, this is not a constant expression. */
|
||||||
|
# if !GNULIB_defined_long_double_union
|
||||||
|
union gl_long_double_union
|
||||||
|
{
|
||||||
|
struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
|
||||||
|
long double ld;
|
||||||
|
};
|
||||||
|
# define GNULIB_defined_long_double_union 1
|
||||||
|
# endif
|
||||||
|
extern const union gl_long_double_union gl_LDBL_MAX;
|
||||||
|
# define LDBL_MAX (gl_LDBL_MAX.ld)
|
||||||
|
/* Minimum e such that 10^e is in the range of normalized numbers. */
|
||||||
|
# undef LDBL_MIN_10_EXP
|
||||||
|
# define LDBL_MIN_10_EXP (-4931)
|
||||||
|
/* Maximum e such that 10^e is in the range of representable finite numbers. */
|
||||||
|
# undef LDBL_MAX_10_EXP
|
||||||
|
# define LDBL_MAX_10_EXP 4932
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are
|
||||||
|
wrong.
|
||||||
|
On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */
|
||||||
|
#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__
|
||||||
|
# undef LDBL_MIN_EXP
|
||||||
|
# define LDBL_MIN_EXP DBL_MIN_EXP
|
||||||
|
# undef LDBL_MIN_10_EXP
|
||||||
|
# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||||
|
# undef LDBL_MIN
|
||||||
|
# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
|
||||||
|
#endif
|
||||||
|
#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
|
||||||
|
# undef LDBL_MAX
|
||||||
|
/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }.
|
||||||
|
It is not easy to define:
|
||||||
|
#define LDBL_MAX 1.79769313486231580793728971405302307166e308L
|
||||||
|
is too small, whereas
|
||||||
|
#define LDBL_MAX 1.79769313486231580793728971405302307167e308L
|
||||||
|
is too large. Apparently a bug in GCC decimal-to-binary conversion.
|
||||||
|
Also, I can't get values larger than
|
||||||
|
#define LDBL63 ((long double) (1ULL << 63))
|
||||||
|
#define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
|
||||||
|
#define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
|
||||||
|
#define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
|
||||||
|
#define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL)
|
||||||
|
which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }.
|
||||||
|
So, define it like this through a reference to an external variable
|
||||||
|
|
||||||
|
const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL };
|
||||||
|
extern const long double LDBL_MAX;
|
||||||
|
|
||||||
|
or through a pointer cast
|
||||||
|
|
||||||
|
#define LDBL_MAX \
|
||||||
|
(*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL })
|
||||||
|
|
||||||
|
Unfortunately, this is not a constant expression, and the latter expression
|
||||||
|
does not work well when GCC is optimizing.. */
|
||||||
|
# if !GNULIB_defined_long_double_union
|
||||||
|
union gl_long_double_union
|
||||||
|
{
|
||||||
|
struct { double hi; double lo; } dd;
|
||||||
|
long double ld;
|
||||||
|
};
|
||||||
|
# define GNULIB_defined_long_double_union 1
|
||||||
|
# endif
|
||||||
|
extern const union gl_long_double_union gl_LDBL_MAX;
|
||||||
|
# define LDBL_MAX (gl_LDBL_MAX.ld)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong.
|
||||||
|
On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON
|
||||||
|
are wrong. */
|
||||||
|
#if defined __sgi && (LDBL_MANT_DIG >= 106)
|
||||||
|
# undef LDBL_MANT_DIG
|
||||||
|
# define LDBL_MANT_DIG 106
|
||||||
|
# if defined __GNUC__
|
||||||
|
# undef LDBL_MIN_EXP
|
||||||
|
# define LDBL_MIN_EXP DBL_MIN_EXP
|
||||||
|
# undef LDBL_MIN_10_EXP
|
||||||
|
# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||||
|
# undef LDBL_MIN
|
||||||
|
# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
|
||||||
|
# undef LDBL_EPSILON
|
||||||
|
# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if @REPLACE_ITOLD@
|
||||||
|
/* Pull in a function that fixes the 'int' to 'long double' conversion
|
||||||
|
of glibc 2.7. */
|
||||||
|
extern
|
||||||
|
# ifdef __cplusplus
|
||||||
|
"C"
|
||||||
|
# endif
|
||||||
|
void _Qp_itoq (long double *, int);
|
||||||
|
static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _@GUARD_PREFIX@_FLOAT_H */
|
||||||
|
#endif /* _@GUARD_PREFIX@_FLOAT_H */
|
360
lib/fnmatch.c
Normal file
360
lib/fnmatch.c
Normal file
|
@ -0,0 +1,360 @@
|
||||||
|
/* Copyright (C) 1991-2023 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
|
||||||
|
# include <libc-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Enable GNU extensions in fnmatch.h. */
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
# define _GNU_SOURCE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <fnmatch.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdckdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#if defined _LIBC || HAVE_ALLOCA
|
||||||
|
# include <alloca.h>
|
||||||
|
#endif
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <wctype.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* We need some of the locale data (the collation sequence information)
|
||||||
|
but there is no interface to get this information in general. Therefore
|
||||||
|
we support a correct implementation only in glibc. */
|
||||||
|
#ifdef _LIBC
|
||||||
|
# include "../locale/localeinfo.h"
|
||||||
|
# include "../locale/coll-lookup.h"
|
||||||
|
# include <shlib-compat.h>
|
||||||
|
|
||||||
|
# define CONCAT(a,b) __CONCAT(a,b)
|
||||||
|
# define btowc __btowc
|
||||||
|
# define iswctype __iswctype
|
||||||
|
# define mbsrtowcs __mbsrtowcs
|
||||||
|
# define mempcpy __mempcpy
|
||||||
|
# define strnlen __strnlen
|
||||||
|
# define towlower __towlower
|
||||||
|
# define wcscat __wcscat
|
||||||
|
# define wcslen __wcslen
|
||||||
|
# define wctype __wctype
|
||||||
|
# define wmemchr __wmemchr
|
||||||
|
# define wmempcpy __wmempcpy
|
||||||
|
# define fnmatch __fnmatch
|
||||||
|
extern int fnmatch (const char *pattern, const char *string, int flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# if __GNUC__ >= 7
|
||||||
|
# define FALLTHROUGH __attribute__ ((__fallthrough__))
|
||||||
|
# else
|
||||||
|
# define FALLTHROUGH ((void) 0)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# include "attribute.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <flexmember.h>
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
typedef ptrdiff_t idx_t;
|
||||||
|
#else
|
||||||
|
# include "idx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */
|
||||||
|
#define NO_LEADING_PERIOD(flags) \
|
||||||
|
((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))
|
||||||
|
|
||||||
|
#ifndef _LIBC
|
||||||
|
# if HAVE_ALLOCA
|
||||||
|
/* The OS usually guarantees only one guard page at the bottom of the stack,
|
||||||
|
and a page size can be as small as 4096 bytes. So we cannot safely
|
||||||
|
allocate anything larger than 4096 bytes. Also care for the possibility
|
||||||
|
of a few compiler-allocated temporary stack slots. */
|
||||||
|
# define __libc_use_alloca(n) ((n) < 4032)
|
||||||
|
# else
|
||||||
|
/* Just use malloc. */
|
||||||
|
# define __libc_use_alloca(n) false
|
||||||
|
# undef alloca
|
||||||
|
# define alloca(n) malloc (n)
|
||||||
|
# endif
|
||||||
|
# define alloca_account(size, avar) ((avar) += (size), alloca (size))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Provide support for user-defined character classes, based on the functions
|
||||||
|
from ISO C 90 amendment 1. */
|
||||||
|
#ifdef CHARCLASS_NAME_MAX
|
||||||
|
# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
|
||||||
|
#else
|
||||||
|
/* This shouldn't happen but some implementation might still have this
|
||||||
|
problem. Use a reasonable default value. */
|
||||||
|
# define CHAR_CLASS_MAX_LENGTH 256
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define IS_CHAR_CLASS(string) wctype (string)
|
||||||
|
|
||||||
|
/* Avoid depending on library functions or files
|
||||||
|
whose names are inconsistent. */
|
||||||
|
|
||||||
|
/* Global variable. */
|
||||||
|
static int posixly_correct;
|
||||||
|
|
||||||
|
/* Note that this evaluates C many times. */
|
||||||
|
#define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
|
||||||
|
#define CHAR char
|
||||||
|
#define UCHAR unsigned char
|
||||||
|
#define INT int
|
||||||
|
#define FCT internal_fnmatch
|
||||||
|
#define EXT ext_match
|
||||||
|
#define END end_pattern
|
||||||
|
#define STRUCT fnmatch_struct
|
||||||
|
#define L_(CS) CS
|
||||||
|
#define BTOWC(C) btowc (C)
|
||||||
|
#define STRLEN(S) strlen (S)
|
||||||
|
#define STRCAT(D, S) strcat (D, S)
|
||||||
|
#define MEMPCPY(D, S, N) mempcpy (D, S, N)
|
||||||
|
#define MEMCHR(S, C, N) memchr (S, C, N)
|
||||||
|
#define WIDE_CHAR_VERSION 0
|
||||||
|
#ifdef _LIBC
|
||||||
|
# include <locale/weight.h>
|
||||||
|
# define FINDIDX findidx
|
||||||
|
#endif
|
||||||
|
#include "fnmatch_loop.c"
|
||||||
|
|
||||||
|
|
||||||
|
#define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
|
||||||
|
#define CHAR wchar_t
|
||||||
|
#define UCHAR wint_t
|
||||||
|
#define INT wint_t
|
||||||
|
#define FCT internal_fnwmatch
|
||||||
|
#define EXT ext_wmatch
|
||||||
|
#define END end_wpattern
|
||||||
|
#define L_(CS) L##CS
|
||||||
|
#define BTOWC(C) (C)
|
||||||
|
#define STRLEN(S) wcslen (S)
|
||||||
|
#define STRCAT(D, S) wcscat (D, S)
|
||||||
|
#define MEMPCPY(D, S, N) wmempcpy (D, S, N)
|
||||||
|
#define MEMCHR(S, C, N) wmemchr (S, C, N)
|
||||||
|
#define WIDE_CHAR_VERSION 1
|
||||||
|
#ifdef _LIBC
|
||||||
|
/* Change the name the header defines so it doesn't conflict with
|
||||||
|
the <locale/weight.h> version included above. */
|
||||||
|
# define findidx findidxwc
|
||||||
|
# include <locale/weightwc.h>
|
||||||
|
# undef findidx
|
||||||
|
# define FINDIDX findidxwc
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef IS_CHAR_CLASS
|
||||||
|
/* We have to convert the wide character string in a multibyte string. But
|
||||||
|
we know that the character class names consist of alphanumeric characters
|
||||||
|
from the portable character set, and since the wide character encoding
|
||||||
|
for a member of the portable character set is the same code point as
|
||||||
|
its single-byte encoding, we can use a simplified method to convert the
|
||||||
|
string to a multibyte character string. */
|
||||||
|
static wctype_t
|
||||||
|
is_char_class (const wchar_t *wcs)
|
||||||
|
{
|
||||||
|
char s[CHAR_CLASS_MAX_LENGTH + 1];
|
||||||
|
char *cp = s;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* Test for a printable character from the portable character set. */
|
||||||
|
#ifdef _LIBC
|
||||||
|
if (*wcs < 0x20 || *wcs > 0x7e
|
||||||
|
|| *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
|
||||||
|
return (wctype_t) 0;
|
||||||
|
#else
|
||||||
|
switch (*wcs)
|
||||||
|
{
|
||||||
|
case L' ': case L'!': case L'"': case L'#': case L'%':
|
||||||
|
case L'&': case L'\'': case L'(': case L')': case L'*':
|
||||||
|
case L'+': case L',': case L'-': case L'.': case L'/':
|
||||||
|
case L'0': case L'1': case L'2': case L'3': case L'4':
|
||||||
|
case L'5': case L'6': case L'7': case L'8': case L'9':
|
||||||
|
case L':': case L';': case L'<': case L'=': case L'>':
|
||||||
|
case L'?':
|
||||||
|
case L'A': case L'B': case L'C': case L'D': case L'E':
|
||||||
|
case L'F': case L'G': case L'H': case L'I': case L'J':
|
||||||
|
case L'K': case L'L': case L'M': case L'N': case L'O':
|
||||||
|
case L'P': case L'Q': case L'R': case L'S': case L'T':
|
||||||
|
case L'U': case L'V': case L'W': case L'X': case L'Y':
|
||||||
|
case L'Z':
|
||||||
|
case L'[': case L'\\': case L']': case L'^': case L'_':
|
||||||
|
case L'a': case L'b': case L'c': case L'd': case L'e':
|
||||||
|
case L'f': case L'g': case L'h': case L'i': case L'j':
|
||||||
|
case L'k': case L'l': case L'm': case L'n': case L'o':
|
||||||
|
case L'p': case L'q': case L'r': case L's': case L't':
|
||||||
|
case L'u': case L'v': case L'w': case L'x': case L'y':
|
||||||
|
case L'z': case L'{': case L'|': case L'}': case L'~':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return (wctype_t) 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Avoid overrunning the buffer. */
|
||||||
|
if (cp == s + CHAR_CLASS_MAX_LENGTH)
|
||||||
|
return (wctype_t) 0;
|
||||||
|
|
||||||
|
*cp++ = (char) *wcs++;
|
||||||
|
}
|
||||||
|
while (*wcs != L'\0');
|
||||||
|
|
||||||
|
*cp = '\0';
|
||||||
|
|
||||||
|
return wctype (s);
|
||||||
|
}
|
||||||
|
#define IS_CHAR_CLASS(string) is_char_class (string)
|
||||||
|
|
||||||
|
#include "fnmatch_loop.c"
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
fnmatch (const char *pattern, const char *string, int flags)
|
||||||
|
{
|
||||||
|
if (__glibc_unlikely (MB_CUR_MAX != 1))
|
||||||
|
{
|
||||||
|
mbstate_t ps;
|
||||||
|
size_t n;
|
||||||
|
const char *p;
|
||||||
|
wchar_t *wpattern_malloc = NULL;
|
||||||
|
wchar_t *wpattern;
|
||||||
|
wchar_t *wstring_malloc = NULL;
|
||||||
|
wchar_t *wstring;
|
||||||
|
size_t alloca_used = 0;
|
||||||
|
|
||||||
|
/* Convert the strings into wide characters. */
|
||||||
|
memset (&ps, '\0', sizeof (ps));
|
||||||
|
p = pattern;
|
||||||
|
n = strnlen (pattern, 1024);
|
||||||
|
if (__glibc_likely (n < 1024))
|
||||||
|
{
|
||||||
|
wpattern = (wchar_t *) alloca_account ((n + 1) * sizeof (wchar_t),
|
||||||
|
alloca_used);
|
||||||
|
n = mbsrtowcs (wpattern, &p, n + 1, &ps);
|
||||||
|
if (__glibc_unlikely (n == (size_t) -1))
|
||||||
|
/* Something wrong.
|
||||||
|
XXX Do we have to set 'errno' to something which mbsrtows hasn't
|
||||||
|
already done? */
|
||||||
|
return -1;
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
memset (&ps, '\0', sizeof (ps));
|
||||||
|
goto prepare_wpattern;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prepare_wpattern:
|
||||||
|
n = mbsrtowcs (NULL, &pattern, 0, &ps);
|
||||||
|
if (__glibc_unlikely (n == (size_t) -1))
|
||||||
|
/* Something wrong.
|
||||||
|
XXX Do we have to set 'errno' to something which mbsrtows hasn't
|
||||||
|
already done? */
|
||||||
|
return -1;
|
||||||
|
if (__glibc_unlikely (n >= (size_t) -1 / sizeof (wchar_t)))
|
||||||
|
{
|
||||||
|
__set_errno (ENOMEM);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
wpattern_malloc = wpattern
|
||||||
|
= (wchar_t *) malloc ((n + 1) * sizeof (wchar_t));
|
||||||
|
assert (mbsinit (&ps));
|
||||||
|
if (wpattern == NULL)
|
||||||
|
return -2;
|
||||||
|
(void) mbsrtowcs (wpattern, &pattern, n + 1, &ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert (mbsinit (&ps));
|
||||||
|
n = strnlen (string, 1024);
|
||||||
|
p = string;
|
||||||
|
if (__glibc_likely (n < 1024))
|
||||||
|
{
|
||||||
|
wstring = (wchar_t *) alloca_account ((n + 1) * sizeof (wchar_t),
|
||||||
|
alloca_used);
|
||||||
|
n = mbsrtowcs (wstring, &p, n + 1, &ps);
|
||||||
|
if (__glibc_unlikely (n == (size_t) -1))
|
||||||
|
{
|
||||||
|
/* Something wrong.
|
||||||
|
XXX Do we have to set 'errno' to something which
|
||||||
|
mbsrtows hasn't already done? */
|
||||||
|
free_return:
|
||||||
|
free (wpattern_malloc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
memset (&ps, '\0', sizeof (ps));
|
||||||
|
goto prepare_wstring;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prepare_wstring:
|
||||||
|
n = mbsrtowcs (NULL, &string, 0, &ps);
|
||||||
|
if (__glibc_unlikely (n == (size_t) -1))
|
||||||
|
/* Something wrong.
|
||||||
|
XXX Do we have to set 'errno' to something which mbsrtows hasn't
|
||||||
|
already done? */
|
||||||
|
goto free_return;
|
||||||
|
if (__glibc_unlikely (n >= (size_t) -1 / sizeof (wchar_t)))
|
||||||
|
{
|
||||||
|
free (wpattern_malloc);
|
||||||
|
__set_errno (ENOMEM);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
wstring_malloc = wstring
|
||||||
|
= (wchar_t *) malloc ((n + 1) * sizeof (wchar_t));
|
||||||
|
if (wstring == NULL)
|
||||||
|
{
|
||||||
|
free (wpattern_malloc);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
assert (mbsinit (&ps));
|
||||||
|
(void) mbsrtowcs (wstring, &string, n + 1, &ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
int res = internal_fnwmatch (wpattern, wstring, wstring + n,
|
||||||
|
flags & FNM_PERIOD, flags, NULL,
|
||||||
|
alloca_used);
|
||||||
|
|
||||||
|
free (wstring_malloc);
|
||||||
|
free (wpattern_malloc);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return internal_fnmatch (pattern, string, string + strlen (string),
|
||||||
|
flags & FNM_PERIOD, flags, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef fnmatch
|
||||||
|
versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3);
|
||||||
|
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3)
|
||||||
|
strong_alias (__fnmatch, __fnmatch_old)
|
||||||
|
compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
|
||||||
|
#endif
|
||||||
|
libc_hidden_ver (__fnmatch, fnmatch)
|
110
lib/fnmatch.in.h
Normal file
110
lib/fnmatch.in.h
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/* Substitute for and wrapper around <fnmatch.h>.
|
||||||
|
Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2023 Free
|
||||||
|
Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
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 _@GUARD_PREFIX@_FNMATCH_H
|
||||||
|
|
||||||
|
#if __GNUC__ >= 3
|
||||||
|
@PRAGMA_SYSTEM_HEADER@
|
||||||
|
#endif
|
||||||
|
@PRAGMA_COLUMNS@
|
||||||
|
|
||||||
|
/* The include_next requires a split double-inclusion guard. */
|
||||||
|
#if @HAVE_FNMATCH_H@ && !@REPLACE_FNMATCH@
|
||||||
|
# @INCLUDE_NEXT@ @NEXT_FNMATCH_H@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _@GUARD_PREFIX@_FNMATCH_H
|
||||||
|
#define _@GUARD_PREFIX@_FNMATCH_H
|
||||||
|
|
||||||
|
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||||
|
|
||||||
|
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||||
|
|
||||||
|
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||||
|
|
||||||
|
#if !@HAVE_FNMATCH_H@ || @REPLACE_FNMATCH@
|
||||||
|
|
||||||
|
/* We #undef these before defining them because some losing systems
|
||||||
|
(HP-UX A.08.07 for example) define these in <unistd.h>. */
|
||||||
|
#undef FNM_PATHNAME
|
||||||
|
#undef FNM_NOESCAPE
|
||||||
|
#undef FNM_PERIOD
|
||||||
|
|
||||||
|
/* Bits set in the FLAGS argument to 'fnmatch'. */
|
||||||
|
#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match '/'. */
|
||||||
|
#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
|
||||||
|
#define FNM_PERIOD (1 << 2) /* Leading '.' is matched only explicitly. */
|
||||||
|
|
||||||
|
#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
|
||||||
|
# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
|
||||||
|
# define FNM_LEADING_DIR (1 << 3) /* Ignore '/...' after a match. */
|
||||||
|
# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
|
||||||
|
# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Value returned by 'fnmatch' if STRING does not match PATTERN. */
|
||||||
|
#define FNM_NOMATCH 1
|
||||||
|
|
||||||
|
/* This value is returned if the implementation does not support
|
||||||
|
'fnmatch'. Since this is not the case here it will never be
|
||||||
|
returned but the conformance test suites still require the symbol
|
||||||
|
to be defined. */
|
||||||
|
#ifdef _XOPEN_SOURCE
|
||||||
|
# define FNM_NOSYS (-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if @GNULIB_FNMATCH@
|
||||||
|
/* Match NAME against the file name pattern PATTERN,
|
||||||
|
returning zero if it matches, FNM_NOMATCH if not. */
|
||||||
|
# if @REPLACE_FNMATCH@
|
||||||
|
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||||
|
# define fnmatch rpl_fnmatch
|
||||||
|
# endif
|
||||||
|
_GL_FUNCDECL_RPL (fnmatch, int,
|
||||||
|
(const char *pattern, const char *name, int flags)
|
||||||
|
_GL_ARG_NONNULL ((1, 2)));
|
||||||
|
_GL_CXXALIAS_RPL (fnmatch, int,
|
||||||
|
(const char *pattern, const char *name, int flags));
|
||||||
|
# else
|
||||||
|
# if !@HAVE_FNMATCH@
|
||||||
|
_GL_FUNCDECL_SYS (fnmatch, int,
|
||||||
|
(const char *pattern, const char *name, int flags)
|
||||||
|
_GL_ARG_NONNULL ((1, 2)));
|
||||||
|
# endif
|
||||||
|
_GL_CXXALIAS_SYS (fnmatch, int,
|
||||||
|
(const char *pattern, const char *name, int flags));
|
||||||
|
# endif
|
||||||
|
# if !GNULIB_FNMATCH_GNU && __GLIBC__ >= 2
|
||||||
|
_GL_CXXALIASWARN (fnmatch);
|
||||||
|
# endif
|
||||||
|
#elif defined GNULIB_POSIXCHECK
|
||||||
|
# undef fnmatch
|
||||||
|
# if HAVE_RAW_DECL_FNMATCH
|
||||||
|
_GL_WARN_ON_USE (fnmatch,
|
||||||
|
"fnmatch does not portably work - "
|
||||||
|
"use gnulib module fnmatch for portability or gnulib module fnmatch-gnu for a glibc compatible implementation");
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _@GUARD_PREFIX@_FNMATCH_H */
|
||||||
|
#endif /* _@GUARD_PREFIX@_FNMATCH_H */
|
1211
lib/fnmatch_loop.c
Normal file
1211
lib/fnmatch_loop.c
Normal file
File diff suppressed because it is too large
Load diff
108
lib/fpucw.h
Normal file
108
lib/fpucw.h
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
/* Manipulating the FPU control word. -*- coding: utf-8 -*-
|
||||||
|
Copyright (C) 2007-2023 Free Software Foundation, Inc.
|
||||||
|
Written by Bruno Haible <bruno@clisp.org>, 2007.
|
||||||
|
|
||||||
|
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 _FPUCW_H
|
||||||
|
#define _FPUCW_H
|
||||||
|
|
||||||
|
/* The i386 floating point hardware (the 387 compatible FPU, not the modern
|
||||||
|
SSE/SSE2 hardware) has a controllable rounding precision. It is specified
|
||||||
|
through the 'PC' bits in the FPU control word ('fctrl' register). (See
|
||||||
|
the GNU libc i386 <fpu_control.h> header for details.)
|
||||||
|
|
||||||
|
On some platforms, such as Linux or Solaris, the default precision setting
|
||||||
|
is set to "extended precision". This means that 'long double' instructions
|
||||||
|
operate correctly, but 'double' computations often produce slightly
|
||||||
|
different results as on strictly IEEE 754 conforming systems.
|
||||||
|
|
||||||
|
On some platforms, such as NetBSD, the default precision is set to
|
||||||
|
"double precision". This means that 'long double' instructions will operate
|
||||||
|
only as 'double', i.e. lead to wrong results. Similarly on FreeBSD 6.4, at
|
||||||
|
least for the division of 'long double' numbers.
|
||||||
|
|
||||||
|
The FPU control word is under control of the application, i.e. it is
|
||||||
|
not required to be set either way by the ABI. (In fact, the i386 ABI
|
||||||
|
https://www.linux-mips.org/pub/linux/mips/doc/ABI/abi386-4.pdf page 3-12 = page 38
|
||||||
|
is not clear about it. But in any case, gcc treats the control word
|
||||||
|
like a "preserved" register: it emits code that assumes that the control
|
||||||
|
word is preserved across calls, and it restores the control word at the
|
||||||
|
end of functions that modify it.)
|
||||||
|
|
||||||
|
See Vincent Lefèvre's page https://www.vinc17.net/research/extended.en.html
|
||||||
|
for a good explanation.
|
||||||
|
See https://web.archive.org/web/20060905133417/http://www.uwsg.iu.edu/hypermail/linux/kernel/0103.0/0453.html
|
||||||
|
some argumentation which setting should be the default. */
|
||||||
|
|
||||||
|
/* This header file provides the following facilities:
|
||||||
|
fpucw_t integral type holding the value of 'fctrl'
|
||||||
|
FPU_PC_MASK bit mask denoting the precision control
|
||||||
|
FPU_PC_DOUBLE precision control for 53 bits mantissa
|
||||||
|
FPU_PC_EXTENDED precision control for 64 bits mantissa
|
||||||
|
GET_FPUCW () yields the current FPU control word
|
||||||
|
SET_FPUCW (word) sets the FPU control word
|
||||||
|
DECL_LONG_DOUBLE_ROUNDING variable declaration for
|
||||||
|
BEGIN/END_LONG_DOUBLE_ROUNDING
|
||||||
|
BEGIN_LONG_DOUBLE_ROUNDING () starts a sequence of instructions with
|
||||||
|
'long double' safe operation precision
|
||||||
|
END_LONG_DOUBLE_ROUNDING () ends a sequence of instructions with
|
||||||
|
'long double' safe operation precision
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Inline assembler like this works only with GNU C and clang. */
|
||||||
|
#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__ || defined __clang__)
|
||||||
|
|
||||||
|
typedef unsigned short fpucw_t; /* glibc calls this fpu_control_t */
|
||||||
|
|
||||||
|
# define FPU_PC_MASK 0x0300
|
||||||
|
# define FPU_PC_DOUBLE 0x200 /* glibc calls this _FPU_DOUBLE */
|
||||||
|
# define FPU_PC_EXTENDED 0x300 /* glibc calls this _FPU_EXTENDED */
|
||||||
|
|
||||||
|
# define GET_FPUCW() __extension__ \
|
||||||
|
({ fpucw_t _cw; \
|
||||||
|
__asm__ __volatile__ ("fnstcw %0" : "=m" (*&_cw)); \
|
||||||
|
_cw; \
|
||||||
|
})
|
||||||
|
# define SET_FPUCW(word) __extension__ \
|
||||||
|
(void)({ fpucw_t _ncw = (word); \
|
||||||
|
__asm__ __volatile__ ("fldcw %0" : : "m" (*&_ncw)); \
|
||||||
|
})
|
||||||
|
|
||||||
|
# define DECL_LONG_DOUBLE_ROUNDING \
|
||||||
|
fpucw_t oldcw;
|
||||||
|
# define BEGIN_LONG_DOUBLE_ROUNDING() \
|
||||||
|
(void)(oldcw = GET_FPUCW (), \
|
||||||
|
SET_FPUCW ((oldcw & ~FPU_PC_MASK) | FPU_PC_EXTENDED))
|
||||||
|
# define END_LONG_DOUBLE_ROUNDING() \
|
||||||
|
SET_FPUCW (oldcw)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef unsigned int fpucw_t;
|
||||||
|
|
||||||
|
# define FPU_PC_MASK 0
|
||||||
|
# define FPU_PC_DOUBLE 0
|
||||||
|
# define FPU_PC_EXTENDED 0
|
||||||
|
|
||||||
|
# define GET_FPUCW() 0
|
||||||
|
# define SET_FPUCW(word) (void)(word)
|
||||||
|
|
||||||
|
# define DECL_LONG_DOUBLE_ROUNDING
|
||||||
|
# define BEGIN_LONG_DOUBLE_ROUNDING()
|
||||||
|
# define END_LONG_DOUBLE_ROUNDING()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _FPUCW_H */
|
53
lib/free.c
Normal file
53
lib/free.c
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/* Make free() preserve errno.
|
||||||
|
|
||||||
|
Copyright (C) 2003, 2006, 2009-2023 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 */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/* A function definition is only needed if HAVE_FREE_POSIX is not defined. */
|
||||||
|
#if !HAVE_FREE_POSIX
|
||||||
|
|
||||||
|
# include <errno.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
rpl_free (void *p)
|
||||||
|
# undef free
|
||||||
|
{
|
||||||
|
# if defined __GNUC__ && !defined __clang__
|
||||||
|
/* An invalid GCC optimization
|
||||||
|
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396>
|
||||||
|
would optimize away the assignments in the code below, when link-time
|
||||||
|
optimization (LTO) is enabled. Make the code more complicated, so that
|
||||||
|
GCC does not grok how to optimize it. */
|
||||||
|
int err[2];
|
||||||
|
err[0] = errno;
|
||||||
|
err[1] = errno;
|
||||||
|
errno = 0;
|
||||||
|
free (p);
|
||||||
|
errno = err[errno == 0];
|
||||||
|
# else
|
||||||
|
int err = errno;
|
||||||
|
free (p);
|
||||||
|
errno = err;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
168
lib/frexp.c
Normal file
168
lib/frexp.c
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
/* Split a double into fraction and mantissa.
|
||||||
|
Copyright (C) 2007-2023 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 Paolo Bonzini <bonzini@gnu.org>, 2003, and
|
||||||
|
Bruno Haible <bruno@clisp.org>, 2007. */
|
||||||
|
|
||||||
|
#if ! defined USE_LONG_DOUBLE
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <float.h>
|
||||||
|
#ifdef USE_LONG_DOUBLE
|
||||||
|
# include "isnanl-nolibm.h"
|
||||||
|
# include "fpucw.h"
|
||||||
|
#else
|
||||||
|
# include "isnand-nolibm.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This file assumes FLT_RADIX = 2. If FLT_RADIX is a power of 2 greater
|
||||||
|
than 2, or not even a power of 2, some rounding errors can occur, so that
|
||||||
|
then the returned mantissa is only guaranteed to be <= 1.0, not < 1.0. */
|
||||||
|
|
||||||
|
#ifdef USE_LONG_DOUBLE
|
||||||
|
# define FUNC frexpl
|
||||||
|
# define DOUBLE long double
|
||||||
|
# define ISNAN isnanl
|
||||||
|
# define DECL_ROUNDING DECL_LONG_DOUBLE_ROUNDING
|
||||||
|
# define BEGIN_ROUNDING() BEGIN_LONG_DOUBLE_ROUNDING ()
|
||||||
|
# define END_ROUNDING() END_LONG_DOUBLE_ROUNDING ()
|
||||||
|
# define L_(literal) literal##L
|
||||||
|
#else
|
||||||
|
# define FUNC frexp
|
||||||
|
# define DOUBLE double
|
||||||
|
# define ISNAN isnand
|
||||||
|
# define DECL_ROUNDING
|
||||||
|
# define BEGIN_ROUNDING()
|
||||||
|
# define END_ROUNDING()
|
||||||
|
# define L_(literal) literal
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DOUBLE
|
||||||
|
FUNC (DOUBLE x, int *expptr)
|
||||||
|
{
|
||||||
|
int sign;
|
||||||
|
int exponent;
|
||||||
|
DECL_ROUNDING
|
||||||
|
|
||||||
|
/* Test for NaN, infinity, and zero. */
|
||||||
|
if (ISNAN (x) || x + x == x)
|
||||||
|
{
|
||||||
|
*expptr = 0;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
sign = 0;
|
||||||
|
if (x < 0)
|
||||||
|
{
|
||||||
|
x = - x;
|
||||||
|
sign = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_ROUNDING ();
|
||||||
|
|
||||||
|
{
|
||||||
|
/* Since the exponent is an 'int', it fits in 64 bits. Therefore the
|
||||||
|
loops are executed no more than 64 times. */
|
||||||
|
DOUBLE pow2[64]; /* pow2[i] = 2^2^i */
|
||||||
|
DOUBLE powh[64]; /* powh[i] = 2^-2^i */
|
||||||
|
int i;
|
||||||
|
|
||||||
|
exponent = 0;
|
||||||
|
if (x >= L_(1.0))
|
||||||
|
{
|
||||||
|
/* A positive exponent. */
|
||||||
|
DOUBLE pow2_i; /* = pow2[i] */
|
||||||
|
DOUBLE powh_i; /* = powh[i] */
|
||||||
|
|
||||||
|
/* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
|
||||||
|
x * 2^exponent = argument, x >= 1.0. */
|
||||||
|
for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
|
||||||
|
;
|
||||||
|
i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
|
||||||
|
{
|
||||||
|
if (x >= pow2_i)
|
||||||
|
{
|
||||||
|
exponent += (1 << i);
|
||||||
|
x *= powh_i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
|
pow2[i] = pow2_i;
|
||||||
|
powh[i] = powh_i;
|
||||||
|
}
|
||||||
|
/* Avoid making x too small, as it could become a denormalized
|
||||||
|
number and thus lose precision. */
|
||||||
|
while (i > 0 && x < pow2[i - 1])
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
powh_i = powh[i];
|
||||||
|
}
|
||||||
|
exponent += (1 << i);
|
||||||
|
x *= powh_i;
|
||||||
|
/* Here 2^-2^i <= x < 1.0. */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* A negative or zero exponent. */
|
||||||
|
DOUBLE pow2_i; /* = pow2[i] */
|
||||||
|
DOUBLE powh_i; /* = powh[i] */
|
||||||
|
|
||||||
|
/* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
|
||||||
|
x * 2^exponent = argument, x < 1.0. */
|
||||||
|
for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
|
||||||
|
;
|
||||||
|
i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
|
||||||
|
{
|
||||||
|
if (x < powh_i)
|
||||||
|
{
|
||||||
|
exponent -= (1 << i);
|
||||||
|
x *= pow2_i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
|
pow2[i] = pow2_i;
|
||||||
|
powh[i] = powh_i;
|
||||||
|
}
|
||||||
|
/* Here 2^-2^i <= x < 1.0. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Invariants: x * 2^exponent = argument, and 2^-2^i <= x < 1.0. */
|
||||||
|
while (i > 0)
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
if (x < powh[i])
|
||||||
|
{
|
||||||
|
exponent -= (1 << i);
|
||||||
|
x *= pow2[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Here 0.5 <= x < 1.0. */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sign < 0)
|
||||||
|
x = - x;
|
||||||
|
|
||||||
|
END_ROUNDING ();
|
||||||
|
|
||||||
|
*expptr = exponent;
|
||||||
|
return x;
|
||||||
|
}
|
35
lib/frexpl.c
Normal file
35
lib/frexpl.c
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/* Split a 'long double' into fraction and mantissa.
|
||||||
|
Copyright (C) 2007, 2009-2023 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>
|
||||||
|
|
||||||
|
#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
# include <math.h>
|
||||||
|
|
||||||
|
long double
|
||||||
|
frexpl (long double x, int *expptr)
|
||||||
|
{
|
||||||
|
return frexp (x, expptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# define USE_LONG_DOUBLE
|
||||||
|
# include "frexp.c"
|
||||||
|
|
||||||
|
#endif
|
94
lib/fstat.c
Normal file
94
lib/fstat.c
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/* fstat() replacement.
|
||||||
|
Copyright (C) 2011-2023 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/>. */
|
||||||
|
|
||||||
|
/* If the user's config.h happens to include <sys/stat.h>, let it include only
|
||||||
|
the system's <sys/stat.h> here, so that orig_fstat doesn't recurse to
|
||||||
|
rpl_fstat. */
|
||||||
|
#define __need_system_sys_stat_h
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/* Get the original definition of fstat. It might be defined as a macro. */
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#undef __need_system_sys_stat_h
|
||||||
|
|
||||||
|
#if defined _WIN32 && ! defined __CYGWIN__
|
||||||
|
# define WINDOWS_NATIVE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined WINDOWS_NATIVE
|
||||||
|
|
||||||
|
static int
|
||||||
|
orig_fstat (int fd, struct stat *buf)
|
||||||
|
{
|
||||||
|
return fstat (fd, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Specification. */
|
||||||
|
#ifdef __osf__
|
||||||
|
/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
|
||||||
|
eliminates this include because of the preliminary #include <sys/stat.h>
|
||||||
|
above. */
|
||||||
|
# include "sys/stat.h"
|
||||||
|
#else
|
||||||
|
# include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "stat-time.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#ifdef WINDOWS_NATIVE
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h>
|
||||||
|
# if GNULIB_MSVC_NOTHROW
|
||||||
|
# include "msvc-nothrow.h"
|
||||||
|
# else
|
||||||
|
# include <io.h>
|
||||||
|
# endif
|
||||||
|
# include "stat-w32.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
rpl_fstat (int fd, struct stat *buf)
|
||||||
|
{
|
||||||
|
#if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY
|
||||||
|
/* Handle the case when rpl_open() used a dummy file descriptor to work
|
||||||
|
around an open() that can't normally visit directories. */
|
||||||
|
const char *name = _gl_directory_name (fd);
|
||||||
|
if (name != NULL)
|
||||||
|
return stat (name, buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WINDOWS_NATIVE
|
||||||
|
/* Fill the fields ourselves, because the original fstat function returns
|
||||||
|
values for st_atime, st_mtime, st_ctime that depend on the current time
|
||||||
|
zone. See
|
||||||
|
<https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */
|
||||||
|
HANDLE h = (HANDLE) _get_osfhandle (fd);
|
||||||
|
|
||||||
|
if (h == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return _gl_fstat_by_handle (h, NULL, buf);
|
||||||
|
#else
|
||||||
|
return stat_time_normalize (orig_fstat (fd, buf), buf);
|
||||||
|
#endif
|
||||||
|
}
|
148
lib/fstatat.c
Normal file
148
lib/fstatat.c
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
/* Work around an fstatat bug on Solaris 9.
|
||||||
|
|
||||||
|
Copyright (C) 2006, 2009-2023 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 Paul Eggert and Jim Meyering. */
|
||||||
|
|
||||||
|
/* If the user's config.h happens to include <sys/stat.h>, let it include only
|
||||||
|
the system's <sys/stat.h> here, so that orig_fstatat doesn't recurse to
|
||||||
|
rpl_fstatat. */
|
||||||
|
#define __need_system_sys_stat_h
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
/* Get the original definition of fstatat. It might be defined as a macro. */
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#undef __need_system_sys_stat_h
|
||||||
|
|
||||||
|
#if HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG
|
||||||
|
static int
|
||||||
|
orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
|
||||||
|
{
|
||||||
|
return fstatat (fd, filename, buf, flags);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __osf__
|
||||||
|
/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
|
||||||
|
eliminates this include because of the preliminary #include <sys/stat.h>
|
||||||
|
above. */
|
||||||
|
# include "sys/stat.h"
|
||||||
|
#else
|
||||||
|
# include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "stat-time.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG
|
||||||
|
|
||||||
|
# ifndef LSTAT_FOLLOWS_SLASHED_SYMLINK
|
||||||
|
# define LSTAT_FOLLOWS_SLASHED_SYMLINK 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
static int
|
||||||
|
normal_fstatat (int fd, char const *file, struct stat *st, int flag)
|
||||||
|
{
|
||||||
|
return stat_time_normalize (orig_fstatat (fd, file, st, flag), st);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fstatat should always follow symbolic links that end in /, but on
|
||||||
|
Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified.
|
||||||
|
Likewise, trailing slash on a non-directory should be an error.
|
||||||
|
These are the same problems that lstat.c and stat.c address, so
|
||||||
|
solve it in a similar way.
|
||||||
|
|
||||||
|
AIX 7.1 fstatat (AT_FDCWD, ..., 0) always fails, which is a bug.
|
||||||
|
Work around this bug if FSTATAT_AT_FDCWD_0_BROKEN is nonzero. */
|
||||||
|
|
||||||
|
int
|
||||||
|
rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
|
||||||
|
{
|
||||||
|
int result = normal_fstatat (fd, file, st, flag);
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0)
|
||||||
|
return result;
|
||||||
|
len = strlen (file);
|
||||||
|
if (flag & AT_SYMLINK_NOFOLLOW)
|
||||||
|
{
|
||||||
|
/* Fix lstat behavior. */
|
||||||
|
if (file[len - 1] != '/' || S_ISDIR (st->st_mode))
|
||||||
|
return 0;
|
||||||
|
if (!S_ISLNK (st->st_mode))
|
||||||
|
{
|
||||||
|
errno = ENOTDIR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
result = normal_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW);
|
||||||
|
}
|
||||||
|
/* Fix stat behavior. */
|
||||||
|
if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/')
|
||||||
|
{
|
||||||
|
errno = ENOTDIR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* ! (HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG) */
|
||||||
|
|
||||||
|
/* On mingw, the gnulib <sys/stat.h> defines 'stat' as a function-like
|
||||||
|
macro; but using it in AT_FUNC_F2 causes compilation failure
|
||||||
|
because the preprocessor sees a use of a macro that requires two
|
||||||
|
arguments but is only given one. Hence, we need an inline
|
||||||
|
forwarder to get past the preprocessor. */
|
||||||
|
static int
|
||||||
|
stat_func (char const *name, struct stat *st)
|
||||||
|
{
|
||||||
|
return stat (name, st);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Likewise, if there is no native 'lstat', then the gnulib
|
||||||
|
<sys/stat.h> defined it as stat, which also needs adjustment. */
|
||||||
|
# if !HAVE_LSTAT
|
||||||
|
# undef lstat
|
||||||
|
# define lstat stat_func
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* Replacement for Solaris' function by the same name.
|
||||||
|
<https://www.google.com/search?q=fstatat+site:docs.oracle.com>
|
||||||
|
First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE").
|
||||||
|
Failing that, simulate it via save_cwd/fchdir/(stat|lstat)/restore_cwd.
|
||||||
|
If either the save_cwd or the restore_cwd fails (relatively unlikely),
|
||||||
|
then give a diagnostic and exit nonzero.
|
||||||
|
Otherwise, this function works just like Solaris' fstatat. */
|
||||||
|
|
||||||
|
# define AT_FUNC_NAME fstatat
|
||||||
|
# define AT_FUNC_F1 lstat
|
||||||
|
# define AT_FUNC_F2 stat_func
|
||||||
|
# define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW
|
||||||
|
# define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat *st, int flag
|
||||||
|
# define AT_FUNC_POST_FILE_ARGS , st
|
||||||
|
# include "at-func.c"
|
||||||
|
# undef AT_FUNC_NAME
|
||||||
|
# undef AT_FUNC_F1
|
||||||
|
# undef AT_FUNC_F2
|
||||||
|
# undef AT_FUNC_USE_F1_COND
|
||||||
|
# undef AT_FUNC_POST_FILE_PARAM_DECLS
|
||||||
|
# undef AT_FUNC_POST_FILE_ARGS
|
||||||
|
|
||||||
|
#endif /* !HAVE_FSTATAT */
|
37
lib/futimens.c
Normal file
37
lib/futimens.c
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/* Set the access and modification time of an open fd.
|
||||||
|
Copyright (C) 2009-2023 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/>. */
|
||||||
|
|
||||||
|
/* written by Eric Blake */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "utimens.h"
|
||||||
|
|
||||||
|
/* Set the access and modification timestamps of FD to be
|
||||||
|
TIMESPEC[0] and TIMESPEC[1], respectively.
|
||||||
|
Fail with ENOSYS on systems without futimes (or equivalent).
|
||||||
|
If TIMESPEC is null, set the timestamps to the current time.
|
||||||
|
Return 0 on success, -1 (setting errno) on failure. */
|
||||||
|
int
|
||||||
|
futimens (int fd, struct timespec const times[2])
|
||||||
|
{
|
||||||
|
/* fdutimens also works around bugs in native futimens, when running
|
||||||
|
with glibc compiled against newer headers but on a Linux kernel
|
||||||
|
older than 2.6.32. */
|
||||||
|
return fdutimens (fd, NULL, times);
|
||||||
|
}
|
127
lib/getcwd-lgpl.c
Normal file
127
lib/getcwd-lgpl.c
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
/* Copyright (C) 2011-2023 Free Software Foundation, Inc.
|
||||||
|
This file is part of gnulib.
|
||||||
|
|
||||||
|
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 <unistd.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if GNULIB_GETCWD
|
||||||
|
/* Favor GPL getcwd.c if both getcwd and getcwd-lgpl modules are in use. */
|
||||||
|
typedef int dummy;
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Get the name of the current working directory, and put it in SIZE
|
||||||
|
bytes of BUF. Returns NULL if the directory couldn't be determined
|
||||||
|
(perhaps because the absolute name was longer than PATH_MAX, or
|
||||||
|
because of missing read/search permissions on parent directories)
|
||||||
|
or SIZE was too small. If successful, returns BUF. If BUF is
|
||||||
|
NULL, an array is allocated with 'malloc'; the array is SIZE bytes
|
||||||
|
long, unless SIZE == 0, in which case it is as big as
|
||||||
|
necessary. */
|
||||||
|
|
||||||
|
# undef getcwd
|
||||||
|
# if defined _WIN32 && !defined __CYGWIN__
|
||||||
|
# define getcwd _getcwd
|
||||||
|
# endif
|
||||||
|
|
||||||
|
char *
|
||||||
|
rpl_getcwd (char *buf, size_t size)
|
||||||
|
{
|
||||||
|
char *ptr;
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
/* Handle single size operations. */
|
||||||
|
if (buf)
|
||||||
|
{
|
||||||
|
if (!size)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return getcwd (buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
{
|
||||||
|
buf = malloc (size);
|
||||||
|
if (!buf)
|
||||||
|
{
|
||||||
|
errno = ENOMEM;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
result = getcwd (buf, size);
|
||||||
|
if (!result)
|
||||||
|
free (buf);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flexible sizing requested. Avoid over-allocation for the common
|
||||||
|
case of a name that fits within a 4k page, minus some space for
|
||||||
|
local variables, to be sure we don't skip over a guard page. */
|
||||||
|
{
|
||||||
|
char tmp[4032];
|
||||||
|
size = sizeof tmp;
|
||||||
|
ptr = getcwd (tmp, size);
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
result = strdup (ptr);
|
||||||
|
if (!result)
|
||||||
|
errno = ENOMEM;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (errno != ERANGE)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* My what a large directory name we have. */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
size <<= 1;
|
||||||
|
ptr = realloc (buf, size);
|
||||||
|
if (ptr == NULL)
|
||||||
|
{
|
||||||
|
free (buf);
|
||||||
|
errno = ENOMEM;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
buf = ptr;
|
||||||
|
result = getcwd (buf, size);
|
||||||
|
}
|
||||||
|
while (!result && errno == ERANGE);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
free (buf);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Here result == buf. */
|
||||||
|
/* Shrink result before returning it. */
|
||||||
|
size_t actual_size = strlen (result) + 1;
|
||||||
|
if (actual_size < size)
|
||||||
|
{
|
||||||
|
char *shrinked_result = realloc (result, actual_size);
|
||||||
|
if (shrinked_result != NULL)
|
||||||
|
result = shrinked_result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
147
lib/getdelim.c
Normal file
147
lib/getdelim.c
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
/* getdelim.c --- Implementation of replacement getdelim function.
|
||||||
|
Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2023 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/>. */
|
||||||
|
|
||||||
|
/* Ported from glibc by Simon Josefsson. */
|
||||||
|
|
||||||
|
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
|
||||||
|
optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */
|
||||||
|
#define _GL_ARG_NONNULL(params)
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifndef SSIZE_MAX
|
||||||
|
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_UNLOCKED_IO
|
||||||
|
# include "unlocked-io.h"
|
||||||
|
# define getc_maybe_unlocked(fp) getc(fp)
|
||||||
|
#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
|
||||||
|
# undef flockfile
|
||||||
|
# undef funlockfile
|
||||||
|
# define flockfile(x) ((void) 0)
|
||||||
|
# define funlockfile(x) ((void) 0)
|
||||||
|
# define getc_maybe_unlocked(fp) getc(fp)
|
||||||
|
#else
|
||||||
|
# define getc_maybe_unlocked(fp) getc_unlocked(fp)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
alloc_failed (void)
|
||||||
|
{
|
||||||
|
#if defined _WIN32 && ! defined __CYGWIN__
|
||||||
|
/* Avoid errno problem without using the realloc module; see:
|
||||||
|
https://lists.gnu.org/r/bug-gnulib/2016-08/msg00025.html */
|
||||||
|
errno = ENOMEM;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
|
||||||
|
NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
|
||||||
|
NULL), pointing to *N characters of space. It is realloc'ed as
|
||||||
|
necessary. Returns the number of characters read (not including
|
||||||
|
the null terminator), or -1 on error or EOF. */
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
|
||||||
|
{
|
||||||
|
ssize_t result;
|
||||||
|
size_t cur_len = 0;
|
||||||
|
|
||||||
|
if (lineptr == NULL || n == NULL || fp == NULL)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
flockfile (fp);
|
||||||
|
|
||||||
|
if (*lineptr == NULL || *n == 0)
|
||||||
|
{
|
||||||
|
char *new_lineptr;
|
||||||
|
*n = 120;
|
||||||
|
new_lineptr = (char *) realloc (*lineptr, *n);
|
||||||
|
if (new_lineptr == NULL)
|
||||||
|
{
|
||||||
|
alloc_failed ();
|
||||||
|
result = -1;
|
||||||
|
goto unlock_return;
|
||||||
|
}
|
||||||
|
*lineptr = new_lineptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = getc_maybe_unlocked (fp);
|
||||||
|
if (i == EOF)
|
||||||
|
{
|
||||||
|
result = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make enough space for len+1 (for final NUL) bytes. */
|
||||||
|
if (cur_len + 1 >= *n)
|
||||||
|
{
|
||||||
|
size_t needed_max =
|
||||||
|
SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
|
||||||
|
size_t needed = 2 * *n + 1; /* Be generous. */
|
||||||
|
char *new_lineptr;
|
||||||
|
|
||||||
|
if (needed_max < needed)
|
||||||
|
needed = needed_max;
|
||||||
|
if (cur_len + 1 >= needed)
|
||||||
|
{
|
||||||
|
result = -1;
|
||||||
|
errno = EOVERFLOW;
|
||||||
|
goto unlock_return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_lineptr = (char *) realloc (*lineptr, needed);
|
||||||
|
if (new_lineptr == NULL)
|
||||||
|
{
|
||||||
|
alloc_failed ();
|
||||||
|
result = -1;
|
||||||
|
goto unlock_return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*lineptr = new_lineptr;
|
||||||
|
*n = needed;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*lineptr)[cur_len] = i;
|
||||||
|
cur_len++;
|
||||||
|
|
||||||
|
if (i == delimiter)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
(*lineptr)[cur_len] = '\0';
|
||||||
|
result = cur_len ? cur_len : result;
|
||||||
|
|
||||||
|
unlock_return:
|
||||||
|
funlockfile (fp); /* doesn't set errno */
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue