mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
198 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7fca77515 | ||
|
|
032bbff2da | ||
|
|
5581bf28e3 | ||
|
|
5eeaca942a | ||
|
|
f85ca2c876 | ||
|
|
ac5739d317 | ||
|
|
0cefe58092 | ||
|
|
7490145dd0 | ||
|
|
d8945c8d8f | ||
|
|
832c85e3f7 | ||
|
|
3d2e55d508 | ||
|
|
37784220dd | ||
|
|
551cbda027 | ||
|
|
af5f2d741b | ||
|
|
44f7444987 | ||
|
|
ac54e1e4d2 | ||
|
|
a8c7983629 | ||
|
|
38e3a90e4b | ||
|
|
197cd0994d | ||
|
|
0d89a42bff | ||
|
|
df9cd0a426 | ||
|
|
683ee76ad2 | ||
|
|
24a1a8c473 | ||
|
|
6a2751d59d | ||
|
|
ebc63d33ea | ||
|
|
1f93c96339 | ||
|
|
423b079f53 | ||
|
|
0ba576979a | ||
|
|
036a9c6909 | ||
|
|
faf5fbeb36 | ||
|
|
4a1527908b | ||
|
|
dce1da2b57 | ||
|
|
4cf9eb5282 | ||
|
|
7055579067 | ||
|
|
005534907c | ||
|
|
149499925e | ||
|
|
0b27edfe1d | ||
|
|
554caaf6ff | ||
|
|
8e2767a3f0 | ||
|
|
bbcf3abc2c | ||
|
|
7eaff0fea3 | ||
|
|
e24c711cbc | ||
|
|
c88f6f22c7 | ||
|
|
e9ced81139 | ||
|
|
0be1ae6620 | ||
|
|
6ab90b53f6 | ||
|
|
42300faaa9 | ||
|
|
2aea1828a1 | ||
|
|
b2bb19b4b3 | ||
|
|
5f35396395 | ||
|
|
e772bddde8 | ||
|
|
f28a09810b | ||
|
|
aeb5222a6d | ||
|
|
42c4ba6ceb | ||
|
|
c29cb31b7f | ||
|
|
339613b6bd | ||
|
|
f603b2d228 | ||
|
|
f3b473c579 | ||
|
|
65a0483fb5 | ||
|
|
dc7284ef72 | ||
|
|
7e576fc403 | ||
|
|
240a633756 | ||
|
|
2d9b49789f | ||
|
|
8f1629f0ad | ||
|
|
8d8f5f1028 | ||
|
|
84185eda59 | ||
|
|
efec1600c9 | ||
|
|
837e1f5519 | ||
|
|
750fadd5d3 | ||
|
|
63613d4935 | ||
|
|
4f71710c42 | ||
|
|
feb0b08c0d | ||
|
|
be6120b5cc | ||
|
|
acdf4e99e6 | ||
|
|
2c558fd0d3 | ||
|
|
7700751c5f | ||
|
|
bf0771a1c5 | ||
|
|
6cafe09c33 | ||
|
|
f8f1c8111e | ||
|
|
af1ffdff17 | ||
|
|
f2dabd6806 | ||
|
|
5a647a05e2 | ||
|
|
4d90d29899 | ||
|
|
4496c94091 | ||
|
|
28a7fb52bc | ||
|
|
b358f1f2a3 | ||
|
|
33171d049a | ||
|
|
88bdce982a | ||
|
|
473b4fc1e8 | ||
|
|
84d048002e | ||
|
|
76d8e9abe1 | ||
|
|
e7734b4a66 | ||
|
|
0c87ba4693 | ||
|
|
10ec91d84a | ||
|
|
18839ad9c1 | ||
|
|
54cbe6e643 | ||
|
|
5f4a1cda67 | ||
|
|
171e1b9815 | ||
|
|
376b19410e | ||
|
|
6301c72b6f | ||
|
|
1d919fbb7f | ||
|
|
ea7c77df7f | ||
|
|
b970f0a505 | ||
|
|
2f60384d6a | ||
|
|
a51c6e0356 | ||
|
|
e23f179557 | ||
|
|
24b3c8b160 | ||
|
|
c8392b368e | ||
|
|
51e9f0308e | ||
|
|
4c3c2c795e | ||
|
|
f0e8f13ead | ||
|
|
23ddefd3d1 | ||
|
|
7df26ae6fe | ||
|
|
2e580ca741 | ||
|
|
13672ec321 | ||
|
|
7f8d9892fb | ||
|
|
6b687452d8 | ||
|
|
ef6e57b24b | ||
|
|
83e424e731 | ||
|
|
6fb9aeedd1 | ||
|
|
2f5c2a25ed | ||
|
|
cd94370f74 | ||
|
|
5a3879ad03 | ||
|
|
e4feb5c03b | ||
|
|
7c77c93dc5 | ||
|
|
869202a18c | ||
|
|
77d41d2e20 | ||
|
|
c2b25223c1 | ||
|
|
b7332b889e | ||
|
|
ccf2d9a482 | ||
|
|
cc8ee4d351 | ||
|
|
e7b4bf4b57 | ||
|
|
c1716a1ebf | ||
|
|
5c557690d8 | ||
|
|
d4aca64b53 | ||
|
|
31bbcc7abf | ||
|
|
d0a9750e08 | ||
|
|
963d809ae9 | ||
|
|
54a49f22ae | ||
|
|
6b282e7510 | ||
|
|
8a26bccb46 | ||
|
|
ad756440fb | ||
|
|
419b6c9d42 | ||
|
|
d7e2365203 | ||
|
|
3f98fe3155 | ||
|
|
a042bba6c7 | ||
|
|
41139da2e7 | ||
|
|
bfffa90947 | ||
|
|
6eec064597 | ||
|
|
5908e29e82 | ||
|
|
d92849fe5a | ||
|
|
e89c998a9e | ||
|
|
bf9d4f1317 | ||
|
|
56a88e9522 | ||
|
|
484df12639 | ||
|
|
dac67b8cc2 | ||
|
|
7d44751f0e | ||
|
|
9ead32a9be | ||
|
|
64ceb14984 | ||
|
|
0a8d30534b | ||
|
|
ac9c5330df | ||
|
|
acbfebeb8d | ||
|
|
d61f5a1c16 | ||
|
|
12c5386a30 | ||
|
|
485a454576 | ||
|
|
cb4a0e31e2 | ||
|
|
beaa949313 | ||
|
|
50ca38e523 | ||
|
|
5116103826 | ||
|
|
27873f1deb | ||
|
|
9d152a1ed7 | ||
|
|
76f49e601e | ||
|
|
89d542f3d8 | ||
|
|
a085b6fc6c | ||
|
|
6bc73ee56e | ||
|
|
eec0e6d2e4 | ||
|
|
9418e01abe | ||
|
|
2141543a37 | ||
|
|
73fd918bd0 | ||
|
|
3c8ff029d4 | ||
|
|
09baf2287e | ||
|
|
2644e288e4 | ||
|
|
a09d9e5bad | ||
|
|
a1f21327eb | ||
|
|
ebce7bfb1b | ||
|
|
9aeffd3fe5 | ||
|
|
719dcc7f01 | ||
|
|
73243f181d | ||
|
|
9d282141ba | ||
|
|
47ef7504da | ||
|
|
4b28ff7f32 | ||
|
|
efa479c1e5 | ||
|
|
b83d289685 | ||
|
|
c1effb1f2b | ||
|
|
d78ccd5949 | ||
|
|
3ed91fc8b9 | ||
|
|
1560848265 | ||
|
|
e3f814a773 |
2
.mailmap
2
.mailmap
@@ -23,6 +23,8 @@ Pádraig Brady <p@draigBrady.com> <P@draigBrady.com>
|
||||
<jrv@debian.org> <jrvz@comcast.net>
|
||||
<dave.anglin@nrc.ca> <dave@hiauly1.hia.nrc.ca>
|
||||
<psfales@alcatel-lucent.com> <psfales@lucent.com>
|
||||
<karl@gnu.org> <karl@freefriends.org>
|
||||
<stephane.raimbault@gmail.com> <stephane.raimbault@makina-corpus.com>
|
||||
|
||||
# Prefer spelled-out middle name and its address.
|
||||
Arne Henrik Juul <arnej@imf.unit.no> Arne H. Juul <arnej@solan.unit.no>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.11
|
||||
8.12
|
||||
|
||||
31
HACKING
31
HACKING
@@ -349,10 +349,25 @@ this code enables the right mode:
|
||||
(not (string-equal mode-name "Makefile")))
|
||||
(setq indent-tabs-mode nil))))
|
||||
|
||||
[*] Makefile and ChangeLog files are exempt, of course.
|
||||
If you use vim (7+ compiled with autocommands), and coreutils working
|
||||
directory name also matches, add the following in ~/.vimrc:
|
||||
|
||||
[FIXME: suggest vim syntax to do same thing, if it can be done safely.
|
||||
Most distros now "set nomodeline" by default for a good reason. ]
|
||||
" Set GNU style indentation, spaces instead of TABs
|
||||
function! CoreutilsIndent()
|
||||
" Check if 'coreutils' is part of the current working directory
|
||||
if match(getcwd(), "coreutils") > 0
|
||||
" The next 3 lines below set the GNU indentation
|
||||
setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
|
||||
setlocal shiftwidth=2
|
||||
setlocal tabstop=8
|
||||
" Coreutils specific, expand TABs with spaces
|
||||
setlocal expandtab
|
||||
endif
|
||||
endfunction
|
||||
|
||||
autocmd BufEnter *.c,*.h call CoreutilsIndent()
|
||||
|
||||
[*] Makefile and ChangeLog files are exempt, of course.
|
||||
|
||||
|
||||
Send patches to the address listed in --help output
|
||||
@@ -415,6 +430,16 @@ as possible. Note to run tests/misc/new-test in isolation you can do:
|
||||
|
||||
(cd tests && make check TESTS=misc/new-test VERBOSE=yes)
|
||||
|
||||
Variables that are significant for tests with their default values are:
|
||||
|
||||
VERBOSE=yes
|
||||
RUN_EXPENSIVE_TESTS=no
|
||||
RUN_VERY_EXPENSIVE_TESTS=no
|
||||
SHELL=/bin/sh
|
||||
NON_ROOT_USERNAME=nobody
|
||||
NON_ROOT_GROUP=$(id -g $NON_ROOT_USERNAME)
|
||||
COREUTILS_GROUPS=$(id -G)
|
||||
|
||||
There are hundreds of tests in the tests/ directories. You can use
|
||||
tests/sample-test as a template, or one of the various Perl-based ones
|
||||
in tests/misc.
|
||||
|
||||
@@ -25,7 +25,6 @@ changelog_etc = \
|
||||
ChangeLog-2007 \
|
||||
ChangeLog-2008 \
|
||||
build-aux/ChangeLog-2007 \
|
||||
build-aux/update-copyright \
|
||||
doc/ChangeLog-2007 \
|
||||
lib/ChangeLog-2007 \
|
||||
m4/ChangeLog-2007 \
|
||||
@@ -53,7 +52,6 @@ EXTRA_DIST = \
|
||||
build-aux/cvsu \
|
||||
cfg.mk \
|
||||
dist-check.mk \
|
||||
gl/modules/getloadavg.diff \
|
||||
maint.mk \
|
||||
thanks-gen
|
||||
|
||||
|
||||
116
NEWS
116
NEWS
@@ -1,5 +1,110 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 8.13 (2011-09-08) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chown and chgrp with the -v --from= options, now output the correct owner.
|
||||
I.E. for skipped files, the original ownership is output, not the new one.
|
||||
[bug introduced in sh-utils-2.0g]
|
||||
|
||||
cp -r could mistakenly change the permissions of an existing destination
|
||||
directory. [bug introduced in coreutils-6.8]
|
||||
|
||||
cp -u -p would fail to preserve one hard link for each up-to-date copy
|
||||
of a src-hard-linked name in the destination tree. I.e., if s/a and s/b
|
||||
are hard-linked and dst/s/a is up to date, "cp -up s dst" would copy s/b
|
||||
to dst/s/b rather than simply linking dst/s/b to dst/s/a.
|
||||
[This bug appears to have been present in "the beginning".]
|
||||
|
||||
fts-using tools (rm, du, chmod, chgrp, chown, chcon) no longer use memory
|
||||
proportional to the number of entries in each directory they process.
|
||||
Before, rm -rf 4-million-entry-directory would consume about 1GiB of memory.
|
||||
Now, it uses less than 30MB, no matter how many entries there are.
|
||||
[this bug was inherent in the use of fts: thus, for rm the bug was
|
||||
introduced in coreutils-8.0. The prior implementation of rm did not use
|
||||
as much memory. du, chmod, chgrp and chown started using fts in 6.0.
|
||||
chcon was added in coreutils-6.9.91 with fts support. ]
|
||||
|
||||
pr -T no longer ignores a specified LAST_PAGE to stop at.
|
||||
[bug introduced in textutils-1.19q]
|
||||
|
||||
printf '%d' '"' no longer accesses out-of-bounds memory in the diagnostic.
|
||||
[bug introduced in sh-utils-1.16]
|
||||
|
||||
split --number l/... no longer creates extraneous files in certain cases.
|
||||
[bug introduced in coreutils-8.8]
|
||||
|
||||
timeout now sends signals to commands that create their own process group.
|
||||
timeout is no longer confused when starting off with a child process.
|
||||
[bugs introduced in coreutils-7.0]
|
||||
|
||||
unexpand -a now aligns correctly when there are spaces spanning a tabstop,
|
||||
followed by a tab. In that case a space was dropped, causing misalignment.
|
||||
We also now ensure that a space never precedes a tab.
|
||||
[bug introduced in coreutils-5.3.0]
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
chmod, chown and chgrp now output the original attributes in messages,
|
||||
when -v or -c specified.
|
||||
|
||||
cp -au (where --preserve=links is implicit) may now replace newer
|
||||
files in the destination, to mirror hard links from the source.
|
||||
|
||||
** New features
|
||||
|
||||
date now accepts ISO 8601 date-time strings with "T" as the
|
||||
separator. It has long parsed dates like "2004-02-29 16:21:42"
|
||||
with a space between the date and time strings. Now it also parses
|
||||
"2004-02-29T16:21:42" and fractional-second and time-zone-annotated
|
||||
variants like "2004-02-29T16:21:42.333-07:00"
|
||||
|
||||
md5sum accepts the new --strict option. With --check, it makes the
|
||||
tool exit non-zero for any invalid input line, rather than just warning.
|
||||
This also affects sha1sum, sha224sum, sha384sum and sha512sum.
|
||||
|
||||
split accepts a new --filter=CMD option. With it, split filters output
|
||||
through CMD. CMD may use the $FILE environment variable, which is set to
|
||||
the nominal output file name for each invocation of CMD. For example, to
|
||||
split a file into 3 approximately equal parts, which are then compressed:
|
||||
split -n3 --filter='xz > $FILE.xz' big
|
||||
Note the use of single quotes, not double quotes.
|
||||
That creates files named xaa.xz, xab.xz and xac.xz.
|
||||
|
||||
timeout accepts a new --foreground option, to support commands not started
|
||||
directly from a shell prompt, where the command is interactive or needs to
|
||||
receive signals initiated from the terminal.
|
||||
|
||||
** Improvements
|
||||
|
||||
cp -p now copies trivial NSFv4 ACLs on Solaris 10. Before, it would
|
||||
mistakenly apply a non-trivial ACL to the destination file.
|
||||
|
||||
cp and ls now support HP-UX 11.11's ACLs, thanks to improved support
|
||||
in gnulib.
|
||||
|
||||
df now supports disk partitions larger than 4 TiB on MacOS X 10.5
|
||||
or newer and on AIX 5.2 or newer.
|
||||
|
||||
join --check-order now prints "join: FILE:LINE_NUMBER: bad_line" for an
|
||||
unsorted input, rather than e.g., "join: file 1 is not in sorted order".
|
||||
|
||||
shuf outputs small subsets of large permutations much more efficiently.
|
||||
For example `shuf -i1-$((2**32-1)) -n2` no longer exhausts memory.
|
||||
|
||||
stat -f now recognizes the GPFS, MQUEUE and PSTOREFS file system types.
|
||||
|
||||
timeout now supports sub-second timeouts.
|
||||
|
||||
** Build-related
|
||||
|
||||
Changes inherited from gnulib address a build failure on HP-UX 11.11
|
||||
when using /opt/ansic/bin/cc.
|
||||
|
||||
Numerous portability and build improvements inherited via gnulib.
|
||||
|
||||
|
||||
* Noteworthy changes in release 8.12 (2011-04-26) [stable]
|
||||
|
||||
** Bug fixes
|
||||
@@ -1039,7 +1144,8 @@ GNU coreutils NEWS -*- outline -*-
|
||||
join has significantly better performance due to better memory management
|
||||
|
||||
ls now uses constant memory when not sorting and using one_per_line format,
|
||||
no matter how many files are in a given directory
|
||||
no matter how many files are in a given directory. I.e., to list a directory
|
||||
with very many files, ls -1U is much more efficient.
|
||||
|
||||
od now aligns fields across lines when printing multiple -t
|
||||
specifiers, and no longer prints fields that resulted entirely from
|
||||
@@ -1053,6 +1159,12 @@ GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 6.12 (2008-05-31) [stable]
|
||||
|
||||
** New features
|
||||
|
||||
cp, install, mv, and touch now preserve nanosecond resolution on
|
||||
file timestamps, on platforms that have the 'utimensat' and
|
||||
'futimens' system calls.
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chcon, runcon: --help output now includes the bug-reporting address
|
||||
@@ -1465,7 +1577,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
"rm --interactive=never F" no longer prompts for an unwritable F
|
||||
|
||||
"rm -rf D" would emit an misleading diagnostic when failing to
|
||||
"rm -rf D" would emit a misleading diagnostic when failing to
|
||||
remove a symbolic link within the unwritable directory, D.
|
||||
Introduced in coreutils-6.0. Similarly, when a cross-partition
|
||||
"mv" fails because the source directory is unwritable, it now gives
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
These notes intend to help people working on the checked-out sources.
|
||||
These requirements do not apply when building from a distribution tarball.
|
||||
See also HACKING for more detailed coreutils contribution guidelines.
|
||||
See also HACKING for more detailed contribution guidelines.
|
||||
|
||||
* Requirements
|
||||
|
||||
@@ -78,11 +78,14 @@ each program. One way to do this is to use vc-dwim
|
||||
"git-changelog-symlink-init" function into your shell, and then run
|
||||
this function at the top-level directory of the package.
|
||||
|
||||
Edit the ChangeLog file that this command creates, creating a
|
||||
Edit the (empty) ChangeLog file that this command creates, creating a
|
||||
properly-formatted entry according to the GNU coding standards
|
||||
<http://www.gnu.org/prep/standards/html_node/Change-Logs.html>.
|
||||
|
||||
Run the command "vc-dwim" and make sure its output looks good.
|
||||
Make your changes.
|
||||
|
||||
Run the command "vc-dwim" and make sure its output (the diff of all
|
||||
your changes) looks good.
|
||||
|
||||
Run "vc-dwim --commit".
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ FIXME: enable excluded programs like arch? to get their manual pages?
|
||||
&& make distcheck \
|
||||
&& make -j$n check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
|
||||
|
||||
If testing on systems with a non standard default shell, spurious failures
|
||||
may occur. Often there are other shells available, and you can select
|
||||
those by using for example, SHELL=bash in the commands above.
|
||||
|
||||
Note that the use of -j$n tells make to use approximately half of the
|
||||
available processing units. If you use -jN, for larger N, some of the
|
||||
expensive tests are likely to interfere with concurrent performance-measuring
|
||||
|
||||
12
THANKS.in
12
THANKS.in
@@ -23,7 +23,6 @@ Adrian Bunk bunk@stusta.de
|
||||
AIDA Shinra shinra@j10n.org
|
||||
Akim Demaille demaille@inf.enst.fr
|
||||
Alain Magloire alain@qnx.com
|
||||
Alan Curry pacman@kosh.dhis.org
|
||||
Alan Iwi iwi@atm.ox.ac.uk
|
||||
Albert Chin-A-Young china@thewrittenword.com
|
||||
Albert Hopkins ahopkins@dynacare.com
|
||||
@@ -81,7 +80,6 @@ Bernd Melchers melchers@cis.fu-berlin.de
|
||||
Bernhard Baehr bernhard.baehr@gmx.de
|
||||
Bernhard Gabler bernhard@uni-koblenz.de
|
||||
Bernhard Rosenkraenzer bero@redhat.de
|
||||
Bernhard Voelker bernhard.voelker@siemens-enterprise.com
|
||||
Bert Deknuydt Bert.Deknuydt@esat.kuleuven.ac.be
|
||||
Bert Wesarg bert.wesarg@googlemail.com
|
||||
Bill Brelsford wb@k2di.net
|
||||
@@ -94,6 +92,7 @@ Brian Kimball bfk@footbag.org
|
||||
Brian M. Carlson sandals@crustytoothpaste.ath.cx
|
||||
Brian Silverman bsilverman@conceptxdesign.com
|
||||
Brian Youmans 3diff@gnu.org
|
||||
Britton Leo Kerin fsblk@aurora.uaf.edu
|
||||
Bruce Robertson brucer@theodolite.dyndns.org
|
||||
Carl Johnson carlj@cjlinux.home.org
|
||||
Carl Lowenstein cdl@mpl.UCSD.EDU
|
||||
@@ -140,6 +139,7 @@ David Alan Gilbert gilbertd@treblig.org
|
||||
David Dyck dcd@tc.fluke.COM
|
||||
David Eisner cradle@umd.edu
|
||||
David Flynn dav@chess.plus.com
|
||||
David Gast dgast@csulb.edu
|
||||
David Godfrey dave@delta.demon.co.uk
|
||||
David Luyer david_luyer@pacific.net.au
|
||||
David Madore david.madore@ens.fr
|
||||
@@ -262,6 +262,7 @@ Jan Moringen jan.moringen@uni-bielefeld.de
|
||||
Jan Nieuwenhuizen janneke@gnu.org
|
||||
Jan-Pawel Wrozstinski jpwroz@gmail.com
|
||||
Janos Farkas chexum@shadow.banki.hu
|
||||
Jari Aalto jari.aalto@cante.net
|
||||
Jarkko Hietaniemi jhi@epsilon.hut.fi
|
||||
Jarod Wilson jwilson@redhat.com
|
||||
Jean Charles Delepine delepine@u-picardie.fr
|
||||
@@ -278,6 +279,7 @@ Jesse Thilo jgt2@eecs.lehigh.edu
|
||||
Jie Xu xuj@iag.net
|
||||
Jim Blandy jimb@cyclic.com
|
||||
Jim Dennis jimd@starshine.org
|
||||
Joachim Schmitz jojo@schmitz-digital.de
|
||||
Joakim Rosqvist dvljrt@cs.umu.se
|
||||
Jochen Hein jochen@jochen.org
|
||||
Joe Orton joe@manyfish.co.uk
|
||||
@@ -297,6 +299,7 @@ John Stanley johnstops@verizon.net
|
||||
John Summerfield summer@OS2.ami.com.au
|
||||
Jon Peatfield J.S.Peatfield@damtp.cam.ac.uk
|
||||
Joost van Baal joostvb@xs4all.nl
|
||||
Jordi Pujol jordipujolp@gmail.com
|
||||
Jorge Stolfi stolfi@ic.unicamp.br
|
||||
Joseph S. Myers jsm28@cam.ac.uk
|
||||
Josh Triplett josh@freedesktop.org
|
||||
@@ -315,7 +318,6 @@ Kai-Uwe Rommel rommel@informatik.tu-muenchen.de
|
||||
Kalle Olavi Niemitalo kon@iki.fi
|
||||
Kamal Paul Nigam Kamal_Paul_Nigam@gs35.sp.cs.cmu.edu
|
||||
Karl Eichwalder keichwa@gmx.net
|
||||
Karl Heuer kwzh@gnu.org
|
||||
Karl-Michael Schneider schneide@phil.uni-passau.de
|
||||
Karsten Thygesen karthy@kom.auc.dk
|
||||
Kaveh R. Ghazi ghazi@caip.rutgers.edu
|
||||
@@ -450,12 +452,14 @@ Patrick Mauritz oxygene@studentenbude.ath.cx
|
||||
Paul D. Smith psmith@gnu.org
|
||||
Paul Ghaleb paul.ghaleb@st.com
|
||||
Paul Jarc prj@po.cwru.edu
|
||||
Paul Marinescu paul.marinescu@imperial.ac.uk
|
||||
Paul Nevai nevai@ops.mps.ohio-state.edu
|
||||
Paul Sauer paul@alexa.com
|
||||
Paul Slootman paul@debian.org
|
||||
Paul Townsend aab@purdue.edu
|
||||
Paul Worrall paul@basilisk.uklinux.net
|
||||
Pawel Prokop pablo@wizard.ae.krakow.pl
|
||||
Peng Yu pengyu.ut@gmail.com
|
||||
Per Cederqvist ceder@lysator.liu.se
|
||||
Per Kristian Hove perhov@math.ntnu.no
|
||||
Per Starbäck starback@stp.lingfil.uu.se
|
||||
@@ -491,6 +495,7 @@ Richard J. Rauenzahn rrauenza@hairball.cup.hp.com
|
||||
Richard Neill rn214@hermes.cam.ac.uk
|
||||
Richard Sharman rsharman@magmacom.com
|
||||
Rick Sladkey jrs@world.std.com
|
||||
Rick Stanley rstanley@rsiny.com
|
||||
Rik Faith faith@cs.unc.edu
|
||||
Risto Kankkunen kankkune@lingsoft.fi
|
||||
Rob Wortman wyrm@haell.com
|
||||
@@ -587,6 +592,7 @@ Uwe H. Steinfeld usteinfeld@gmx.net
|
||||
Vesselin Atanasov vesselin@bgnet.bg
|
||||
Ville Skyttä ville.skytta@iki.fi
|
||||
Vin Shelton acs@alumni.princeton.edu
|
||||
Vincent Lefevre vincent@vinc17.org
|
||||
Vineet Chadha chadha@acis.ufl.edu
|
||||
Vitali Lovich vlovich@gmail.com
|
||||
Vitaly A. Ostanin vyt@altlinux.org
|
||||
|
||||
105
bootstrap
105
bootstrap
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Print a version string.
|
||||
scriptversion=2011-03-03.12; # UTC
|
||||
scriptversion=2011-08-11.17; # UTC
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
@@ -130,18 +130,7 @@ source_base=lib
|
||||
m4_base=m4
|
||||
doc_base=doc
|
||||
tests_base=tests
|
||||
|
||||
# Extra files from gnulib, which override files from other sources.
|
||||
gnulib_extra_files="
|
||||
$build_aux/install-sh
|
||||
$build_aux/missing
|
||||
$build_aux/mdate-sh
|
||||
$build_aux/texinfo.tex
|
||||
$build_aux/depcomp
|
||||
$build_aux/config.guess
|
||||
$build_aux/config.sub
|
||||
doc/INSTALL
|
||||
"
|
||||
gnulib_extra_files=''
|
||||
|
||||
# Additional gnulib-tool options to use. Use "\newline" to break lines.
|
||||
gnulib_tool_option_extras=
|
||||
@@ -229,6 +218,18 @@ case "$0" in
|
||||
*) test -r "$0.conf" && . ./"$0.conf" ;;
|
||||
esac
|
||||
|
||||
# Extra files from gnulib, which override files from other sources.
|
||||
test -z "${gnulib_extra_files}" && \
|
||||
gnulib_extra_files="
|
||||
$build_aux/install-sh
|
||||
$build_aux/missing
|
||||
$build_aux/mdate-sh
|
||||
$build_aux/texinfo.tex
|
||||
$build_aux/depcomp
|
||||
$build_aux/config.guess
|
||||
$build_aux/config.sub
|
||||
doc/INSTALL
|
||||
"
|
||||
|
||||
if test "$vc_ignore" = auto; then
|
||||
vc_ignore=
|
||||
@@ -278,14 +279,29 @@ if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure that lines starting with ! sort last, per gitignore conventions
|
||||
# for whitelisting exceptions after a more generic blacklist pattern.
|
||||
sort_patterns() {
|
||||
sort -u "$@" | sed '/^!/ {
|
||||
H
|
||||
d
|
||||
}
|
||||
$ {
|
||||
P
|
||||
x
|
||||
s/^\n//
|
||||
}' | sed '/^$/d'
|
||||
}
|
||||
|
||||
# If $STR is not already on a line by itself in $FILE, insert it,
|
||||
# sorting the new contents of the file and replacing $FILE with the result.
|
||||
insert_sorted_if_absent() {
|
||||
file=$1
|
||||
str=$2
|
||||
test -f $file || touch $file
|
||||
echo "$str" | sort -u - $file | cmp - $file > /dev/null \
|
||||
|| echo "$str" | sort -u - $file -o $file \
|
||||
echo "$str" | sort_patterns - $file | cmp - $file > /dev/null \
|
||||
|| { echo "$str" | sort_patterns - $file > $file.bak \
|
||||
&& mv $file.bak $file; } \
|
||||
|| exit 1
|
||||
}
|
||||
|
||||
@@ -405,18 +421,32 @@ check_versions() {
|
||||
# Honor $APP variables ($TAR, $AUTOCONF, etc.)
|
||||
appvar=`echo $app | tr '[a-z]-' '[A-Z]_'`
|
||||
test "$appvar" = TAR && appvar=AMTAR
|
||||
eval "app=\${$appvar-$app}"
|
||||
inst_ver=$(get_version $app)
|
||||
if [ ! "$inst_ver" ]; then
|
||||
echo "$me: Error: '$app' not found" >&2
|
||||
ret=1
|
||||
elif [ ! "$req_ver" = "-" ]; then
|
||||
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
|
||||
if [ ! "$latest_ver" = "$inst_ver" ]; then
|
||||
echo "$me: Error: '$app' version == $inst_ver is too old" >&2
|
||||
echo " '$app' version >= $req_ver is required" >&2
|
||||
case $appvar in
|
||||
GZIP) ;; # Do not use $GZIP: it contains gzip options.
|
||||
*) eval "app=\${$appvar-$app}" ;;
|
||||
esac
|
||||
if [ "$req_ver" = "-" ]; then
|
||||
# Merely require app to exist; not all prereq apps are well-behaved
|
||||
# so we have to rely on $? rather than get_version.
|
||||
$app --version >/dev/null 2>&1
|
||||
if [ 126 -le $? ]; then
|
||||
echo "$me: Error: '$app' not found" >&2
|
||||
ret=1
|
||||
fi
|
||||
else
|
||||
# Require app to produce a new enough version string.
|
||||
inst_ver=$(get_version $app)
|
||||
if [ ! "$inst_ver" ]; then
|
||||
echo "$me: Error: '$app' not found" >&2
|
||||
ret=1
|
||||
else
|
||||
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
|
||||
if [ ! "$latest_ver" = "$inst_ver" ]; then
|
||||
echo "$me: Error: '$app' version == $inst_ver is too old" >&2
|
||||
echo " '$app' version >= $req_ver is required" >&2
|
||||
ret=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -640,10 +670,18 @@ symlink_to_dir()
|
||||
cp -fp "$src" "$dst"
|
||||
}
|
||||
else
|
||||
# Leave any existing symlink alone, if it already points to the source,
|
||||
# so that broken build tools that care about symlink times
|
||||
# aren't confused into doing unnecessary builds. Conversely, if the
|
||||
# existing symlink's time stamp is older than the source, make it afresh,
|
||||
# so that broken tools aren't confused into skipping needed builds. See
|
||||
# <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
|
||||
test -h "$dst" &&
|
||||
src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
|
||||
dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
|
||||
test "$src_i" = "$dst_i" || {
|
||||
test "$src_i" = "$dst_i" &&
|
||||
both_ls=`ls -dt "$src" "$dst"` &&
|
||||
test "X$both_ls" = "X$dst$nl$src" || {
|
||||
dot_dots=
|
||||
case $src in
|
||||
/*) ;;
|
||||
@@ -762,20 +800,7 @@ slurp() {
|
||||
echo "$me: $dir/$file overrides $1/$dir/$file"
|
||||
else
|
||||
copied=$copied$sep$file; sep=$nl
|
||||
if test $file = gettext.m4; then
|
||||
echo "$me: patching m4/gettext.m4 to remove need for intl/* ..."
|
||||
rm -f $dir/$file
|
||||
sed '
|
||||
/^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
|
||||
AC_DEFUN([AM_INTL_SUBDIR], [])
|
||||
/^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
|
||||
AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
|
||||
$a\
|
||||
AC_DEFUN([gl_LOCK_EARLY], [])
|
||||
' $1/$dir/$file >$dir/$file
|
||||
else
|
||||
cp_mark_as_generated $1/$dir/$file $dir/$file
|
||||
fi
|
||||
cp_mark_as_generated $1/$dir/$file $dir/$file
|
||||
fi || exit
|
||||
done
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ avoided_gnulib_modules='
|
||||
# gnulib modules used by this package.
|
||||
gnulib_modules="
|
||||
$avoided_gnulib_modules
|
||||
$obsolete_gnulib_modules
|
||||
acl
|
||||
alignof
|
||||
alloca
|
||||
@@ -71,6 +70,7 @@ gnulib_modules="
|
||||
faccessat
|
||||
fadvise
|
||||
fchdir
|
||||
fclose
|
||||
fcntl
|
||||
fcntl-safer
|
||||
fdl
|
||||
@@ -101,7 +101,7 @@ gnulib_modules="
|
||||
getopt-gnu
|
||||
getpagesize
|
||||
getpass-gnu
|
||||
gettext-h
|
||||
gettext
|
||||
gettime
|
||||
gettimeofday
|
||||
getugroups
|
||||
@@ -125,6 +125,7 @@ gnulib_modules="
|
||||
inttypes
|
||||
isapipe
|
||||
isblank
|
||||
largefile
|
||||
lchmod
|
||||
lchown
|
||||
ldtoastr
|
||||
@@ -138,6 +139,7 @@ gnulib_modules="
|
||||
maintainer-makefile
|
||||
malloc-gnu
|
||||
manywarnings
|
||||
mbrlen
|
||||
mbrtowc
|
||||
mbsalign
|
||||
mbswidth
|
||||
@@ -159,7 +161,6 @@ gnulib_modules="
|
||||
nproc
|
||||
obstack
|
||||
parse-datetime
|
||||
pathmax
|
||||
perl
|
||||
physmem
|
||||
posix-shell
|
||||
@@ -197,6 +198,7 @@ gnulib_modules="
|
||||
sigaction
|
||||
ssize_t
|
||||
stat-macros
|
||||
stat-size
|
||||
stat-time
|
||||
stdbool
|
||||
stdlib-safer
|
||||
@@ -207,13 +209,13 @@ gnulib_modules="
|
||||
strsignal
|
||||
strtod
|
||||
strtoimax
|
||||
strtol
|
||||
strtoumax
|
||||
symlink
|
||||
sys_ioctl
|
||||
sys_stat
|
||||
sys_wait
|
||||
termios
|
||||
timer-time
|
||||
timespec
|
||||
tzset
|
||||
uname
|
||||
@@ -241,6 +243,7 @@ gnulib_modules="
|
||||
xalloc
|
||||
xfreopen
|
||||
xgetcwd
|
||||
xgetgroups
|
||||
xgethostname
|
||||
xmemcoll
|
||||
xnanosleep
|
||||
@@ -283,31 +286,6 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
|
||||
--keyword=proper_name_utf8:1,'"$see_manual"'\\\
|
||||
'
|
||||
|
||||
# If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]"
|
||||
# appears in configure.ac, exclude some unnecessary files.
|
||||
# Without grep's -E option (not portable enough, pre-configure),
|
||||
# the following test is ugly. Also, this depends on the existence
|
||||
# of configure.ac, not the obsolescent-named configure.in. But if
|
||||
# you're using this infrastructure, you should care about such things.
|
||||
|
||||
gettext_external=0
|
||||
grep '^[ ]*AM_GNU_GETTEXT(external\>' configure.ac > /dev/null &&
|
||||
gettext_external=1
|
||||
grep '^[ ]*AM_GNU_GETTEXT(\[external\]' configure.ac > /dev/null &&
|
||||
gettext_external=1
|
||||
|
||||
if test $gettext_external = 1; then
|
||||
# Gettext supplies these files, but we don't need them since
|
||||
# we don't have an intl subdirectory.
|
||||
excluded_files='
|
||||
m4/glibc2.m4
|
||||
m4/intdiv0.m4
|
||||
m4/uintmax_t.m4
|
||||
m4/ulonglong.m4
|
||||
m4/visibility.m4
|
||||
'
|
||||
fi
|
||||
|
||||
gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
|
||||
|
||||
# Build prerequisites
|
||||
@@ -320,7 +298,7 @@ gettext 0.17
|
||||
git 1.4.4
|
||||
gperf -
|
||||
gzip -
|
||||
makeinfo -
|
||||
makeinfo 4.13
|
||||
patch -
|
||||
perl 5.5
|
||||
rsync -
|
||||
|
||||
43
cfg.mk
43
cfg.mk
@@ -27,7 +27,7 @@ bootstrap-tools = autoconf,automake,gnulib,bison
|
||||
# Now that we have better tests, make this the default.
|
||||
export VERBOSE = yes
|
||||
|
||||
old_NEWS_hash = 656dc592d4ed57c83662be60caa1af9e
|
||||
old_NEWS_hash = d491296a7e0e2269b2b96dc4bd5f77a8
|
||||
|
||||
# Add an exemption for sc_makefile_at_at_check.
|
||||
_makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
|
||||
@@ -128,13 +128,9 @@ sc_sun_os_names:
|
||||
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
|
||||
exit 1; } || :
|
||||
|
||||
ALL_RECURSIVE_TARGETS += sc_tight_scope
|
||||
sc_tight_scope:
|
||||
@$(MAKE) -s -C src $@
|
||||
|
||||
ALL_RECURSIVE_TARGETS += sc_check-AUTHORS
|
||||
sc_check-AUTHORS:
|
||||
@$(MAKE) -s -C src $@
|
||||
@$(MAKE) -s -C src _sc_check-AUTHORS
|
||||
|
||||
# Look for lines longer than 80 characters, except omit:
|
||||
# - program-generated long lines in diff headers,
|
||||
@@ -209,7 +205,11 @@ sc_strftime_check:
|
||||
{ echo N; \
|
||||
info libc date calendar format 2>/dev/null|grep '^ `%.'\'\
|
||||
| $(extract_char); } | sort > $@-info; \
|
||||
diff -u $@-src $@-info || exit 1; \
|
||||
if test $$(stat --format %s $@-info) != 2; then \
|
||||
diff -u $@-src $@-info || exit 1; \
|
||||
else \
|
||||
echo '$(ME): skipping $@: libc info not installed' 1>&2; \
|
||||
fi; \
|
||||
rm -f $@-src $@-info; \
|
||||
fi
|
||||
|
||||
@@ -219,6 +219,14 @@ sc_prohibit_tab_based_indentation:
|
||||
halt='TAB in indentation; use only spaces' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# The SEE ALSO section of a man page should not be terminated with
|
||||
# a period. Check the first line after each "SEE ALSO" line in man/*.x:
|
||||
sc_prohibit_man_see_also_period:
|
||||
@grep -nB1 '\.$$' $$($(VC_LIST_EXCEPT) | grep 'man/.*\.x$$') \
|
||||
| grep -A1 -e '-\[SEE ALSO\]' | grep '\.$$' && \
|
||||
{ echo '$(ME): do not end "SEE ALSO" section with a period' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
|
||||
sc_prohibit_emacs__indent_tabs_mode__setting:
|
||||
@prohibit='^( *[*#] *)?indent-tabs-mode:' \
|
||||
@@ -262,6 +270,12 @@ sc_prohibit_verbose_version:
|
||||
halt='use the print_ver_ function instead...' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Use framework_failure_, not the old name without the trailing underscore.
|
||||
sc_prohibit_framework_failure:
|
||||
@prohibit='\<framework_''failure\>' \
|
||||
halt='use framework_failure_ instead' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
###########################################################
|
||||
_p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
|
||||
_pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
|
||||
@@ -324,11 +338,21 @@ sc_prohibit_strncmp:
|
||||
{ echo '$(ME): use STREQ_LEN or STRPREFIX instead of str''ncmp' \
|
||||
1>&2; exit 1; } || :
|
||||
|
||||
# Enforce recommended preprocessor indentation style.
|
||||
sc_preprocessor_indentation:
|
||||
@if cppi --version >/dev/null 2>&1; then \
|
||||
$(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c \
|
||||
|| { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
|
||||
exit 1; }; \
|
||||
else \
|
||||
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
|
||||
fi
|
||||
|
||||
# Override the default Cc: used in generating an announcement.
|
||||
announcement_Cc_ = $(translation_project_), \
|
||||
coreutils@gnu.org, coreutils-announce@gnu.org
|
||||
|
||||
include $(srcdir)/dist-check.mk
|
||||
-include $(srcdir)/dist-check.mk
|
||||
|
||||
update-copyright-env = \
|
||||
UPDATE_COPYRIGHT_USE_INTERVALS=1 \
|
||||
@@ -363,6 +387,9 @@ exclude_file_name_regexp--sc_prohibit_fail_0 = \
|
||||
exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
|
||||
exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
|
||||
^tests/pr/|(^gl/lib/reg.*\.c\.diff|Makefile(\.am)?|\.mk|^man/help2man)$$
|
||||
exclude_file_name_regexp--sc_preprocessor_indentation = \
|
||||
^(gl/lib/rand-isaac\.[ch]|gl/tests/test-rand-isaac\.c)$$
|
||||
|
||||
|
||||
exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
|
||||
^(src/system\.h|tests/du/2g)$$
|
||||
|
||||
21
configure.ac
21
configure.ac
@@ -18,7 +18,7 @@
|
||||
|
||||
dnl Written by Jim Meyering.
|
||||
|
||||
AC_PREREQ([2.62])
|
||||
AC_PREREQ([2.64])
|
||||
|
||||
# Make inter-release version strings look like, e.g., v6.9-219-g58ddd, which
|
||||
# indicates that it is built from the 219th delta (in _some_ repository)
|
||||
@@ -88,17 +88,22 @@ if test "$gl_gcc_warnings" = yes; then
|
||||
nw="$nw -Wmissing-format-attribute" # copy.c
|
||||
nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
|
||||
nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
|
||||
nw="$nw -Wstrict-overflow" # expr.c, pr.c, tr.c, factor.c
|
||||
# ?? -Wstrict-overflow
|
||||
|
||||
# Using -Wstrict-overflow is a pain, but the alternative is worse.
|
||||
# For an example, see the code that provoked this report:
|
||||
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
|
||||
# Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
|
||||
|
||||
gl_MANYWARN_ALL_GCC([ws])
|
||||
gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
|
||||
for w in $ws; do
|
||||
gl_WARN_ADD([$w])
|
||||
done
|
||||
gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
|
||||
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
|
||||
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
|
||||
gl_WARN_ADD([-Wsuggest-attribute=const])
|
||||
gl_WARN_ADD([-Wsuggest-attribute=pure])
|
||||
gl_WARN_ADD([-Wsuggest-attribute=noreturn])
|
||||
|
||||
# In spite of excluding -Wlogical-op above, it is enabled, as of
|
||||
# gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
|
||||
@@ -117,10 +122,14 @@ if test "$gl_gcc_warnings" = yes; then
|
||||
# We use a slightly smaller set of warning options for lib/.
|
||||
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
|
||||
nw=
|
||||
nw="$nw -Wstrict-overflow"
|
||||
nw="$nw -Wuninitialized"
|
||||
nw="$nw -Wunused-macros"
|
||||
nw="$nw -Wmissing-prototypes"
|
||||
nw="$nw -Wold-style-definition"
|
||||
# FIXME: remove/reenable the following two, once gnulib is adjusted.
|
||||
nw="$nw -Wsuggest-attribute=const"
|
||||
nw="$nw -Wsuggest-attribute=pure"
|
||||
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
||||
AC_SUBST([GNULIB_WARN_CFLAGS])
|
||||
|
||||
@@ -416,7 +425,7 @@ esac
|
||||
|
||||
MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
|
||||
|
||||
# Change ginstall.1 to "install.h" in $MAN.
|
||||
# Change "ginstall.1" to "install.1" in $MAN.
|
||||
MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
|
||||
| tr '\015\012' ' '; echo`
|
||||
|
||||
@@ -443,7 +452,7 @@ AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
|
||||
# As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
|
||||
# translatable strings, we must use need-formatstring-macros here.
|
||||
AM_GNU_GETTEXT([external], [need-formatstring-macros])
|
||||
AM_GNU_GETTEXT_VERSION([0.17])
|
||||
AM_GNU_GETTEXT_VERSION([0.18.1])
|
||||
|
||||
# For a test of uniq: it uses the $LOCALE_FR envvar.
|
||||
gt_LOCALE_FR
|
||||
|
||||
@@ -128,7 +128,7 @@ find_upper_case_var = \
|
||||
} \
|
||||
END {$$m and (warn "$(ME): do not use upper case in \@var{...}\n"), exit 1}'
|
||||
sc-lower-case-var:
|
||||
$(AM_V_GEN)$(PERL) -e 1 \
|
||||
&& $(PERL) -lne $(find_upper_case_var) $(srcdir)/*.texi
|
||||
$(AM_V_GEN)$(PERL) -e 1 || { echo $@: skipping test; exit 0; }; \
|
||||
$(PERL) -lne $(find_upper_case_var) $(srcdir)/*.texi
|
||||
|
||||
check: check-texinfo
|
||||
|
||||
@@ -1883,7 +1883,7 @@ Output at most @var{bytes} bytes of the input. Prefixes and suffixes on
|
||||
Instead of the normal output, output only @dfn{string constants}: at
|
||||
least @var{bytes} consecutive @acronym{ASCII} graphic characters,
|
||||
followed by a zero byte (@acronym{ASCII} @sc{nul}).
|
||||
Prefixes and suffixes on @code{bytes} are interpreted as for the
|
||||
Prefixes and suffixes on @var{bytes} are interpreted as for the
|
||||
@option{-j} option.
|
||||
|
||||
If @var{n} is omitted with @option{--strings}, the default is 3.
|
||||
@@ -2830,6 +2830,18 @@ no @var{file} operand is specified and standard input is a FIFO or a pipe.
|
||||
Likewise, the @option{-f} option has no effect for any
|
||||
operand specified as @samp{-}, when standard input is a FIFO or a pipe.
|
||||
|
||||
With kernel inotify support, output is triggered by file changes
|
||||
and is generally very prompt.
|
||||
Otherwise, @command{tail} sleeps for one second between checks---
|
||||
use @option{--sleep-interval=@var{n}} to change that default---which can
|
||||
make the output appear slightly less responsive or bursty.
|
||||
When using tail without inotify support, you can make it more responsive
|
||||
by using a sub-second sleep interval, e.g., via an alias like this:
|
||||
|
||||
@example
|
||||
alias tail='tail -s.1'
|
||||
@end example
|
||||
|
||||
@item -F
|
||||
@opindex -F
|
||||
This option is the same as @option{--follow=name --retry}. That is, tail
|
||||
@@ -2992,8 +3004,8 @@ The program accepts the following options. Also see @ref{Common options}.
|
||||
Put @var{lines} lines of @var{input} into each output file.
|
||||
|
||||
For compatibility @command{split} also supports an obsolete
|
||||
option syntax @option{-@var{lines}}. New scripts should use @option{-l
|
||||
@var{lines}} instead.
|
||||
option syntax @option{-@var{lines}}. New scripts should use
|
||||
@option{-l @var{lines}} instead.
|
||||
|
||||
@item -b @var{size}
|
||||
@itemx --bytes=@var{size}
|
||||
@@ -3011,6 +3023,25 @@ possible without exceeding @var{size} bytes. Individual lines longer than
|
||||
@var{size} bytes are broken into multiple files.
|
||||
@var{size} has the same format as for the @option{--bytes} option.
|
||||
|
||||
@itemx --filter=@var{command}
|
||||
@opindex --filter
|
||||
With this option, rather than simply writing to each output file,
|
||||
write through a pipe to the specified shell @var{command} for each output file.
|
||||
@var{command} should use the $FILE environment variable, which is set
|
||||
to a different output file name for each invocation of the command.
|
||||
For example, imagine that you have a 1TiB compressed file
|
||||
that, if uncompressed, would be too large to reside on disk,
|
||||
yet you must split it into individually-compressed pieces
|
||||
of a more manageable size.
|
||||
To do that, you might run this command:
|
||||
|
||||
@example
|
||||
xz -dc BIG.xz | split -b200G --filter='xz > $FILE.xz' - big-
|
||||
@end example
|
||||
|
||||
Assuming a 10:1 compression ratio, that would create about fifty 20GiB files
|
||||
with names @file{big-xaa.xz}, @file{big-xab.xz}, @file{big-xac.xz}, etc.
|
||||
|
||||
@item -n @var{chunks}
|
||||
@itemx --number=@var{chunks}
|
||||
@opindex -n
|
||||
@@ -3671,6 +3702,13 @@ When verifying checksums, warn about improperly formatted MD5 checksum lines.
|
||||
This option is useful only if all but a few lines in the checked input
|
||||
are valid.
|
||||
|
||||
@itemx --strict
|
||||
@opindex --strict
|
||||
@cindex verifying MD5 checksums
|
||||
When verifying checksums,
|
||||
if one or more input line is invalid,
|
||||
exit nonzero after all warnings have been issued.
|
||||
|
||||
@end table
|
||||
|
||||
@exitstatus
|
||||
@@ -4109,8 +4147,8 @@ a temporary file, which is then used as an input in a subsequent merge.
|
||||
|
||||
A large value of @var{nmerge} may improve merge performance and decrease
|
||||
temporary storage utilization at the expense of increased memory usage
|
||||
and I/0. Conversely a small value of @var{nmerge} may reduce memory
|
||||
requirements and I/0 at the expense of temporary storage consumption and
|
||||
and I/O. Conversely a small value of @var{nmerge} may reduce memory
|
||||
requirements and I/O at the expense of temporary storage consumption and
|
||||
merge performance.
|
||||
|
||||
The value of @var{nmerge} must be at least 2. The default value is
|
||||
@@ -7023,6 +7061,23 @@ Piping a colorized listing through a pager like @command{more} or
|
||||
@command{less} usually produces unreadable results. However, using
|
||||
@code{more -f} does seem to work.
|
||||
|
||||
@vindex LS_COLORS
|
||||
@vindex SHELL @r{environment variable, and color}
|
||||
Note that using the @option{--color} option may incur a noticeable
|
||||
performance penalty when run in a directory with very many entries,
|
||||
because the default settings require that @command{ls} @code{stat} every
|
||||
single file it lists.
|
||||
However, if you would like most of the file-type coloring
|
||||
but can live without the other coloring options (e.g.,
|
||||
executable, orphan, sticky, other-writable, capability), use
|
||||
@command{dircolors} to set the @env{LS_COLORS} environment variable like this,
|
||||
@example
|
||||
eval $(dircolors -p | perl -pe \
|
||||
's/^((CAP|S[ET]|O[TR]|M|E)\w+).*/$1 00/' | dircolors -)
|
||||
@end example
|
||||
and on a @code{dirent.d_type}-capable file system, @command{ls}
|
||||
will perform only one @code{stat} call per command line argument.
|
||||
|
||||
@item -F
|
||||
@itemx --classify
|
||||
@itemx --indicator-style=classify
|
||||
@@ -7899,8 +7954,11 @@ same or newer modification time. If time stamps are being preserved,
|
||||
the comparison is to the source time stamp truncated to the
|
||||
resolutions of the destination file system and of the system calls
|
||||
used to update time stamps; this avoids duplicate work if several
|
||||
@samp{cp -pu} commands are executed with the same source and
|
||||
destination.
|
||||
@samp{cp -pu} commands are executed with the same source and destination.
|
||||
If @option{--preserve=links} is also specified (like with @samp{cp -au}
|
||||
for example), that will take precedence. Consequently, depending on the
|
||||
order that files are processed from the source, newer files in the destination
|
||||
may be replaced, to mirror hard links in the source.
|
||||
|
||||
@item -v
|
||||
@itemx --verbose
|
||||
@@ -13873,10 +13931,10 @@ hour (@samp{00}@dots{}@samp{23})
|
||||
@item %I
|
||||
hour (@samp{01}@dots{}@samp{12})
|
||||
@item %k
|
||||
hour (@samp{ 0}@dots{}@samp{23}).
|
||||
hour, space padded (@samp{ 0}@dots{}@samp{23}); equivalent to @samp{%_H}.
|
||||
This is a @acronym{GNU} extension.
|
||||
@item %l
|
||||
hour (@samp{ 1}@dots{}@samp{12}).
|
||||
hour, space padded (@samp{ 1}@dots{}@samp{12}); equivalent to @samp{%_I}.
|
||||
This is a @acronym{GNU} extension.
|
||||
@item %M
|
||||
minute (@samp{00}@dots{}@samp{59})
|
||||
@@ -15350,6 +15408,17 @@ three standard I/O streams associated with a program. Synopsis:
|
||||
stdbuf @var{option}@dots{} @var{command}
|
||||
@end example
|
||||
|
||||
@var{command} must start with the name of a program that
|
||||
@enumerate
|
||||
@item
|
||||
uses the ISO C @code{FILE} streams for input/output (note the
|
||||
programs @command{dd} and @command{cat} don't do that),
|
||||
|
||||
@item
|
||||
does not adjust the buffering of its standard streams (note the
|
||||
program @command{tee} is not in this category).
|
||||
@end enumerate
|
||||
|
||||
Any additional @var{arg}s are passed as additional arguments to the
|
||||
@var{command}.
|
||||
|
||||
@@ -15389,8 +15458,13 @@ This option is invalid with standard input.
|
||||
|
||||
@item 0
|
||||
Disable buffering of the selected stream.
|
||||
In this mode data is output immediately and only the
|
||||
In this mode, data is output immediately and only the
|
||||
amount of data requested is read from input.
|
||||
Note the difference in function for input and output.
|
||||
Disabling buffering for input will not influence the responsiveness
|
||||
or blocking behavior of the stream input functions.
|
||||
For example @code{fread} will still block until @code{EOF} or error,
|
||||
even if the underlying @code{read} returns less data than requested.
|
||||
|
||||
@item @var{size}
|
||||
Specify the size of the buffer to use in fully buffered mode.
|
||||
@@ -15398,12 +15472,6 @@ Specify the size of the buffer to use in fully buffered mode.
|
||||
|
||||
@end table
|
||||
|
||||
NOTE: If @var{command} adjusts the buffering of its standard streams
|
||||
(@command{tee} does for e.g.) then that will override corresponding settings
|
||||
changed by @command{stdbuf}. Also some filters (like @command{dd} and
|
||||
@command{cat} etc.) don't use streams for I/O, and are thus unaffected
|
||||
by @command{stdbuf} settings.
|
||||
|
||||
@cindex exit status of @command{stdbuf}
|
||||
Exit status:
|
||||
|
||||
@@ -15593,6 +15661,23 @@ The program accepts the following options. Also see @ref{Common options}.
|
||||
Options must precede operands.
|
||||
|
||||
@table @samp
|
||||
@itemx --foreground
|
||||
@opindex --foreground
|
||||
Don't create a separate background program group, so that
|
||||
the managed @var{command} can use the foreground TTY normally.
|
||||
This is needed to support timing out commands not started
|
||||
directly from an interactive shell, in two situations.
|
||||
@enumerate
|
||||
@item
|
||||
@var{command} is interactive and needs to read from the terminal for example
|
||||
@item
|
||||
the user wants to support sending signals directly to @var{command}
|
||||
from the terminal (like Ctrl-C for example)
|
||||
@end enumerate
|
||||
|
||||
Note in this mode of operation, any children of @var{command}
|
||||
will not be timed out.
|
||||
|
||||
@item -k @var{duration}
|
||||
@itemx --kill-after=@var{duration}
|
||||
@opindex -k
|
||||
@@ -15612,7 +15697,7 @@ or a number. Also see @xref{Signal specifications}.
|
||||
@end table
|
||||
|
||||
@cindex time units
|
||||
@var{duration} is an integer followed by an optional unit:
|
||||
@var{duration} is a floating point number followed by an optional unit:
|
||||
@display
|
||||
@samp{s} for seconds (the default)
|
||||
@samp{m} for minutes
|
||||
@@ -15620,6 +15705,8 @@ or a number. Also see @xref{Signal specifications}.
|
||||
@samp{d} for days
|
||||
@end display
|
||||
A duration of 0 disables the associated timeout.
|
||||
Note that the actual timeout duration is dependent on system conditions,
|
||||
which should be especially considered when specifying sub-second timeouts.
|
||||
|
||||
@cindex exit status of @command{timeout}
|
||||
Exit status:
|
||||
|
||||
@@ -93,10 +93,12 @@ heap_insert (struct heap *heap, void *item)
|
||||
void *
|
||||
heap_remove_top (struct heap *heap)
|
||||
{
|
||||
void *top;
|
||||
|
||||
if (heap->count == 0)
|
||||
return NULL;
|
||||
|
||||
void *top = heap->array[1];
|
||||
top = heap->array[1];
|
||||
heap->array[1] = heap->array[heap->count--];
|
||||
heapify_down (heap->array, heap->count, 1, heap->compare);
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ struct randint_source;
|
||||
|
||||
struct randint_source *randint_new (struct randread_source *);
|
||||
struct randint_source *randint_all_new (char const *, size_t);
|
||||
struct randread_source *randint_get_source (struct randint_source const *);
|
||||
struct randread_source *randint_get_source (struct randint_source const *)
|
||||
_GL_ATTRIBUTE_PURE;
|
||||
randint randint_genmax (struct randint_source *, randint genmax);
|
||||
|
||||
/* Consume random data from *S to generate a random number in the range
|
||||
|
||||
@@ -19,16 +19,18 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "hash.h"
|
||||
#include "randperm.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "xalloc.h"
|
||||
|
||||
/* Return the ceiling of the log base 2 of N. If N is zero, return
|
||||
an unspecified value. */
|
||||
|
||||
static size_t
|
||||
static size_t _GL_ATTRIBUTE_CONST
|
||||
ceil_lg (size_t n)
|
||||
{
|
||||
size_t b = 0;
|
||||
@@ -57,6 +59,94 @@ randperm_bound (size_t h, size_t n)
|
||||
return bound;
|
||||
}
|
||||
|
||||
/* Swap elements I and J in array V. */
|
||||
|
||||
static void
|
||||
swap (size_t *v, size_t i, size_t j)
|
||||
{
|
||||
size_t t = v[i];
|
||||
v[i] = v[j];
|
||||
v[j] = t;
|
||||
}
|
||||
|
||||
/* Structures and functions for a sparse_map abstract data type that's
|
||||
used to effectively swap elements I and J in array V like swap(),
|
||||
but in a more memory efficient manner (when the number of permutations
|
||||
performed is significantly less than the size of the input). */
|
||||
|
||||
struct sparse_ent_
|
||||
{
|
||||
size_t index;
|
||||
size_t val;
|
||||
};
|
||||
|
||||
static size_t
|
||||
sparse_hash_ (void const *x, size_t table_size)
|
||||
{
|
||||
struct sparse_ent_ const *ent = x;
|
||||
return ent->index % table_size;
|
||||
}
|
||||
|
||||
static bool
|
||||
sparse_cmp_ (void const *x, void const *y)
|
||||
{
|
||||
struct sparse_ent_ const *ent1 = x;
|
||||
struct sparse_ent_ const *ent2 = y;
|
||||
return ent1->index == ent2->index;
|
||||
}
|
||||
|
||||
typedef Hash_table sparse_map;
|
||||
|
||||
/* Initialize the structure for the sparse map,
|
||||
when a best guess as to the number of entries
|
||||
specified with SIZE_HINT. */
|
||||
|
||||
static sparse_map *
|
||||
sparse_new (size_t size_hint)
|
||||
{
|
||||
return hash_initialize (size_hint, NULL, sparse_hash_, sparse_cmp_, free);
|
||||
}
|
||||
|
||||
/* Swap the values for I and J. If a value is not already present
|
||||
then assume it's equal to the index. Update the value for
|
||||
index I in array V. */
|
||||
|
||||
static void
|
||||
sparse_swap (sparse_map *sv, size_t* v, size_t i, size_t j)
|
||||
{
|
||||
struct sparse_ent_ *v1 = hash_delete (sv, &(struct sparse_ent_) {i,0});
|
||||
struct sparse_ent_ *v2 = hash_delete (sv, &(struct sparse_ent_) {j,0});
|
||||
|
||||
/* FIXME: reduce the frequency of these mallocs. */
|
||||
if (!v1)
|
||||
{
|
||||
v1 = xmalloc (sizeof *v1);
|
||||
v1->index = v1->val = i;
|
||||
}
|
||||
if (!v2)
|
||||
{
|
||||
v2 = xmalloc (sizeof *v2);
|
||||
v2->index = v2->val = j;
|
||||
}
|
||||
|
||||
size_t t = v1->val;
|
||||
v1->val = v2->val;
|
||||
v2->val = t;
|
||||
if (!hash_insert (sv, v1))
|
||||
xalloc_die ();
|
||||
if (!hash_insert (sv, v2))
|
||||
xalloc_die ();
|
||||
|
||||
v[i] = v1->val;
|
||||
}
|
||||
|
||||
static void
|
||||
sparse_free (sparse_map *sv)
|
||||
{
|
||||
hash_free (sv);
|
||||
}
|
||||
|
||||
|
||||
/* From R, allocate and return a malloc'd array of the first H elements
|
||||
of a random permutation of N elements. H must not exceed N.
|
||||
Return NULL if H is zero. */
|
||||
@@ -79,21 +169,66 @@ randperm_new (struct randint_source *r, size_t h, size_t n)
|
||||
|
||||
default:
|
||||
{
|
||||
size_t i;
|
||||
/* The algorithm is essentially the same in both
|
||||
the sparse and non sparse case. In the sparse case we use
|
||||
a hash to implement sparse storage for the set of n numbers
|
||||
we're shuffling. When to use the sparse method was
|
||||
determined with the help of this script:
|
||||
|
||||
v = xnmalloc (n, sizeof *v);
|
||||
for (i = 0; i < n; i++)
|
||||
v[i] = i;
|
||||
#!/bin/sh
|
||||
for n in $(seq 2 32); do
|
||||
for h in $(seq 2 32); do
|
||||
test $h -gt $n && continue
|
||||
for s in o n; do
|
||||
test $s = o && shuf=shuf || shuf=./shuf
|
||||
num=$(env time -f "$s:${h},${n} = %e,%M" \
|
||||
$shuf -i0-$((2**$n-2)) -n$((2**$h-2)) | wc -l)
|
||||
test $num = $((2**$h-2)) || echo "$s:${h},${n} = failed" >&2
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
This showed that if sparseness = n/h, then:
|
||||
|
||||
sparseness = 128 => .125 mem used, and about same speed
|
||||
sparseness = 64 => .25 mem used, but 1.5 times slower
|
||||
sparseness = 32 => .5 mem used, but 2 times slower
|
||||
|
||||
Also the memory usage was only significant when n > 128Ki
|
||||
*/
|
||||
bool sparse = (n >= (128 * 1024)) && (n / h >= 32);
|
||||
|
||||
size_t i;
|
||||
sparse_map *sv;
|
||||
|
||||
if (sparse)
|
||||
{
|
||||
sv = sparse_new (h * 2);
|
||||
if (sv == NULL)
|
||||
xalloc_die ();
|
||||
v = xnmalloc (h, sizeof *v);
|
||||
}
|
||||
else
|
||||
{
|
||||
sv = NULL; /* To placate GCC's -Wuninitialized. */
|
||||
v = xnmalloc (n, sizeof *v);
|
||||
for (i = 0; i < n; i++)
|
||||
v[i] = i;
|
||||
}
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
{
|
||||
size_t j = i + randint_choose (r, n - i);
|
||||
size_t t = v[i];
|
||||
v[i] = v[j];
|
||||
v[j] = t;
|
||||
if (sparse)
|
||||
sparse_swap (sv, v, i, j);
|
||||
else
|
||||
swap (v, i, j);
|
||||
}
|
||||
|
||||
v = xnrealloc (v, h, sizeof *v);
|
||||
if (sparse)
|
||||
sparse_free (sv);
|
||||
else
|
||||
v = xnrealloc (v, h, sizeof *v);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "randint.h"
|
||||
#include <stddef.h>
|
||||
size_t randperm_bound (size_t, size_t);
|
||||
size_t randperm_bound (size_t, size_t) _GL_ATTRIBUTE_CONST;
|
||||
size_t *randperm_new (struct randint_source *, size_t, size_t);
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef NAME_OF_NONCE_DEVICE
|
||||
#define NAME_OF_NONCE_DEVICE "/dev/urandom"
|
||||
# define NAME_OF_NONCE_DEVICE "/dev/urandom"
|
||||
#endif
|
||||
|
||||
/* The maximum buffer size used for reads of random data. Using the
|
||||
@@ -162,7 +162,7 @@ get_nonce (void *buffer, size_t bufsize, size_t bytes_bound)
|
||||
|
||||
/* If there's no nonce device, use a poor approximation
|
||||
by getting the time of day, etc. */
|
||||
# define ISAAC_SEED(type, initialize_v) \
|
||||
#define ISAAC_SEED(type, initialize_v) \
|
||||
if (seeded < bufsize) \
|
||||
{ \
|
||||
type v; \
|
||||
|
||||
@@ -22,7 +22,7 @@ index 2da5afe..562955a 100644
|
||||
}
|
||||
#endif /* _LIBC */
|
||||
|
||||
+static inline bool
|
||||
+static inline bool _GL_ATTRIBUTE_PURE
|
||||
+check_x_suffix (char const *s, size_t len)
|
||||
+{
|
||||
+ return len <= strspn (s, "X");
|
||||
@@ -100,7 +100,7 @@ index 2da5afe..562955a 100644
|
||||
- }
|
||||
-#endif
|
||||
- value += random_time_bits ^ __getpid ();
|
||||
+ rand_src = randint_all_new (NULL, 8);
|
||||
+ rand_src = randint_all_new (NULL, x_suffix_len);
|
||||
+ if (! rand_src)
|
||||
+ return -1;
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
diff --git a/modules/getloadavg b/modules/getloadavg
|
||||
index 2fbeb40..b79aaca 100644
|
||||
--- a/modules/getloadavg
|
||||
+++ b/modules/getloadavg
|
||||
@@ -16,7 +16,7 @@ stdbool
|
||||
fcntl-safer
|
||||
|
||||
configure.ac:
|
||||
-gl_GETLOADAVG([$gl_source_base])
|
||||
+gl_GETLOADAVG([lib])
|
||||
gl_STDLIB_MODULE_INDICATOR([getloadavg])
|
||||
|
||||
Makefile.am:
|
||||
@@ -8,6 +8,7 @@ lib/randperm.h
|
||||
Depends-on:
|
||||
randint
|
||||
xalloc
|
||||
hash
|
||||
|
||||
configure.ac:
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
Description:
|
||||
gen_tempname, gen_tempname_len: create a private temporary file or directory.
|
||||
|
||||
Files:
|
||||
lib/tempname.c
|
||||
lib/tempname.h
|
||||
m4/tempname.m4
|
||||
|
||||
Depends-on:
|
||||
extensions
|
||||
gettimeofday
|
||||
randint
|
||||
stdbool
|
||||
stdint
|
||||
sys_stat
|
||||
sys_time
|
||||
|
||||
configure.ac:
|
||||
gl_FUNC_GEN_TEMPNAME
|
||||
|
||||
Makefile.am:
|
||||
|
||||
Include:
|
||||
"tempname.h"
|
||||
|
||||
License:
|
||||
LGPL
|
||||
|
||||
Maintainer:
|
||||
Eric Blake and Jim Meyering
|
||||
18
gl/modules/tempname.diff
Normal file
18
gl/modules/tempname.diff
Normal file
@@ -0,0 +1,18 @@
|
||||
--- /gnulib/modules/tempname 2011-06-17 11:41:46.070787376 +0200
|
||||
+++ gl/modules/tempname 2011-06-17 11:43:49.571154551 +0200
|
||||
@@ -1,2 +1,2 @@
|
||||
Description:
|
||||
-gen_tempname() function: create a private temporary file or directory.
|
||||
+gen_tempname, gen_tempname_len: create a private temporary file or directory.
|
||||
|
||||
Files:
|
||||
lib/tempname.c
|
||||
@@ -10,6 +10,8 @@ Depends-on:
|
||||
extensions
|
||||
gettimeofday
|
||||
lstat
|
||||
+randint
|
||||
+stdbool
|
||||
stdint
|
||||
sys_stat
|
||||
sys_time
|
||||
2
gnulib
2
gnulib
Submodule gnulib updated: a81348d2e1...da1717b7f9
@@ -17,6 +17,7 @@
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#include <config.h>
|
||||
#include "buffer-lcm.h"
|
||||
|
||||
/* Return a buffer size suitable for doing I/O with files whose block
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#include <stddef.h>
|
||||
size_t buffer_lcm (size_t, size_t, size_t);
|
||||
size_t buffer_lcm (size_t, size_t, size_t) _GL_ATTRIBUTE_CONST;
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "group-member.h"
|
||||
#include "stat-macros.h"
|
||||
|
||||
/* Return true if the current user has permission of type MODE
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
if digit return -1, else 0
|
||||
return 0 */
|
||||
|
||||
static inline int
|
||||
static inline int _GL_ATTRIBUTE_PURE
|
||||
fraccompare (char const *a, char const *b, char decimal_point)
|
||||
{
|
||||
if (*a == decimal_point && *b == decimal_point)
|
||||
@@ -111,7 +111,7 @@ fraccompare (char const *a, char const *b, char decimal_point)
|
||||
causes comparisons to act as if there is no decimal point
|
||||
character, and likewise for THOUSANDS_SEP. */
|
||||
|
||||
static inline int
|
||||
static inline int _GL_ATTRIBUTE_PURE
|
||||
numcompare (char const *a, char const *b,
|
||||
int decimal_point, int thousands_sep)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
/* Externally-visible name for numcompare. */
|
||||
|
||||
int
|
||||
int _GL_ATTRIBUTE_PURE
|
||||
strnumcmp (char const *a, char const *b,
|
||||
int decimal_point, int thousands_sep)
|
||||
{
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
int strintcmp (char const *, char const *);
|
||||
int strintcmp (char const *, char const *) _GL_ATTRIBUTE_PURE;
|
||||
int strnumcmp (char const *, char const *, int, int);
|
||||
|
||||
@@ -6,4 +6,5 @@ xfts_open (char * const *, int options,
|
||||
int (*) (const FTSENT **, const FTSENT **));
|
||||
|
||||
bool
|
||||
cycle_warning_required (FTS const *fts, FTSENT const *ent);
|
||||
cycle_warning_required (FTS const *fts, FTSENT const *ent)
|
||||
_GL_ATTRIBUTE_PURE;
|
||||
|
||||
@@ -41,8 +41,6 @@ AC_DEFUN([coreutils_MACROS],
|
||||
AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
|
||||
[Define to the declaration of the xargmatch failure function.])
|
||||
|
||||
# used by ls
|
||||
AC_REQUIRE([gl_CLOCK_TIME])
|
||||
# used by shred
|
||||
AC_CHECK_FUNCS_ONCE([directio])
|
||||
|
||||
@@ -65,6 +63,8 @@ AC_DEFUN([coreutils_MACROS],
|
||||
|
||||
# Used by sort.c.
|
||||
AC_CHECK_FUNCS_ONCE([nl_langinfo])
|
||||
# Used by timeout.c
|
||||
AC_CHECK_FUNCS_ONCE([setrlimit])
|
||||
|
||||
# Used by tail.c.
|
||||
AC_CHECK_FUNCS([inotify_init],
|
||||
@@ -93,14 +93,20 @@ AC_DEFUN([coreutils_MACROS],
|
||||
cu_PREREQ_STAT_PROG
|
||||
|
||||
# for dd.c and shred.c
|
||||
coreutils_saved_libs=$LIBS
|
||||
LIB_FDATASYNC=
|
||||
#
|
||||
# Use fdatasync only if declared. On MacOS X 10.7, fdatasync exists but
|
||||
# is not declared, and is ineffective.
|
||||
LIB_FDATASYNC=
|
||||
AC_SUBST([LIB_FDATASYNC])
|
||||
AC_CHECK_DECLS_ONCE([fdatasync])
|
||||
if test $ac_cv_have_decl_fdatasync = yes; then
|
||||
coreutils_saved_libs=$LIBS
|
||||
AC_SEARCH_LIBS([fdatasync], [rt posix4],
|
||||
[test "$ac_cv_search_fdatasync" = "none required" ||
|
||||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
|
||||
AC_SUBST([LIB_FDATASYNC])
|
||||
AC_CHECK_FUNCS([fdatasync])
|
||||
LIBS=$coreutils_saved_libs
|
||||
LIBS=$coreutils_saved_libs
|
||||
fi
|
||||
|
||||
# Check whether libcap is usable -- for ls --color support
|
||||
LIB_CAP=
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# stat-prog.m4 serial 6
|
||||
# stat-prog.m4 serial 7
|
||||
# Record the prerequisites of src/stat.c from the coreutils package.
|
||||
|
||||
# Copyright (C) 2002-2004, 2006, 2008-2011 Free Software Foundation, Inc.
|
||||
@@ -53,7 +53,8 @@ AC_INCLUDES_DEFAULT
|
||||
"
|
||||
dnl Keep this long conditional in sync with the USE_STATVFS conditional
|
||||
dnl in ../src/stat.c.
|
||||
if test "$fu_cv_sys_stat_statvfs" = yes &&
|
||||
if case "$fu_cv_sys_stat_statvfs$fu_cv_sys_stat_statvfs64" in
|
||||
*yes*) ;; *) false;; esac &&
|
||||
{ AC_CHECK_MEMBERS([struct statvfs.f_basetype],,, [$statvfs_includes])
|
||||
test $ac_cv_member_struct_statvfs_f_basetype = yes ||
|
||||
{ AC_CHECK_MEMBERS([struct statvfs.f_fstypename],,, [$statvfs_includes])
|
||||
|
||||
@@ -3,4 +3,4 @@ cat \- concatenate files and print on the standard output
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
\fBtac\fP(1).
|
||||
\fBtac\fP(1)
|
||||
|
||||
@@ -3,4 +3,4 @@ tac \- concatenate and print files in reverse
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
\fBrev\fP(1).
|
||||
\fBrev\fP(1)
|
||||
|
||||
@@ -138,7 +138,7 @@ bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
|
||||
|
||||
noinst_PROGRAMS = setuidgid getlimits
|
||||
|
||||
pkglib_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
|
||||
pkglibexec_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
|
||||
|
||||
noinst_HEADERS = \
|
||||
chown-core.h \
|
||||
@@ -149,6 +149,7 @@ noinst_HEADERS = \
|
||||
find-mount-point.h \
|
||||
fs.h \
|
||||
group-list.h \
|
||||
ioblksize.h \
|
||||
ls.h \
|
||||
operand2sig.h \
|
||||
prog-fprintf.h \
|
||||
@@ -164,7 +165,7 @@ BUILT_SOURCES =
|
||||
CLEANFILES = $(SCRIPTS) su
|
||||
|
||||
# Also remove these sometimes-built programs.
|
||||
# For example, even when excluded, they're built via sc_check-AUTHORS.
|
||||
# For example, even when excluded, they're built via _sc_check-AUTHORS.
|
||||
CLEANFILES += $(no_install__progs)
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/lib
|
||||
@@ -328,6 +329,7 @@ date_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
ginstall_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
ls_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
pr_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
timeout_LDADD += $(LIB_TIMER_TIME)
|
||||
touch_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
|
||||
# for gethrxtime
|
||||
@@ -677,10 +679,10 @@ check-duplicate-no-install: tr
|
||||
# translation inhibits printing of UTF-8 names, just skip this test.
|
||||
au_dotdot = authors-dotdot
|
||||
au_actual = authors-actual
|
||||
.PHONY: sc_check-AUTHORS
|
||||
sc_check-AUTHORS: $(all_programs)
|
||||
.PHONY: _sc_check-AUTHORS
|
||||
_sc_check-AUTHORS: $(all_programs)
|
||||
@locale=en_US.UTF-8; \
|
||||
LC_ALL=$$locale ./cat --version \
|
||||
LC_ALL=$$locale ./cat --version \
|
||||
| grep ' Torbjorn ' > /dev/null \
|
||||
&& { echo "$@: skipping this check"; exit 0; }; \
|
||||
rm -f $(au_actual) $(au_dotdot); \
|
||||
@@ -702,46 +704,6 @@ sc_check-AUTHORS: $(all_programs)
|
||||
sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot) && \
|
||||
diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
|
||||
|
||||
# The following rule is not designed to be portable,
|
||||
# and relies on tools that not everyone has.
|
||||
|
||||
# Most functions in src/*.c should have static scope.
|
||||
# Any that don't must be marked with `extern', but `main'
|
||||
# and `usage' are exceptions: they're always extern, but
|
||||
# do not need to be marked. Also functions starting with __
|
||||
# are exempted due to possibly being added by the compiler
|
||||
# (when compiled as a shared library for example).
|
||||
#
|
||||
# The second nm|grep checks for file-scope variables with `extern' scope.
|
||||
.PHONY: sc_tight_scope
|
||||
sc_tight_scope: $(bin_PROGRAMS)
|
||||
@t=exceptions-$$$$; \
|
||||
trap 's=$$?; rm -f $$t; exit $$s' 0; \
|
||||
for sig in 1 2 3 13 15; do \
|
||||
eval "trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \
|
||||
done; \
|
||||
src=`for f in $(SOURCES); do \
|
||||
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
|
||||
hdr=`for f in $(noinst_HEADERS); do \
|
||||
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
|
||||
( printf 'main\nusage\n_.*\n'; \
|
||||
grep -h -A1 '^extern .*[^;]$$' $$src \
|
||||
| grep -vE '^(extern |--)' | sed 's/ .*//'; \
|
||||
perl -lne '/^extern (?:enum )?\S+ \**(\S*) \(/ and print $$1' \
|
||||
$$hdr; \
|
||||
) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
|
||||
nm -e *.$(OBJEXT) | sed -n 's/.* T //p' \
|
||||
| sed 's/^_//' | grep -Ev -f $$t \
|
||||
&& { echo the above functions should have static scope >&2; \
|
||||
exit 1; } || : ; \
|
||||
( printf '^program_name$$\n'; \
|
||||
perl -lne '/^extern .*?\**(\w+);/ and print "^$$1\$$"' \
|
||||
$$hdr *.h ) | $(ASSORT) -u > $$t; \
|
||||
nm -e *.$(OBJEXT) | sed -n 's/.* [BD] //p' \
|
||||
| sed 's/^_//' | grep -Ev -f $$t \
|
||||
&& { echo the above variables should have static scope >&2; \
|
||||
exit 1; } || :
|
||||
|
||||
# Use the just-built ./ginstall, when not cross-compiling.
|
||||
if CROSS_COMPILING
|
||||
cu_install_program = @INSTALL_PROGRAM@
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "ioblksize.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "full-write.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "chown-core.h"
|
||||
#include "error.h"
|
||||
#include "fts_.h"
|
||||
#include "group-member.h"
|
||||
#include "quote.h"
|
||||
#include "root-dev-ino.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
18
src/chmod.c
18
src/chmod.c
@@ -137,10 +137,11 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
|
||||
CHANGED describes what (if anything) has happened. */
|
||||
|
||||
static void
|
||||
describe_change (const char *file, mode_t mode,
|
||||
describe_change (const char *file, mode_t old_mode, mode_t mode,
|
||||
enum Change_status changed)
|
||||
{
|
||||
char perms[12]; /* "-rwxrwxrwx" ls-style modes. */
|
||||
char old_perms[12];
|
||||
const char *fmt;
|
||||
|
||||
if (changed == CH_NOT_APPLIED)
|
||||
@@ -152,21 +153,28 @@ describe_change (const char *file, mode_t mode,
|
||||
|
||||
strmode (mode, perms);
|
||||
perms[10] = '\0'; /* Remove trailing space. */
|
||||
|
||||
strmode (old_mode, old_perms);
|
||||
old_perms[10] = '\0'; /* Remove trailing space. */
|
||||
|
||||
switch (changed)
|
||||
{
|
||||
case CH_SUCCEEDED:
|
||||
fmt = _("mode of %s changed to %04lo (%s)\n");
|
||||
fmt = _("mode of %s changed from %04lo (%s) to %04lo (%s)\n");
|
||||
break;
|
||||
case CH_FAILED:
|
||||
fmt = _("failed to change mode of %s to %04lo (%s)\n");
|
||||
fmt = _("failed to change mode of %s from %04lo (%s) to %04lo (%s)\n");
|
||||
break;
|
||||
case CH_NO_CHANGE_REQUESTED:
|
||||
fmt = _("mode of %s retained as %04lo (%s)\n");
|
||||
break;
|
||||
printf (fmt, quote (file),
|
||||
(unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]);
|
||||
return;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
printf (fmt, quote (file),
|
||||
(unsigned long int) (old_mode & CHMOD_MODE_BITS), &old_perms[1],
|
||||
(unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]);
|
||||
}
|
||||
|
||||
@@ -284,7 +292,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
: !chmod_succeeded ? CH_NOT_APPLIED
|
||||
: !changed ? CH_NO_CHANGE_REQUESTED
|
||||
: CH_SUCCEEDED);
|
||||
describe_change (file_full_name, new_mode, ch_status);
|
||||
describe_change (file_full_name, old_mode, new_mode, ch_status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,17 +102,45 @@ uid_to_name (uid_t uid)
|
||||
: umaxtostr (uid, buf));
|
||||
}
|
||||
|
||||
/* Allocate a string representing USER and GROUP. */
|
||||
|
||||
static char *
|
||||
user_group_str (char const *user, char const *group)
|
||||
{
|
||||
char *spec = NULL;
|
||||
|
||||
if (user)
|
||||
{
|
||||
if (group)
|
||||
{
|
||||
spec = xmalloc (strlen (user) + 1 + strlen (group) + 1);
|
||||
stpcpy (stpcpy (stpcpy (spec, user), ":"), group);
|
||||
}
|
||||
else
|
||||
{
|
||||
spec = xstrdup (user);
|
||||
}
|
||||
}
|
||||
else if (group)
|
||||
{
|
||||
spec = xstrdup (group);
|
||||
}
|
||||
|
||||
return spec;
|
||||
}
|
||||
|
||||
/* Tell the user how/if the user and group of FILE have been changed.
|
||||
If USER is NULL, give the group-oriented messages.
|
||||
CHANGED describes what (if anything) has happened. */
|
||||
|
||||
static void
|
||||
describe_change (const char *file, enum Change_status changed,
|
||||
char const *old_user, char const *old_group,
|
||||
char const *user, char const *group)
|
||||
{
|
||||
const char *fmt;
|
||||
char const *spec;
|
||||
char *spec_allocated = NULL;
|
||||
char *old_spec;
|
||||
char *spec;
|
||||
|
||||
if (changed == CH_NOT_APPLIED)
|
||||
{
|
||||
@@ -121,35 +149,32 @@ describe_change (const char *file, enum Change_status changed,
|
||||
return;
|
||||
}
|
||||
|
||||
if (user)
|
||||
{
|
||||
if (group)
|
||||
{
|
||||
spec_allocated = xmalloc (strlen (user) + 1 + strlen (group) + 1);
|
||||
stpcpy (stpcpy (stpcpy (spec_allocated, user), ":"), group);
|
||||
spec = spec_allocated;
|
||||
}
|
||||
else
|
||||
{
|
||||
spec = user;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spec = group;
|
||||
}
|
||||
spec = user_group_str (user, group);
|
||||
old_spec = user_group_str (user ? old_user : NULL, group ? old_group : NULL);
|
||||
|
||||
switch (changed)
|
||||
{
|
||||
case CH_SUCCEEDED:
|
||||
fmt = (user ? _("changed ownership of %s to %s\n")
|
||||
: group ? _("changed group of %s to %s\n")
|
||||
fmt = (user ? _("changed ownership of %s from %s to %s\n")
|
||||
: group ? _("changed group of %s from %s to %s\n")
|
||||
: _("no change to ownership of %s\n"));
|
||||
break;
|
||||
case CH_FAILED:
|
||||
fmt = (user ? _("failed to change ownership of %s to %s\n")
|
||||
: group ? _("failed to change group of %s to %s\n")
|
||||
: _("failed to change ownership of %s\n"));
|
||||
if (old_spec)
|
||||
{
|
||||
fmt = (user ? _("failed to change ownership of %s from %s to %s\n")
|
||||
: group ? _("failed to change group of %s from %s to %s\n")
|
||||
: _("failed to change ownership of %s\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt = (user ? _("failed to change ownership of %s to %s\n")
|
||||
: group ? _("failed to change group of %s to %s\n")
|
||||
: _("failed to change ownership of %s\n"));
|
||||
free (old_spec);
|
||||
old_spec = spec;
|
||||
spec = NULL;
|
||||
}
|
||||
break;
|
||||
case CH_NO_CHANGE_REQUESTED:
|
||||
fmt = (user ? _("ownership of %s retained as %s\n")
|
||||
@@ -160,9 +185,10 @@ describe_change (const char *file, enum Change_status changed,
|
||||
abort ();
|
||||
}
|
||||
|
||||
printf (fmt, quote (file), spec);
|
||||
printf (fmt, quote (file), old_spec, spec);
|
||||
|
||||
free (spec_allocated);
|
||||
free (old_spec);
|
||||
free (spec);
|
||||
}
|
||||
|
||||
/* Change the owner and/or group of the FILE to UID and/or GID (safely)
|
||||
@@ -230,12 +256,10 @@ restricted_chown (int cwd_fd, char const *file,
|
||||
}
|
||||
}
|
||||
|
||||
{ /* FIXME: remove these curly braces when we assume C99. */
|
||||
int saved_errno = errno;
|
||||
close (fd);
|
||||
errno = saved_errno;
|
||||
return status;
|
||||
}
|
||||
int saved_errno = errno;
|
||||
close (fd);
|
||||
errno = saved_errno;
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Change the owner and/or group of the file specified by FTS and ENT
|
||||
@@ -459,8 +483,13 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
: !symlink_changed ? CH_NOT_APPLIED
|
||||
: !changed ? CH_NO_CHANGE_REQUESTED
|
||||
: CH_SUCCEEDED);
|
||||
char *old_usr = file_stats ? uid_to_name (file_stats->st_uid) : NULL;
|
||||
char *old_grp = file_stats ? gid_to_name (file_stats->st_gid) : NULL;
|
||||
describe_change (file_full_name, ch_status,
|
||||
old_usr, old_grp,
|
||||
chopt->user_name, chopt->group_name);
|
||||
free (old_usr);
|
||||
free (old_grp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,13 +68,13 @@ struct Chown_option
|
||||
void
|
||||
chopt_init (struct Chown_option *);
|
||||
|
||||
void
|
||||
void _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_CONST
|
||||
chopt_free (struct Chown_option *);
|
||||
|
||||
char *
|
||||
gid_to_name (gid_t);
|
||||
|
||||
char *
|
||||
char * _GL_ATTRIBUTE_PURE
|
||||
uid_to_name (uid_t);
|
||||
|
||||
bool
|
||||
|
||||
106
src/copy.c
106
src/copy.c
@@ -47,9 +47,11 @@
|
||||
#include "hash.h"
|
||||
#include "hash-triple.h"
|
||||
#include "ignore-value.h"
|
||||
#include "ioblksize.h"
|
||||
#include "quote.h"
|
||||
#include "same.h"
|
||||
#include "savedir.h"
|
||||
#include "stat-size.h"
|
||||
#include "stat-time.h"
|
||||
#include "utimecmp.h"
|
||||
#include "utimens.h"
|
||||
@@ -466,7 +468,7 @@ extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size,
|
||||
performance hit that's probably noticeable only on trees deeper
|
||||
than a few hundred levels. See use of active_dir_map in remove.c */
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
|
||||
{
|
||||
while (ancestors != 0)
|
||||
@@ -949,7 +951,9 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
dest_errno = ENOTDIR;
|
||||
}
|
||||
else
|
||||
omitted_permissions = 0;
|
||||
{
|
||||
omitted_permissions = 0;
|
||||
}
|
||||
|
||||
if (dest_desc < 0)
|
||||
{
|
||||
@@ -975,7 +979,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
if (!clone_ok)
|
||||
{
|
||||
error (0, errno, _("failed to clone %s from %s"),
|
||||
quote (dst_name), quote (src_name));
|
||||
quote_n (0, dst_name), quote_n (1, src_name));
|
||||
return_val = false;
|
||||
goto close_src_and_dst_desc;
|
||||
}
|
||||
@@ -1486,6 +1490,43 @@ restore_default_fscreatecon_or_die (void)
|
||||
_("failed to restore the default file creation context"));
|
||||
}
|
||||
|
||||
/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE and
|
||||
VERBOSE settings. Return true upon success. Otherwise, diagnose
|
||||
the failure and return false.
|
||||
If SRC_NAME is a symbolic link it will not be followed. If the system
|
||||
doesn't support hard links to symbolic links, then DST_NAME will
|
||||
be created as a symbolic link to SRC_NAME. */
|
||||
static bool
|
||||
create_hard_link (char const *src_name, char const *dst_name,
|
||||
bool replace, bool verbose)
|
||||
{
|
||||
/* We want to guarantee that symlinks are not followed. */
|
||||
bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0);
|
||||
|
||||
/* If the link failed because of an existing destination,
|
||||
remove that file and then call link again. */
|
||||
if (link_failed && replace && errno == EEXIST)
|
||||
{
|
||||
if (unlink (dst_name) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot remove %s"), quote (dst_name));
|
||||
return false;
|
||||
}
|
||||
if (verbose)
|
||||
printf (_("removed %s\n"), quote (dst_name));
|
||||
link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0);
|
||||
}
|
||||
|
||||
if (link_failed)
|
||||
{
|
||||
error (0, errno, _("cannot create hard link %s to %s"),
|
||||
quote_n (0, dst_name), quote_n (1, src_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Copy the file SRC_NAME to the file DST_NAME. The files may be of
|
||||
any type. NEW_DST should be true if the file DST_NAME cannot
|
||||
exist because its parent directory was just created; NEW_DST should
|
||||
@@ -1626,6 +1667,25 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
end up removing the source file. */
|
||||
if (rename_succeeded)
|
||||
*rename_succeeded = true;
|
||||
|
||||
/* However, we still must record that we've processed
|
||||
this src/dest pair, in case this source file is
|
||||
hard-linked to another one. In that case, we'll use
|
||||
the mapping information to link the corresponding
|
||||
destination names. */
|
||||
earlier_file = remember_copied (dst_name, src_sb.st_ino,
|
||||
src_sb.st_dev);
|
||||
if (earlier_file)
|
||||
{
|
||||
/* Note we currently replace DST_NAME unconditionally,
|
||||
even if it was a newer separate file. */
|
||||
if (! create_hard_link (earlier_file, dst_name, true,
|
||||
x->verbose))
|
||||
{
|
||||
goto un_backup;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1946,31 +2006,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We want to guarantee that symlinks are not followed. */
|
||||
bool link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD,
|
||||
dst_name, 0) != 0);
|
||||
|
||||
/* If the link failed because of an existing destination,
|
||||
remove that file and then call link again. */
|
||||
if (link_failed && errno == EEXIST)
|
||||
{
|
||||
if (unlink (dst_name) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot remove %s"), quote (dst_name));
|
||||
goto un_backup;
|
||||
}
|
||||
if (x->verbose)
|
||||
printf (_("removed %s\n"), quote (dst_name));
|
||||
link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD,
|
||||
dst_name, 0) != 0);
|
||||
}
|
||||
|
||||
if (link_failed)
|
||||
{
|
||||
error (0, errno, _("cannot create hard link %s to %s"),
|
||||
quote_n (0, dst_name), quote_n (1, earlier_file));
|
||||
goto un_backup;
|
||||
}
|
||||
if (! create_hard_link (earlier_file, dst_name, true, x->verbose))
|
||||
goto un_backup;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2197,6 +2234,10 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
if (x->verbose)
|
||||
emit_verbose (src_name, dst_name, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
omitted_permissions = 0;
|
||||
}
|
||||
|
||||
/* Decide whether to copy the contents of the directory. */
|
||||
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
|
||||
@@ -2272,11 +2313,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
&& !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode)
|
||||
&& x->dereference == DEREF_NEVER))
|
||||
{
|
||||
if (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0))
|
||||
{
|
||||
error (0, errno, _("cannot create link %s"), quote (dst_name));
|
||||
goto un_backup;
|
||||
}
|
||||
if (! create_hard_link (src_name, dst_name, false, false))
|
||||
goto un_backup;
|
||||
}
|
||||
else if (S_ISREG (src_mode)
|
||||
|| (x->copy_as_regular && !S_ISLNK (src_mode)))
|
||||
@@ -2533,7 +2571,7 @@ un_backup:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
valid_options (const struct cp_options *co)
|
||||
{
|
||||
assert (co != NULL);
|
||||
|
||||
@@ -282,7 +282,7 @@ void dest_info_init (struct cp_options *);
|
||||
void src_info_init (struct cp_options *);
|
||||
|
||||
void cp_options_default (struct cp_options *);
|
||||
bool chown_failure_ok (struct cp_options const *);
|
||||
bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE;
|
||||
mode_t cached_umask (void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
|
||||
#include "same.h"
|
||||
#include "hash.h"
|
||||
#include "cp-hash.h"
|
||||
|
||||
|
||||
2
src/cp.c
2
src/cp.c
@@ -187,7 +187,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-H follow command-line symbolic links in SOURCE\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-l, --link link files instead of copying\n\
|
||||
-l, --link hard link files instead of copying\n\
|
||||
-L, --dereference always follow symbolic links in SOURCE\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
|
||||
@@ -225,6 +225,7 @@ static void
|
||||
interrupt_handler (int sig)
|
||||
{
|
||||
delete_all_files (true);
|
||||
signal (sig, SIG_DFL);
|
||||
/* The signal has been reset to SIG_DFL, but blocked during this
|
||||
handler. Force the default action of this signal once the
|
||||
handler returns and the block is removed. */
|
||||
@@ -1421,7 +1422,7 @@ main (int argc, char **argv)
|
||||
|
||||
act.sa_handler = interrupt_handler;
|
||||
act.sa_mask = caught_signals;
|
||||
act.sa_flags = SA_NODEFER | SA_RESETHAND;
|
||||
act.sa_flags = 0;
|
||||
|
||||
for (i = 0; i < nsigs; i++)
|
||||
if (sigismember (&caught_signals, sig[i]))
|
||||
|
||||
16
src/date.c
16
src/date.c
@@ -179,8 +179,8 @@ FORMAT controls the output. Interpreted sequences are:\n\
|
||||
%j day of year (001..366)\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
%k hour ( 0..23)\n\
|
||||
%l hour ( 1..12)\n\
|
||||
%k hour, space padded ( 0..23); same as %_H\n\
|
||||
%l hour, space padded ( 1..12); same as %_I\n\
|
||||
%m month (01..12)\n\
|
||||
%M minute (00..59)\n\
|
||||
"), stdout);
|
||||
@@ -235,6 +235,18 @@ After any flags comes an optional field width, as a decimal number;\n\
|
||||
then an optional modifier, which is either\n\
|
||||
E to use the locale's alternate representations if available, or\n\
|
||||
O to use the locale's alternate numeric symbols if available.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
Examples:\n\
|
||||
Convert seconds since the epoch (1970-01-01 UTC) to a date\n\
|
||||
$ date --date='@2147483647'\n\
|
||||
\n\
|
||||
Show the time on the west coast of the US (use tzselect(1) to find TZ)\n\
|
||||
$ TZ='America/Los_Angeles' date\n\
|
||||
\n\
|
||||
Show the local time for 9AM next Friday on the west coast of the US\n\
|
||||
$ date --date='TZ=\"America/Los_Angeles\" 09:00 next Fri'\n\
|
||||
"), stdout);
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
|
||||
15
src/dd.c
15
src/dd.c
@@ -27,7 +27,6 @@
|
||||
#include "system.h"
|
||||
#include "close-stream.h"
|
||||
#include "error.h"
|
||||
#include "fadvise.h"
|
||||
#include "fd-reopen.h"
|
||||
#include "gethrxtime.h"
|
||||
#include "human.h"
|
||||
@@ -46,7 +45,7 @@
|
||||
proper_name ("Stuart Kemp")
|
||||
|
||||
/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
|
||||
present. SA_NODEFER and SA_RESETHAND are XSI extensions. */
|
||||
present. */
|
||||
#ifndef SA_NOCLDSTOP
|
||||
# define SA_NOCLDSTOP 0
|
||||
# define sigprocmask(How, Set, Oset) /* empty */
|
||||
@@ -56,6 +55,11 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* NonStop circa 2011 lacks SA_RESETHAND; see Bug#9076. */
|
||||
#ifndef SA_RESETHAND
|
||||
# define SA_RESETHAND 0
|
||||
#endif
|
||||
|
||||
#ifndef SIGINFO
|
||||
# define SIGINFO SIGUSR1
|
||||
#endif
|
||||
@@ -727,9 +731,6 @@ install_signal_handlers (void)
|
||||
|
||||
if (sigismember (&caught_signals, SIGINT))
|
||||
{
|
||||
/* POSIX 1003.1-2001 says SA_RESETHAND implies SA_NODEFER,
|
||||
but this is not true on Solaris 8 at least. It doesn't
|
||||
hurt to use SA_NODEFER here, so leave it in. */
|
||||
act.sa_handler = interrupt_handler;
|
||||
act.sa_flags = SA_NODEFER | SA_RESETHAND;
|
||||
sigaction (SIGINT, &act, NULL);
|
||||
@@ -1029,7 +1030,7 @@ write_output (void)
|
||||
|
||||
/* Return true if STR is of the form "PATTERN" or "PATTERNDELIM...". */
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
operand_matches (char const *str, char const *pattern, char delim)
|
||||
{
|
||||
while (*pattern)
|
||||
@@ -1109,7 +1110,7 @@ parse_integer (const char *str, bool *invalid)
|
||||
|
||||
/* OPERAND is of the form "X=...". Return true if X is NAME. */
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
operand_is (char const *operand, char const *name)
|
||||
{
|
||||
return operand_matches (operand, name, '=');
|
||||
|
||||
16
src/df.c
16
src/df.c
@@ -215,7 +215,7 @@ print_table (void)
|
||||
{
|
||||
size_t width = widths[field];
|
||||
char *cell = table[row][field];
|
||||
if (!cell)
|
||||
if (!cell) /* Missing type column, or mount point etc. */
|
||||
continue;
|
||||
|
||||
/* Note the DEV_FIELD used to be displayed on it's own line
|
||||
@@ -227,9 +227,9 @@ print_table (void)
|
||||
fputs (cell, stdout);
|
||||
else
|
||||
{
|
||||
cell = ambsalign (table[row][field], &width,
|
||||
alignments[field], MBA_UNIBYTE_FALLBACK);
|
||||
fputs (cell, stdout);
|
||||
cell = ambsalign (cell, &width, alignments[field], 0);
|
||||
/* When ambsalign fails, output unaligned data. */
|
||||
fputs (cell ? cell : table[row][field], stdout);
|
||||
free (cell);
|
||||
}
|
||||
IF_LINT (free (table[row][field]));
|
||||
@@ -241,7 +241,7 @@ print_table (void)
|
||||
IF_LINT (free (table));
|
||||
}
|
||||
|
||||
/* Optain the appropriate header entries. */
|
||||
/* Obtain the appropriate header entries. */
|
||||
|
||||
static void
|
||||
get_header (void)
|
||||
@@ -321,7 +321,7 @@ get_header (void)
|
||||
|
||||
/* Is FSTYPE a type of file system that should be listed? */
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
selected_fstype (const char *fstype)
|
||||
{
|
||||
const struct fs_type_list *fsp;
|
||||
@@ -336,7 +336,7 @@ selected_fstype (const char *fstype)
|
||||
|
||||
/* Is FSTYPE a type of file system that should be omitted? */
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
excluded_fstype (const char *fstype)
|
||||
{
|
||||
const struct fs_type_list *fsp;
|
||||
@@ -417,7 +417,7 @@ add_uint_with_neg_flag (uintmax_t *dest, bool *dest_neg,
|
||||
*dest = -*dest;
|
||||
}
|
||||
|
||||
/* Optain a space listing for the disk device with absolute file name DISK.
|
||||
/* Obtain a space listing for the disk device with absolute file name DISK.
|
||||
If MOUNT_POINT is non-NULL, it is the name of the root of the
|
||||
file system on DISK.
|
||||
If STAT_FILE is non-null, it is the name of a file within the file
|
||||
|
||||
@@ -456,7 +456,7 @@ to select a shell syntax are mutually exclusive"));
|
||||
if (print_database)
|
||||
{
|
||||
char const *p = G_line;
|
||||
while (p < G_line + sizeof G_line)
|
||||
while (p - G_line < sizeof G_line)
|
||||
{
|
||||
puts (p);
|
||||
p += strlen (p) + 1;
|
||||
|
||||
@@ -49,6 +49,7 @@ TERM screen-256color
|
||||
TERM screen-256color-bce
|
||||
TERM screen-bce
|
||||
TERM screen-w
|
||||
TERM screen.Eterm
|
||||
TERM screen.rxvt
|
||||
TERM screen.linux
|
||||
TERM terminator
|
||||
@@ -163,6 +164,7 @@ EXEC 01;32
|
||||
.mpeg 01;35
|
||||
.m2v 01;35
|
||||
.mkv 01;35
|
||||
.webm 01;35
|
||||
.ogm 01;35
|
||||
.mp4 01;35
|
||||
.m4v 01;35
|
||||
|
||||
2
src/du.c
2
src/du.c
@@ -37,7 +37,7 @@
|
||||
#include "human.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "same.h"
|
||||
#include "stat-size.h"
|
||||
#include "stat-time.h"
|
||||
#include "stdio--.h"
|
||||
#include "xfts.h"
|
||||
|
||||
18
src/env.c
18
src/env.c
@@ -123,13 +123,17 @@ main (int argc, char **argv)
|
||||
if (optind < argc && STREQ (argv[optind], "-"))
|
||||
++optind;
|
||||
|
||||
while (optind < argc && strchr (argv[optind], '='))
|
||||
if (putenv (argv[optind++]))
|
||||
{
|
||||
char *name = argv[optind - 1];
|
||||
*(strchr (name, '=')) = '\0';
|
||||
error (EXIT_CANCELED, errno, _("cannot set %s"), quote (name));
|
||||
}
|
||||
char *eq;
|
||||
while (optind < argc && (eq = strchr (argv[optind], '=')))
|
||||
{
|
||||
if (putenv (argv[optind]))
|
||||
{
|
||||
*eq = '\0';
|
||||
error (EXIT_CANCELED, errno, _("cannot set %s"),
|
||||
quote (argv[optind]));
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
|
||||
/* If no program is specified, print the environment and exit. */
|
||||
if (argc <= optind)
|
||||
|
||||
14
src/expr.c
14
src/expr.c
@@ -312,15 +312,17 @@ main (int argc, char **argv)
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
|
||||
/* The above handles --help and --version.
|
||||
Since there is no other invocation of getopt, handle `--' here. */
|
||||
if (argc > 1 && STREQ (argv[1], "--"))
|
||||
unsigned int u_argc = argc;
|
||||
if (1 < u_argc && STREQ (argv[1], "--"))
|
||||
{
|
||||
--argc;
|
||||
--u_argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (argc <= 1)
|
||||
if (u_argc <= 1)
|
||||
{
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXPR_INVALID);
|
||||
@@ -391,7 +393,7 @@ printv (VALUE *v)
|
||||
|
||||
/* Return true if V is a null-string or zero-number. */
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
null (VALUE *v)
|
||||
{
|
||||
switch (v->type)
|
||||
@@ -422,7 +424,7 @@ null (VALUE *v)
|
||||
|
||||
/* Return true if CP takes the form of an integer. */
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
looks_like_integer (char const *cp)
|
||||
{
|
||||
cp += (*cp == '-');
|
||||
@@ -483,7 +485,7 @@ toarith (VALUE *v)
|
||||
}
|
||||
}
|
||||
|
||||
/* Extract a size_t value from a integer value I.
|
||||
/* Extract a size_t value from an integer value I.
|
||||
If the value is negative, return SIZE_MAX.
|
||||
If the value is too large, return SIZE_MAX - 1. */
|
||||
static size_t
|
||||
|
||||
@@ -24,11 +24,9 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "extent-scan.h"
|
||||
#include "fiemap.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
#ifndef HAVE_FIEMAP
|
||||
# include "fiemap.h"
|
||||
#endif
|
||||
|
||||
/* Work around Linux kernel issues on BTRFS and EXT4 before 2.6.39.
|
||||
FIXME: remove in 2013, or whenever we're pretty confident
|
||||
@@ -50,7 +48,7 @@ extent_need_sync (void)
|
||||
struct utsname name;
|
||||
need_sync = 0; /* No workaround by default. */
|
||||
|
||||
#ifdef __linux__
|
||||
# ifdef __linux__
|
||||
if (uname (&name) != -1 && STRNCMP_LIT (name.release, "2.6.") == 0)
|
||||
{
|
||||
unsigned long val;
|
||||
@@ -60,7 +58,7 @@ extent_need_sync (void)
|
||||
need_sync = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
return need_sync;
|
||||
|
||||
@@ -160,7 +160,7 @@ factor_using_pollard_rho (mpz_t n, int a_int)
|
||||
mpz_t a;
|
||||
mpz_t g;
|
||||
mpz_t t1, t2;
|
||||
int k, l, c, i;
|
||||
int k, l, c;
|
||||
|
||||
debug ("[pollard-rho (%d)] ", a_int);
|
||||
|
||||
@@ -204,6 +204,7 @@ S2:
|
||||
mpz_set (x1, x);
|
||||
k = l;
|
||||
l = 2 * l;
|
||||
unsigned int i;
|
||||
for (i = 0; i < k; i++)
|
||||
{
|
||||
mpz_mul (x, x, x); mpz_add (x, x, a); mpz_mod (x, x, n);
|
||||
|
||||
@@ -51,8 +51,13 @@ struct fiemap
|
||||
|
||||
uint32_t fm_reserved;
|
||||
|
||||
/* Array of mapped extents(out). */
|
||||
/* Array of mapped extents(out).
|
||||
This is protected by the ifdef because it uses non standard
|
||||
zero length arrays. Note C99 has the equivalent flexible arrays,
|
||||
but we don't use those for maximum portability to older systems. */
|
||||
# ifdef __linux__
|
||||
struct fiemap_extent fm_extents[0];
|
||||
# endif
|
||||
};
|
||||
|
||||
/* The maximum offset can be mapped for a file. */
|
||||
|
||||
13
src/head.c
13
src/head.c
@@ -32,7 +32,6 @@
|
||||
#include "system.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "full-write.h"
|
||||
#include "full-read.h"
|
||||
#include "quote.h"
|
||||
#include "safe-read.h"
|
||||
@@ -390,7 +389,7 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0)
|
||||
}
|
||||
}
|
||||
|
||||
free_mem:;
|
||||
free_mem:
|
||||
for (i = 0; i < n_bufs; i++)
|
||||
free (b[i]);
|
||||
free (b);
|
||||
@@ -422,8 +421,8 @@ elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide)
|
||||
off_t diff;
|
||||
enum Copy_fd_status err;
|
||||
|
||||
if ((current_pos = lseek (fd, (off_t) 0, SEEK_CUR)) == -1
|
||||
|| (end_pos = lseek (fd, (off_t) 0, SEEK_END)) == -1)
|
||||
if ((current_pos = lseek (fd, 0, SEEK_CUR)) == -1
|
||||
|| (end_pos = lseek (fd, 0, SEEK_END)) == -1)
|
||||
{
|
||||
error (0, errno, _("cannot lseek %s"), quote (filename));
|
||||
return false;
|
||||
@@ -438,7 +437,7 @@ elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide)
|
||||
|
||||
/* Seek back to `current' position, then copy the required
|
||||
number of bytes from fd. */
|
||||
if (lseek (fd, (off_t) 0, current_pos) == -1)
|
||||
if (lseek (fd, 0, current_pos) == -1)
|
||||
{
|
||||
error (0, errno, _("%s: cannot lseek back to original position"),
|
||||
quote (filename));
|
||||
@@ -716,8 +715,8 @@ elide_tail_lines_file (const char *filename, int fd, uintmax_t n_elide)
|
||||
If found, write from current position to OFF, inclusive.
|
||||
Otherwise, just return true. */
|
||||
|
||||
off_t start_pos = lseek (fd, (off_t) 0, SEEK_CUR);
|
||||
off_t end_pos = lseek (fd, (off_t) 0, SEEK_END);
|
||||
off_t start_pos = lseek (fd, 0, SEEK_CUR);
|
||||
off_t end_pos = lseek (fd, 0, SEEK_END);
|
||||
if (0 <= start_pos && start_pos < end_pos)
|
||||
{
|
||||
/* If the file is empty, we're done. */
|
||||
|
||||
66
src/ioblksize.h
Normal file
66
src/ioblksize.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* I/O block size definitions for coreutils
|
||||
Copyright (C) 1989, 1991-2011 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Include this file _after_ system headers if possible. */
|
||||
|
||||
/* sys/stat.h will already have been included by system.h. */
|
||||
#include "stat-size.h"
|
||||
|
||||
|
||||
/* As of Mar 2009, 32KiB is determined to be the minimium
|
||||
blksize to best minimize system call overhead.
|
||||
This can be tested with this script with the results
|
||||
shown for a 1.7GHz pentium-m with 2GB of 400MHz DDR2 RAM:
|
||||
|
||||
for i in $(seq 0 10); do
|
||||
size=$((8*1024**3)) #ensure this is big enough
|
||||
bs=$((1024*2**$i))
|
||||
printf "%7s=" $bs
|
||||
dd bs=$bs if=/dev/zero of=/dev/null count=$(($size/$bs)) 2>&1 |
|
||||
sed -n 's/.* \([0-9.]* [GM]B\/s\)/\1/p'
|
||||
done
|
||||
|
||||
1024=734 MB/s
|
||||
2048=1.3 GB/s
|
||||
4096=2.4 GB/s
|
||||
8192=3.5 GB/s
|
||||
16384=3.9 GB/s
|
||||
32768=5.2 GB/s
|
||||
65536=5.3 GB/s
|
||||
131072=5.5 GB/s
|
||||
262144=5.7 GB/s
|
||||
524288=5.7 GB/s
|
||||
1048576=5.8 GB/s
|
||||
|
||||
Note that this is to minimize system call overhead.
|
||||
Other values may be appropriate to minimize file system
|
||||
or disk overhead. For example on my current GNU/Linux system
|
||||
the readahead setting is 128KiB which was read using:
|
||||
|
||||
file="."
|
||||
device=$(df -P --local "$file" | tail -n1 | cut -d' ' -f1)
|
||||
echo $(( $(blockdev --getra $device) * 512 ))
|
||||
|
||||
However there isn't a portable way to get the above.
|
||||
In the future we could use the above method if available
|
||||
and default to io_blksize() if not.
|
||||
*/
|
||||
enum { IO_BUFSIZE = 32*1024 };
|
||||
static inline size_t
|
||||
io_blksize (struct stat sb)
|
||||
{
|
||||
return MAX (IO_BUFSIZE, ST_BLKSIZE (sb));
|
||||
}
|
||||
46
src/join.c
46
src/join.c
@@ -86,9 +86,15 @@ struct seq
|
||||
struct line **lines;
|
||||
};
|
||||
|
||||
/* The previous line read from each file. */
|
||||
/* The previous line read from each file. */
|
||||
static struct line *prevline[2] = {NULL, NULL};
|
||||
|
||||
/* The number of lines read from each file. */
|
||||
static uintmax_t line_no[2] = {0, 0};
|
||||
|
||||
/* The input file names. */
|
||||
static char *g_names[2];
|
||||
|
||||
/* This provides an extra line buffer for each file. We need these if we
|
||||
try to read two consecutive lines into the same buffer, since we don't
|
||||
want to overwrite the previous buffer before we check order. */
|
||||
@@ -384,12 +390,23 @@ check_order (const struct line *prev,
|
||||
size_t join_field = whatfile == 1 ? join_field_1 : join_field_2;
|
||||
if (keycmp (prev, current, join_field, join_field) > 0)
|
||||
{
|
||||
/* Exclude any trailing newline. */
|
||||
size_t len = current->buf.length;
|
||||
if (0 < len && current->buf.buffer[len - 1] == '\n')
|
||||
--len;
|
||||
|
||||
/* If the offending line is longer than INT_MAX, output
|
||||
only the first INT_MAX bytes in this diagnostic. */
|
||||
len = MIN (INT_MAX, len);
|
||||
|
||||
error ((check_input_order == CHECK_ORDER_ENABLED
|
||||
? EXIT_FAILURE : 0),
|
||||
0, _("file %d is not in sorted order"), whatfile);
|
||||
0, _("%s:%ju: is not sorted: %.*s"),
|
||||
g_names[whatfile - 1], line_no[whatfile - 1],
|
||||
(int) len, current->buf.buffer);
|
||||
|
||||
/* If we get to here, the message was just a warning, but we
|
||||
want only to issue it once. */
|
||||
/* If we get to here, the message was merely a warning.
|
||||
Arrange to issue it only once per file. */
|
||||
issued_disorder_warning[whatfile-1] = true;
|
||||
}
|
||||
}
|
||||
@@ -405,8 +422,7 @@ reset_line (struct line *line)
|
||||
static struct line *
|
||||
init_linep (struct line **linep)
|
||||
{
|
||||
struct line *line = xmalloc (sizeof *line);
|
||||
memset (line, '\0', sizeof *line);
|
||||
struct line *line = xcalloc (1, sizeof *line);
|
||||
*linep = line;
|
||||
return line;
|
||||
}
|
||||
@@ -437,6 +453,7 @@ get_line (FILE *fp, struct line **linep, int which)
|
||||
freeline (line);
|
||||
return false;
|
||||
}
|
||||
++line_no[which - 1];
|
||||
|
||||
xfields (line);
|
||||
|
||||
@@ -981,7 +998,6 @@ main (int argc, char **argv)
|
||||
int prev_optc_status = MUST_BE_OPERAND;
|
||||
int operand_status[2];
|
||||
int joption_count[2] = { 0, 0 };
|
||||
char *names[2];
|
||||
FILE *fp1, *fp2;
|
||||
int optc;
|
||||
int nfiles = 0;
|
||||
@@ -1101,7 +1117,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 1: /* Non-option argument. */
|
||||
add_file_name (optarg, names, operand_status, joption_count,
|
||||
add_file_name (optarg, g_names, operand_status, joption_count,
|
||||
&nfiles, &prev_optc_status, &optc_status);
|
||||
break;
|
||||
|
||||
@@ -1123,7 +1139,7 @@ main (int argc, char **argv)
|
||||
/* Process any operands after "--". */
|
||||
prev_optc_status = MUST_BE_OPERAND;
|
||||
while (optind < argc)
|
||||
add_file_name (argv[optind++], names, operand_status, joption_count,
|
||||
add_file_name (argv[optind++], g_names, operand_status, joption_count,
|
||||
&nfiles, &prev_optc_status, &optc_status);
|
||||
|
||||
if (nfiles != 2)
|
||||
@@ -1149,20 +1165,20 @@ main (int argc, char **argv)
|
||||
if (join_field_2 == SIZE_MAX)
|
||||
join_field_2 = 0;
|
||||
|
||||
fp1 = STREQ (names[0], "-") ? stdin : fopen (names[0], "r");
|
||||
fp1 = STREQ (g_names[0], "-") ? stdin : fopen (g_names[0], "r");
|
||||
if (!fp1)
|
||||
error (EXIT_FAILURE, errno, "%s", names[0]);
|
||||
fp2 = STREQ (names[1], "-") ? stdin : fopen (names[1], "r");
|
||||
error (EXIT_FAILURE, errno, "%s", g_names[0]);
|
||||
fp2 = STREQ (g_names[1], "-") ? stdin : fopen (g_names[1], "r");
|
||||
if (!fp2)
|
||||
error (EXIT_FAILURE, errno, "%s", names[1]);
|
||||
error (EXIT_FAILURE, errno, "%s", g_names[1]);
|
||||
if (fp1 == fp2)
|
||||
error (EXIT_FAILURE, errno, _("both files cannot be standard input"));
|
||||
join (fp1, fp2);
|
||||
|
||||
if (fclose (fp1) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", names[0]);
|
||||
error (EXIT_FAILURE, errno, "%s", g_names[0]);
|
||||
if (fclose (fp2) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", names[1]);
|
||||
error (EXIT_FAILURE, errno, "%s", g_names[1]);
|
||||
|
||||
if (issued_disorder_warning[0] || issued_disorder_warning[1])
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
@@ -293,7 +292,7 @@ main (int argc, char **argv)
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
no_more_options:;
|
||||
no_more_options:
|
||||
|
||||
if (signum < 0)
|
||||
signum = SIGTERM;
|
||||
|
||||
80
src/ls.c
80
src/ls.c
@@ -53,7 +53,6 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <setjmp.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
@@ -75,6 +74,14 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* NonStop circa 2011 lacks both SA_RESTART and siginterrupt, so don't
|
||||
restart syscalls after a signal handler fires. This may cause
|
||||
colors to get messed up on the screen if 'ls' is interrupted, but
|
||||
that's the best we can do on such a platform. */
|
||||
#ifndef SA_RESTART
|
||||
# define SA_RESTART 0
|
||||
#endif
|
||||
|
||||
#include "system.h"
|
||||
#include <fnmatch.h>
|
||||
|
||||
@@ -95,7 +102,7 @@
|
||||
#include "obstack.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "same.h"
|
||||
#include "stat-size.h"
|
||||
#include "stat-time.h"
|
||||
#include "strftime.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -2265,12 +2272,21 @@ get_funky_string (char **dest, const char **src, bool equals_end,
|
||||
return state != ST_ERROR;
|
||||
}
|
||||
|
||||
enum parse_state
|
||||
{
|
||||
PS_START = 1,
|
||||
PS_2,
|
||||
PS_3,
|
||||
PS_4,
|
||||
PS_DONE,
|
||||
PS_FAIL
|
||||
};
|
||||
|
||||
static void
|
||||
parse_ls_color (void)
|
||||
{
|
||||
const char *p; /* Pointer to character being parsed */
|
||||
char *buf; /* color_buf buffer pointer */
|
||||
int state; /* State of parser */
|
||||
int ind_no; /* Indicator number */
|
||||
char label[3]; /* Indicator label */
|
||||
struct color_ext_type *ext; /* Extension we are working on */
|
||||
@@ -2287,12 +2303,12 @@ parse_ls_color (void)
|
||||
advance. */
|
||||
buf = color_buf = xstrdup (p);
|
||||
|
||||
state = 1;
|
||||
while (state > 0)
|
||||
enum parse_state state = PS_START;
|
||||
while (true)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case 1: /* First label character */
|
||||
case PS_START: /* First label character */
|
||||
switch (*p)
|
||||
{
|
||||
case ':':
|
||||
@@ -2313,32 +2329,32 @@ parse_ls_color (void)
|
||||
ext->ext.string = buf;
|
||||
|
||||
state = (get_funky_string (&buf, &p, true, &ext->ext.len)
|
||||
? 4 : -1);
|
||||
? PS_4 : PS_FAIL);
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
state = 0; /* Done! */
|
||||
break;
|
||||
state = PS_DONE; /* Done! */
|
||||
goto done;
|
||||
|
||||
default: /* Assume it is file type label */
|
||||
label[0] = *(p++);
|
||||
state = 2;
|
||||
state = PS_2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* Second label character */
|
||||
case PS_2: /* Second label character */
|
||||
if (*p)
|
||||
{
|
||||
label[1] = *(p++);
|
||||
state = 3;
|
||||
state = PS_3;
|
||||
}
|
||||
else
|
||||
state = -1; /* Error */
|
||||
state = PS_FAIL; /* Error */
|
||||
break;
|
||||
|
||||
case 3: /* Equal sign after indicator label */
|
||||
state = -1; /* Assume failure... */
|
||||
case PS_3: /* Equal sign after indicator label */
|
||||
state = PS_FAIL; /* Assume failure... */
|
||||
if (*(p++) == '=')/* It *should* be... */
|
||||
{
|
||||
for (ind_no = 0; indicator_name[ind_no] != NULL; ++ind_no)
|
||||
@@ -2348,29 +2364,36 @@ parse_ls_color (void)
|
||||
color_indicator[ind_no].string = buf;
|
||||
state = (get_funky_string (&buf, &p, false,
|
||||
&color_indicator[ind_no].len)
|
||||
? 1 : -1);
|
||||
? PS_START : PS_FAIL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (state == -1)
|
||||
if (state == PS_FAIL)
|
||||
error (0, 0, _("unrecognized prefix: %s"), quotearg (label));
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: /* Equal sign after *.ext */
|
||||
case PS_4: /* Equal sign after *.ext */
|
||||
if (*(p++) == '=')
|
||||
{
|
||||
ext->seq.string = buf;
|
||||
state = (get_funky_string (&buf, &p, false, &ext->seq.len)
|
||||
? 1 : -1);
|
||||
? PS_START : PS_FAIL);
|
||||
}
|
||||
else
|
||||
state = -1;
|
||||
state = PS_FAIL;
|
||||
break;
|
||||
|
||||
case PS_FAIL:
|
||||
goto done;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
done:
|
||||
|
||||
if (state < 0)
|
||||
if (state == PS_FAIL)
|
||||
{
|
||||
struct color_ext_type *e;
|
||||
struct color_ext_type *e2;
|
||||
@@ -2740,7 +2763,10 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
/* When coloring a directory (we may know the type from
|
||||
direct.d_type), we have to stat it in order to indicate
|
||||
sticky and/or other-writable attributes. */
|
||||
|| (type == directory && print_with_color)
|
||||
|| (type == directory && print_with_color
|
||||
&& (is_colored (C_OTHER_WRITABLE)
|
||||
|| is_colored (C_STICKY)
|
||||
|| is_colored (C_STICKY_OTHER_WRITABLE)))
|
||||
/* When dereferencing symlinks, the inode and type must come from
|
||||
stat, but readdir provides the inode and type of lstat. */
|
||||
|| ((print_inode || format_needs_type)
|
||||
@@ -3891,7 +3917,7 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
|
||||
reach its end, replacing each non-printable multibyte
|
||||
character with a single question mark. */
|
||||
{
|
||||
DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate);
|
||||
mbstate_t mbstate = { 0, };
|
||||
do
|
||||
{
|
||||
wchar_t wc;
|
||||
@@ -4129,7 +4155,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target)
|
||||
{
|
||||
name = f->linkname;
|
||||
mode = f->linkmode;
|
||||
linkok = f->linkok - 1;
|
||||
linkok = f->linkok ? 0 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4570,7 +4596,7 @@ usage (int status)
|
||||
printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name);
|
||||
fputs (_("\
|
||||
List information about the FILEs (the current directory by default).\n\
|
||||
Sort entries alphabetically if none of -cftuvSUX nor --sort.\n\
|
||||
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
@@ -4590,7 +4616,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-c with -lt: sort by, and show, ctime (time of last\n\
|
||||
modification of file status information)\n\
|
||||
with -l: show ctime and sort by name\n\
|
||||
otherwise: sort by ctime\n\
|
||||
otherwise: sort by ctime, newest first\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-C list entries by columns\n\
|
||||
@@ -4693,7 +4719,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
takes effect only outside the POSIX locale\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-t sort by modification time\n\
|
||||
-t sort by modification time, newest first\n\
|
||||
-T, --tabsize=COLS assume tab stops at each COLS instead of 8\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
|
||||
29
src/md5sum.c
29
src/md5sum.c
@@ -122,12 +122,17 @@ static bool warn = false;
|
||||
/* With --check, suppress the "OK" printed for each verified file. */
|
||||
static bool quiet = false;
|
||||
|
||||
/* With --check, exit with a non-zero return code if any line is
|
||||
improperly formatted. */
|
||||
static bool strict = false;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
STATUS_OPTION = CHAR_MAX + 1,
|
||||
QUIET_OPTION
|
||||
QUIET_OPTION,
|
||||
STRICT_OPTION
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
@@ -138,6 +143,7 @@ static struct option const long_options[] =
|
||||
{ "status", no_argument, NULL, STATUS_OPTION },
|
||||
{ "text", no_argument, NULL, 't' },
|
||||
{ "warn", no_argument, NULL, 'w' },
|
||||
{ "strict", no_argument, NULL, STRICT_OPTION },
|
||||
{ GETOPT_HELP_OPTION_DECL },
|
||||
{ GETOPT_VERSION_OPTION_DECL },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
@@ -186,6 +192,9 @@ The following three options are useful only when verifying checksums:\n\
|
||||
--status don't output anything, status code shows success\n\
|
||||
-w, --warn warn about improperly formatted checksum lines\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--strict with --check, exit non-zero for any invalid input\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
@@ -355,7 +364,7 @@ split_3 (char *s, size_t s_len,
|
||||
|
||||
/* Return true if S is a NUL-terminated string of DIGEST_HEX_BYTES hex digits.
|
||||
Otherwise, return false. */
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
hex_digits (unsigned char const *s)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -434,6 +443,7 @@ digest_check (const char *checkfile_name)
|
||||
FILE *checkfile_stream;
|
||||
uintmax_t n_misformatted_lines = 0;
|
||||
uintmax_t n_properly_formatted_lines = 0;
|
||||
uintmax_t n_improperly_formatted_lines = 0;
|
||||
uintmax_t n_mismatched_checksums = 0;
|
||||
uintmax_t n_open_or_read_failures = 0;
|
||||
unsigned char bin_buffer_unaligned[DIGEST_BIN_BYTES + DIGEST_ALIGN];
|
||||
@@ -501,6 +511,8 @@ digest_check (const char *checkfile_name)
|
||||
checkfile_name, line_number,
|
||||
DIGEST_TYPE_STRING);
|
||||
}
|
||||
|
||||
++n_improperly_formatted_lines;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -603,7 +615,8 @@ digest_check (const char *checkfile_name)
|
||||
|
||||
return (n_properly_formatted_lines != 0
|
||||
&& n_mismatched_checksums == 0
|
||||
&& n_open_or_read_failures == 0);
|
||||
&& n_open_or_read_failures == 0
|
||||
&& (!strict || n_improperly_formatted_lines == 0));
|
||||
}
|
||||
|
||||
int
|
||||
@@ -657,6 +670,9 @@ main (int argc, char **argv)
|
||||
warn = false;
|
||||
quiet = true;
|
||||
break;
|
||||
case STRICT_OPTION:
|
||||
strict = true;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
@@ -694,6 +710,13 @@ main (int argc, char **argv)
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (strict & !do_check)
|
||||
{
|
||||
error (0, 0,
|
||||
_("the --strict option is meaningful only when verifying checksums"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!O_BINARY && binary < 0)
|
||||
binary = 0;
|
||||
|
||||
|
||||
@@ -71,6 +71,9 @@ usage (int status)
|
||||
Create a temporary file or directory, safely, and print its name.\n\
|
||||
TEMPLATE must contain at least 3 consecutive `X's in last component.\n\
|
||||
If TEMPLATE is not specified, use tmp.XXXXXXXXXX, and --tmpdir is implied.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
Files are created u+rw, and directories u+rwx, minus umask restrictions.\n\
|
||||
"), stdout);
|
||||
fputs ("\n", stdout);
|
||||
fputs (_("\
|
||||
@@ -341,7 +344,7 @@ main (int argc, char **argv)
|
||||
puts (dest_name);
|
||||
/* If we created a file, but then failed to output the file
|
||||
name, we should clean up the mess before failing. */
|
||||
if (!dry_run && (stdout_closed = true) && close_stream (stdout) != 0)
|
||||
if (!dry_run && ((stdout_closed = true), close_stream (stdout) != 0))
|
||||
{
|
||||
int saved_errno = errno;
|
||||
remove (dest_name);
|
||||
|
||||
4
src/od.c
4
src/od.c
@@ -1257,7 +1257,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
|
||||
/* Return the least common multiple of the sizes associated
|
||||
with the format specs. */
|
||||
|
||||
static int
|
||||
static int _GL_ATTRIBUTE_PURE
|
||||
get_lcm (void)
|
||||
{
|
||||
size_t i;
|
||||
@@ -1905,7 +1905,7 @@ it must be one character from [doxn]"),
|
||||
|
||||
ok &= (flag_dump_strings ? dump_strings () : dump ());
|
||||
|
||||
cleanup:;
|
||||
cleanup:
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF)
|
||||
error (EXIT_FAILURE, errno, _("standard input"));
|
||||
|
||||
@@ -145,7 +145,7 @@ collapse_escapes (char const *strptr)
|
||||
}
|
||||
}
|
||||
|
||||
done:;
|
||||
done:
|
||||
|
||||
delim_end = strout;
|
||||
return backslash_at_end ? 1 : 0;
|
||||
|
||||
@@ -25,11 +25,6 @@
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
|
||||
#if ! (HAVE_MBRLEN && HAVE_MBSTATE_T)
|
||||
# define mbrlen(s, n, ps) 1
|
||||
# define mbstate_t int
|
||||
#endif
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "pathchk"
|
||||
|
||||
@@ -196,7 +191,7 @@ portable_chars_only (char const *file, size_t filelen)
|
||||
|
||||
if (*invalid)
|
||||
{
|
||||
DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate);
|
||||
mbstate_t mbstate = { 0, };
|
||||
size_t charlen = mbrlen (invalid, filelen - validlen, &mbstate);
|
||||
error (0, 0,
|
||||
_("nonportable character %s in file name %s"),
|
||||
@@ -211,7 +206,7 @@ portable_chars_only (char const *file, size_t filelen)
|
||||
|
||||
/* Return the address of the start of the next file name component in F. */
|
||||
|
||||
static char *
|
||||
static char * _GL_ATTRIBUTE_PURE
|
||||
component_start (char *f)
|
||||
{
|
||||
while (*f == '/')
|
||||
@@ -221,7 +216,7 @@ component_start (char *f)
|
||||
|
||||
/* Return the size of the file name component F. F must be nonempty. */
|
||||
|
||||
static size_t
|
||||
static size_t _GL_ATTRIBUTE_PURE
|
||||
component_len (char const *f)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
@@ -82,7 +82,7 @@ static struct option const longopts[] =
|
||||
|
||||
/* Count and return the number of ampersands in STR. */
|
||||
|
||||
static size_t
|
||||
static size_t _GL_ATTRIBUTE_PURE
|
||||
count_ampersands (const char *str)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
8
src/pr.c
8
src/pr.c
@@ -773,7 +773,7 @@ static struct option const long_options[] =
|
||||
/* Return the number of columns that have either an open file or
|
||||
stored lines. */
|
||||
|
||||
static int
|
||||
static int _GL_ATTRIBUTE_PURE
|
||||
cols_ready_to_print (void)
|
||||
{
|
||||
COLUMN *q;
|
||||
@@ -1165,7 +1165,7 @@ main (int argc, char **argv)
|
||||
print_files (n_files, file_names);
|
||||
else
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
for (i = 0; i < n_files; i++)
|
||||
print_files (1, &file_names[i]);
|
||||
}
|
||||
@@ -1887,7 +1887,7 @@ print_page (void)
|
||||
print_a_FF = false;
|
||||
}
|
||||
|
||||
if (last_page_number < page_number)
|
||||
if (last_page_number < ++page_number)
|
||||
return false; /* Stop printing with LAST_PAGE */
|
||||
|
||||
reset_status (); /* Change ON_HOLD to OPEN. */
|
||||
@@ -2399,7 +2399,7 @@ print_header (void)
|
||||
/* The translator must ensure that formatting the translation of
|
||||
"Page %"PRIuMAX does not generate more than (sizeof page_text - 1)
|
||||
bytes. */
|
||||
sprintf (page_text, _("Page %"PRIuMAX), page_number++);
|
||||
sprintf (page_text, _("Page %"PRIuMAX), page_number);
|
||||
available_width = header_width_available - mbswidth (page_text, 0);
|
||||
available_width = MAX (0, available_width);
|
||||
lhs_spaces = available_width >> 1;
|
||||
|
||||
@@ -160,7 +160,7 @@ FUNC_NAME (char const *s) \
|
||||
char *end; \
|
||||
TYPE val; \
|
||||
\
|
||||
if (*s == '\"' || *s == '\'') \
|
||||
if ((*s == '\"' || *s == '\'') && *(s + 1)) \
|
||||
{ \
|
||||
unsigned char ch = *++s; \
|
||||
val = ch; \
|
||||
@@ -533,7 +533,7 @@ print_formatted (const char *format, int argc, char **argv)
|
||||
default:
|
||||
goto no_more_flag_characters;
|
||||
}
|
||||
no_more_flag_characters:;
|
||||
no_more_flag_characters:
|
||||
|
||||
if (*f == '*')
|
||||
{
|
||||
|
||||
@@ -595,7 +595,7 @@ compare_occurs (const void *void_first, const void *void_second)
|
||||
| Return !0 if WORD appears in TABLE. Uses a binary search. |
|
||||
`------------------------------------------------------------*/
|
||||
|
||||
static int
|
||||
static int _GL_ATTRIBUTE_PURE
|
||||
search_table (WORD *word, WORD_TABLE *table)
|
||||
{
|
||||
int lowest; /* current lowest possible index */
|
||||
@@ -797,7 +797,7 @@ find_occurs_in_text (void)
|
||||
|
||||
context_start = cursor;
|
||||
|
||||
/* If a end of line or end of sentence sequence is defined and
|
||||
/* If an end of line or end of sentence sequence is defined and
|
||||
non-empty, `next_context_start' will be recomputed to be the end of
|
||||
each line or sentence, before each one is processed. If no such
|
||||
sequence, then `next_context_start' is set at the end of the whole
|
||||
|
||||
15
src/shred.c
15
src/shred.c
@@ -100,6 +100,7 @@
|
||||
#include "quotearg.h" /* For quotearg_colon */
|
||||
#include "randint.h"
|
||||
#include "randread.h"
|
||||
#include "stat-size.h"
|
||||
|
||||
/* Default number of times to overwrite. */
|
||||
enum { DEFAULT_PASSES = 3 };
|
||||
@@ -781,7 +782,7 @@ do_wipefd (int fd, char const *qname, struct randint_source *s,
|
||||
}
|
||||
|
||||
/* If we know that we can't possibly shred the file, give up now.
|
||||
Otherwise, we may go into a infinite loop writing data before we
|
||||
Otherwise, we may go into an infinite loop writing data before we
|
||||
find that we can't rewind the device. */
|
||||
if ((S_ISCHR (st.st_mode) && isatty (fd))
|
||||
|| S_ISFIFO (st.st_mode)
|
||||
@@ -907,9 +908,9 @@ static char const nameset[] =
|
||||
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.";
|
||||
|
||||
/* Increment NAME (with LEN bytes). NAME must be a big-endian base N
|
||||
number with the digits taken from nameset. Return true if
|
||||
successful if not (because NAME already has the greatest possible
|
||||
value. */
|
||||
number with the digits taken from nameset. Return true if successful.
|
||||
Otherwise, (because NAME already has the greatest possible value)
|
||||
return false. */
|
||||
|
||||
static bool
|
||||
incname (char *name, size_t len)
|
||||
@@ -918,6 +919,10 @@ incname (char *name, size_t len)
|
||||
{
|
||||
char const *p = strchr (nameset, name[len]);
|
||||
|
||||
/* Given that NAME is composed of bytes from NAMESET,
|
||||
P will never be NULL here. */
|
||||
assert (p);
|
||||
|
||||
/* If this character has a successor, use it. */
|
||||
if (p[1])
|
||||
{
|
||||
@@ -1098,7 +1103,7 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
bool ok = true;
|
||||
DECLARE_ZEROED_AGGREGATE (struct Options, flags);
|
||||
struct Options flags = { 0, };
|
||||
char **file;
|
||||
int n_files;
|
||||
int c;
|
||||
|
||||
@@ -112,7 +112,7 @@ struct rlimit { size_t rlim_cur; };
|
||||
/* Heuristic value for the number of lines for which it is worth creating
|
||||
a subthread, during an internal merge sort. I.e., it is a small number
|
||||
of "average" lines for which sorting via two threads is faster than
|
||||
sorting via one on an "average" system. On an dual-core 2.0 GHz i686
|
||||
sorting via one on an "average" system. On a dual-core 2.0 GHz i686
|
||||
system with 3GB of RAM and 2MB of L2 cache, a file containing 128K
|
||||
lines of gensort -a output is sorted slightly faster with --parallel=2
|
||||
than with --parallel=1. By contrast, using --parallel=1 is about 10%
|
||||
@@ -1846,7 +1846,7 @@ static char const unit_order[UCHAR_LIM] =
|
||||
separators and a decimal point, but it may not contain leading blanks.
|
||||
Negative numbers get negative orders; zero numbers have a zero order. */
|
||||
|
||||
static int
|
||||
static int _GL_ATTRIBUTE_PURE
|
||||
find_unit_order (char const *number)
|
||||
{
|
||||
bool minus_sign = (*number == '-');
|
||||
@@ -2029,7 +2029,7 @@ compare_random (char *restrict texta, size_t lena,
|
||||
char *restrict textb, size_t lenb)
|
||||
{
|
||||
/* XFRM_DIFF records the equivalent of memcmp on the transformed
|
||||
data. This is used to break ties if there is an checksum
|
||||
data. This is used to break ties if there is a checksum
|
||||
collision, and this is good enough given the astronomically low
|
||||
probability of a collision. */
|
||||
int xfrm_diff = 0;
|
||||
@@ -2385,7 +2385,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
|
||||
size_t eword = key->eword + 1;
|
||||
if (!sword)
|
||||
sword++;
|
||||
if (sword != eword)
|
||||
if (!eword || sword < eword)
|
||||
error (0, 0, _("key %lu is numeric and spans multiple fields"),
|
||||
keynum);
|
||||
}
|
||||
|
||||
279
src/split.c
279
src/split.c
@@ -25,7 +25,9 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
@@ -33,8 +35,10 @@
|
||||
#include "fcntl--.h"
|
||||
#include "full-read.h"
|
||||
#include "full-write.h"
|
||||
#include "ioblksize.h"
|
||||
#include "quote.h"
|
||||
#include "safe-read.h"
|
||||
#include "sig2str.h"
|
||||
#include "xfreopen.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -45,6 +49,21 @@
|
||||
proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \
|
||||
proper_name ("Richard M. Stallman")
|
||||
|
||||
/* Shell command to filter through, instead of creating files. */
|
||||
static char const *filter_command;
|
||||
|
||||
/* Process ID of the filter. */
|
||||
static int filter_pid;
|
||||
|
||||
/* Array of open pipes. */
|
||||
static int *open_pipes;
|
||||
static size_t open_pipes_alloc;
|
||||
static size_t n_open_pipes;
|
||||
|
||||
/* Blocked signals. */
|
||||
static sigset_t oldblocked;
|
||||
static sigset_t newblocked;
|
||||
|
||||
/* Base name of output files. */
|
||||
static char const *outbase;
|
||||
|
||||
@@ -90,6 +109,7 @@ enum Split_type
|
||||
enum
|
||||
{
|
||||
VERBOSE_OPTION = CHAR_MAX + 1,
|
||||
FILTER_OPTION,
|
||||
IO_BLKSIZE_OPTION
|
||||
};
|
||||
|
||||
@@ -103,14 +123,22 @@ static struct option const longopts[] =
|
||||
{"unbuffered", no_argument, NULL, 'u'},
|
||||
{"suffix-length", required_argument, NULL, 'a'},
|
||||
{"numeric-suffixes", no_argument, NULL, 'd'},
|
||||
{"filter", required_argument, NULL, FILTER_OPTION},
|
||||
{"verbose", no_argument, NULL, VERBOSE_OPTION},
|
||||
{"-io-blksize", required_argument, NULL,
|
||||
IO_BLKSIZE_OPTION}, /* do not document */
|
||||
IO_BLKSIZE_OPTION}, /* do not document */
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
/* Return true if the errno value, ERR, is ignorable. */
|
||||
static inline bool
|
||||
ignorable (int err)
|
||||
{
|
||||
return filter_command && err == EPIPE;
|
||||
}
|
||||
|
||||
static void
|
||||
set_suffix_length (uintmax_t n_units, enum Split_type split_type)
|
||||
{
|
||||
@@ -155,7 +183,7 @@ usage (int status)
|
||||
Usage: %s [OPTION]... [INPUT [PREFIX]]\n\
|
||||
"),
|
||||
program_name);
|
||||
fputs (_("\
|
||||
fputs (_("\
|
||||
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default\n\
|
||||
size is 1000 lines, and default PREFIX is `x'. With no INPUT, or when INPUT\n\
|
||||
is -, read standard input.\n\
|
||||
@@ -170,6 +198,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-C, --line-bytes=SIZE put at most SIZE bytes of lines per output file\n\
|
||||
-d, --numeric-suffixes use numeric suffixes instead of alphabetic\n\
|
||||
-e, --elide-empty-files do not generate empty output files with `-n'\n\
|
||||
--filter=COMMAND write to shell COMMAND; file name is $FILE\n\
|
||||
-l, --lines=NUMBER put NUMBER lines per output file\n\
|
||||
-n, --number=CHUNKS generate CHUNKS output files. See below\n\
|
||||
-u, --unbuffered immediately copy input to output with `-n r/...'\n\
|
||||
@@ -181,7 +210,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_size_note ();
|
||||
fputs (_("\n\
|
||||
fputs (_("\n\
|
||||
CHUNKS may be:\n\
|
||||
N split into N files based on size of input\n\
|
||||
K/N output Kth of N to stdout\n\
|
||||
@@ -254,12 +283,125 @@ next_file_name (void)
|
||||
/* Create or truncate a file. */
|
||||
|
||||
static int
|
||||
create (const char* name)
|
||||
create (const char *name)
|
||||
{
|
||||
if (verbose)
|
||||
fprintf (stdout, _("creating file %s\n"), quote (name));
|
||||
return open (name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
|
||||
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
|
||||
if (!filter_command)
|
||||
{
|
||||
if (verbose)
|
||||
fprintf (stdout, _("creating file %s\n"), quote (name));
|
||||
return open (name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
|
||||
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
|
||||
}
|
||||
else
|
||||
{
|
||||
int fd_pair[2];
|
||||
pid_t child_pid;
|
||||
char const *shell_prog = getenv ("SHELL");
|
||||
if (shell_prog == NULL)
|
||||
shell_prog = "/bin/sh";
|
||||
if (setenv ("FILE", name, 1) != 0)
|
||||
error (EXIT_FAILURE, errno,
|
||||
_("failed to set FILE environment variable"));
|
||||
if (verbose)
|
||||
fprintf (stdout, _("executing with FILE=%s\n"), quote (name));
|
||||
if (pipe (fd_pair) != 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to create pipe"));
|
||||
child_pid = fork ();
|
||||
if (child_pid == 0)
|
||||
{
|
||||
/* This is the child process. If an error occurs here, the
|
||||
parent will eventually learn about it after doing a wait,
|
||||
at which time it will emit its own error message. */
|
||||
int j;
|
||||
/* We have to close any pipes that were opened during an
|
||||
earlier call, otherwise this process will be holding a
|
||||
write-pipe that will prevent the earlier process from
|
||||
reading an EOF on the corresponding read-pipe. */
|
||||
for (j = 0; j < n_open_pipes; ++j)
|
||||
if (close (open_pipes[j]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("closing prior pipe"));
|
||||
if (close (fd_pair[1]))
|
||||
error (EXIT_FAILURE, errno, _("closing output pipe"));
|
||||
if (fd_pair[0] != STDIN_FILENO)
|
||||
{
|
||||
if (dup2 (fd_pair[0], STDIN_FILENO) != STDIN_FILENO)
|
||||
error (EXIT_FAILURE, errno, _("moving input pipe"));
|
||||
if (close (fd_pair[0]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("closing input pipe"));
|
||||
}
|
||||
sigprocmask (SIG_SETMASK, &oldblocked, NULL);
|
||||
execl (shell_prog, last_component (shell_prog), "-c",
|
||||
filter_command, (char *) NULL);
|
||||
error (EXIT_FAILURE, errno, _("failed to run command: \"%s -c %s\""),
|
||||
shell_prog, filter_command);
|
||||
}
|
||||
if (child_pid == -1)
|
||||
error (EXIT_FAILURE, errno, _("fork system call failed"));
|
||||
if (close (fd_pair[0]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("failed to close input pipe"));
|
||||
filter_pid = child_pid;
|
||||
if (n_open_pipes == open_pipes_alloc)
|
||||
open_pipes = x2nrealloc (open_pipes, &open_pipes_alloc,
|
||||
sizeof *open_pipes);
|
||||
open_pipes[n_open_pipes++] = fd_pair[1];
|
||||
return fd_pair[1];
|
||||
}
|
||||
}
|
||||
|
||||
/* Close the output file, and do any associated cleanup.
|
||||
If FP and FD are both specified, they refer to the same open file;
|
||||
in this case FP is closed, but FD is still used in cleanup. */
|
||||
static void
|
||||
closeout (FILE *fp, int fd, pid_t pid, char const *name)
|
||||
{
|
||||
if (fp != NULL && fclose (fp) != 0 && ! ignorable (errno))
|
||||
error (EXIT_FAILURE, errno, "%s", name);
|
||||
if (fd >= 0)
|
||||
{
|
||||
if (fp == NULL && close (fd) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", name);
|
||||
int j;
|
||||
for (j = 0; j < n_open_pipes; ++j)
|
||||
{
|
||||
if (open_pipes[j] == fd)
|
||||
{
|
||||
open_pipes[j] = open_pipes[--n_open_pipes];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pid > 0)
|
||||
{
|
||||
int wstatus = 0;
|
||||
if (waitpid (pid, &wstatus, 0) == -1 && errno != ECHILD)
|
||||
error (EXIT_FAILURE, errno, _("waiting for child process"));
|
||||
if (WIFSIGNALED (wstatus))
|
||||
{
|
||||
int sig = WTERMSIG (wstatus);
|
||||
if (sig != SIGPIPE)
|
||||
{
|
||||
char signame[MAX (SIG2STR_MAX, INT_BUFSIZE_BOUND (int))];
|
||||
if (sig2str (sig, signame) != 0)
|
||||
sprintf (signame, "%d", sig);
|
||||
error (sig + 128, 0,
|
||||
_("with FILE=%s, signal %s from command: %s"),
|
||||
name, signame, filter_command);
|
||||
}
|
||||
}
|
||||
else if (WIFEXITED (wstatus))
|
||||
{
|
||||
int ex = WEXITSTATUS (wstatus);
|
||||
if (ex != 0)
|
||||
error (ex, 0, _("with FILE=%s, exit %d from command: %s"),
|
||||
name, ex, filter_command);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* shouldn't happen. */
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("unknown status from command (0x%X)"), wstatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Write BYTES bytes at BP to an output file.
|
||||
@@ -273,13 +415,12 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
|
||||
{
|
||||
if (!bp && bytes == 0 && elide_empty_files)
|
||||
return;
|
||||
if (output_desc >= 0 && close (output_desc) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", outfile);
|
||||
closeout (NULL, output_desc, filter_pid, outfile);
|
||||
next_file_name ();
|
||||
if ((output_desc = create (outfile)) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", outfile);
|
||||
}
|
||||
if (full_write (output_desc, bp, bytes) != bytes)
|
||||
if (full_write (output_desc, bp, bytes) != bytes && ! ignorable (errno))
|
||||
error (EXIT_FAILURE, errno, "%s", outfile);
|
||||
}
|
||||
|
||||
@@ -322,6 +463,12 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize, uintmax_t max_files)
|
||||
cwrite (new_file_flag, bp_out, w);
|
||||
opened += new_file_flag;
|
||||
new_file_flag = !max_files || (opened < max_files);
|
||||
if (!new_file_flag && ignorable (errno))
|
||||
{
|
||||
/* If filter no longer accepting input, stop reading. */
|
||||
n_read = 0;
|
||||
break;
|
||||
}
|
||||
bp_out += w;
|
||||
to_read -= w;
|
||||
to_write = n_bytes;
|
||||
@@ -459,6 +606,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
off_t chunk_end = chunk_size - 1;
|
||||
off_t n_written = 0;
|
||||
bool new_file_flag = true;
|
||||
bool chunk_truncated = false;
|
||||
|
||||
if (k > 1)
|
||||
{
|
||||
@@ -480,6 +628,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
else if (n_read == 0)
|
||||
break; /* eof. */
|
||||
chunk_truncated = false;
|
||||
eob = buf + n_read;
|
||||
|
||||
while (bp != eob)
|
||||
@@ -504,7 +653,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
|
||||
error (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
}
|
||||
else
|
||||
else if (! k)
|
||||
cwrite (new_file_flag, bp, to_write);
|
||||
n_written += to_write;
|
||||
bp += to_write;
|
||||
@@ -516,7 +665,11 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
while (next || chunk_end <= n_written - 1)
|
||||
{
|
||||
if (!next && bp == eob)
|
||||
break; /* replenish buf, before going to next chunk. */
|
||||
{
|
||||
/* replenish buf, before going to next chunk. */
|
||||
chunk_truncated = true;
|
||||
break;
|
||||
}
|
||||
chunk_no++;
|
||||
if (k && chunk_no > k)
|
||||
return;
|
||||
@@ -525,13 +678,19 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
else
|
||||
chunk_end += chunk_size;
|
||||
if (chunk_end <= n_written - 1)
|
||||
cwrite (true, NULL, 0);
|
||||
{
|
||||
if (! k)
|
||||
cwrite (true, NULL, 0);
|
||||
}
|
||||
else
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (chunk_truncated)
|
||||
chunk_no++;
|
||||
|
||||
/* Ensure NUMBER files are created, which truncates
|
||||
any existing files or notifies any consumers on fifos.
|
||||
FIXME: Should we do this before EXIT_FAILURE? */
|
||||
@@ -564,7 +723,8 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
else if (n_read == 0)
|
||||
break; /* eof. */
|
||||
if (full_write (STDOUT_FILENO, buf, n_read) != n_read)
|
||||
if (full_write (STDOUT_FILENO, buf, n_read) != n_read
|
||||
&& ! ignorable (errno))
|
||||
error (EXIT_FAILURE, errno, "%s", quote ("-"));
|
||||
start += n_read;
|
||||
}
|
||||
@@ -574,7 +734,8 @@ typedef struct of_info
|
||||
{
|
||||
char *of_name;
|
||||
int ofd;
|
||||
FILE* ofile;
|
||||
FILE *ofile;
|
||||
int opid;
|
||||
} of_t;
|
||||
|
||||
enum
|
||||
@@ -615,10 +776,15 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
|
||||
In specialised cases the consumer can keep reading
|
||||
from the fifo, terminating on conditions in the data
|
||||
itself, or perhaps never in the case of `tail -f`.
|
||||
I.E. for fifos it is valid to attempt this reopen. */
|
||||
fd = open (files[i_check].of_name,
|
||||
O_WRONLY | O_BINARY | O_APPEND | O_NONBLOCK);
|
||||
}
|
||||
I.E. for fifos it is valid to attempt this reopen.
|
||||
|
||||
We don't handle the filter_command case here, as create()
|
||||
will exit if there are not enough files in that case.
|
||||
I.E. we don't support restarting filters, as that would
|
||||
put too much burden on users specifying --filter commands. */
|
||||
fd = open (files[i_check].of_name,
|
||||
O_WRONLY | O_BINARY | O_APPEND | O_NONBLOCK);
|
||||
}
|
||||
|
||||
if (-1 < fd)
|
||||
break;
|
||||
@@ -639,12 +805,15 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
|
||||
|
||||
if (fclose (files[i_reopen].ofile) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_reopen].of_name);
|
||||
files[i_reopen].ofile = NULL;
|
||||
files[i_reopen].ofd = OFD_APPEND;
|
||||
}
|
||||
|
||||
files[i_check].ofd = fd;
|
||||
if (!(files[i_check].ofile = fdopen (fd, "a")))
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
|
||||
files[i_check].opid = filter_pid;
|
||||
filter_pid = 0;
|
||||
}
|
||||
|
||||
return file_limit;
|
||||
@@ -658,6 +827,8 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
|
||||
static void
|
||||
lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
|
||||
{
|
||||
bool wrapped = false;
|
||||
bool wrote = false;
|
||||
bool file_limit;
|
||||
size_t i_file;
|
||||
of_t *files IF_LINT (= NULL);
|
||||
@@ -678,6 +849,7 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
|
||||
files[i_file].of_name = xstrdup (outfile);
|
||||
files[i_file].ofd = OFD_NEW;
|
||||
files[i_file].ofile = NULL;
|
||||
files[i_file].opid = 0;
|
||||
}
|
||||
i_file = 0;
|
||||
file_limit = false;
|
||||
@@ -734,34 +906,55 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
|
||||
{
|
||||
/* Note writing to fd, rather than flushing the FILE gives
|
||||
an 8% performance benefit, due to reduced data copying. */
|
||||
if (full_write (files[i_file].ofd, bp, to_write) != to_write)
|
||||
if (full_write (files[i_file].ofd, bp, to_write) != to_write
|
||||
&& ! ignorable (errno))
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
|
||||
}
|
||||
else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1)
|
||||
else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1
|
||||
&& ! ignorable (errno))
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
|
||||
if (! ignorable (errno))
|
||||
wrote = true;
|
||||
|
||||
if (file_limit)
|
||||
{
|
||||
if (fclose (files[i_file].ofile) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
|
||||
files[i_file].ofile = NULL;
|
||||
files[i_file].ofd = OFD_APPEND;
|
||||
}
|
||||
if (next && ++i_file == n)
|
||||
i_file = 0;
|
||||
{
|
||||
wrapped = true;
|
||||
/* If no filters are accepting input, stop reading. */
|
||||
if (! wrote)
|
||||
goto no_filters;
|
||||
wrote = false;
|
||||
i_file = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bp = bp_out;
|
||||
}
|
||||
}
|
||||
|
||||
no_filters:
|
||||
/* Ensure all files created, so that any existing files are truncated,
|
||||
and to signal any waiting fifo consumers.
|
||||
Also, close any open file descriptors.
|
||||
FIXME: Should we do this before EXIT_FAILURE? */
|
||||
for (i_file = 0; !k && !elide_empty_files && i_file < n; i_file++)
|
||||
if (!k)
|
||||
{
|
||||
file_limit |= ofile_open (files, i_file, n);
|
||||
if (fclose (files[i_file].ofile) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
|
||||
int ceiling = (wrapped ? n : i_file);
|
||||
for (i_file = 0; i_file < n; i_file++)
|
||||
{
|
||||
if (i_file >= ceiling && !elide_empty_files)
|
||||
file_limit |= ofile_open (files, i_file, n);
|
||||
if (files[i_file].ofd >= 0)
|
||||
closeout (files[i_file].ofile, files[i_file].ofd,
|
||||
files[i_file].opid, files[i_file].of_name);
|
||||
files[i_file].ofd = OFD_APPEND;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -779,9 +972,9 @@ static void
|
||||
parse_chunk (uintmax_t *k_units, uintmax_t *n_units, char *slash)
|
||||
{
|
||||
*slash = '\0';
|
||||
if (xstrtoumax (slash+1, NULL, 10, n_units, "") != LONGINT_OK
|
||||
if (xstrtoumax (slash + 1, NULL, 10, n_units, "") != LONGINT_OK
|
||||
|| *n_units == 0)
|
||||
error (EXIT_FAILURE, 0, _("%s: invalid number of chunks"), slash+1);
|
||||
error (EXIT_FAILURE, 0, _("%s: invalid number of chunks"), slash + 1);
|
||||
if (slash != optarg /* a leading number is specified. */
|
||||
&& (xstrtoumax (optarg, NULL, 10, k_units, "") != LONGINT_OK
|
||||
|| *k_units == 0 || *n_units < *k_units))
|
||||
@@ -824,7 +1017,8 @@ main (int argc, char **argv)
|
||||
int this_optind = optind ? optind : 1;
|
||||
char *slash;
|
||||
|
||||
c = getopt_long (argc, argv, "0123456789C:a:b:del:n:u", longopts, NULL);
|
||||
c = getopt_long (argc, argv, "0123456789C:a:b:del:n:u",
|
||||
longopts, NULL);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
@@ -955,6 +1149,10 @@ main (int argc, char **argv)
|
||||
elide_empty_files = true;
|
||||
break;
|
||||
|
||||
case FILTER_OPTION:
|
||||
filter_command = optarg;
|
||||
break;
|
||||
|
||||
case IO_BLKSIZE_OPTION:
|
||||
{
|
||||
uintmax_t tmp_blk_size;
|
||||
@@ -980,6 +1178,12 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (k_units != 0 && filter_command)
|
||||
{
|
||||
error (0, 0, _("--filter does not process a chunk extracted to stdout"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Handle default case. */
|
||||
if (split_type == type_undef)
|
||||
{
|
||||
@@ -1048,6 +1252,18 @@ main (int argc, char **argv)
|
||||
|
||||
buf = ptr_align (xmalloc (in_blk_size + 1 + page_size - 1), page_size);
|
||||
|
||||
/* When filtering, closure of one pipe must not terminate the process,
|
||||
as there may still be other streams expecting input from us. */
|
||||
if (filter_command)
|
||||
{
|
||||
struct sigaction act;
|
||||
sigemptyset (&newblocked);
|
||||
sigaction (SIGPIPE, NULL, &act);
|
||||
if (act.sa_handler != SIG_IGN)
|
||||
sigaddset (&newblocked, SIGPIPE);
|
||||
sigprocmask (SIG_BLOCK, &newblocked, &oldblocked);
|
||||
}
|
||||
|
||||
switch (split_type)
|
||||
{
|
||||
case type_digits:
|
||||
@@ -1086,8 +1302,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (close (STDIN_FILENO) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
if (output_desc >= 0 && close (output_desc) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", outfile);
|
||||
closeout (NULL, output_desc, filter_pid, outfile);
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
17
src/stat.c
17
src/stat.c
@@ -20,7 +20,7 @@
|
||||
|
||||
/* Keep this conditional in sync with the similar conditional in
|
||||
../m4/stat-prog.m4. */
|
||||
#if (STAT_STATVFS \
|
||||
#if ((STAT_STATVFS || STAT_STATVFS64) \
|
||||
&& (HAVE_STRUCT_STATVFS_F_BASETYPE || HAVE_STRUCT_STATVFS_F_FSTYPENAME \
|
||||
|| (! HAVE_STRUCT_STATFS_F_FSTYPENAME && HAVE_STRUCT_STATVFS_F_TYPE)))
|
||||
# define USE_STATVFS 1
|
||||
@@ -67,6 +67,7 @@
|
||||
#include "mountlist.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "stat-size.h"
|
||||
#include "stat-time.h"
|
||||
#include "strftime.h"
|
||||
#include "find-mount-point.h"
|
||||
@@ -79,7 +80,11 @@
|
||||
# if HAVE_STRUCT_STATVFS_F_NAMEMAX
|
||||
# define SB_F_NAMEMAX(S) ((S)->f_namemax)
|
||||
# endif
|
||||
# define STATFS statvfs
|
||||
# if ! STAT_STATVFS && STAT_STATVFS64
|
||||
# define STATFS statvfs64
|
||||
# else
|
||||
# define STATFS statvfs
|
||||
# endif
|
||||
# define STATFS_FRSIZE(S) ((S)->f_frsize)
|
||||
#else
|
||||
# define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATFS_F_TYPE
|
||||
@@ -288,6 +293,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
|
||||
return "futexfs";
|
||||
case S_MAGIC_GFS: /* 0x1161970 */
|
||||
return "gfs/gfs2";
|
||||
case S_MAGIC_GPFS: /* 0x47504653 */
|
||||
return "gpfs";
|
||||
case S_MAGIC_HFS: /* 0x4244 */
|
||||
return "hfs";
|
||||
case S_MAGIC_HPFS: /* 0xF995E849 */
|
||||
@@ -322,6 +329,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
|
||||
return "minix v2 (30 char.)";
|
||||
case S_MAGIC_MINIX_V3: /* 0x4D5A */
|
||||
return "minix3";
|
||||
case S_MAGIC_MQUEUE: /* 0x19800202 */
|
||||
return "mqueue";
|
||||
case S_MAGIC_MSDOS: /* 0x4D44 */
|
||||
return "msdos";
|
||||
case S_MAGIC_NCP: /* 0x564C */
|
||||
@@ -340,6 +349,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
|
||||
return "ocfs2";
|
||||
case S_MAGIC_PROC: /* 0x9FA0 */
|
||||
return "proc";
|
||||
case S_MAGIC_PSTOREFS: /* 0x6165676C */
|
||||
return "pstorefs";
|
||||
case S_MAGIC_QNX4: /* 0x002F */
|
||||
return "qnx4";
|
||||
case S_MAGIC_RAMFS: /* 0x858458F6 */
|
||||
@@ -944,7 +955,7 @@ print_stat (char *pformat, size_t prefix_len, unsigned int m,
|
||||
out_uint (pformat, prefix_len, ST_NBLOCKS (*statbuf));
|
||||
break;
|
||||
case 'o':
|
||||
out_uint (pformat, prefix_len, statbuf->st_blksize);
|
||||
out_uint (pformat, prefix_len, ST_BLKSIZE (*statbuf));
|
||||
break;
|
||||
case 'w':
|
||||
{
|
||||
|
||||
14
src/stdbuf.c
14
src/stdbuf.c
@@ -25,7 +25,6 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "posixver.h"
|
||||
#include "quote.h"
|
||||
#include "xreadlink.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -194,15 +193,14 @@ set_LD_PRELOAD (void)
|
||||
char *LD_PRELOAD;
|
||||
|
||||
/* Note this would auto add the appropriate search path for "libstdbuf.so":
|
||||
gcc stdbuf.c -Wl,-rpath,'$ORIGIN' -Wl,-rpath,$PKGLIBDIR
|
||||
gcc stdbuf.c -Wl,-rpath,'$ORIGIN' -Wl,-rpath,$PKGLIBEXECDIR
|
||||
However we want the lookup done for the exec'd command not stdbuf.
|
||||
|
||||
Since we don't link against libstdbuf.so add it to LIBDIR rather than
|
||||
LIBEXECDIR, as we'll search for it in the "sys default" case below. */
|
||||
Since we don't link against libstdbuf.so add it to PKGLIBEXECDIR
|
||||
rather than to LIBDIR. */
|
||||
char const *const search_path[] = {
|
||||
program_path,
|
||||
PKGLIBDIR,
|
||||
"", /* sys default */
|
||||
PKGLIBEXECDIR,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -257,7 +255,7 @@ set_LD_PRELOAD (void)
|
||||
static void
|
||||
set_libstdbuf_options (void)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_CARDINALITY (stdbuf); i++)
|
||||
{
|
||||
@@ -356,7 +354,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* Try to preload libstdbuf first from the same path as
|
||||
stdbuf is running from. */
|
||||
set_program_path (argv[0]);
|
||||
set_program_path (program_name);
|
||||
if (!program_path)
|
||||
program_path = xstrdup (PKGLIBDIR); /* Need to init to non NULL. */
|
||||
set_LD_PRELOAD ();
|
||||
|
||||
10
src/stty.c
10
src/stty.c
@@ -730,7 +730,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
/* Initialize to all zeroes so there is no risk memcmp will report a
|
||||
spurious difference in an uninitialized portion of the structure. */
|
||||
DECLARE_ZEROED_AGGREGATE (struct termios, mode);
|
||||
struct termios mode = { 0, };
|
||||
|
||||
enum output_type output_type;
|
||||
int optc;
|
||||
@@ -1003,7 +1003,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
/* Initialize to all zeroes so there is no risk memcmp will report a
|
||||
spurious difference in an uninitialized portion of the structure. */
|
||||
DECLARE_ZEROED_AGGREGATE (struct termios, new_mode);
|
||||
struct termios new_mode = { 0, };
|
||||
|
||||
if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode))
|
||||
error (EXIT_FAILURE, errno, "%s", device_name);
|
||||
@@ -1428,7 +1428,7 @@ screen_columns (void)
|
||||
}
|
||||
}
|
||||
|
||||
static tcflag_t *
|
||||
static tcflag_t * _GL_ATTRIBUTE_PURE
|
||||
mode_type_flag (enum mode_type type, struct termios *mode)
|
||||
{
|
||||
switch (type)
|
||||
@@ -1789,7 +1789,7 @@ static struct speed_map const speeds[] =
|
||||
{NULL, 0, 0}
|
||||
};
|
||||
|
||||
static speed_t
|
||||
static speed_t _GL_ATTRIBUTE_PURE
|
||||
string_to_baud (const char *arg)
|
||||
{
|
||||
int i;
|
||||
@@ -1800,7 +1800,7 @@ string_to_baud (const char *arg)
|
||||
return (speed_t) -1;
|
||||
}
|
||||
|
||||
static unsigned long int
|
||||
static unsigned long int _GL_ATTRIBUTE_PURE
|
||||
baud_to_value (speed_t speed)
|
||||
{
|
||||
int i;
|
||||
|
||||
144
src/system.h
144
src/system.h
@@ -40,11 +40,10 @@ you must include <sys/types.h> before including this file
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/* limits.h must come before pathmax.h because limits.h on some systems
|
||||
undefs PATH_MAX, whereas pathmax.h sets PATH_MAX. */
|
||||
#include <limits.h>
|
||||
|
||||
#include "pathmax.h"
|
||||
#ifndef PATH_MAX
|
||||
# define PATH_MAX 8192
|
||||
#endif
|
||||
|
||||
#include "configmake.h"
|
||||
|
||||
@@ -133,77 +132,6 @@ enum
|
||||
/* include here for SIZE_MAX. */
|
||||
#include <inttypes.h>
|
||||
|
||||
/* Get or fake the disk device blocksize.
|
||||
Usually defined by sys/param.h (if at all). */
|
||||
#if !defined DEV_BSIZE && defined BSIZE
|
||||
# define DEV_BSIZE BSIZE
|
||||
#endif
|
||||
#if !defined DEV_BSIZE && defined BBSIZE /* SGI */
|
||||
# define DEV_BSIZE BBSIZE
|
||||
#endif
|
||||
#ifndef DEV_BSIZE
|
||||
# define DEV_BSIZE 4096
|
||||
#endif
|
||||
|
||||
/* Extract or fake data from a `struct stat'.
|
||||
ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes.
|
||||
ST_NBLOCKS: Number of blocks in the file, including indirect blocks.
|
||||
ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS. */
|
||||
#ifndef HAVE_STRUCT_STAT_ST_BLOCKS
|
||||
# define ST_BLKSIZE(statbuf) DEV_BSIZE
|
||||
# if defined _POSIX_SOURCE || !defined BSIZE /* fileblocks.c uses BSIZE. */
|
||||
# define ST_NBLOCKS(statbuf) \
|
||||
((statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 0))
|
||||
# else /* !_POSIX_SOURCE && BSIZE */
|
||||
# define ST_NBLOCKS(statbuf) \
|
||||
(S_ISREG ((statbuf).st_mode) \
|
||||
|| S_ISDIR ((statbuf).st_mode) \
|
||||
? st_blocks ((statbuf).st_size) : 0)
|
||||
# endif /* !_POSIX_SOURCE && BSIZE */
|
||||
#else /* HAVE_STRUCT_STAT_ST_BLOCKS */
|
||||
/* Some systems, like Sequents, return st_blksize of 0 on pipes.
|
||||
Also, when running `rsh hpux11-system cat any-file', cat would
|
||||
determine that the output stream had an st_blksize of 2147421096.
|
||||
Conversely st_blksize can be 2 GiB (or maybe even larger) with XFS
|
||||
on 64-bit hosts. Somewhat arbitrarily, limit the `optimal' block
|
||||
size to SIZE_MAX / 8 + 1. (Dividing SIZE_MAX by only 4 wouldn't
|
||||
suffice, since "cat" sometimes multiplies the result by 4.) If
|
||||
anyone knows of a system for which this limit is too small, please
|
||||
report it as a bug in this code. */
|
||||
# define ST_BLKSIZE(statbuf) ((0 < (statbuf).st_blksize \
|
||||
&& (statbuf).st_blksize <= SIZE_MAX / 8 + 1) \
|
||||
? (statbuf).st_blksize : DEV_BSIZE)
|
||||
# if defined hpux || defined __hpux__ || defined __hpux
|
||||
/* HP-UX counts st_blocks in 1024-byte units.
|
||||
This loses when mixing HP-UX and BSD file systems with NFS. */
|
||||
# define ST_NBLOCKSIZE 1024
|
||||
# else /* !hpux */
|
||||
# if defined _AIX && defined _I386
|
||||
/* AIX PS/2 counts st_blocks in 4K units. */
|
||||
# define ST_NBLOCKSIZE (4 * 1024)
|
||||
# else /* not AIX PS/2 */
|
||||
# if defined _CRAY
|
||||
# define ST_NBLOCKS(statbuf) \
|
||||
(S_ISREG ((statbuf).st_mode) \
|
||||
|| S_ISDIR ((statbuf).st_mode) \
|
||||
? (statbuf).st_blocks * ST_BLKSIZE (statbuf) / ST_NBLOCKSIZE : 0)
|
||||
# endif /* _CRAY */
|
||||
# endif /* not AIX PS/2 */
|
||||
# endif /* !hpux */
|
||||
#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
|
||||
|
||||
#ifndef ST_NBLOCKS
|
||||
# define ST_NBLOCKS(statbuf) ((statbuf).st_blocks)
|
||||
#endif
|
||||
|
||||
#ifndef ST_NBLOCKSIZE
|
||||
# ifdef S_BLKSIZE
|
||||
# define ST_NBLOCKSIZE S_BLKSIZE
|
||||
# else
|
||||
# define ST_NBLOCKSIZE 512
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Redirection and wildcarding when done by the utility itself.
|
||||
Generally a noop, but used in particular for native VMS. */
|
||||
#ifndef initialize_main
|
||||
@@ -467,19 +395,6 @@ enum
|
||||
# define IF_LINT(Code) /* empty */
|
||||
#endif
|
||||
|
||||
/* With -Dlint, avoid warnings from gcc about code like mbstate_t m = {0,};
|
||||
by wasting space on a static variable of the same type, that is thus
|
||||
guaranteed to be initialized to 0, and use that on the RHS. */
|
||||
#define DZA_CONCAT0(x,y) x ## y
|
||||
#define DZA_CONCAT(x,y) DZA_CONCAT0 (x, y)
|
||||
#ifdef lint
|
||||
# define DECLARE_ZEROED_AGGREGATE(Type, Var) \
|
||||
static Type DZA_CONCAT (s0_, __LINE__); Type Var = DZA_CONCAT (s0_, __LINE__)
|
||||
#else
|
||||
# define DECLARE_ZEROED_AGGREGATE(Type, Var) \
|
||||
Type Var = { 0, }
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(x) /* empty */
|
||||
@@ -524,7 +439,7 @@ enum
|
||||
/* Compute the greatest common divisor of U and V using Euclid's
|
||||
algorithm. U and V must be nonzero. */
|
||||
|
||||
static inline size_t
|
||||
static inline size_t _GL_ATTRIBUTE_CONST
|
||||
gcd (size_t u, size_t v)
|
||||
{
|
||||
do
|
||||
@@ -542,7 +457,7 @@ gcd (size_t u, size_t v)
|
||||
nonzero. There is no overflow checking, so callers should not
|
||||
specify outlandish sizes. */
|
||||
|
||||
static inline size_t
|
||||
static inline size_t _GL_ATTRIBUTE_CONST
|
||||
lcm (size_t u, size_t v)
|
||||
{
|
||||
return u * (v / gcd (u, v));
|
||||
@@ -606,9 +521,7 @@ emit_ancillary_info (void)
|
||||
{
|
||||
printf (_("\nReport %s bugs to %s\n"), last_component (program_name),
|
||||
PACKAGE_BUGREPORT);
|
||||
/* FIXME 2010: use AC_PACKAGE_URL once we require autoconf-2.64 */
|
||||
printf (_("%s home page: <http://www.gnu.org/software/%s/>\n"),
|
||||
PACKAGE_NAME, PACKAGE);
|
||||
printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
|
||||
fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>\n"),
|
||||
stdout);
|
||||
/* Don't output this redundant message for English locales.
|
||||
@@ -644,51 +557,6 @@ bad_cast (char const *s)
|
||||
return (char *) s;
|
||||
}
|
||||
|
||||
/* As of Mar 2009, 32KiB is determined to be the minimium
|
||||
blksize to best minimize system call overhead.
|
||||
This can be tested with this script with the results
|
||||
shown for a 1.7GHz pentium-m with 2GB of 400MHz DDR2 RAM:
|
||||
|
||||
for i in $(seq 0 10); do
|
||||
size=$((8*1024**3)) #ensure this is big enough
|
||||
bs=$((1024*2**$i))
|
||||
printf "%7s=" $bs
|
||||
dd bs=$bs if=/dev/zero of=/dev/null count=$(($size/$bs)) 2>&1 |
|
||||
sed -n 's/.* \([0-9.]* [GM]B\/s\)/\1/p'
|
||||
done
|
||||
|
||||
1024=734 MB/s
|
||||
2048=1.3 GB/s
|
||||
4096=2.4 GB/s
|
||||
8192=3.5 GB/s
|
||||
16384=3.9 GB/s
|
||||
32768=5.2 GB/s
|
||||
65536=5.3 GB/s
|
||||
131072=5.5 GB/s
|
||||
262144=5.7 GB/s
|
||||
524288=5.7 GB/s
|
||||
1048576=5.8 GB/s
|
||||
|
||||
Note that this is to minimize system call overhead.
|
||||
Other values may be appropriate to minimize file system
|
||||
or disk overhead. For example on my current GNU/Linux system
|
||||
the readahead setting is 128KiB which was read using:
|
||||
|
||||
file="."
|
||||
device=$(df -P --local "$file" | tail -n1 | cut -d' ' -f1)
|
||||
echo $(( $(blockdev --getra $device) * 512 ))
|
||||
|
||||
However there isn't a portable way to get the above.
|
||||
In the future we could use the above method if available
|
||||
and default to io_blksize() if not.
|
||||
*/
|
||||
enum { IO_BUFSIZE = 32*1024 };
|
||||
static inline size_t
|
||||
io_blksize (struct stat sb)
|
||||
{
|
||||
return MAX (IO_BUFSIZE, ST_BLKSIZE (sb));
|
||||
}
|
||||
|
||||
void usage (int status) ATTRIBUTE_NORETURN;
|
||||
|
||||
#define emit_cycle_warning(file_name) \
|
||||
|
||||
@@ -215,7 +215,7 @@ tac_seekable (int input_fd, const char *file)
|
||||
size_t match_length1 = match_length - 1; /* Speed optimization, non-regexp. */
|
||||
|
||||
/* Find the size of the input file. */
|
||||
file_pos = lseek (input_fd, (off_t) 0, SEEK_END);
|
||||
file_pos = lseek (input_fd, 0, SEEK_END);
|
||||
if (file_pos < 1)
|
||||
return true; /* It's an empty file. */
|
||||
|
||||
@@ -546,7 +546,7 @@ tac_file (const char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
file_size = lseek (fd, (off_t) 0, SEEK_END);
|
||||
file_size = lseek (fd, 0, SEEK_END);
|
||||
|
||||
ok = (file_size < 0 || isatty (fd)
|
||||
? tac_nonseekable (fd, filename)
|
||||
|
||||
@@ -159,8 +159,8 @@ struct File_spec
|
||||
#if HAVE_INOTIFY
|
||||
/* The events mask used with inotify on files. This mask is not used on
|
||||
directories. */
|
||||
const uint32_t inotify_wd_mask = (IN_MODIFY | IN_ATTRIB | IN_DELETE_SELF
|
||||
| IN_MOVE_SELF);
|
||||
static const uint32_t inotify_wd_mask = (IN_MODIFY | IN_ATTRIB
|
||||
| IN_DELETE_SELF | IN_MOVE_SELF);
|
||||
#endif
|
||||
|
||||
/* Keep trying to open a file even if it is inaccessible when tail starts
|
||||
@@ -818,7 +818,7 @@ start_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes,
|
||||
error (0, errno, _("error reading %s"), quote (pretty_filename));
|
||||
return 1;
|
||||
}
|
||||
read_pos += bytes_read;
|
||||
*read_pos += bytes_read;
|
||||
if (bytes_read <= n_bytes)
|
||||
n_bytes -= bytes_read;
|
||||
else
|
||||
|
||||
206
src/timeout.c
206
src/timeout.c
@@ -35,7 +35,7 @@
|
||||
This can be seen with `timeout 10 dd&` for example.
|
||||
However if one brings this group to the foreground with the `fg`
|
||||
command before the timer expires, the command will remain
|
||||
in the sTop state as the shell doesn't send a SIGCONT
|
||||
in the stop state as the shell doesn't send a SIGCONT
|
||||
because the timeout process (group leader) is already running.
|
||||
To get the command running again one can Ctrl-Z, and do fg again.
|
||||
Note one can Ctrl-C the whole job when in this state.
|
||||
@@ -52,13 +52,24 @@
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "xstrtol.h"
|
||||
#include "c-strtod.h"
|
||||
#include "xstrtod.h"
|
||||
#include "sig2str.h"
|
||||
#include "operand2sig.h"
|
||||
#include "cloexec.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
#if HAVE_SETRLIMIT
|
||||
/* FreeBSD 5.0 at least needs <sys/types.h> and <sys/time.h> included
|
||||
before <sys/resource.h>. Currently "system.h" includes <sys/time.h>. */
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
/* NonStop circa 2011 lacks both SA_RESTART and siginterrupt. */
|
||||
#ifndef SA_RESTART
|
||||
# define SA_RESTART 0
|
||||
#endif
|
||||
|
||||
#define PROGRAM_NAME "timeout"
|
||||
|
||||
#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
|
||||
@@ -67,17 +78,69 @@ static int timed_out;
|
||||
static int term_signal = SIGTERM; /* same default as kill command. */
|
||||
static int monitored_pid;
|
||||
static int sigs_to_ignore[NSIG]; /* so monitor can ignore sigs it resends. */
|
||||
static unsigned long kill_after;
|
||||
static double kill_after;
|
||||
static bool foreground; /* whether to use another program group. */
|
||||
|
||||
/* for long options with no corresponding short option, use enum */
|
||||
enum
|
||||
{
|
||||
FOREGROUND_OPTION = CHAR_MAX + 1
|
||||
};
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"kill-after", required_argument, NULL, 'k'},
|
||||
{"signal", required_argument, NULL, 's'},
|
||||
{"foreground", no_argument, NULL, FOREGROUND_OPTION},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
/* Start the timeout after which we'll receive a SIGALRM.
|
||||
Round DURATION up to the next representable value.
|
||||
Treat out-of-range values as if they were maximal,
|
||||
as that's more useful in practice than reporting an error.
|
||||
'0' means don't timeout. */
|
||||
static void
|
||||
settimeout (double duration)
|
||||
{
|
||||
/* timer_settime() provides potentially nanosecond resolution.
|
||||
setitimer() is more portable (to Darwin for example),
|
||||
but only provides microsecond resolution and thus is
|
||||
a little more awkward to use with timespecs, as well as being
|
||||
deprecated by POSIX. Instead we fallback to single second
|
||||
resolution provided by alarm(). */
|
||||
|
||||
#if HAVE_TIMER_SETTIME
|
||||
struct timespec ts = dtotimespec (duration);
|
||||
struct itimerspec its = { {0, 0}, ts };
|
||||
timer_t timerid;
|
||||
if (timer_create (CLOCK_REALTIME, NULL, &timerid) == 0)
|
||||
{
|
||||
if (timer_settime (timerid, 0, &its, NULL) == 0)
|
||||
return;
|
||||
else
|
||||
{
|
||||
error (0, errno, _("warning: timer_settime"));
|
||||
timer_delete (timerid);
|
||||
}
|
||||
}
|
||||
else if (errno != ENOSYS)
|
||||
error (0, errno, _("warning: timer_create"));
|
||||
#endif
|
||||
|
||||
unsigned int timeint;
|
||||
if (UINT_MAX <= duration)
|
||||
timeint = UINT_MAX;
|
||||
else
|
||||
{
|
||||
unsigned int duration_floor = duration;
|
||||
timeint = duration_floor + (duration_floor < duration);
|
||||
}
|
||||
alarm (timeint);
|
||||
}
|
||||
|
||||
/* send sig to group but not ourselves.
|
||||
* FIXME: Is there a better way to achieve this? */
|
||||
static int
|
||||
@@ -106,12 +169,24 @@ cleanup (int sig)
|
||||
{
|
||||
/* Start a new timeout after which we'll send SIGKILL. */
|
||||
term_signal = SIGKILL;
|
||||
alarm (kill_after);
|
||||
settimeout (kill_after);
|
||||
kill_after = 0; /* Don't let later signals reset kill alarm. */
|
||||
}
|
||||
send_sig (0, sig);
|
||||
|
||||
/* Send the signal directly to the monitored child,
|
||||
in case it has itself become group leader,
|
||||
or is not running in a separate group. */
|
||||
send_sig (monitored_pid, sig);
|
||||
/* The normal case is the job has remained in our
|
||||
newly created process group, so send to all processes in that. */
|
||||
if (!foreground)
|
||||
send_sig (0, sig);
|
||||
if (sig != SIGKILL && sig != SIGCONT)
|
||||
send_sig (0, SIGCONT);
|
||||
{
|
||||
send_sig (monitored_pid, SIGCONT);
|
||||
if (!foreground)
|
||||
send_sig (0, SIGCONT);
|
||||
}
|
||||
}
|
||||
else /* we're the child or the child is not exec'd yet. */
|
||||
_exit (128 + sig);
|
||||
@@ -135,21 +210,25 @@ Start COMMAND, and kill it if still running after DURATION.\n\
|
||||
Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--foreground\n\
|
||||
When not running timeout directly from a shell prompt,\n\
|
||||
allow COMMAND to read from the TTY and receive TTY signals.\n\
|
||||
In this mode, children of COMMAND will not be timed out.\n\
|
||||
-k, --kill-after=DURATION\n\
|
||||
also send a KILL signal if COMMAND is still running\n\
|
||||
this long after the initial signal was sent.\n\
|
||||
also send a KILL signal if COMMAND is still running\n\
|
||||
this long after the initial signal was sent.\n\
|
||||
-s, --signal=SIGNAL\n\
|
||||
specify the signal to be sent on timeout.\n\
|
||||
SIGNAL may be a name like `HUP' or a number.\n\
|
||||
See `kill -l` for a list of signals\n"), stdout);
|
||||
specify the signal to be sent on timeout.\n\
|
||||
SIGNAL may be a name like `HUP' or a number.\n\
|
||||
See `kill -l` for a list of signals\n"), stdout);
|
||||
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
|
||||
fputs (_("\n\
|
||||
DURATION is an integer with an optional suffix:\n\
|
||||
`s' for seconds(the default), `m' for minutes, `h' for hours or `d' for days.\n\
|
||||
"), stdout);
|
||||
DURATION is a floating point number with an optional suffix:\n\
|
||||
`s' for seconds (the default), `m' for minutes, `h' for hours \
|
||||
or `d' for days.\n"), stdout);
|
||||
|
||||
fputs (_("\n\
|
||||
If the command times out, then exit with status 124. Otherwise, exit\n\
|
||||
@@ -162,54 +241,51 @@ use the KILL (9) signal, since this signal cannot be caught.\n"), stdout);
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* Given a long integer value *X, and a suffix character, SUFFIX_CHAR,
|
||||
/* Given a floating point value *X, and a suffix character, SUFFIX_CHAR,
|
||||
scale *X by the multiplier implied by SUFFIX_CHAR. SUFFIX_CHAR may
|
||||
be the NUL byte or `s' to denote seconds, `m' for minutes, `h' for
|
||||
hours, or `d' for days. If SUFFIX_CHAR is invalid, don't modify *X
|
||||
and return false. If *X would overflow an integer, don't modify *X
|
||||
and return false. Otherwise return true. */
|
||||
and return false. Otherwise return true. */
|
||||
|
||||
static bool
|
||||
apply_time_suffix (unsigned long *x, char suffix_char)
|
||||
apply_time_suffix (double *x, char suffix_char)
|
||||
{
|
||||
unsigned int multiplier = 1;
|
||||
int multiplier;
|
||||
|
||||
switch (suffix_char)
|
||||
{
|
||||
case 0:
|
||||
case 's':
|
||||
return true;
|
||||
case 'd':
|
||||
multiplier *= 24;
|
||||
case 'h':
|
||||
multiplier *= 60;
|
||||
multiplier = 1;
|
||||
break;
|
||||
case 'm':
|
||||
if (multiplier > UINT_MAX / 60) /* 16 bit overflow */
|
||||
return false;
|
||||
multiplier *= 60;
|
||||
multiplier = 60;
|
||||
break;
|
||||
case 'h':
|
||||
multiplier = 60 * 60;
|
||||
break;
|
||||
case 'd':
|
||||
multiplier = 60 * 60 * 24;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*x > UINT_MAX / multiplier)
|
||||
return false;
|
||||
|
||||
*x *= multiplier;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static double
|
||||
parse_duration (const char* str)
|
||||
{
|
||||
unsigned long duration;
|
||||
char *ep;
|
||||
double duration;
|
||||
const char *ep;
|
||||
|
||||
if (xstrtoul (str, &ep, 10, &duration, NULL)
|
||||
/* Invalid interval. Note 0 disables timeout */
|
||||
|| (duration > UINT_MAX)
|
||||
/* Extra chars after the number and an optional s,m,h,d char. */
|
||||
if (!xstrtod (str, &ep, &duration, c_strtod)
|
||||
/* Nonnegative interval. */
|
||||
|| ! (0 <= duration)
|
||||
/* No extra chars after the number and an optional s,m,h,d char. */
|
||||
|| (*ep && *(ep + 1))
|
||||
/* Check any suffix char and update timeout based on the suffix. */
|
||||
|| !apply_time_suffix (&duration, *ep))
|
||||
@@ -227,7 +303,8 @@ install_signal_handlers (int sigterm)
|
||||
struct sigaction sa;
|
||||
sigemptyset (&sa.sa_mask); /* Allow concurrent calls to handler */
|
||||
sa.sa_handler = cleanup;
|
||||
sa.sa_flags = SA_RESTART; /* restart syscalls (like wait() below) */
|
||||
sa.sa_flags = SA_RESTART; /* Restart syscalls if possible, as that's
|
||||
more likely to work cleanly. */
|
||||
|
||||
sigaction (SIGALRM, &sa, NULL); /* our timeout. */
|
||||
sigaction (SIGINT, &sa, NULL); /* Ctrl-C at terminal for example. */
|
||||
@@ -240,7 +317,7 @@ install_signal_handlers (int sigterm)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
unsigned long timeout;
|
||||
double timeout;
|
||||
char signame[SIG2STR_MAX];
|
||||
int c;
|
||||
|
||||
@@ -267,6 +344,10 @@ main (int argc, char **argv)
|
||||
usage (EXIT_CANCELED);
|
||||
break;
|
||||
|
||||
case FOREGROUND_OPTION:
|
||||
foreground = true;
|
||||
break;
|
||||
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
@@ -288,14 +369,15 @@ main (int argc, char **argv)
|
||||
Note we don't just put the child in a separate group as
|
||||
then we would need to worry about foreground and background groups
|
||||
and propagating signals between them. */
|
||||
setpgid (0, 0);
|
||||
if (!foreground)
|
||||
setpgid (0, 0);
|
||||
|
||||
/* Setup handlers before fork() so that we
|
||||
handle any signals caused by child, without races. */
|
||||
install_signal_handlers (term_signal);
|
||||
signal (SIGTTIN, SIG_IGN); /* don't sTop if background child needs tty. */
|
||||
signal (SIGTTOU, SIG_IGN); /* don't sTop if background child needs tty. */
|
||||
signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */
|
||||
signal (SIGTTIN, SIG_IGN); /* Don't stop if background child needs tty. */
|
||||
signal (SIGTTOU, SIG_IGN); /* Don't stop if background child needs tty. */
|
||||
signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */
|
||||
|
||||
monitored_pid = fork ();
|
||||
if (monitored_pid == -1)
|
||||
@@ -320,18 +402,16 @@ main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
pid_t wait_result;
|
||||
int status;
|
||||
|
||||
alarm (timeout);
|
||||
settimeout (timeout);
|
||||
|
||||
/* We're just waiting for a single process here, so wait() suffices.
|
||||
Note the signal() calls above on GNU/Linux and BSD at least,
|
||||
essentially call the lower level sigaction() with the SA_RESTART flag
|
||||
set, which ensures the following wait call will only return if the
|
||||
child exits, not on this process receiving a signal. Also we're not
|
||||
passing WUNTRACED | WCONTINUED to a waitpid() call and so will not get
|
||||
indication that the child has stopped or continued. */
|
||||
if (wait (&status) == -1)
|
||||
while ((wait_result = waitpid (monitored_pid, &status, 0)) < 0
|
||||
&& errno == EINTR)
|
||||
continue;
|
||||
|
||||
if (wait_result < 0)
|
||||
{
|
||||
/* shouldn't happen. */
|
||||
error (0, errno, _("error waiting for command"));
|
||||
@@ -342,7 +422,25 @@ main (int argc, char **argv)
|
||||
if (WIFEXITED (status))
|
||||
status = WEXITSTATUS (status);
|
||||
else if (WIFSIGNALED (status))
|
||||
status = WTERMSIG (status) + 128; /* what sh does at least. */
|
||||
{
|
||||
int sig = WTERMSIG (status);
|
||||
/* The following is not used as one cannot disable processing
|
||||
by a filter in /proc/sys/kernel/core_pattern on Linux. */
|
||||
#if 0 && HAVE_SETRLIMIT && defined RLIMIT_CORE
|
||||
if (!timed_out)
|
||||
{
|
||||
/* exit with the signal flag set, but avoid core files. */
|
||||
if (setrlimit (RLIMIT_CORE, &(struct rlimit) {0,0}) == 0)
|
||||
{
|
||||
signal (sig, SIG_DFL);
|
||||
raise (sig);
|
||||
}
|
||||
else
|
||||
error (0, errno, _("warning: disabling core dumps failed"));
|
||||
}
|
||||
#endif
|
||||
status = sig + 128; /* what sh returns for signaled processes. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* shouldn't happen. */
|
||||
|
||||
18
src/touch.c
18
src/touch.c
@@ -405,12 +405,18 @@ main (int argc, char **argv)
|
||||
if (! getenv ("POSIXLY_CORRECT"))
|
||||
{
|
||||
struct tm const *tm = localtime (&newtime[0].tv_sec);
|
||||
error (0, 0,
|
||||
_("warning: `touch %s' is obsolete; use "
|
||||
"`touch -t %04ld%02d%02d%02d%02d.%02d'"),
|
||||
argv[optind],
|
||||
tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
|
||||
/* Technically, it appears that even a deliberate attempt to cause
|
||||
the above localtime to return NULL will always fail because our
|
||||
posixtime implementation rejects all dates for which localtime
|
||||
would fail. However, skip the warning if it ever fails. */
|
||||
if (tm)
|
||||
error (0, 0,
|
||||
_("warning: `touch %s' is obsolete; use "
|
||||
"`touch -t %04ld%02d%02d%02d%02d.%02d'"),
|
||||
argv[optind],
|
||||
tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
}
|
||||
|
||||
optind++;
|
||||
|
||||
8
src/tr.c
8
src/tr.c
@@ -364,7 +364,7 @@ is_equiv_class_member (unsigned char equiv_class, unsigned char c)
|
||||
/* Return true if the character C is a member of the
|
||||
character class CHAR_CLASS. */
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
is_char_class_member (enum Char_class char_class, unsigned char c)
|
||||
{
|
||||
int result;
|
||||
@@ -542,7 +542,7 @@ unquote (char const *s, struct E_string *es)
|
||||
/* If CLASS_STR is a valid character class string, return its index
|
||||
in the global char_class_name array. Otherwise, return CC_NO_CLASS. */
|
||||
|
||||
static enum Char_class
|
||||
static enum Char_class _GL_ATTRIBUTE_PURE
|
||||
look_up_char_class (char const *class_str, size_t len)
|
||||
{
|
||||
enum Char_class i;
|
||||
@@ -844,7 +844,7 @@ find_bracketed_repeat (const struct E_string *es, size_t start_idx,
|
||||
expression `\*[0-9]*\]', false otherwise. The string does not
|
||||
match if any of its characters are escaped. */
|
||||
|
||||
static bool
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
star_digits_closebracket (const struct E_string *es, size_t idx)
|
||||
{
|
||||
size_t i;
|
||||
@@ -1555,7 +1555,7 @@ squeeze_filter (char *buf, size_t size, size_t (*reader) (char *, size_t))
|
||||
{
|
||||
/* A value distinct from any character that may have been stored in a
|
||||
buffer as the result of a block-read in the function squeeze_filter. */
|
||||
enum { NOT_A_CHAR = CHAR_MAX + 1 };
|
||||
const int NOT_A_CHAR = INT_MAX;
|
||||
|
||||
int char_to_squeeze = NOT_A_CHAR;
|
||||
size_t i = 0;
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "posixver.h"
|
||||
#include "quote.h"
|
||||
#include "stat-size.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
|
||||
@@ -379,13 +379,8 @@ unexpand (void)
|
||||
{
|
||||
column = next_tab_column;
|
||||
|
||||
/* Discard pending blanks, unless it was a single
|
||||
blank just before the previous tab stop. */
|
||||
if (! (pending == 1 && one_blank_before_tab_stop))
|
||||
{
|
||||
pending = 0;
|
||||
one_blank_before_tab_stop = false;
|
||||
}
|
||||
if (pending)
|
||||
pending_blank[0] = '\t';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -404,8 +399,11 @@ unexpand (void)
|
||||
|
||||
/* Replace the pending blanks by a tab or two. */
|
||||
pending_blank[0] = c = '\t';
|
||||
pending = one_blank_before_tab_stop;
|
||||
}
|
||||
|
||||
/* Discard pending blanks, unless it was a single
|
||||
blank just before the previous tab stop. */
|
||||
pending = one_blank_before_tab_stop;
|
||||
}
|
||||
}
|
||||
else if (c == '\b')
|
||||
@@ -425,6 +423,8 @@ unexpand (void)
|
||||
|
||||
if (pending)
|
||||
{
|
||||
if (pending > 1 && one_blank_before_tab_stop)
|
||||
pending_blank[0] = '\t';
|
||||
if (fwrite (pending_blank, 1, pending, stdout) != pending)
|
||||
error (EXIT_FAILURE, errno, _("write error"));
|
||||
pending = 0;
|
||||
|
||||
@@ -206,7 +206,7 @@ size_opt (char const *opt, char const *msgid)
|
||||
/* Given a linebuffer LINE,
|
||||
return a pointer to the beginning of the line's field to be compared. */
|
||||
|
||||
static char *
|
||||
static char * _GL_ATTRIBUTE_PURE
|
||||
find_field (struct linebuffer const *line)
|
||||
{
|
||||
size_t count;
|
||||
|
||||
10
src/wc.c
10
src/wc.c
@@ -120,6 +120,8 @@ Print newline, word, and byte counts for each FILE, and a total line if\n\
|
||||
more than one FILE is specified. With no FILE, or when FILE is -,\n\
|
||||
read standard input. A word is a non-zero-length sequence of characters\n\
|
||||
delimited by white space.\n\
|
||||
The options below may be used to select which counts are printed, always in\n\
|
||||
the following order: newline, word, character, byte, maximum line length.\n\
|
||||
-c, --bytes print the byte counts\n\
|
||||
-m, --chars print the character counts\n\
|
||||
-l, --lines print the newline counts\n\
|
||||
@@ -234,8 +236,8 @@ wc (int fd, char const *file_x, struct fstatus *fstatus)
|
||||
fstatus->failed = fstat (fd, &fstatus->st);
|
||||
|
||||
if (! fstatus->failed && S_ISREG (fstatus->st.st_mode)
|
||||
&& (current_pos = lseek (fd, (off_t) 0, SEEK_CUR)) != -1
|
||||
&& (end_pos = lseek (fd, (off_t) 0, SEEK_END)) != -1)
|
||||
&& (current_pos = lseek (fd, 0, SEEK_CUR)) != -1
|
||||
&& (end_pos = lseek (fd, 0, SEEK_END)) != -1)
|
||||
{
|
||||
/* Be careful here. The current position may actually be
|
||||
beyond the end of the file. As in the example above. */
|
||||
@@ -285,7 +287,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus)
|
||||
{
|
||||
bool in_word = false;
|
||||
uintmax_t linepos = 0;
|
||||
DECLARE_ZEROED_AGGREGATE (mbstate_t, state);
|
||||
mbstate_t state = { 0, };
|
||||
bool in_shift = false;
|
||||
# if SUPPORT_OLD_MBRTOWC
|
||||
/* Back-up the state before each multibyte character conversion and
|
||||
@@ -556,7 +558,7 @@ get_input_fstatus (int nfiles, char *const *file)
|
||||
recorded in FSTATUS. Optimize the same special case that
|
||||
get_input_fstatus optimizes. */
|
||||
|
||||
static int
|
||||
static int _GL_ATTRIBUTE_PURE
|
||||
compute_number_width (int nfiles, struct fstatus const *fstatus)
|
||||
{
|
||||
int width = 1;
|
||||
|
||||
@@ -84,9 +84,6 @@ main (int argc, char **argv)
|
||||
for (i = optind; i < argc; i++)
|
||||
if (fputs (argv[i], stdout) == EOF
|
||||
|| putchar (i == argc - 1 ? '\n' : ' ') == EOF)
|
||||
{
|
||||
error (0, errno, _("standard output"));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
error (EXIT_FAILURE, errno, _("standard output"));
|
||||
}
|
||||
}
|
||||
|
||||
39
tests/CuSkip.pm
Normal file
39
tests/CuSkip.pm
Normal file
@@ -0,0 +1,39 @@
|
||||
package CuSkip;
|
||||
# Skip a test: emit diag to log and to stderr, and exit 77
|
||||
|
||||
# Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our $ME = $0 || "<???>";
|
||||
|
||||
# Emit a diagnostic both to stderr and to $stderr_fileno_.
|
||||
# FIXME: don't hard-code that value (9), since it's already defined in init.cfg.
|
||||
sub skip ($)
|
||||
{
|
||||
my ($msg) = @_;
|
||||
my $stderr_fileno_ = 9;
|
||||
warn $msg;
|
||||
open FH, ">&$stderr_fileno_"
|
||||
or warn "$ME: failed to dup stderr\n";
|
||||
print FH $msg;
|
||||
close FH
|
||||
or warn "$ME: failed to close FD $stderr_fileno_\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -7,8 +7,10 @@ ASSORT = LC_ALL=C sort
|
||||
|
||||
EXTRA_DIST = \
|
||||
Coreutils.pm \
|
||||
CuSkip.pm \
|
||||
CuTmpdir.pm \
|
||||
check.mk \
|
||||
d_type-check \
|
||||
envvar-check \
|
||||
filefrag-extent-compare \
|
||||
fiemap-capable \
|
||||
@@ -16,8 +18,8 @@ EXTRA_DIST = \
|
||||
init.sh \
|
||||
lang-default \
|
||||
other-fs-tmpdir \
|
||||
require-perl \
|
||||
sample-test \
|
||||
shell-or-perl \
|
||||
$(pr_data)
|
||||
|
||||
root_tests = \
|
||||
@@ -132,6 +134,7 @@ TESTS = \
|
||||
rm/unread3 \
|
||||
rm/unreadable \
|
||||
rm/v-slash \
|
||||
rm/many-dir-entries-vs-OOM \
|
||||
chgrp/default-no-deref \
|
||||
chgrp/deref \
|
||||
chgrp/no-x \
|
||||
@@ -160,7 +163,6 @@ TESTS = \
|
||||
pr/pr-tests \
|
||||
misc/df-P \
|
||||
misc/pwd-option \
|
||||
misc/pwd-unreadable-parent \
|
||||
misc/chcon-fail \
|
||||
misc/cut \
|
||||
misc/wc \
|
||||
@@ -247,12 +249,13 @@ TESTS = \
|
||||
misc/sort-unique \
|
||||
misc/sort-unique-segv \
|
||||
misc/sort-version \
|
||||
misc/split-a \
|
||||
misc/split-bchunk \
|
||||
misc/split-fail \
|
||||
misc/split-l \
|
||||
misc/split-lchunk \
|
||||
misc/split-rchunk \
|
||||
split/filter \
|
||||
split/suffix-length \
|
||||
split/b-chunk \
|
||||
split/fail \
|
||||
split/lines \
|
||||
split/l-chunk \
|
||||
split/r-chunk \
|
||||
misc/stat-birthtime \
|
||||
misc/stat-fmt \
|
||||
misc/stat-hyphen \
|
||||
@@ -274,6 +277,7 @@ TESTS = \
|
||||
misc/tee-dash \
|
||||
misc/test-diag \
|
||||
misc/timeout \
|
||||
misc/timeout-group \
|
||||
misc/timeout-parameters \
|
||||
misc/tr \
|
||||
misc/tr-case-class \
|
||||
@@ -319,6 +323,7 @@ TESTS = \
|
||||
cp/dir-rm-dest \
|
||||
cp/dir-slash \
|
||||
cp/dir-vs-file \
|
||||
cp/existing-perm-dir \
|
||||
cp/existing-perm-race \
|
||||
cp/fail-perm \
|
||||
cp/fiemap-empty \
|
||||
@@ -337,6 +342,7 @@ TESTS = \
|
||||
cp/parent-perm-race \
|
||||
cp/perm \
|
||||
cp/preserve-2 \
|
||||
cp/preserve-link \
|
||||
cp/preserve-slink-time \
|
||||
cp/proc-short-read \
|
||||
cp/proc-zero-len \
|
||||
@@ -425,6 +431,7 @@ TESTS = \
|
||||
ls/rt-1 \
|
||||
ls/stat-dtype \
|
||||
ls/stat-failed \
|
||||
ls/stat-free-color \
|
||||
ls/stat-free-symlinks \
|
||||
ls/stat-vs-dirent \
|
||||
ls/symlink-slash \
|
||||
|
||||
@@ -48,6 +48,16 @@ check-am: .built-programs
|
||||
&& MAKEFLAGS= $(MAKE) -s built_programs.list) \
|
||||
> $@-t && mv $@-t $@
|
||||
|
||||
## `$f' is set by the Automake-generated test harness to the path of the
|
||||
## current test script stripped of VPATH components, and is used by the
|
||||
## shell-or-perl script to determine the name of the temporary files to be
|
||||
## used. Note that $f is a shell variable, not a make macro, so the use of
|
||||
## `$$f' below is correct, and not a typo.
|
||||
LOG_COMPILER = \
|
||||
$(SHELL) $(srcdir)/shell-or-perl \
|
||||
--test-name "$$f" --srcdir '$(srcdir)' \
|
||||
--shell '$(SHELL)' --perl '$(PERL)' --
|
||||
|
||||
# Note that the first lines are statements. They ensure that environment
|
||||
# variables that can perturb tests are unset or set to expected values.
|
||||
# The rest are envvar settings that propagate build-related Makefile
|
||||
@@ -58,22 +68,6 @@ TESTS_ENVIRONMENT = \
|
||||
test -d "$$tmp__" && test -w "$$tmp__" || tmp__=.; \
|
||||
. $(srcdir)/envvar-check; \
|
||||
TMPDIR=$$tmp__; export TMPDIR; \
|
||||
exec 9>&2; \
|
||||
shell_or_perl_() { \
|
||||
if grep '^\#!/usr/bin/perl' "$$1" > /dev/null; then \
|
||||
if $(PERL) -e 'use warnings' > /dev/null 2>&1; then \
|
||||
grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=T || T_=; \
|
||||
$(PERL) -w$$T_ -I$(srcdir) -MCoreutils \
|
||||
-M"CuTmpdir qw($$f)" -- "$$1"; \
|
||||
else \
|
||||
echo 1>&2 "$$tst: configure did not find a usable version of Perl," \
|
||||
"so skipping this test"; \
|
||||
(exit 77); \
|
||||
fi; \
|
||||
else \
|
||||
$(SHELL) "$$1"; \
|
||||
fi; \
|
||||
}; \
|
||||
export \
|
||||
VERSION='$(VERSION)' \
|
||||
LOCALE_FR='$(LOCALE_FR)' \
|
||||
@@ -100,6 +94,6 @@ TESTS_ENVIRONMENT = \
|
||||
REPLACE_GETCWD=$(REPLACE_GETCWD) \
|
||||
; test -d /usr/xpg4/bin && PATH='/usr/xpg4/bin$(PATH_SEPARATOR)'"$$PATH"; \
|
||||
PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
|
||||
; shell_or_perl_
|
||||
; 9>&2
|
||||
|
||||
VERBOSE = yes
|
||||
|
||||
@@ -23,7 +23,7 @@ require_membership_in_two_groups_
|
||||
set _ $groups; shift
|
||||
g2=$2
|
||||
|
||||
mkdir d && touch f && ln -s ../f d/s || framework_failure
|
||||
mkdir d && touch f && ln -s ../f d/s || framework_failure_
|
||||
|
||||
|
||||
g_init=`stat --printf=%g f`
|
||||
|
||||
@@ -31,7 +31,7 @@ chgrp -h $g2 symlink 2> /dev/null
|
||||
set _ `ls -ln symlink`
|
||||
g=$5
|
||||
test "$g" = $g2 ||
|
||||
skip_test_ "your system doesn't support changing the owner or group" \
|
||||
skip_ "your system doesn't support changing the owner or group" \
|
||||
"of a symbolic link."
|
||||
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ set _ $groups; shift
|
||||
g1=$1
|
||||
g2=$2
|
||||
|
||||
mkdir -p d/no-x/y || framework_failure
|
||||
chmod u=rw d/no-x || framework_failure
|
||||
mkdir -p d/no-x/y || framework_failure_
|
||||
chmod u=rw d/no-x || framework_failure_
|
||||
|
||||
|
||||
# This must exit nonzero.
|
||||
|
||||
@@ -24,11 +24,11 @@ set _ $groups; shift
|
||||
g1=$1
|
||||
g2=$2
|
||||
|
||||
mkdir 1 2 3 || framework_failure
|
||||
touch 1/1F 2/2F 3/3F || framework_failure
|
||||
ln -s 1 1s || framework_failure
|
||||
ln -s ../3 2/2s || framework_failure
|
||||
chgrp -R $g1 1 2 3 || framework_failure
|
||||
mkdir 1 2 3 || framework_failure_
|
||||
touch 1/1F 2/2F 3/3F || framework_failure_
|
||||
ln -s 1 1s || framework_failure_
|
||||
ln -s ../3 2/2s || framework_failure_
|
||||
chgrp -R $g1 1 2 3 || framework_failure_
|
||||
|
||||
|
||||
chgrp --preserve-root -H -R $g2 1s 2 || fail=1
|
||||
|
||||
@@ -21,8 +21,8 @@ print_ver_ chmod
|
||||
|
||||
umask 0
|
||||
file=f
|
||||
touch $file || framework_failure
|
||||
chmod 444 $file || framework_failure
|
||||
touch $file || framework_failure_
|
||||
chmod 444 $file || framework_failure_
|
||||
|
||||
skip_if_setgid_
|
||||
|
||||
@@ -33,8 +33,8 @@ chmod -c g=rwx $file > empty || fail=1
|
||||
|
||||
test -s empty && fail=1
|
||||
case "`cat out`" in
|
||||
"mode of \`f' changed to 0774 "?rwxrwxr--?) ;;
|
||||
*) fail=1 ;;
|
||||
"mode of \`f' changed from 0744 "?rwxr--r--?" to 0774 "?rwxrwxr--?) ;;
|
||||
*) cat out; fail=1 ;;
|
||||
esac
|
||||
|
||||
Exit $fail
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
print_ver_ chmod
|
||||
|
||||
file=f
|
||||
touch $file || framework_failure
|
||||
touch $file || framework_failure_
|
||||
|
||||
umask 005
|
||||
for mode in =x =xX =Xx =x,=X =X,=x; do
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
touch f || framework_failure
|
||||
touch f || framework_failure_
|
||||
|
||||
|
||||
expected_u=-rwx------
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
mkdir -p d/e || framework_failure
|
||||
chmod 0 d/e d || framework_failure
|
||||
mkdir -p d/e || framework_failure_
|
||||
chmod 0 d/e d || framework_failure_
|
||||
|
||||
|
||||
chmod u+rwx d d/e || fail=1
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user