Remove the GNU patch(1) sources that were committed to HEAD.
Approved by: ache, cvs, ru MFC after: 2 weeks
This commit is contained in:
parent
aa1eb20ba2
commit
9d80ef9bb5
@ -1,340 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
File diff suppressed because it is too large
Load Diff
@ -1,34 +0,0 @@
|
||||
This directory contains the virgin patch source on the vendor branch. Do
|
||||
not under any circumstances commit new versions onto the mainline, new
|
||||
versions or official-patch versions must be imported.
|
||||
|
||||
To prepare a new patch dist for import, extract it into a fresh directory
|
||||
and remove the following files (and any others that are non-FreeBSD
|
||||
specific):
|
||||
|
||||
memchr.c
|
||||
mkinstalldirs
|
||||
pc/*
|
||||
rename.c
|
||||
|
||||
The only other change that was made to the original tarball was to
|
||||
rename patch.man to patch.1.
|
||||
|
||||
patch has RCS Id, Name and Header tags. It needs to be imported with -ko.
|
||||
|
||||
It is imported from it's top level directory something like this:
|
||||
cvs -n import -ko src/contrib/patch FSF patch_<version>
|
||||
|
||||
The -n option is "don't do anything" so you can see what is about to happen
|
||||
first. Remove it when it looks ok.
|
||||
|
||||
The initial import was done with:
|
||||
cvs import -ko src/contrib/patch FSF patch_2_4
|
||||
|
||||
When new versions are imported, cvs will give instructions on how to merge
|
||||
the local and vendor changes when/if conflicts arise..
|
||||
|
||||
steve@freebsd.org - 29 June 1997
|
||||
|
||||
Current local changes:
|
||||
- Make patch(1) compile -Wall clean.
|
@ -1,183 +0,0 @@
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, a file
|
||||
`config.cache' that saves the results of its tests to speed up
|
||||
reconfiguring, and a file `config.log' containing compiler output
|
||||
(useful mainly for debugging `configure').
|
||||
|
||||
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 at some point `config.cache'
|
||||
contains results you don't want to keep, you may remove or edit it.
|
||||
|
||||
The file `configure.in' is used to create `configure' by a program
|
||||
called `autoconf'. You only need `configure.in' if you want to change
|
||||
it or regenerate `configure' using a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. You can give `configure'
|
||||
initial values for variables by setting them in the environment. Using
|
||||
a Bourne-compatible shell, you can do that on the command line like
|
||||
this:
|
||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||
|
||||
Or on systems that have the `env' program, you can do it like this:
|
||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not supports the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a time
|
||||
in the source code directory. After you have installed the package for
|
||||
one architecture, use `make distclean' before reconfiguring for another
|
||||
architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' can not figure out
|
||||
automatically, but needs to determine by the type of host the package
|
||||
will run on. Usually `configure' can figure that out, but if it prints
|
||||
a message saying it can not guess the host type, give it the
|
||||
`--host=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name with three fields:
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the host type.
|
||||
|
||||
If you are building compiler tools for cross-compiling, you can also
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for and the `--build=TYPE' option to select the type of
|
||||
system on which you are compiling the package.
|
||||
|
||||
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.
|
||||
|
||||
Operation Controls
|
||||
==================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Use and save the results of the tests in FILE instead of
|
||||
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
||||
debugging `configure'.
|
||||
|
||||
`--help'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--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.
|
||||
|
||||
`--version'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options.
|
||||
|
@ -1,158 +0,0 @@
|
||||
# Makefile for GNU patch.
|
||||
# Copyright 1993, 1997 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
CC = @CC@
|
||||
ed_PROGRAM = @ed_PROGRAM@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
transform = @program_transform_name@
|
||||
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
DEFS = @DEFS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
PACKAGE = @PACKAGE@
|
||||
VERSION = @VERSION@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = $(exec_prefix)/bin
|
||||
|
||||
# Where to put the manual pages.
|
||||
man1dir = $(prefix)/man/man1
|
||||
# Extension (including `.') for the manual page filenames.
|
||||
man1ext = .1
|
||||
|
||||
# Hook for nonstandard builds.
|
||||
CONFIG_STATUS = config.status
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
LIBSRCS = getopt.c getopt1.c memchr.c rename.c
|
||||
SRCS = addext.c argmatch.c backupfile.c basename.c inp.c maketime.c \
|
||||
partime.c patch.c pch.c quotearg.c util.c version.c $(LIBSRCS)
|
||||
OBJS = addext.o argmatch.o backupfile.o basename.o inp.o maketime.o \
|
||||
partime.o patch.o pch.o quotearg.o util.o version.o $(LIBOBJS)
|
||||
HDRS = argmatch.h backupfile.h common.h getopt.h \
|
||||
inp.h maketime.h partime.h pch.h quotearg.h util.h version.h
|
||||
MISC = COPYING ChangeLog INSTALL Makefile.in NEWS README \
|
||||
acconfig.h config.hin configure configure.in \
|
||||
install-sh mkinstalldirs patch.man
|
||||
DISTFILES = $(MISC) $(SRCS) $(HDRS)
|
||||
DISTFILES_PC = pc/chdirsaf.c
|
||||
DISTFILES_PC_DJGPP = pc/djgpp/README pc/djgpp/config.sed \
|
||||
pc/djgpp/configure.bat pc/djgpp/configure.sed
|
||||
|
||||
patch_name = `echo patch | sed '$(transform)'`
|
||||
|
||||
all:: patch
|
||||
|
||||
info::
|
||||
check::
|
||||
installcheck::
|
||||
|
||||
COMPILE = $(CC) -c $(CPPFLAGS) $(DEFS) -Ded_PROGRAM=\"$(ed_PROGRAM)\" \
|
||||
-I. -I$(srcdir) $(CFLAGS)
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) $<
|
||||
|
||||
patch: $(OBJS)
|
||||
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS)
|
||||
|
||||
install:: all installdirs
|
||||
$(INSTALL_PROGRAM) patch $(bindir)/$(patch_name)
|
||||
-$(INSTALL_DATA) $(srcdir)/patch.man $(man1dir)/$(patch_name)$(man1ext)
|
||||
|
||||
installdirs::
|
||||
$(SHELL) $(srcdir)/mkinstalldirs $(bindir) $(man1dir)
|
||||
|
||||
install-strip::
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
||||
|
||||
uninstall::
|
||||
rm -f $(bindir)/$(patch_name) $(man1dir)/$(patch_name)$(man1ext)
|
||||
|
||||
Makefile: Makefile.in $(CONFIG_STATUS)
|
||||
$(SHELL) $(CONFIG_STATUS)
|
||||
config.status: configure
|
||||
$(SHELL) $(CONFIG_STATUS) --recheck
|
||||
configure: configure.in
|
||||
cd $(srcdir) && autoconf
|
||||
config.hin: configure.in acconfig.h
|
||||
cd $(srcdir) && rm -f config.hin && autoheader
|
||||
|
||||
patchlevel.h: Makefile
|
||||
echo '#define PATCH_VERSION "$(VERSION)"' >patchlevel.h
|
||||
|
||||
TAGS: $(HDRS) patchlevel.h $(SRCS)
|
||||
etags $(HDRS) patchlevel.h $(SRCS)
|
||||
|
||||
clean::
|
||||
rm -f patch core* *core *.o
|
||||
|
||||
mostlyclean:: clean
|
||||
|
||||
distclean:: clean
|
||||
rm -f Makefile config.cache config.log config.status config.h
|
||||
rm -f patchlevel.h
|
||||
|
||||
maintainer-clean::
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "rebuilding the deleted files requires special tools."
|
||||
$(MAKE) distclean
|
||||
rm -f TAGS
|
||||
|
||||
PV = $(PACKAGE)-$(VERSION)
|
||||
|
||||
dist:: $(DISTFILES) $(DISTFILES_PC) $(DISTFILES_PC_DJGPP)
|
||||
rm -rf $(PV)
|
||||
mkdir $(PV) $(PV)/pc $(PV)/pc/djgpp
|
||||
cp -p $(DISTFILES) $(PV)
|
||||
cp -p $(DISTFILES_PC) $(PV)/pc
|
||||
cp -p $(DISTFILES_PC_DJGPP) $(PV)/pc/djgpp
|
||||
tar -chf - $(PV) | gzip -9 >$(PV).tar.gz
|
||||
rm -rf $(PV)
|
||||
|
||||
$(OBJS): config.h
|
||||
addext.o: backupfile.h
|
||||
argmatch.o: argmatch.h
|
||||
backupfile.o: argmatch.h backupfile.h
|
||||
basename.o: backupfile.h
|
||||
getopt.o getopt1.o: getopt.h
|
||||
maketime.o: maketime.h partime.h
|
||||
inp.o: backupfile.h common.h inp.h pch.h util.h
|
||||
partime.o: partime.h
|
||||
patch.o: argmatch.h backupfile.h common.h getopt.h inp.h pch.h util.h version.h
|
||||
pch.o: common.h inp.h pch.h util.h
|
||||
quotearg.o: quotearg.h
|
||||
util.o: backupfile.h common.h maketime.h partime.h quotearg.h util.h version.h
|
||||
version.o: common.h patchlevel.h util.h version.h
|
@ -1,173 +0,0 @@
|
||||
Known problems:
|
||||
|
||||
* The diffutils 2.7 documentation for `patch' is obsolete; this should be
|
||||
fixed in diffutils 2.8. Until then, see `patch --help' or `man patch'.
|
||||
|
||||
Changes in version 2.5:
|
||||
|
||||
* Version control is now independent of whether backups are made.
|
||||
The -V or --version-control option and the VERSION_CONTROL and
|
||||
PATCH_VERSION_CONTROL environment variables no longer affect whether
|
||||
backups are made; they affect only the names of the backup files.
|
||||
|
||||
* When asking the user whether to reverse a patch,
|
||||
the default answer is now `no' instead of `yes'.
|
||||
|
||||
* `patch' can now recognize context diffs that have been encapsulated
|
||||
by prepending "- " to lines beginning with "-" (as per Internet RFC 934).
|
||||
|
||||
* `patch' now reports an error if the input contains garbage and no patches.
|
||||
|
||||
Changes in version 2.4:
|
||||
|
||||
* New options:
|
||||
-Z or --set-utc sets times of patched files, assuming diff uses UTC (GMT).
|
||||
-T or --set-time is similar, assuming local time (not recommended).
|
||||
--backup-if-mismatch makes a backup if the patch does not match exactly
|
||||
--no-backup-if-mismatch makes a backup only if otherwise requested
|
||||
|
||||
* The default is now --backup-if-mismatch unless POSIXLY_CORRECT is set.
|
||||
|
||||
* The -B or --prefix, -Y or --basename-prefix, and -z or --suffix options
|
||||
no longer affect whether backups are made (as they did in patch 2.2 and 2.3);
|
||||
they now merely specify the file names used when simple backups are made.
|
||||
|
||||
* When patching a nonexistent file and making backups, an empty backup file
|
||||
is now made (just as with traditional patch); but the backup file is
|
||||
unreadable, as a way of indicating that it represents a nonexistent file.
|
||||
|
||||
* `patch' now matches against empty and nonexistent files more generously.
|
||||
A patch against an empty file applies to a nonexistent file, and vice versa.
|
||||
|
||||
* -g or --get and PATCH_GET now have a numeric value that specifies
|
||||
whether `patch' is getting files.
|
||||
If the value is positive, working files are gotten from RCS or SCCS files;
|
||||
if zero, `patch' ignores RCS and SCCS and working files are not gotten;
|
||||
and if negative, `patch' asks the user whether to get each file.
|
||||
The default is normally negative, but it is zero if POSIXLY_CORRECT is set.
|
||||
|
||||
* The -G or --no-get option introduced in GNU patch 2.3 has been removed;
|
||||
use -g0 instead.
|
||||
|
||||
* The method used to intuit names of files to be patched is changed again:
|
||||
`Index:' lines are normally ignored for context diffs,
|
||||
and RCS and SCCS files are normally looked for when files do not exist.
|
||||
The complete new method is described in the man page.
|
||||
|
||||
* By default, `patch' is now more verbose when patches do not match exactly.
|
||||
|
||||
* The manual page has a new COMPATIBILITY ISSUES section.
|
||||
|
||||
Changes in version 2.3:
|
||||
|
||||
* Unless the POSIXLY_CORRECT environment variable is set:
|
||||
|
||||
- `patch' now distinguishes more accurately between empty and
|
||||
nonexistent files if the input is a context diff.
|
||||
A file is assumed to not exist if its context diff header
|
||||
suggests that it is empty, and if the header timestamp
|
||||
looks like it might be equivalent to 1970-01-01 00:00:00 UTC.
|
||||
- Files that ``become nonexistent'' after patching are now removed.
|
||||
When a file is removed, any empty ancestor directories are also removed.
|
||||
|
||||
* Files are now automatically gotten from RCS and SCCS
|
||||
if the -g or --get option is specified.
|
||||
(The -G or --no-get option, also introduced in 2.3, was withdrawn in 2.4.)
|
||||
|
||||
* If the PATCH_VERSION_CONTROL environment variable is set,
|
||||
it overrides the VERSION_CONTROL environment variable.
|
||||
|
||||
* The method used to intuit names of files to be patched is changed.
|
||||
(It was further revised in 2.4; see above.)
|
||||
|
||||
* The new --binary option makes `patch' read and write files in binary mode.
|
||||
This option has no effect on POSIX-compliant hosts;
|
||||
it is useful only in on operating systems like DOS
|
||||
that distinguish between text and binary I/O.
|
||||
|
||||
* The environment variables TMP and TEMP are consulted for the name of
|
||||
the temporary directory if TMPDIR is not set.
|
||||
|
||||
* A port to MS-DOS and MS-Windows is available; see the `pc' directory.
|
||||
|
||||
* Backup file names are no longer ever computed by uppercasing characters,
|
||||
since this isn't portable to systems with case-insensitive file names.
|
||||
|
||||
Changes in version 2.2:
|
||||
|
||||
* Arbitrary limits removed (e.g. line length, file name length).
|
||||
|
||||
* On POSIX.1-compliant hosts, you can now patch binary files using the output
|
||||
of GNU `diff -a'.
|
||||
|
||||
* New options:
|
||||
--dry-run
|
||||
--help
|
||||
--verbose
|
||||
-i FILE or --input=FILE
|
||||
-Y PREF or --basename-prefix=PREF
|
||||
|
||||
* patch is now quieter by default; use --verbose for the old chatty behavior.
|
||||
|
||||
* Patch now complies better with POSIX.2 if your host complies with POSIX.1.
|
||||
|
||||
Therefore:
|
||||
- By default, no backups are made.
|
||||
(But this was changed again in patch 2.4; see above.)
|
||||
- The simple backup file name for F defaults to F.orig
|
||||
regardless of whether the file system supports long file names,
|
||||
and F~ is used only if F.orig is too long for that particular file.
|
||||
- Similarly for the reject file names F.rej and F#.
|
||||
|
||||
Also:
|
||||
- The pseudo-option `+' has been withdrawn.
|
||||
- -b is equivalent to --version-control=simple;
|
||||
`-z SUFF' has the meaning that `-b SUFF' used to.
|
||||
- Names of files to be patched are taken first from *** line and then from
|
||||
--- line of context diffs; then from Index: line; /dev/tty is
|
||||
consulted if none of the above files exist. However, if the patch
|
||||
appears to create a file, the file does not have to exist: instead,
|
||||
the first name with the longest existing directory prefix is taken.
|
||||
(These rules were changed again in patch 2.3 and 2.4; see above.)
|
||||
- Exit status 0 means success, 1 means hunks were rejected, 2 means trouble.
|
||||
- `-l' ignores changes only in spaces and tabs, not in other white space.
|
||||
- If no `-p' option is given, `-pINFINITY' is assumed, instead of trying
|
||||
to guess the proper value.
|
||||
- `-p' now requires an operand; use `-p 0' to get the effect of the old plain
|
||||
`-p' option.
|
||||
- `-p' treats two or more adjacent slashes as if it were one slash.
|
||||
- The TERM signal is caught.
|
||||
- New option `-i F' reads patch from F instead of stdin.
|
||||
|
||||
* The `patch' options and build procedure conform to current GNU standards.
|
||||
For example, the `--version' option now outputs copyright information.
|
||||
|
||||
* When the patch is creating a file, but a nonempty file of that name already
|
||||
exists, `patch' now asks for confirmation before patching.
|
||||
|
||||
* RCS is used only if the version control method is `existing'
|
||||
and there is already an RCS file. Similarly for SCCS.
|
||||
(But this was changed again in patch 2.3 and 2.4; see above.)
|
||||
|
||||
* Copyright notices have been clarified. Every file in this version of `patch'
|
||||
can be distributed under the GNU General Public License. See README for
|
||||
details.
|
||||
|
||||
Changes in version 2.1:
|
||||
|
||||
* A few more portability bugs have been fixed. The version number has
|
||||
been changed from 2.0.12g11 to 2.1, because the name
|
||||
`patch-2.0.12g10' was too long for traditional Unix file systems.
|
||||
|
||||
Versions 2.0.12g9 through 2.0.12g11 fix various portability bugs.
|
||||
|
||||
Changes in version 2.0.12g8:
|
||||
|
||||
* Start of the 12g series, with a GNU-style configure script and
|
||||
long-named options.
|
||||
* Added the -t --batch option, similar to -f.
|
||||
* Improved detection of files that are locked under RCS or SCCS.
|
||||
* Reinstate the -E option to remove output files that are empty after
|
||||
being patched.
|
||||
* Print the system error message when system calls fail.
|
||||
* Fixed various bugs and portability problems.
|
@ -1,52 +0,0 @@
|
||||
This version of `patch' has many changes made by the Free Software Foundation.
|
||||
They add support for:
|
||||
* handling arbitrary binary data and large files
|
||||
* the unified context diff format that GNU diff can produce
|
||||
* making GNU Emacs-style backup files
|
||||
* improved interaction with RCS and SCCS
|
||||
* the GNU conventions for option parsing and configuring and compilation.
|
||||
* better POSIX.2 compliance
|
||||
They also fix some bugs. See the NEWS and ChangeLog files for details.
|
||||
|
||||
Tutorial-style documentation for patch is included in the GNU
|
||||
diffutils package. Unfortunately, the diffutils 2.7 documentation
|
||||
for `patch' is obsolete; this should be fixed in diffutils 2.8.
|
||||
In the mean time, see `patch --help', or consult the man page
|
||||
in this distribution.
|
||||
|
||||
For GNU and Unix build and installation instructions, see the file INSTALL.
|
||||
For MS-DOS using DJGPP tools, see the file pc/djgpp/README.
|
||||
For other systems, copy config.hin to config.h and change
|
||||
#undef statements in it to #define as appropriate for your system,
|
||||
and copy Makefile.in to Makefile and set the variables that are
|
||||
enclosed in @ signs as appropriate for your system.
|
||||
|
||||
Please send bug reports for this version of patch to
|
||||
bug-gnu-utils@prep.ai.mit.edu.
|
||||
|
||||
The Free Software Foundation is distributing this version of patch
|
||||
independently because as of this writing, Larry Wall has not released a
|
||||
new version of patch since mid-1988. We have heard that he has been
|
||||
too busy working on other things, like Perl. He has graciously agreed
|
||||
to let GNU `patch' be distributed under the terms of the GNU General
|
||||
Public License.
|
||||
|
||||
------
|
||||
|
||||
Copyright 1984, 1985, 1986, 1987, 1988 Larry Wall
|
||||
Copyright 1989, 1990, 1991, 1992, 1993, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this file; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
@ -1,14 +0,0 @@
|
||||
/* Local acconfig.h for autoheader.
|
||||
Descriptive text for the C preprocessor macros that
|
||||
the patch configure.in can define.
|
||||
autoheader copies the comments into config.hin. */
|
||||
|
||||
/* Define if there is a member named d_ino in the struct describing
|
||||
directory headers. */
|
||||
#undef D_INO_IN_DIRENT
|
||||
|
||||
/* Define if memchr works. */
|
||||
#undef HAVE_MEMCHR
|
||||
|
||||
/* Define if `struct utimbuf' is declared -- usually in <utime.h>. */
|
||||
#undef HAVE_STRUCT_UTIMBUF
|
@ -1,106 +0,0 @@
|
||||
/* addext.c -- add an extension to a file name
|
||||
Copyright (C) 1990, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu> and Paul Eggert */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DOS_FILE_NAMES
|
||||
#define HAVE_DOS_FILE_NAMES 0
|
||||
#endif
|
||||
#ifndef HAVE_LONG_FILE_NAMES
|
||||
#define HAVE_LONG_FILE_NAMES 0
|
||||
#endif
|
||||
|
||||
#include <backupfile.h>
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef _POSIX_NAME_MAX
|
||||
#define _POSIX_NAME_MAX 14
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* Append to FILENAME the extension EXT, unless the result would be too long,
|
||||
in which case just append the character E. */
|
||||
|
||||
void
|
||||
addext (filename, ext, e)
|
||||
char *filename;
|
||||
char const *ext;
|
||||
int e;
|
||||
{
|
||||
char *s = base_name (filename);
|
||||
size_t slen = strlen (s), extlen = strlen (ext);
|
||||
long slen_max = -1;
|
||||
|
||||
#if HAVE_PATHCONF && defined _PC_NAME_MAX
|
||||
if (slen + extlen <= _POSIX_NAME_MAX && ! HAVE_DOS_FILE_NAMES)
|
||||
/* The file name is so short there's no need to call pathconf. */
|
||||
slen_max = _POSIX_NAME_MAX;
|
||||
else if (s == filename)
|
||||
slen_max = pathconf (".", _PC_NAME_MAX);
|
||||
else
|
||||
{
|
||||
char c = *s;
|
||||
*s = 0;
|
||||
slen_max = pathconf (filename, _PC_NAME_MAX);
|
||||
*s = c;
|
||||
}
|
||||
#endif
|
||||
if (slen_max < 0)
|
||||
slen_max = HAVE_LONG_FILE_NAMES ? 255 : 14;
|
||||
|
||||
if (HAVE_DOS_FILE_NAMES && slen_max <= 12)
|
||||
{
|
||||
/* Live within DOS's 8.3 limit. */
|
||||
char *dot = strchr (s, '.');
|
||||
if (dot)
|
||||
{
|
||||
slen -= dot + 1 - s;
|
||||
s = dot + 1;
|
||||
slen_max = 3;
|
||||
}
|
||||
else
|
||||
slen_max = 8;
|
||||
extlen = 9; /* Don't use EXT. */
|
||||
}
|
||||
|
||||
if (slen + extlen <= slen_max)
|
||||
strcpy (s + slen, ext);
|
||||
else
|
||||
{
|
||||
if (slen_max <= slen)
|
||||
slen = slen_max - 1;
|
||||
s[slen] = e;
|
||||
s[slen + 1] = 0;
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/* argmatch.c -- find a match for a string in an array
|
||||
Copyright (C) 1990, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <argmatch.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
/* If ARG is an unambiguous match for an element of the
|
||||
null-terminated array OPTLIST, return the index in OPTLIST
|
||||
of the matched element, else -1 if it does not match any element
|
||||
or -2 if it is ambiguous (is a prefix of more than one element). */
|
||||
|
||||
int
|
||||
argmatch (arg, optlist)
|
||||
const char *arg;
|
||||
const char *const *optlist;
|
||||
{
|
||||
int i; /* Temporary index in OPTLIST. */
|
||||
size_t arglen; /* Length of ARG. */
|
||||
int matchind = -1; /* Index of first nonexact match. */
|
||||
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
|
||||
|
||||
arglen = strlen (arg);
|
||||
|
||||
/* Test all elements for either exact match or abbreviated matches. */
|
||||
for (i = 0; optlist[i]; i++)
|
||||
{
|
||||
if (!strncmp (optlist[i], arg, arglen))
|
||||
{
|
||||
if (strlen (optlist[i]) == arglen)
|
||||
/* Exact match found. */
|
||||
return i;
|
||||
else if (matchind == -1)
|
||||
/* First nonexact match found. */
|
||||
matchind = i;
|
||||
else
|
||||
/* Second nonexact match found. */
|
||||
ambiguous = 1;
|
||||
}
|
||||
}
|
||||
if (ambiguous)
|
||||
return -2;
|
||||
else
|
||||
return matchind;
|
||||
}
|
||||
|
||||
/* Error reporting for argmatch.
|
||||
KIND is a description of the type of entity that was being matched.
|
||||
VALUE is the invalid value that was given.
|
||||
PROBLEM is the return value from argmatch. */
|
||||
|
||||
void
|
||||
invalid_arg (kind, value, problem)
|
||||
const char *kind;
|
||||
const char *value;
|
||||
int problem;
|
||||
{
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
if (problem == -1)
|
||||
fprintf (stderr, "invalid");
|
||||
else /* Assume -2. */
|
||||
fprintf (stderr, "ambiguous");
|
||||
fprintf (stderr, " %s `%s'\n", kind, value);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
/* argmatch.h -- declarations for matching arguments against option lists */
|
||||
|
||||
#if defined __STDC__ || __GNUC__
|
||||
# define __ARGMATCH_P(args) args
|
||||
#else
|
||||
# define __ARGMATCH_P(args) ()
|
||||
#endif
|
||||
|
||||
int argmatch __ARGMATCH_P ((const char *, const char * const *));
|
||||
void invalid_arg __ARGMATCH_P ((const char *, const char *, int));
|
||||
|
||||
extern char const program_name[];
|
@ -1,252 +0,0 @@
|
||||
/* backupfile.c -- make Emacs style backup file names
|
||||
Copyright (C) 1990,1991,1992,1993,1995,1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>.
|
||||
Some algorithms adapted from GNU Emacs. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <argmatch.h>
|
||||
#include <backupfile.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#if HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
# define NLENGTH(direct) strlen ((direct)->d_name)
|
||||
#else
|
||||
# define dirent direct
|
||||
# define NLENGTH(direct) ((size_t) (direct)->d_namlen)
|
||||
# if HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# if HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# if HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if CLOSEDIR_VOID
|
||||
/* Fake a return value. */
|
||||
# define CLOSEDIR(d) (closedir (d), 0)
|
||||
#else
|
||||
# define CLOSEDIR(d) closedir (d)
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
char *malloc ();
|
||||
#endif
|
||||
|
||||
#if HAVE_DIRENT_H || HAVE_NDIR_H || HAVE_SYS_DIR_H || HAVE_SYS_NDIR_H
|
||||
# define HAVE_DIR 1
|
||||
#else
|
||||
# define HAVE_DIR 0
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef CHAR_BIT
|
||||
#define CHAR_BIT 8
|
||||
#endif
|
||||
/* Upper bound on the string length of an integer converted to string.
|
||||
302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
|
||||
add 1 for integer division truncation; add 1 more for a minus sign. */
|
||||
#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
|
||||
|
||||
/* ISDIGIT differs from isdigit, as follows:
|
||||
- Its arg may be any int or unsigned int; it need not be an unsigned char.
|
||||
- It's guaranteed to evaluate its argument exactly once.
|
||||
- It's typically faster.
|
||||
Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
|
||||
only '0' through '9' are digits. Prefer ISDIGIT to isdigit unless
|
||||
it's important to use the locale's definition of `digit' even when the
|
||||
host does not conform to Posix. */
|
||||
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
|
||||
|
||||
#if D_INO_IN_DIRENT
|
||||
# define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0)
|
||||
#else
|
||||
# define REAL_DIR_ENTRY(dp) 1
|
||||
#endif
|
||||
|
||||
/* Which type of backup file names are generated. */
|
||||
enum backup_type backup_type = none;
|
||||
|
||||
/* The extension added to file names to produce a simple (as opposed
|
||||
to numbered) backup file name. */
|
||||
const char *simple_backup_suffix = ".orig";
|
||||
|
||||
static int max_backup_version __BACKUPFILE_P ((const char *, const char *));
|
||||
static int version_number __BACKUPFILE_P ((const char *, const char *, size_t));
|
||||
|
||||
/* Return the name of the new backup file for file FILE,
|
||||
allocated with malloc. Return 0 if out of memory.
|
||||
FILE must not end with a '/' unless it is the root directory.
|
||||
Do not call this function if backup_type == none. */
|
||||
|
||||
char *
|
||||
find_backup_file_name (file)
|
||||
const char *file;
|
||||
{
|
||||
size_t backup_suffix_size_max;
|
||||
size_t file_len = strlen (file);
|
||||
size_t numbered_suffix_size_max = INT_STRLEN_BOUND (int) + 4;
|
||||
char *s;
|
||||
const char *suffix = simple_backup_suffix;
|
||||
|
||||
/* Allow room for simple or `.~N~' backups. */
|
||||
backup_suffix_size_max = strlen (simple_backup_suffix) + 1;
|
||||
if (HAVE_DIR && backup_suffix_size_max < numbered_suffix_size_max)
|
||||
backup_suffix_size_max = numbered_suffix_size_max;
|
||||
|
||||
s = malloc (file_len + backup_suffix_size_max + numbered_suffix_size_max);
|
||||
if (s)
|
||||
{
|
||||
strcpy (s, file);
|
||||
|
||||
#if HAVE_DIR
|
||||
if (backup_type != simple)
|
||||
{
|
||||
int highest_backup;
|
||||
size_t dir_len = base_name (s) - s;
|
||||
|
||||
strcpy (s + dir_len, ".");
|
||||
highest_backup = max_backup_version (file + dir_len, s);
|
||||
if (! (backup_type == numbered_existing && highest_backup == 0))
|
||||
{
|
||||
char *numbered_suffix = s + (file_len + backup_suffix_size_max);
|
||||
sprintf (numbered_suffix, ".~%d~", highest_backup + 1);
|
||||
suffix = numbered_suffix;
|
||||
}
|
||||
strcpy (s, file);
|
||||
}
|
||||
#endif /* HAVE_DIR */
|
||||
|
||||
addext (s, suffix, '~');
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
#if HAVE_DIR
|
||||
|
||||
/* Return the number of the highest-numbered backup file for file
|
||||
FILE in directory DIR. If there are no numbered backups
|
||||
of FILE in DIR, or an error occurs reading DIR, return 0.
|
||||
*/
|
||||
|
||||
static int
|
||||
max_backup_version (file, dir)
|
||||
const char *file;
|
||||
const char *dir;
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
int highest_version;
|
||||
int this_version;
|
||||
size_t file_name_length;
|
||||
|
||||
dirp = opendir (dir);
|
||||
if (!dirp)
|
||||
return 0;
|
||||
|
||||
highest_version = 0;
|
||||
file_name_length = strlen (file);
|
||||
|
||||
while ((dp = readdir (dirp)) != 0)
|
||||
{
|
||||
if (!REAL_DIR_ENTRY (dp) || NLENGTH (dp) < file_name_length + 4)
|
||||
continue;
|
||||
|
||||
this_version = version_number (file, dp->d_name, file_name_length);
|
||||
if (this_version > highest_version)
|
||||
highest_version = this_version;
|
||||
}
|
||||
if (CLOSEDIR (dirp))
|
||||
return 0;
|
||||
return highest_version;
|
||||
}
|
||||
|
||||
/* If BACKUP is a numbered backup of BASE, return its version number;
|
||||
otherwise return 0. BASE_LENGTH is the length of BASE.
|
||||
*/
|
||||
|
||||
static int
|
||||
version_number (base, backup, base_length)
|
||||
const char *base;
|
||||
const char *backup;
|
||||
size_t base_length;
|
||||
{
|
||||
int version;
|
||||
const char *p;
|
||||
|
||||
version = 0;
|
||||
if (strncmp (base, backup, base_length) == 0
|
||||
&& backup[base_length] == '.'
|
||||
&& backup[base_length + 1] == '~')
|
||||
{
|
||||
for (p = &backup[base_length + 2]; ISDIGIT (*p); ++p)
|
||||
version = version * 10 + *p - '0';
|
||||
if (p[0] != '~' || p[1])
|
||||
version = 0;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
#endif /* HAVE_DIR */
|
||||
|
||||
static const char * const backup_args[] =
|
||||
{
|
||||
"never", "simple", "nil", "existing", "t", "numbered", 0
|
||||
};
|
||||
|
||||
static const enum backup_type backup_types[] =
|
||||
{
|
||||
simple, simple, numbered_existing, numbered_existing, numbered, numbered
|
||||
};
|
||||
|
||||
/* Return the type of backup indicated by VERSION.
|
||||
Unique abbreviations are accepted. */
|
||||
|
||||
enum backup_type
|
||||
get_version (version)
|
||||
const char *version;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (version == 0 || *version == 0)
|
||||
return numbered_existing;
|
||||
i = argmatch (version, backup_args);
|
||||
if (i < 0)
|
||||
{
|
||||
invalid_arg ("version control type", version, i);
|
||||
exit (2);
|
||||
}
|
||||
return backup_types[i];
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/* backupfile.h -- declarations for making Emacs style backup file names
|
||||
Copyright (C) 1990, 1991, 1992, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* When to make backup files. */
|
||||
enum backup_type
|
||||
{
|
||||
/* Never make backups. */
|
||||
none,
|
||||
|
||||
/* Make simple backups of every file. */
|
||||
simple,
|
||||
|
||||
/* Make numbered backups of files that already have numbered backups,
|
||||
and simple backups of the others. */
|
||||
numbered_existing,
|
||||
|
||||
/* Make numbered backups of every file. */
|
||||
numbered
|
||||
};
|
||||
|
||||
extern enum backup_type backup_type;
|
||||
extern char const *simple_backup_suffix;
|
||||
|
||||
#ifndef __BACKUPFILE_P
|
||||
# if defined __STDC__ || __GNUC__
|
||||
# define __BACKUPFILE_P(args) args
|
||||
# else
|
||||
# define __BACKUPFILE_P(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
char *base_name __BACKUPFILE_P ((char const *));
|
||||
char *find_backup_file_name __BACKUPFILE_P ((char const *));
|
||||
enum backup_type get_version __BACKUPFILE_P ((char const *));
|
||||
void addext __BACKUPFILE_P ((char *, char const *, int));
|
@ -1,32 +0,0 @@
|
||||
/* basename.c -- return the last element in a path */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <backupfile.h>
|
||||
|
||||
#ifndef FILESYSTEM_PREFIX_LEN
|
||||
#define FILESYSTEM_PREFIX_LEN(f) 0
|
||||
#endif
|
||||
|
||||
#ifndef ISSLASH
|
||||
#define ISSLASH(c) ((c) == '/')
|
||||
#endif
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `basename' modifies its argument. */
|
||||
|
||||
char *
|
||||
base_name (name)
|
||||
char const *name;
|
||||
{
|
||||
char const *base = name += FILESYSTEM_PREFIX_LEN (name);
|
||||
|
||||
for (; *name; name++)
|
||||
if (ISSLASH (*name))
|
||||
base = name + 1;
|
||||
|
||||
return (char *) base;
|
||||
}
|
@ -1,307 +0,0 @@
|
||||
/* common definitions for `patch' */
|
||||
|
||||
/* $Id: common.h,v 1.18 1997/06/13 06:28:37 eggert Exp $ */
|
||||
|
||||
/*
|
||||
Copyright 1986, 1988 Larry Wall
|
||||
Copyright 1990, 1991, 1992, 1993, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef DEBUGGING
|
||||
#define DEBUGGING 1
|
||||
#endif
|
||||
|
||||
/* We must define `volatile' and `const' first (the latter inside config.h),
|
||||
so that they're used consistently in all system includes. */
|
||||
#ifndef __STDC__
|
||||
# ifndef volatile
|
||||
# define volatile
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Enable support for fseeko and ftello on hosts
|
||||
where it is available but is turned off by default.
|
||||
This must be defined before any system file is included. */
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#if ! defined S_ISDIR && defined S_IFDIR
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#if ! defined S_ISREG && defined S_IFREG
|
||||
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
#ifndef S_IXOTH
|
||||
#define S_IXOTH 1
|
||||
#endif
|
||||
#ifndef S_IWOTH
|
||||
#define S_IWOTH 2
|
||||
#endif
|
||||
#ifndef S_IROTH
|
||||
#define S_IROTH 4
|
||||
#endif
|
||||
#ifndef S_IXGRP
|
||||
#define S_IXGRP (S_IXOTH << 3)
|
||||
#endif
|
||||
#ifndef S_IWGRP
|
||||
#define S_IWGRP (S_IWOTH << 3)
|
||||
#endif
|
||||
#ifndef S_IRGRP
|
||||
#define S_IRGRP (S_IROTH << 3)
|
||||
#endif
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR (S_IXOTH << 6)
|
||||
#endif
|
||||
#ifndef S_IWUSR
|
||||
#define S_IWUSR (S_IWOTH << 6)
|
||||
#endif
|
||||
#ifndef S_IRUSR
|
||||
#define S_IRUSR (S_IROTH << 6)
|
||||
#endif
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#ifndef INT_MAX
|
||||
#define INT_MAX 2147483647
|
||||
#endif
|
||||
#ifndef LONG_MIN
|
||||
#define LONG_MIN (-1-2147483647L)
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
/* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given
|
||||
as an argument to <ctype.h> macros like `isspace'. */
|
||||
#if STDC_HEADERS
|
||||
#define CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
#define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
|
||||
#endif
|
||||
#ifndef ISSPACE
|
||||
#define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
|
||||
#endif
|
||||
|
||||
#ifndef ISDIGIT
|
||||
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef FILESYSTEM_PREFIX_LEN
|
||||
#define FILESYSTEM_PREFIX_LEN(f) 0
|
||||
#endif
|
||||
|
||||
#ifndef ISSLASH
|
||||
#define ISSLASH(c) ((c) == '/')
|
||||
#endif
|
||||
|
||||
|
||||
/* constants */
|
||||
|
||||
/* AIX predefines these. */
|
||||
#ifdef TRUE
|
||||
#undef TRUE
|
||||
#endif
|
||||
#ifdef FALSE
|
||||
#undef FALSE
|
||||
#endif
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/* handy definitions */
|
||||
|
||||
#define strEQ(s1,s2) (!strcmp(s1, s2))
|
||||
#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
|
||||
|
||||
/* typedefs */
|
||||
|
||||
typedef int bool; /* must promote to itself */
|
||||
typedef long LINENUM; /* must be signed */
|
||||
|
||||
/* globals */
|
||||
|
||||
extern char const program_name[];
|
||||
|
||||
XTERN char *buf; /* general purpose buffer */
|
||||
XTERN size_t bufsize; /* allocated size of buf */
|
||||
|
||||
XTERN bool using_plan_a; /* try to keep everything in memory */
|
||||
|
||||
XTERN char *inname;
|
||||
XTERN char *outfile;
|
||||
XTERN int inerrno;
|
||||
XTERN int invc;
|
||||
XTERN struct stat instat;
|
||||
XTERN bool dry_run;
|
||||
XTERN bool posixly_correct;
|
||||
|
||||
XTERN char const *origprae;
|
||||
XTERN char const *origbase;
|
||||
|
||||
XTERN char const * volatile TMPOUTNAME;
|
||||
XTERN char const * volatile TMPINNAME;
|
||||
XTERN char const * volatile TMPPATNAME;
|
||||
|
||||
#ifdef DEBUGGING
|
||||
XTERN int debug;
|
||||
#else
|
||||
# define debug 0
|
||||
#endif
|
||||
XTERN bool force;
|
||||
XTERN bool batch;
|
||||
XTERN bool noreverse;
|
||||
XTERN int reverse;
|
||||
XTERN enum { DEFAULT_VERBOSITY, SILENT, VERBOSE } verbosity;
|
||||
XTERN bool skip_rest_of_patch;
|
||||
XTERN int strippath;
|
||||
XTERN bool canonicalize;
|
||||
XTERN int patch_get;
|
||||
XTERN int set_time;
|
||||
XTERN int set_utc;
|
||||
|
||||
enum diff
|
||||
{
|
||||
NO_DIFF,
|
||||
CONTEXT_DIFF,
|
||||
NORMAL_DIFF,
|
||||
ED_DIFF,
|
||||
NEW_CONTEXT_DIFF,
|
||||
UNI_DIFF
|
||||
};
|
||||
|
||||
XTERN enum diff diff_type;
|
||||
|
||||
XTERN char *revision; /* prerequisite revision, if any */
|
||||
|
||||
#ifdef __STDC__
|
||||
# define GENERIC_OBJECT void
|
||||
#else
|
||||
# define GENERIC_OBJECT char
|
||||
#endif
|
||||
|
||||
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifndef PARAMS
|
||||
# ifdef __STDC__
|
||||
# define PARAMS(args) args
|
||||
# else
|
||||
# define PARAMS(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
GENERIC_OBJECT *xmalloc PARAMS ((size_t));
|
||||
void fatal_exit PARAMS ((int)) __attribute__ ((noreturn));
|
||||
|
||||
#include <errno.h>
|
||||
#if !STDC_HEADERS && !defined errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS || HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# if !HAVE_MEMCHR
|
||||
# define memcmp(s1, s2, n) bcmp (s1, s2, n)
|
||||
# define memcpy(d, s, n) bcopy (s, d, n)
|
||||
GENERIC_OBJECT *memchr ();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
long atol ();
|
||||
char *getenv ();
|
||||
GENERIC_OBJECT *malloc ();
|
||||
GENERIC_OBJECT *realloc ();
|
||||
#endif
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifndef lseek
|
||||
off_t lseek ();
|
||||
#endif
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif
|
||||
#ifndef STDIN_FILENO
|
||||
#define STDIN_FILENO 0
|
||||
#endif
|
||||
#ifndef STDOUT_FILENO
|
||||
#define STDOUT_FILENO 1
|
||||
#endif
|
||||
#ifndef STDERR_FILENO
|
||||
#define STDERR_FILENO 2
|
||||
#endif
|
||||
#if _LFS_LARGEFILE
|
||||
typedef off_t file_offset;
|
||||
# define file_seek fseeko
|
||||
# define file_tell ftello
|
||||
#else
|
||||
typedef long file_offset;
|
||||
# define file_seek fseek
|
||||
# define file_tell ftell
|
||||
#endif
|
||||
|
||||
#if HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#ifndef O_RDONLY
|
||||
#define O_RDONLY 0
|
||||
#endif
|
||||
#ifndef O_WRONLY
|
||||
#define O_WRONLY 1
|
||||
#endif
|
||||
#ifndef O_RDWR
|
||||
#define O_RDWR 2
|
||||
#endif
|
||||
#ifndef _O_BINARY
|
||||
#define _O_BINARY 0
|
||||
#endif
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY _O_BINARY
|
||||
#endif
|
||||
#ifndef O_CREAT
|
||||
#define O_CREAT 0
|
||||
#endif
|
||||
#ifndef O_TRUNC
|
||||
#define O_TRUNC 0
|
||||
#endif
|
||||
|
||||
#if HAVE_SETMODE
|
||||
XTERN int binary_transput; /* O_BINARY if binary i/o is desired */
|
||||
#else
|
||||
# define binary_transput 0
|
||||
#endif
|
||||
|
||||
#ifndef NULL_DEVICE
|
||||
#define NULL_DEVICE "/dev/null"
|
||||
#endif
|
||||
|
||||
#ifndef TTY_DEVICE
|
||||
#define TTY_DEVICE "/dev/tty"
|
||||
#endif
|
@ -1,124 +0,0 @@
|
||||
/* config.hin. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define if on AIX 3.
|
||||
System headers sometimes define this.
|
||||
We just want to avoid a redefinition error message. */
|
||||
#ifndef _ALL_SOURCE
|
||||
#undef _ALL_SOURCE
|
||||
#endif
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
#undef CLOSEDIR_VOID
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
|
||||
/* Define if you don't have vprintf but do have _doprnt. */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define if you support file names longer than 14 characters. */
|
||||
#undef HAVE_LONG_FILE_NAMES
|
||||
|
||||
/* Define if you have the vprintf function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef mode_t
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define if the system does not provide POSIX.1 features except
|
||||
with this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if there is a member named d_ino in the struct describing
|
||||
directory headers. */
|
||||
#undef D_INO_IN_DIRENT
|
||||
|
||||
/* Define if memchr works. */
|
||||
#undef HAVE_MEMCHR
|
||||
|
||||
/* Define if `struct utimbuf' is declared -- usually in <utime.h>. */
|
||||
#undef HAVE_STRUCT_UTIMBUF
|
||||
|
||||
/* Define if you have the _doprintf function. */
|
||||
#undef HAVE__DOPRINTF
|
||||
|
||||
/* Define if you have the isascii function. */
|
||||
#undef HAVE_ISASCII
|
||||
|
||||
/* Define if you have the memchr function. */
|
||||
#undef HAVE_MEMCHR
|
||||
|
||||
/* Define if you have the memcmp function. */
|
||||
#undef HAVE_MEMCMP
|
||||
|
||||
/* Define if you have the mkdir function. */
|
||||
#undef HAVE_MKDIR
|
||||
|
||||
/* Define if you have the mktemp function. */
|
||||
#undef HAVE_MKTEMP
|
||||
|
||||
/* Define if you have the pathconf function. */
|
||||
#undef HAVE_PATHCONF
|
||||
|
||||
/* Define if you have the raise function. */
|
||||
#undef HAVE_RAISE
|
||||
|
||||
/* Define if you have the rename function. */
|
||||
#undef HAVE_RENAME
|
||||
|
||||
/* Define if you have the sigaction function. */
|
||||
#undef HAVE_SIGACTION
|
||||
|
||||
/* Define if you have the sigprocmask function. */
|
||||
#undef HAVE_SIGPROCMASK
|
||||
|
||||
/* Define if you have the sigsetmask function. */
|
||||
#undef HAVE_SIGSETMASK
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define if you have the <ndir.h> header file. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define if you have the <sys/dir.h> header file. */
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file. */
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if you have the <utime.h> header file. */
|
||||
#undef HAVE_UTIME_H
|
||||
|
||||
/* Define if you have the <varargs.h> header file. */
|
||||
#undef HAVE_VARARGS_H
|
2364
contrib/patch/configure
vendored
2364
contrib/patch/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,134 +0,0 @@
|
||||
# Configure `patch'.
|
||||
# Copyright 1993, 1997 Free Software Foundation, Inc.
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.12)
|
||||
AC_INIT(patch.c)
|
||||
AC_CONFIG_HEADER(config.h:config.hin)
|
||||
AC_ARG_PROGRAM
|
||||
|
||||
PACKAGE=patch
|
||||
VERSION=2.5
|
||||
AC_SUBST(PACKAGE)
|
||||
AC_SUBST(VERSION)
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
# Use ed_PROGRAM, not ED_PROGRAM,
|
||||
# because <errno.h> reserves symbols starting with `E'.
|
||||
AC_PATH_PROG(ed_PROGRAM, ed, ed)
|
||||
|
||||
# If available, prefer support for large files unless the user specified
|
||||
# one of the CPPFLAGS, LDFLAGS, or LIBS variables.
|
||||
AC_MSG_CHECKING(whether large file support needs explicit enabling)
|
||||
ac_getconfs=''
|
||||
ac_result=yes
|
||||
ac_set=''
|
||||
ac_shellvars='CPPFLAGS LDFLAGS LIBS'
|
||||
for ac_shellvar in $ac_shellvars; do
|
||||
case $ac_shellvar in
|
||||
CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
|
||||
*) ac_lfsvar=LFS_$ac_shellvar ;;
|
||||
esac
|
||||
eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
|
||||
(getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
|
||||
ac_getconf=`getconf $ac_lfsvar`
|
||||
ac_getconfs=$ac_getconfs$ac_getconf
|
||||
eval ac_test_$ac_shellvar=\$ac_getconf
|
||||
done
|
||||
case "$ac_result$ac_getconfs" in
|
||||
yes) ac_result=no ;;
|
||||
esac
|
||||
case "$ac_result$ac_set" in
|
||||
yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
|
||||
esac
|
||||
AC_MSG_RESULT($ac_result)
|
||||
case $ac_result in
|
||||
yes)
|
||||
for ac_shellvar in $ac_shellvars; do
|
||||
eval $ac_shellvar=\$ac_test_$ac_shellvar
|
||||
done ;;
|
||||
esac
|
||||
|
||||
AC_AIX
|
||||
AC_MINIX
|
||||
AC_ISC_POSIX
|
||||
|
||||
AC_C_CONST
|
||||
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h limits.h string.h unistd.h utime.h varargs.h)
|
||||
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_SIGNAL
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
dnl Some systems have utime.h but don't declare the struct anywhere.
|
||||
AC_MSG_CHECKING(for struct utimbuf)
|
||||
AC_CACHE_VAL(patch_cv_sys_struct_utimbuf,
|
||||
[AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#if HAVE_UTIME_H
|
||||
#include <utime.h>
|
||||
#endif], [static struct utimbuf x; x.actime = x.modtime;],
|
||||
patch_cv_sys_struct_utimbuf=yes,
|
||||
patch_cv_sys_struct_utimbuf=no)])
|
||||
AC_MSG_RESULT($patch_cv_sys_struct_utimbuf)
|
||||
if test $patch_cv_sys_struct_utimbuf = yes; then
|
||||
AC_DEFINE(HAVE_STRUCT_UTIMBUF)
|
||||
fi
|
||||
|
||||
# Check for NetBSD 1.0 bug, where memchr(..., 0) returns nonzero.
|
||||
AC_MSG_CHECKING(for working memchr)
|
||||
AC_CACHE_VAL(ac_cv_func_memchr,
|
||||
[AC_TRY_RUN([#include <string.h>
|
||||
main () { exit (memchr ("", 0, 0) != 0 || memchr ("", 1, 0) != 0); }],
|
||||
ac_cv_func_memchr=yes,
|
||||
ac_cv_func_memchr=no,
|
||||
AC_MSG_WARN([We are cross-compiling so we assume memchr does not work.])
|
||||
ac_cv_func_memchr=no)])dnl
|
||||
AC_MSG_RESULT($ac_cv_func_memchr)
|
||||
if test $ac_cv_func_memchr = yes; then
|
||||
AC_DEFINE(HAVE_MEMCHR)
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNC(getopt_long, , [LIBOBJS="$LIBOBJS getopt1.o getopt.o"])
|
||||
AC_SUBST(LIBOBJS)
|
||||
AC_CHECK_FUNCS(_doprintf isascii memcmp mkdir mktemp pathconf raise sigaction sigprocmask sigsetmask)
|
||||
AC_REPLACE_FUNCS(memchr rename)
|
||||
AC_FUNC_CLOSEDIR_VOID
|
||||
AC_FUNC_VPRINTF
|
||||
|
||||
AC_SYS_LONG_FILE_NAMES
|
||||
|
||||
AC_MSG_CHECKING([for d_ino member in directory struct])
|
||||
AC_CACHE_VAL(patch_cv_sys_d_ino_in_dirent,
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
#else
|
||||
# define dirent direct
|
||||
# if HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# ifdef HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# ifdef HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif
|
||||
],
|
||||
[struct dirent dp; dp.d_ino = 0;],
|
||||
patch_cv_sys_d_ino_in_dirent=yes,
|
||||
patch_cv_sys_d_ino_in_dirent=no)])
|
||||
AC_MSG_RESULT($patch_cv_sys_d_ino_in_dirent)
|
||||
if test $patch_cv_sys_d_ino_in_dirent = yes; then
|
||||
AC_DEFINE(D_INO_IN_DIRENT)
|
||||
fi
|
||||
|
||||
AC_OUTPUT(Makefile)
|
File diff suppressed because it is too large
Load Diff
@ -1,133 +0,0 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
#if defined (__STDC__) && __STDC__
|
||||
const char *name;
|
||||
#else
|
||||
char *name;
|
||||
#endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#ifdef __GNU_LIBRARY__
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
#else /* not __GNU_LIBRARY__ */
|
||||
extern int getopt ();
|
||||
#endif /* __GNU_LIBRARY__ */
|
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
extern int getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
#else /* not __STDC__ */
|
||||
extern int getopt ();
|
||||
extern int getopt_long ();
|
||||
extern int getopt_long_only ();
|
||||
|
||||
extern int _getopt_internal ();
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GETOPT_H */
|
@ -1,189 +0,0 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#if !defined (__STDC__) || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#define GETOPT_INTERFACE_VERSION 2
|
||||
#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* Not ELIDE_CODE. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
@ -1,462 +0,0 @@
|
||||
/* inputting files to be patched */
|
||||
|
||||
/* $Id: inp.c,v 1.18 1997/07/21 17:59:46 eggert Exp $ */
|
||||
|
||||
/*
|
||||
Copyright 1986, 1988 Larry Wall
|
||||
Copyright 1991, 1992, 1993, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define XTERN extern
|
||||
#include <common.h>
|
||||
#include <backupfile.h>
|
||||
#include <pch.h>
|
||||
#include <util.h>
|
||||
#undef XTERN
|
||||
#define XTERN
|
||||
#include <inp.h>
|
||||
|
||||
/* Input-file-with-indexable-lines abstract type */
|
||||
|
||||
static char *i_buffer; /* plan A buffer */
|
||||
static char const **i_ptr; /* pointers to lines in plan A buffer */
|
||||
|
||||
static size_t tibufsize; /* size of plan b buffers */
|
||||
#ifndef TIBUFSIZE_MINIMUM
|
||||
#define TIBUFSIZE_MINIMUM (8 * 1024) /* minimum value for tibufsize */
|
||||
#endif
|
||||
static int tifd = -1; /* plan b virtual string array */
|
||||
static char *tibuf[2]; /* plan b buffers */
|
||||
static LINENUM tiline[2] = {-1, -1}; /* 1st line in each buffer */
|
||||
static LINENUM lines_per_buf; /* how many lines per buffer */
|
||||
static size_t tireclen; /* length of records in tmp file */
|
||||
static size_t last_line_size; /* size of last input line */
|
||||
|
||||
static bool plan_a PARAMS ((char const *));/* yield FALSE if memory runs out */
|
||||
static void plan_b PARAMS ((char const *));
|
||||
static void report_revision PARAMS ((int));
|
||||
static void too_many_lines PARAMS ((char const *)) __attribute__((noreturn));
|
||||
|
||||
/* New patch--prepare to edit another file. */
|
||||
|
||||
void
|
||||
re_input()
|
||||
{
|
||||
if (using_plan_a) {
|
||||
free (i_buffer);
|
||||
free (i_ptr);
|
||||
}
|
||||
else {
|
||||
close (tifd);
|
||||
tifd = -1;
|
||||
free(tibuf[0]);
|
||||
tibuf[0] = 0;
|
||||
tiline[0] = tiline[1] = -1;
|
||||
tireclen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Construct the line index, somehow or other. */
|
||||
|
||||
void
|
||||
scan_input(filename)
|
||||
char *filename;
|
||||
{
|
||||
using_plan_a = ! (debug & 16) && plan_a (filename);
|
||||
if (!using_plan_a)
|
||||
plan_b(filename);
|
||||
switch (verbosity)
|
||||
{
|
||||
case SILENT:
|
||||
break;
|
||||
|
||||
case VERBOSE:
|
||||
say ("Patching file `%s' using Plan %s...\n",
|
||||
filename, using_plan_a ? "A" : "B");
|
||||
break;
|
||||
|
||||
case DEFAULT_VERBOSITY:
|
||||
say ("patching file `%s'\n", filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Report whether a desired revision was found. */
|
||||
|
||||
static void
|
||||
report_revision (found_revision)
|
||||
int found_revision;
|
||||
{
|
||||
if (found_revision)
|
||||
{
|
||||
if (verbosity == VERBOSE)
|
||||
say ("Good. This file appears to be the %s version.\n", revision);
|
||||
}
|
||||
else if (force)
|
||||
{
|
||||
if (verbosity != SILENT)
|
||||
say ("Warning: this file doesn't appear to be the %s version -- patching anyway.\n",
|
||||
revision);
|
||||
}
|
||||
else if (batch)
|
||||
{
|
||||
fatal ("This file doesn't appear to be the %s version -- aborting.",
|
||||
revision);
|
||||
}
|
||||
else
|
||||
{
|
||||
ask ("This file doesn't appear to be the %s version -- patch anyway? [n] ",
|
||||
revision);
|
||||
if (*buf != 'y')
|
||||
fatal ("aborted");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
too_many_lines (filename)
|
||||
char const *filename;
|
||||
{
|
||||
fatal ("File `%s' has too many lines.", filename);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
get_input_file (filename, outname)
|
||||
char const *filename;
|
||||
char const *outname;
|
||||
{
|
||||
int elsewhere = strcmp (filename, outname);
|
||||
char const *cs;
|
||||
char *diffbuf;
|
||||
char *getbuf;
|
||||
|
||||
if (inerrno == -1)
|
||||
inerrno = stat (inname, &instat) == 0 ? 0 : errno;
|
||||
|
||||
/* Perhaps look for RCS or SCCS versions. */
|
||||
if (patch_get
|
||||
&& invc != 0
|
||||
&& (inerrno
|
||||
|| (! elsewhere
|
||||
&& (/* No one can write to it. */
|
||||
(instat.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) == 0
|
||||
/* Only the owner (who's not me) can write to it. */
|
||||
|| ((instat.st_mode & (S_IWGRP|S_IWOTH)) == 0
|
||||
&& instat.st_uid != geteuid ()))))
|
||||
&& (invc = !! (cs = (version_controller
|
||||
(filename, elsewhere,
|
||||
inerrno ? (struct stat *) 0 : &instat,
|
||||
&getbuf, &diffbuf))))) {
|
||||
|
||||
if (!inerrno) {
|
||||
if (!elsewhere
|
||||
&& (instat.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) != 0)
|
||||
/* Somebody can write to it. */
|
||||
fatal ("file `%s' seems to be locked by somebody else under %s",
|
||||
filename, cs);
|
||||
/* It might be checked out unlocked. See if it's safe to
|
||||
check out the default version locked. */
|
||||
if (verbosity == VERBOSE)
|
||||
say ("Comparing file `%s' to default %s version...\n",
|
||||
filename, cs);
|
||||
if (systemic (diffbuf) != 0)
|
||||
{
|
||||
say ("warning: patching file `%s', which does not match default %s version\n",
|
||||
filename, cs);
|
||||
cs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (cs && version_get (filename, cs, ! inerrno, elsewhere, getbuf,
|
||||
&instat))
|
||||
inerrno = 0;
|
||||
|
||||
free (getbuf);
|
||||
free (diffbuf);
|
||||
|
||||
} else if (inerrno && !pch_says_nonexistent (reverse))
|
||||
{
|
||||
errno = inerrno;
|
||||
pfatal ("can't find file `%s'", filename);
|
||||
}
|
||||
|
||||
if (inerrno)
|
||||
{
|
||||
instat.st_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
|
||||
instat.st_size = 0;
|
||||
}
|
||||
else if (! S_ISREG (instat.st_mode))
|
||||
fatal ("`%s' is not a regular file -- can't patch", filename);
|
||||
}
|
||||
|
||||
|
||||
/* Try keeping everything in memory. */
|
||||
|
||||
static bool
|
||||
plan_a(filename)
|
||||
char const *filename;
|
||||
{
|
||||
register char const *s;
|
||||
register char const *lim;
|
||||
register char const **ptr;
|
||||
register char *buffer;
|
||||
register LINENUM iline;
|
||||
size_t size = instat.st_size;
|
||||
|
||||
/* Fail if the file size doesn't fit in a size_t,
|
||||
or if storage isn't available. */
|
||||
if (! (size == instat.st_size
|
||||
&& (buffer = malloc (size ? size : (size_t) 1))))
|
||||
return FALSE;
|
||||
|
||||
/* Read the input file, but don't bother reading it if it's empty.
|
||||
When creating files, the files do not actually exist. */
|
||||
if (size)
|
||||
{
|
||||
int ifd = open (filename, O_RDONLY|binary_transput);
|
||||
size_t buffered = 0, n;
|
||||
if (ifd < 0)
|
||||
pfatal ("can't open file `%s'", filename);
|
||||
|
||||
while (size - buffered != 0)
|
||||
{
|
||||
n = read (ifd, buffer + buffered, size - buffered);
|
||||
if (n == 0)
|
||||
{
|
||||
/* Some non-POSIX hosts exaggerate st_size in text mode;
|
||||
or the file may have shrunk! */
|
||||
size = buffered;
|
||||
break;
|
||||
}
|
||||
if (n == (size_t) -1)
|
||||
{
|
||||
/* Perhaps size is too large for this host. */
|
||||
close (ifd);
|
||||
free (buffer);
|
||||
return FALSE;
|
||||
}
|
||||
buffered += n;
|
||||
}
|
||||
|
||||
if (close (ifd) != 0)
|
||||
read_fatal ();
|
||||
}
|
||||
|
||||
/* Scan the buffer and build array of pointers to lines. */
|
||||
lim = buffer + size;
|
||||
iline = 3; /* 1 unused, 1 for SOF, 1 for EOF if last line is incomplete */
|
||||
for (s = buffer; (s = (char *) memchr (s, '\n', lim - s)); s++)
|
||||
if (++iline < 0)
|
||||
too_many_lines (filename);
|
||||
if (! (iline == (size_t) iline
|
||||
&& (size_t) iline * sizeof *ptr / sizeof *ptr == (size_t) iline
|
||||
&& (ptr = (char const **) malloc ((size_t) iline * sizeof *ptr))))
|
||||
{
|
||||
free (buffer);
|
||||
return FALSE;
|
||||
}
|
||||
iline = 0;
|
||||
for (s = buffer; ; s++)
|
||||
{
|
||||
ptr[++iline] = s;
|
||||
if (! (s = (char *) memchr (s, '\n', lim - s)))
|
||||
break;
|
||||
}
|
||||
if (size && lim[-1] != '\n')
|
||||
ptr[++iline] = lim;
|
||||
input_lines = iline - 1;
|
||||
|
||||
if (revision)
|
||||
{
|
||||
char const *rev = revision;
|
||||
int rev0 = rev[0];
|
||||
int found_revision = 0;
|
||||
size_t revlen = strlen (rev);
|
||||
|
||||
if (revlen <= size)
|
||||
{
|
||||
char const *limrev = lim - revlen;
|
||||
|
||||
for (s = buffer; (s = (char *) memchr (s, rev0, limrev - s)); s++)
|
||||
if (memcmp (s, rev, revlen) == 0
|
||||
&& (s == buffer || ISSPACE ((unsigned char) s[-1]))
|
||||
&& (s + 1 == limrev || ISSPACE ((unsigned char) s[revlen])))
|
||||
{
|
||||
found_revision = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
report_revision (found_revision);
|
||||
}
|
||||
|
||||
/* Plan A will work. */
|
||||
i_buffer = buffer;
|
||||
i_ptr = ptr;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Keep (virtually) nothing in memory. */
|
||||
|
||||
static void
|
||||
plan_b(filename)
|
||||
char const *filename;
|
||||
{
|
||||
register FILE *ifp;
|
||||
register int c;
|
||||
register size_t len;
|
||||
register size_t maxlen;
|
||||
register int found_revision;
|
||||
register size_t i;
|
||||
register char const *rev;
|
||||
register size_t revlen;
|
||||
register LINENUM line = 1;
|
||||
|
||||
if (instat.st_size == 0)
|
||||
filename = NULL_DEVICE;
|
||||
if (! (ifp = fopen (filename, binary_transput ? "rb" : "r")))
|
||||
pfatal ("can't open file `%s'", filename);
|
||||
tifd = create_file (TMPINNAME, O_RDWR | O_BINARY, (mode_t) 0);
|
||||
i = 0;
|
||||
len = 0;
|
||||
maxlen = 1;
|
||||
rev = revision;
|
||||
found_revision = !rev;
|
||||
revlen = rev ? strlen (rev) : 0;
|
||||
|
||||
while ((c = getc (ifp)) != EOF)
|
||||
{
|
||||
len++;
|
||||
|
||||
if (c == '\n')
|
||||
{
|
||||
if (++line < 0)
|
||||
too_many_lines (filename);
|
||||
if (maxlen < len)
|
||||
maxlen = len;
|
||||
len = 0;
|
||||
}
|
||||
|
||||
if (!found_revision)
|
||||
{
|
||||
if (i == revlen)
|
||||
{
|
||||
found_revision = ISSPACE ((unsigned char) c);
|
||||
i = (size_t) -1;
|
||||
}
|
||||
else if (i != (size_t) -1)
|
||||
i = rev[i]==c ? i + 1 : (size_t) -1;
|
||||
|
||||
if (i == (size_t) -1 && ISSPACE ((unsigned char) c))
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (revision)
|
||||
report_revision (found_revision);
|
||||
Fseek (ifp, (off_t) 0, SEEK_SET); /* rewind file */
|
||||
for (tibufsize = TIBUFSIZE_MINIMUM; tibufsize < maxlen; tibufsize <<= 1)
|
||||
continue;
|
||||
lines_per_buf = tibufsize / maxlen;
|
||||
tireclen = maxlen;
|
||||
tibuf[0] = xmalloc (2 * tibufsize);
|
||||
tibuf[1] = tibuf[0] + tibufsize;
|
||||
|
||||
for (line = 1; ; line++)
|
||||
{
|
||||
char *p = tibuf[0] + maxlen * (line % lines_per_buf);
|
||||
char const *p0 = p;
|
||||
if (! (line % lines_per_buf)) /* new block */
|
||||
if (write (tifd, tibuf[0], tibufsize) != tibufsize)
|
||||
write_fatal ();
|
||||
if ((c = getc (ifp)) == EOF)
|
||||
break;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
*p++ = c;
|
||||
if (c == '\n')
|
||||
{
|
||||
last_line_size = p - p0;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((c = getc (ifp)) == EOF)
|
||||
{
|
||||
last_line_size = p - p0;
|
||||
line++;
|
||||
goto EOF_reached;
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF_reached:
|
||||
if (ferror (ifp) || fclose (ifp) != 0)
|
||||
read_fatal ();
|
||||
|
||||
if (line % lines_per_buf != 0)
|
||||
if (write (tifd, tibuf[0], tibufsize) != tibufsize)
|
||||
write_fatal ();
|
||||
input_lines = line - 1;
|
||||
}
|
||||
|
||||
/* Fetch a line from the input file. */
|
||||
|
||||
char const *
|
||||
ifetch (line, whichbuf, psize)
|
||||
register LINENUM line;
|
||||
int whichbuf; /* ignored when file in memory */
|
||||
size_t *psize;
|
||||
{
|
||||
register char const *q;
|
||||
register char const *p;
|
||||
|
||||
if (line < 1 || line > input_lines) {
|
||||
*psize = 0;
|
||||
return "";
|
||||
}
|
||||
if (using_plan_a) {
|
||||
p = i_ptr[line];
|
||||
*psize = i_ptr[line + 1] - p;
|
||||
return p;
|
||||
} else {
|
||||
LINENUM offline = line % lines_per_buf;
|
||||
LINENUM baseline = line - offline;
|
||||
|
||||
if (tiline[0] == baseline)
|
||||
whichbuf = 0;
|
||||
else if (tiline[1] == baseline)
|
||||
whichbuf = 1;
|
||||
else {
|
||||
tiline[whichbuf] = baseline;
|
||||
if (lseek (tifd, (off_t) (baseline/lines_per_buf * tibufsize),
|
||||
SEEK_SET) == -1
|
||||
|| read (tifd, tibuf[whichbuf], tibufsize) < 0)
|
||||
read_fatal ();
|
||||
}
|
||||
p = tibuf[whichbuf] + (tireclen*offline);
|
||||
if (line == input_lines)
|
||||
*psize = last_line_size;
|
||||
else {
|
||||
for (q = p; *q++ != '\n'; )
|
||||
continue;
|
||||
*psize = q - p;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
/* inputting files to be patched */
|
||||
|
||||
/* $Id: inp.h,v 1.4 1997/04/07 01:07:00 eggert Exp $ */
|
||||
|
||||
XTERN LINENUM input_lines; /* how long is input file in lines */
|
||||
|
||||
char const *ifetch PARAMS ((LINENUM, int, size_t *));
|
||||
void get_input_file PARAMS ((char const *, char const *));
|
||||
void re_input PARAMS ((void));
|
||||
void scan_input PARAMS ((char *));
|
@ -1,250 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# 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 $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
@ -1,391 +0,0 @@
|
||||
/* Convert struct partime into time_t. */
|
||||
|
||||
/* Copyright 1992, 1993, 1994, 1995, 1997 Paul Eggert
|
||||
Distributed under license by the Free Software Foundation, Inc.
|
||||
|
||||
This file is part of RCS.
|
||||
|
||||
RCS 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.
|
||||
|
||||
RCS 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 RCS; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
rcs-bugs@cs.purdue.edu
|
||||
|
||||
*/
|
||||
|
||||
#if has_conf_h
|
||||
# include <conf.h>
|
||||
#else
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# else
|
||||
# ifndef __STDC__
|
||||
# define const
|
||||
# endif
|
||||
# endif
|
||||
/* MIPS RISCOS4.52 defines time_t in <sys/types.h> not <time.h>. */
|
||||
# include <sys/types.h>
|
||||
# if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
# endif
|
||||
# ifndef LONG_MIN
|
||||
# define LONG_MIN (-1-2147483647L)
|
||||
# endif
|
||||
# if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# endif
|
||||
# include <time.h>
|
||||
# ifdef __STDC__
|
||||
# define P(x) x
|
||||
# else
|
||||
# define P(x) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <partime.h>
|
||||
#include <maketime.h>
|
||||
|
||||
char const maketId[] =
|
||||
"$Id: maketime.c,v 5.15 1997/06/17 16:54:36 eggert Exp $";
|
||||
|
||||
static int isleap P ((int));
|
||||
static int month_days P ((struct tm const *));
|
||||
static time_t maketime P ((struct partime const *, time_t));
|
||||
|
||||
/* For maximum portability, use only localtime and gmtime.
|
||||
Make no assumptions about the time_t epoch or the range of time_t values.
|
||||
Avoid mktime because it's not universal and because there's no easy,
|
||||
portable way for mktime to yield the inverse of gmtime. */
|
||||
|
||||
#define TM_YEAR_ORIGIN 1900
|
||||
|
||||
static int
|
||||
isleap (y)
|
||||
int y;
|
||||
{
|
||||
return (y & 3) == 0 && (y % 100 != 0 || y % 400 == 0);
|
||||
}
|
||||
|
||||
/* days in year before start of months 0-12 */
|
||||
static int const month_yday[] =
|
||||
{
|
||||
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
|
||||
};
|
||||
|
||||
/* Yield the number of days in TM's month. */
|
||||
static int
|
||||
month_days (tm)
|
||||
struct tm const *tm;
|
||||
{
|
||||
int m = tm->tm_mon;
|
||||
return (month_yday[m + 1] - month_yday[m]
|
||||
+ (m == 1 && isleap (tm->tm_year + TM_YEAR_ORIGIN)));
|
||||
}
|
||||
|
||||
/* Convert UNIXTIME to struct tm form.
|
||||
Use gmtime if available and if !LOCALZONE, localtime otherwise. */
|
||||
struct tm *
|
||||
time2tm (unixtime, localzone)
|
||||
time_t unixtime;
|
||||
int localzone;
|
||||
{
|
||||
struct tm *tm;
|
||||
#ifdef TZ_is_unset
|
||||
static char const *TZ;
|
||||
if (!TZ && !(TZ = getenv ("TZ")))
|
||||
TZ_is_unset ("The TZ environment variable is not set; please set it to your timezone");
|
||||
#endif
|
||||
if (localzone || !(tm = gmtime (&unixtime)))
|
||||
tm = localtime (&unixtime);
|
||||
return tm;
|
||||
}
|
||||
|
||||
/* Yield A - B, measured in seconds. */
|
||||
time_t
|
||||
difftm (a, b)
|
||||
struct tm const *a;
|
||||
struct tm const *b;
|
||||
{
|
||||
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int ac = ay / 100 - (ay % 100 < 0);
|
||||
int bc = by / 100 - (by % 100 < 0);
|
||||
int difference_in_day_of_year = a->tm_yday - b->tm_yday;
|
||||
int intervening_leap_days = (((ay >> 2) - (by >> 2))
|
||||
- (ac - bc)
|
||||
+ ((ac >> 2) - (bc >> 2)));
|
||||
time_t difference_in_years = ay - by;
|
||||
time_t difference_in_days
|
||||
= (difference_in_years * 365
|
||||
+ (intervening_leap_days + difference_in_day_of_year));
|
||||
return (((((difference_in_days * 24
|
||||
+ (a->tm_hour - b->tm_hour))
|
||||
* 60)
|
||||
+ (a->tm_min - b->tm_min))
|
||||
* 60)
|
||||
+ (a->tm_sec - b->tm_sec));
|
||||
}
|
||||
|
||||
/*
|
||||
* Adjust time T by adding SECONDS. SECONDS must be at most 24 hours' worth.
|
||||
* Adjust only T's year, mon, mday, hour, min and sec members;
|
||||
* plus adjust wday if it is defined.
|
||||
*/
|
||||
void
|
||||
adjzone (t, seconds)
|
||||
register struct tm *t;
|
||||
long seconds;
|
||||
{
|
||||
/*
|
||||
* This code can be off by a second if SECONDS is not a multiple of 60,
|
||||
* if T is local time, and if a leap second happens during this minute.
|
||||
* But this bug has never occurred, and most likely will not ever occur.
|
||||
* Liberia, the last country for which SECONDS % 60 was nonzero,
|
||||
* switched to UTC in May 1972; the first leap second was in June 1972.
|
||||
*/
|
||||
int leap_second = t->tm_sec == 60;
|
||||
long sec = seconds + (t->tm_sec - leap_second);
|
||||
if (sec < 0)
|
||||
{
|
||||
if ((t->tm_min -= (59 - sec) / 60) < 0)
|
||||
{
|
||||
if ((t->tm_hour -= (59 - t->tm_min) / 60) < 0)
|
||||
{
|
||||
t->tm_hour += 24;
|
||||
if (TM_DEFINED (t->tm_wday) && --t->tm_wday < 0)
|
||||
t->tm_wday = 6;
|
||||
if (--t->tm_mday <= 0)
|
||||
{
|
||||
if (--t->tm_mon < 0)
|
||||
{
|
||||
--t->tm_year;
|
||||
t->tm_mon = 11;
|
||||
}
|
||||
t->tm_mday = month_days (t);
|
||||
}
|
||||
}
|
||||
t->tm_min += 24 * 60;
|
||||
}
|
||||
sec += 24L * 60 * 60;
|
||||
}
|
||||
else if (60 <= (t->tm_min += sec / 60))
|
||||
if (24 <= (t->tm_hour += t->tm_min / 60))
|
||||
{
|
||||
t->tm_hour -= 24;
|
||||
if (TM_DEFINED (t->tm_wday) && ++t->tm_wday == 7)
|
||||
t->tm_wday = 0;
|
||||
if (month_days (t) < ++t->tm_mday)
|
||||
{
|
||||
if (11 < ++t->tm_mon)
|
||||
{
|
||||
++t->tm_year;
|
||||
t->tm_mon = 0;
|
||||
}
|
||||
t->tm_mday = 1;
|
||||
}
|
||||
}
|
||||
t->tm_min %= 60;
|
||||
t->tm_sec = (int) (sec % 60) + leap_second;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert TM to time_t, using localtime if LOCALZONE and gmtime otherwise.
|
||||
* Use only TM's year, mon, mday, hour, min, and sec members.
|
||||
* Ignore TM's old tm_yday and tm_wday, but fill in their correct values.
|
||||
* Yield -1 on failure (e.g. a member out of range).
|
||||
* Posix 1003.1-1990 doesn't allow leap seconds, but some implementations
|
||||
* have them anyway, so allow them if localtime/gmtime does.
|
||||
*/
|
||||
time_t
|
||||
tm2time (tm, localzone)
|
||||
struct tm *tm;
|
||||
int localzone;
|
||||
{
|
||||
/* Cache the most recent t,tm pairs; 1 for gmtime, 1 for localtime. */
|
||||
static time_t t_cache[2];
|
||||
static struct tm tm_cache[2];
|
||||
|
||||
time_t d, gt;
|
||||
struct tm const *gtm;
|
||||
/*
|
||||
* The maximum number of iterations should be enough to handle any
|
||||
* combinations of leap seconds, time zone rule changes, and solar time.
|
||||
* 4 is probably enough; we use a bigger number just to be safe.
|
||||
*/
|
||||
int remaining_tries = 8;
|
||||
|
||||
/* Avoid subscript errors. */
|
||||
if (12 <= (unsigned) tm->tm_mon)
|
||||
return -1;
|
||||
|
||||
tm->tm_yday = month_yday[tm->tm_mon] + tm->tm_mday
|
||||
- (tm->tm_mon < 2 || !isleap (tm->tm_year + TM_YEAR_ORIGIN));
|
||||
|
||||
/* Make a first guess. */
|
||||
gt = t_cache[localzone];
|
||||
gtm = gt ? &tm_cache[localzone] : time2tm (gt, localzone);
|
||||
|
||||
/* Repeatedly use the error from the guess to improve the guess. */
|
||||
while ((d = difftm (tm, gtm)) != 0)
|
||||
{
|
||||
if (--remaining_tries == 0)
|
||||
return -1;
|
||||
gt += d;
|
||||
gtm = time2tm (gt, localzone);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that the guess actually matches;
|
||||
* overflow can cause difftm to yield 0 even on differing times,
|
||||
* or tm may have members out of range (e.g. bad leap seconds).
|
||||
*/
|
||||
#define TM_DIFFER(a,b) \
|
||||
( \
|
||||
((a)->tm_year ^ (b)->tm_year) | \
|
||||
((a)->tm_mon ^ (b)->tm_mon) | \
|
||||
((a)->tm_mday ^ (b)->tm_mday) | \
|
||||
((a)->tm_hour ^ (b)->tm_hour) | \
|
||||
((a)->tm_min ^ (b)->tm_min) | \
|
||||
((a)->tm_sec ^ (b)->tm_sec) \
|
||||
)
|
||||
if (TM_DIFFER (tm, gtm))
|
||||
{
|
||||
/*
|
||||
* If gt is a leap second, try gt+1; if it is one greater than
|
||||
* a leap second, try gt-1; otherwise, it doesn't matter.
|
||||
* Leap seconds always fall at month end.
|
||||
*/
|
||||
int yd = tm->tm_year - gtm->tm_year;
|
||||
gt += yd + (yd ? 0 : tm->tm_mon - gtm->tm_mon);
|
||||
gtm = time2tm (gt, localzone);
|
||||
if (TM_DIFFER (tm, gtm))
|
||||
return -1;
|
||||
}
|
||||
t_cache[localzone] = gt;
|
||||
tm_cache[localzone] = *gtm;
|
||||
|
||||
tm->tm_wday = gtm->tm_wday;
|
||||
return gt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check *PT and convert it to time_t.
|
||||
* If it is incompletely specified, use DEFAULT_TIME to fill it out.
|
||||
* Use localtime if PT->zone is the special value TM_LOCAL_ZONE.
|
||||
* Yield -1 on failure.
|
||||
* ISO 8601 day-of-year and week numbers are not yet supported.
|
||||
*/
|
||||
static time_t
|
||||
maketime (pt, default_time)
|
||||
struct partime const *pt;
|
||||
time_t default_time;
|
||||
{
|
||||
int localzone, wday;
|
||||
struct tm tm;
|
||||
struct tm *tm0 = 0;
|
||||
time_t r;
|
||||
|
||||
tm0 = 0; /* Keep gcc -Wall happy. */
|
||||
localzone = pt->zone == TM_LOCAL_ZONE;
|
||||
|
||||
tm = pt->tm;
|
||||
|
||||
if (TM_DEFINED (pt->ymodulus) || !TM_DEFINED (tm.tm_year))
|
||||
{
|
||||
/* Get tm corresponding to default time. */
|
||||
tm0 = time2tm (default_time, localzone);
|
||||
if (!localzone)
|
||||
adjzone (tm0, pt->zone);
|
||||
}
|
||||
|
||||
if (TM_DEFINED (pt->ymodulus))
|
||||
tm.tm_year +=
|
||||
(tm0->tm_year + TM_YEAR_ORIGIN) / pt->ymodulus * pt->ymodulus;
|
||||
else if (!TM_DEFINED (tm.tm_year))
|
||||
{
|
||||
/* Set default year, month, day from current time. */
|
||||
tm.tm_year = tm0->tm_year + TM_YEAR_ORIGIN;
|
||||
if (!TM_DEFINED (tm.tm_mon))
|
||||
{
|
||||
tm.tm_mon = tm0->tm_mon;
|
||||
if (!TM_DEFINED (tm.tm_mday))
|
||||
tm.tm_mday = tm0->tm_mday;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert from partime year (Gregorian) to Posix year. */
|
||||
tm.tm_year -= TM_YEAR_ORIGIN;
|
||||
|
||||
/* Set remaining default fields to be their minimum values. */
|
||||
if (!TM_DEFINED (tm.tm_mon))
|
||||
tm.tm_mon = 0;
|
||||
if (!TM_DEFINED (tm.tm_mday))
|
||||
tm.tm_mday = 1;
|
||||
if (!TM_DEFINED (tm.tm_hour))
|
||||
tm.tm_hour = 0;
|
||||
if (!TM_DEFINED (tm.tm_min))
|
||||
tm.tm_min = 0;
|
||||
if (!TM_DEFINED (tm.tm_sec))
|
||||
tm.tm_sec = 0;
|
||||
|
||||
if (!localzone)
|
||||
adjzone (&tm, -pt->zone);
|
||||
wday = tm.tm_wday;
|
||||
|
||||
/* Convert and fill in the rest of the tm. */
|
||||
r = tm2time (&tm, localzone);
|
||||
|
||||
/* Check weekday. */
|
||||
if (r != -1 && TM_DEFINED (wday) && wday != tm.tm_wday)
|
||||
return -1;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Parse a free-format date in SOURCE, yielding a Unix format time. */
|
||||
time_t
|
||||
str2time (source, default_time, default_zone)
|
||||
char const *source;
|
||||
time_t default_time;
|
||||
long default_zone;
|
||||
{
|
||||
struct partime pt;
|
||||
|
||||
if (*partime (source, &pt))
|
||||
return -1;
|
||||
if (pt.zone == TM_UNDEFINED_ZONE)
|
||||
pt.zone = default_zone;
|
||||
return maketime (&pt, default_time);
|
||||
}
|
||||
|
||||
#if TEST
|
||||
#include <stdio.h>
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
time_t default_time = time ((time_t *) 0);
|
||||
long default_zone = argv[1] ? atol (argv[1]) : 0;
|
||||
char buf[1000];
|
||||
while (fgets (buf, sizeof (buf), stdin))
|
||||
{
|
||||
time_t t = str2time (buf, default_time, default_zone);
|
||||
printf ("%s", asctime (gmtime (&t)));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
@ -1,39 +0,0 @@
|
||||
/* Yield time_t from struct partime yielded by partime. */
|
||||
|
||||
/* Copyright 1993, 1994, 1995 Paul Eggert
|
||||
Distributed under license by the Free Software Foundation, Inc.
|
||||
|
||||
This file is part of RCS.
|
||||
|
||||
RCS 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.
|
||||
|
||||
RCS 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 RCS; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
rcs-bugs@cs.purdue.edu
|
||||
|
||||
*/
|
||||
|
||||
#if defined __STDC__ || has_prototypes
|
||||
# define __MAKETIME_P(x) x
|
||||
#else
|
||||
# define __MAKETIME_P(x) ()
|
||||
#endif
|
||||
|
||||
struct tm *time2tm __MAKETIME_P ((time_t, int));
|
||||
time_t difftm __MAKETIME_P ((struct tm const *, struct tm const *));
|
||||
time_t str2time __MAKETIME_P ((char const *, time_t, long));
|
||||
time_t tm2time __MAKETIME_P ((struct tm *, int));
|
||||
void adjzone __MAKETIME_P ((struct tm *, long));
|
@ -1,742 +0,0 @@
|
||||
/* Parse a string, yielding a struct partime that describes it. */
|
||||
|
||||
/* Copyright 1993, 1994, 1995, 1997 Paul Eggert
|
||||
Distributed under license by the Free Software Foundation, Inc.
|
||||
|
||||
This file is part of RCS.
|
||||
|
||||
RCS 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.
|
||||
|
||||
RCS 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 RCS; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
rcs-bugs@cs.purdue.edu
|
||||
|
||||
*/
|
||||
|
||||
#if has_conf_h
|
||||
# include <conf.h>
|
||||
#else
|
||||
# if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
# else
|
||||
# ifndef __STDC__
|
||||
# define const
|
||||
# endif
|
||||
# endif
|
||||
# if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
# endif
|
||||
# ifndef LONG_MIN
|
||||
# define LONG_MIN (-1-2147483647L)
|
||||
# endif
|
||||
# if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# endif
|
||||
# include <time.h>
|
||||
# ifdef __STDC__
|
||||
# define P(x) x
|
||||
# else
|
||||
# define P(x) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#if STDC_HEADERS
|
||||
# define CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177)
|
||||
#endif
|
||||
#define ISALNUM(c) (CTYPE_DOMAIN (c) && isalnum (c))
|
||||
#define ISALPHA(c) (CTYPE_DOMAIN (c) && isalpha (c))
|
||||
#define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c))
|
||||
#define ISUPPER(c) (CTYPE_DOMAIN (c) && isupper (c))
|
||||
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
|
||||
|
||||
#include <partime.h>
|
||||
|
||||
char const partimeId[] =
|
||||
"$Id: partime.c,v 5.16 1997/05/19 06:33:53 eggert Exp $";
|
||||
|
||||
|
||||
/* Lookup tables for names of months, weekdays, time zones. */
|
||||
|
||||
#define NAME_LENGTH_MAXIMUM 4
|
||||
|
||||
struct name_val
|
||||
{
|
||||
char name[NAME_LENGTH_MAXIMUM];
|
||||
int val;
|
||||
};
|
||||
|
||||
|
||||
static char const *parse_decimal P ((char const *, int, int, int, int, int *, int *));
|
||||
static char const *parse_fixed P ((char const *, int, int *));
|
||||
static char const *parse_pattern_letter P ((char const *, int, struct partime *));
|
||||
static char const *parse_prefix P ((char const *, struct partime *, int *));
|
||||
static char const *parse_ranged P ((char const *, int, int, int, int *));
|
||||
static int lookup P ((char const *, struct name_val const[]));
|
||||
static int merge_partime P ((struct partime *, struct partime const *));
|
||||
static void undefine P ((struct partime *));
|
||||
|
||||
|
||||
static struct name_val const month_names[] =
|
||||
{
|
||||
{"jan", 0},
|
||||
{"feb", 1},
|
||||
{"mar", 2},
|
||||
{"apr", 3},
|
||||
{"may", 4},
|
||||
{"jun", 5},
|
||||
{"jul", 6},
|
||||
{"aug", 7},
|
||||
{"sep", 8},
|
||||
{"oct", 9},
|
||||
{"nov", 10},
|
||||
{"dec", 11},
|
||||
{"", TM_UNDEFINED}
|
||||
};
|
||||
|
||||
static struct name_val const weekday_names[] =
|
||||
{
|
||||
{"sun", 0},
|
||||
{"mon", 1},
|
||||
{"tue", 2},
|
||||
{"wed", 3},
|
||||
{"thu", 4},
|
||||
{"fri", 5},
|
||||
{"sat", 6},
|
||||
{"", TM_UNDEFINED}
|
||||
};
|
||||
|
||||
#define hr60nonnegative(t) ((t)/100 * 60 + (t)%100)
|
||||
#define hr60(t) ((t)<0 ? -hr60nonnegative(-(t)) : hr60nonnegative(t))
|
||||
#define zs(t,s) {s, hr60(t)}
|
||||
#define zd(t,s,d) zs(t, s), zs((t)+100, d)
|
||||
|
||||
static struct name_val const zone_names[] =
|
||||
{
|
||||
zs (-1000, "hst"), /* Hawaii */
|
||||
zd (-1000, "hast", "hadt"), /* Hawaii-Aleutian */
|
||||
zd (- 900, "akst", "akdt"), /* Alaska */
|
||||
zd (- 800, "pst" , "pdt" ), /* Pacific */
|
||||
zd (- 700, "mst" , "mdt" ), /* Mountain */
|
||||
zd (- 600, "cst" , "cdt" ), /* Central */
|
||||
zd (- 500, "est" , "edt" ), /* Eastern */
|
||||
zd (- 400, "ast" , "adt" ), /* Atlantic */
|
||||
zd (- 330, "nst" , "ndt" ), /* Newfoundland */
|
||||
zs ( 000, "utc" ), /* Coordinated Universal */
|
||||
zs ( 000, "uct" ), /* " */
|
||||
zs ( 000, "cut" ), /* " */
|
||||
zs ( 000, "ut"), /* Universal */
|
||||
zs ( 000, "z"), /* Zulu (required by ISO 8601) */
|
||||
zd ( 000, "gmt" , "bst" ), /* Greenwich Mean, British Summer */
|
||||
zd ( 000, "wet" , "west"), /* Western European */
|
||||
zd ( 100, "cet" , "cest"), /* Central European */
|
||||
zd ( 100, "met" , "mest"), /* Middle European (bug in old tz versions) */
|
||||
zd ( 100, "mez" , "mesz"), /* Mittel-Europaeische Zeit */
|
||||
zd ( 200, "eet" , "eest"), /* Eastern European */
|
||||
zs ( 530, "ist" ), /* India */
|
||||
zd ( 900, "jst" , "jdt" ), /* Japan */
|
||||
zd ( 900, "kst" , "kdt" ), /* Korea */
|
||||
zd ( 1200, "nzst", "nzdt"), /* New Zealand */
|
||||
{"lt", 1},
|
||||
#if 0
|
||||
/* The following names are duplicates or are not well attested.
|
||||
There are lots more where these came from. */
|
||||
zs (-1100, "sst" ), /* Samoan */
|
||||
zd (- 900, "yst" , "ydt" ), /* Yukon - name is no longer used */
|
||||
zd (- 500, "ast" , "adt" ), /* Acre */
|
||||
zd (- 400, "wst" , "wdt" ), /* Western Brazil */
|
||||
zd (- 400, "cst" , "cdt" ), /* Chile */
|
||||
zd (- 200, "fst" , "fdt" ), /* Fernando de Noronha */
|
||||
zs ( 000, "wat" ), /* West African */
|
||||
zs ( 100, "cat" ), /* Central African */
|
||||
zs ( 200, "sat" ), /* South African */
|
||||
zd ( 200, "ist" , "idt" ), /* Israel */
|
||||
zs ( 300, "eat" ), /* East African */
|
||||
zd ( 300, "msk" , "msd" ), /* Moscow */
|
||||
zd ( 330, "ist" , "idt" ), /* Iran */
|
||||
zs ( 800, "hkt" ), /* Hong Kong */
|
||||
zs ( 800, "sgt" ), /* Singapore */
|
||||
zd ( 800, "cst" , "cdt" ), /* China */
|
||||
zd ( 800, "wst" , "wst" ), /* Western Australia */
|
||||
zd ( 930, "cst" , "cst" ), /* Central Australia */
|
||||
zs ( 1000, "gst" ), /* Guam */
|
||||
zd ( 1000, "est" , "est" ), /* Eastern Australia */
|
||||
#endif
|
||||
{"", -1}
|
||||
};
|
||||
|
||||
/* Look for a prefix of S in TABLE, returning val for first matching entry. */
|
||||
static int
|
||||
lookup (s, table)
|
||||
char const *s;
|
||||
struct name_val const table[];
|
||||
{
|
||||
int j;
|
||||
char buf[NAME_LENGTH_MAXIMUM];
|
||||
|
||||
for (j = 0; j < NAME_LENGTH_MAXIMUM; j++)
|
||||
{
|
||||
unsigned char c = *s++;
|
||||
if (! ISALPHA (c))
|
||||
{
|
||||
buf[j] = '\0';
|
||||
break;
|
||||
}
|
||||
buf[j] = ISUPPER (c) ? tolower (c) : c;
|
||||
}
|
||||
|
||||
for (;; table++)
|
||||
for (j = 0; ; j++)
|
||||
if (j == NAME_LENGTH_MAXIMUM || ! table[0].name[j])
|
||||
return table[0].val;
|
||||
else if (buf[j] != table[0].name[j])
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Set *T to ``undefined'' values. */
|
||||
static void
|
||||
undefine (t)
|
||||
struct partime *t;
|
||||
{
|
||||
t->tm.tm_sec = t->tm.tm_min = t->tm.tm_hour = t->tm.tm_mday = t->tm.tm_mon
|
||||
= t->tm.tm_year = t->tm.tm_wday = t->tm.tm_yday
|
||||
= t->ymodulus = t->yweek
|
||||
= TM_UNDEFINED;
|
||||
t->zone = TM_UNDEFINED_ZONE;
|
||||
}
|
||||
|
||||
/* Array of patterns to look for in a date string.
|
||||
Order is important: we look for the first matching pattern
|
||||
whose values do not contradict values that we already know about.
|
||||
See `parse_pattern_letter' below for the meaning of the pattern codes. */
|
||||
static char const *const patterns[] =
|
||||
{
|
||||
/* These traditional patterns must come first,
|
||||
to prevent an ISO 8601 format from misinterpreting their prefixes. */
|
||||
"E_n_y", "x", /* RFC 822 */
|
||||
"E_n", "n_E", "n", "t:m:s_A", "t:m_A", "t_A", /* traditional */
|
||||
"y/N/D$", /* traditional RCS */
|
||||
|
||||
/* ISO 8601:1988 formats, generalized a bit. */
|
||||
"y-N-D$", "4ND$", "Y-N$",
|
||||
"RND$", "-R=N$", "-R$", "--N=D$", "N=DT",
|
||||
"--N$", "---D$", "DT",
|
||||
"Y-d$", "4d$", "R=d$", "-d$", "dT",
|
||||
"y-W-X", "yWX", "y=W",
|
||||
"-r-W-X", "r-W-XT", "-rWX", "rWXT", "-W=X", "W=XT", "-W",
|
||||
"-w-X", "w-XT", "---X$", "XT", "4$",
|
||||
"T",
|
||||
"h:m:s$", "hms$", "h:m$", "hm$", "h$", "-m:s$", "-ms$", "-m$", "--s$",
|
||||
"Y", "Z",
|
||||
|
||||
0
|
||||
};
|
||||
|
||||
/* Parse an initial prefix of STR, setting *T accordingly.
|
||||
Return the first character after the prefix, or 0 if it couldn't be parsed.
|
||||
Start with pattern *PI; if success, set *PI to the next pattern to try.
|
||||
Set *PI to -1 if we know there are no more patterns to try;
|
||||
if *PI is initially negative, give up immediately. */
|
||||
static char const *
|
||||
parse_prefix (str, t, pi)
|
||||
char const *str;
|
||||
struct partime *t;
|
||||
int *pi;
|
||||
{
|
||||
int i = *pi;
|
||||
char const *pat;
|
||||
unsigned char c;
|
||||
|
||||
if (i < 0)
|
||||
return 0;
|
||||
|
||||
/* Remove initial noise. */
|
||||
while (! ISALNUM (c = *str) && c != '-' && c != '+')
|
||||
{
|
||||
if (! c)
|
||||
{
|
||||
undefine (t);
|
||||
*pi = -1;
|
||||
return str;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
|
||||
/* Try a pattern until one succeeds. */
|
||||
while ((pat = patterns[i++]) != 0)
|
||||
{
|
||||
char const *s = str;
|
||||
undefine (t);
|
||||
do
|
||||
{
|
||||
if (! (c = *pat++))
|
||||
{
|
||||
*pi = i;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
while ((s = parse_pattern_letter (s, c, t)) != 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Parse an initial prefix of S of length DIGITS; it must be a number.
|
||||
Store the parsed number into *RES.
|
||||
Return the first character after the prefix, or 0 if it wasn't parsed. */
|
||||
static char const *
|
||||
parse_fixed (s, digits, res)
|
||||
char const *s;
|
||||
int digits, *res;
|
||||
{
|
||||
int n = 0;
|
||||
char const *lim = s + digits;
|
||||
while (s < lim)
|
||||
{
|
||||
unsigned d = *s++ - '0';
|
||||
if (9 < d)
|
||||
return 0;
|
||||
n = 10 * n + d;
|
||||
}
|
||||
*res = n;
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Parse an initial prefix of S of length DIGITS;
|
||||
it must be a number in the range LO through HI.
|
||||
Store the parsed number into *RES.
|
||||
Return the first character after the prefix, or 0 if it wasn't parsed. */
|
||||
static char const *
|
||||
parse_ranged (s, digits, lo, hi, res)
|
||||
char const *s;
|
||||
int digits, lo, hi, *res;
|
||||
{
|
||||
s = parse_fixed (s, digits, res);
|
||||
return s && lo <= *res && *res <= hi ? s : 0;
|
||||
}
|
||||
|
||||
/* Parse an initial prefix of S of length DIGITS;
|
||||
it must be a number in the range LO through HI
|
||||
and it may be followed by a fraction to be computed using RESOLUTION.
|
||||
Store the parsed number into *RES; store the fraction times RESOLUTION,
|
||||
rounded to the nearest integer, into *FRES.
|
||||
Return the first character after the prefix, or 0 if it wasn't parsed. */
|
||||
static char const *
|
||||
parse_decimal (s, digits, lo, hi, resolution, res, fres)
|
||||
char const *s;
|
||||
int digits, lo, hi, resolution, *res, *fres;
|
||||
{
|
||||
s = parse_fixed (s, digits, res);
|
||||
if (s && lo <= *res && *res <= hi)
|
||||
{
|
||||
int f = 0;
|
||||
if ((s[0] == ',' || s[0] == '.') && ISDIGIT (s[1]))
|
||||
{
|
||||
char const *s1 = ++s;
|
||||
int num10 = 0, denom10 = 10, product;
|
||||
while (ISDIGIT (*++s))
|
||||
{
|
||||
int d = denom10 * 10;
|
||||
if (d / 10 != denom10)
|
||||
return 0; /* overflow */
|
||||
denom10 = d;
|
||||
}
|
||||
s = parse_fixed (s1, (int) (s - s1), &num10);
|
||||
product = num10 * resolution;
|
||||
f = (product + (denom10 >> 1)) / denom10;
|
||||
f -= f & (product % denom10 == denom10 >> 1); /* round to even */
|
||||
if (f < 0 || product/resolution != num10)
|
||||
return 0; /* overflow */
|
||||
}
|
||||
*fres = f;
|
||||
return s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Parse an initial prefix of S; it must denote a time zone.
|
||||
Set *ZONE to the number of seconds east of GMT,
|
||||
or to TM_LOCAL_ZONE if it is the local time zone.
|
||||
Return the first character after the prefix, or 0 if it wasn't parsed. */
|
||||
char *
|
||||
parzone (s, zone)
|
||||
char const *s;
|
||||
long *zone;
|
||||
{
|
||||
char sign;
|
||||
int hh, mm, ss;
|
||||
int minutesEastOfUTC;
|
||||
long offset, z;
|
||||
|
||||
/* The formats are LT, n, n DST, nDST, no, o
|
||||
where n is a time zone name
|
||||
and o is a time zone offset of the form [-+]hh[:mm[:ss]]. */
|
||||
switch (*s)
|
||||
{
|
||||
case '-':
|
||||
case '+':
|
||||
z = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
minutesEastOfUTC = lookup (s, zone_names);
|
||||
if (minutesEastOfUTC == -1)
|
||||
return 0;
|
||||
|
||||
/* Don't bother to check rest of spelling. */
|
||||
while (ISALPHA ((unsigned char) *s))
|
||||
s++;
|
||||
|
||||
/* Don't modify LT. */
|
||||
if (minutesEastOfUTC == 1)
|
||||
{
|
||||
*zone = TM_LOCAL_ZONE;
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
z = minutesEastOfUTC * 60L;
|
||||
|
||||
/* Look for trailing " DST". */
|
||||
if ((s[-1] == 'T' || s[-1] == 't')
|
||||
&& (s[-2] == 'S' || s[-2] == 's')
|
||||
&& (s[-3] == 'D' || s[-3] == 'd'))
|
||||
goto trailing_dst;
|
||||
while (ISSPACE ((unsigned char) *s))
|
||||
s++;
|
||||
if ((s[0] == 'D' || s[0] == 'd')
|
||||
&& (s[1] == 'S' || s[1] == 's')
|
||||
&& (s[2] == 'T' || s[2] == 't'))
|
||||
{
|
||||
s += 3;
|
||||
trailing_dst:
|
||||
*zone = z + 60*60;
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
switch (*s)
|
||||
{
|
||||
case '-':
|
||||
case '+':
|
||||
break;
|
||||
|
||||
default:
|
||||
*zone = z;
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
sign = *s++;
|
||||
|
||||
if (! (s = parse_ranged (s, 2, 0, 23, &hh)))
|
||||
return 0;
|
||||
mm = ss = 0;
|
||||
if (*s == ':')
|
||||
s++;
|
||||
if (ISDIGIT (*s))
|
||||
{
|
||||
if (! (s = parse_ranged (s, 2, 0, 59, &mm)))
|
||||
return 0;
|
||||
if (*s == ':' && s[-3] == ':' && ISDIGIT (s[1])
|
||||
&& ! (s = parse_ranged (s + 1, 2, 0, 59, &ss)))
|
||||
return 0;
|
||||
}
|
||||
if (ISDIGIT (*s))
|
||||
return 0;
|
||||
offset = (hh * 60 + mm) * 60L + ss;
|
||||
*zone = z + (sign == '-' ? -offset : offset);
|
||||
/* ?? Are fractions allowed here? If so, they're not implemented. */
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
/* Parse an initial prefix of S, matching the pattern whose code is C.
|
||||
Set *T accordingly.
|
||||
Return the first character after the prefix, or 0 if it wasn't parsed. */
|
||||
static char const *
|
||||
parse_pattern_letter (s, c, t)
|
||||
char const *s;
|
||||
int c;
|
||||
struct partime *t;
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '$': /* The next character must be a non-digit. */
|
||||
if (ISDIGIT (*s))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case '-':
|
||||
case '/':
|
||||
case ':':
|
||||
/* These characters stand for themselves. */
|
||||
if (*s++ != c)
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case '4': /* 4-digit year */
|
||||
s = parse_fixed (s, 4, &t->tm.tm_year);
|
||||
break;
|
||||
|
||||
case '=': /* optional '-' */
|
||||
s += *s == '-';
|
||||
break;
|
||||
|
||||
case 'A': /* AM or PM */
|
||||
/* This matches the regular expression [AaPp][Mm]?.
|
||||
It must not be followed by a letter or digit;
|
||||
otherwise it would match prefixes of strings like "PST". */
|
||||
switch (*s++)
|
||||
{
|
||||
case 'A':
|
||||
case 'a':
|
||||
if (t->tm.tm_hour == 12)
|
||||
t->tm.tm_hour = 0;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
case 'p':
|
||||
if (t->tm.tm_hour != 12)
|
||||
t->tm.tm_hour += 12;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
switch (*s)
|
||||
{
|
||||
case 'M':
|
||||
case 'm':
|
||||
s++;
|
||||
break;
|
||||
}
|
||||
if (ISALNUM ((unsigned char) *s))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case 'D': /* day of month [01-31] */
|
||||
s = parse_ranged (s, 2, 1, 31, &t->tm.tm_mday);
|
||||
break;
|
||||
|
||||
case 'd': /* day of year [001-366] */
|
||||
s = parse_ranged (s, 3, 1, 366, &t->tm.tm_yday);
|
||||
t->tm.tm_yday--;
|
||||
break;
|
||||
|
||||
case 'E': /* extended day of month [1-9, 01-31] */
|
||||
s = parse_ranged (s, (ISDIGIT (s[0]) && ISDIGIT (s[1])) + 1, 1, 31,
|
||||
&t->tm.tm_mday);
|
||||
break;
|
||||
|
||||
case 'h': /* hour [00-23 followed by optional fraction] */
|
||||
{
|
||||
int frac;
|
||||
s = parse_decimal (s, 2, 0, 23, 60 * 60, &t->tm.tm_hour, &frac);
|
||||
t->tm.tm_min = frac / 60;
|
||||
t->tm.tm_sec = frac % 60;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'm': /* minute [00-59 followed by optional fraction] */
|
||||
s = parse_decimal (s, 2, 0, 59, 60, &t->tm.tm_min, &t->tm.tm_sec);
|
||||
break;
|
||||
|
||||
case 'n': /* month name [e.g. "Jan"] */
|
||||
if (! TM_DEFINED (t->tm.tm_mon = lookup (s, month_names)))
|
||||
return 0;
|
||||
/* Don't bother to check rest of spelling. */
|
||||
while (ISALPHA ((unsigned char) *s))
|
||||
s++;
|
||||
break;
|
||||
|
||||
case 'N': /* month [01-12] */
|
||||
s = parse_ranged (s, 2, 1, 12, &t->tm.tm_mon);
|
||||
t->tm.tm_mon--;
|
||||
break;
|
||||
|
||||
case 'r': /* year % 10 (remainder in origin-0 decade) [0-9] */
|
||||
s = parse_fixed (s, 1, &t->tm.tm_year);
|
||||
t->ymodulus = 10;
|
||||
break;
|
||||
|
||||
case_R:
|
||||
case 'R': /* year % 100 (remainder in origin-0 century) [00-99] */
|
||||
s = parse_fixed (s, 2, &t->tm.tm_year);
|
||||
t->ymodulus = 100;
|
||||
break;
|
||||
|
||||
case 's': /* second [00-60 followed by optional fraction] */
|
||||
{
|
||||
int frac;
|
||||
s = parse_decimal (s, 2, 0, 60, 1, &t->tm.tm_sec, &frac);
|
||||
t->tm.tm_sec += frac;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'T': /* 'T' or 't' */
|
||||
switch (*s++)
|
||||
{
|
||||
case 'T':
|
||||
case 't':
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 't': /* traditional hour [1-9 or 01-12] */
|
||||
s = parse_ranged (s, (ISDIGIT (s[0]) && ISDIGIT (s[1])) + 1, 1, 12,
|
||||
&t->tm.tm_hour);
|
||||
break;
|
||||
|
||||
case 'w': /* 'W' or 'w' only (stands for current week) */
|
||||
switch (*s++)
|
||||
{
|
||||
case 'W':
|
||||
case 'w':
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'W': /* 'W' or 'w', followed by a week of year [00-53] */
|
||||
switch (*s++)
|
||||
{
|
||||
case 'W':
|
||||
case 'w':
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
s = parse_ranged (s, 2, 0, 53, &t->yweek);
|
||||
break;
|
||||
|
||||
case 'X': /* weekday (1=Mon ... 7=Sun) [1-7] */
|
||||
s = parse_ranged (s, 1, 1, 7, &t->tm.tm_wday);
|
||||
t->tm.tm_wday--;
|
||||
break;
|
||||
|
||||
case 'x': /* weekday name [e.g. "Sun"] */
|
||||
if (! TM_DEFINED (t->tm.tm_wday = lookup (s, weekday_names)))
|
||||
return 0;
|
||||
/* Don't bother to check rest of spelling. */
|
||||
while (ISALPHA ((unsigned char) *s))
|
||||
s++;
|
||||
break;
|
||||
|
||||
case 'y': /* either R or Y */
|
||||
if (ISDIGIT (s[0]) && ISDIGIT (s[1]) && ! ISDIGIT (s[2]))
|
||||
goto case_R;
|
||||
/* fall into */
|
||||
case 'Y': /* year in full [4 or more digits] */
|
||||
{
|
||||
int len = 0;
|
||||
while (ISDIGIT (s[len]))
|
||||
len++;
|
||||
if (len < 4)
|
||||
return 0;
|
||||
s = parse_fixed (s, len, &t->tm.tm_year);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Z': /* time zone */
|
||||
s = parzone (s, &t->zone);
|
||||
break;
|
||||
|
||||
case '_': /* possibly empty sequence of non-alphanumerics */
|
||||
while (! ISALNUM ((unsigned char) *s) && *s)
|
||||
s++;
|
||||
break;
|
||||
|
||||
default: /* bad pattern */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/* If there is no conflict, merge into *T the additional information in *U
|
||||
and return 0. Otherwise do nothing and return -1. */
|
||||
static int
|
||||
merge_partime (t, u)
|
||||
struct partime *t;
|
||||
struct partime const *u;
|
||||
{
|
||||
# define conflict(a,b) ((a) != (b) && TM_DEFINED (a) && TM_DEFINED (b))
|
||||
if (conflict (t->tm.tm_sec, u->tm.tm_sec)
|
||||
|| conflict (t->tm.tm_min, u->tm.tm_min)
|
||||
|| conflict (t->tm.tm_hour, u->tm.tm_hour)
|
||||
|| conflict (t->tm.tm_mday, u->tm.tm_mday)
|
||||
|| conflict (t->tm.tm_mon, u->tm.tm_mon)
|
||||
|| conflict (t->tm.tm_year, u->tm.tm_year)
|
||||
|| conflict (t->tm.tm_wday, u->tm.tm_yday)
|
||||
|| conflict (t->ymodulus, u->ymodulus)
|
||||
|| conflict (t->yweek, u->yweek)
|
||||
|| (t->zone != u->zone
|
||||
&& t->zone != TM_UNDEFINED_ZONE
|
||||
&& u->zone != TM_UNDEFINED_ZONE))
|
||||
return -1;
|
||||
# undef conflict
|
||||
# define merge_(a,b) if (TM_DEFINED (b)) (a) = (b);
|
||||
merge_ (t->tm.tm_sec, u->tm.tm_sec)
|
||||
merge_ (t->tm.tm_min, u->tm.tm_min)
|
||||
merge_ (t->tm.tm_hour, u->tm.tm_hour)
|
||||
merge_ (t->tm.tm_mday, u->tm.tm_mday)
|
||||
merge_ (t->tm.tm_mon, u->tm.tm_mon)
|
||||
merge_ (t->tm.tm_year, u->tm.tm_year)
|
||||
merge_ (t->tm.tm_wday, u->tm.tm_yday)
|
||||
merge_ (t->ymodulus, u->ymodulus)
|
||||
merge_ (t->yweek, u->yweek)
|
||||
# undef merge_
|
||||
if (u->zone != TM_UNDEFINED_ZONE)
|
||||
t->zone = u->zone;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Parse a date/time prefix of S, putting the parsed result into *T.
|
||||
Return the first character after the prefix.
|
||||
The prefix may contain no useful information;
|
||||
in that case, *T will contain only undefined values. */
|
||||
char *
|
||||
partime (s, t)
|
||||
char const *s;
|
||||
struct partime *t;
|
||||
{
|
||||
struct partime p;
|
||||
|
||||
undefine (t);
|
||||
|
||||
while (*s)
|
||||
{
|
||||
int i = 0;
|
||||
char const *s1;
|
||||
|
||||
do
|
||||
{
|
||||
if (! (s1 = parse_prefix (s, &p, &i)))
|
||||
return (char *) s;
|
||||
}
|
||||
while (merge_partime (t, &p) != 0);
|
||||
|
||||
s = s1;
|
||||
}
|
||||
|
||||
return (char *) s;
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/* Parse a string, yielding a struct partime that describes it. */
|
||||
|
||||
/* Copyright 1993, 1994, 1995, 1997 Paul Eggert
|
||||
Distributed under license by the Free Software Foundation, Inc.
|
||||
|
||||
This file is part of RCS.
|
||||
|
||||
RCS 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.
|
||||
|
||||
RCS 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 RCS; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Report problems and direct all questions to:
|
||||
|
||||
rcs-bugs@cs.purdue.edu
|
||||
|
||||
*/
|
||||
|
||||
#define TM_UNDEFINED (-1)
|
||||
#define TM_DEFINED(x) (0 <= (x))
|
||||
|
||||
/* #include <limits.h> if you want to use these symbols. */
|
||||
#define TM_LOCAL_ZONE LONG_MIN
|
||||
#define TM_UNDEFINED_ZONE (LONG_MIN + 1)
|
||||
|
||||
struct partime
|
||||
{
|
||||
/* This structure describes the parsed time.
|
||||
Only the following tm_* values in it are used:
|
||||
sec, min, hour, mday, mon, year, wday, yday.
|
||||
If TM_UNDEFINED (value), the parser never found the value.
|
||||
The tm_year field is the actual year, not the year - 1900;
|
||||
but see ymodulus below. */
|
||||
struct tm tm;
|
||||
|
||||
/* If !TM_UNDEFINED (ymodulus),
|
||||
then tm.tm_year is actually modulo ymodulus. */
|
||||
int ymodulus;
|
||||
|
||||
/* Week of year, ISO 8601 style.
|
||||
If TM_UNDEFINED (yweek), the parser never found yweek.
|
||||
Weeks start on Mondays.
|
||||
Week 1 includes Jan 4. */
|
||||
int yweek;
|
||||
|
||||
/* Seconds east of UTC; or TM_LOCAL_ZONE or TM_UNDEFINED_ZONE. */
|
||||
long zone;
|
||||
};
|
||||
|
||||
#if defined __STDC__ || has_prototypes
|
||||
# define __PARTIME_P(x) x
|
||||
#else
|
||||
# define __PARTIME_P(x) ()
|
||||
#endif
|
||||
|
||||
char *partime __PARTIME_P ((char const *, struct partime *));
|
||||
char *parzone __PARTIME_P ((char const *, long *));
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1865
contrib/patch/pch.c
1865
contrib/patch/pch.c
File diff suppressed because it is too large
Load Diff
@ -1,25 +0,0 @@
|
||||
/* reading patches */
|
||||
|
||||
/* $Id: pch.h,v 1.8 1997/06/13 06:28:37 eggert Exp $ */
|
||||
|
||||
LINENUM pch_end PARAMS ((void));
|
||||
LINENUM pch_first PARAMS ((void));
|
||||
LINENUM pch_hunk_beg PARAMS ((void));
|
||||
LINENUM pch_newfirst PARAMS ((void));
|
||||
LINENUM pch_prefix_context PARAMS ((void));
|
||||
LINENUM pch_ptrn_lines PARAMS ((void));
|
||||
LINENUM pch_repl_lines PARAMS ((void));
|
||||
LINENUM pch_suffix_context PARAMS ((void));
|
||||
bool pch_swap PARAMS ((void));
|
||||
bool pch_write_line PARAMS ((LINENUM, FILE *));
|
||||
bool there_is_another_patch PARAMS ((void));
|
||||
char *pfetch PARAMS ((LINENUM));
|
||||
char pch_char PARAMS ((LINENUM));
|
||||
int another_hunk PARAMS ((enum diff, int));
|
||||
int pch_says_nonexistent PARAMS ((int));
|
||||
size_t pch_line_len PARAMS ((LINENUM));
|
||||
time_t pch_timestamp PARAMS ((int));
|
||||
void do_ed_script PARAMS ((FILE *));
|
||||
void open_patch_file PARAMS ((char const *));
|
||||
void re_patch PARAMS ((void));
|
||||
void set_hunkmax PARAMS ((void));
|
@ -1,125 +0,0 @@
|
||||
/* Shell command argument quoting.
|
||||
Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; see the file COPYING.
|
||||
If not, write to the Free Software Foundation,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <quotearg.h>
|
||||
|
||||
/* Place into QUOTED a quoted version of ARG suitable for `system'.
|
||||
Return the length of the resulting string (which is not null-terminated).
|
||||
If QUOTED is null, return the length without any side effects. */
|
||||
|
||||
size_t
|
||||
quote_system_arg (quoted, arg)
|
||||
char *quoted;
|
||||
char const *arg;
|
||||
{
|
||||
char const *a;
|
||||
size_t len = 0;
|
||||
|
||||
/* Scan ARG, copying it to QUOTED if QUOTED is not null,
|
||||
looking for shell metacharacters. */
|
||||
|
||||
for (a = arg; ; a++)
|
||||
{
|
||||
char c = *a;
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
/* ARG has no shell metacharacters. */
|
||||
return len;
|
||||
|
||||
case '=':
|
||||
if (*arg == '-')
|
||||
break;
|
||||
/* Fall through. */
|
||||
case '\t': case '\n': case ' ':
|
||||
case '!': case '"': case '#': case '$': case '%': case '&': case '\'':
|
||||
case '(': case ')': case '*': case ';':
|
||||
case '<': case '>': case '?': case '[': case '\\':
|
||||
case '^': case '`': case '|': case '~':
|
||||
{
|
||||
/* ARG has a shell metacharacter.
|
||||
Start over, quoting it this time. */
|
||||
|
||||
len = 0;
|
||||
c = *arg++;
|
||||
|
||||
/* If ARG is an option, quote just its argument.
|
||||
This is not necessary, but it looks nicer. */
|
||||
if (c == '-' && arg < a)
|
||||
{
|
||||
c = *arg++;
|
||||
|
||||
if (quoted)
|
||||
{
|
||||
quoted[len] = '-';
|
||||
quoted[len + 1] = c;
|
||||
}
|
||||
len += 2;
|
||||
|
||||
if (c == '-')
|
||||
while (arg < a)
|
||||
{
|
||||
c = *arg++;
|
||||
if (quoted)
|
||||
quoted[len] = c;
|
||||
len++;
|
||||
if (c == '=')
|
||||
break;
|
||||
}
|
||||
c = *arg++;
|
||||
}
|
||||
|
||||
if (quoted)
|
||||
quoted[len] = '\'';
|
||||
len++;
|
||||
|
||||
for (; c; c = *arg++)
|
||||
{
|
||||
if (c == '\'')
|
||||
{
|
||||
if (quoted)
|
||||
{
|
||||
quoted[len] = '\'';
|
||||
quoted[len + 1] = '\\';
|
||||
quoted[len + 2] = '\'';
|
||||
}
|
||||
len += 3;
|
||||
}
|
||||
if (quoted)
|
||||
quoted[len] = c;
|
||||
len++;
|
||||
}
|
||||
|
||||
if (quoted)
|
||||
quoted[len] = '\'';
|
||||
return len + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (quoted)
|
||||
quoted[len] = c;
|
||||
len++;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
/* quote.h -- declarations for quoting system arguments */
|
||||
|
||||
#if defined __STDC__ || __GNUC__
|
||||
# define __QUOTEARG_P(args) args
|
||||
#else
|
||||
# define __QUOTEARG_P(args) ()
|
||||
#endif
|
||||
|
||||
size_t quote_system_arg __QUOTEARG_P ((char *, char const *));
|
1079
contrib/patch/util.c
1079
contrib/patch/util.c
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
||||
/* utility functions for `patch' */
|
||||
|
||||
/* $Id: util.h,v 1.15 1997/07/16 12:26:36 eggert Exp $ */
|
||||
|
||||
int ok_to_reverse PARAMS ((char const *, ...)) __attribute__ ((format (printf, 1, 2)));
|
||||
void ask PARAMS ((char const *, ...)) __attribute__ ((format (printf, 1, 2)));
|
||||
void say PARAMS ((char const *, ...)) __attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
void fatal PARAMS ((char const *, ...))
|
||||
__attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
void pfatal PARAMS ((char const *, ...))
|
||||
__attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
|
||||
char *fetchname PARAMS ((char *, int, time_t *));
|
||||
char *savebuf PARAMS ((char const *, size_t));
|
||||
char *savestr PARAMS ((char const *));
|
||||
char const *version_controller PARAMS ((char const *, int, struct stat const *, char **, char **));
|
||||
int version_get PARAMS ((char const *, char const *, int, int, char const *, struct stat *));
|
||||
int create_file PARAMS ((char const *, int, mode_t));
|
||||
int systemic PARAMS ((char const *));
|
||||
void Fseek PARAMS ((FILE *, file_offset, int));
|
||||
void copy_file PARAMS ((char const *, char const *, mode_t));
|
||||
void exit_with_signal PARAMS ((int)) __attribute__ ((noreturn));
|
||||
void ignore_signals PARAMS ((void));
|
||||
void init_time PARAMS ((void));
|
||||
void memory_fatal PARAMS ((void)) __attribute__ ((noreturn));
|
||||
void move_file PARAMS ((char const *, char *, mode_t, int));
|
||||
void read_fatal PARAMS ((void)) __attribute__ ((noreturn));
|
||||
void remove_prefix PARAMS ((char *, size_t));
|
||||
void removedirs PARAMS ((char *));
|
||||
void set_signals PARAMS ((int));
|
||||
void write_fatal PARAMS ((void)) __attribute__ ((noreturn));
|
@ -1,30 +0,0 @@
|
||||
/* Print the version number. */
|
||||
|
||||
/* $Id: version.c,v 1.5 1997/05/21 18:29:20 eggert Exp $ */
|
||||
|
||||
#define XTERN extern
|
||||
#include <common.h>
|
||||
#undef XTERN
|
||||
#define XTERN
|
||||
#include <patchlevel.h>
|
||||
#include <version.h>
|
||||
|
||||
static char const copyright_string[] = "\
|
||||
Copyright 1988 Larry Wall\n\
|
||||
Copyright 1997 Free Software Foundation, Inc.";
|
||||
|
||||
static char const free_software_msgid[] = "\
|
||||
This program comes with NO WARRANTY, to the extent permitted by law.\n\
|
||||
You may redistribute copies of this program\n\
|
||||
under the terms of the GNU General Public License.\n\
|
||||
For more information about these matters, see the file named COPYING.";
|
||||
|
||||
static char const authorship_msgid[] = "\
|
||||
written by Larry Wall with lots o' patches by Paul Eggert";
|
||||
|
||||
void
|
||||
version()
|
||||
{
|
||||
printf ("%s %s\n%s\n\n%s\n\n%s\n", program_name, PATCH_VERSION,
|
||||
copyright_string, free_software_msgid, authorship_msgid);
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
/* Print the version number. */
|
||||
|
||||
/* $Id: version.h,v 1.3 1997/04/07 01:07:00 eggert Exp $ */
|
||||
|
||||
void version PARAMS ((void));
|
Loading…
Reference in New Issue
Block a user