mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
120 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
518b92a5e3 | ||
|
|
b795e60844 | ||
|
|
887d530e62 | ||
|
|
51f60a6237 | ||
|
|
056caf4857 | ||
|
|
a300cfd43c | ||
|
|
7ca55ef3d1 | ||
|
|
960fc61624 | ||
|
|
41159f9604 | ||
|
|
4a423bedea | ||
|
|
5947491895 | ||
|
|
0eaa993ae6 | ||
|
|
e66948c3b5 | ||
|
|
0e181024c0 | ||
|
|
eea8e7530b | ||
|
|
6d488ca041 | ||
|
|
c67a96c4c1 | ||
|
|
561f8be2c9 | ||
|
|
8e81a99c26 | ||
|
|
1b31ce6982 | ||
|
|
f3c584d1e0 | ||
|
|
33a5de5a0e | ||
|
|
14ad7a2550 | ||
|
|
8f40ed634c | ||
|
|
dcb3f60d0a | ||
|
|
0da4d84300 | ||
|
|
6d36bd4c64 | ||
|
|
0c70708db7 | ||
|
|
8351407f87 | ||
|
|
b212633c41 | ||
|
|
45ff91af2e | ||
|
|
ad61335bf8 | ||
|
|
9a9d69e9e4 | ||
|
|
27e997d0eb | ||
|
|
c9db0ac6de | ||
|
|
d1f7003556 | ||
|
|
621876ff44 | ||
|
|
195c455d0a | ||
|
|
a1629ba1ec | ||
|
|
231d8719f1 | ||
|
|
cd00fa6ee1 | ||
|
|
fb282c7b30 | ||
|
|
fb41e82c77 | ||
|
|
f2d977aff1 | ||
|
|
6f4279421d | ||
|
|
f35f4b3396 | ||
|
|
eb989f4b75 | ||
|
|
b6ef652e50 | ||
|
|
b5a25a996d | ||
|
|
038fcfcf1b | ||
|
|
0ec869e8be | ||
|
|
a5207bb139 | ||
|
|
3afda5f007 | ||
|
|
43d1112d01 | ||
|
|
fbb47bf424 | ||
|
|
b8cd747cc8 | ||
|
|
67f7ed3e3a | ||
|
|
013d95af11 | ||
|
|
be107398e5 | ||
|
|
dadca988af | ||
|
|
c2bdd17856 | ||
|
|
a71c22fdf0 | ||
|
|
cf90729e09 | ||
|
|
c1b41c5c3b | ||
|
|
ae5cfc9f12 | ||
|
|
8f9be76b0d | ||
|
|
a8c8484ee1 | ||
|
|
293c37b906 | ||
|
|
5c0275e953 | ||
|
|
11d3389f5a | ||
|
|
fbcc100f5b | ||
|
|
ff7f0ff85c | ||
|
|
f38becab02 | ||
|
|
30b74dfff1 | ||
|
|
01a27b9054 | ||
|
|
79adacc431 | ||
|
|
9ad13ad14a | ||
|
|
c8d570c2b3 | ||
|
|
0d1ba34494 | ||
|
|
f9cfda6ad2 | ||
|
|
b19733bb42 | ||
|
|
f70c7b785b | ||
|
|
ee6f187b18 | ||
|
|
e143ba52c4 | ||
|
|
d2e0f3602e | ||
|
|
2d5b3329a2 | ||
|
|
ff5fc553f9 | ||
|
|
4a8e9bf14c | ||
|
|
6568b173db | ||
|
|
0339eb4598 | ||
|
|
7727908335 | ||
|
|
0cfd4f2161 | ||
|
|
425503c807 | ||
|
|
4a14a80bd1 | ||
|
|
dd45755406 | ||
|
|
ca9aa75960 | ||
|
|
6c058b2dab | ||
|
|
3261914da1 | ||
|
|
c7375c236c | ||
|
|
312549b627 | ||
|
|
7b4e77352d | ||
|
|
1369fe9284 | ||
|
|
db42ae787d | ||
|
|
272f8bf0ac | ||
|
|
30e207fa46 | ||
|
|
883ac22239 | ||
|
|
0d792d061e | ||
|
|
3e1905baf4 | ||
|
|
7930367a34 | ||
|
|
c84ddbaa33 | ||
|
|
7d93a082b6 | ||
|
|
d5d82ecf3b | ||
|
|
10a0bdfa98 | ||
|
|
407806b27f | ||
|
|
3c7112104d | ||
|
|
840e8c9cfb | ||
|
|
b1b23d894b | ||
|
|
766ec503f7 | ||
|
|
9c589e694f | ||
|
|
6728401351 |
140
.gitignore
vendored
140
.gitignore
vendored
@@ -7,79 +7,77 @@
|
||||
._bootmp
|
||||
.gdb-history
|
||||
.kludge-stamp
|
||||
.tarball-version
|
||||
.version
|
||||
ABOUT-NLS
|
||||
ChangeLog
|
||||
GNUmakefile
|
||||
/ABOUT-NLS
|
||||
/ChangeLog
|
||||
/GNUmakefile
|
||||
/INSTALL
|
||||
/THANKS-to-translators
|
||||
/aclocal.m4
|
||||
/autom4te.cache
|
||||
/build-aux/.gitignore
|
||||
/build-aux/compile
|
||||
/build-aux/config.guess
|
||||
/build-aux/config.sub
|
||||
/build-aux/depcomp
|
||||
/build-aux/install-sh
|
||||
/build-aux/mdate-sh
|
||||
/build-aux/missing
|
||||
/build-aux/texinfo.tex
|
||||
/build-aux/ylwrap
|
||||
/config.cache
|
||||
/config.log
|
||||
/config.status
|
||||
/configure
|
||||
/coreutils-*.tar.gz
|
||||
/coreutils-*.tar.gz.sig
|
||||
/coreutils-*.tar.xz
|
||||
/coreutils-*.tar.xz.sig
|
||||
/gnulib-tests
|
||||
/lib/.cvsignore
|
||||
/lib/.gitignore
|
||||
/lib/arg-nonnull.h
|
||||
/lib/arpa
|
||||
/lib/binary-io.h
|
||||
/lib/c++defs.h
|
||||
/lib/charset.alias
|
||||
/lib/config.h
|
||||
/lib/config.hin
|
||||
/lib/configmake.h
|
||||
/lib/glthread
|
||||
/lib/libcoreutils.a
|
||||
/lib/link-warning.h
|
||||
/lib/printf.c
|
||||
/lib/progname.c
|
||||
/lib/progname.h
|
||||
/lib/selinux
|
||||
/lib/stamp-h1
|
||||
/lib/unistr
|
||||
/lib/uniwidth
|
||||
/lib/unused-parameter.h
|
||||
/lib/warn-on-use.h
|
||||
/m4/.cvsignore
|
||||
/m4/.gitignore
|
||||
/maint.mk
|
||||
/man/*.1
|
||||
/po/*.gmo
|
||||
/po/*.po
|
||||
/po/.gitignore
|
||||
/po/.reference
|
||||
/po/LINGUAS
|
||||
/po/Makefile.in
|
||||
/po/Makevars
|
||||
/po/POTFILES
|
||||
/po/checksums
|
||||
/po/coreutils.pot
|
||||
/po/stamp-po
|
||||
/src/version.c
|
||||
/src/version.h
|
||||
/stamp-h1
|
||||
/tests/*/*.log
|
||||
/tests/t?
|
||||
/tests/test-suite.log
|
||||
ID
|
||||
INSTALL
|
||||
Makefile
|
||||
Makefile.in
|
||||
TAGS
|
||||
THANKS-to-translators
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
build-aux/.gitignore
|
||||
build-aux/compile
|
||||
build-aux/config.guess
|
||||
build-aux/config.sub
|
||||
build-aux/depcomp
|
||||
build-aux/install-sh
|
||||
build-aux/mdate-sh
|
||||
build-aux/missing
|
||||
build-aux/texinfo.tex
|
||||
build-aux/ylwrap
|
||||
config.cache
|
||||
config.h
|
||||
config.hin
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
coreutils-*.tar.bz2
|
||||
coreutils-*.tar.bz2.sig
|
||||
coreutils-*.tar.gz
|
||||
coreutils-*.tar.gz.sig
|
||||
coreutils-*.tar.xz
|
||||
coreutils-*.tar.xz.sig
|
||||
gnulib-tests
|
||||
lib/.cvsignore
|
||||
lib/.gitignore
|
||||
lib/arg-nonnull.h
|
||||
lib/arpa
|
||||
lib/binary-io.h
|
||||
lib/c++defs.h
|
||||
lib/charset.alias
|
||||
lib/configmake.h
|
||||
lib/glthread
|
||||
lib/libcoreutils.a
|
||||
lib/link-warning.h
|
||||
lib/printf.c
|
||||
lib/progname.c
|
||||
lib/progname.h
|
||||
lib/selinux
|
||||
lib/unistr
|
||||
lib/uniwidth
|
||||
lib/unused-parameter.h
|
||||
lib/warn-on-use.h
|
||||
m4/.cvsignore
|
||||
m4/.gitignore
|
||||
maint.mk
|
||||
man/*.1
|
||||
po/*.gmo
|
||||
po/*.po
|
||||
po/.gitignore
|
||||
po/.reference
|
||||
po/LINGUAS
|
||||
po/Makefile.in
|
||||
po/Makevars
|
||||
po/POTFILES
|
||||
po/checksums
|
||||
po/coreutils.pot
|
||||
po/stamp-po
|
||||
src/version.c
|
||||
src/version.h
|
||||
stamp-h1
|
||||
tests/*/*.log
|
||||
tests/t?
|
||||
tests/test-suite.log
|
||||
|
||||
2
.mailmap
2
.mailmap
@@ -8,3 +8,5 @@ Paul R. Eggert <eggert@cs.ucla.edu> <eggert@CS.UCLA.EDU>
|
||||
Evan Hunt <ethanol@armory.com> Evan Hunt <jim@meyering.net>
|
||||
<P@draigBrady.com> <P@draigBrady.com (trivial change)>
|
||||
Pádraig Brady <p@draigbrady.com> <p@draigBrady.com>
|
||||
<chen.guo.0625@gmail.com> <chenguo4@yahoo.com>
|
||||
<chen.guo.0625@gmail.com> <chenguo4@ucla.edu>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.5
|
||||
8.7
|
||||
|
||||
7
.x-sc_bindtextdomain
Normal file
7
.x-sc_bindtextdomain
Normal file
@@ -0,0 +1,7 @@
|
||||
^gl/lib/randint\.c$
|
||||
^gl/tests/test-di-set\.c$
|
||||
^gl/tests/test-fadvise\.c$
|
||||
^gl/tests/test-ino-map\.c$
|
||||
^gl/tests/test-mbsalign\.c$
|
||||
^gl/tests/test-rand-isaac\.c$
|
||||
^lib/euidaccess-stat\.c$
|
||||
@@ -41,6 +41,7 @@ changelog_etc = \
|
||||
|
||||
syntax_check_exceptions = \
|
||||
.x-sc_GPL_version \
|
||||
.x-sc_bindtextdomain \
|
||||
.x-sc_error_message_uppercase \
|
||||
.x-sc_file_system \
|
||||
.x-sc_obsolete_symbols \
|
||||
|
||||
71
NEWS
71
NEWS
@@ -1,5 +1,76 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 8.8 (2010-12-22) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
cp -u no longer does unnecessary copying merely because the source
|
||||
has finer-grained time stamps than the destination.
|
||||
|
||||
od now prints floating-point numbers without losing information, and
|
||||
it no longer omits spaces between floating-point columns in some cases.
|
||||
|
||||
sort -u with at least two threads could attempt to read through a
|
||||
corrupted pointer. [bug introduced in coreutils-8.6]
|
||||
|
||||
sort with at least two threads and with blocked output would busy-loop
|
||||
(spinlock) all threads, often using 100% of available CPU cycles to
|
||||
do no work. I.e., "sort < big-file | less" could waste a lot of power.
|
||||
[bug introduced in coreutils-8.6]
|
||||
|
||||
sort with at least two threads no longer segfaults due to use of pointers
|
||||
into the stack of an expired thread. [bug introduced in coreutils-8.6]
|
||||
|
||||
sort --compress no longer mishandles subprocesses' exit statuses,
|
||||
no longer hangs indefinitely due to a bug in waiting for subprocesses,
|
||||
and no longer generates many more than NMERGE subprocesses.
|
||||
|
||||
sort -m -o f f ... f no longer dumps core when file descriptors are limited.
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
sort will not create more than 8 threads by default due to diminishing
|
||||
performance gains. Also the --parallel option is no longer restricted
|
||||
to the number of available processors.
|
||||
|
||||
** New features
|
||||
|
||||
split accepts the --number option to generate a specific number of files.
|
||||
|
||||
|
||||
* Noteworthy changes in release 8.7 (2010-11-13) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
cp, install, mv, and touch no longer crash when setting file times
|
||||
on Solaris 10 Update 9 [Solaris PatchID 144488 and newer expose a
|
||||
latent bug introduced in coreutils 8.1, and possibly a second latent
|
||||
bug going at least as far back as coreutils 5.97]
|
||||
|
||||
csplit no longer corrupts heap when writing more than 999 files,
|
||||
nor does it leak memory for every chunk of input processed
|
||||
[the bugs were present in the initial implementation]
|
||||
|
||||
tail -F once again notices changes in a currently unavailable
|
||||
remote directory [bug introduced in coreutils-7.5]
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
cp --attributes-only now completely overrides --reflink.
|
||||
Previously a reflink was needlessly attempted.
|
||||
|
||||
stat's %X, %Y, and %Z directives once again print only the integer
|
||||
part of seconds since the epoch. This reverts a change from
|
||||
coreutils-8.6, that was deemed unnecessarily disruptive.
|
||||
To obtain a nanosecond-precision time stamp for %X use %.X;
|
||||
if you want (say) just 3 fractional digits, use %.3X.
|
||||
Likewise for %Y and %Z.
|
||||
|
||||
stat's new %W format directive would print floating point seconds.
|
||||
However, with the above change to %X, %Y and %Z, we've made %W work
|
||||
the same way as the others.
|
||||
|
||||
|
||||
* Noteworthy changes in release 8.6 (2010-10-15) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
@@ -16,26 +16,34 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
# Convert Makefile.am files:
|
||||
# find tests -name Makefile.am | xargs grep -wl PATH|xargs perl -pi -e \
|
||||
# 's,src(\$\(PATH_SEPARATOR\)\$\$PATH),src/vg$1,'
|
||||
# find tests -name check.mk | xargs grep -wl PATH |
|
||||
# xargs perl -pi -e 's,src(\$\(PATH_SEPARATOR\)),src/vg$1,'
|
||||
# To restore:
|
||||
# find tests -name Makefile.am|xargs grep -wl PATH|xargs perl -pi -e 's,src/vg,src,'
|
||||
# find tests -name check.mk | xargs grep -wl PATH |
|
||||
# xargs perl -pi -e 's,src/vg,src,'
|
||||
#
|
||||
# Create this symlink for suppressions (this is no longer necessary,
|
||||
# with Linux kernel 2.6.9 and valgrind-2.2.0):
|
||||
# ln -s $PWD/.vg-suppressions /tmp/cu-vg
|
||||
|
||||
|
||||
# Create src/vg:
|
||||
|
||||
coreutils=$(echo 'spy:;@echo $(all_programs)' | (cd src; make -f Makefile -f - spy | tr -s '\n ' ' '))
|
||||
coreutils=$(echo 'spy:;@echo $(all_programs) $(noinst_PROGRAMS)' |
|
||||
(cd src; make -f Makefile -f - spy | tr -s '\n ' ' '))
|
||||
mkdir -p src/vg
|
||||
pwd=`pwd`
|
||||
srcdir=$pwd/src
|
||||
_path='export PATH='$srcdir':${PATH#*:}'
|
||||
pre='#!/bin/sh\n'"$_path"'\n'
|
||||
n=15
|
||||
vg='exec /usr/bin/valgrind --suppressions=/tmp/cu-vg --log-fd=3 --leak-check=yes --track-fds=yes --leak-check=full --num-callers='$n
|
||||
n=15 # stack trace depth
|
||||
log_fd=3 # One can redirect this to file like 3>vg.log
|
||||
test -e /tmp/cu-vg && suppressions='--supressions=/tmp/cu-vg'
|
||||
vg="exec /usr/bin/valgrind $suppressions --log-fd=$log_fd \
|
||||
--leak-check=yes --track-fds=yes --leak-check=full --num-callers=$n"
|
||||
cat <<EOF > src/vg/gen
|
||||
for i in $coreutils; do
|
||||
printf "$pre$vg -- \$i"' "\$@"\n' > \$i
|
||||
|
||||
4
THANKS
4
THANKS
@@ -62,6 +62,7 @@ Arnold Robbins arnold@skeeve.com
|
||||
Arthur Pool pool@commerce.uq.edu.au
|
||||
Arun Sharma arun.sharma@intel.com
|
||||
Arvind Autar Autar022@planet.nl
|
||||
Assaf Gordon assafgordon@gmail.com
|
||||
Augey Mikus mikus@dqc.org
|
||||
Aurelien Jarno aurel32@debian.org
|
||||
Austin Donnelly Austin.Donnelly@cl.cam.ac.uk
|
||||
@@ -105,6 +106,7 @@ Carlos Canau Carlos.Canau@relay.puug.pt
|
||||
Charles Karney karney@pppl.gov
|
||||
Charles Randall crandall@matchlogic.com
|
||||
Chas. Owens chas.owens@gmail.com
|
||||
Chen Guo chen.guo.0625@gmail.com
|
||||
Chip Salzenberg chip@valinux.com
|
||||
Chris Clayton chris2553@googlemail.com
|
||||
Chris Faylor cgf@cygnus.com
|
||||
@@ -362,6 +364,7 @@ M. P. Suzuki mpsuzuki@hiroshima-u.ac.jp
|
||||
Maciej Kwapulinski pikpok@univ.gda.pl
|
||||
Manas Garg manas@cygsoft.com
|
||||
Manfred Hollstein manfred@s-direktnet.de
|
||||
Марк Коренберг socketpair@gmail.com
|
||||
Marc Boucher marc@mbsi.ca
|
||||
Marc Haber mh+debian-bugs@zugschlus.de
|
||||
Marc Lehman schmorp@schmorp.de
|
||||
@@ -593,6 +596,7 @@ Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu
|
||||
Tim Ryan Tim_Ryan@bnz.co.nz
|
||||
Tim Smithers mouse@dmouse.com.au
|
||||
Tim Waugh twaugh@redhat
|
||||
Tobias Quathamer toddy@debian.org
|
||||
Tobias Stoeckmann tobias@bugol.de
|
||||
Toby Peterson toby@opendarwin.org
|
||||
Todd A. Jacobs tjacobs@codegnome.org
|
||||
|
||||
51
bootstrap
51
bootstrap
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Print a version string.
|
||||
scriptversion=2010-10-05.15; # UTC
|
||||
scriptversion=2010-10-08.16; # UTC
|
||||
|
||||
# Bootstrap this package from checked-out sources.
|
||||
|
||||
@@ -80,6 +80,10 @@ gnulib_modules=
|
||||
# Any gnulib files needed that are not in modules.
|
||||
gnulib_files=
|
||||
|
||||
# A function to be called to edit gnulib.mk right after it's created.
|
||||
# Override it via your own definition in bootstrap.conf.
|
||||
gnulib_mk_hook() { :; }
|
||||
|
||||
# A function to be called after everything else in this script.
|
||||
# Override it via your own definition in bootstrap.conf.
|
||||
bootstrap_epilogue() { :; }
|
||||
@@ -257,6 +261,21 @@ insert_sorted_if_absent() {
|
||||
|| exit 1
|
||||
}
|
||||
|
||||
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
|
||||
# insert_sorted_if_absent.
|
||||
insert_vc_ignore() {
|
||||
vc_ignore_file="$1"
|
||||
pattern="$2"
|
||||
case $vc_ignore_file in
|
||||
*.gitignore)
|
||||
# A .gitignore entry that does not start with `/' applies
|
||||
# recursively to subdirectories, so prepend `/' to every
|
||||
# .gitignore entry.
|
||||
pattern=`echo "$pattern" | sed s,^,/,`;;
|
||||
esac
|
||||
insert_sorted_if_absent "$vc_ignore_file" "$pattern"
|
||||
}
|
||||
|
||||
# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
|
||||
found_aux_dir=no
|
||||
grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
|
||||
@@ -275,7 +294,7 @@ if test ! -d $build_aux; then
|
||||
mkdir $build_aux
|
||||
for dot_ig in x $vc_ignore; do
|
||||
test $dot_ig = x && continue
|
||||
insert_sorted_if_absent $dot_ig $build_aux
|
||||
insert_vc_ignore $dot_ig $build_aux
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -394,7 +413,7 @@ fi
|
||||
if ! printf "$buildreq" | check_versions; then
|
||||
echo >&2
|
||||
if test -f README-prereq; then
|
||||
echo "See README-prereq for notes on obtaining the prerequisite programs" >&2
|
||||
echo "See README-prereq for how to get the prerequisite programs" >&2
|
||||
else
|
||||
echo "Please install the prerequisite programs" >&2
|
||||
fi
|
||||
@@ -561,7 +580,7 @@ symlink_to_dir()
|
||||
for dot_ig in x $vc_ignore; do
|
||||
test $dot_ig = x && continue
|
||||
ig=$parent/$dot_ig
|
||||
insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
|
||||
insert_vc_ignore $ig `echo "$dst_dir"|sed 's,.*/,,'`
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -678,7 +697,8 @@ slurp() {
|
||||
for file in `ls -a $1/$dir`; do
|
||||
case $file in
|
||||
.|..) continue;;
|
||||
.*) continue;; # FIXME: should all file names starting with "." be ignored?
|
||||
# FIXME: should all file names starting with "." be ignored?
|
||||
.*) continue;;
|
||||
esac
|
||||
test -d $1/$dir/$file && continue
|
||||
for excluded_file in $excluded_files; do
|
||||
@@ -687,10 +707,12 @@ slurp() {
|
||||
if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
|
||||
copied=$copied${sep}$gnulib_mk; sep=$nl
|
||||
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
|
||||
sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || {
|
||||
sed "$remove_intl" $1/$dir/$file |
|
||||
cmp - $dir/$gnulib_mk > /dev/null || {
|
||||
echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
|
||||
rm -f $dir/$gnulib_mk &&
|
||||
sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
|
||||
sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk &&
|
||||
gnulib_mk_hook $dir/$gnulib_mk
|
||||
}
|
||||
elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
|
||||
version_controlled_file $dir $file; then
|
||||
@@ -718,18 +740,25 @@ slurp() {
|
||||
test $dot_ig = x && continue
|
||||
ig=$dir/$dot_ig
|
||||
if test -n "$copied"; then
|
||||
insert_sorted_if_absent $ig "$copied"
|
||||
insert_vc_ignore $ig "$copied"
|
||||
# If an ignored file name ends with .in.h, then also add
|
||||
# the name with just ".h". Many gnulib headers are generated,
|
||||
# e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
|
||||
# Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
|
||||
f=`echo "$copied"|sed 's/\.in\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'`
|
||||
insert_sorted_if_absent $ig "$f"
|
||||
f=`echo "$copied" |
|
||||
sed '
|
||||
s/\.in\.h$/.h/
|
||||
s/\.sin$/.sed/
|
||||
s/\.y$/.c/
|
||||
s/\.gperf$/.h/
|
||||
'
|
||||
`
|
||||
insert_vc_ignore $ig "$f"
|
||||
|
||||
# For files like sys_stat.in.h and sys_time.in.h, record as
|
||||
# ignorable the directory we might eventually create: sys/.
|
||||
f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
|
||||
insert_sorted_if_absent $ig "$f"
|
||||
insert_vc_ignore $ig "$f"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
@@ -88,6 +88,7 @@ gnulib_modules="
|
||||
fsusage
|
||||
fsync
|
||||
ftello
|
||||
ftoastr
|
||||
fts
|
||||
getgroups
|
||||
gethrxtime
|
||||
@@ -315,6 +316,7 @@ git 1.4.4
|
||||
gperf -
|
||||
gzip -
|
||||
makeinfo -
|
||||
patch -
|
||||
perl 5.5
|
||||
rsync -
|
||||
tar -
|
||||
|
||||
15
cfg.mk
15
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 = 27e765279d5735f99114b57fa097e6bd
|
||||
old_NEWS_hash = e2a254a0d4c81397994ea10a15663ac3
|
||||
|
||||
# Add an exemption for sc_makefile_at_at_check.
|
||||
_makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
|
||||
@@ -164,6 +164,13 @@ sc_man_file_correlation:
|
||||
@$(MAKE) -s -C src all_programs
|
||||
@$(MAKE) -s -C man $@
|
||||
|
||||
# Ensure that the end of each release's section is marked by two empty lines.
|
||||
sc_NEWS_two_empty_lines:
|
||||
@sed -n 4,/Noteworthy/p $(srcdir)/NEWS \
|
||||
| perl -n0e '/(^|\n)\n\n\* Noteworthy/ or exit 1' \
|
||||
|| { echo '$(ME): use two empty lines to separate NEWS sections' \
|
||||
1>&2; exit 1; } || :; \
|
||||
|
||||
# Perl-based tests used to exec perl from a #!/bin/sh script.
|
||||
# Now they all start with #!/usr/bin/perl and the portability
|
||||
# infrastructure is in tests/Makefile.am. Make sure no old-style
|
||||
@@ -244,6 +251,12 @@ sc_prohibit_sleep:
|
||||
halt='prefer xnanosleep over other sleep interfaces' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Use print_ver_ (from init.cfg), not open-coded $VERBOSE check.
|
||||
sc_prohibit_verbose_version:
|
||||
@prohibit='test "\$$VERBOSE" = yes && .* --version' \
|
||||
halt='use the print_ver_ function instead...' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
###########################################################
|
||||
_p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
|
||||
_pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
|
||||
|
||||
@@ -98,7 +98,6 @@ if test "$gl_gcc_warnings" = yes; then
|
||||
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-pointer-sign]) # Too many warnings for now
|
||||
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
|
||||
|
||||
# In spite of excluding -Wlogical-op above, it is enabled, as of
|
||||
|
||||
46
doc/.gitignore
vendored
46
doc/.gitignore
vendored
@@ -1,24 +1,22 @@
|
||||
constants.texi
|
||||
coreutils.aux
|
||||
coreutils.cp
|
||||
coreutils.cps
|
||||
coreutils.dvi
|
||||
coreutils.fl
|
||||
coreutils.fn
|
||||
coreutils.html
|
||||
coreutils.info
|
||||
coreutils.ky
|
||||
coreutils.log
|
||||
coreutils.op
|
||||
coreutils.pdf
|
||||
coreutils.pg
|
||||
coreutils.toc
|
||||
coreutils.tp
|
||||
coreutils.vr
|
||||
fdl.texi
|
||||
gendocs_template
|
||||
get_date.texi
|
||||
getdate.texi
|
||||
parse-datetime.texi
|
||||
stamp-vti
|
||||
version.texi
|
||||
/constants.texi
|
||||
/coreutils.aux
|
||||
/coreutils.cp
|
||||
/coreutils.cps
|
||||
/coreutils.dvi
|
||||
/coreutils.fl
|
||||
/coreutils.fn
|
||||
/coreutils.html
|
||||
/coreutils.info
|
||||
/coreutils.ky
|
||||
/coreutils.log
|
||||
/coreutils.op
|
||||
/coreutils.pdf
|
||||
/coreutils.pg
|
||||
/coreutils.toc
|
||||
/coreutils.tp
|
||||
/coreutils.vr
|
||||
/fdl.texi
|
||||
/gendocs_template
|
||||
/parse-datetime.texi
|
||||
/stamp-vti
|
||||
/version.texi
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
* shuf: (coreutils)shuf invocation. Shuffling text files.
|
||||
* sleep: (coreutils)sleep invocation. Delay for a specified time.
|
||||
* sort: (coreutils)sort invocation. Sort text files.
|
||||
* split: (coreutils)split invocation. Split into fixed-size pieces.
|
||||
* split: (coreutils)split invocation. Split into pieces.
|
||||
* stat: (coreutils)stat invocation. Report file(system) status.
|
||||
* stdbuf: (coreutils)stdbuf invocation. Modify stdio buffering.
|
||||
* stty: (coreutils)stty invocation. Print/change terminal settings.
|
||||
@@ -2624,7 +2624,7 @@ These commands output pieces of the input.
|
||||
@menu
|
||||
* head invocation:: Output the first part of files.
|
||||
* tail invocation:: Output the last part of files.
|
||||
* split invocation:: Split a file into fixed-size pieces.
|
||||
* split invocation:: Split a file into pieces.
|
||||
* csplit invocation:: Split a file into context-determined pieces.
|
||||
@end menu
|
||||
|
||||
@@ -2821,6 +2821,7 @@ Historical implementations of @command{tail} have required that
|
||||
@var{number} be an integer. However, GNU @command{tail} accepts
|
||||
an arbitrary floating point number (using a period before any
|
||||
fractional digits).
|
||||
When @command{tail} uses inotify, this polling-related option is ignored.
|
||||
|
||||
@itemx --pid=@var{pid}
|
||||
@opindex --pid
|
||||
@@ -2855,7 +2856,8 @@ still associated with the same device/inode-number pair as before.
|
||||
When following a log file that is rotated, this is approximately the
|
||||
number of seconds between when tail prints the last pre-rotation lines
|
||||
and when it prints the lines that have accumulated in the new log file.
|
||||
This option is meaningful only when following by name.
|
||||
This option is meaningful only when polling (i.e., without inotify)
|
||||
and when following by name.
|
||||
|
||||
@itemx -n @var{k}
|
||||
@itemx --lines=@var{k}
|
||||
@@ -2920,15 +2922,15 @@ mean either @samp{tail ./+4} or @samp{tail -n +4}.
|
||||
|
||||
|
||||
@node split invocation
|
||||
@section @command{split}: Split a file into fixed-size pieces
|
||||
@section @command{split}: Split a file into pieces.
|
||||
|
||||
@pindex split
|
||||
@cindex splitting a file into pieces
|
||||
@cindex pieces, splitting a file into
|
||||
|
||||
@command{split} creates output files containing consecutive sections of
|
||||
@var{input} (standard input if none is given or @var{input} is
|
||||
@samp{-}). Synopsis:
|
||||
@command{split} creates output files containing consecutive or interleaved
|
||||
sections of @var{input} (standard input if none is given or @var{input}
|
||||
is @samp{-}). Synopsis:
|
||||
|
||||
@example
|
||||
split [@var{option}] [@var{input} [@var{prefix}]]
|
||||
@@ -2941,10 +2943,9 @@ left over for the last section), into each output file.
|
||||
The output files' names consist of @var{prefix} (@samp{x} by default)
|
||||
followed by a group of characters (@samp{aa}, @samp{ab}, @dots{} by
|
||||
default), such that concatenating the output files in traditional
|
||||
sorted order by file name produces
|
||||
the original input file. If the output file names are exhausted,
|
||||
@command{split} reports an error without deleting the output files
|
||||
that it did create.
|
||||
sorted order by file name produces the original input file (except
|
||||
@option{-r}). If the output file names are exhausted, @command{split}
|
||||
reports an error without deleting the output files that it did create.
|
||||
|
||||
The program accepts the following options. Also see @ref{Common options}.
|
||||
|
||||
@@ -2976,6 +2977,41 @@ 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.
|
||||
|
||||
@item -n @var{chunks}
|
||||
@itemx --number=@var{chunks}
|
||||
@opindex -n
|
||||
@opindex --number
|
||||
|
||||
Split @var{input} to @var{chunks} output files where @var{chunks} may be:
|
||||
|
||||
@example
|
||||
@var{n} generate @var{n} files based on current size of @var{input}
|
||||
@var{k}/@var{n} only output @var{k}th of @var{n} to stdout
|
||||
l/@var{n} generate @var{n} files without splitting lines
|
||||
l/@var{k}/@var{n} likewise but only output @var{k}th of @var{n} to stdout
|
||||
r/@var{n} like @samp{l} but use round robin distribution
|
||||
r/@var{k}/@var{n} likewise but only output @var{k}th of @var{n} to stdout
|
||||
@end example
|
||||
|
||||
Any excess bytes remaining after dividing the @var{input}
|
||||
into @var{n} chunks, are assigned to the last chunk.
|
||||
Any excess bytes appearing after the initial calculation are discarded
|
||||
(except when using @samp{r} mode).
|
||||
|
||||
All @var{n} files are created even if there are fewer than @var{n} lines,
|
||||
or the @var{input} is truncated.
|
||||
|
||||
For @samp{l} mode, chunks are approximately @var{input} size / @var{n}.
|
||||
The @var{input} is partitioned into @var{n} equal sized portions, with
|
||||
the last assigned any excess. If a line @emph{starts} within a partition
|
||||
it is written completely to the corresponding file. Since lines
|
||||
are not split even if they overlap a partition, the files written
|
||||
can be larger or smaller than the partition size, and even empty
|
||||
if a line is so long as to completely overlap the partition.
|
||||
|
||||
For @samp{r} mode, the size of @var{input} is irrelevant,
|
||||
and so can be a pipe for example.
|
||||
|
||||
@item -a @var{length}
|
||||
@itemx --suffix-length=@var{length}
|
||||
@opindex -a
|
||||
@@ -2988,6 +3024,23 @@ Use suffixes of length @var{length}. The default @var{length} is 2.
|
||||
@opindex --numeric-suffixes
|
||||
Use digits in suffixes rather than lower-case letters.
|
||||
|
||||
@item -e
|
||||
@itemx --elide-empty-files
|
||||
@opindex -e
|
||||
@opindex --elide-empty-files
|
||||
Suppress the generation of zero-length output files. This can happen
|
||||
with the @option{--number} option if a file is (truncated to be) shorter
|
||||
than the number requested, or if a line is so long as to completely
|
||||
span a chunk. The output file sequence numbers, always run consecutively
|
||||
even when this option is specified.
|
||||
|
||||
@item -u
|
||||
@itemx --unbuffered
|
||||
@opindex -u
|
||||
@opindex --unbuffered
|
||||
Immediately copy input to output in @option{--number r/...} mode,
|
||||
which is a much slower mode of operation.
|
||||
|
||||
@itemx --verbose
|
||||
@opindex --verbose
|
||||
Write a diagnostic just before each output file is opened.
|
||||
@@ -2996,6 +3049,67 @@ Write a diagnostic just before each output file is opened.
|
||||
|
||||
@exitstatus
|
||||
|
||||
Here are a few examples to illustrate how the
|
||||
@option{--number} (@option{-n}) option works:
|
||||
|
||||
Notice how, by default, one line may be split onto two or more:
|
||||
|
||||
@example
|
||||
$ seq -w 6 10 > k; split -n3 k; head xa?
|
||||
==> xaa <==
|
||||
06
|
||||
07
|
||||
==> xab <==
|
||||
|
||||
08
|
||||
0
|
||||
==> xac <==
|
||||
9
|
||||
10
|
||||
@end example
|
||||
|
||||
Use the "l/" modifier to suppress that:
|
||||
|
||||
@example
|
||||
$ seq -w 6 10 > k; split -nl/3 k; head xa?
|
||||
==> xaa <==
|
||||
06
|
||||
07
|
||||
|
||||
==> xab <==
|
||||
08
|
||||
09
|
||||
|
||||
==> xac <==
|
||||
10
|
||||
@end example
|
||||
|
||||
Use the "r/" modifier to distribute lines in a round-robin fashion:
|
||||
|
||||
@example
|
||||
$ seq -w 6 10 > k; split -nr/3 k; head xa?
|
||||
==> xaa <==
|
||||
06
|
||||
09
|
||||
|
||||
==> xab <==
|
||||
07
|
||||
10
|
||||
|
||||
==> xac <==
|
||||
08
|
||||
@end example
|
||||
|
||||
You can also extract just the Kth chunk.
|
||||
This extracts and prints just the 7th "chunk" of 33:
|
||||
|
||||
@example
|
||||
$ seq 100 > k; split -nl/7/33 k
|
||||
20
|
||||
21
|
||||
22
|
||||
@end example
|
||||
|
||||
|
||||
@node csplit invocation
|
||||
@section @command{csplit}: Split a file into context-determined pieces
|
||||
@@ -3082,7 +3196,8 @@ specified, the suffix string must include exactly one
|
||||
@code{printf(3)}-style conversion specification, possibly including
|
||||
format specification flags, a field width, a precision specifications,
|
||||
or all of these kinds of modifiers. The format letter must convert a
|
||||
binary integer argument to readable form; thus, only @samp{d}, @samp{i},
|
||||
binary unsigned integer argument to readable form. The format letters
|
||||
@samp{d} and @samp{i} are aliases for @samp{u}, and the
|
||||
@samp{u}, @samp{o}, @samp{x}, and @samp{X} conversions are allowed. The
|
||||
entire @var{suffix} is given (with the current output file number) to
|
||||
@code{sprintf(3)} to form the file name suffixes for each of the
|
||||
@@ -4075,10 +4190,11 @@ disks and controllers.
|
||||
@item --parallel=@var{n}
|
||||
@opindex --parallel
|
||||
@cindex multithreaded sort
|
||||
Limit the number of sorts run in parallel to @var{n}. By default,
|
||||
@var{n} is set to the number of available processors, and values
|
||||
greater than that are reduced to that limit. Also see
|
||||
@ref{nproc invocation}.
|
||||
Set the number of sorts run in parallel to @var{n}. By default,
|
||||
@var{n} is set to the number of available processors, but limited
|
||||
to 8, as there are diminishing performance gains after that.
|
||||
Note also that using @var{n} threads increases the memory usage by
|
||||
a factor of log @var{n}. Also see @ref{nproc invocation}.
|
||||
|
||||
@item -u
|
||||
@itemx --unique
|
||||
@@ -7614,12 +7730,11 @@ implementations that dereference symbolic links by default.
|
||||
@cindex COW
|
||||
@cindex clone
|
||||
@cindex copy on write
|
||||
Perform a lightweight, copy-on-write (COW) copy.
|
||||
Copying with this option can succeed only on some file systems.
|
||||
Once it has succeeded, beware that the source and destination files
|
||||
share the same disk data blocks as long as they remain unmodified.
|
||||
Perform a lightweight, copy-on-write (COW) copy, if supported by the
|
||||
file system. Once it has succeeded, beware that the source and destination
|
||||
files share the same disk data blocks as long as they remain unmodified.
|
||||
Thus, if a disk I/O error affects data blocks of one of the files,
|
||||
the other suffers the exact same fate.
|
||||
the other suffers the same fate.
|
||||
|
||||
The @var{when} value can be one of the following:
|
||||
|
||||
@@ -7633,6 +7748,15 @@ If the copy-on-write operation is not supported then fall back
|
||||
to the standard copy behaviour.
|
||||
@end table
|
||||
|
||||
This option is overridden by the @option{--link}, @option{--symbolic-link}
|
||||
and @option{--attributes-only} options, thus allowing it to be used
|
||||
to configure the default data copying behavior for @command{cp}.
|
||||
For example, with the following alias, @command{cp} will use the
|
||||
minimum amount of space supported by the file system.
|
||||
|
||||
@example
|
||||
alias cp='cp --reflink=auto --sparse=always'
|
||||
@end example
|
||||
|
||||
@item --remove-destination
|
||||
@opindex --remove-destination
|
||||
@@ -10698,7 +10822,7 @@ The valid @var{format} directives for files with @option{--format} and
|
||||
@item %u - User ID of owner
|
||||
@item %U - User name of owner
|
||||
@item %w - Time of file birth, or @samp{-} if unknown
|
||||
@item %W - Time of file birth as seconds since Epoch, or @samp{-}
|
||||
@item %W - Time of file birth as seconds since Epoch, or @samp{0}
|
||||
@item %x - Time of last access
|
||||
@item %X - Time of last access as seconds since Epoch
|
||||
@item %y - Time of last modification
|
||||
@@ -10707,6 +10831,30 @@ The valid @var{format} directives for files with @option{--format} and
|
||||
@item %Z - Time of last change as seconds since Epoch
|
||||
@end itemize
|
||||
|
||||
The @samp{%W}, @samp{%X}, @samp{%Y}, and @samp{%Z} formats accept a
|
||||
precision preceded by a period to specify the number of digits to
|
||||
print after the decimal point. For example, @samp{%.3X} outputs the
|
||||
last access time to millisecond precision. If a period is given but no
|
||||
precision, @command{stat} uses 9 digits, so @samp{%.X} is equivalent to
|
||||
@samp{%.9X}. When discarding excess precision, time stamps are truncated
|
||||
toward minus infinity.
|
||||
|
||||
@example
|
||||
zero pad:
|
||||
$ stat -c '[%015Y]' /usr
|
||||
[000001288929712]
|
||||
space align:
|
||||
$ stat -c '[%15Y]' /usr
|
||||
[ 1288929712]
|
||||
$ stat -c '[%-15Y]' /usr
|
||||
[1288929712 ]
|
||||
precision:
|
||||
$ stat -c '[%.3Y]' /usr
|
||||
[1288929712.114]
|
||||
$ stat -c '[%.Y]' /usr
|
||||
[1288929712.114951834]
|
||||
@end example
|
||||
|
||||
The mount point printed by @samp{%m} is similar to that output
|
||||
by @command{df}, except that:
|
||||
@itemize @bullet
|
||||
|
||||
10
gl/modules/fadvise-tests
Normal file
10
gl/modules/fadvise-tests
Normal file
@@ -0,0 +1,10 @@
|
||||
Files:
|
||||
tests/test-fadvise.c
|
||||
|
||||
Depends-on:
|
||||
|
||||
configure.ac:
|
||||
|
||||
Makefile.am:
|
||||
TESTS += test-fadvise
|
||||
check_PROGRAMS += test-fadvise
|
||||
@@ -21,6 +21,13 @@
|
||||
|
||||
#include "fadvise.h"
|
||||
|
||||
/* We ignore any errors as these hints are only advisory.
|
||||
* There is the chance one can pass invalid ADVICE, which will
|
||||
* not be indicated, but given the simplicity of the interface
|
||||
* this is unlikely. Also not returning errors allows the
|
||||
* unconditional passing of descriptors to non standard files,
|
||||
* which will just be ignored if unsupported. */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
2
gnulib
2
gnulib
Submodule gnulib updated: 78c0415acc...fe2a2304a8
@@ -1,17 +1,20 @@
|
||||
include gnulib.mk
|
||||
|
||||
AM_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS) # $(WERROR_CFLAGS)
|
||||
AM_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||
|
||||
# A few tests are inherently warning-evoking.
|
||||
# Since we require -Werror, exempt the few offenders.
|
||||
# In the typical case where we use -Werror, exempt the few offenders.
|
||||
|
||||
# test-xvasprintf.c: In function 'test_xasprintf':
|
||||
# test-xvasprintf.c:100: error: format not a string literal and no \
|
||||
# format arguments [-Wformat-security]
|
||||
test_xvasprintf_CFLAGS = $(AM_CFLAGS) -Wno-format-security
|
||||
test_xvasprintf_CFLAGS = $(AM_CFLAGS) \
|
||||
`test -n '$(WERROR_CFLAGS)' && echo ' -Wno-format-security'`
|
||||
|
||||
# test-lock.c: In function 'lock_mutator_thread':
|
||||
# test-lock.c:148: error: cast from function call of type 'pthread_t' to \
|
||||
# non-matching type 'void *' [-Wbad-function-cast]
|
||||
test_lock_CFLAGS = $(AM_CFLAGS) -Wno-bad-function-cast
|
||||
test_tls_CFLAGS = $(AM_CFLAGS) -Wno-bad-function-cast
|
||||
test_lock_CFLAGS = $(AM_CFLAGS) \
|
||||
`test -n '$(WERROR_CFLAGS)' && echo ' -Wno-bad-function-cast'`
|
||||
test_tls_CFLAGS = $(AM_CFLAGS) \
|
||||
`test -n '$(WERROR_CFLAGS)' && echo ' -Wno-bad-function-cast'`
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
cat \- concatenate files and print on the standard output
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
[SEE ALSO]
|
||||
\fBtac\fP(1).
|
||||
|
||||
@@ -603,6 +603,12 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Improve quality of diagnostic when a nonexistent dst_name
|
||||
ends in a slash and open fails with errno == EISDIR. */
|
||||
if (dest_desc < 0 && dest_errno == EISDIR
|
||||
&& *dst_name && dst_name[strlen (dst_name) - 1] == '/')
|
||||
dest_errno = ENOTDIR;
|
||||
}
|
||||
else
|
||||
omitted_permissions = 0;
|
||||
@@ -622,7 +628,8 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
goto close_src_and_dst_desc;
|
||||
}
|
||||
|
||||
if (x->reflink_mode)
|
||||
/* --attributes-only overrides --reflink. */
|
||||
if (data_copy_required && x->reflink_mode)
|
||||
{
|
||||
bool clone_ok = clone_file (dest_desc, source_desc) == 0;
|
||||
if (clone_ok || x->reflink_mode == REFLINK_ALWAYS)
|
||||
|
||||
2
src/cp.c
2
src/cp.c
@@ -604,6 +604,8 @@ do_copy (int n_files, char **file, const char *target_directory,
|
||||
error (0, 0, _("extra operand %s"), quote (file[2]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
/* Update NEW_DST and SB, which may be checked below. */
|
||||
ignore_value (target_directory_operand (file[n_files -1], &sb, &new_dst));
|
||||
}
|
||||
else if (!target_directory)
|
||||
{
|
||||
|
||||
156
src/csplit.c
156
src/csplit.c
@@ -418,6 +418,13 @@ get_new_buffer (size_t min_size)
|
||||
static void
|
||||
free_buffer (struct buffer_record *buf)
|
||||
{
|
||||
struct line *l;
|
||||
for (l = buf->line_start; l;)
|
||||
{
|
||||
struct line *n = l->next;
|
||||
free (l);
|
||||
l = n;
|
||||
}
|
||||
free (buf->buffer);
|
||||
buf->buffer = NULL;
|
||||
}
|
||||
@@ -542,6 +549,7 @@ remove_line (void)
|
||||
if (prev_buf)
|
||||
{
|
||||
free_buffer (prev_buf);
|
||||
free (prev_buf);
|
||||
prev_buf = NULL;
|
||||
}
|
||||
|
||||
@@ -1173,81 +1181,64 @@ parse_patterns (int argc, int start, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
get_format_flags (char **format_ptr)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
|
||||
for (; **format_ptr; (*format_ptr)++)
|
||||
|
||||
/* Names for the printf format flags ' and #. These can be ORed together. */
|
||||
enum { FLAG_THOUSANDS = 1, FLAG_ALTERNATIVE = 2 };
|
||||
|
||||
/* Scan the printf format flags in FORMAT, storing info about the
|
||||
flags into *FLAGS_PTR. Return the number of flags found. */
|
||||
static size_t
|
||||
get_format_flags (char const *format, int *flags_ptr)
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
for (size_t count = 0; ; count++)
|
||||
{
|
||||
switch (**format_ptr)
|
||||
switch (format[count])
|
||||
{
|
||||
case '-':
|
||||
case '0':
|
||||
break;
|
||||
|
||||
case '+':
|
||||
case ' ':
|
||||
count |= 1;
|
||||
case '\'':
|
||||
flags |= FLAG_THOUSANDS;
|
||||
break;
|
||||
|
||||
case '#':
|
||||
count |= 2; /* Allow for 0x prefix preceding an `x' conversion. */
|
||||
flags |= FLAG_ALTERNATIVE;
|
||||
break;
|
||||
|
||||
default:
|
||||
*flags_ptr = flags;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static size_t
|
||||
get_format_width (char **format_ptr)
|
||||
{
|
||||
unsigned long int val = 0;
|
||||
|
||||
if (ISDIGIT (**format_ptr)
|
||||
&& (xstrtoul (*format_ptr, format_ptr, 10, &val, NULL) != LONGINT_OK
|
||||
|| SIZE_MAX < val))
|
||||
error (EXIT_FAILURE, 0, _("invalid format width"));
|
||||
|
||||
/* Allow for enough octal digits to represent the value of UINT_MAX,
|
||||
even if the field width is less than that. */
|
||||
return MAX (val, (sizeof (unsigned int) * CHAR_BIT + 2) / 3);
|
||||
}
|
||||
|
||||
static size_t
|
||||
get_format_prec (char **format_ptr)
|
||||
{
|
||||
if (**format_ptr != '.')
|
||||
return 0;
|
||||
(*format_ptr)++;
|
||||
|
||||
if (! ISDIGIT (**format_ptr))
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
unsigned long int val;
|
||||
if (xstrtoul (*format_ptr, format_ptr, 10, &val, NULL) != LONGINT_OK
|
||||
|| SIZE_MAX < val)
|
||||
error (EXIT_FAILURE, 0, _("invalid format precision"));
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that the printf format conversion specifier *FORMAT is valid
|
||||
and compatible with FLAGS. Change it to 'u' if it is 'd' or 'i',
|
||||
since the format will be used with an unsigned value. */
|
||||
static void
|
||||
get_format_conv_type (char **format_ptr)
|
||||
check_format_conv_type (char *format, int flags)
|
||||
{
|
||||
unsigned char ch = *(*format_ptr)++;
|
||||
unsigned char ch = *format;
|
||||
int compatible_flags = FLAG_THOUSANDS;
|
||||
|
||||
switch (ch)
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'o':
|
||||
*format = 'u';
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
case 'x':
|
||||
case 'X':
|
||||
compatible_flags = FLAG_ALTERNATIVE;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
@@ -1262,45 +1253,46 @@ get_format_conv_type (char **format_ptr)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid conversion specifier in suffix: \\%.3o"), ch);
|
||||
}
|
||||
|
||||
if (flags & ~ compatible_flags)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("invalid flags in conversion specification: %%%c%c"),
|
||||
(flags & ~ compatible_flags & FLAG_ALTERNATIVE ? '#' : '\''), ch);
|
||||
}
|
||||
|
||||
/* Return the maximum number of bytes that can be generated by
|
||||
applying FORMAT to an unsigned int value. If the format is
|
||||
invalid, diagnose the problem and exit. */
|
||||
static size_t
|
||||
max_out (char *format)
|
||||
{
|
||||
size_t out_count = 0;
|
||||
bool percent = false;
|
||||
|
||||
while (*format)
|
||||
{
|
||||
if (*format++ != '%')
|
||||
out_count++;
|
||||
else if (*format == '%')
|
||||
{
|
||||
format++;
|
||||
out_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (percent)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("too many %% conversion specifications in suffix"));
|
||||
percent = true;
|
||||
out_count += get_format_flags (&format);
|
||||
{
|
||||
size_t width = get_format_width (&format);
|
||||
size_t prec = get_format_prec (&format);
|
||||
|
||||
out_count += MAX (width, prec);
|
||||
}
|
||||
get_format_conv_type (&format);
|
||||
}
|
||||
}
|
||||
for (char *f = format; *f; f++)
|
||||
if (*f == '%' && *++f != '%')
|
||||
{
|
||||
if (percent)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("too many %% conversion specifications in suffix"));
|
||||
percent = true;
|
||||
int flags;
|
||||
f += get_format_flags (f, &flags);
|
||||
while (ISDIGIT (*f))
|
||||
f++;
|
||||
if (*f == '.')
|
||||
while (ISDIGIT (*++f))
|
||||
continue;
|
||||
check_format_conv_type (f, flags);
|
||||
}
|
||||
|
||||
if (! percent)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("missing %% conversion specification in suffix"));
|
||||
|
||||
return out_count;
|
||||
int maxlen = snprintf (NULL, 0, format, UINT_MAX);
|
||||
if (! (0 <= maxlen && maxlen <= SIZE_MAX))
|
||||
xalloc_die ();
|
||||
return maxlen;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -1341,7 +1333,7 @@ main (int argc, char **argv)
|
||||
|
||||
case 'n':
|
||||
if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK
|
||||
|| val > INT_MAX)
|
||||
|| MIN (INT_MAX, SIZE_MAX) < val)
|
||||
error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg);
|
||||
digits = val;
|
||||
break;
|
||||
@@ -1372,10 +1364,14 @@ main (int argc, char **argv)
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (suffix)
|
||||
filename_space = xmalloc (strlen (prefix) + max_out (suffix) + 2);
|
||||
else
|
||||
filename_space = xmalloc (strlen (prefix) + digits + 2);
|
||||
size_t prefix_len = strlen (prefix);
|
||||
size_t max_digit_string_len
|
||||
= (suffix
|
||||
? max_out (suffix)
|
||||
: MAX (INT_STRLEN_BOUND (unsigned int), digits));
|
||||
if (SIZE_MAX - 1 - prefix_len < max_digit_string_len)
|
||||
xalloc_die ();
|
||||
filename_space = xmalloc (prefix_len + max_digit_string_len + 1);
|
||||
|
||||
set_input_file (argv[optind++]);
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ FORMAT controls the output. Interpreted sequences are:\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
%C century; like %Y, except omit last two digits (e.g., 20)\n\
|
||||
%d day of month (e.g, 01)\n\
|
||||
%d day of month (e.g., 01)\n\
|
||||
%D date; same as %m/%d/%y\n\
|
||||
%e day of month, space padded; same as %_d\n\
|
||||
"), stdout);
|
||||
@@ -212,8 +212,8 @@ FORMAT controls the output. Interpreted sequences are:\n\
|
||||
%Y year\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
%z +hhmm numeric timezone (e.g., -0400)\n\
|
||||
%:z +hh:mm numeric timezone (e.g., -04:00)\n\
|
||||
%z +hhmm numeric time zone (e.g., -0400)\n\
|
||||
%:z +hh:mm numeric time zone (e.g., -04:00)\n\
|
||||
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)\n\
|
||||
%:::z numeric time zone with : to necessary precision (e.g., -04, +05:30)\n\
|
||||
%Z alphabetic time zone abbreviation (e.g., EDT)\n\
|
||||
|
||||
5
src/du.c
5
src/du.c
@@ -351,8 +351,9 @@ show_date (const char *format, struct timespec when)
|
||||
if (! tm)
|
||||
{
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
error (0, 0, _("time %s is out of range"), timetostr (when.tv_sec, buf));
|
||||
fputs (buf, stdout);
|
||||
char *when_str = timetostr (when.tv_sec, buf);
|
||||
error (0, 0, _("time %s is out of range"), when_str);
|
||||
fputs (when_str, stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ fold_file (char const *filename, size_t width)
|
||||
return false;
|
||||
}
|
||||
|
||||
fadvise (stdin, FADVISE_SEQUENTIAL);
|
||||
fadvise (istream, FADVISE_SEQUENTIAL);
|
||||
|
||||
while ((c = getc (istream)) != EOF)
|
||||
{
|
||||
|
||||
36
src/md5sum.c
36
src/md5sum.c
@@ -431,6 +431,7 @@ static bool
|
||||
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_mismatched_checksums = 0;
|
||||
uintmax_t n_open_or_read_failures = 0;
|
||||
@@ -489,6 +490,8 @@ digest_check (const char *checkfile_name)
|
||||
&& ! (is_stdin && STREQ (filename, "-"))
|
||||
&& hex_digits (hex_digest)))
|
||||
{
|
||||
++n_misformatted_lines;
|
||||
|
||||
if (warn)
|
||||
{
|
||||
error (0, 0,
|
||||
@@ -571,27 +574,26 @@ digest_check (const char *checkfile_name)
|
||||
{
|
||||
if (!status_only)
|
||||
{
|
||||
if (n_misformatted_lines != 0)
|
||||
error (0, 0,
|
||||
ngettext ("WARNING: %" PRIuMAX " line is improperly formatted",
|
||||
"WARNING: %" PRIuMAX " lines are improperly formatted",
|
||||
select_plural (n_misformatted_lines)),
|
||||
n_misformatted_lines);
|
||||
|
||||
if (n_open_or_read_failures != 0)
|
||||
error (0, 0,
|
||||
ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX
|
||||
" listed file could not be read",
|
||||
"WARNING: %" PRIuMAX " of %" PRIuMAX
|
||||
" listed files could not be read",
|
||||
select_plural (n_properly_formatted_lines)),
|
||||
n_open_or_read_failures, n_properly_formatted_lines);
|
||||
ngettext ("WARNING: %" PRIuMAX " listed file could not be read",
|
||||
"WARNING: %" PRIuMAX " listed files could not be read",
|
||||
select_plural (n_open_or_read_failures)),
|
||||
n_open_or_read_failures);
|
||||
|
||||
if (n_mismatched_checksums != 0)
|
||||
{
|
||||
uintmax_t n_computed_checksums =
|
||||
(n_properly_formatted_lines - n_open_or_read_failures);
|
||||
error (0, 0,
|
||||
ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX
|
||||
" computed checksum did NOT match",
|
||||
"WARNING: %" PRIuMAX " of %" PRIuMAX
|
||||
" computed checksums did NOT match",
|
||||
select_plural (n_computed_checksums)),
|
||||
n_mismatched_checksums, n_computed_checksums);
|
||||
}
|
||||
error (0, 0,
|
||||
ngettext ("WARNING: %" PRIuMAX " computed checksum did NOT match",
|
||||
"WARNING: %" PRIuMAX " computed checksums did NOT match",
|
||||
select_plural (n_mismatched_checksums)),
|
||||
n_mismatched_checksums);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
63
src/od.c
63
src/od.c
@@ -24,6 +24,7 @@
|
||||
#include <sys/types.h>
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "ftoastr.h"
|
||||
#include "quote.h"
|
||||
#include "xfreopen.h"
|
||||
#include "xprintf.h"
|
||||
@@ -34,21 +35,9 @@
|
||||
|
||||
#define AUTHORS proper_name ("Jim Meyering")
|
||||
|
||||
#include <float.h>
|
||||
|
||||
/* The default number of input bytes per output line. */
|
||||
#define DEFAULT_BYTES_PER_BLOCK 16
|
||||
|
||||
/* The number of decimal digits of precision in a float. */
|
||||
#ifndef FLT_DIG
|
||||
# define FLT_DIG 7
|
||||
#endif
|
||||
|
||||
/* The number of decimal digits of precision in a double. */
|
||||
#ifndef DBL_DIG
|
||||
# define DBL_DIG 15
|
||||
#endif
|
||||
|
||||
#if HAVE_UNSIGNED_LONG_LONG_INT
|
||||
typedef unsigned long long int unsigned_long_long_int;
|
||||
#else
|
||||
@@ -92,17 +81,15 @@ enum output_format
|
||||
enum
|
||||
{
|
||||
FMT_BYTES_ALLOCATED =
|
||||
MAX ((sizeof "%*.99" - 1
|
||||
(sizeof "%*.99" - 1
|
||||
+ MAX (sizeof "ld",
|
||||
MAX (sizeof PRIdMAX,
|
||||
MAX (sizeof PRIoMAX,
|
||||
MAX (sizeof PRIuMAX,
|
||||
sizeof PRIxMAX))))),
|
||||
sizeof "%*.99Le")
|
||||
sizeof PRIxMAX)))))
|
||||
};
|
||||
|
||||
/* Ensure that our choice for FMT_BYTES_ALLOCATED is reasonable. */
|
||||
verify (LDBL_DIG <= 99);
|
||||
verify (MAX_INTEGRAL_TYPE_SIZE * CHAR_BIT / 3 <= 99);
|
||||
|
||||
/* Each output format specification (from `-t spec' or from
|
||||
@@ -401,10 +388,10 @@ implies 32. By default, od uses -A o -t oS -w16.\n\
|
||||
|
||||
/* Define the print functions. */
|
||||
|
||||
#define PRINT_TYPE(N, T) \
|
||||
#define PRINT_FIELDS(N, T, FMT_STRING, ACTION) \
|
||||
static void \
|
||||
N (size_t fields, size_t blank, void const *block, \
|
||||
char const *fmt_string, int width, int pad) \
|
||||
char const *FMT_STRING, int width, int pad) \
|
||||
{ \
|
||||
T const *p = block; \
|
||||
size_t i; \
|
||||
@@ -412,11 +399,22 @@ N (size_t fields, size_t blank, void const *block, \
|
||||
for (i = fields; blank < i; i--) \
|
||||
{ \
|
||||
int next_pad = pad * (i - 1) / fields; \
|
||||
xprintf (fmt_string, pad_remaining - next_pad + width, *p++); \
|
||||
int adjusted_width = pad_remaining - next_pad + width; \
|
||||
T x = *p++; \
|
||||
ACTION; \
|
||||
pad_remaining = next_pad; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PRINT_TYPE(N, T) \
|
||||
PRINT_FIELDS (N, T, fmt_string, xprintf (fmt_string, adjusted_width, x))
|
||||
|
||||
#define PRINT_FLOATTYPE(N, T, FTOASTR, BUFSIZE) \
|
||||
PRINT_FIELDS (N, T, fmt_string ATTRIBUTE_UNUSED, \
|
||||
char buf[BUFSIZE]; \
|
||||
FTOASTR (buf, sizeof buf, 0, 0, x); \
|
||||
xprintf ("%*s", adjusted_width, buf))
|
||||
|
||||
PRINT_TYPE (print_s_char, signed char)
|
||||
PRINT_TYPE (print_char, unsigned char)
|
||||
PRINT_TYPE (print_s_short, short int)
|
||||
@@ -424,11 +422,13 @@ PRINT_TYPE (print_short, unsigned short int)
|
||||
PRINT_TYPE (print_int, unsigned int)
|
||||
PRINT_TYPE (print_long, unsigned long int)
|
||||
PRINT_TYPE (print_long_long, unsigned_long_long_int)
|
||||
PRINT_TYPE (print_float, float)
|
||||
PRINT_TYPE (print_double, double)
|
||||
PRINT_TYPE (print_long_double, long double)
|
||||
|
||||
PRINT_FLOATTYPE (print_float, float, ftoastr, FLT_BUFSIZE_BOUND)
|
||||
PRINT_FLOATTYPE (print_double, double, dtoastr, DBL_BUFSIZE_BOUND)
|
||||
PRINT_FLOATTYPE (print_long_double, long double, ldtoastr, LDBL_BUFSIZE_BOUND)
|
||||
|
||||
#undef PRINT_TYPE
|
||||
#undef PRINT_FLOATTYPE
|
||||
|
||||
static void
|
||||
dump_hexl_mode_trailer (size_t n_bytes, const char *block)
|
||||
@@ -586,13 +586,11 @@ decode_one_format (const char *s_orig, const char *s, const char **next,
|
||||
enum size_spec size_spec;
|
||||
unsigned long int size;
|
||||
enum output_format fmt;
|
||||
const char *pre_fmt_string;
|
||||
void (*print_function) (size_t, size_t, void const *, char const *,
|
||||
int, int);
|
||||
const char *p;
|
||||
char c;
|
||||
int field_width;
|
||||
int precision;
|
||||
|
||||
assert (tspec != NULL);
|
||||
|
||||
@@ -772,34 +770,31 @@ this system doesn't provide a %lu-byte floating point type"),
|
||||
}
|
||||
size_spec = fp_type_size[size];
|
||||
|
||||
struct lconv const *locale = localeconv ();
|
||||
size_t decimal_point_len =
|
||||
(locale->decimal_point[0] ? strlen (locale->decimal_point) : 1);
|
||||
|
||||
switch (size_spec)
|
||||
{
|
||||
case FLOAT_SINGLE:
|
||||
print_function = print_float;
|
||||
/* FIXME - should we use %g instead of %e? */
|
||||
pre_fmt_string = "%%*.%de";
|
||||
precision = FLT_DIG;
|
||||
field_width = FLT_STRLEN_BOUND_L (decimal_point_len);
|
||||
break;
|
||||
|
||||
case FLOAT_DOUBLE:
|
||||
print_function = print_double;
|
||||
pre_fmt_string = "%%*.%de";
|
||||
precision = DBL_DIG;
|
||||
field_width = DBL_STRLEN_BOUND_L (decimal_point_len);
|
||||
break;
|
||||
|
||||
case FLOAT_LONG_DOUBLE:
|
||||
print_function = print_long_double;
|
||||
pre_fmt_string = "%%*.%dLe";
|
||||
precision = LDBL_DIG;
|
||||
field_width = LDBL_STRLEN_BOUND_L (decimal_point_len);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
field_width = precision + 8;
|
||||
sprintf (tspec->fmt_string, pre_fmt_string, precision);
|
||||
assert (strlen (tspec->fmt_string) < FMT_BYTES_ALLOCATED);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
|
||||
@@ -37,10 +37,6 @@
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Kaveh Ghazi")
|
||||
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
# define MAXHOSTNAMELEN 64
|
||||
#endif
|
||||
|
||||
char *ttyname (int);
|
||||
|
||||
/* If true, display the hours:minutes since each user has touched
|
||||
|
||||
@@ -46,7 +46,6 @@ static char const *separator;
|
||||
|
||||
/* The string output after all numbers have been output.
|
||||
Usually "\n" or "\0". */
|
||||
/* FIXME: make this an option. */
|
||||
static char const terminator[] = "\n";
|
||||
|
||||
static struct option const long_options[] =
|
||||
|
||||
687
src/sort.c
687
src/sort.c
File diff suppressed because it is too large
Load Diff
558
src/split.c
558
src/split.c
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
@@ -33,6 +34,7 @@
|
||||
#include "full-read.h"
|
||||
#include "full-write.h"
|
||||
#include "quote.h"
|
||||
#include "safe-read.h"
|
||||
#include "xfreopen.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -43,8 +45,6 @@
|
||||
proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \
|
||||
proper_name ("Richard M. Stallman")
|
||||
|
||||
#define DEFAULT_SUFFIX_LENGTH 2
|
||||
|
||||
/* Base name of output files. */
|
||||
static char const *outbase;
|
||||
|
||||
@@ -56,7 +56,7 @@ static char *outfile;
|
||||
static char *outfile_mid;
|
||||
|
||||
/* Length of OUTFILE's suffix. */
|
||||
static size_t suffix_length = DEFAULT_SUFFIX_LENGTH;
|
||||
static size_t suffix_length;
|
||||
|
||||
/* Alphabet of characters to use in suffix. */
|
||||
static char const *suffix_alphabet = "abcdefghijklmnopqrstuvwxyz";
|
||||
@@ -65,17 +65,25 @@ static char const *suffix_alphabet = "abcdefghijklmnopqrstuvwxyz";
|
||||
static char *infile;
|
||||
|
||||
/* Descriptor on which output file is open. */
|
||||
static int output_desc;
|
||||
static int output_desc = -1;
|
||||
|
||||
/* If true, print a diagnostic on standard error just before each
|
||||
output file is opened. */
|
||||
static bool verbose;
|
||||
|
||||
/* If true, don't generate zero length output files. */
|
||||
static bool elide_empty_files;
|
||||
|
||||
/* If true, in round robin mode, immediately copy
|
||||
input to output, which is much slower, so disabled by default. */
|
||||
static bool unbuffered;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
|
||||
enum
|
||||
{
|
||||
VERBOSE_OPTION = CHAR_MAX + 1
|
||||
VERBOSE_OPTION = CHAR_MAX + 1,
|
||||
IO_BLKSIZE_OPTION
|
||||
};
|
||||
|
||||
static struct option const longopts[] =
|
||||
@@ -83,14 +91,45 @@ static struct option const longopts[] =
|
||||
{"bytes", required_argument, NULL, 'b'},
|
||||
{"lines", required_argument, NULL, 'l'},
|
||||
{"line-bytes", required_argument, NULL, 'C'},
|
||||
{"number", required_argument, NULL, 'n'},
|
||||
{"elide-empty-files", no_argument, NULL, 'e'},
|
||||
{"unbuffered", no_argument, NULL, 'u'},
|
||||
{"suffix-length", required_argument, NULL, 'a'},
|
||||
{"numeric-suffixes", no_argument, NULL, 'd'},
|
||||
{"verbose", no_argument, NULL, VERBOSE_OPTION},
|
||||
{"-io-blksize", required_argument, NULL,
|
||||
IO_BLKSIZE_OPTION}, /* do not document */
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static void
|
||||
set_suffix_length (uintmax_t n_units)
|
||||
{
|
||||
#define DEFAULT_SUFFIX_LENGTH 2
|
||||
|
||||
size_t suffix_needed = 0;
|
||||
size_t alphabet_len = strlen (suffix_alphabet);
|
||||
bool alphabet_slop = (n_units % alphabet_len) != 0;
|
||||
while (n_units /= alphabet_len)
|
||||
suffix_needed++;
|
||||
suffix_needed += alphabet_slop;
|
||||
|
||||
if (suffix_length) /* set by user */
|
||||
{
|
||||
if (suffix_length < suffix_needed)
|
||||
{
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("the suffix length needs to be at least %zu"),
|
||||
suffix_needed);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
suffix_length = MAX (DEFAULT_SUFFIX_LENGTH, suffix_needed);
|
||||
}
|
||||
|
||||
void
|
||||
usage (int status)
|
||||
{
|
||||
@@ -117,7 +156,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-b, --bytes=SIZE put SIZE bytes per output file\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\
|
||||
-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\
|
||||
"), DEFAULT_SUFFIX_LENGTH);
|
||||
fputs (_("\
|
||||
--verbose print a diagnostic just before each\n\
|
||||
@@ -126,6 +168,15 @@ 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\
|
||||
CHUNKS may be:\n\
|
||||
N split into N files based on size of input\n\
|
||||
K/N output Kth of N to stdout\n\
|
||||
l/N split into N files without splitting lines\n\
|
||||
l/K/N output Kth of N to stdout without splitting lines\n\
|
||||
r/N like `l' but use round robin distribution\n\
|
||||
r/K/N likewise but only output Kth of N to stdout\n\
|
||||
"), stdout);
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
@@ -187,6 +238,17 @@ next_file_name (void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Create or truncate a file. */
|
||||
|
||||
static int
|
||||
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));
|
||||
}
|
||||
|
||||
/* Write BYTES bytes at BP to an output file.
|
||||
If NEW_FILE_FLAG is true, open the next output file.
|
||||
Otherwise add to the same output file already in use. */
|
||||
@@ -196,17 +258,12 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
|
||||
{
|
||||
if (new_file_flag)
|
||||
{
|
||||
if (!bp && bytes == 0 && elide_empty_files)
|
||||
return;
|
||||
if (output_desc >= 0 && close (output_desc) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", outfile);
|
||||
|
||||
next_file_name ();
|
||||
if (verbose)
|
||||
fprintf (stdout, _("creating file %s\n"), quote (outfile));
|
||||
output_desc = open (outfile,
|
||||
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
|
||||
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
|
||||
| S_IROTH | S_IWOTH));
|
||||
if (output_desc < 0)
|
||||
if ((output_desc = create (outfile)) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", outfile);
|
||||
}
|
||||
if (full_write (output_desc, bp, bytes) != bytes)
|
||||
@@ -217,13 +274,14 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
|
||||
Use buffer BUF, whose size is BUFSIZE. */
|
||||
|
||||
static void
|
||||
bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize)
|
||||
bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize, uintmax_t max_files)
|
||||
{
|
||||
size_t n_read;
|
||||
bool new_file_flag = true;
|
||||
size_t to_read;
|
||||
uintmax_t to_write = n_bytes;
|
||||
char *bp_out;
|
||||
uintmax_t opened = 0;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -239,6 +297,7 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize)
|
||||
if (to_read) /* do not write 0 bytes! */
|
||||
{
|
||||
cwrite (new_file_flag, bp_out, to_read);
|
||||
opened += new_file_flag;
|
||||
to_write -= to_read;
|
||||
new_file_flag = false;
|
||||
}
|
||||
@@ -248,14 +307,21 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize)
|
||||
{
|
||||
size_t w = to_write;
|
||||
cwrite (new_file_flag, bp_out, w);
|
||||
opened += new_file_flag;
|
||||
new_file_flag = !max_files || (opened < max_files);
|
||||
bp_out += w;
|
||||
to_read -= w;
|
||||
new_file_flag = true;
|
||||
to_write = n_bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (n_read == bufsize);
|
||||
|
||||
/* Ensure NUMBER files are created, which truncates
|
||||
any existing files or notifies any consumers on fifos.
|
||||
FIXME: Should we do this before EXIT_FAILURE? */
|
||||
while (opened++ < max_files)
|
||||
cwrite (true, NULL, 0);
|
||||
}
|
||||
|
||||
/* Split into pieces of exactly N_LINES lines.
|
||||
@@ -361,6 +427,331 @@ line_bytes_split (size_t n_bytes)
|
||||
free (buf);
|
||||
}
|
||||
|
||||
/* -n l/[K/]N: Write lines to files of approximately file size / N.
|
||||
The file is partitioned into file size / N sized portions, with the
|
||||
last assigned any excess. If a line _starts_ within a partition
|
||||
it is written completely to the corresponding file. Since lines
|
||||
are not split even if they overlap a partition, the files written
|
||||
can be larger or smaller than the partition size, and even empty
|
||||
if a line is so long as to completely overlap the partition. */
|
||||
|
||||
static void
|
||||
lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
off_t file_size)
|
||||
{
|
||||
assert (n && k <= n && n <= file_size);
|
||||
|
||||
const off_t chunk_size = file_size / n;
|
||||
uintmax_t chunk_no = 1;
|
||||
off_t chunk_end = chunk_size - 1;
|
||||
off_t n_written = 0;
|
||||
bool new_file_flag = true;
|
||||
|
||||
if (k > 1)
|
||||
{
|
||||
/* Start reading 1 byte before kth chunk of file. */
|
||||
off_t start = (k - 1) * chunk_size - 1;
|
||||
if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
n_written = start;
|
||||
chunk_no = k - 1;
|
||||
chunk_end = chunk_no * chunk_size - 1;
|
||||
}
|
||||
|
||||
while (n_written < file_size)
|
||||
{
|
||||
char *bp = buf, *eob;
|
||||
size_t n_read = full_read (STDIN_FILENO, buf, bufsize);
|
||||
n_read = MIN (n_read, file_size - n_written);
|
||||
if (n_read < bufsize && errno)
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
else if (n_read == 0)
|
||||
break; /* eof. */
|
||||
eob = buf + n_read;
|
||||
|
||||
while (bp != eob)
|
||||
{
|
||||
size_t to_write;
|
||||
bool next = false;
|
||||
|
||||
/* Begin looking for '\n' at last byte of chunk. */
|
||||
off_t skip = MIN (n_read, MAX (0, chunk_end - n_written));
|
||||
char *bp_out = memchr (bp + skip, '\n', n_read - skip);
|
||||
if (bp_out++)
|
||||
next = true;
|
||||
else
|
||||
bp_out = eob;
|
||||
to_write = bp_out - bp;
|
||||
|
||||
if (k == chunk_no)
|
||||
{
|
||||
/* We don't use the stdout buffer here since we're writing
|
||||
large chunks from an existing file, so it's more efficient
|
||||
to write out directly. */
|
||||
if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
|
||||
error (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
}
|
||||
else
|
||||
cwrite (new_file_flag, bp, to_write);
|
||||
n_written += to_write;
|
||||
bp += to_write;
|
||||
n_read -= to_write;
|
||||
new_file_flag = next;
|
||||
|
||||
/* A line could have been so long that it skipped
|
||||
entire chunks. So create empty files in that case. */
|
||||
while (next || chunk_end <= n_written - 1)
|
||||
{
|
||||
if (!next && bp == eob)
|
||||
break; /* replenish buf, before going to next chunk. */
|
||||
chunk_no++;
|
||||
if (k && chunk_no > k)
|
||||
return;
|
||||
if (chunk_no == n)
|
||||
chunk_end = file_size - 1; /* >= chunk_size. */
|
||||
else
|
||||
chunk_end += chunk_size;
|
||||
if (chunk_end <= n_written - 1)
|
||||
cwrite (true, NULL, 0);
|
||||
else
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure NUMBER files are created, which truncates
|
||||
any existing files or notifies any consumers on fifos.
|
||||
FIXME: Should we do this before EXIT_FAILURE? */
|
||||
while (!k && chunk_no++ <= n)
|
||||
cwrite (true, NULL, 0);
|
||||
}
|
||||
|
||||
/* -n K/N: Extract Kth of N chunks. */
|
||||
|
||||
static void
|
||||
bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
|
||||
off_t file_size)
|
||||
{
|
||||
off_t start;
|
||||
off_t end;
|
||||
|
||||
assert (k && n && k <= n && n <= file_size);
|
||||
|
||||
start = (k - 1) * (file_size / n);
|
||||
end = (k == n) ? file_size : k * (file_size / n);
|
||||
|
||||
if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0)
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
|
||||
while (start < end)
|
||||
{
|
||||
size_t n_read = full_read (STDIN_FILENO, buf, bufsize);
|
||||
n_read = MIN (n_read, end - start);
|
||||
if (n_read < bufsize && errno)
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
else if (n_read == 0)
|
||||
break; /* eof. */
|
||||
if (full_write (STDOUT_FILENO, buf, n_read) != n_read)
|
||||
error (EXIT_FAILURE, errno, "%s", quote ("-"));
|
||||
start += n_read;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct of_info
|
||||
{
|
||||
char *of_name;
|
||||
int ofd;
|
||||
FILE* ofile;
|
||||
} of_t;
|
||||
|
||||
enum
|
||||
{
|
||||
OFD_NEW = -1,
|
||||
OFD_APPEND = -2
|
||||
};
|
||||
|
||||
/* Rotate file descriptors when we're writing to more output files than we
|
||||
have available file descriptors.
|
||||
Return whether we came under file resource pressure.
|
||||
If so, it's probably best to close each file when finished with it. */
|
||||
|
||||
static bool
|
||||
ofile_open (of_t *files, size_t i_check, size_t nfiles)
|
||||
{
|
||||
bool file_limit = false;
|
||||
|
||||
if (files[i_check].ofd <= OFD_NEW)
|
||||
{
|
||||
int fd;
|
||||
size_t i_reopen = i_check ? i_check - 1 : nfiles - 1;
|
||||
|
||||
/* Another process could have opened a file in between the calls to
|
||||
close and open, so we should keep trying until open succeeds or
|
||||
we've closed all of our files. */
|
||||
while (true)
|
||||
{
|
||||
if (files[i_check].ofd == OFD_NEW)
|
||||
fd = create (files[i_check].of_name);
|
||||
else /* OFD_APPEND */
|
||||
{
|
||||
/* Attempt to append to previously opened file.
|
||||
We use O_NONBLOCK to support writing to fifos,
|
||||
where the other end has closed because of our
|
||||
previous close. In that case we'll immediately
|
||||
get an error, rather than waiting indefinitely.
|
||||
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);
|
||||
}
|
||||
|
||||
if (-1 < fd)
|
||||
break;
|
||||
|
||||
if (!(errno == EMFILE || errno == ENFILE))
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
|
||||
|
||||
file_limit = true;
|
||||
|
||||
/* Search backwards for an open file to close. */
|
||||
while (files[i_reopen].ofd < 0)
|
||||
{
|
||||
i_reopen = i_reopen ? i_reopen - 1 : nfiles - 1;
|
||||
/* No more open files to close, exit with E[NM]FILE. */
|
||||
if (i_reopen == i_check)
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
|
||||
}
|
||||
|
||||
if (fclose (files[i_reopen].ofile) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_reopen].of_name);
|
||||
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);
|
||||
}
|
||||
|
||||
return file_limit;
|
||||
}
|
||||
|
||||
/* -n r/[K/]N: Divide file into N chunks in round robin fashion.
|
||||
When K == 0, we try to keep the files open in parallel.
|
||||
If we run out of file resources, then we revert
|
||||
to opening and closing each file for each line. */
|
||||
|
||||
static void
|
||||
lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
|
||||
{
|
||||
bool file_limit;
|
||||
size_t i_file;
|
||||
of_t *files;
|
||||
uintmax_t line_no;
|
||||
|
||||
if (k)
|
||||
line_no = 1;
|
||||
else
|
||||
{
|
||||
if (SIZE_MAX < n)
|
||||
error (exit_failure, 0, "%s", _("memory exhausted"));
|
||||
files = xnmalloc (n, sizeof *files);
|
||||
|
||||
/* Generate output file names. */
|
||||
for (i_file = 0; i_file < n; i_file++)
|
||||
{
|
||||
next_file_name ();
|
||||
files[i_file].of_name = xstrdup (outfile);
|
||||
files[i_file].ofd = OFD_NEW;
|
||||
files[i_file].ofile = NULL;
|
||||
}
|
||||
i_file = 0;
|
||||
file_limit = false;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
char *bp = buf, *eob;
|
||||
/* Use safe_read() rather than full_read() here
|
||||
so that we process available data immediately. */
|
||||
size_t n_read = safe_read (STDIN_FILENO, buf, bufsize);
|
||||
if (n_read == SAFE_READ_ERROR)
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
else if (n_read == 0)
|
||||
break; /* eof. */
|
||||
eob = buf + n_read;
|
||||
|
||||
while (bp != eob)
|
||||
{
|
||||
size_t to_write;
|
||||
bool next = false;
|
||||
|
||||
/* Find end of line. */
|
||||
char *bp_out = memchr (bp, '\n', eob - bp);
|
||||
if (bp_out)
|
||||
{
|
||||
bp_out++;
|
||||
next = true;
|
||||
}
|
||||
else
|
||||
bp_out = eob;
|
||||
to_write = bp_out - bp;
|
||||
|
||||
if (k)
|
||||
{
|
||||
if (line_no == k && unbuffered)
|
||||
{
|
||||
if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
|
||||
error (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
}
|
||||
else if (line_no == k && fwrite (bp, to_write, 1, stdout) != 1)
|
||||
{
|
||||
clearerr (stdout); /* To silence close_stdout(). */
|
||||
error (EXIT_FAILURE, errno, "%s", _("write error"));
|
||||
}
|
||||
if (next)
|
||||
line_no = (line_no == n) ? 1 : line_no + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Secure file descriptor. */
|
||||
file_limit |= ofile_open (files, i_file, n);
|
||||
if (unbuffered)
|
||||
{
|
||||
/* 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)
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
|
||||
}
|
||||
else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1)
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
|
||||
if (file_limit)
|
||||
{
|
||||
if (fclose (files[i_file].ofile) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
|
||||
files[i_file].ofd = OFD_APPEND;
|
||||
}
|
||||
if (next && ++i_file == n)
|
||||
i_file = 0;
|
||||
}
|
||||
|
||||
bp = bp_out;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
#define FAIL_ONLY_ONE_WAY() \
|
||||
do \
|
||||
{ \
|
||||
@@ -369,21 +760,41 @@ line_bytes_split (size_t n_bytes)
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Parse K/N syntax of chunk options. */
|
||||
|
||||
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
|
||||
|| *n_units == 0)
|
||||
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))
|
||||
error (EXIT_FAILURE, 0, _("%s: invalid chunk number"), optarg);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
enum
|
||||
{
|
||||
type_undef, type_bytes, type_byteslines, type_lines, type_digits
|
||||
type_undef, type_bytes, type_byteslines, type_lines, type_digits,
|
||||
type_chunk_bytes, type_chunk_lines, type_rr
|
||||
} split_type = type_undef;
|
||||
size_t in_blk_size; /* optimal block size of input file device */
|
||||
size_t in_blk_size = 0; /* optimal block size of input file device */
|
||||
char *buf; /* file i/o buffer */
|
||||
size_t page_size = getpagesize ();
|
||||
uintmax_t k_units = 0;
|
||||
uintmax_t n_units;
|
||||
|
||||
static char const multipliers[] = "bEGKkMmPTYZ0";
|
||||
int c;
|
||||
int digits_optind = 0;
|
||||
off_t file_size;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -395,15 +806,16 @@ main (int argc, char **argv)
|
||||
|
||||
/* Parse command line options. */
|
||||
|
||||
infile = bad_cast ( "-");
|
||||
infile = bad_cast ("-");
|
||||
outbase = bad_cast ("x");
|
||||
|
||||
while (1)
|
||||
while (true)
|
||||
{
|
||||
/* This is the argv-index of the option we will read next. */
|
||||
int this_optind = optind ? optind : 1;
|
||||
char *slash;
|
||||
|
||||
c = getopt_long (argc, argv, "0123456789C:a:b:dl:", longopts, NULL);
|
||||
c = getopt_long (argc, argv, "0123456789C:a:b:del:n:u", longopts, NULL);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
@@ -432,6 +844,13 @@ main (int argc, char **argv)
|
||||
error (0, 0, _("%s: invalid number of bytes"), optarg);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
/* If input is a pipe, we could get more data than is possible
|
||||
to write to a single file, so indicate that immediately
|
||||
rather than having possibly future invocations fail. */
|
||||
if (OFF_T_MAX < n_units)
|
||||
error (EXIT_FAILURE, EFBIG,
|
||||
_("%s: invalid number of bytes"), optarg);
|
||||
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
@@ -456,6 +875,38 @@ main (int argc, char **argv)
|
||||
error (0, 0, _("%s: invalid number of bytes"), optarg);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
if (OFF_T_MAX < n_units)
|
||||
error (EXIT_FAILURE, EFBIG,
|
||||
_("%s: invalid number of bytes"), optarg);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (split_type != type_undef)
|
||||
FAIL_ONLY_ONE_WAY ();
|
||||
/* skip any whitespace */
|
||||
while (isspace (to_uchar (*optarg)))
|
||||
optarg++;
|
||||
if (strncmp (optarg, "r/", 2) == 0)
|
||||
{
|
||||
split_type = type_rr;
|
||||
optarg += 2;
|
||||
}
|
||||
else if (strncmp (optarg, "l/", 2) == 0)
|
||||
{
|
||||
split_type = type_chunk_lines;
|
||||
optarg += 2;
|
||||
}
|
||||
else
|
||||
split_type = type_chunk_bytes;
|
||||
if ((slash = strchr (optarg, '/')))
|
||||
parse_chunk (&k_units, &n_units, slash);
|
||||
else if (xstrtoumax (optarg, NULL, 10, &n_units, "") != LONGINT_OK
|
||||
|| n_units == 0)
|
||||
error (EXIT_FAILURE, 0, _("%s: invalid number of chunks"), optarg);
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
unbuffered = true;
|
||||
break;
|
||||
|
||||
case '0':
|
||||
@@ -491,6 +942,22 @@ main (int argc, char **argv)
|
||||
suffix_alphabet = "0123456789";
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
elide_empty_files = true;
|
||||
break;
|
||||
|
||||
case IO_BLKSIZE_OPTION:
|
||||
{
|
||||
uintmax_t tmp_blk_size;
|
||||
if (xstrtoumax (optarg, NULL, 10, &tmp_blk_size,
|
||||
multipliers) != LONGINT_OK
|
||||
|| tmp_blk_size == 0 || SIZE_MAX - page_size < tmp_blk_size)
|
||||
error (0, 0, _("%s: invalid IO block size"), optarg);
|
||||
else
|
||||
in_blk_size = tmp_blk_size;
|
||||
}
|
||||
break;
|
||||
|
||||
case VERBOSE_OPTION:
|
||||
verbose = true;
|
||||
break;
|
||||
@@ -513,10 +980,12 @@ main (int argc, char **argv)
|
||||
|
||||
if (n_units == 0)
|
||||
{
|
||||
error (0, 0, _("invalid number of lines: 0"));
|
||||
error (0, 0, _("%s: invalid number of lines"), "0");
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
set_suffix_length (n_units);
|
||||
|
||||
/* Get out the filename arguments. */
|
||||
|
||||
if (optind < argc)
|
||||
@@ -537,18 +1006,36 @@ main (int argc, char **argv)
|
||||
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
|
||||
quote (infile));
|
||||
|
||||
/* Binary I/O is safer when bytecounts are used. */
|
||||
/* Binary I/O is safer when byte counts are used. */
|
||||
if (O_BINARY && ! isatty (STDIN_FILENO))
|
||||
xfreopen (NULL, "rb", stdin);
|
||||
|
||||
/* No output file is open now. */
|
||||
output_desc = -1;
|
||||
|
||||
/* Get the optimal block size of input device and make a buffer. */
|
||||
|
||||
if (fstat (STDIN_FILENO, &stat_buf) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", infile);
|
||||
in_blk_size = io_blksize (stat_buf);
|
||||
if (in_blk_size == 0)
|
||||
in_blk_size = io_blksize (stat_buf);
|
||||
file_size = stat_buf.st_size;
|
||||
|
||||
if (split_type == type_chunk_bytes || split_type == type_chunk_lines)
|
||||
{
|
||||
off_t input_offset = lseek (STDIN_FILENO, 0, SEEK_CUR);
|
||||
if (input_offset < 0)
|
||||
error (EXIT_FAILURE, 0, _("%s: cannot determine file size"),
|
||||
quote (infile));
|
||||
file_size -= input_offset;
|
||||
/* Overflow, and sanity checking. */
|
||||
if (OFF_T_MAX < n_units)
|
||||
{
|
||||
char buffer[INT_BUFSIZE_BOUND (uintmax_t)];
|
||||
error (EXIT_FAILURE, EFBIG, _("%s: invalid number of chunks"),
|
||||
umaxtostr (n_units, buffer));
|
||||
}
|
||||
/* increase file_size to n_units here, so that we still process
|
||||
any input data, and create empty files for the rest. */
|
||||
file_size = MAX (file_size, n_units);
|
||||
}
|
||||
|
||||
buf = ptr_align (xmalloc (in_blk_size + 1 + page_size - 1), page_size);
|
||||
|
||||
@@ -560,13 +1047,30 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case type_bytes:
|
||||
bytes_split (n_units, buf, in_blk_size);
|
||||
bytes_split (n_units, buf, in_blk_size, 0);
|
||||
break;
|
||||
|
||||
case type_byteslines:
|
||||
line_bytes_split (n_units);
|
||||
break;
|
||||
|
||||
case type_chunk_bytes:
|
||||
if (k_units == 0)
|
||||
bytes_split (file_size / n_units, buf, in_blk_size, n_units);
|
||||
else
|
||||
bytes_chunk_extract (k_units, n_units, buf, in_blk_size, file_size);
|
||||
break;
|
||||
|
||||
case type_chunk_lines:
|
||||
lines_chunk_split (k_units, n_units, buf, in_blk_size, file_size);
|
||||
break;
|
||||
|
||||
case type_rr:
|
||||
/* Note, this is like `sed -n ${k}~${n}p` when k > 0,
|
||||
but the functionality is provided for symmetry. */
|
||||
lines_rr (k_units, n_units, buf, in_blk_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
242
src/stat.c
242
src/stat.c
@@ -149,6 +149,16 @@ statfs (char const *filename, struct fs_info *buf)
|
||||
#define hextobin(c) ((c) >= 'a' && (c) <= 'f' ? (c) - 'a' + 10 : \
|
||||
(c) >= 'A' && (c) <= 'F' ? (c) - 'A' + 10 : (c) - '0')
|
||||
|
||||
static char const digits[] = "0123456789";
|
||||
|
||||
/* Flags that are portable for use in printf, for at least one
|
||||
conversion specifier; make_format removes unportable flags as
|
||||
needed for particular specifiers. The glibc 2.2 extension "I" is
|
||||
listed here; it is removed by make_format because it has undefined
|
||||
behavior elsewhere and because it is incompatible with
|
||||
out_epoch_sec. */
|
||||
static char const printf_flags[] = "'-+ #0I";
|
||||
|
||||
#define PROGRAM_NAME "stat"
|
||||
|
||||
#define AUTHORS proper_name ("Michael Meskes")
|
||||
@@ -182,6 +192,10 @@ static bool interpret_backslash_escapes;
|
||||
"" for --printf=FMT, "\n" for --format=FMT (-c). */
|
||||
static char const *trailing_delim = "";
|
||||
|
||||
/* The representation of the decimal point in the current locale. */
|
||||
static char const *decimal_point;
|
||||
static size_t decimal_point_len;
|
||||
|
||||
/* Return the type of the specified file system.
|
||||
Some systems have statfvs.f_basetype[FSTYPSZ] (AIX, HP-UX, and Solaris).
|
||||
Others have statvfs.f_fstypename[_VFS_NAMELEN] (NetBSD 3.0).
|
||||
@@ -462,56 +476,168 @@ human_time (struct timespec t)
|
||||
return str;
|
||||
}
|
||||
|
||||
static char * ATTRIBUTE_WARN_UNUSED_RESULT
|
||||
epoch_time (struct timespec t)
|
||||
/* PFORMAT points to a '%' followed by a prefix of a format, all of
|
||||
size PREFIX_LEN. The flags allowed for this format are
|
||||
ALLOWED_FLAGS; remove other printf flags from the prefix, then
|
||||
append SUFFIX. */
|
||||
static void
|
||||
make_format (char *pformat, size_t prefix_len, char const *allowed_flags,
|
||||
char const *suffix)
|
||||
{
|
||||
static char str[INT_STRLEN_BOUND (time_t) + sizeof ".NNNNNNNNN"];
|
||||
/* Note that time_t can technically be a floating point value, such
|
||||
that casting to [u]intmax_t could lose a fractional value or
|
||||
suffer from overflow. However, most porting targets have an
|
||||
integral time_t; also, we know of no file systems that store
|
||||
valid time values outside the bounds of intmax_t even if that
|
||||
value were represented as a floating point. Besides, the cost of
|
||||
converting to struct tm just to use nstrftime (str, len, "%s.%N",
|
||||
tm, 0, t.tv_nsec) is pointless, since nstrftime would have to
|
||||
convert back to seconds as time_t. */
|
||||
if (TYPE_SIGNED (time_t))
|
||||
sprintf (str, "%" PRIdMAX ".%09ld", (intmax_t) t.tv_sec, t.tv_nsec);
|
||||
else
|
||||
sprintf (str, "%" PRIuMAX ".%09ld", (uintmax_t) t.tv_sec, t.tv_nsec);
|
||||
return str;
|
||||
char *dst = pformat + 1;
|
||||
char const *src;
|
||||
char const *srclim = pformat + prefix_len;
|
||||
for (src = dst; src < srclim && strchr (printf_flags, *src); src++)
|
||||
if (strchr (allowed_flags, *src))
|
||||
*dst++ = *src;
|
||||
while (src < srclim)
|
||||
*dst++ = *src++;
|
||||
strcpy (dst, suffix);
|
||||
}
|
||||
|
||||
static void
|
||||
out_string (char *pformat, size_t prefix_len, char const *arg)
|
||||
{
|
||||
strcpy (pformat + prefix_len, "s");
|
||||
make_format (pformat, prefix_len, "-", "s");
|
||||
printf (pformat, arg);
|
||||
}
|
||||
static void
|
||||
static int
|
||||
out_int (char *pformat, size_t prefix_len, intmax_t arg)
|
||||
{
|
||||
strcpy (pformat + prefix_len, PRIdMAX);
|
||||
printf (pformat, arg);
|
||||
make_format (pformat, prefix_len, "'-+ 0", PRIdMAX);
|
||||
return printf (pformat, arg);
|
||||
}
|
||||
static void
|
||||
static int
|
||||
out_uint (char *pformat, size_t prefix_len, uintmax_t arg)
|
||||
{
|
||||
strcpy (pformat + prefix_len, PRIuMAX);
|
||||
printf (pformat, arg);
|
||||
make_format (pformat, prefix_len, "'-0", PRIuMAX);
|
||||
return printf (pformat, arg);
|
||||
}
|
||||
static void
|
||||
out_uint_o (char *pformat, size_t prefix_len, uintmax_t arg)
|
||||
{
|
||||
strcpy (pformat + prefix_len, PRIoMAX);
|
||||
make_format (pformat, prefix_len, "-#0", PRIoMAX);
|
||||
printf (pformat, arg);
|
||||
}
|
||||
static void
|
||||
out_uint_x (char *pformat, size_t prefix_len, uintmax_t arg)
|
||||
{
|
||||
strcpy (pformat + prefix_len, PRIxMAX);
|
||||
make_format (pformat, prefix_len, "-#0", PRIxMAX);
|
||||
printf (pformat, arg);
|
||||
}
|
||||
static int
|
||||
out_minus_zero (char *pformat, size_t prefix_len)
|
||||
{
|
||||
make_format (pformat, prefix_len, "'-+ 0", ".0f");
|
||||
return printf (pformat, -0.25);
|
||||
}
|
||||
|
||||
/* Output the number of seconds since the Epoch, using a format that
|
||||
acts like printf's %f format. */
|
||||
static void
|
||||
out_epoch_sec (char *pformat, size_t prefix_len, struct stat const *statbuf,
|
||||
struct timespec arg)
|
||||
{
|
||||
char *dot = memchr (pformat, '.', prefix_len);
|
||||
size_t sec_prefix_len = prefix_len;
|
||||
int width = 0;
|
||||
int precision = 0;
|
||||
bool frac_left_adjust = false;
|
||||
|
||||
if (dot)
|
||||
{
|
||||
sec_prefix_len = dot - pformat;
|
||||
pformat[prefix_len] = '\0';
|
||||
|
||||
if (ISDIGIT (dot[1]))
|
||||
{
|
||||
long int lprec = strtol (dot + 1, NULL, 10);
|
||||
precision = (lprec <= INT_MAX ? lprec : INT_MAX);
|
||||
}
|
||||
else
|
||||
{
|
||||
precision = 9;
|
||||
}
|
||||
|
||||
if (precision && ISDIGIT (dot[-1]))
|
||||
{
|
||||
/* If a nontrivial width is given, subtract the width of the
|
||||
decimal point and PRECISION digits that will be output
|
||||
later. */
|
||||
char *p = dot;
|
||||
*dot = '\0';
|
||||
|
||||
do
|
||||
--p;
|
||||
while (ISDIGIT (p[-1]));
|
||||
|
||||
long int lwidth = strtol (p, NULL, 10);
|
||||
width = (lwidth <= INT_MAX ? lwidth : INT_MAX);
|
||||
if (1 < width)
|
||||
{
|
||||
p += (*p == '0');
|
||||
sec_prefix_len = p - pformat;
|
||||
int w_d = (decimal_point_len < width
|
||||
? width - decimal_point_len
|
||||
: 0);
|
||||
if (1 < w_d)
|
||||
{
|
||||
int w = w_d - precision;
|
||||
if (1 < w)
|
||||
{
|
||||
char *dst = pformat;
|
||||
for (char const *src = dst; src < p; src++)
|
||||
{
|
||||
if (*src == '-')
|
||||
frac_left_adjust = true;
|
||||
else
|
||||
*dst++ = *src;
|
||||
}
|
||||
sec_prefix_len =
|
||||
(dst - pformat
|
||||
+ (frac_left_adjust ? 0 : sprintf (dst, "%d", w)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int divisor = 1;
|
||||
for (int i = precision; i < 9; i++)
|
||||
divisor *= 10;
|
||||
int frac_sec = arg.tv_nsec / divisor;
|
||||
int int_len;
|
||||
|
||||
if (TYPE_SIGNED (time_t))
|
||||
{
|
||||
bool minus_zero = false;
|
||||
if (arg.tv_sec < 0 && arg.tv_nsec != 0)
|
||||
{
|
||||
int frac_sec_modulus = 1000000000 / divisor;
|
||||
frac_sec = (frac_sec_modulus - frac_sec
|
||||
- (arg.tv_nsec % divisor != 0));
|
||||
arg.tv_sec += (frac_sec != 0);
|
||||
minus_zero = (arg.tv_sec == 0);
|
||||
}
|
||||
int_len = (minus_zero
|
||||
? out_minus_zero (pformat, sec_prefix_len)
|
||||
: out_int (pformat, sec_prefix_len, arg.tv_sec));
|
||||
}
|
||||
else
|
||||
int_len = out_uint (pformat, sec_prefix_len, arg.tv_sec);
|
||||
|
||||
if (precision)
|
||||
{
|
||||
int prec = (precision < 9 ? precision : 9);
|
||||
int trailing_prec = precision - prec;
|
||||
int ilen = (int_len < 0 ? 0 : int_len);
|
||||
int trailing_width = (ilen < width && decimal_point_len < width - ilen
|
||||
? width - ilen - decimal_point_len - prec
|
||||
: 0);
|
||||
printf ("%s%.*d%-*.*d", decimal_point, prec, frac_sec,
|
||||
trailing_width, trailing_prec, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Print the context information of FILENAME, and return true iff the
|
||||
context could not be obtained. */
|
||||
@@ -539,7 +665,8 @@ out_file_context (char *pformat, size_t prefix_len, char const *filename)
|
||||
|
||||
/* Print statfs info. Return zero upon success, nonzero upon failure. */
|
||||
static bool ATTRIBUTE_WARN_UNUSED_RESULT
|
||||
print_statfs (char *pformat, size_t prefix_len, char m, char const *filename,
|
||||
print_statfs (char *pformat, size_t prefix_len, unsigned int m,
|
||||
char const *filename,
|
||||
void const *data)
|
||||
{
|
||||
STRUCT_STATVFS const *statfsbuf = data;
|
||||
@@ -711,9 +838,19 @@ print_mount_point:
|
||||
return fail;
|
||||
}
|
||||
|
||||
/* Map a TS with negative TS.tv_nsec to {0,0}. */
|
||||
static inline struct timespec
|
||||
neg_to_zero (struct timespec ts)
|
||||
{
|
||||
if (0 <= ts.tv_nsec)
|
||||
return ts;
|
||||
struct timespec z = {0, 0};
|
||||
return z;
|
||||
}
|
||||
|
||||
/* Print stat info. Return zero upon success, nonzero upon failure. */
|
||||
static bool
|
||||
print_stat (char *pformat, size_t prefix_len, char m,
|
||||
print_stat (char *pformat, size_t prefix_len, unsigned int m,
|
||||
char const *filename, void const *data)
|
||||
{
|
||||
struct stat *statbuf = (struct stat *) data;
|
||||
@@ -815,31 +952,26 @@ print_stat (char *pformat, size_t prefix_len, char m,
|
||||
}
|
||||
break;
|
||||
case 'W':
|
||||
{
|
||||
struct timespec t = get_stat_birthtime (statbuf);
|
||||
if (t.tv_nsec < 0)
|
||||
out_string (pformat, prefix_len, "-");
|
||||
else
|
||||
out_string (pformat, prefix_len, epoch_time (t));
|
||||
}
|
||||
out_epoch_sec (pformat, prefix_len, statbuf,
|
||||
neg_to_zero (get_stat_birthtime (statbuf)));
|
||||
break;
|
||||
case 'x':
|
||||
out_string (pformat, prefix_len, human_time (get_stat_atime (statbuf)));
|
||||
break;
|
||||
case 'X':
|
||||
out_string (pformat, prefix_len, epoch_time (get_stat_atime (statbuf)));
|
||||
out_epoch_sec (pformat, prefix_len, statbuf, get_stat_atime (statbuf));
|
||||
break;
|
||||
case 'y':
|
||||
out_string (pformat, prefix_len, human_time (get_stat_mtime (statbuf)));
|
||||
break;
|
||||
case 'Y':
|
||||
out_string (pformat, prefix_len, epoch_time (get_stat_mtime (statbuf)));
|
||||
out_epoch_sec (pformat, prefix_len, statbuf, get_stat_mtime (statbuf));
|
||||
break;
|
||||
case 'z':
|
||||
out_string (pformat, prefix_len, human_time (get_stat_ctime (statbuf)));
|
||||
break;
|
||||
case 'Z':
|
||||
out_string (pformat, prefix_len, epoch_time (get_stat_ctime (statbuf)));
|
||||
out_epoch_sec (pformat, prefix_len, statbuf, get_stat_ctime (statbuf));
|
||||
break;
|
||||
case 'C':
|
||||
fail |= out_file_context (pformat, prefix_len, filename);
|
||||
@@ -897,7 +1029,8 @@ print_esc_char (char c)
|
||||
Return zero upon success, nonzero upon failure. */
|
||||
static bool ATTRIBUTE_WARN_UNUSED_RESULT
|
||||
print_it (char const *format, char const *filename,
|
||||
bool (*print_func) (char *, size_t, char, char const *, void const *),
|
||||
bool (*print_func) (char *, size_t, unsigned int,
|
||||
char const *, void const *),
|
||||
void const *data)
|
||||
{
|
||||
bool fail = false;
|
||||
@@ -920,12 +1053,17 @@ print_it (char const *format, char const *filename,
|
||||
{
|
||||
case '%':
|
||||
{
|
||||
size_t len = strspn (b + 1, "#-+.I 0123456789");
|
||||
size_t len = strspn (b + 1, printf_flags);
|
||||
char const *fmt_char = b + len + 1;
|
||||
fmt_char += strspn (fmt_char, digits);
|
||||
if (*fmt_char == '.')
|
||||
fmt_char += 1 + strspn (fmt_char + 1, digits);
|
||||
len = fmt_char - (b + 1);
|
||||
unsigned int fmt_code = *fmt_char;
|
||||
memcpy (dest, b, len + 1);
|
||||
|
||||
b = fmt_char;
|
||||
switch (*fmt_char)
|
||||
switch (fmt_code)
|
||||
{
|
||||
case '\0':
|
||||
--b;
|
||||
@@ -941,7 +1079,7 @@ print_it (char const *format, char const *filename,
|
||||
putchar ('%');
|
||||
break;
|
||||
default:
|
||||
fail |= print_func (dest, len + 1, *fmt_char, filename, data);
|
||||
fail |= print_func (dest, len + 1, fmt_code, filename, data);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1215,14 +1353,14 @@ The valid format sequences for files (without --file-system):\n\
|
||||
fputs (_("\
|
||||
%u User ID of owner\n\
|
||||
%U User name of owner\n\
|
||||
%w Time of file birth, or - if unknown\n\
|
||||
%W Time of file birth as seconds since Epoch, or - if unknown\n\
|
||||
%x Time of last access\n\
|
||||
%X Time of last access as seconds since Epoch\n\
|
||||
%y Time of last modification\n\
|
||||
%Y Time of last modification as seconds since Epoch\n\
|
||||
%z Time of last change\n\
|
||||
%Z Time of last change as seconds since Epoch\n\
|
||||
%w Time of file birth, human-readable; - if unknown\n\
|
||||
%W Time of file birth, seconds since Epoch; 0 if unknown\n\
|
||||
%x Time of last access, human-readable\n\
|
||||
%X Time of last access, seconds since Epoch\n\
|
||||
%y Time of last modification, human-readable\n\
|
||||
%Y Time of last modification, seconds since Epoch\n\
|
||||
%z Time of last change, human-readable\n\
|
||||
%Z Time of last change, seconds since Epoch\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
|
||||
@@ -1267,6 +1405,10 @@ main (int argc, char *argv[])
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
struct lconv const *locale = localeconv ();
|
||||
decimal_point = (locale->decimal_point[0] ? locale->decimal_point : ".");
|
||||
decimal_point_len = strlen (decimal_point);
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "c:fLt", long_options, NULL)) != -1)
|
||||
|
||||
10
src/tail.c
10
src/tail.c
@@ -286,7 +286,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
with --follow=name, reopen a FILE which has not\n\
|
||||
changed size after N (default %d) iterations\n\
|
||||
to see if it has been unlinked or renamed\n\
|
||||
(this is the usual case of rotated log files)\n\
|
||||
(this is the usual case of rotated log files).\n\
|
||||
With inotify, this option is rarely useful.\n\
|
||||
"),
|
||||
DEFAULT_N_LINES,
|
||||
DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS
|
||||
@@ -300,7 +301,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-s, --sleep-interval=N with -f, sleep for approximately N seconds\n\
|
||||
(default 1.0) between iterations\n\
|
||||
(default 1.0) between iterations.\n\
|
||||
With inotify, this option is rarely useful.\n\
|
||||
-v, --verbose always output headers giving file names\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
@@ -2169,7 +2171,8 @@ main (int argc, char **argv)
|
||||
FIXME: when using inotify, and a directory for a watched file
|
||||
is recreated, then we don't recheck any new file when
|
||||
follow_mode == Follow_name */
|
||||
if (tailable_stdin (F, n_files) || any_remote_file (F, n_files))
|
||||
if (!disable_inotify && (tailable_stdin (F, n_files)
|
||||
|| any_remote_file (F, n_files)))
|
||||
disable_inotify = true;
|
||||
|
||||
if (!disable_inotify)
|
||||
@@ -2189,6 +2192,7 @@ main (int argc, char **argv)
|
||||
error (0, errno, _("inotify cannot be used, reverting to polling"));
|
||||
}
|
||||
#endif
|
||||
disable_inotify = true;
|
||||
tail_forever (F, n_files, sleep_interval);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,8 +129,8 @@ SIZE may also be prefixed by one of the following modifying characters:\n\
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/* return 1 on error, 0 on success */
|
||||
static int
|
||||
/* return true on success, false on error. */
|
||||
static bool
|
||||
do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
|
||||
rel_mode_t rel_mode)
|
||||
{
|
||||
@@ -140,7 +140,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
|
||||
if ((block_mode || (rel_mode && rsize < 0)) && fstat (fd, &sb) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot fstat %s"), quote (fname));
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
if (block_mode)
|
||||
{
|
||||
@@ -152,7 +152,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
|
||||
" * %" PRIdMAX " byte blocks for file %s"),
|
||||
(intmax_t) ssize, (intmax_t) blksize,
|
||||
quote (fname));
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
ssize *= blksize;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
|
||||
if (!S_ISREG (sb.st_mode) && !S_TYPEISSHM (&sb))
|
||||
{
|
||||
error (0, 0, _("cannot get the size of %s"), quote (fname));
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
if (sb.st_size < 0)
|
||||
{
|
||||
@@ -173,7 +173,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
|
||||
this would ever go negative. */
|
||||
error (0, 0, _("%s has unusable, apparently negative size"),
|
||||
quote (fname));
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
|
||||
{
|
||||
error (0, 0, _("overflow rounding up size of file %s"),
|
||||
quote (fname));
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
nsize = overflow;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
|
||||
{
|
||||
error (0, 0, _("overflow extending size of file %s"),
|
||||
quote (fname));
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
nsize = fsize + ssize;
|
||||
}
|
||||
@@ -218,21 +218,22 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
|
||||
error (0, errno,
|
||||
_("failed to truncate %s at %" PRIdMAX " bytes"), quote (fname),
|
||||
(intmax_t) nsize);
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
bool got_size = false;
|
||||
bool errors = false;
|
||||
off_t size IF_LINT ( = 0);
|
||||
off_t rsize = -1;
|
||||
rel_mode_t rel_mode = rm_abs;
|
||||
mode_t omode;
|
||||
int c, errors = 0, fd = -1, oflags;
|
||||
int c, fd = -1, oflags;
|
||||
char const *fname;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -374,7 +375,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
error (0, errno, _("cannot open %s for writing"),
|
||||
quote (fname));
|
||||
errors++;
|
||||
errors = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -382,11 +383,11 @@ main (int argc, char **argv)
|
||||
|
||||
if (fd != -1)
|
||||
{
|
||||
errors += do_ftruncate (fd, fname, size, rsize, rel_mode);
|
||||
errors |= !do_ftruncate (fd, fname, size, rsize, rel_mode);
|
||||
if (close (fd) != 0)
|
||||
{
|
||||
error (0, errno, _("closing %s"), quote (fname));
|
||||
errors++;
|
||||
errors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,6 +487,11 @@ tsort (const char *file)
|
||||
|
||||
/* T5. Output front of queue. */
|
||||
puts (head->str);
|
||||
#ifdef lint
|
||||
/* suppress valgrind "definitely lost" warnings. */
|
||||
void *head_str = (void *) head->str;
|
||||
free (head_str);
|
||||
#endif
|
||||
head->str = NULL; /* Avoid printing the same string twice. */
|
||||
n_strings--;
|
||||
|
||||
|
||||
4
src/wc.c
4
src/wc.c
@@ -726,8 +726,8 @@ main (int argc, char **argv)
|
||||
switch (ai_err)
|
||||
{
|
||||
case AI_ERR_READ:
|
||||
error (0, errno, _("%s: read error"), quote (files_from));
|
||||
skip_file = true;
|
||||
error (EXIT_FAILURE, errno, _("%s: read error"),
|
||||
quote (files_from));
|
||||
continue;
|
||||
case AI_ERR_MEM:
|
||||
xalloc_die ();
|
||||
|
||||
@@ -49,10 +49,6 @@
|
||||
proper_name ("David MacKenzie"), \
|
||||
proper_name ("Michael Stone")
|
||||
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
# define MAXHOSTNAMELEN 64
|
||||
#endif
|
||||
|
||||
#ifdef RUN_LVL
|
||||
# define UT_TYPE_RUN_LVL(U) UT_TYPE_EQ (U, RUN_LVL)
|
||||
#else
|
||||
|
||||
@@ -16,7 +16,6 @@ EXTRA_DIST = \
|
||||
other-fs-tmpdir \
|
||||
require-perl \
|
||||
sample-test \
|
||||
test-lib.sh \
|
||||
$(pr_data)
|
||||
|
||||
root_tests = \
|
||||
@@ -150,6 +149,7 @@ TESTS = \
|
||||
misc/xstrtol \
|
||||
tail-2/pid \
|
||||
misc/od \
|
||||
misc/od-float \
|
||||
misc/mktemp \
|
||||
misc/arch \
|
||||
misc/pr \
|
||||
@@ -172,6 +172,8 @@ TESTS = \
|
||||
misc/chroot-fail \
|
||||
misc/comm \
|
||||
misc/csplit \
|
||||
misc/csplit-1000 \
|
||||
misc/csplit-heap \
|
||||
misc/date-sec \
|
||||
misc/dircolors \
|
||||
misc/df \
|
||||
@@ -226,6 +228,8 @@ TESTS = \
|
||||
misc/sort \
|
||||
misc/sort-benchmark-random \
|
||||
misc/sort-compress \
|
||||
misc/sort-compress-hang \
|
||||
misc/sort-compress-proc \
|
||||
misc/sort-continue \
|
||||
misc/sort-debug-keys \
|
||||
misc/sort-debug-warn \
|
||||
@@ -235,15 +239,22 @@ TESTS = \
|
||||
misc/sort-merge-fdlimit \
|
||||
misc/sort-month \
|
||||
misc/sort-rand \
|
||||
misc/sort-spinlock-abuse \
|
||||
misc/sort-stale-thread-mem \
|
||||
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 \
|
||||
misc/stat-birthtime \
|
||||
misc/stat-fmt \
|
||||
misc/stat-hyphen \
|
||||
misc/stat-mount \
|
||||
misc/stat-nanoseconds \
|
||||
misc/stat-printf \
|
||||
misc/stat-slash \
|
||||
misc/stdbuf \
|
||||
@@ -346,6 +357,7 @@ TESTS = \
|
||||
du/2g \
|
||||
du/8gb \
|
||||
du/basic \
|
||||
du/bigtime \
|
||||
du/deref \
|
||||
du/deref-args \
|
||||
du/exclude \
|
||||
|
||||
@@ -49,7 +49,8 @@ built_programs = \
|
||||
# variables to test scripts.
|
||||
TESTS_ENVIRONMENT = \
|
||||
. $(srcdir)/lang-default; \
|
||||
tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \
|
||||
tmp__=$${TMPDIR-/tmp}; \
|
||||
test -d "$$tmp__" && test -w "$$tmp__" || tmp__=.; \
|
||||
. $(srcdir)/envvar-check; \
|
||||
TMPDIR=$$tmp__; export TMPDIR; \
|
||||
exec 9>&2; \
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chgrp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chgrp
|
||||
require_membership_in_two_groups_
|
||||
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chgrp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chgrp
|
||||
require_membership_in_two_groups_
|
||||
|
||||
set _ $groups; shift
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chgrp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chgrp
|
||||
require_membership_in_two_groups_
|
||||
|
||||
set _ $groups; shift
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chgrp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chgrp
|
||||
require_membership_in_two_groups_
|
||||
skip_if_root_
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chgrp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chgrp
|
||||
require_membership_in_two_groups_
|
||||
|
||||
set _ $groups; shift
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chgrp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chgrp
|
||||
require_membership_in_two_groups_
|
||||
|
||||
set _ $groups; shift
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
umask 0
|
||||
file=f
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
file=f
|
||||
touch $file || framework_failure
|
||||
|
||||
@@ -18,12 +18,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
touch f || framework_failure
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
mkdir -p d/e || framework_failure
|
||||
chmod 0 d/e d || framework_failure
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
skip_if_root_
|
||||
|
||||
mkdir -p d/no-x/y a/b || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
|
||||
# Before coreutils-5.92, this would mistakenly succeed,
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
umask 0
|
||||
mkdir d || framework_failure
|
||||
|
||||
@@ -16,14 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chgrp --version
|
||||
chmod --version
|
||||
chown --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chgrp chmod chown
|
||||
|
||||
chmod -f 0 no-such 2> out && fail=1
|
||||
chgrp -f 0 no-such 2>> out && fail=1
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
ln -s non-existent dangle || framework_failure
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
touch file
|
||||
chmod 755 file
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chmod --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chmod
|
||||
|
||||
|
||||
# Each line in this list is a set of arguments, followed by :,
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chgrp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chgrp
|
||||
require_root_
|
||||
|
||||
touch f || framework_failure
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chown --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chown
|
||||
|
||||
ln -s no-such dangle || framework_failure
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chown --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chown
|
||||
skip_if_root_
|
||||
|
||||
mkdir d && ln -s / d/slink-to-root
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
chown --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ chown
|
||||
|
||||
id_u=`id -u` || framework_failure
|
||||
test -n "$id_u" || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir a b c || framework_failure
|
||||
ln -s ../t a/1 || framework_failure
|
||||
|
||||
11
tests/cp/acl
11
tests/cp/acl
@@ -17,16 +17,9 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make sure we get English translations.
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ mv getfacl setfacl
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
mv --version
|
||||
getfacl --version
|
||||
setfacl --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
require_acl_
|
||||
|
||||
# Skip this test if cp was built without ACL support:
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
suffix=.b
|
||||
file=b1.$$
|
||||
@@ -34,8 +30,8 @@ echo test > $file || fail=1
|
||||
|
||||
# Specify both version control and suffix so the environment variables
|
||||
# (possibly set by the user running these tests) aren't used.
|
||||
cp --force --backup=simple --suffix=$suffix $file $file \
|
||||
|| fail=1
|
||||
cp --force --backup=simple --suffix=$suffix $file $file || fail=1
|
||||
cp -T --force --backup=simple --suffix=$suffix $file $file || fail=1
|
||||
|
||||
test -f $file || fail=1
|
||||
test -f $file_backup || fail=1
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir x y || framework_failure
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
echo a > a || framework_failure
|
||||
echo a-tilde > a~ || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
ls --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ ls
|
||||
require_root_
|
||||
working_umask_or_skip_
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir src-dir dest-dir || framework_failure
|
||||
echo f > f || framework_failure
|
||||
|
||||
@@ -19,12 +19,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
require_root_
|
||||
require_selinux_
|
||||
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir a b c d || framework_failure
|
||||
ln -s ../c a || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir -p a b/a/c || framework_failure
|
||||
touch a/c || framework_failure
|
||||
|
||||
@@ -16,14 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
# Ensure that ls sorts the same way for everyone.
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
umask 022
|
||||
|
||||
@@ -34,7 +28,7 @@ umask 022
|
||||
actual=actual
|
||||
expected=expected
|
||||
|
||||
exec 1> $actual
|
||||
exec 3>&1 1> $actual
|
||||
|
||||
for prog in cp mv; do
|
||||
for initial_files in 'x' 'x y' 'x y y~' 'x y y.~1~' 'x y y~ y.~1~'; do
|
||||
@@ -91,6 +85,8 @@ EOF
|
||||
|
||||
sed 's/: x/:/' $expected-tmp |cat $expected-tmp - > $expected
|
||||
|
||||
exec 1>&3 3>&-
|
||||
|
||||
compare $expected $actual || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
@@ -18,13 +18,9 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
mv --version
|
||||
fi
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp mv
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
require_root_
|
||||
|
||||
cwd=`pwd`
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
mv --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ mv
|
||||
|
||||
working_umask_or_skip_
|
||||
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
touch f slink-target || framework_failure
|
||||
ln -s slink-target slink || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir d e || framework_failure
|
||||
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir dir1 dir2 || framework_failure
|
||||
touch dir1/file || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir dir || framework_failure
|
||||
touch file || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
require_membership_in_two_groups_
|
||||
|
||||
|
||||
@@ -15,12 +15,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
skip_if_root_
|
||||
|
||||
chmod g-s . || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least
|
||||
require_local_dir_
|
||||
|
||||
@@ -21,12 +21,8 @@
|
||||
# Now it gives this:
|
||||
# cp: can't copy a directory `dir' into itself `dir/dir'
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir a dir || framework_failure
|
||||
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
touch src || framework_failure
|
||||
touch dest || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
expensive_
|
||||
require_ulimit_
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
ln -s no-such-file dangling-slink || framework_failure
|
||||
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
touch a || framework_failure
|
||||
ln a b || framework_failure
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir a b
|
||||
msg=bar
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
mkdir b
|
||||
msg=bar
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
msg=bar
|
||||
echo $msg > a
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
working_umask_or_skip_
|
||||
# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least
|
||||
require_local_dir_
|
||||
|
||||
@@ -16,13 +16,9 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
mv --version
|
||||
fi
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp mv
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
very_expensive_
|
||||
|
||||
umask 037
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least
|
||||
require_local_dir_
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
require_root_
|
||||
|
||||
# Some of the tests expect a umask that grants group and/or world read access.
|
||||
@@ -58,11 +60,6 @@ t1() {
|
||||
"$nameless_uid" "$@"
|
||||
}
|
||||
|
||||
if test "x$VERBOSE" = xyes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
nameless_uid=`$PERL -le 'foreach my $i (1000..16*1024-1) { getpwuid $i or (print $i), exit }'`
|
||||
nameless_gid1=`$PERL -le 'foreach my $i (1000..16*1024) { getgrgid $i or (print $i), exit }'`
|
||||
nameless_gid2=`$PERL -le 'foreach my $i ('"$nameless_gid1"'+1..16*1024) { getgrgid $i or (print $i), exit }'`
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null ||
|
||||
grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null ||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
kall=/proc/kallsyms
|
||||
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
touch empty || framework_failure
|
||||
|
||||
|
||||
@@ -20,12 +20,8 @@
|
||||
# though now such usage evokes a warning:
|
||||
# cp: `slink': WARNING: using -r to copy symbolic links is not portable
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
echo abc > foo || framework_failure
|
||||
ln -s foo slink || framework_failure
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
cleanup_() { rm -rf "$other_partition_tmpdir"; }
|
||||
. "$abs_srcdir/other-fs-tmpdir"
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
|
||||
: > time_check
|
||||
@@ -39,8 +35,11 @@ test "$mode" = "-rwxrwxrwx" || fail=1
|
||||
|
||||
test copy -nt file && fail=1
|
||||
|
||||
# Ensure that --attributes-only overrides --reflink completely
|
||||
echo > file2 # file with data
|
||||
cp --reflink=auto --preserve --attributes-only file2 empty_copy || fail=1
|
||||
test -s empty_copy && fail=1
|
||||
cp --reflink=always --preserve --attributes-only file2 empty_copy || fail=1
|
||||
test -s empty_copy && fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$VERBOSE" = yes; then
|
||||
set -x
|
||||
cp --version
|
||||
fi
|
||||
|
||||
. $srcdir/test-lib.sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
print_ver_ cp
|
||||
|
||||
# Unset CDPATH. Otherwise, output from the `cd dir' command
|
||||
# can make this test fail.
|
||||
@@ -46,7 +42,7 @@ test $hard_link_to_symlink_does_the_deref = yes \
|
||||
actual=actual-$$
|
||||
expected=expected-$$
|
||||
|
||||
exec 1> $actual
|
||||
exec 3>&1 1> $actual
|
||||
|
||||
# FIXME: This should be bigger: like more than 8k
|
||||
contents=XYZ
|
||||
@@ -220,6 +216,7 @@ cat <<\EOF | sed "$remove_these_sed" > $expected
|
||||
|
||||
EOF
|
||||
|
||||
exec 1>&3 3>&-
|
||||
|
||||
compare $expected $actual 1>&2 || 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