mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
235 Commits
FILEUTILS-
...
FILEUTILS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3581b3cf77 | ||
|
|
9f425a515b | ||
|
|
b4721f8c6e | ||
|
|
59bf576f46 | ||
|
|
1d0ba16702 | ||
|
|
c4c4106e8b | ||
|
|
d7af479281 | ||
|
|
5b55669c7a | ||
|
|
94d34806bd | ||
|
|
c93a607f05 | ||
|
|
7b1d35af90 | ||
|
|
33db1748a0 | ||
|
|
9c55b67dd4 | ||
|
|
74a00a63a0 | ||
|
|
f801837d6c | ||
|
|
55692e275e | ||
|
|
5bf6f179da | ||
|
|
f9850882f1 | ||
|
|
5d0d80fc27 | ||
|
|
c055d35869 | ||
|
|
61a8f5b321 | ||
|
|
0dd04df27f | ||
|
|
dde8f61f1c | ||
|
|
1696188993 | ||
|
|
3804c0288a | ||
|
|
70b951593e | ||
|
|
614723b9c1 | ||
|
|
849d512ee9 | ||
|
|
c4e4ba9607 | ||
|
|
5f52473b9c | ||
|
|
f0a4b95c58 | ||
|
|
d5d043c57a | ||
|
|
5f14914c49 | ||
|
|
8c446739e7 | ||
|
|
0f8dd3a954 | ||
|
|
d927d60b36 | ||
|
|
bed2ded78f | ||
|
|
406f1dcb0f | ||
|
|
fc0b4f7672 | ||
|
|
262dbfe2f6 | ||
|
|
27289e8b53 | ||
|
|
8656b00f6d | ||
|
|
ce9d58029c | ||
|
|
c187c5884b | ||
|
|
ae8efa7087 | ||
|
|
13a7e4caf8 | ||
|
|
00874a5dad | ||
|
|
52f1830329 | ||
|
|
af77319c56 | ||
|
|
60d7a8e772 | ||
|
|
e37768067a | ||
|
|
47e19fb368 | ||
|
|
f2893678eb | ||
|
|
1a27d41352 | ||
|
|
9099ba78e2 | ||
|
|
017ee79337 | ||
|
|
44d3e01da9 | ||
|
|
52d20e4420 | ||
|
|
04d18f430c | ||
|
|
c2177b12b3 | ||
|
|
7c032c04b9 | ||
|
|
19d6aed760 | ||
|
|
c14f06f708 | ||
|
|
5018ccfb7e | ||
|
|
d0c8664700 | ||
|
|
2ed0078725 | ||
|
|
f64320db7b | ||
|
|
f253241fa6 | ||
|
|
129ede91ad | ||
|
|
c5e73d1f4a | ||
|
|
543cd52e60 | ||
|
|
a9a5efd77b | ||
|
|
b99ee65d9f | ||
|
|
b2557211cb | ||
|
|
6fa66b8414 | ||
|
|
13587cf0ec | ||
|
|
deffd164df | ||
|
|
8b6882e5e9 | ||
|
|
1899efe4f6 | ||
|
|
8180fd9209 | ||
|
|
d681dd7524 | ||
|
|
c64d3aaf18 | ||
|
|
b6bacc5dcf | ||
|
|
3424a30611 | ||
|
|
045b33aaef | ||
|
|
1fdeee96e2 | ||
|
|
8d381987d0 | ||
|
|
1def0627b7 | ||
|
|
cab29a570d | ||
|
|
02edb50e8f | ||
|
|
3190f18d1c | ||
|
|
d8f02c5c3a | ||
|
|
8f8f0254b2 | ||
|
|
51b6b653a2 | ||
|
|
90fb34362a | ||
|
|
7299626404 | ||
|
|
0ae67ef6a8 | ||
|
|
fd5da15041 | ||
|
|
0981ef97c0 | ||
|
|
eb6e8b63c6 | ||
|
|
0ef1ebe00e | ||
|
|
56752ea034 | ||
|
|
568f9e0516 | ||
|
|
497785afe5 | ||
|
|
43fde4395a | ||
|
|
aee6ce52e0 | ||
|
|
a64e651230 | ||
|
|
4951b1a4b0 | ||
|
|
3110281aad | ||
|
|
0d9ee9b50c | ||
|
|
496964cdc3 | ||
|
|
9048856887 | ||
|
|
61b0870c41 | ||
|
|
ae9ce08522 | ||
|
|
95b686e751 | ||
|
|
773a575cd5 | ||
|
|
8db7ef9e42 | ||
|
|
6b95201b8d | ||
|
|
a8fd3f260a | ||
|
|
8b39b39763 | ||
|
|
76211dbaeb | ||
|
|
1b57516fe2 | ||
|
|
b3197453ad | ||
|
|
f79bc88685 | ||
|
|
81b2c3735e | ||
|
|
e69797a267 | ||
|
|
77a40f148f | ||
|
|
26a7265907 | ||
|
|
4e39b59aba | ||
|
|
90d90ce434 | ||
|
|
a5b5eb21f9 | ||
|
|
641dabb657 | ||
|
|
0037a01cf8 | ||
|
|
c60c4a9fdc | ||
|
|
1d80882fc0 | ||
|
|
f3e288c470 | ||
|
|
ac4300150a | ||
|
|
051a7c856a | ||
|
|
449a130ddb | ||
|
|
10798a81c4 | ||
|
|
cf04cc6ec2 | ||
|
|
fe15457dcd | ||
|
|
a55a40b616 | ||
|
|
d203fb94d2 | ||
|
|
8baafe1f08 | ||
|
|
07e0171826 | ||
|
|
d034a083ab | ||
|
|
cbed17e88a | ||
|
|
ef49ee4777 | ||
|
|
a2e30297d1 | ||
|
|
56d6e5a38a | ||
|
|
4e02f20bd3 | ||
|
|
216cc77784 | ||
|
|
6fb996fcc5 | ||
|
|
5a95ad0a73 | ||
|
|
5dcaccf5be | ||
|
|
beb983dd07 | ||
|
|
e0be88dd59 | ||
|
|
456a1ea3ea | ||
|
|
c8a15b9edb | ||
|
|
0e1dfa9b8b | ||
|
|
7b79dfe695 | ||
|
|
a53a181821 | ||
|
|
614cf2b06b | ||
|
|
a73455fc19 | ||
|
|
87ad4e1dbb | ||
|
|
56836dca33 | ||
|
|
3048ed8790 | ||
|
|
a0947ac542 | ||
|
|
a313a8b995 | ||
|
|
c2c1f42b0b | ||
|
|
381ba4a26a | ||
|
|
8330089910 | ||
|
|
ff6161442d | ||
|
|
7373e3149d | ||
|
|
608cabf1d4 | ||
|
|
76bc5dc396 | ||
|
|
fb61cfca00 | ||
|
|
1f9d1ea959 | ||
|
|
eb128f8a49 | ||
|
|
395e6c592a | ||
|
|
4d617153d5 | ||
|
|
222f736378 | ||
|
|
b53d6da640 | ||
|
|
d4365673c5 | ||
|
|
493d6182eb | ||
|
|
6986c2b9ad | ||
|
|
e15422c3d3 | ||
|
|
ec739a978b | ||
|
|
b9e891771e | ||
|
|
3b18fcfb6a | ||
|
|
ae3ec5f069 | ||
|
|
02b4fede5b | ||
|
|
74fe479350 | ||
|
|
048017b39c | ||
|
|
734d411884 | ||
|
|
4524bbcaf8 | ||
|
|
70c58e8192 | ||
|
|
ce49687fac | ||
|
|
7ddc6c5927 | ||
|
|
043c4958de | ||
|
|
3819c2d7cb | ||
|
|
ba8620bf01 | ||
|
|
e32586114e | ||
|
|
7102df4dd3 | ||
|
|
586254e713 | ||
|
|
cbcd5929c1 | ||
|
|
e6db9876a0 | ||
|
|
f247c7bd44 | ||
|
|
e7a7601ef4 | ||
|
|
3330c7dab7 | ||
|
|
d0f57e1004 | ||
|
|
9b14de28be | ||
|
|
9133ae8f15 | ||
|
|
d86f9d40a5 | ||
|
|
ebd74667bc | ||
|
|
d3938d3118 | ||
|
|
c0186d3cbb | ||
|
|
289dacfa49 | ||
|
|
1bfc7036c0 | ||
|
|
cb1df652a7 | ||
|
|
135a310ca1 | ||
|
|
01bd168259 | ||
|
|
50631d7b81 | ||
|
|
18051fbbb3 | ||
|
|
ddc825a0f0 | ||
|
|
2071a4054e | ||
|
|
80dbd557de | ||
|
|
b083f93482 | ||
|
|
66a0218c1a | ||
|
|
50c130325e | ||
|
|
1978f56515 | ||
|
|
d53f7b9a5d | ||
|
|
d565aeb336 | ||
|
|
5294c10e84 |
6
THANKS
6
THANKS
@@ -159,6 +159,7 @@ Lars Hecking lhecking@nmrc.ucc.ie
|
||||
Lehti Rami rammer@cs.tut.fi
|
||||
Leonard N. Zubkoff lnz@dandelion.com
|
||||
Lorne Baker lbaker@nitro.avint.net
|
||||
Maciej Kwapulinski pikpok@univ.gda.pl
|
||||
Manas Garg manas@cygsoft.com
|
||||
Manfred Hollstein manfred@s-direktnet.de
|
||||
Marc Boucher marc@mbsi.ca
|
||||
@@ -203,6 +204,7 @@ Niklas Edmundsson nikke@acc.umu.se
|
||||
Noah Friedman friedman@splode.com
|
||||
Noel Cragg noel@red-bean.com
|
||||
Olav Morkrid olav@funcom.com
|
||||
Ørn E. Hansen oehansen@daimi.aau.dk
|
||||
Paul Eggert eggert@twinsun.com
|
||||
Paul Nevai nevai@ops.mps.ohio-state.edu
|
||||
Paul Sauer paul@alexa.com
|
||||
@@ -218,7 +220,7 @@ Philippe De Muyter phdm@macqel.be
|
||||
Philippe Schnoebelen Philippe.Schnoebelen@imag.fr
|
||||
Piergiorgio Sartor sartor@sony.de
|
||||
Piotr Kwapulinski kwap@univ.gda.pl
|
||||
Maciej Kwapulinski pikpok@univ.gda.pl
|
||||
Prashant TR tr@eth.net
|
||||
Rainer Orth ro@TechFak.Uni-Bielefeld.DE
|
||||
Ralf W. Stephan stephan@tmt.de
|
||||
Ralph Loader loader@maths.ox.ac.uk
|
||||
@@ -242,6 +244,7 @@ Santiago Vila Doncel sanvila@unex.es
|
||||
Savochkin Andrey Vladimirovich saw@msu.ru
|
||||
Scott Lurndal slurn@griffin.engr.sgi.com
|
||||
Stephen Gildea gildea@x.org
|
||||
Stephen Smoogen ??????????
|
||||
Steve McConnel steve@acadcomp.sil.org
|
||||
Stuart Kemp skemp@peter.bmc.com
|
||||
Tadayoshi Funaba tadf@kt.rim.or.jp
|
||||
@@ -270,4 +273,3 @@ William Dowling will@franklin.com
|
||||
William Lewis wiml@omnigroup.com
|
||||
Wolfram Kleff kleff@cs.uni-bonn.de
|
||||
Zvi Har'El rl@math.technion.ac.il
|
||||
Ørn E. Hansen oehansen@daimi.aau.dk
|
||||
|
||||
@@ -158,9 +158,11 @@ $(srcdir)/version.texi: stamp-vti
|
||||
@:
|
||||
|
||||
$(srcdir)/stamp-vti: fileutils.texi $(top_srcdir)/configure.in
|
||||
@echo "@set UPDATED `$(SHELL) $(srcdir)/mdate-sh $(srcdir)/fileutils.texi`" > vti.tmp
|
||||
@echo "@set EDITION $(VERSION)" >> vti.tmp
|
||||
@echo "@set VERSION $(VERSION)" >> vti.tmp
|
||||
@(set `$(SHELL) $(srcdir)/mdate-sh $(srcdir)/fileutils.texi`; \
|
||||
echo "@set UPDATED $$1 $$2 $$3"; \
|
||||
echo "@set UPDATED-MONTH $$2 $$3"; \
|
||||
echo "@set EDITION $(VERSION)"; \
|
||||
echo "@set VERSION $(VERSION)") > vti.tmp
|
||||
@cmp -s vti.tmp $(srcdir)/version.texi \
|
||||
|| (echo "Updating $(srcdir)/version.texi"; \
|
||||
cp vti.tmp $(srcdir)/version.texi)
|
||||
|
||||
@@ -1796,32 +1796,34 @@ contents of files.
|
||||
|
||||
@pindex wc
|
||||
@cindex byte count
|
||||
@cindex character count
|
||||
@cindex word count
|
||||
@cindex line count
|
||||
|
||||
@code{wc} counts the number of bytes, whitespace-separated words, and
|
||||
newlines in each given @var{file}, or standard input if none are given
|
||||
or for a @var{file} of @samp{-}. Synopsis:
|
||||
@code{wc} counts the number of bytes, characters, whitespace-separated
|
||||
words, and newlines in each given @var{file}, or standard input if none
|
||||
are given or for a @var{file} of @samp{-}. Synopsis:
|
||||
|
||||
@example
|
||||
wc [@var{option}]@dots{} [@var{file}]@dots{}
|
||||
@end example
|
||||
|
||||
@cindex total counts
|
||||
@vindex POSIXLY_CORRECT
|
||||
@code{wc} prints one line of counts for each file, and if the file was
|
||||
given as an argument, it prints the file name following the counts. If
|
||||
more than one @var{file} is given, @code{wc} prints a final line
|
||||
containing the cumulative counts, with the file name @file{total}. The
|
||||
counts are printed in this order: newlines, words, bytes.
|
||||
counts are printed in this order: newlines, words, characters, bytes.
|
||||
By default, each count is output right-justified in a 7-byte field with
|
||||
one space between fields so that the numbers and file names line up nicely
|
||||
in columns. However, @sc{posix} requires that there be exactly one space
|
||||
separating columns. You can make @code{wc} use the @sc{posix}-mandated
|
||||
output format by setting the @env{POSIXLY_CORRECT} environment variable.
|
||||
|
||||
By default, @code{wc} prints all three counts. Options can specify
|
||||
that only certain counts be printed. Options do not undo others
|
||||
previously given, so
|
||||
By default, @code{wc} prints three counts: the newline, words, byte counts.
|
||||
Options can specify that only certain counts be printed. Options do not
|
||||
undo others previously given, so
|
||||
|
||||
@example
|
||||
wc --bytes --words
|
||||
@@ -1840,12 +1842,16 @@ The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@item -c
|
||||
@itemx --bytes
|
||||
@itemx --chars
|
||||
@opindex -c
|
||||
@opindex --bytes
|
||||
@opindex --chars
|
||||
Print only the byte counts.
|
||||
|
||||
@item -m
|
||||
@itemx --chars
|
||||
@opindex -m
|
||||
@opindex --chars
|
||||
Print only the character counts.
|
||||
|
||||
@item -w
|
||||
@itemx --words
|
||||
@opindex -w
|
||||
@@ -2137,42 +2143,49 @@ value as the directory for temporary files instead of @file{/tmp}. The
|
||||
@samp{-T @var{tempdir}} option in turn overrides the environment
|
||||
variable.
|
||||
|
||||
@vindex LC_CTYPE
|
||||
The following options affect the ordering of output lines. They may be
|
||||
specified globally or as part of a specific key field. If no key
|
||||
fields are specified, global options apply to comparison of entire
|
||||
lines; otherwise the global options are inherited by key fields that do
|
||||
not specify any special options of their own. The @samp{-b}, @samp{-d},
|
||||
@samp{-f} and @samp{-i} options classify characters according to
|
||||
the @env{LC_CTYPE} locale.
|
||||
not specify any special options of their own. In pre-@sc{posix}
|
||||
versions of @command{sort}, global options affect only later key fields,
|
||||
so portable shell scripts should specify global options first.
|
||||
|
||||
@table @samp
|
||||
|
||||
@item -b
|
||||
@opindex -b
|
||||
@cindex blanks, ignoring leading
|
||||
@vindex LC_CTYPE
|
||||
Ignore leading blanks when finding sort keys in each line.
|
||||
The @env{LC_CTYPE} locale determines character types.
|
||||
|
||||
@item -d
|
||||
@opindex -d
|
||||
@cindex phone directory order
|
||||
@cindex telephone directory order
|
||||
@vindex LC_CTYPE
|
||||
Sort in @dfn{phone directory} order: ignore all characters except
|
||||
letters, digits and blanks when sorting.
|
||||
The @env{LC_CTYPE} locale determines character types.
|
||||
|
||||
@item -f
|
||||
@opindex -f
|
||||
@cindex case folding
|
||||
@vindex LC_CTYPE
|
||||
Fold lowercase characters into the equivalent uppercase characters when
|
||||
sorting so that, for example, @samp{b} and @samp{B} sort as equal.
|
||||
The @env{LC_CTYPE} locale determines character types.
|
||||
|
||||
@item -g
|
||||
@opindex -g
|
||||
@cindex general numeric sort
|
||||
@vindex LC_NUMERIC
|
||||
Sort numerically, using the standard C function @code{strtod} to convert
|
||||
a prefix of each line to a double-precision floating point number.
|
||||
This allows floating point numbers to be specified in scientific notation,
|
||||
like @code{1.0e-34} and @code{10e100}.
|
||||
The @env{LC_NUMERIC} locale determines the decimal-point character.
|
||||
Do not report overflow, underflow, or conversion errors.
|
||||
Use the following collating sequence:
|
||||
|
||||
@@ -2196,7 +2209,9 @@ Use this option only if there is no alternative; it is much slower than
|
||||
@item -i
|
||||
@opindex -i
|
||||
@cindex unprintable characters, ignoring
|
||||
@vindex LC_CTYPE
|
||||
Ignore unprintable characters.
|
||||
The @env{LC_CTYPE} locale determines character types.
|
||||
|
||||
@item -M
|
||||
@opindex -M
|
||||
@@ -2215,13 +2230,13 @@ determines the month spellings.
|
||||
Sort numerically: the number begins each line; specifically, it consists
|
||||
of optional whitespace, an optional @samp{-} sign, and zero or more
|
||||
digits possibly separated by thousands separators, optionally followed
|
||||
by a radix character and zero or more digits. The @env{LC_NUMERIC}
|
||||
locale specifies the radix character and thousands separator.
|
||||
by a decimal-point character and zero or more digits. The @env{LC_NUMERIC}
|
||||
locale specifies the decimal-point character and thousands separator.
|
||||
|
||||
@code{sort -n} uses what might be considered an unconventional method
|
||||
to compare strings representing floating point numbers. Rather than
|
||||
first converting each string to the C @code{double} type and then
|
||||
comparing those values, sort aligns the radix characters in the two
|
||||
comparing those values, sort aligns the decimal-point characters in the two
|
||||
strings and compares the strings a character at a time. One benefit
|
||||
of using this approach is its speed. In practice this is much more
|
||||
efficient than performing the two corresponding string-to-double (or even
|
||||
@@ -2264,6 +2279,17 @@ into fields @w{@samp{ foo}} and @w{@samp{ bar}}. The field separator is
|
||||
not considered to be part of either the field preceding or the field
|
||||
following.
|
||||
|
||||
@item -T @var{tempdir}
|
||||
@opindex -T
|
||||
@cindex temporary directory
|
||||
@vindex TMPDIR
|
||||
Use directory @var{tempdir} to store temporary files, overriding the
|
||||
@env{TMPDIR} environment variable. If this option is given more than
|
||||
once, temporary files are stored in all the directories given. If you
|
||||
have a large sort or merge that is I/O-bound, you can often improve
|
||||
performance by using this option to specify directories on different
|
||||
disks and controllers.
|
||||
|
||||
@item -u
|
||||
@opindex -u
|
||||
@cindex uniquifying output
|
||||
@@ -2542,8 +2568,8 @@ comm [@var{option}]@dots{} @var{file1} @var{file2}
|
||||
|
||||
@vindex LC_COLLATE
|
||||
Before @code{comm} can be used, the input files must be sorted using the
|
||||
collating sequence specified by the @env{LC_COLLATE} locale, with
|
||||
trailing newlines significant. If an input file ends in a non-newline
|
||||
collating sequence specified by the @env{LC_COLLATE} locale.
|
||||
If an input file ends in a non-newline
|
||||
character, a newline is silently appended. The @code{sort} command with
|
||||
no options always outputs a file that is suitable input to @code{comm}.
|
||||
|
||||
@@ -3410,11 +3436,23 @@ A backslash.
|
||||
The notation @samp{@var{m}-@var{n}} expands to all of the characters
|
||||
from @var{m} through @var{n}, in ascending order. @var{m} should
|
||||
collate before @var{n}; if it doesn't, an error results. As an example,
|
||||
@samp{0-9} is the same as @samp{0123456789}. Although GNU @code{tr}
|
||||
does not support the System V syntax that uses square brackets to
|
||||
enclose ranges, translations specified in that format will still work as
|
||||
long as the brackets in @var{string1} correspond to identical brackets
|
||||
in @var{string2}.
|
||||
@samp{0-9} is the same as @samp{0123456789}.
|
||||
|
||||
GNU @code{tr} does not support the System V syntax that uses square
|
||||
brackets to enclose ranges. Translations specified in that format
|
||||
sometimes work as expected, since the brackets are often transliterated
|
||||
to themselves. However, they should be avoided because they sometimes
|
||||
behave unexpectedly. For example, @samp{tr -d '[0-9]'} deletes brackets
|
||||
as well as digits.
|
||||
|
||||
Many historically common and even accepted uses of ranges are not
|
||||
portable. For example, on @sc{ebcdic} hosts using the @samp{A-Z}
|
||||
range will not do what most would expect because @samp{A} through @samp{Z}
|
||||
are not contiguous as they are in @sc{ascii}.
|
||||
If you can rely on a @sc{posix} compliant version of @code{tr}, then
|
||||
the best way to work around this is to use character classes (see below).
|
||||
Otherwise, it is most portable (and most ugly) to enumerate the members
|
||||
of the ranges.
|
||||
|
||||
@item Repeated characters
|
||||
@cindex repeated characters
|
||||
@@ -3523,6 +3561,9 @@ tr a-z A-Z
|
||||
tr '[:lower:]' '[:upper:]'
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
But note that using ranges like @code{a-z} above is not portable.
|
||||
|
||||
When @code{tr} is performing translation, @var{set1} and @var{set2}
|
||||
typically have the same length. If @var{set1} is shorter than
|
||||
@var{set2}, the extra characters at the end of @var{set2} are ignored.
|
||||
@@ -3550,6 +3591,14 @@ because it converts only zero bytes (the first element in the
|
||||
complement of @var{set1}), rather than all non-alphanumerics, to
|
||||
newlines.
|
||||
|
||||
@noindent
|
||||
By the way, the above idiom is not portable because it uses ranges.
|
||||
Assuming a @sc{posix} compliant @code{tr}, here is a better way to write it:
|
||||
|
||||
@example
|
||||
tr -cs '[:alnum:]' '[\n*]'
|
||||
@end example
|
||||
|
||||
|
||||
@node Squeezing
|
||||
@subsection Squeezing repeats and deleting
|
||||
@@ -3589,7 +3638,7 @@ non-alphanumeric characters to newlines, then squeezes each string
|
||||
of repeated newlines into a single newline:
|
||||
|
||||
@example
|
||||
tr -cs 'a-zA-Z0-9' '[\n*]'
|
||||
tr -cs '[:alnum:]' '[\n*]'
|
||||
@end example
|
||||
|
||||
@item
|
||||
@@ -4075,7 +4124,7 @@ characters. Normally it is used for things like mapping upper case to
|
||||
lower case:
|
||||
|
||||
@example
|
||||
$ echo ThIs ExAmPlE HaS MIXED case! | tr '[A-Z]' '[a-z]'
|
||||
$ echo ThIs ExAmPlE HaS MIXED case! | tr '[:upper:]' '[:lower:]'
|
||||
this example has mixed case!
|
||||
@end example
|
||||
|
||||
@@ -4134,7 +4183,7 @@ The first step is to change the case of all the letters in our input file
|
||||
to one case. ``The'' and ``the'' are the same word when doing counting.
|
||||
|
||||
@example
|
||||
$ tr '[A-Z]' '[a-z]' < whats.gnu | ...
|
||||
$ tr '[:upper:]' '[:lower:]' < whats.gnu | ...
|
||||
@end example
|
||||
|
||||
The next step is to get rid of punctuation. Quoted words and unquoted words
|
||||
@@ -4142,7 +4191,7 @@ should be treated identically; it's easiest to just get the punctuation out of
|
||||
the way.
|
||||
|
||||
@smallexample
|
||||
$ tr '[A-Z]' '[a-z]' < whats.gnu | tr -cd '[A-Za-z0-9_ \012]' | ...
|
||||
$ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \012' | ...
|
||||
@end smallexample
|
||||
|
||||
The second @code{tr} command operates on the complement of the listed
|
||||
@@ -4157,8 +4206,8 @@ next step is break the data apart so that we have one word per line. This
|
||||
makes the counting operation much easier, as we will see shortly.
|
||||
|
||||
@smallexample
|
||||
$ tr '[A-Z]' '[a-z]' < whats.gnu | tr -cd '[A-Za-z0-9_ \012]' |
|
||||
> tr -s '[ ]' '\012' | ...
|
||||
$ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \012' |
|
||||
> tr -s ' ' '\012' | ...
|
||||
@end smallexample
|
||||
|
||||
This command turns blanks into newlines. The @samp{-s} option squeezes
|
||||
@@ -4171,8 +4220,8 @@ We now have data consisting of one word per line, no punctuation, all one
|
||||
case. We're ready to count each word:
|
||||
|
||||
@smallexample
|
||||
$ tr '[A-Z]' '[a-z]' < whats.gnu | tr -cd '[A-Za-z0-9_ \012]' |
|
||||
> tr -s '[ ]' '\012' | sort | uniq -c | ...
|
||||
$ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \012' |
|
||||
> tr -s ' ' '\012' | sort | uniq -c | ...
|
||||
@end smallexample
|
||||
|
||||
At this point, the data might look something like this:
|
||||
@@ -4203,8 +4252,8 @@ reverse the order of the sort
|
||||
The final pipeline looks like this:
|
||||
|
||||
@smallexample
|
||||
$ tr '[A-Z]' '[a-z]' < whats.gnu | tr -cd '[A-Za-z0-9_ \012]' |
|
||||
> tr -s '[ ]' '\012' | sort | uniq -c | sort -nr
|
||||
$ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \012' |
|
||||
> tr -s ' ' '\012' | sort | uniq -c | sort -nr
|
||||
156 the
|
||||
60 a
|
||||
58 to
|
||||
@@ -4230,16 +4279,16 @@ Now, how to compare our file with the dictionary? As before, we generate
|
||||
a sorted list of words, one per line:
|
||||
|
||||
@smallexample
|
||||
$ tr '[A-Z]' '[a-z]' < whats.gnu | tr -cd '[A-Za-z0-9_ \012]' |
|
||||
> tr -s '[ ]' '\012' | sort -u | ...
|
||||
$ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \012' |
|
||||
> tr -s ' ' '\012' | sort -u | ...
|
||||
@end smallexample
|
||||
|
||||
Now, all we need is a list of words that are @emph{not} in the
|
||||
dictionary. Here is where the @code{comm} command comes in.
|
||||
|
||||
@smallexample
|
||||
$ tr '[A-Z]' '[a-z]' < whats.gnu | tr -cd '[A-Za-z0-9_ \012]' |
|
||||
> tr -s '[ ]' '\012' | sort -u |
|
||||
$ tr '[:upper:]' '[:lower:]' < whats.gnu | tr -cd '[:alnum:]_ \012' |
|
||||
> tr -s ' ' '\012' | sort -u |
|
||||
> comm -23 - /usr/lib/ispell/ispell.words
|
||||
@end smallexample
|
||||
|
||||
|
||||
131
lib/ChangeLog
131
lib/ChangeLog
@@ -1,3 +1,130 @@
|
||||
2000-08-07 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Standardize on "memory exhausted" instead of "Memory exhausted"
|
||||
or "virtual memory exhausted".
|
||||
* obstack.c (print_and_abort): Use "memory exhausted", not
|
||||
"virtual memory exhausted".
|
||||
* same.c (same_name): Invoke xalloc_die instead of printing
|
||||
our own message.
|
||||
* userspec.c (parse_user_spec): Likewise.
|
||||
* bumpalloc.h: comment fix
|
||||
* same.c, userspec.c: Include xalloc.h.
|
||||
|
||||
* xalloc.h (xalloc_msg_memory_exhausted): Now char const[],
|
||||
not char *const and pointing to a constant array.
|
||||
* xmalloc.c (xalloc_msg_memory_exhausted): Likewise.
|
||||
(xrealloc): Comment fix.
|
||||
|
||||
* userspec.c (parse_user_spec):
|
||||
Don't translate a message until just before returning,
|
||||
to avoid unnecessary translation.
|
||||
|
||||
2000-08-07 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* addext.c, argmatch.c, argmatch.h, backupfile.h, bumpalloc.h,
|
||||
chown.c, diacrit.h, dirname.h, dup2.c, exclude.h, fileblocks.c,
|
||||
fnmatch.c, fnmatch.h, fsusage.c, fsusage.h, getdate.h,
|
||||
getgroups.c, gethostname.c, getopt.h, group-member.c,
|
||||
hard-locale.c, hash.h, isdir.c, lchown.c, linebuffer.c,
|
||||
linebuffer.h, long-options.h, malloc.c, md5.c, md5.h, memchr.c,
|
||||
memcmp.c, memcoll.c, memset.c, mktime.c, modechange.h, obstack.h,
|
||||
pathmax.h, realloc.c, rmdir.c, safe-read.c, save-cwd.c, stime.c,
|
||||
stpcpy.c, strcasecmp.c, strcspn.c, strdup.c, stripslash.c,
|
||||
strstr.c, strtod.c, strtol.c, strtoul.c, strtoull.c, strtoumax.c,
|
||||
utime.c, version-etc.h, xalloc.h, xstrdup.c, xstrtoumax.c,
|
||||
yesno.c: Back out Copyright date changes for each file with no change
|
||||
this year. This eases coordination with other programs using the same
|
||||
source code modules. From Paul Eggert.
|
||||
|
||||
2000-08-03 Greg McGary <greg@mcgary.org>
|
||||
|
||||
* regex.c (SET_HIGH_BOUND, MOVE_BUFFER_POINTER,
|
||||
ELSE_EXTEND_BUFFER_HIGH_BOUND): New macros.
|
||||
(EXTEND_BUFFER): Use them.
|
||||
|
||||
2000-08-01 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* dirname.c (ISSLASH): Define.
|
||||
(BACKSLASH_IS_PATH_SEPARATOR): Define.
|
||||
(dir_name) [BACKSLASH_IS_PATH_SEPARATOR]: Handle the case in which
|
||||
both `\' and `/' may be use as path separators.
|
||||
Based on a patch from Prashant TR.
|
||||
|
||||
2000-07-31 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* quotearg.c (quotearg_n_options): Don't make the initial
|
||||
slot vector a constant, since it might get modified.
|
||||
|
||||
2000-07-31 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* xmalloc.c: Use `virtual memory exhausted', not `Memory exhausted'.
|
||||
* obstack.c (print_and_abort): Likewise.
|
||||
|
||||
2000-07-30 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* quotearg.c (quotearg_n_options): Preallocate a slot 0
|
||||
buffer, so that the caller can always quote one small
|
||||
component of a "memory exhausted" message in slot 0.
|
||||
From a suggestion by Jim Meyering.
|
||||
|
||||
2000-07-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* makepath.c (make_path): Quote the other instance, too.
|
||||
|
||||
* quotearg.c (N_STATIC_SLOTVECS): Define.
|
||||
(STATIC_BUF_SIZE): Define.
|
||||
(quotearg_n_options): Use only statically allocated storage when
|
||||
N < N_STATIC_SLOTVECS and the length of the quoted result is smaller
|
||||
than STATIC_BUF_SIZE.
|
||||
|
||||
2000-07-29 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* diacrit.c (diacrit_diac): Use __MSDOS__ in favor of MSDOS.
|
||||
* dirname.c (dir_name): Likewise.
|
||||
|
||||
* basename.c (base_name): Use ISSLASH rather than comparing against `/'.
|
||||
|
||||
* dirname.c (dir_name) [MSDOS]: Declare `lim' to be const.
|
||||
(dir_name): Assert that there are no trailing slashes.
|
||||
|
||||
2000-07-18 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* mbswidth.h (mbswidth): Add a flags argument.
|
||||
(mbswidth): New declaration.
|
||||
(MBSW_ACCEPT_INVALID, MBSW_ACCEPT_UNPRINTABLE): New macros.
|
||||
* mbswidth.c (mbswidth): Add a flags argument.
|
||||
(mbsnwidth): New function.
|
||||
|
||||
2000-07-24 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* mbswidth.c: Remove useless #else. From Bruno Haible.
|
||||
|
||||
2000-07-23 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* mbswidth.c (_XOPEN_SOURCE):
|
||||
Don't define; this causes problems on Solaris 7.
|
||||
(wcwidth) [!HAVE_DECL_WCWIDTH]: Declare.
|
||||
|
||||
2000-07-23 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* quotearg.c:
|
||||
Include <wchar.h> even if ! (HAVE_MBRTOWC && 1 < MB_LEN_MAX),
|
||||
so that mbstate_t is always defined.
|
||||
|
||||
Do not inspect MB_LEN_MAX, since it's incorrectly defined to
|
||||
be 1 in at least one GCC installation, and this configuration
|
||||
error is likely to be common. Ignoring MB_LEN_MAX hurts
|
||||
performance on hosts that have mbrtowc but have only unibyte
|
||||
locales, but I assume these hosts are rare.
|
||||
|
||||
2000-07-23 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* quotearg.c: Streamline by invoking multibyte code only if needed.
|
||||
<wchar.h>: Include only if HAVE_MBRTOWC && 1 < MB_LEN_MAX.
|
||||
(MB_CUR_MAX): Redefine to 1 if ! (HAVE_MBRTOWC && 1 < MB_LEN_MAX).
|
||||
(quotearg_buffer_restyled): If a unibyte locale, don't bother to
|
||||
invoke multibyte primitives.
|
||||
|
||||
2000-07-23 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* basename.c (base_name): Add an assertion.
|
||||
@@ -12,7 +139,7 @@
|
||||
* mbswidth.h: New file.
|
||||
* mbswidth.c: New file.
|
||||
* Makefile.am (libfetish_a_SOURCES): Add mbswidth.c.
|
||||
(noinst_HEADERS): Add mbswidth.h.
|
||||
(noinst_HEADERS): Add mbswidth.h.
|
||||
|
||||
2000-07-17 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
@@ -109,7 +236,7 @@
|
||||
2000-07-03 Paul Eggert <eggert@twinsun.com>
|
||||
and Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* lib/quotearg.c (mbrtowc):
|
||||
* quotearg.c (mbrtowc):
|
||||
Assign to *pwc, and return 1 only if result is nonzero.
|
||||
(iswprint): Use ISPRINT when substituting our own mbrtowc.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* addext.c -- add an extension to a file name
|
||||
Copyright (C) 1990, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* argmatch.c -- find a match for a string in an array
|
||||
Copyright (C) 1990, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* argmatch.h -- definitions and prototypes for argmatch.c
|
||||
Copyright (C) 1990, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* backupfile.h -- declarations for making Emacs style backup file names
|
||||
Copyright (C) 1990-1992, 1997-2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1992, 1997-1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -64,7 +64,7 @@ base_name (char const *name)
|
||||
--base;
|
||||
|
||||
/* Make sure the last byte is not a slash. */
|
||||
assert (all_slashes || *(p - 1) != '/');
|
||||
assert (all_slashes || !ISSLASH (*(p - 1)));
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
`-------------------------------------------------------------------------*/
|
||||
|
||||
/* Routines `xmalloc' and `xrealloc' are called to do the actual memory
|
||||
management. This implies that the program will abort with an `Memory
|
||||
exhausted!' error if any problem arise.
|
||||
management. This implies that the program will abort with a "memory
|
||||
exhausted" error if any problem arise.
|
||||
|
||||
To work correctly, at least EXPONENT and TYPE should always be the
|
||||
same for all uses of this macro for any given TABLE. A secure way to
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* provide consistent interface to chown for systems that don't interpret
|
||||
an ID of -1 as meaning `don't change the corresponding ID'.
|
||||
Copyright (C) 1997, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 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
|
||||
|
||||
@@ -38,7 +38,7 @@ const char diacrit_base[256] =
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||
'x', 'y', 'z', 0, 0, 0, 0, 0,
|
||||
|
||||
#ifdef MSDOS
|
||||
#ifdef __MSDOS__
|
||||
|
||||
'C', 'u', 'e', 'a', 'a', 'a', 'a', 'c',
|
||||
'e', 'e', 'e', 'i', 'i', 'i', 'A', 'A',
|
||||
@@ -57,7 +57,7 @@ const char diacrit_base[256] =
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
#else /* not MSDOS */
|
||||
#else
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -76,7 +76,7 @@ const char diacrit_base[256] =
|
||||
0, 'n', 'o', 'o', 'o', 'o', 'o', 0,
|
||||
'o', 'u', 'u', 'u', 'u', 'y', 0, 'y',
|
||||
|
||||
#endif /* not MSDOS */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------.
|
||||
@@ -106,7 +106,7 @@ const char diacrit_diac[256] =
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 6, 0,
|
||||
|
||||
#ifdef MSDOS
|
||||
#ifdef __MSDOS__
|
||||
|
||||
7, 5, 2, 4, 5, 3, 8, 7,
|
||||
4, 5, 3, 5, 4, 3, 5, 8,
|
||||
@@ -125,7 +125,7 @@ const char diacrit_diac[256] =
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
#else /* not MSDOS */
|
||||
#else
|
||||
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -144,5 +144,5 @@ const char diacrit_diac[256] =
|
||||
0, 6, 3, 2, 4, 6, 5, 0,
|
||||
9, 3, 2, 4, 5, 2, 0, 0,
|
||||
|
||||
#endif /* not MSDOS */
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Diacritics processing for a few character codes.
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
François Pinard <pinard@iro.umontreal.ca>, 1988.
|
||||
|
||||
All this file is a temporary hack, waiting for locales in GNU.
|
||||
@@ -13,4 +13,3 @@ extern const char diacrit_diac[]; /* diacritic code for each character */
|
||||
|
||||
/* Returns a diacritic code for CHAR. CHAR is known to be alphabetic. */
|
||||
#define todiac(Char) (diacrit_diac[(unsigned char) (Char)])
|
||||
|
||||
|
||||
@@ -32,9 +32,16 @@ char *malloc ();
|
||||
# define strrchr rindex
|
||||
# endif
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
#ifndef ISSLASH
|
||||
# define ISSLASH(C) ((C) == '/')
|
||||
#endif
|
||||
|
||||
#define BACKSLASH_IS_PATH_SEPARATOR ISSLASH ('\\')
|
||||
|
||||
/* Return the leading directories part of PATH,
|
||||
allocated with malloc. If out of memory, return 0.
|
||||
Assumes that trailing slashes have already been
|
||||
@@ -48,6 +55,19 @@ dir_name (const char *path)
|
||||
int length; /* Length of result, not including NUL. */
|
||||
|
||||
slash = strrchr (path, '/');
|
||||
if (BACKSLASH_IS_PATH_SEPARATOR)
|
||||
{
|
||||
char *b = strrchr (path, '\\');
|
||||
if (b && slash < b)
|
||||
slash = b;
|
||||
}
|
||||
|
||||
/* Make sure there are no trailing slashes. */
|
||||
assert (slash == NULL /* There are no slashes in PATH. */
|
||||
|| slash[1] != 0 /* There is a non-NUL byte after the last slash. */
|
||||
|| path == slash /* PATH is just `/'. */
|
||||
);
|
||||
|
||||
if (slash == 0)
|
||||
{
|
||||
/* File is in the current directory. */
|
||||
@@ -57,20 +77,25 @@ dir_name (const char *path)
|
||||
else
|
||||
{
|
||||
/* Remove any trailing slashes from the result. */
|
||||
#ifdef MSDOS
|
||||
char *lim = (path[0] >= 'A' && path[0] <= 'z' && path[1] == ':')
|
||||
? path + 2 : path;
|
||||
if (BACKSLASH_IS_PATH_SEPARATOR)
|
||||
{
|
||||
const char *lim = ((path[0] >= 'A' && path[0] <= 'z'
|
||||
&& path[1] == ':')
|
||||
? path + 2 : path);
|
||||
|
||||
/* If canonicalized "d:/path", leave alone the root case "d:/". */
|
||||
while (slash > lim && *slash == '/')
|
||||
--slash;
|
||||
#else
|
||||
while (slash > path && *slash == '/')
|
||||
--slash;
|
||||
#endif
|
||||
/* If canonicalized "d:/path", leave alone the root case "d:/". */
|
||||
while (slash > lim && ISSLASH (*slash))
|
||||
--slash;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (slash > path && ISSLASH (*slash))
|
||||
--slash;
|
||||
}
|
||||
|
||||
length = slash - path + 1;
|
||||
}
|
||||
|
||||
newpath = (char *) malloc (length + 1);
|
||||
if (newpath == 0)
|
||||
return 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Duplicate an open file descriptor to a specified file descriptor.
|
||||
Copyright 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* exclude.h -- declarations for excluding file names
|
||||
Copyright 1992, 1993, 1994, 1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright 1992, 1993, 1994, 1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Convert file size to number of blocks on System V-like machines.
|
||||
Copyright (C) 1990, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1992, 1993, 1996, 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1993, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1992, 1993 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* fsusage.c -- return space usage of mounted filesystems
|
||||
Copyright (C) 1991, 1992, 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 1996, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* fsusage.h -- declarations for filesystem space usage info
|
||||
Copyright (C) 1991, 1992, 1997, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* provide consistent interface to getgroups for systems that don't allow N==0
|
||||
Copyright (C) 1996, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1996, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* gethostname emulation for SysV and POSIX.1.
|
||||
Copyright (C) 1992, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989,90,91,92,93,94,96,97,1998,2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@gnu.org.
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* group-member.c -- determine whether group id is in calling user's group list
|
||||
Copyright (C) 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* hard-locale.c -- Determine whether a locale is hard.
|
||||
Copyright 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* hash - hashing table processing.
|
||||
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Written by Jim Meyering <meyering@ascend.com>, 1998.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* isdir.c -- determine whether a directory exists
|
||||
Copyright (C) 1990, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Provide a stub lchown function for systems that lack it.
|
||||
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* linebuffer.c -- read arbitrarily long lines
|
||||
Copyright (C) 1986, 1991, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1986, 1991, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* linebuffer.h -- declarations for reading arbitrarily long lines
|
||||
Copyright (C) 1986, 1991, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1986, 1991, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* long-options.h -- declaration for --help- and --version-handling function.
|
||||
Copyright (C) 1993, 1994, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -370,7 +370,7 @@ make_path (const char *argpath,
|
||||
umask (oldmask);
|
||||
|
||||
if (verbose_fmt_string != NULL)
|
||||
error (0, 0, verbose_fmt_string, dirpath);
|
||||
error (0, 0, verbose_fmt_string, quote (dirpath));
|
||||
|
||||
if (owner != (uid_t) -1 || group != (gid_t) -1)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Work around bug on some systems where malloc (0) fails.
|
||||
Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -21,11 +21,6 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Tell GNU libc to declare wcwidth(). */
|
||||
#ifndef _XOPEN_SOURCE
|
||||
# define _XOPEN_SOURCE 500
|
||||
#endif
|
||||
|
||||
/* Get MB_LEN_MAX. */
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
@@ -62,10 +57,19 @@
|
||||
# define mbsinit(ps) 1
|
||||
#endif
|
||||
|
||||
/* If wcwidth() doesn't exist, assume all printable characters have
|
||||
#ifndef HAVE_DECL_WCWIDTH
|
||||
"this configure-time declaration test was not run"
|
||||
#endif
|
||||
#if !HAVE_DECL_WCWIDTH
|
||||
int wcwidth ();
|
||||
#endif
|
||||
|
||||
#ifndef wcwidth
|
||||
# if !HAVE_WCWIDTH
|
||||
/* wcwidth doesn't exist, so assume all printable characters have
|
||||
width 1. */
|
||||
#if !defined wcwidth && !HAVE_WCWIDTH
|
||||
# define wcwidth(wc) ((wc) == 0 ? 0 : iswprint (wc) ? 1 : -1)
|
||||
# define wcwidth(wc) ((wc) == 0 ? 0 : iswprint (wc) ? 1 : -1)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Get ISPRINT. */
|
||||
@@ -80,15 +84,27 @@
|
||||
#undef ISPRINT
|
||||
#define ISPRINT(c) (ISASCII (c) && isprint (c))
|
||||
|
||||
#include "mbswidth.h"
|
||||
|
||||
/* Returns the number of columns needed to represent the multibyte
|
||||
character string pointed to by STRING. If a non-printable character
|
||||
occurs, -1 is returned.
|
||||
This is the multibyte analogon of the wcswidth function. */
|
||||
occurs, -1 is returned, unless MBSW_ACCEPT_UNPRINTABLE is specified.
|
||||
With flags = 0, this is the multibyte analogon of the wcswidth function. */
|
||||
int
|
||||
mbswidth (const char *string)
|
||||
mbswidth (const char *string, int flags)
|
||||
{
|
||||
return mbsnwidth (string, strlen (string), flags);
|
||||
}
|
||||
|
||||
/* Returns the number of columns needed to represent the multibyte
|
||||
character string pointed to by STRING of length NBYTES. If a
|
||||
non-printable character occurs, -1 is returned, unless
|
||||
MBSW_ACCEPT_UNPRINTABLE is specified. */
|
||||
int
|
||||
mbsnwidth (const char *string, size_t nbytes, int flags)
|
||||
{
|
||||
const char *p = string;
|
||||
const char *plimit = p + strlen (p);
|
||||
const char *plimit = p + nbytes;
|
||||
int width;
|
||||
|
||||
width = 0;
|
||||
@@ -122,8 +138,6 @@ mbswidth (const char *string)
|
||||
p++;
|
||||
width++;
|
||||
break;
|
||||
case '\0':
|
||||
break;
|
||||
default:
|
||||
/* If we have a multibyte sequence, scan it up to its end. */
|
||||
{
|
||||
@@ -132,20 +146,32 @@ mbswidth (const char *string)
|
||||
do
|
||||
{
|
||||
wchar_t wc;
|
||||
size_t bytes = mbrtowc (&wc, p, plimit - p, &mbstate);
|
||||
size_t bytes;
|
||||
int w;
|
||||
|
||||
if (bytes == 0)
|
||||
/* A null wide character was encountered. */
|
||||
break;
|
||||
bytes = mbrtowc (&wc, p, plimit - p, &mbstate);
|
||||
|
||||
if (bytes == (size_t) -1)
|
||||
/* An invalid multibyte sequence was encountered. */
|
||||
return -1;
|
||||
{
|
||||
if (flags & MBSW_ACCEPT_INVALID)
|
||||
break;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bytes == (size_t) -2)
|
||||
/* An incomplete multibyte character at the end. */
|
||||
return -1;
|
||||
{
|
||||
if (flags & MBSW_ACCEPT_INVALID)
|
||||
break;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bytes == 0)
|
||||
/* A null wide character was encountered. */
|
||||
bytes = 1;
|
||||
|
||||
w = wcwidth (wc);
|
||||
if (w >= 0)
|
||||
@@ -153,7 +179,10 @@ mbswidth (const char *string)
|
||||
width += w;
|
||||
else
|
||||
/* An unprintable multibyte character. */
|
||||
return -1;
|
||||
if (flags & MBSW_ACCEPT_UNPRINTABLE)
|
||||
width += 1;
|
||||
else
|
||||
return -1;
|
||||
|
||||
p += bytes;
|
||||
}
|
||||
@@ -169,10 +198,7 @@ mbswidth (const char *string)
|
||||
{
|
||||
unsigned char c = (unsigned char) *p++;
|
||||
|
||||
if (c == '\0')
|
||||
break;
|
||||
|
||||
if (ISPRINT (c))
|
||||
if ((flags & MBSW_ACCEPT_UNPRINTABLE) || ISPRINT (c))
|
||||
width++;
|
||||
else
|
||||
return -1;
|
||||
|
||||
@@ -23,4 +23,19 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern int mbswidth PARAMS ((const char *string));
|
||||
/* Optional flags to influence mbswidth/mbsnwidth behavior. */
|
||||
|
||||
/* If this bit is set, assume invalid characters have width 0.
|
||||
Otherwise, return -1 upon finding an invalid or incomplete character. */
|
||||
#define MBSW_ACCEPT_INVALID 1
|
||||
|
||||
/* If this bit is set, assume unprintable characters have width 1.
|
||||
Otherwise, return -1 upon finding a non-printable character. */
|
||||
#define MBSW_ACCEPT_UNPRINTABLE 2
|
||||
|
||||
/* Returns the number of screen columns needed for STRING. */
|
||||
extern int mbswidth PARAMS ((const char *string, int flags));
|
||||
|
||||
/* Returns the number of screen columns needed for the NBYTES bytes
|
||||
starting at BUF. */
|
||||
extern int mbsnwidth PARAMS ((const char *buf, size_t nbytes, int flags));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
|
||||
according to the definition of MD5 in RFC 1321 from April 1992.
|
||||
Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996 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.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* md5.h - Declaration of functions and data types used for MD5 sum
|
||||
computing library functions.
|
||||
Copyright (C) 1995, 1996, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C
|
||||
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1993, 1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1993, 1997, 1999 Free Software Foundation, Inc.
|
||||
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
|
||||
with help from Dan Sahlin (dan@sics.se) and
|
||||
commentary by Jim Blandy (jimb@ai.mit.edu);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1993, 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1993, 1995, 1997, 1998 Free Software Foundation, Inc.
|
||||
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Locale-specific memory comparison.
|
||||
Copyright 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* memset.c -- set an area of memory to a given value
|
||||
Copyright (C) 1991, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Convert a `struct tm' to a time_t value.
|
||||
Copyright (C) 1993, 94, 95, 96, 97, 98, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Paul Eggert (eggert@twinsun.com).
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* modechange.h -- definitions for file mode manipulation
|
||||
Copyright (C) 1989, 1990, 1997, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989, 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* obstack.h - object stack macros
|
||||
Copyright (C) 1988,89,90,91,92,93,94,96,97,98,1999,2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc.
|
||||
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Define PATH_MAX somehow. Requires sys/types.h.
|
||||
Copyright (C) 1992, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
110
lib/quotearg.c
110
lib/quotearg.c
@@ -70,6 +70,11 @@ size_t mbrtowc ();
|
||||
# define mbsinit(ps) 1
|
||||
# endif
|
||||
#else
|
||||
/* Disable multibyte processing entirely. Since MB_CUR_MAX is 1, the
|
||||
other macros are defined only for documentation and to satisfy C
|
||||
syntax. */
|
||||
# undef MB_CUR_MAX
|
||||
# define MB_CUR_MAX 1
|
||||
# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
|
||||
# define mbsinit(ps) 1
|
||||
# define iswprint(wc) ISPRINT ((unsigned char) (wc))
|
||||
@@ -213,6 +218,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
||||
char const *quote_string = 0;
|
||||
size_t quote_string_len = 0;
|
||||
int backslash_escapes = 0;
|
||||
int unibyte_locale = MB_CUR_MAX == 1;
|
||||
|
||||
#define STORE(c) \
|
||||
do \
|
||||
@@ -398,57 +404,59 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
||||
we can't easily escape single characters within it. */
|
||||
{
|
||||
/* Length of multibyte sequence found so far. */
|
||||
size_t m = 0;
|
||||
size_t m;
|
||||
|
||||
int printable = 1;
|
||||
mbstate_t mbstate;
|
||||
memset (&mbstate, 0, sizeof mbstate);
|
||||
int printable;
|
||||
|
||||
if (argsize == (size_t) -1)
|
||||
argsize = strlen (arg);
|
||||
|
||||
do
|
||||
if (unibyte_locale)
|
||||
{
|
||||
wchar_t w;
|
||||
size_t bytes = mbrtowc (&w, &arg[i + m],
|
||||
argsize - (i + m), &mbstate);
|
||||
if (bytes == 0)
|
||||
break;
|
||||
else if (bytes == (size_t) -1)
|
||||
{
|
||||
printable = 0;
|
||||
break;
|
||||
}
|
||||
else if (bytes == (size_t) -2)
|
||||
{
|
||||
printable = 0;
|
||||
while (i + m < argsize && arg[i + m])
|
||||
m++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! iswprint (w))
|
||||
printable = 0;
|
||||
m += bytes;
|
||||
}
|
||||
m = 1;
|
||||
printable = ISPRINT (c);
|
||||
}
|
||||
while (! mbsinit (&mbstate));
|
||||
|
||||
if (m <= 1)
|
||||
else
|
||||
{
|
||||
/* Escape a unibyte character like a multibyte
|
||||
sequence if using backslash escapes, and if the
|
||||
character is not printable. */
|
||||
m = backslash_escapes && ! ISPRINT (c);
|
||||
printable = 0;
|
||||
mbstate_t mbstate;
|
||||
memset (&mbstate, 0, sizeof mbstate);
|
||||
|
||||
m = 0;
|
||||
printable = 1;
|
||||
if (argsize == (size_t) -1)
|
||||
argsize = strlen (arg);
|
||||
|
||||
do
|
||||
{
|
||||
wchar_t w;
|
||||
size_t bytes = mbrtowc (&w, &arg[i + m],
|
||||
argsize - (i + m), &mbstate);
|
||||
if (bytes == 0)
|
||||
break;
|
||||
else if (bytes == (size_t) -1)
|
||||
{
|
||||
printable = 0;
|
||||
break;
|
||||
}
|
||||
else if (bytes == (size_t) -2)
|
||||
{
|
||||
printable = 0;
|
||||
while (i + m < argsize && arg[i + m])
|
||||
m++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! iswprint (w))
|
||||
printable = 0;
|
||||
m += bytes;
|
||||
}
|
||||
}
|
||||
while (! mbsinit (&mbstate));
|
||||
}
|
||||
|
||||
if (m)
|
||||
if (1 < m || (backslash_escapes && ! printable))
|
||||
{
|
||||
/* Output a multibyte sequence, or an escaped
|
||||
unprintable unibyte character. */
|
||||
size_t imax = i + m - 1;
|
||||
size_t ilim = i + m;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -459,7 +467,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
||||
STORE ('0' + ((c >> 3) & 7));
|
||||
c = '0' + (c & 7);
|
||||
}
|
||||
if (i == imax)
|
||||
if (ilim <= i + 1)
|
||||
break;
|
||||
STORE (c);
|
||||
c = arg[++i];
|
||||
@@ -522,12 +530,17 @@ static char *
|
||||
quotearg_n_options (int n, char const *arg,
|
||||
struct quoting_options const *options)
|
||||
{
|
||||
static unsigned int nslots;
|
||||
static struct slotvec
|
||||
/* Preallocate a slot 0 buffer, so that the caller can always quote
|
||||
one small component of a "memory exhausted" message in slot 0. */
|
||||
static char slot0[256];
|
||||
static unsigned int nslots = 1;
|
||||
struct slotvec
|
||||
{
|
||||
size_t size;
|
||||
char *val;
|
||||
} *slotvec;
|
||||
};
|
||||
static struct slotvec slotvec0 = {sizeof slot0, slot0};
|
||||
static struct slotvec *slotvec = &slotvec0;
|
||||
|
||||
if (nslots <= n)
|
||||
{
|
||||
@@ -535,6 +548,11 @@ quotearg_n_options (int n, char const *arg,
|
||||
size_t s = n1 * sizeof (struct slotvec);
|
||||
if (! (0 < n1 && n1 == s / sizeof (struct slotvec)))
|
||||
abort ();
|
||||
if (slotvec == &slotvec0)
|
||||
{
|
||||
slotvec = (struct slotvec *) xmalloc (sizeof (struct slotvec));
|
||||
*slotvec = slotvec0;
|
||||
}
|
||||
slotvec = (struct slotvec *) xrealloc (slotvec, s);
|
||||
memset (slotvec + nslots, 0, (n1 - nslots) * sizeof (struct slotvec));
|
||||
nslots = n;
|
||||
@@ -548,7 +566,7 @@ quotearg_n_options (int n, char const *arg,
|
||||
if (size <= qsize)
|
||||
{
|
||||
slotvec[n].size = size = qsize + 1;
|
||||
slotvec[n].val = val = xrealloc (val, size);
|
||||
slotvec[n].val = val = xrealloc (val == slot0 ? 0 : val, size);
|
||||
quotearg_buffer (val, size, arg, (size_t) -1, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Work around bug on some systems where realloc (NULL, 0) fails.
|
||||
Copyright (C) 1997, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 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
|
||||
|
||||
44
lib/regex.c
44
lib/regex.c
@@ -1747,29 +1747,51 @@ static reg_errcode_t compile_range _RE_ARGS ((unsigned int range_start,
|
||||
reset the pointers that pointed into the old block to point to the
|
||||
correct places in the new one. If extending the buffer results in it
|
||||
being larger than MAX_BUF_SIZE, then flag memory exhausted. */
|
||||
#if __BOUNDED_POINTERS__
|
||||
# define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated)
|
||||
# define MOVE_BUFFER_POINTER(P) \
|
||||
(__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr)
|
||||
# define ELSE_EXTEND_BUFFER_HIGH_BOUND \
|
||||
else \
|
||||
{ \
|
||||
SET_HIGH_BOUND (b); \
|
||||
SET_HIGH_BOUND (begalt); \
|
||||
if (fixup_alt_jump) \
|
||||
SET_HIGH_BOUND (fixup_alt_jump); \
|
||||
if (laststart) \
|
||||
SET_HIGH_BOUND (laststart); \
|
||||
if (pending_exact) \
|
||||
SET_HIGH_BOUND (pending_exact); \
|
||||
}
|
||||
#else
|
||||
# define MOVE_BUFFER_POINTER(P) (P) += incr
|
||||
# define ELSE_EXTEND_BUFFER_HIGH_BOUND
|
||||
#endif
|
||||
#define EXTEND_BUFFER() \
|
||||
do { \
|
||||
do { \
|
||||
unsigned char *old_buffer = bufp->buffer; \
|
||||
if (bufp->allocated == MAX_BUF_SIZE) \
|
||||
if (bufp->allocated == MAX_BUF_SIZE) \
|
||||
return REG_ESIZE; \
|
||||
bufp->allocated <<= 1; \
|
||||
if (bufp->allocated > MAX_BUF_SIZE) \
|
||||
bufp->allocated = MAX_BUF_SIZE; \
|
||||
bufp->allocated = MAX_BUF_SIZE; \
|
||||
bufp->buffer = (unsigned char *) REALLOC (bufp->buffer, bufp->allocated);\
|
||||
if (bufp->buffer == NULL) \
|
||||
return REG_ESPACE; \
|
||||
/* If the buffer moved, move all the pointers into it. */ \
|
||||
if (old_buffer != bufp->buffer) \
|
||||
{ \
|
||||
b = (b - old_buffer) + bufp->buffer; \
|
||||
begalt = (begalt - old_buffer) + bufp->buffer; \
|
||||
if (fixup_alt_jump) \
|
||||
fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\
|
||||
if (laststart) \
|
||||
laststart = (laststart - old_buffer) + bufp->buffer; \
|
||||
if (pending_exact) \
|
||||
pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
|
||||
int incr = bufp->buffer - old_buffer; \
|
||||
MOVE_BUFFER_POINTER (b); \
|
||||
MOVE_BUFFER_POINTER (begalt); \
|
||||
if (fixup_alt_jump) \
|
||||
MOVE_BUFFER_POINTER (fixup_alt_jump); \
|
||||
if (laststart) \
|
||||
MOVE_BUFFER_POINTER (laststart); \
|
||||
if (pending_exact) \
|
||||
MOVE_BUFFER_POINTER (pending_exact); \
|
||||
} \
|
||||
ELSE_EXTEND_BUFFER_HIGH_BOUND \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* BSD compatible remove directory function for System V
|
||||
Copyright (C) 1988, 1990, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988, 1990 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* safe-read.c -- an interface to read that retries after interrupts
|
||||
Copyright (C) 1993, 1994, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1994, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -45,6 +45,7 @@ extern int errno;
|
||||
#include "same.h"
|
||||
#include "dirname.h"
|
||||
#include "error.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
@@ -81,7 +82,7 @@ same_name (const char *source, const char *dest)
|
||||
source_dirname = dir_name (source);
|
||||
dest_dirname = dir_name (dest);
|
||||
if (source_dirname == NULL || dest_dirname == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
xalloc_die ();
|
||||
|
||||
if (stat (source_dirname, &source_dir_stats))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* save-cwd.c -- Save and restore current working directory.
|
||||
Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* stime -- set the system clock
|
||||
Copyright (C) 1989, 1991, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1989, 1991 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* stpcpy.c -- copy a string and return pointer to end of new string
|
||||
Copyright (C) 1992, 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 1995, 1997, 1998 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* strcasecmp.c -- case insensitive string comparator
|
||||
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1994, 1996, 1997, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1994, 1996, 1997 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* strdup.c -- return a newly allocated copy of a string
|
||||
Copyright (C) 1990, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* stripslash.c -- remove trailing slashes from a string
|
||||
Copyright (C) 1990, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1994, 1999, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1994, 1999 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1992, 1997, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Convert string representation of a number into an integer value.
|
||||
Copyright (C) 1991, 92, 94, 95, 96, 97, 98, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 92, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C
|
||||
Library. Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1999, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Function to parse an `unsigned long long int' from text.
|
||||
Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
|
||||
NOTE: The canonical source of this file is maintained with the GNU C
|
||||
Library. Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Convert string representation of a number into an uintmax_t value.
|
||||
Copyright 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -57,6 +57,8 @@ char *alloca ();
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "xalloc.h"
|
||||
|
||||
#if ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# define _(Text) gettext (Text)
|
||||
@@ -137,7 +139,6 @@ const char *
|
||||
parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
|
||||
char **username_arg, char **groupname_arg)
|
||||
{
|
||||
static const char *E_no_memory = N_("virtual memory exhausted");
|
||||
static const char *E_invalid_user = N_("invalid user");
|
||||
static const char *E_invalid_group = N_("invalid group");
|
||||
static const char *E_bad_spec =
|
||||
@@ -210,13 +211,13 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
|
||||
{
|
||||
|
||||
if (!is_number (u))
|
||||
error_msg = _(E_invalid_user);
|
||||
error_msg = E_invalid_user;
|
||||
else
|
||||
{
|
||||
int use_login_group;
|
||||
use_login_group = (separator != NULL && g == NULL);
|
||||
if (use_login_group)
|
||||
error_msg = _(E_bad_spec);
|
||||
error_msg = E_bad_spec;
|
||||
else
|
||||
{
|
||||
/* FIXME: don't use atoi! */
|
||||
@@ -259,7 +260,7 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
|
||||
if (grp == NULL)
|
||||
{
|
||||
if (!is_number (g))
|
||||
error_msg = _(E_invalid_group);
|
||||
error_msg = E_invalid_group;
|
||||
else
|
||||
{
|
||||
/* FIXME: don't use atoi! */
|
||||
@@ -280,7 +281,7 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
|
||||
{
|
||||
*username_arg = strdup (u);
|
||||
if (*username_arg == NULL)
|
||||
error_msg = _(E_no_memory);
|
||||
error_msg = xalloc_msg_memory_exhausted;
|
||||
}
|
||||
|
||||
if (groupname != NULL && error_msg == NULL)
|
||||
@@ -293,7 +294,7 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
|
||||
free (*username_arg);
|
||||
*username_arg = NULL;
|
||||
}
|
||||
error_msg = _(E_no_memory);
|
||||
error_msg = xalloc_msg_memory_exhausted;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,7 +307,7 @@ parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
|
||||
goto retry;
|
||||
}
|
||||
|
||||
return error_msg;
|
||||
return _(error_msg);
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Utility to help print --version output in a consistent format.
|
||||
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* xalloc.h -- malloc with out-of-memory checking
|
||||
Copyright (C) 1990-1998, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1998, 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -46,9 +46,9 @@ extern int xalloc_exit_failure;
|
||||
extern void (*xalloc_fail_func) PARAMS ((void));
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this
|
||||
message must be non-NULL. It is translated via gettext.
|
||||
The default value is "Memory exhausted". */
|
||||
extern char *const xalloc_msg_memory_exhausted;
|
||||
message is output. It is translated via gettext.
|
||||
Its value is "memory exhausted". */
|
||||
extern char const xalloc_msg_memory_exhausted[];
|
||||
|
||||
/* This function is always triggered when memory is exhausted. It is
|
||||
in charge of honoring the three previous items. This is the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
Copyright (C) 1990-1997, 98, 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1999, 2000 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -63,7 +63,7 @@ void (*xalloc_fail_func) PARAMS ((void)) = 0;
|
||||
|
||||
/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message
|
||||
before exiting when memory is exhausted. Goes through gettext. */
|
||||
char *const xalloc_msg_memory_exhausted = N_("Memory exhausted");
|
||||
char const xalloc_msg_memory_exhausted[] = N_("memory exhausted");
|
||||
|
||||
void
|
||||
xalloc_die (void)
|
||||
@@ -91,8 +91,7 @@ xmalloc (size_t n)
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking.
|
||||
If P is NULL, run xmalloc. */
|
||||
with error checking. */
|
||||
|
||||
void *
|
||||
xrealloc (void *p, size_t n)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* xstrdup.c -- copy a string with out of memory checking
|
||||
Copyright (C) 1990, 1996, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1996, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* xstrtoumax.c -- A more useful interface to strtoumax.
|
||||
Copyright 1999, 2000 Free Software Foundation, Inc.
|
||||
Copyright 1999 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* yesno.c -- read a yes/no response from stdin
|
||||
Copyright (C) 1990, 1998, 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
22
m4/ChangeLog
22
m4/ChangeLog
@@ -1,3 +1,25 @@
|
||||
2000-08-20 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* check-decl.m4: Include utmp.h `#if HAVE_UTMP_H', rather than
|
||||
`#if !HAVE_UTMPX_H'. The latter would lose on systems with neither
|
||||
utmp.h nor utmpx.h. Reported by Eli Zaretskii.
|
||||
|
||||
2000-08-11 J. David Anglin <dave@hiauly1.hia.nrc.ca>
|
||||
|
||||
Improve fileutils installation on systems where running
|
||||
programs (like install) can't be unlinked.
|
||||
* unlink-busy.m4 (jm_FUNC_UNLINK_BUSY_TEXT): New file/macro.
|
||||
* jm-macros.m4: Use jm_FUNC_UNLINK_BUSY_TEXT.
|
||||
|
||||
2000-08-06 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* m4/mbstate_t.m4 (AC_MBSTATE_T): Define mbstate_t to be int,
|
||||
not char, for compatibility with glibc 2.1.3 strftime.c.
|
||||
|
||||
2000-07-23 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* mbswidth.m4 (jm_PREREQ_MBSWIDTH): Check for wcwidth declaration.
|
||||
|
||||
2000-07-23 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* check-decl.m4 (jm_CHECK_DECLS): Check for declarations of these, too:
|
||||
|
||||
@@ -60,6 +60,7 @@ strftime.m4 \
|
||||
timespec.m4 \
|
||||
uintmax_t.m4 \
|
||||
ulonglong.m4 \
|
||||
unlink-busy.m4 \
|
||||
uptime.m4 \
|
||||
utimbuf.m4 \
|
||||
utime.m4 \
|
||||
|
||||
@@ -174,6 +174,7 @@ strftime.m4 \
|
||||
timespec.m4 \
|
||||
uintmax_t.m4 \
|
||||
ulonglong.m4 \
|
||||
unlink-busy.m4 \
|
||||
uptime.m4 \
|
||||
utimbuf.m4 \
|
||||
utime.m4 \
|
||||
|
||||
@@ -38,7 +38,7 @@ AC_DEFUN(jm_CHECK_DECLS,
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !HAVE_UTMPX_H
|
||||
#if HAVE_UTMP_H
|
||||
# include <utmp.h>
|
||||
#endif
|
||||
'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 24
|
||||
#serial 25
|
||||
|
||||
dnl Misc type-related macros for fileutils, sh-utils, textutils.
|
||||
|
||||
@@ -209,6 +209,7 @@ AC_DEFUN(jm_MACROS,
|
||||
jm_LANGINFO_CODESET
|
||||
jm_GLIBC21
|
||||
jm_ICONV
|
||||
jm_FUNC_UNLINK_BUSY_TEXT
|
||||
|
||||
# These tests are for df.
|
||||
jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# serial 7
|
||||
# serial 8
|
||||
|
||||
# From Paul Eggert.
|
||||
|
||||
@@ -24,6 +24,6 @@ AC_DEFUN(AC_MBSTATE_T,
|
||||
ac_cv_type_mbstate_t=yes,
|
||||
ac_cv_type_mbstate_t=no)])
|
||||
if test $ac_cv_type_mbstate_t = no; then
|
||||
AC_DEFINE(mbstate_t, char,
|
||||
AC_DEFINE(mbstate_t, int,
|
||||
[Define to a type if <wchar.h> does not define.])
|
||||
fi])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 1
|
||||
#serial 2
|
||||
|
||||
dnl autoconf tests required for use of mbswidth.c
|
||||
dnl From Bruno Haible.
|
||||
@@ -9,5 +9,11 @@ AC_DEFUN(jm_PREREQ_MBSWIDTH,
|
||||
AC_REQUIRE([AM_C_PROTOTYPES])
|
||||
AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
|
||||
AC_CHECK_FUNCS(isascii iswprint mbrtowc wcwidth)
|
||||
headers='
|
||||
# if HAVE_WCHAR_H
|
||||
# include <wchar.h>
|
||||
# endif
|
||||
'
|
||||
AC_CHECK_DECLS([wcwidth], , , $headers)
|
||||
AC_MBSTATE_T
|
||||
])
|
||||
|
||||
32
m4/unlink-busy.m4
Normal file
32
m4/unlink-busy.m4
Normal file
@@ -0,0 +1,32 @@
|
||||
#serial 5
|
||||
|
||||
dnl From J. David Anglin.
|
||||
|
||||
dnl HPUX and other systems can't unlink shared text that is being executed.
|
||||
|
||||
AC_DEFUN(jm_FUNC_UNLINK_BUSY_TEXT,
|
||||
[dnl
|
||||
AC_CACHE_CHECK([whether a running program can be unlinked],
|
||||
jm_cv_func_unlink_busy_text,
|
||||
[
|
||||
AC_TRY_RUN([
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
if (!argc)
|
||||
exit (-1);
|
||||
exit (unlink (argv[0]));
|
||||
}
|
||||
],
|
||||
jm_cv_func_unlink_busy_text=yes,
|
||||
jm_cv_func_unlink_busy_text=no,
|
||||
jm_cv_func_unlink_busy_text=no
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
if test $jm_cv_func_unlink_busy_text = no; then
|
||||
INSTALL=$ac_install_sh
|
||||
fi
|
||||
])
|
||||
@@ -1,3 +1,218 @@
|
||||
2000-08-20 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0y.
|
||||
|
||||
Add support for cp's new POSIX-mandated -H and -L options.
|
||||
* src/copy.h (enum Dereference_symlink): Define.
|
||||
(struct cp_options) [dereference]: Change type to Dereference_symlink.
|
||||
* src/copy.c: Declare lstat.
|
||||
(copy_dir): Set `xstat' member to lstat so that with `-H' we don't
|
||||
follow symlinks found via recursive traversal.
|
||||
Update uses of `dereference' to compare against new enum member names.
|
||||
* src/cp.c (long_opts): Add --dereference, -L.
|
||||
(usage): Describe -L and -H.
|
||||
(cp_option_init): Initialize to DEREF_UNDEFINED, not `1'.
|
||||
(main): Add `H' and `-L' to getopt spec string.
|
||||
[case 'a']: Initialize `dereference' to DEREF_NEVER, not 0.
|
||||
[case 'd']: Likewise.
|
||||
[case 'H']: New case.
|
||||
[case 'L']: New case.
|
||||
[case 'R']: Don't set dereference to `0' here.
|
||||
If it's not yet defined, set x.dereference to DEREF_NEVER
|
||||
if -R was specified, else set it to DEREF_ALWAYS.
|
||||
Set x.xstat accordingly for -H.
|
||||
* doc/fileutils.texi (cp invocation): Describe -H and -L.
|
||||
* src/mv.c (cp_option_init): Initialize to DEREF_NEVER, not `0'.
|
||||
* src/install.c (cp_option_init): Initialize to DEREF_ALWAYS, not `1'.
|
||||
|
||||
* tests/cp/Makefile.am (TESTS): Add cp-HL.
|
||||
* tests/cp/cp-HL: New test.
|
||||
|
||||
* src/du.c (print_totals): Rename global from opt_combined_arguments.
|
||||
|
||||
2000-08-17 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/copy.c (DO_CHOWN): Do not make a special case for non-root.
|
||||
POSIX.2 requires that cp -p and mv attempt to set the uid of the
|
||||
destination file, even if you're not root. This affects behavior
|
||||
only on hosts that let you give files away via chmod.
|
||||
* NEWS: Describe the above change.
|
||||
|
||||
2000-08-15 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/du.c (count_entry): Remember the current directory also for `.'
|
||||
and `..'. Reported by Stephen Smoogen, based on a patch from H.J. Lu.
|
||||
* tests/du/two-args: Add tests for this.
|
||||
|
||||
2000-08-14 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/copy.c (copy_reg): Move declaration of local, `n_read', into
|
||||
the scope where it's used.
|
||||
(copy_internal): In calling copy_reg, pass not the raw `src_mode',
|
||||
but the possibly-umask-relative mode, `get_dest_mode (x, src_mode)'.
|
||||
|
||||
2000-08-13 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/copy.c (get_dest_mode): Rename from new_nondir_mode.
|
||||
Honor the umask for `cp', but not for `mv' or `cp -p'.
|
||||
(copy_reg): New 4th parameter, dst_mode. Pass it as 3rd arg. to open.
|
||||
(copy_internal): Change type of locals `src_mode' and `src_type' from
|
||||
int to mode_t.
|
||||
Remove unnecessary local, `fix_mode'.
|
||||
Combine two if-stmts into one.
|
||||
Pass `src_mode' as 4th arg to copy_reg.
|
||||
If we've just created a new regular file, return early, skipping the
|
||||
chmod step. copy_reg now sets permissions of such files upon creation.
|
||||
Use get_dest_mode, so there's just one chmod call here.
|
||||
|
||||
* tests/cp/Makefile.am (TESTS): Add perm.
|
||||
* tests/cp/perm: New tests, to help ensure the above didn't
|
||||
change anything.
|
||||
|
||||
2000-08-12 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/mv/into-self-2: Remove test for the VERSION_CONTROL and/or
|
||||
SIMPLE_BACKUP_SUFFIX envvars. Source ../envvar-check instead.
|
||||
* tests/mv/i-2: Likewise.
|
||||
* tests/mv/to-symlink: Likewise.
|
||||
* tests/cp/slink-2-slink: Likewise.
|
||||
* tests/mv/partition-perm: Likewise.
|
||||
* tests/cp/cp-mv-backup: Likewise.
|
||||
|
||||
* tests/Makefile.am (EXTRA_DIST): Add envvar-check.
|
||||
* tests/envvar-check: New file.
|
||||
|
||||
* install-sh: Remove trailing blanks.
|
||||
Output diagnostics to stderr, not stdout.
|
||||
Remove many useless curly braces and double quotes.
|
||||
|
||||
2000-08-11 J. David Anglin <dave@hiauly1.hia.nrc.ca>
|
||||
|
||||
* install-sh: Improve error handling.
|
||||
Do the job even when the target file is `busy' on systems
|
||||
that don't allow such files to be unlinked.
|
||||
|
||||
2000-08-12 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* README: Remove note about how installation can fail and the
|
||||
work-around, now that it's all automated.
|
||||
|
||||
2000-08-07 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/cp.c (usage, main): For cp -P messages, mention the new
|
||||
behavior as well as the old.
|
||||
|
||||
2000-08-07 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
Standardize on "memory exhausted" instead of "Memory exhausted"
|
||||
or "virtual memory exhausted".
|
||||
Invoke xalloc_die instead of printing our own message.
|
||||
* src/chmod.c (main): Likewise.
|
||||
* src/copy.c (copy_dir, copy_internal): Likewise.
|
||||
* src/cp.c (do_copy): Likewise.
|
||||
* src/dircolors.c (xstrndup): Likewise.
|
||||
* src/install.c (main): Likewise.
|
||||
* src/ln.c (do_link): Likewise.
|
||||
* src/mkdir.c (main): Likewise.
|
||||
* src/mkfifo.c (main): Likewise.
|
||||
* src/mknod.c (main): Likewise.
|
||||
* src/mv.c (movefile): Likewise.
|
||||
* src/remove.c (remove_cwd_entries, rm): Likewise.
|
||||
* src/shred.c (quotearg_colon, xmalloc):
|
||||
"virtual memory exhausted" -> "memory exhausted"
|
||||
|
||||
2000-08-07 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/cp.c (enum) [PARENTS_OPTION]: New member.
|
||||
(long_opts): Update "parents" and deprecated "path" entries to use
|
||||
`PARENTS_OPTION', not `P'.
|
||||
(usage): Update --help output.
|
||||
(main): Warn that the meaning of `-P' will soon change.
|
||||
|
||||
2000-08-06 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* doc/fileutils.texi (cp invocation) [-r]: Remove inaccurate mention of
|
||||
`non-symbolic links'.
|
||||
|
||||
2000-08-05 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* config.guess: Update from master repository.
|
||||
* config.sub: Likewise.
|
||||
|
||||
* Regenerate build/config framework to use the latest CVS versions
|
||||
of automake and autoconf.
|
||||
|
||||
2000-07-31 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/shred.c [!HAVE_CONFIG_H]: Use `virtual memory exhausted', not
|
||||
`Memory exhausted'.
|
||||
|
||||
2000-07-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/sys2.h (ISPRINT): Undef before defining to avoid warning.
|
||||
|
||||
* src/copy.c (copy_internal): Quote the file names that are displayed
|
||||
with --verbose and --backup.
|
||||
* src/remove.c (remove_file): Quote the file names that are displayed
|
||||
with --verbose.
|
||||
(remove_dir): Likewise.
|
||||
* tests/mv/mv-special-1: Add quote marks to match new behavior.
|
||||
* tests/rm/r-1: Likewise.
|
||||
* tests/rm/r-2: Likewise.
|
||||
|
||||
* src/df.c: Convert "`%s'" in format strings to "%s", and wrap each
|
||||
corresponding argument in a `quote (...)' call.
|
||||
* src/dircolors.c: Likewise.
|
||||
* src/du.c: Likewise.
|
||||
* src/mkdir.c: Likewise.
|
||||
* src/mkfifo.c: Likewise.
|
||||
* src/mknod.c: Likewise.
|
||||
* src/shred.c: Likewise.
|
||||
* src/rmdir.c: Likewise.
|
||||
* src/cp-hash.c: Likewise.
|
||||
|
||||
* src/chgrp.c: Convert "`%s'" in format strings to "%s", and wrap each
|
||||
corresponding argument in a `quote (...)' call.
|
||||
Add more precise diagnostics.
|
||||
* src/chmod.c: Likewise.
|
||||
* src/chown.c: Likewise.
|
||||
|
||||
* src/remove.c (remove_cwd_entries): Quote one more file name.
|
||||
|
||||
* src/help-version: Remove file. Move it to ...
|
||||
* tests/help-version: ...here
|
||||
* tests/Makefile.am (TESTS): Set to help-version.
|
||||
(TESTS_ENVIRONMENT): Define.
|
||||
(EXTRA_DIST): Add $(TESTS).
|
||||
* src/Makefile.am (EXTRA_DIST): Remove help-version.
|
||||
(TESTS): Remove definition.
|
||||
(TESTS_ENVIRONMENT): Remove definition.
|
||||
|
||||
2000-07-24 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* src/ls.c: Include <limits.h>, <stdlib.h>, <wchar.h>, <wctype.h>.
|
||||
(quote_name): Use mbrtowc to step through the filename string while
|
||||
replacing nonprintables with question marks. Return the screen width,
|
||||
not the strlen length. Do no output if the out stream is NULL.
|
||||
(length_of_file_name_and_frills): Use the quote_name return value.
|
||||
|
||||
2000-07-25 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/chgrp.c (change_file_group): Save errno from a possibly failed
|
||||
chown, and use that later. Otherwise, errno itself could be clobbered
|
||||
before used.
|
||||
* src/chmod.c (change_file_mode): Likewise.
|
||||
* src/chown.c (change_file_owner): Likewise.
|
||||
|
||||
* src/mv.c (main): Remove unnecessary "%s" argument.
|
||||
|
||||
* src/ln.c: Convert "`%s'" in format strings to "%s", and wrap each
|
||||
corresponding argument in a `quote (...)' call.
|
||||
Add more precise diagnostics.
|
||||
* src/mv.c: Likewise.
|
||||
* src/cp.c: Likewise.
|
||||
* src/touch.c: Likewise.
|
||||
|
||||
2000-07-23 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 4.0x.
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
Changes in release 4.1:
|
||||
[4.0y]
|
||||
* cp now accepts the POSIX-mandated -H and -L options.
|
||||
* cp -p and mv now try to preserve uid even if you're not root, as per POSIX.2.
|
||||
This affects behavior only on hosts that let you give files away via chmod.
|
||||
* du would fail when given `.' or `..' followed by other command line arguments
|
||||
* Using cp's short-named `-P' option evokes the warning that that the
|
||||
meaning of `-P' will soon change. Use `--parents' instead.
|
||||
* chgrp, chmod, and chown: when used with the --verbose option, might give an
|
||||
invalid diagnostic (due to clobbered errno) when failing.
|
||||
[4.0x]
|
||||
* Fix cp so that `cp -r DIR1/ DIR2' works properly once again.
|
||||
* New ls option --quoting-style=clocale acts like --quoting-style=locale,
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
2000-08-14 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/tee.c (main): Remove incorrect `FIXME' comment.
|
||||
|
||||
2000-08-07 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/su.c (xputenv): Invoke xalloc_die instead of printing
|
||||
our own message.
|
||||
|
||||
2000-07-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/tee.c (tee): Use SET_BINARY and SET_BINARY2.
|
||||
From Prashant TR.
|
||||
|
||||
* src/help-version: Remove file. Move it to ...
|
||||
* tests/help-version: ...here
|
||||
* tests/Makefile.am (TESTS): Add help-version.
|
||||
(TESTS_ENVIRONMENT): Define.
|
||||
* src/Makefile.am (EXTRA_DIST): Remove help-version.
|
||||
(TESTS): Remove definition.
|
||||
(TESTS_ENVIRONMENT): Remove definition.
|
||||
|
||||
2000-07-23 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/help-version (su_args): Punt, so we don't try to start a shell.
|
||||
|
||||
* src/su.c: Include <sys/param.h> if HAVE_SYS_PARAM_H is defined,
|
||||
rather than if _POSIX_VERSION is defined. Remove declarations of
|
||||
getpwuid, getgrgid, and getuid, now that they're in sys2.h.
|
||||
|
||||
@@ -1,3 +1,160 @@
|
||||
2000-08-19 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/comm.c (writeline): Correct comments. From Bruno Haible.
|
||||
|
||||
2000-08-11 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* doc/textutils.texi:
|
||||
|
||||
Portable shell scripts should specify global options before
|
||||
key fields.
|
||||
|
||||
Move global LC_CTYPE remark to each sort option that depends
|
||||
on LC_CTYPE.
|
||||
|
||||
sort -g depends on LC_NUMERIC.
|
||||
|
||||
Add @vindex where it's missing.
|
||||
|
||||
"radix character" -> "decimal-point character", to match Standard C
|
||||
terminology, which is easier for most people to follow.
|
||||
|
||||
"comm" does not consider trailing newlines to be significant.
|
||||
|
||||
2000-08-10 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* doc/textutils.texi: Recommend against the System V syntax
|
||||
for tr ranges, and don't use it in examples. Use POSIX
|
||||
classes rather than ranges, for portability.
|
||||
* src/tr.c (usage): Don't describe System V syntax, as it
|
||||
doesn't always work.
|
||||
|
||||
* src/sort.c (usage): Describe -d and -i in a locale-independent way.
|
||||
|
||||
* doc/Makefile.am (constants.texi): Use the C locale so that
|
||||
[A-Z] works as expected.
|
||||
|
||||
2000-08-07 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/cut.c (cut_fields): Invoke xalloc_die instead of printing
|
||||
our own message.
|
||||
(cut_fields): Check for I/O error as well as end-of-file
|
||||
|
||||
2000-08-06 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* src/wc.c: Add support for multi-byte locales.
|
||||
(iswprint, mbrtowc, wcwidth): Provide default definitions.
|
||||
(total_bytes): New variable.
|
||||
(print_bytes): New variable.
|
||||
(longopts): Change abbreviation for --chars from 'c' to 'm'.
|
||||
(usage): Update.
|
||||
(write_counts): Add `bytes' argument.
|
||||
(wc): New variables `bytes', `count_bytes', `count_chars',
|
||||
`count_complicated'. The old code determines `bytes', not `chars'.
|
||||
New case for MB_CUR_MAX > 1. A non-printable non-space character does
|
||||
not increment the line position or start a word. Update `total_bytes'.
|
||||
(main): Initialize `print_bytes' and `total_bytes' to 0. Accept 'm'
|
||||
option. Pass `total_bytes' to write_counts.
|
||||
* doc/textutils.texi (wc invocation): Update accordingly.
|
||||
|
||||
2000-08-06 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* src/head.c (head): Call write_header here.
|
||||
(head_file): ... not here.
|
||||
|
||||
* src/cat.c (closeout_func): Remove variable.
|
||||
(close_stdout_wrapper): Remove unused function.
|
||||
(main): Remove assignment to closeout_func.
|
||||
|
||||
* src/fold.c (fold_file): Remove ferror(stdout) check, already done
|
||||
in close_stdout.
|
||||
|
||||
2000-08-06 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
* src/sort.c (usage): Warn more succintly about the effects of
|
||||
the locale on sort order.
|
||||
|
||||
2000-08-06 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* Version 2.0g.
|
||||
|
||||
* src/tail.c (pipe_lines): Declare local `cp' to be const.
|
||||
|
||||
2000-08-04 Greg McGary <greg@mcgary.org>
|
||||
|
||||
* src/tail.c (pipe_lines): Add variable `nbytes' so we can free
|
||||
`tmp' immediately after read loop. Don't process an empty file.
|
||||
[This fixes a buffer-underrun error -- detected thanks to
|
||||
bounded pointers -jmm]
|
||||
|
||||
2000-08-05 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
Fix buffer-overrun error.
|
||||
* src/pr.c (init_header): Allocated buffer was sometimes too small.
|
||||
Reported by Greg McGary (who found this bug using his
|
||||
bounded-pointers-enabled gcc).
|
||||
(init_header): Move declarations of several variables into the
|
||||
inner scope where they are used.
|
||||
* tests/pr/Test.pm (narrow-1): New test, for the above.
|
||||
|
||||
* src/csplit.c (MAX): Remove definition (It's in sys2.h).
|
||||
|
||||
2000-08-04 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/sort.c (main): Rename local `t' to `tmp_dir' to avoid shadowing
|
||||
a previous local by that name.
|
||||
(usage): Warn that GNU sort is now locale-aware, and suggest
|
||||
people put LC_ALL=POSIX in their environment.
|
||||
|
||||
* src/pr.c (store_columns): Remove conjunct that would dereference
|
||||
an out-of-bounds pointer. Reported by Greg McGary (who found this
|
||||
bug using his bounded-pointers-enabled gcc).
|
||||
|
||||
2000-08-03 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/Makefile.am.in ($(srcdir)/$x-tests): Use -I$(srcdir), not `-I.'.
|
||||
(Makefile.am): Likewise. Reported by Greg McGary.
|
||||
|
||||
2000-08-01 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* doc/textutils.texi (tr invocation): Note that ranges are not portable.
|
||||
Update examples not to use ranges.
|
||||
|
||||
2000-07-31 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/cut.c (cut_fields): Use `virtual memory exhausted',
|
||||
not `Memory exhausted'.
|
||||
|
||||
2000-07-30 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* src/help-version: Remove file. Move it to ...
|
||||
* tests/help-version: ...here
|
||||
* tests/Makefile.am (TESTS): Set to help-version.
|
||||
(TESTS_ENVIRONMENT): Define.
|
||||
(EXTRA_DIST): Add $(TESTS).
|
||||
* src/Makefile.am (EXTRA_DIST): Remove help-version.
|
||||
(TESTS): Remove definition.
|
||||
(TESTS_ENVIRONMENT): Remove definition.
|
||||
|
||||
2000-07-28 Paul Eggert <eggert@twinsun.com>
|
||||
|
||||
sort's -T option can now appear multiple times.
|
||||
Thanks to Charles Randall for suggesting this idea.
|
||||
|
||||
* doc/textutils.texi, NEWS: Document this.
|
||||
|
||||
* src/sort.c (temp_dir): Remove.
|
||||
(temp_dirs, temp_dir_count, temp_dir_alloc): New vars.
|
||||
(process_id): New var.
|
||||
(usage): Describe new use of -T.
|
||||
(add_temp_dir): New function.
|
||||
(tempname): Use new temp_dirs array.
|
||||
Do not discard information from the process-id or sequence
|
||||
number, unless we have short file names.
|
||||
(sighandle): Use process_id instead of getpid.
|
||||
(main): Initialize process_id.
|
||||
Add support for the new use of -T.
|
||||
|
||||
2000-07-23 Jim Meyering <meyering@lucent.com>
|
||||
|
||||
* tests/head/Test.pm: Rename tests (and hence files) to have a short
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
Changes in release 2.1
|
||||
[2.0h]
|
||||
[2.0g]
|
||||
* sort's --help output now warns that it is locale-aware
|
||||
* tail: fix a buffer underrun error that occurred on an empty pipe,
|
||||
also thanks to bounded pointers
|
||||
* pr: fix a bounds violation found by Greg McGary's bounded-pointers-enabled gcc
|
||||
It could have caused (with low probability) the columns on the last page of
|
||||
output *not* to be `balanced' when they should have been.
|
||||
* sort: if the -T tmpdir option is given multiple times, all the given
|
||||
directories are used; this can improve performance for huge sort/merges.
|
||||
[2.0f]
|
||||
* all programs fail when printing --help or --version output to a full device
|
||||
* cut no longer gets a segfault under some circumstances
|
||||
|
||||
13
src/cat.c
13
src/cat.c
@@ -462,17 +462,6 @@ cat (
|
||||
}
|
||||
}
|
||||
|
||||
/* This is gross, but necessary, because of the way close_stdout
|
||||
works and because this program closes STDOUT_FILENO directly. */
|
||||
static void (*closeout_func) (void) = close_stdout;
|
||||
|
||||
static void
|
||||
close_stdout_wrapper (void)
|
||||
{
|
||||
if (closeout_func)
|
||||
(*closeout_func) ();
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@@ -632,8 +621,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
closeout_func = NULL;
|
||||
|
||||
/* Get device, i-node number, and optimal blocksize of output. */
|
||||
|
||||
if (fstat (STDOUT_FILENO, &stat_buf) < 0)
|
||||
|
||||
33
src/chgrp.c
33
src/chgrp.c
@@ -27,6 +27,7 @@
|
||||
#include "error.h"
|
||||
#include "lchown.h"
|
||||
#include "group-member.h"
|
||||
#include "quote.h"
|
||||
#include "savedir.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -137,7 +138,7 @@ describe_change (const char *file, enum Change_status changed)
|
||||
if (changed == CH_NOT_APPLIED)
|
||||
{
|
||||
printf (_("neither symbolic link %s nor referent has been changed\n"),
|
||||
file);
|
||||
quote (file));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@ describe_change (const char *file, enum Change_status changed)
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
printf (fmt, file, groupname);
|
||||
printf (fmt, quote (file), groupname);
|
||||
}
|
||||
|
||||
/* Set *G according to NAME. */
|
||||
@@ -176,14 +177,14 @@ parse_group (const char *name, gid_t *g)
|
||||
unsigned long int tmp_long;
|
||||
|
||||
if (!ISDIGIT (*name))
|
||||
error (1, 0, _("invalid group name `%s'"), name);
|
||||
error (1, 0, _("invalid group name %s"), quote (name));
|
||||
|
||||
s_err = xstrtoul (name, NULL, 0, &tmp_long, NULL);
|
||||
if (s_err != LONGINT_OK)
|
||||
STRTOL_FATAL_ERROR (name, _("group number"), s_err);
|
||||
|
||||
if (tmp_long > MAXGID)
|
||||
error (1, 0, _("invalid group number `%s'"), name);
|
||||
error (1, 0, _("invalid group number %s"), quote (name));
|
||||
|
||||
*g = tmp_long;
|
||||
}
|
||||
@@ -205,7 +206,7 @@ change_file_group (int cmdline_arg, const char *file, gid_t group)
|
||||
if ((*xstat) (file, &file_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
error (0, errno, _("getting attributes of %s"), quote (file));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -213,6 +214,7 @@ change_file_group (int cmdline_arg, const char *file, gid_t group)
|
||||
{
|
||||
int fail;
|
||||
int symlink_changed = 1;
|
||||
int saved_errno;
|
||||
|
||||
if (S_ISLNK (file_stats.st_mode) && change_symlinks)
|
||||
{
|
||||
@@ -231,6 +233,9 @@ change_file_group (int cmdline_arg, const char *file, gid_t group)
|
||||
fail = chown (file, (uid_t) -1, group);
|
||||
}
|
||||
|
||||
/* Save errno, since in verbose mode, describe_change might change it. */
|
||||
saved_errno = errno;
|
||||
|
||||
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
|
||||
{
|
||||
enum Change_status ch_status = (! symlink_changed ? CH_NOT_APPLIED
|
||||
@@ -246,18 +251,20 @@ change_file_group (int cmdline_arg, const char *file, gid_t group)
|
||||
/* Give a more specific message. Some systems set errno
|
||||
to EPERM for both `inaccessible file' and `user not a member
|
||||
of the specified group' errors. */
|
||||
if (errno == EPERM && !group_member (group))
|
||||
if (saved_errno == EPERM && !group_member (group))
|
||||
{
|
||||
error (0, errno, _("you are not a member of group `%s'"),
|
||||
groupname);
|
||||
error (0, saved_errno, _("you are not a member of group %s"),
|
||||
quote (groupname));
|
||||
}
|
||||
else if (errno == EINVAL && group > MAXUID)
|
||||
else if (saved_errno == EINVAL && group > MAXUID)
|
||||
{
|
||||
error (0, 0, _("%s: invalid group number"), groupname);
|
||||
error (0, 0, _("%s: invalid group number"),
|
||||
quote (groupname));
|
||||
}
|
||||
else
|
||||
{
|
||||
error (0, errno, "%s", file);
|
||||
error (0, saved_errno, _("changing group of %s"),
|
||||
quote (file));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,7 +299,7 @@ change_dir_group (const char *dir, gid_t group, const struct stat *statp)
|
||||
if (name_space == NULL)
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", dir);
|
||||
error (0, errno, "%s", quote (dir));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -419,7 +426,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
struct stat ref_stats;
|
||||
if (stat (reference_file, &ref_stats))
|
||||
error (1, errno, "%s", reference_file);
|
||||
error (1, errno, _("getting attributes of %s"), quote (reference_file));
|
||||
|
||||
group = ref_stats.st_gid;
|
||||
}
|
||||
|
||||
18
src/chmod.c
18
src/chmod.c
@@ -26,6 +26,7 @@
|
||||
#include "error.h"
|
||||
#include "filemode.h"
|
||||
#include "modechange.h"
|
||||
#include "quote.h"
|
||||
#include "savedir.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -120,7 +121,8 @@ describe_change (const char *file, mode_t mode,
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
printf (fmt, file, (unsigned long) (mode & CHMOD_MODE_BITS), &perms[1]);
|
||||
printf (fmt, quote (file),
|
||||
(unsigned long) (mode & CHMOD_MODE_BITS), &perms[1]);
|
||||
}
|
||||
|
||||
/* Change the mode of FILE according to the list of operations CHANGES.
|
||||
@@ -139,7 +141,7 @@ change_file_mode (const char *file, const struct mode_change *changes,
|
||||
if (lstat (file, &file_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
error (0, errno, _("getting attributes of %s"), quote (file));
|
||||
return 1;
|
||||
}
|
||||
#ifdef S_ISLNK
|
||||
@@ -151,7 +153,7 @@ change_file_mode (const char *file, const struct mode_change *changes,
|
||||
if (stat (file, &file_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
error (0, errno, _("getting attributes of %s"), quote (file));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -162,6 +164,7 @@ change_file_mode (const char *file, const struct mode_change *changes,
|
||||
if (newmode != (file_stats.st_mode & CHMOD_MODE_BITS))
|
||||
{
|
||||
int fail = chmod (file, newmode);
|
||||
int saved_errno = errno;
|
||||
|
||||
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
|
||||
describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
|
||||
@@ -169,7 +172,8 @@ change_file_mode (const char *file, const struct mode_change *changes,
|
||||
if (fail)
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
error (0, saved_errno, _("changing permissions of %s"),
|
||||
quote (file));
|
||||
errors = 1;
|
||||
}
|
||||
}
|
||||
@@ -201,7 +205,7 @@ change_dir_mode (const char *dir, const struct mode_change *changes,
|
||||
if (name_space == NULL)
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", dir);
|
||||
error (0, errno, "%s", quote (dir));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -349,9 +353,9 @@ main (int argc, char **argv)
|
||||
if (changes == MODE_INVALID)
|
||||
error (1, 0, _("invalid mode"));
|
||||
else if (changes == MODE_MEMORY_EXHAUSTED)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
xalloc_die ();
|
||||
else if (changes == MODE_BAD_REFERENCE)
|
||||
error (1, errno, "%s", reference_file);
|
||||
error (1, errno, _("getting attributes of %s"), quote (reference_file));
|
||||
|
||||
for (; optind < argc; ++optind)
|
||||
{
|
||||
|
||||
19
src/chown.c
19
src/chown.c
@@ -38,6 +38,7 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "lchown.h"
|
||||
#include "quote.h"
|
||||
#include "savedir.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -144,7 +145,7 @@ describe_change (const char *file, enum Change_status changed)
|
||||
if (changed == CH_NOT_APPLIED)
|
||||
{
|
||||
printf (_("neither symbolic link %s nor referent has been changed\n"),
|
||||
file);
|
||||
quote (file));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +187,7 @@ change_file_owner (int cmdline_arg, const char *file, uid_t user, gid_t group,
|
||||
if (lstat (file, &file_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
error (0, errno, _("getting attributes of %s"), quote (file));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -199,6 +200,7 @@ change_file_owner (int cmdline_arg, const char *file, uid_t user, gid_t group,
|
||||
{
|
||||
int fail;
|
||||
int symlink_changed = 1;
|
||||
int saved_errno;
|
||||
|
||||
if (S_ISLNK (file_stats.st_mode) && change_symlinks)
|
||||
{
|
||||
@@ -216,6 +218,7 @@ change_file_owner (int cmdline_arg, const char *file, uid_t user, gid_t group,
|
||||
{
|
||||
fail = chown (file, newuser, newgroup);
|
||||
}
|
||||
saved_errno = errno;
|
||||
|
||||
if (verbosity == V_high || (verbosity == V_changes_only && !fail))
|
||||
{
|
||||
@@ -229,7 +232,8 @@ change_file_owner (int cmdline_arg, const char *file, uid_t user, gid_t group,
|
||||
if (fail)
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
error (0, saved_errno, _("changing ownership of %s"),
|
||||
quote (file));
|
||||
errors = 1;
|
||||
}
|
||||
}
|
||||
@@ -266,7 +270,7 @@ change_dir_owner (const char *dir, uid_t user, gid_t group,
|
||||
if (name_space == NULL)
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", dir);
|
||||
error (0, errno, "%s", quote (dir));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -373,10 +377,11 @@ main (int argc, char **argv)
|
||||
case FROM_OPTION:
|
||||
{
|
||||
char *u_dummy, *g_dummy;
|
||||
const char *e = parse_user_spec (argv[optind], &old_user, &old_group,
|
||||
const char *e = parse_user_spec (argv[optind],
|
||||
&old_user, &old_group,
|
||||
&u_dummy, &g_dummy);
|
||||
if (e)
|
||||
error (1, 0, "%s: %s", argv[optind], e);
|
||||
error (1, 0, "%s: %s", quote (argv[optind]), e);
|
||||
break;
|
||||
}
|
||||
case 'R':
|
||||
@@ -412,7 +417,7 @@ main (int argc, char **argv)
|
||||
struct stat ref_stats;
|
||||
|
||||
if (stat (reference_file, &ref_stats))
|
||||
error (1, errno, "%s", reference_file);
|
||||
error (1, errno, _("getting attributes of %s"), quote (reference_file));
|
||||
|
||||
user = ref_stats.st_uid;
|
||||
group = ref_stats.st_gid;
|
||||
|
||||
@@ -108,7 +108,7 @@ writeline (const struct linebuffer *line, FILE *stream, int class)
|
||||
case 2:
|
||||
if (!only_file_2)
|
||||
return;
|
||||
/* Skip the tab stop for case 1, if we are printing case 1. */
|
||||
/* Print a TAB if we are printing lines from file 1. */
|
||||
if (only_file_1)
|
||||
putc ('\t', stream);
|
||||
break;
|
||||
@@ -116,10 +116,10 @@ writeline (const struct linebuffer *line, FILE *stream, int class)
|
||||
case 3:
|
||||
if (!both)
|
||||
return;
|
||||
/* Skip the tab stop for case 1, if we are printing case 1. */
|
||||
/* Print a TAB if we are printing lines from file 1. */
|
||||
if (only_file_1)
|
||||
putc ('\t', stream);
|
||||
/* Skip the tab stop for case 2, if we are printing case 2. */
|
||||
/* Print a TAB if we are printing lines from file 2. */
|
||||
if (only_file_2)
|
||||
putc ('\t', stream);
|
||||
break;
|
||||
|
||||
130
src/copy.c
130
src/copy.c
@@ -38,10 +38,10 @@
|
||||
#include "same.h"
|
||||
|
||||
#define DO_CHOWN(Chown, File, New_uid, New_gid) \
|
||||
(Chown ((File), (x->myeuid == 0 ? (New_uid) : x->myeuid), (New_gid)) \
|
||||
(Chown (File, New_uid, New_gid) \
|
||||
/* If non-root uses -p, it's ok if we can't preserve ownership. \
|
||||
But root probably wants to know, e.g. if NFS disallows it, \
|
||||
or if the target system doesn't support file ownership. */ \
|
||||
or if the target system doesn't support file ownership. */ \
|
||||
&& ((errno != EPERM && errno != EINVAL) || x->myeuid == 0))
|
||||
|
||||
struct dir_list
|
||||
@@ -55,6 +55,8 @@ int full_write ();
|
||||
int euidaccess ();
|
||||
int yesno ();
|
||||
|
||||
int lstat ();
|
||||
|
||||
static int copy_internal PARAMS ((const char *src_path, const char *dst_path,
|
||||
int new_dst, dev_t device,
|
||||
struct dir_list *ancestors,
|
||||
@@ -70,15 +72,18 @@ extern char *program_name;
|
||||
new non-directories. */
|
||||
|
||||
static mode_t
|
||||
new_nondir_mode (const struct cp_options *option, mode_t mode)
|
||||
get_dest_mode (const struct cp_options *option, mode_t mode)
|
||||
{
|
||||
/* In some applications (e.g., install), use precisely the
|
||||
specified mode. */
|
||||
if (option->set_mode)
|
||||
return option->mode;
|
||||
|
||||
/* In others (e.g., cp, mv), apply the user's umask. */
|
||||
return mode & option->umask_kill;
|
||||
/* Honor the umask for `cp', but not for `mv' or `cp -p'. */
|
||||
if (!option->move_mode && !option->preserve_chmod_bits)
|
||||
mode &= option->umask_kill;
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
/* FIXME: describe */
|
||||
@@ -113,6 +118,7 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
|
||||
{
|
||||
char *name_space;
|
||||
char *namep;
|
||||
struct cp_options non_command_line_options = *x;
|
||||
int ret = 0;
|
||||
|
||||
name_space = savedir (src_path_in, src_sb->st_size);
|
||||
@@ -124,6 +130,11 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* For cp's -H option, dereference command line arguments, but do not
|
||||
dereference symlinks that are found via recursive traversal. */
|
||||
if (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
|
||||
non_command_line_options.xstat = lstat;
|
||||
|
||||
namep = name_space;
|
||||
while (*namep != '\0')
|
||||
{
|
||||
@@ -132,10 +143,11 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
|
||||
char *dst_path = path_concat (dst_path_in, namep, NULL);
|
||||
|
||||
if (dst_path == NULL || src_path == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
xalloc_die ();
|
||||
|
||||
ret |= copy_internal (src_path, dst_path, new_dst, src_sb->st_dev,
|
||||
ancestors, x, 0, &local_copy_into_self, NULL);
|
||||
ancestors, &non_command_line_options, 0,
|
||||
&local_copy_into_self, NULL);
|
||||
*copy_into_self |= local_copy_into_self;
|
||||
|
||||
/* Free the memory for `src_path'. The memory for `dst_path'
|
||||
@@ -154,18 +166,18 @@ copy_dir (const char *src_path_in, const char *dst_path_in, int new_dst,
|
||||
If the source file contains holes, copies holes and blocks of zeros
|
||||
in the source file as holes in the destination file.
|
||||
(Holes are read as zeroes by the `read' system call.)
|
||||
Use DST_MODE as the 3rd argument in the call to open.
|
||||
Return 0 if successful, -1 if an error occurred.
|
||||
FIXME: describe sparse_mode. */
|
||||
|
||||
static int
|
||||
copy_reg (const char *src_path, const char *dst_path,
|
||||
enum Sparse_type sparse_mode)
|
||||
enum Sparse_type sparse_mode, mode_t dst_mode)
|
||||
{
|
||||
char *buf;
|
||||
int buf_size;
|
||||
int dest_desc;
|
||||
int source_desc;
|
||||
int n_read;
|
||||
struct stat sb;
|
||||
char *cp;
|
||||
int *ip;
|
||||
@@ -190,10 +202,7 @@ copy_reg (const char *src_path, const char *dst_path,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create the new regular file with restrictive permissions (u=rw)
|
||||
initially. */
|
||||
|
||||
dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||
dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, dst_mode);
|
||||
if (dest_desc < 0)
|
||||
{
|
||||
error (0, errno, _("cannot create regular file %s"), quote (dst_path));
|
||||
@@ -240,7 +249,7 @@ copy_reg (const char *src_path, const char *dst_path,
|
||||
|
||||
for (;;)
|
||||
{
|
||||
n_read = read (source_desc, buf, buf_size);
|
||||
int n_read = read (source_desc, buf, buf_size);
|
||||
if (n_read < 0)
|
||||
{
|
||||
#ifdef EINTR
|
||||
@@ -363,14 +372,14 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
{
|
||||
struct stat src_sb;
|
||||
struct stat dst_sb;
|
||||
int src_mode;
|
||||
int src_type;
|
||||
mode_t src_mode;
|
||||
mode_t src_type;
|
||||
char *earlier_file;
|
||||
char *dst_backup = NULL;
|
||||
int backup_succeeded = 0;
|
||||
int fix_mode = 0;
|
||||
int rename_errno;
|
||||
int delayed_fail;
|
||||
int copied_as_regular = 0;
|
||||
|
||||
if (move_mode && rename_succeeded)
|
||||
*rename_succeeded = 0;
|
||||
@@ -445,7 +454,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
|| (x->hard_link
|
||||
&& S_ISLNK (src_sb.st_mode)
|
||||
&& !S_ISLNK (dst_sb.st_mode)))
|
||||
&& !x->dereference
|
||||
&& x->dereference == DEREF_NEVER
|
||||
&& (S_ISLNK (dst_sb.st_mode) ^ S_ISLNK (src_sb.st_mode)))
|
||||
{
|
||||
struct stat dst2_sb;
|
||||
@@ -520,7 +529,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
{
|
||||
error (0, 0,
|
||||
_("cannot move directory onto non-directory: %s -> %s"),
|
||||
src_path, dst_path);
|
||||
quote_n (0, src_path), quote_n (0, dst_path));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -530,7 +539,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
char *tmp_backup = find_backup_file_name (dst_path,
|
||||
x->backup_type);
|
||||
if (tmp_backup == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
xalloc_die ();
|
||||
|
||||
/* Detect (and fail) when creating the backup file would
|
||||
destroy the source file. Before, running the commands
|
||||
@@ -575,17 +584,13 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
if (S_ISDIR (dst_sb.st_mode))
|
||||
{
|
||||
/* Temporarily change mode to allow overwriting. */
|
||||
if (euidaccess (dst_path, W_OK | X_OK) != 0)
|
||||
if (euidaccess (dst_path, W_OK | X_OK) != 0
|
||||
&& chmod (dst_path, S_IRWXU))
|
||||
{
|
||||
if (chmod (dst_path, S_IRWXU))
|
||||
{
|
||||
error (0, errno,
|
||||
_("cannot change permissions for %s"),
|
||||
quote (dst_path));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
fix_mode = 1;
|
||||
error (0, errno,
|
||||
_("cannot change permissions for %s"),
|
||||
quote (dst_path));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -611,17 +616,16 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
sure we'll create a directory. */
|
||||
if (x->verbose && !S_ISDIR (src_type))
|
||||
{
|
||||
/* FIXME: do we really want to add quotes here? */
|
||||
printf ("%s -> %s", src_path, dst_path);
|
||||
printf ("%s -> %s", quote_n (0, src_path), quote_n (1, dst_path));
|
||||
if (backup_succeeded)
|
||||
printf (_(" (backup: %s)"), dst_backup);
|
||||
printf (_(" (backup: %s)"), quote (dst_backup));
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
/* Did we copy this inode somewhere else (in this command line argument)
|
||||
and therefore this is a second hard link to the inode? */
|
||||
|
||||
if (!x->dereference && src_sb.st_nlink > 1 && earlier_file)
|
||||
if (x->dereference == DEREF_NEVER && src_sb.st_nlink > 1 && earlier_file)
|
||||
{
|
||||
/* Avoid damaging the destination filesystem by refusing to preserve
|
||||
hard-linked directories (which are found at least in Netapp snapshot
|
||||
@@ -648,7 +652,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
if (rename (src_path, dst_path) == 0)
|
||||
{
|
||||
if (x->verbose && S_ISDIR (src_type))
|
||||
printf ("%s -> %s\n", src_path, dst_path);
|
||||
printf ("%s -> %s\n", quote_n (0, src_path), quote_n (1, dst_path));
|
||||
if (rename_succeeded)
|
||||
*rename_succeeded = 1;
|
||||
return 0;
|
||||
@@ -741,7 +745,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
goto un_backup;
|
||||
|
||||
if (x->verbose)
|
||||
printf ("%s -> %s\n", src_path, dst_path);
|
||||
printf ("%s -> %s\n", quote_n (0, src_path), quote_n (1, dst_path));
|
||||
}
|
||||
|
||||
/* Are we crossing a file system boundary? */
|
||||
@@ -772,7 +776,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
|
||||
dst_parent = dir_name (dst_path);
|
||||
if (dst_parent == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
xalloc_die ();
|
||||
|
||||
in_current_dir = (STREQ (".", dst_parent)
|
||||
/* If either stat call fails, it's ok not to report
|
||||
@@ -817,14 +821,19 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
#endif
|
||||
))
|
||||
{
|
||||
if (copy_reg (src_path, dst_path, x->sparse_mode))
|
||||
copied_as_regular = 1;
|
||||
/* POSIX says the permission bits of the source file must be
|
||||
used as the 3rd argument in the open call, but that's not consistent
|
||||
with historical practice. */
|
||||
if (copy_reg (src_path, dst_path, x->sparse_mode,
|
||||
get_dest_mode (x, src_mode)))
|
||||
goto un_backup;
|
||||
}
|
||||
else
|
||||
#ifdef S_ISFIFO
|
||||
if (S_ISFIFO (src_type))
|
||||
{
|
||||
if (mkfifo (dst_path, new_nondir_mode (x, src_mode)))
|
||||
if (mkfifo (dst_path, get_dest_mode (x, src_mode)))
|
||||
{
|
||||
error (0, errno, _("cannot create fifo %s"), quote (dst_path));
|
||||
goto un_backup;
|
||||
@@ -838,7 +847,7 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (mknod (dst_path, new_nondir_mode (x, src_mode), src_sb.st_rdev))
|
||||
if (mknod (dst_path, get_dest_mode (x, src_mode), src_sb.st_rdev))
|
||||
{
|
||||
error (0, errno, _("cannot create special file %s"),
|
||||
quote (dst_path));
|
||||
@@ -955,41 +964,21 @@ copy_internal (const char *src_path, const char *dst_path,
|
||||
}
|
||||
}
|
||||
|
||||
if (x->set_mode)
|
||||
/* Permissions of newly-created regular files were set upon `open'
|
||||
in copy_reg. */
|
||||
if (new_dst && copied_as_regular)
|
||||
return delayed_fail;
|
||||
|
||||
if ((x->preserve_chmod_bits || new_dst)
|
||||
&& (x->copy_as_regular || S_ISREG (src_type) || S_ISDIR (src_type)))
|
||||
{
|
||||
/* This is so install's -m MODE option works. */
|
||||
if (chmod (dst_path, x->mode))
|
||||
if (chmod (dst_path, get_dest_mode (x, src_mode)))
|
||||
{
|
||||
error (0, errno, _("setting permissions for %s"), quote (dst_path));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if ((x->preserve_chmod_bits || new_dst)
|
||||
&& (x->copy_as_regular || S_ISREG (src_type) || S_ISDIR (src_type)))
|
||||
{
|
||||
mode_t dst_mode = src_mode;
|
||||
|
||||
/* Honor the umask for `cp', but not for `mv'. */
|
||||
if (!x->move_mode)
|
||||
dst_mode &= x->umask_kill;
|
||||
|
||||
if (chmod (dst_path, dst_mode))
|
||||
{
|
||||
error (0, errno, _("preserving permissions for %s"),
|
||||
quote (dst_path));
|
||||
if (x->require_preserve)
|
||||
if (x->set_mode || x->require_preserve)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (fix_mode)
|
||||
{
|
||||
/* Reset the temporarily changed mode. */
|
||||
if (chmod (dst_path, dst_sb.st_mode))
|
||||
{
|
||||
error (0, errno, _("restoring permissions of %s"), quote (dst_path));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return delayed_fail;
|
||||
|
||||
@@ -1001,7 +990,8 @@ un_backup:
|
||||
else
|
||||
{
|
||||
if (x->verbose)
|
||||
printf (_("%s -> %s (unbackup)\n"), dst_backup, dst_path);
|
||||
printf (_("%s -> %s (unbackup)\n"),
|
||||
quote_n (0, dst_backup), quote_n (1, dst_path));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
10
src/copy.h
10
src/copy.h
@@ -22,6 +22,14 @@ enum Sparse_type
|
||||
SPARSE_ALWAYS
|
||||
};
|
||||
|
||||
enum Dereference_symlink
|
||||
{
|
||||
DEREF_UNDEFINED = 1,
|
||||
DEREF_ALWAYS,
|
||||
DEREF_NEVER,
|
||||
DEREF_COMMAND_LINE_ARGUMENTS
|
||||
};
|
||||
|
||||
# define VALID_SPARSE_MODE(Mode) \
|
||||
((Mode) == SPARSE_NEVER \
|
||||
|| (Mode) == SPARSE_AUTO \
|
||||
@@ -36,7 +44,7 @@ struct cp_options
|
||||
int copy_as_regular;
|
||||
|
||||
/* If nonzero, dereference symbolic links (copy the files they point to). */
|
||||
int dereference;
|
||||
enum Dereference_symlink dereference;
|
||||
|
||||
/* If nonzero, remove existing destination nondirectories. */
|
||||
int force;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "cp-hash.h"
|
||||
#include "quote.h"
|
||||
|
||||
struct entry
|
||||
{
|
||||
@@ -60,7 +61,7 @@ remember_created (const char *path)
|
||||
|
||||
if (stat (path, &sb) < 0)
|
||||
{
|
||||
error (0, errno, "%s", path);
|
||||
error (0, errno, "%s", quote (path));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
82
src/cp.c
82
src/cp.c
@@ -72,7 +72,8 @@ enum
|
||||
{
|
||||
TARGET_DIRECTORY_OPTION = CHAR_MAX + 1,
|
||||
SPARSE_OPTION,
|
||||
STRIP_TRAILING_SLASHES_OPTION
|
||||
STRIP_TRAILING_SLASHES_OPTION,
|
||||
PARENTS_OPTION
|
||||
};
|
||||
|
||||
int stat ();
|
||||
@@ -122,14 +123,15 @@ static struct option const long_opts[] =
|
||||
{
|
||||
{"archive", no_argument, NULL, 'a'},
|
||||
{"backup", optional_argument, NULL, 'b'},
|
||||
{"dereference", no_argument, NULL, 'L'},
|
||||
{"force", no_argument, NULL, 'f'},
|
||||
{"sparse", required_argument, NULL, SPARSE_OPTION},
|
||||
{"interactive", no_argument, NULL, 'i'},
|
||||
{"link", no_argument, NULL, 'l'},
|
||||
{"no-dereference", no_argument, NULL, 'd'},
|
||||
{"one-file-system", no_argument, NULL, 'x'},
|
||||
{"parents", no_argument, NULL, 'P'},
|
||||
{"path", no_argument, NULL, 'P'},
|
||||
{"parents", no_argument, NULL, PARENTS_OPTION},
|
||||
{"path", no_argument, NULL, PARENTS_OPTION}, /* Deprecated. */
|
||||
{"preserve", no_argument, NULL, 'p'},
|
||||
{"recursive", no_argument, NULL, 'R'},
|
||||
{"strip-trailing-slash", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
|
||||
@@ -167,9 +169,16 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
|
||||
-d, --no-dereference preserve links\n\
|
||||
-f, --force remove existing destinations, never prompt\n\
|
||||
-i, --interactive prompt before overwrite\n\
|
||||
-H follow symbolic links that are explicitly\n\
|
||||
specified in the command line, but do not\n\
|
||||
follow symlinks that are found via recursive\n\
|
||||
traversal\n\
|
||||
-l, --link link files instead of copying\n\
|
||||
-L, --dereference always follow symbolic links\n\
|
||||
-p, --preserve preserve file attributes if possible\n\
|
||||
-P, --parents append source path to DIRECTORY\n\
|
||||
--parents append source path to DIRECTORY\n\
|
||||
-P same as `--parents' for now; soon to change to\n\
|
||||
`--no-dereference' to conform to POSIX\n\
|
||||
-r copy recursively, non-directories as files\n\
|
||||
WARNING: use -R instead when you might copy\n\
|
||||
special files like FIFOs or /dev/zero\n\
|
||||
@@ -257,7 +266,8 @@ re_protect (const char *const_dst_path, int src_offset,
|
||||
|
||||
if ((*(x->xstat)) (src_path, &src_sb))
|
||||
{
|
||||
error (0, errno, "%s", src_path);
|
||||
error (0, errno, _("getting attributes of %s"),
|
||||
quote (src_path));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -278,7 +288,7 @@ re_protect (const char *const_dst_path, int src_offset,
|
||||
|
||||
if (utime (dst_path, &utb))
|
||||
{
|
||||
error (0, errno, _("preserving times for %s"), dst_path);
|
||||
error (0, errno, _("preserving times for %s"), quote (dst_path));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -291,7 +301,8 @@ re_protect (const char *const_dst_path, int src_offset,
|
||||
if (chown (dst_path, src_sb.st_uid, src_sb.st_gid)
|
||||
&& ((errno != EPERM && errno != EINVAL) || myeuid == 0))
|
||||
{
|
||||
error (0, errno, _("preserving ownership for %s"), dst_path);
|
||||
error (0, errno, _("preserving ownership for %s"),
|
||||
quote (dst_path));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -300,7 +311,8 @@ re_protect (const char *const_dst_path, int src_offset,
|
||||
{
|
||||
if (chmod (dst_path, src_sb.st_mode & x->umask_kill))
|
||||
{
|
||||
error (0, errno, _("preserving permissions for %s"), dst_path);
|
||||
error (0, errno, _("preserving permissions for %s"),
|
||||
quote (dst_path));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -462,7 +474,7 @@ do_copy (int n_files, char **file, const char *target_directory,
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
error (0, errno, _("accessing %s"), quote (dest));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -522,7 +534,7 @@ do_copy (int n_files, char **file, const char *target_directory,
|
||||
/* Append all of `arg' to `dest'. */
|
||||
dst_path = path_concat (dest, arg, &arg_in_concat);
|
||||
if (dst_path == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
xalloc_die ();
|
||||
|
||||
/* For --parents, we have to make sure that the directory
|
||||
dir_name (dst_path) exists. We may have to create a few
|
||||
@@ -609,7 +621,7 @@ do_copy (int n_files, char **file, const char *target_directory,
|
||||
x = &x_tmp;
|
||||
|
||||
if (new_dest == NULL)
|
||||
error (1, 0, _("virtual memory exhausted"));
|
||||
xalloc_die ();
|
||||
}
|
||||
|
||||
/* When the destination is specified with a trailing slash and the
|
||||
@@ -645,7 +657,7 @@ static void
|
||||
cp_option_init (struct cp_options *x)
|
||||
{
|
||||
x->copy_as_regular = 1;
|
||||
x->dereference = 1;
|
||||
x->dereference = DEREF_UNDEFINED;
|
||||
x->force = 0;
|
||||
x->failed_unlink_is_fatal = 1;
|
||||
x->hard_link = 0;
|
||||
@@ -684,6 +696,7 @@ main (int argc, char **argv)
|
||||
char *version_control_string = NULL;
|
||||
struct cp_options x;
|
||||
char *target_directory = NULL;
|
||||
int used_P_option = 0;
|
||||
|
||||
program_name = argv[0];
|
||||
setlocale (LC_ALL, "");
|
||||
@@ -698,7 +711,7 @@ main (int argc, char **argv)
|
||||
we'll actually use backup_suffix_string. */
|
||||
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abdfilprsuvxPRS:V:", long_opts, NULL))
|
||||
while ((c = getopt_long (argc, argv, "abdfHilLprsuvxPRS:V:", long_opts, NULL))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -712,7 +725,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'a': /* Like -dpR. */
|
||||
x.dereference = 0;
|
||||
x.dereference = DEREF_NEVER;
|
||||
x.preserve_owner_and_group = 1;
|
||||
x.preserve_chmod_bits = 1;
|
||||
x.preserve_timestamps = 1;
|
||||
@@ -735,13 +748,17 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
x.dereference = 0;
|
||||
x.dereference = DEREF_NEVER;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
x.force = 1;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
x.dereference = DEREF_COMMAND_LINE_ARGUMENTS;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
x.interactive = 1;
|
||||
break;
|
||||
@@ -750,6 +767,10 @@ main (int argc, char **argv)
|
||||
x.hard_link = 1;
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
x.dereference = DEREF_ALWAYS;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
x.preserve_owner_and_group = 1;
|
||||
x.preserve_chmod_bits = 1;
|
||||
@@ -758,6 +779,9 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
used_P_option = 1;
|
||||
/* fall through */
|
||||
case PARENTS_OPTION:
|
||||
flag_path = 1;
|
||||
break;
|
||||
|
||||
@@ -819,6 +843,14 @@ main (int argc, char **argv)
|
||||
usage (1);
|
||||
}
|
||||
|
||||
if (used_P_option)
|
||||
{
|
||||
error (0, 0,
|
||||
_("\
|
||||
Warning: the meaning of `-P' will change in the future to conform to POSIX.\n\
|
||||
Use `--parents' for the old meaning, and `--no-dereference' for the new."));
|
||||
}
|
||||
|
||||
if (backup_suffix_string)
|
||||
simple_backup_suffix = xstrdup (backup_suffix_string);
|
||||
|
||||
@@ -830,13 +862,27 @@ main (int argc, char **argv)
|
||||
if (x.preserve_chmod_bits == 1)
|
||||
x.umask_kill = ~ (mode_t) 0;
|
||||
|
||||
if (x.dereference == DEREF_UNDEFINED)
|
||||
{
|
||||
if (x.recursive)
|
||||
/* This is compatible with FreeBSD. */
|
||||
x.dereference = DEREF_NEVER;
|
||||
else
|
||||
x.dereference = DEREF_ALWAYS;
|
||||
}
|
||||
|
||||
/* The key difference between -d (--no-dereference) and not is the version
|
||||
of `stat' to call. */
|
||||
|
||||
if (x.dereference)
|
||||
x.xstat = stat;
|
||||
else
|
||||
if (x.dereference == DEREF_NEVER)
|
||||
x.xstat = lstat;
|
||||
else
|
||||
{
|
||||
/* For DEREF_COMMAND_LINE_ARGUMENTS, x.xstat must be stat for
|
||||
each command line argument, but must later be `lstat' for
|
||||
any symlinks that are found via recursive traversal. */
|
||||
x.xstat = stat;
|
||||
}
|
||||
|
||||
/* Allocate space for remembering copied and created files. */
|
||||
|
||||
|
||||
@@ -46,10 +46,6 @@
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define FALSE 0
|
||||
# define TRUE 1
|
||||
|
||||
@@ -478,9 +478,9 @@ cut_fields (FILE *stream)
|
||||
delim, '\n', 0);
|
||||
if (len < 0)
|
||||
{
|
||||
if (feof (stream))
|
||||
if (ferror (stream) || feof (stream))
|
||||
break;
|
||||
FATAL_ERROR (_("Memory exhausted"));
|
||||
xalloc_die ();
|
||||
}
|
||||
|
||||
assert (len != 0);
|
||||
|
||||
13
src/df.c
13
src/df.c
@@ -39,6 +39,7 @@
|
||||
#include "human.h"
|
||||
#include "mountlist.h"
|
||||
#include "path-concat.h"
|
||||
#include "quote.h"
|
||||
#include "save-cwd.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -275,7 +276,7 @@ show_dev (const char *disk, const char *mount_point, const char *fstype,
|
||||
|
||||
if (get_fs_usage (stat_file, disk, &fsu))
|
||||
{
|
||||
error (0, errno, "%s", stat_file);
|
||||
error (0, errno, "%s", quote (stat_file));
|
||||
exit_status = 1;
|
||||
return;
|
||||
}
|
||||
@@ -627,7 +628,7 @@ show_point (const char *point, const struct stat *statp)
|
||||
me->me_dev = disk_stats.st_dev;
|
||||
else
|
||||
{
|
||||
error (0, errno, "%s", me->me_mountdir);
|
||||
error (0, errno, "%s", quote (me->me_mountdir));
|
||||
exit_status = 1;
|
||||
/* So we won't try and fail repeatedly. */
|
||||
me->me_dev = (dev_t) -2;
|
||||
@@ -666,7 +667,7 @@ show_point (const char *point, const struct stat *statp)
|
||||
free (mp);
|
||||
}
|
||||
else
|
||||
error (0, errno, "%s", point);
|
||||
error (0, errno, "%s", quote (point));
|
||||
}
|
||||
|
||||
goto free_then_return;
|
||||
@@ -872,8 +873,8 @@ main (int argc, char **argv)
|
||||
if (STREQ (fs_incl->fs_name, fs_excl->fs_name))
|
||||
{
|
||||
error (0, 0,
|
||||
_("file system type `%s' both selected and excluded"),
|
||||
fs_incl->fs_name);
|
||||
_("file system type %s both selected and excluded"),
|
||||
quote (fs_incl->fs_name));
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
@@ -894,7 +895,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
if (stat (argv[i], &stats[i - optind]))
|
||||
{
|
||||
error (0, errno, "%s", argv[i]);
|
||||
error (0, errno, "%s", quote (argv[i]));
|
||||
exit_status = 1;
|
||||
argv[i] = NULL;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user