Compare commits

..

72 Commits
v7.2 ... v7.3

Author SHA1 Message Date
Jim Meyering
0ae4336f4f version 7.3
* NEWS: Record release date.
2009-05-01 18:03:50 +02:00
Jim Meyering
120118c7d8 maint: tweak release-building notes
* README-release: Specify -j1 on the command to run all tests.
Otherwise, running some in parallel would cause failures, e.g.,
for rm/ext3-perf and tail-2/assert-2.
2009-05-01 17:55:11 +02:00
Eric Blake
875cae47a9 stdopen: remove unused code
* m4/stdopen.m4: Delete now-unused file.
* lib/stdopen.h: Likewise.
* lib/stdopen.c: Likewise.
2009-04-30 16:47:13 -06:00
Jim Meyering
269bb7362f build: update from gnulib, for fixed lib/signbitl.c
* gnulib: Update submodule to latest.
2009-04-30 17:23:49 +02:00
Jim Meyering
0e945ebcc5 build: "make check" now fails in a friendlier manner for missing Perl
* doc/Makefile.am (sc-lower-case-var): Don't redirect stderr of
$(PERL) (which is sometimes build-aux/missing) to /dev/null,
so that a failing "make check" explains that Perl is not installed.
Reported by James Youngman.
2009-04-30 13:50:40 +02:00
Jim Meyering
71ebb443d8 build: doc: emit something for each "make check"-run rule
* doc/Makefile.am: Use $(AM_V_GEN) in place of each leading "@".
(check-texinfo): Align line-continuation backslashes.
2009-04-30 13:47:46 +02:00
Jim Meyering
428db13557 build: update from gnulib, for the lib/*-state.c compilation fixes
* gnulib: Update submodule to latest.
2009-04-29 07:35:43 +02:00
Pádraig Brady
0a28715b10 misc: correct NEWS entry about id -G portability
* NEWS (Portability): getgrouplist has the portability issues,
not getgroups.
2009-04-28 15:52:29 +01:00
Jim Meyering
74171b693c df: adjust comment to match recent code change
* src/df.c (main): Update comment to match.
2009-04-28 14:45:43 +02:00
Jim Meyering
c4dfd3138e misc: mention the df vs. automount change
* NEWS (Portability): Mention that df now accommodates the new
behavior of some automounters.
2009-04-28 14:32:26 +02:00
Jim Meyering
d76a1c2a2d misc: alphabetize NEWS entries 2009-04-28 14:32:26 +02:00
Tomas Smetana
dbd17157d7 df: use open(2), not stat, to trigger automounting
* src/df.c (main): When iterating over command-line arguments,
attempting to ensure each backing file system is mounted, use
open, not stat.  stat is no longer sufficient to trigger
automounting, in some cases.  Based on a suggestion from Ian Kent.
More details in http://bugzilla.redhat.com/497830
2009-04-28 14:32:17 +02:00
Ondřej Vašík
cb9fd93743 tests: ensure that cp's -a doesn't silence --preserve=context
* tests/cp/cp-a-selinux: Ensure that the -a option does not silence
error diagnostics from --preserve=context, when preserving context
is required.
2009-04-28 11:16:33 +02:00
Ondřej Vašík
8259a73a85 tests: add test for xattr diagnostics on dest. FS lacking xattr support
* tests/cp/cp-mv-enotsup-xattr: Ensure that xattr diagnostics are
displayed correctly when destination filesystem lacks xattr support.
* tests/Makefile.am (root_tests): Add new root-only test.
2009-04-28 11:16:29 +02:00
Jim Meyering
e0cf592f48 copy.c: factor out test for errno value indicating "unsupported"
* src/copy.c (errno_unsupported): New function.
(copy_attr_error, copy_internal): Use it.
2009-04-27 13:33:47 +02:00
Ondřej Vašík
1fa226772c cp -a: diagnose failure when preserving xattr/context required
* src/copy.c (copy_attr_by_fs): Always print diagnostics when preserving
xattrs is required.
(copy_attr_by_name): Likewise.
(copy_reg): Always print diagnostics when preserving SELinux
context is required.
(copy_internal): Likewise.  Also, do not ignore ENOTSUP and ENODATA
errors when preserving SELinux context is required.
* NEWS (Bug fixes): Mention it.
2009-04-27 13:33:42 +02:00
Ondřej Vašík
941bd48235 mv: ignore xattr-preservation failure when not supported by filesystem
*src/copy.c: Do not warn about xattr-preservation failure when xattrs
are not supported and preservation of xattrs is not explicitly required.
Reported by Eric Sandeen in http://bugzilla.redhat.com/496142
2009-04-27 13:26:03 +02:00
Jim Meyering
819ee4272b build: update from gnulib, for the vc-list-files fix
* gnulib: Update submodule to latest.
2009-04-25 10:29:55 +02:00
Jim Meyering
a81441557b build: adjust use of automake's new $(AM_V_GEN) variable
* src/Makefile.am (dircolors.h, wheel-size.h, wheel.h, fs.h):
(version.c, version.h): Use $(AM_V_GEN) only as a prefix of an existing
command.  Otherwise, it provokes warnings from some "make" programs.
Suggestion from Ralf Wildenhues.
2009-04-25 09:23:48 +02:00
Ralf Wildenhues
6debf54e61 tests: fix check-AUTHORS skip logic
* src/Makefile.am (check-AUTHORS): When this test is skipped, be
sure to avoid all commands in the recipe, not just those passed
to the first shell.
2009-04-25 08:35:53 +02:00
Eric Blake
c86509d86e cfg.mk: update to latest gnulib change
* cfg.mk (bootstrap-tools): Override maint.mk default to include
bison.
* gnulib: Update to latest gnulib.
2009-04-24 20:16:27 -06:00
Jim Meyering
9e7edf0006 build: move coreutils-specific rules from maint.mk to new file
* dist-check.mk: New file: coreutils-specific rules extracted
from maint.mk, now that maint.mk has migrated to gnulib.
* Makefile.am (EXTRA_DIST): Add dist-check.mk.
* coreutils/cfg.mk: Include $(srcdir)/dist-check.mk.
* gnulib: Update submodule to latest.
2009-04-24 21:41:11 +02:00
Jim Meyering
b726914a4c tests: avoid unusual (~1-in-20) failure of a new test
* tests/misc/sort: Remove one of the generated tests.
363 remain in this file alone.
2009-04-24 21:34:59 +02:00
Jim Meyering
207daac5c1 build: use automake's new $(AM_V_GEN) and $(AM_V_at) variables
* src/Makefile.am (dircolors.h, wheel-size.h, wheel.h, fs.h):
(version.c, version.h): Mark with $(AM_V_GEN) and $(AM_V_at),
so that the latest automake prints "GEN $@" by default.
2009-04-24 15:16:46 +02:00
Simon Josefsson
98dbd8cc53 build: use maint.mk from gnulib
* maint.mk: Remove file.  Now it's generated.
* .gitignore: Ignore it.
* bootstrap.conf (gnulib_modules): Add maintainer-makefile.
* gnulib: Update submodule to latest.
2009-04-24 07:40:14 +02:00
Jim Meyering
52c4018a9c build: make --enable-silent-rules the default
* configure.ac (AM_INIT_AUTOMAKE): Remove silent-rules.  Instead,...
(AM_SILENT_RULES): Use this, with it's undocumented [yes] argument.
Those who want verbose build output may configure with
--disable-silent-rules or use "make V=1".
2009-04-23 21:09:13 +02:00
Jim Meyering
0e414d9e4a * gnulib: Update submodule to latest. 2009-04-23 21:04:51 +02:00
Jim Meyering
25eb4c6909 sort -m: don't segfault when output file is also an input file
* src/sort.c (avoid_trashing_input): Fix an off-by-one error and
guard the use of memmove.
* NEWS (Bug fixes): Mention it.
* tests/misc/sort: Add tests to exercise the offending code.
* THANKS: Update.
Reported by Otavio Salvador in http://bugs.debian.org/525048.
2009-04-23 21:03:14 +02:00
Jim Meyering
f41f926aab tests: make the check-AUTHORS test more portable, now that it's...
run as part of "make check".
* src/Makefile.am (check-AUTHORS): Don't depend on en_US.UTF-8.
Instead, use the French UTF8 locale, if configure found one.
If not found, just skip the test.
2009-04-23 21:02:43 +02:00
Jim Meyering
cbc4d9bd13 avoid parallel "make distcheck" failure due to two run-in-src/ rules
Move the check-AUTHORS rule from "syntax-check" to "check".
* maint.mk (local-checks-available): Remove check-AUTHORS.
(check-AUTHORS): Remove rule.
* src/Makefile.am (CLEANFILES): Add $(no_install__progs),
since they too are built sometimes.
(check-AUTHORS): Split a longer-than-80 sed command.
(../AUTHORS): Remove obsolete rule.
2009-04-23 21:01:52 +02:00
Jim Meyering
c74fbaefeb cp: work around linux kernel bug: short-read != EOF on /proc
Remove the optimization that avoided up to 50% of cp's read syscalls.
Do not assume that a short read on a regular file indicates EOF.
When reading from a file in /proc on linux [at least 2.6.9 - 2.6.29]
into a 4k-byte buffer or larger, a short read does not
always indicate EOF.  For example, "cp /proc/slabinfo /tmp"
copies only 4068 of the total 7493 bytes.  This optimization
(25719a3315, Improve performance a bit
by optimizing away; 2005-11-24) appears to have been worth less than
a 2% speed-up (and usually much less), so the impact of removing it
is negligible.

* src/copy.c (copy_reg): Don't exit the loop early.
* tests/cp/proc-short-read: New test, lightly based on a suggestion
from Mike Frysinger, to exercise this fix.
* tests/Makefile.am (TESTS): Add cp/proc-short-read.
* NEWS (Improve robustness): Mention this change.
2009-04-22 21:52:11 +02:00
Jim Meyering
2ad7da7594 tests: avoid new "make distcheck" failure due to newer File::Temp
With newer perl (e.g., Fedora 10's 4:5.10.0-68.fc10), tests/CuTmpdir.pm
stopped removing its temporary directories, with diagnostics like this:
  cannot remove path when cwd is /c/coreutils/tests/misc/seq.tmp-e2up \
  for /c/coreutils/tests/misc/seq.tmp-e2up: at \
  /usr/lib/perl5/5.10.0/File/Temp.pm line 902
Chdir out of the target directory before that code runs:
* tests/CuTmpdir.pm (END): chdir '..'.
(chmod_tree): Remove explicit "chdir $dir".
2009-04-22 21:45:24 +02:00
Jim Meyering
4298108f46 doc: update README
* README: (Reporting bugs): List the bug-reporting address here, too,
not just in the following more test-oriented paragraph.
Reported by Tim Mooney.
All changes are no longer listed in version-controlled ChangeLog
files, so note that contributions are attributed in the commit logs.
Mention bootstrap.conf, now that it's the authoritative source of
minimal prerequisite program/version# pairs.
2009-04-19 23:11:16 +02:00
Aurelien Jarno
e453e720b9 tests: avoid failure of install-C test on FreeBSD UFS file system
* tests/install/install-C: Use 2755 (set-gid), not 1755 (sticky),
to test install -C with non-permission mode bits set.  At least on
FreeBSD with a UFS file system, a non-root user may not set the
sticky bit on a non-directory.
2009-04-19 22:17:08 +02:00
Jim Meyering
51a6c63496 comment touch up: insert a space between "#" and text of comment
* bootstrap: It's easier to read that way.
2009-04-19 21:49:14 +02:00
Ralf Wildenhues
2977df8e7d fix comment typos
* bootstrap: Fix comment typos.
* src/pr.c: Likewise.
2009-04-19 21:28:43 +02:00
Jim Meyering
48430d6a4a maint: bootstrap: sync a tiny change from gnulib
* bootstrap: rename variable to sync with gnulib: s/\$depth/$shallow/
2009-04-17 09:10:57 +02:00
Jim Meyering
f08504b43b * gnulib: Update submodule to latest. 2009-04-16 07:42:20 +02:00
Jim Meyering
ea6abe343d build: use '.'-relative name, gnulib_dir
* cfg.mk (gnulib_dir): Use "gnulib", not "/gnulib", now that
the former is a git submodule, and guaranteed to exist.
2009-04-16 07:03:59 +02:00
Jim Meyering
a46c077467 maint: clean up skipped syntax-check rules
* cfg.mk (local-checks-to-skip): Remove patch-check and changelog-check.
* maint.mk (patch-check): Remove rule.
(local-checks-available): Remove patch-check.
(changelog-check): Remove rule.
2009-04-15 20:18:24 +02:00
Ralf Wildenhues
4404198c12 build: avoid parallel distcheck failure
* Makefile.am (ALL_RECURSIVE_TARGETS): Initialize here, too,
to please automake.  Add install-root, check-root, distcheck-hook.
* cfg.mk (ALL_RECURSIVE_TARGETS): Add sc_tight_scope.
* maint.mk (ALL_RECURSIVE_TARGETS): Add patch-check,
check-AUTHORS, maintainer-distcheck, vc-dist, taint-distcheck,
my-distcheck, alpha, beta, major.
2009-04-11 15:20:37 +02:00
Jim Meyering
0523f45f66 doc: fix a typo: s/is a is a/is a/
* doc/coreutils.texi (Putting the tools together): Fix typo.
2009-04-10 12:50:14 +02:00
Jim Meyering
b571b61970 build: tight-scope test: don't build excluded programs
* src/Makefile.am (sc_tight_scope): Depend on $(bin_PROGRAMS),
not $(all_programs)
2009-04-10 11:35:10 +02:00
Jim Meyering
03490e3565 gnulib: update to latest: fix ls -v & sort -V
* NEWS (Bug fixes): Mention it.
2009-04-10 10:15:24 +02:00
Jim Meyering
854f76ed4f maint: remove obsolete utime module
* bootstrap.conf (obsolete_gnulib_modules): Remove utime.
2009-04-10 08:42:10 +02:00
Jim Meyering
6a51c69b05 maint: put each module name on its own line; sort
* bootstrap.conf (gnulib_modules): List them one per line.
2009-04-10 08:20:13 +02:00
Jim Meyering
0df3a91b25 tests: misc/ls-misc: avoid shadowing local decl of $e
* tests/misc/ls-misc (make_j_d): Rename latter $e to $env
2009-04-09 15:29:59 +02:00
Pádraig Brady
bf87a2c8ea id: fix infinite loop on some systems
Steven Parkes reported that `id -G $USER` went into an infinite loop
on Darwin systems for users in more than 10 groups:
http://bugs.gentoo.org/show_bug.cgi?id=264007
* gl/lib/mgetgroups.c (mgetgroups): Work around buggy getgrouplist
implementations that don't update the required size correctly,
by doubling the result buffer and retrying. Also return the
parameter updated by getgrouplist rather than its return value,
as the documentation doesn't actually state the number of groups
stored is returned by getgrouplist.
* tests/misc/id-groups: Add test to exercise this logic
* tests/Makefile.am: Reference new test
* NEWS: Mention the fix
* THANKS: Update
2009-04-09 14:07:29 +01:00
Jim Meyering
148ddb3232 maint: avoid "make syntax-check" failure
* src/install.c (main): Tweak syntax of new diagnostic.
2009-04-07 20:16:00 +02:00
Pádraig Brady
6fb27500ee install: deprecate the --preserve_context option
src/install.c: Print a warning when --preserve_context
rather than --preserve-context is used as per FIXME.
2009-04-07 19:10:16 +01:00
Pádraig Brady
0f1b8c021d maint: remove compiler warnings from randint and randread modules
* gl/lib/randint.c: Remove unused MAX macro
* gl/lib/randread.c (randread_error): Add __attribute__((__noreturn__))
2009-04-07 19:08:32 +01:00
Pádraig Brady
af5723c71e shred,sort,shuf: don't use /dev/urandom by default
Suggestion from Steven Schveighoffer at:
http://savannah.gnu.org/patch/?6797
to greatly speed up the random passes done by shred.
* gl/lib/randread.c: Default to using the internal
pseudorandom generator, rather than reading /dev/urandom
* src/shred.c (usage): remove mention of /dev/urandom
* src/shuf.c (usage); ditto
* src/sort.c (usage): ditto
* doc/coreutils.text: Document the new behaviour
for aquiring random data.
2009-04-07 19:01:46 +01:00
Pádraig Brady
9fdf5845fc maint: Clarify ambiguous refs to Linux kernels or GNU/Linux systems
* README-prereq: s_linux_GNU/Linux_ or s_linux_Linux kernel_
* README-valgrind: ditto
* src/chown-core.c: ditto
* src/dd.c: ditto
* src/df.c: ditto
* src/ls.c: ditto
* src/mv.c: ditto
* src/pwd.c: ditto
* src/remove.c: ditto
* src/shred.c: ditto
* src/stat.c: ditto
* src/su.c: ditto
* src/system.h: ditto
* src/timeout.c: ditto
* src/truncate.c: ditto
2009-04-07 18:57:53 +01:00
Pádraig Brady
e22f096d10 doc: add missing documentation for some SELinux options
* doc/coreutils.texi (ls invocation): Describe the --context (-Z) option
(install invocation): Describe the --preserve-context and -Z options
(id invocation): Describe the --context (-Z) option
(mkdir invocation): ditto
(mknod invocation): ditto
(mkfifo invocation): ditto
* TODO: remove the todo item
2009-04-07 18:53:51 +01:00
Jim Meyering
33e7070464 * doc/code-vs-command: Remove long-unused, never-distributed file. 2009-04-06 07:59:52 +02:00
Jim Meyering
1974dc34b6 gnulib: update to latest: includes Solaris 8 portability fixes 2009-04-04 22:53:56 +02:00
Jim Meyering
8e8b025c90 maint: clean up Makefile.am, rename remaining ChangeLog files
* Makefile.am (changelog_etc, syntax_check_exceptions): Define.
(EXTRA_DIST): Use.  Remove names that are now automatically
included: build-aux/git-version-gen, build-aux/vc-list-files.
* build-aux/ChangeLog-2007: Rename from */ChangeLog.
* doc/ChangeLog-2007: Likewise.
* lib/ChangeLog-2007: Likewise.
* m4/ChangeLog-2007: Likewise.
* po/ChangeLog-2007: Likewise.
2009-04-04 12:40:58 +02:00
Jim Meyering
7008e33441 tests: tweak po_check syntax check
* maint.mk (sc_po_check): Don't let dangling lib/*.[ch] links cause
spurious "grep: lib/file.h: No such file or directory" warnings.
2009-04-04 10:49:36 +02:00
Jim Meyering
100d4983e7 tests: improve ChangeLog syntax check
* maint.mk (sc_changelog): Use $(VC_LIST_EXCEPT), not find.
Don't hang when there are no ChangeLog files.
(sc_require_config_h): For the file-name-filter, use grep -l
to be slightly more efficient.
(sc_require_config_h_first, _header_without_use, sc_program_name):
Likewise.
2009-04-04 10:49:36 +02:00
Ralf Wildenhues
d75bcea4cf tests: make syntax-checks more robust
* maint.mk (_prohibit_regexp): Add ';' at end of ':'-introduced
comment so that the comment doesn't gobble up the following test
for a missing regexp definition.
(_header_without_use): Escape all '.'s in a header file name,
not just the first one.
2009-04-04 10:25:18 +02:00
Jim Meyering
eaacc89a45 * cfg.mk (old_NEWS_hash): Regenerate once more. 2009-04-03 22:05:10 +02:00
Jim Meyering
e1e5963a9d doc: adjust 7.2 "cat,cp,install,mv,split speed-up" NEWS item
* NEWS: Reword an entry from 7.2 and change "linux" to "GNU/Linux".
The latter was requested by Richard Stallman.
* cfg.mk (old_NEWS_hash): Regenerate.
2009-04-03 21:53:50 +02:00
Pádraig Brady
612b647dd1 ls: fix alignment when month names have varying widths
Reported by Samuel Thibault and Stéphane Raimbault, as the glibc fr_FR
locale has recently changed to use the official but variable width
abbreviated month names. Other glibc locales also have variable widths.
http://sourceware.org/ml/libc-locales/2008-q1/msg00035.html
http://sourceware.org/bugzilla/show_bug.cgi?id=9859
* NEWS: Mention the fix
* gl/lib/mbsalign.c: A new module to align and truncate a
string in a specified number of screen cells, while handling
multi-byte characters appropriately.
* gl/lib/mbsalign.h: Ditto
* gl/modules/mbsalign: Ditto
* bootstrap.conf: Reference the new module
* src/ls.c (abmon_init): New function, precompute the abbreviated
months aligned left in a minimum width column <= 5 screen cells.
(align_nstrftime): New function, replace the first %b in the
format specification to strftime with the precomputed month string.
Note using the cached month strings speeds up `ls -lU` by around 17%
on glibc-2.7-2 on linux at least.  Also if we implement this function
using heap storage rather than automatic storage, and use snprintf
instead of strcpy, ls will slow down by 2% and 1% respectively
(i.e. a net gain of 14% rather than 17%).
* tests/ls/abmon-align: A new test to test ls alignment for
various formats and locales
* tests/Makefile.am: Reference the new test
2009-04-03 00:34:11 +01:00
Pádraig Brady
34f0c3e522 doc: Clarify the help for version sorting in ls and sort
* src/ls.c: Update the -v help description
* src/sort.c: Update the -V help description
2009-04-02 13:53:43 +01:00
Jim Meyering
a5ba6c8ef8 doc: adjust README-prereq instructions
* README-prereq: Reverse order of -b/--track options.
 Pádraig Brady mentioned that is required with at least git-1.5.3.6.
Invoke automake's own bootstrap script.
2009-04-02 14:45:49 +02:00
C de-Avillez
2ade7643de build: require automake-1.10b or newer
* bootstrap.conf: Require at least automake-1.10b.
* README-prereq: Mention 1.10b, not 1.10a.
2009-04-02 08:56:32 +02:00
Jim Meyering
4145a1e54c tests: skip mv/i-3 if /dev/stdin is unreadable
* tests/mv/i-3: Skip if /dev/stdin is unreadable.
Reported by Sergei Steshenko.
2009-04-02 08:44:12 +02:00
Jim Meyering
1417251e29 build: set automake's silent-rules option via configure.ac
* bootstrap: Revert commit 9f39fa855, 2009-03-28,
"build: use automake's --silent-rules option when possible".
* configure.ac (AM_INIT_AUTOMAKE): Instead, set it here.
Require the just-released version of automake: 1.10b.
2009-03-31 20:57:11 +02:00
Jim Meyering
30071248c9 tests: enable automake's color-tests and parallel-tests via configure.ac
* gnulib-tests/Makefile.am (AUTOMAKE_OPTIONS): Don't define here.
* tests/Makefile.am (AUTOMAKE_OPTIONS): Likewise.
* configure.ac (AM_INIT_AUTOMAKE): Instead, add color-tests and
parallel-tests here.
2009-03-31 20:29:01 +02:00
Ralf Wildenhues
f8268d3bae build: use Automake's new parallel-tests feature
* build-aux/check.mk: Remove, not needed any more.
* tests/Makefile.am (AUTOMAKE_OPTIONS): Add parallel-tests and
color-tests.
* tests/check.mk: Do not include build-aux/check.mk any more.
(SUFFIXES, TEST_LOGS): Remove.
(TESTS_ENVIRONMENT): Use $$f rather than $$tst in $PERL invocation.
* gnulib-tests/Makefile.am: Do not include build-aux/check.mk.
(AUTOMAKE_OPTIONS): New macro, add parallel-test and color-tests.
(TEST_LOGS): Remove.
2009-03-31 20:29:01 +02:00
Jim Meyering
7a21310eb3 * README-release (savannah news): Also mention the Subject: to use. 2009-03-31 20:28:41 +02:00
Jim Meyering
278ae924be post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2009-03-31 14:48:50 +02:00
68 changed files with 1424 additions and 1656 deletions

1
.gitignore vendored
View File

@@ -56,6 +56,7 @@ lib/selinux
lib/uniwidth
m4/.cvsignore
m4/.gitignore
maint.mk
po/*.gmo
po/*.po
po/.gitignore

View File

@@ -1 +1 @@
7.1
7.2

View File

@@ -1,6 +1,6 @@
# Make coreutils. -*-Makefile-*-
# Copyright (C) 1990, 1993-2008 Free Software Foundation, Inc.
# Copyright (C) 1990, 1993-2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,50 +15,69 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
SUBDIRS = lib src doc man po tests gnulib-tests
EXTRA_DIST = cfg.mk maint.mk \
.prev-version THANKS-to-translators THANKStt.in \
.version \
.vg-suppressions \
.x-sc_GPL_version \
.x-sc_file_system \
.x-sc_obsolete_symbols \
.x-sc_po_check \
.x-sc_program_name \
.x-sc_prohibit_atoi_atof \
.x-sc_prohibit_stat_st_blocks \
.x-sc_prohibit_strcmp \
.x-sc_require_config_h \
.x-sc_space_tab .x-sc_sun_os_names \
.x-sc_trailing_blank \
.x-sc_unmarked_diagnostics \
.x-sc_useless_cpp_parens \
ChangeLog-2005 \
ChangeLog-2006 \
ChangeLog-2007 \
ChangeLog-2008 \
bootstrap \
bootstrap.conf \
build-aux/cvsu \
build-aux/git-version-gen \
build-aux/vc-list-files \
gl/modules/getloadavg.diff \
m4/ChangeLog \
old/fileutils/ChangeLog \
old/fileutils/ChangeLog-1997 \
old/fileutils/NEWS \
old/sh-utils/ChangeLog \
old/sh-utils/ChangeLog.0 \
old/sh-utils/NEWS \
old/textutils/ChangeLog \
old/textutils/NEWS
ALL_RECURSIVE_TARGETS =
SUBDIRS = lib src doc man po tests gnulib-tests
changelog_etc = \
ChangeLog-2005 \
ChangeLog-2006 \
ChangeLog-2007 \
ChangeLog-2008 \
build-aux/ChangeLog-2007 \
doc/ChangeLog-2007 \
lib/ChangeLog-2007 \
m4/ChangeLog-2007 \
old/fileutils/ChangeLog \
old/fileutils/ChangeLog-1997 \
old/fileutils/NEWS \
old/sh-utils/ChangeLog \
old/sh-utils/ChangeLog.0 \
old/sh-utils/NEWS \
old/textutils/ChangeLog \
old/textutils/NEWS \
po/ChangeLog-2007
syntax_check_exceptions = \
.x-sc_GPL_version \
.x-sc_file_system \
.x-sc_obsolete_symbols \
.x-sc_po_check \
.x-sc_program_name \
.x-sc_prohibit_atoi_atof \
.x-sc_prohibit_stat_st_blocks \
.x-sc_prohibit_strcmp \
.x-sc_require_config_h \
.x-sc_space_tab \
.x-sc_sun_os_names \
.x-sc_trailing_blank \
.x-sc_unmarked_diagnostics \
.x-sc_useless_cpp_parens
EXTRA_DIST = \
$(changelog_etc) \
$(syntax_check_exceptions) \
.prev-version \
.version \
.vg-suppressions \
THANKS-to-translators \
THANKStt.in \
bootstrap \
bootstrap.conf \
build-aux/cvsu \
cfg.mk \
dist-check.mk \
gl/modules/getloadavg.diff \
maint.mk
ALL_RECURSIVE_TARGETS += install-root
install-root:
cd src && $(MAKE) $@
ACLOCAL_AMFLAGS = -I m4
# Some tests always need root privileges, others need them only sometimes.
ALL_RECURSIVE_TARGETS += check-root
check-root:
cd tests && $(MAKE) $@ SUBDIRS=
@@ -94,6 +113,7 @@ gen-ChangeLog:
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
fi
ALL_RECURSIVE_TARGETS += distcheck-hook
distcheck-hook: check-ls-dircolors
$(MAKE) my-distcheck

58
NEWS
View File

@@ -1,5 +1,57 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 7.3 (2009-05-01) [stable]
** Bug fixes
cp now diagnoses failure to preserve selinux/xattr attributes when
--preserve=context,xattr is specified in combination with -a.
Also, cp no longer suppresses attribute-preservation diagnostics
when preserving SELinux context was explicitly requested.
ls now aligns output correctly in the presence of abbreviated month
names from the locale database that have differing widths.
ls -v and sort -V now order names like "#.b#" properly
mv: do not print diagnostics when failing to preserve xattr's on file
systems without xattr support.
sort -m no longer segfaults when its output file is also an input file.
E.g., with this, touch 1; sort -m -o 1 1, sort would segfault.
[introduced in coreutils-7.2]
** Changes in behavior
shred, sort, shuf: now use an internal pseudorandom generator by default.
This is mainly noticable in shred where the 3 random passes it does by
default should proceed at the speed of the disk. Previously /dev/urandom
was used if available, which is relatively slow on GNU/Linux systems.
** Improved robustness
cp would exit successfully after copying less than the full contents
of a file larger than ~4000 bytes from a linux-/proc file system to a
destination file system with a fundamental block size of 4KiB or greater.
Reading into a 4KiB-or-larger buffer, cp's "read" syscall would return
a value smaller than 4096, and cp would interpret that as EOF (POSIX
allows this). This optimization, now removed, saved 50% of cp's read
syscalls when copying small files. Affected linux kernels: at least
2.6.9 through 2.6.29.
[the optimization was introduced in coreutils-6.0]
** Portability
df now pre-mounts automountable directories even with automounters for
which stat-like syscalls no longer provoke mounting. Now, df uses open.
`id -G $USER` now works correctly even on Darwin and NetBSD. Previously it
would either truncate the group list to 10, or go into an infinite loop,
due to their non-standard getgrouplist implementations.
[truncation introduced in coreutils-6.11]
[infinite loop introduced in coreutils-7.1]
* Noteworthy changes in release 7.2 (2009-03-31) [stable]
** New features
@@ -37,9 +89,9 @@ GNU coreutils NEWS -*- outline -*-
** Changes in behavior
cp,mv,install,cat,split: now read and write a minimum of 32KiB
at a time. This was seen to increase throughput. Up to 2 times
when reading cached files on linux for example.
cat,cp,install,mv,split: these programs now read and write a minimum
of 32KiB at a time. This was seen to double throughput when reading
cached files on GNU/Linux-based systems.
cp -a now tries to preserve extended attributes (xattr), but does not
diagnose xattr-preservation failure. However, cp --preserve=all still does.

14
README
View File

@@ -41,7 +41,7 @@ Special thanks to Paul Eggert, Brian Matthews, Bruce Evans, Karl Berry,
Kaveh Ghazi, and François Pinard for help with debugging and porting
these programs. Many thanks to all of the people who have taken the
time to submit problem reports and fixes. All contributed changes are
attributed in the ChangeLog files.
attributed in the commit logs.
And thanks to the following people who have provided accounts for
portability testing on many different types of systems: Bob Proulx,
@@ -173,6 +173,10 @@ run this command:
For some tests, you can get even more detail by adding DEBUG=yes.
Then include the contents of the file `log' in your bug report.
Send bug reports, questions, comments, etc. to bug-coreutils@gnu.org.
If you would like to suggest a patch, see the files README-hacking
and HACKING for tips.
***************************************
There are many tests, but nowhere near as many as we need.
@@ -209,13 +213,7 @@ subtle bugs.
WARNING: If you modify files like configure.in, m4/*.m4, aclocal.m4,
or any Makefile.am, then don't be surprised if what gets regenerated no
longer works. To make things work, you'll have to be using appropriate
versions of automake and autoconf. As for what versions are `appropriate',
use the versions of
* autoconf specified via AC_PREREQ in m4/jm-macros.m4
* automake specified via AM_INIT_AUTOMAKE in configure.ac
Usually it's fine to use versions that are newer than those specified.
versions of the tools listed in bootstrap.conf's buildreq string.
All of these programs except `test' recognize the `--version' option.
When reporting bugs, please include in the subject line both the package

View File

@@ -1,12 +1,12 @@
Detailed below are concrete examples for
getting the prerequisites for particular systems.
- linux - fedora
- GNU/Linux - fedora
This shows the steps for getting the required tools to build coreutils 7.0
on a Fedora 8 system. We try to use official packages where possible.
The 3 methods described for making these required packages available, should
help clarify build requirements on any linux system at least.
help clarify build requirements on any GNU/Linux system at least.
1. Make sure offical distro git package is installed
# yum install git
@@ -16,16 +16,19 @@ getting the prerequisites for particular systems.
# yum install emacs #autoconf build requires emacs (20MB)
# rpmbuild --rebuild http://download.fedora.redhat.com/pub/fedora/linux/development/source/SRPMS/autoconf-2.63-1.fc10.src.rpm
# rpm -Uvh /usr/src/redhat/RPMS/noarch/autoconf-2.63-1.fc8.noarch.rpm
Note Autoconf 2.61a-341 or newer is needed to build automake-1.10a in step 3.
Note Autoconf 2.61a-341 or newer is needed to build automake-1.10b in step 3.
Apply the same method to install the lzma package.
[FIXME: mention xz when it's packaged]
3. The latest released automake (1.10.1) was not new enough, so we download
and build automake-1.10a from its repository and make it available
3. The latest stable automake (1.10.1) was not new enough, so we download
and build automake-1.10b or newer from its repository and make it available
just to coreutils:
# yum install help2man #required to build automake fully
$ git clone git://git.sv.gnu.org/automake.git
$ cd automake && ./configure --prefix=$HOME/coreutils/deps
$ cd automake
$ git checkout -b next --track origin/next
$ ./bootstrap
$ ./configure --prefix=$HOME/coreutils/deps
$ make install
Now we can build coreutils as described in README-hacking

View File

@@ -23,7 +23,7 @@ FIXME: enable excluded programs like arch? to get their manual pages?
On at least one SELinux-enabled (enforcing) and one non-SELinux system,
run all tests, both root-only and regular.
Run *all* non-root tests, including expensive and very expensive ones i.e.,
run this: make check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
run this: make -j1 check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
Run the root-only tests:
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
@@ -31,9 +31,9 @@ FIXME: enable excluded programs like arch? to get their manual pages?
* Run "make distcheck"
* Manually set the date, version number, and [stable/alpha/beta] on
line 3 of NEWS, then do this:
line 3 of NEWS, then do e.g.,:
v=7.1
v=7.3
git commit -F <(printf 'version '$v'\n\n* NEWS: Record release date.\n') -a
git tag -s -m "coreutils $v" v$v HEAD
@@ -73,8 +73,9 @@ Once all the builds and tests have passed,
https://savannah.gnu.org/projects/coreutils/
click on the "submit news", then write something like the following:
Subject: coreutils-7.2 released [stable]
The announcement is here:
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/48
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/49
Then go here to approve it:
https://savannah.gnu.org/news/approve.php?group=coreutils

View File

@@ -23,7 +23,7 @@
# find tests -name Makefile.am|xargs grep -wl PATH|xargs perl -pi -e 's,src/vg,src,'
#
# Create this symlink for suppressions (this is no longer necessary,
# with linux-2.6.9 and valgrind-2.2.0):
# with Linux kernel 2.6.9 and valgrind-2.2.0):
# ln -s $PWD/.vg-suppressions /tmp/cu-vg
# Create src/vg:

5
THANKS
View File

@@ -235,6 +235,7 @@ Hugh Daniel hugh@xanadu.com
Ian Bruce ian.bruce@myrealbox.com
Iain Calder ic56@rogers.com
Ian Jackson ijackson@chiark.greenend.org.uk
Ian Kent ikent@redhat.com
Ian Lance Taylor ian@cygnus.com
Ian Turner vectro@pipeline.com
Iida Yosiaki iida@gnu.org
@@ -435,6 +436,7 @@ Ole Laursen olau@hardworking.dk
Oliver Kiddle okiddle@yahoo.co.uk
Ørn E. Hansen oehansen@daimi.aau.dk
Oskar Liljeblad osk@hem.passagen.se
Otavio Salvador otavio@ossystems.com.br
Pádraig Brady P@draigBrady.com
Patrick Mauritz oxygene@studentenbude.ath.cx
Paul D. Smith psmith@gnu.org
@@ -509,6 +511,7 @@ Santiago Vila Doncel sanvila@unex.es
Savochkin Andrey Vladimirovich saw@msu.ru
Scott Lurndal slurn@griffin.engr.sgi.com
Sébastien Maret smaret@umich.edu
Sergei Steshenko sergstesh@yahoo.com
Shing-Shong Shei shei@cs.indiana.edu
Soeren Sonnenburg sonnenburg@informatik.hu-berlin.de
Solar Designer solar@owl.openwall.com
@@ -524,6 +527,8 @@ Steve McIntyre steve@einval.com
Steve Ward planet36@gmail.com
Steven G. Johnson stevenj@alum.mit.edu
Steven Mocking ufo@quicknet.nl
Steven Parkes smparkes@smparkes.net
Steven Schveighoffer schveiguy@yahoo.com
Steven P Watson steven@magelico.net
Stuart Kemp skemp@peter.bmc.com
Stuart Shelton stuart@shelton.me

1
TODO
View File

@@ -15,7 +15,6 @@ document the following in coreutils.texi:
mktemp
[
pinky
Also document the SELinux changes.
Suggestion from Paul Eggert:
More generally, there's not that much use for imaxtostr nowadays,

View File

@@ -231,11 +231,11 @@ fi
# version formats or redundant trailing .0 in bootstrap.conf.
# If we did want full compatibility then we should probably
# use m4_version_compare from autoconf.
sort_ver() { #sort -V is not generally available
sort_ver() { # sort -V is not generally available
ver1="$1"
ver2="$2"
#split on '.' and compare each component
# split on '.' and compare each component
i=1
while : ; do
p1=$(echo "$ver1" | cut -d. -f$i)
@@ -247,11 +247,11 @@ sort_ver() { #sort -V is not generally available
echo "$2 $1"
break
elif [ ! "$p1" = "$p2" ]; then
if [ "$p1" -gt "$p2" ] 2>/dev/null; then #numeric comparision
if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
echo "$2 $1"
elif [ "$p2" -gt "$p1" ] 2>/dev/null; then #numeric comparision
elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
echo "$1 $2"
else #numeric, then lexographic comparison
else # numeric, then lexicographic comparison
lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
if [ "$lp" = "$p2" ]; then
echo "$1 $2"
@@ -308,7 +308,7 @@ print_versions() {
echo "----------------------"
printf "$buildreq"
echo "----------------------"
#can't depend on column -t
# can't depend on column -t
}
if ! printf "$buildreq" | check_versions; then
@@ -359,8 +359,8 @@ case ${GNULIB_SRCDIR--} in
trap cleanup_gnulib 1 2 13 15
git clone --help|grep depth > /dev/null && depth='--depth 2' || depth=
git clone $depth git://git.sv.gnu.org/gnulib ||
git clone --help|grep depth > /dev/null && shallow='--depth 2' || shallow=
git clone $shallow git://git.sv.gnu.org/gnulib ||
cleanup_gnulib
trap - 1 2 13 15
@@ -686,12 +686,6 @@ find "$m4_base" "$source_base" \
-depth \( -name '*.m4' -o -name '*.[ch]' \) \
-type l -xtype l -delete > /dev/null 2>&1
# Use automake's --silent-rules option, if possible.
automake="${AUTOMAKE-automake} --add-missing --copy --force-missing"
(${AUTOMAKE-automake} --help) 2>&1 \
| grep -e '^ *--silent-rules' > /dev/null \
&& automake="$automake --silent-rules"
# Reconfigure, getting other files.
for command in \
@@ -699,7 +693,7 @@ for command in \
"${ACLOCAL-aclocal} --force -I m4" \
"${AUTOCONF-autoconf} --force" \
"${AUTOHEADER-autoheader} --force" \
"$automake"
"${AUTOMAKE-automake} --add-missing --copy --force-missing"
do
if test "$command" = libtool; then
use_libtool=0

View File

@@ -18,103 +18,226 @@
# We don't need these modules.
avoided_gnulib_modules='
--avoid=canonicalize-lgpl
--avoid=dummy
--avoid=lock
--avoid=canonicalize-lgpl
--avoid=dummy
--avoid=lock
'
# These modules are obsolete and can probably be removed soon,
# but leave them in for now to minimize changes.
obsolete_gnulib_modules='
atexit memchr memcmp memcpy memmove memset rename
strcspn strtod strtol utime
atexit
memchr
memcmp
memcpy
memmove
memset
rename
strcspn
strtod
strtol
'
# gnulib modules used by this package.
gnulib_modules="
$avoided_gnulib_modules
$obsolete_gnulib_modules
acl alloca announce-gen argmatch
argv-iter
assert
autobuild
backupfile base64
c-strcase c-strtod
c-strtold calloc canon-host canonicalize chown cloexec
config-h configmake
closein closeout
crypto/md5
crypto/sha1
crypto/sha256
crypto/sha512
cycle-check
d-ino d-type diacrit dirfd dirname dup2
error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl
file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu
fopen-safer
fprintftime
fseeko
fsusage ftruncate
ftello
fts getdate getgroups gethrxtime
gendocs
getline getloadavg getndelim2 getopt getpagesize getpass-gnu
gettext gettime gettimeofday getugroups getusershell
git-version-gen
gitlog-to-changelog
gnu-make gnumakefile gnupload
group-member hard-locale hash hash-pjw host-os human idcache
ignore-value
inttostr inttypes isapipe
lchmod lchown lib-ignore linebuffer link-follow
long-options lstat malloc
manywarnings
mbrtowc
mbswidth
memcasecmp memcmp2 mempcpy
memrchr mgetgroups
mkancesdirs mkdir mkdir-p mkstemp mktime modechange
mountlist mpsort obstack pathmax perl physmem
posix-shell
posixtm
posixver
progname
propername
putenv
quote quotearg raise readlink areadlink-with-size
randint
randperm
readtokens
readtokens0 readutmp
realloc regex rename-dest-slash rmdir rmdir-errno
root-dev-ino
rpmatch
safe-read same
save-cwd savedir savewd
selinux-at
settime sig2str sigaction ssize_t stat-macros
stat-time stdbool stdlib-safer stpcpy
stpncpy
strdup
strftime
strpbrk strtoimax strtoumax strverscmp sys_stat timespec tzset
unicodeio unistd-safer unlink-busy unlinkdir unlocked-io
uptime
useless-if-before-free
userspec utimecmp utimens
vasprintf-posix
vc-list-files
verify version-etc-fsf verror
warnings
wcwidth winsz-ioctl winsz-termios write-any-file
xalloc
xfreopen
xgetcwd xgethostname
xmemcoll xnanosleep
xprintf
xprintf-posix
xstrtod xstrtoimax
xstrtol xstrtold xstrtoumax yesno
$avoided_gnulib_modules
$obsolete_gnulib_modules
acl
alloca
announce-gen
areadlink-with-size
argmatch
argv-iter
assert
autobuild
backupfile
base64
c-strcase
c-strtod
c-strtold
calloc
canon-host
canonicalize
chown
cloexec
closein
closeout
config-h
configmake
crypto/md5
crypto/sha1
crypto/sha256
crypto/sha512
cycle-check
d-ino
d-type
diacrit
dirfd
dirname
dup2
error
euidaccess
exclude
exitfail
fchdir
fcntl
fcntl-safer
fdl
file-type
fileblocks
filemode
filenamecat
filevercmp
fnmatch-gnu
fopen-safer
fprintftime
fseeko
fsusage
ftello
ftruncate
fts
gendocs
getdate
getgroups
gethrxtime
getline
getloadavg
getndelim2
getopt
getpagesize
getpass-gnu
gettext
gettime
gettimeofday
getugroups
getusershell
git-version-gen
gitlog-to-changelog
gnu-make
gnumakefile
gnupload
group-member
hard-locale
hash
hash-pjw
host-os
human
idcache
ignore-value
inttostr
inttypes
isapipe
lchmod
lchown
lib-ignore
linebuffer
link-follow
long-options
lstat
maintainer-makefile
malloc
manywarnings
mbrtowc
mbsalign
mbswidth
memcasecmp
memcmp2
mempcpy
memrchr
mgetgroups
mkancesdirs
mkdir
mkdir-p
mkstemp
mktime
modechange
mountlist
mpsort
obstack
pathmax
perl
physmem
posix-shell
posixtm
posixver
progname
propername
putenv
quote
quotearg
raise
randint
randperm
readlink
readtokens
readtokens0
readutmp
realloc
regex
rename-dest-slash
rmdir
rmdir-errno
root-dev-ino
rpmatch
safe-read
same
save-cwd
savedir
savewd
selinux-at
settime
sig2str
sigaction
ssize_t
stat-macros
stat-time
stdbool
stdlib-safer
stpcpy
stpncpy
strdup
strftime
strpbrk
strtoimax
strtoumax
strverscmp
sys_stat
timespec
tzset
unicodeio
unistd-safer
unlink-busy
unlinkdir
unlocked-io
uptime
useless-if-before-free
userspec
utimecmp
utimens
vasprintf-posix
vc-list-files
verify
verror
version-etc-fsf
warnings
wcwidth
winsz-ioctl
winsz-termios
write-any-file
xalloc
xfreopen
xgetcwd
xgethostname
xmemcoll
xnanosleep
xprintf
xprintf-posix
xstrtod
xstrtoimax
xstrtol
xstrtold
xstrtoumax
yesno
"
# Other locale categories that need message catalogs.
@@ -177,7 +300,7 @@ gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
# Build prerequisites
buildreq="\
autoconf 2.61
automake 1.10a
automake 1.10b
autopoint -
bison -
gettext -

View File

@@ -1,283 +0,0 @@
## Vaucanson, a generic library for finite state machines.
## Copyright (C) 2006, 2007 The Vaucanson Group.
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
## The complete GNU General Public Licence Notice can be found as the
## `COPYING' file in the root directory.
## Override the definition from Automake to generate a log file with
## failed tests. It also supports parallel make checks.
##
## This file provides special support for "unit tests", that is to
## say, tests that (once run) no longer need to be re-compiled and
## re-run at each "make check", unless their sources changed. To
## enable unit-test supports, define LAZY_TEST_SUITE. In such a
## setting, that heavily relies on correct dependencies, its users may
## prefer to define EXTRA_PROGRAMS instead of check_PROGRAMS, because
## it allows intertwined compilation and execution of the tests.
## Sometimes this helps catching errors earlier (you don't have to
## wait for all the tests to be compiled).
##
## Define TEST_SUITE_LOG to be the name of the global log to create.
## Define TEST_LOGS to the set of logs to include in it. One possibility
## is $(TESTS:.test=.log).
##
## In addition to the magic "exit 77 means SKIP" feature (which was
## imported from automake), there is a magic "exit 177 means FAIL" feature
## which is useful if you need to issue a hard error no matter whether the
## test is XFAIL or not.
# Use a POSIX-compatible shell if available, as this file uses
# features of the POSIX shell that are not supported by some standard
# shell implementations (e.g., Solaris 10 /bin/sh).
SHELL = $(PREFERABLY_POSIX_SHELL)
# Set this to `false' to disable hard errors.
ENABLE_HARD_ERRORS = :
## We use GNU Make extensions (%-rules) inside GNU_MAKE checks,
## and we override check-TESTS.
AUTOMAKE_OPTIONS += -Wno-portability -Wno-override
# Restructured Text title and section.
am__rst_title = sed 's/.*/ & /;h;s/./=/g;p;x;p;g;p;s/.*//'
am__rst_section = sed 'p;s/./=/g;p;g'
# Put stdin (possibly several lines separated by ". ") in a box.
am__text_box = $(AWK) '{gsub ("\\. ", "\n"); print $$0; }' | \
$(AWK) ' \
max < length($$0) { \
final= final (final ? "\n" : "") " " $$0; \
max = length($$0); \
} \
END { \
for (i = 0; i < max + 2 ; ++i) \
line = line "="; \
print line; \
print final; \
print line; \
}'
# If stdout is a tty and TERM is smart then use colors. If test -t or
# tput are not supported then this fails; a conservative approach. Of
# course do not redirect stdout here, just stderr...
am__tty_colors = \
red=; \
grn=; \
lgn=; \
blu=; \
std=; \
test "X$$TERM" != Xdumb && \
test -t 1 2>/dev/null && \
tput bold 1 >/dev/null 2>&1 && \
tput setaf 1 >/dev/null 2>&1 && \
tput sgr0 >/dev/null 2>&1 && \
{ \
red=$$(tput setaf 1); \
grn=$$(tput setaf 2); \
lgn=$$(tput bold)$$(tput setaf 2); \
blu=$$(tput setaf 4); \
std=$$(tput sgr0); \
}
# Solaris 10 'make', and several other traditional 'make' implementations,
# pass "-e" to $(SHELL). This contradicts POSIX. Work around the problem
# by disabling -e (using the XSI extension "set +e") if it's set.
SH_E_WORKAROUND = case $$- in *e*) set +e;; esac
# Emulate dirname with sed.
_d_no_slash = s,^[^/]*$$,.,
_d_strip_trailing = s,\([^/]\)//*$$,\1,
_d_abs_trivial = s,^//*[^/]*$$,/,
_d_rm_basename = s,\([^/]\)//*[^/]*$$,\1,
_dirname = \
sed '$(_d_no_slash);$(_d_strip_trailing);$(_d_abs_trivial);$(_d_rm_basename)'
# To be inserted before the command running the test. Creates the
# directory for the log if needed. Stores in $dir the directory
# containing $src, and passes TESTS_ENVIRONMENT.
# Save and restore TERM around use of TESTS_ENVIRONMENT,
# in case that unsets it.
am__check_pre = \
$(SH_E_WORKAROUND); \
tst=`echo "$$src" | sed 's|^.*/||'`; \
rm -f $@-t; \
trap 'st=$$?; rm -f '\''$(abs_builddir)/$@-t'\''; (exit $$st); exit $$st' \
1 2 13 15; \
$(mkdir_p) "$$(echo '$@'|$(_dirname))" || exit; \
if test -f "./$$src"; then dir=./; \
elif test -f "$$src"; then dir=; \
else dir="$(srcdir)/"; fi; \
__SAVED_TERM=$$TERM; \
$(TESTS_ENVIRONMENT)
# To be appended to the command running the test. Handles the stdout
# and stderr redirection, and catch the exit status.
am__check_post = \
>$@-t 2>&1; \
estatus=$$?; \
if test $$estatus -eq 177; then \
$(ENABLE_HARD_ERRORS) || estatus=1; \
fi; \
TERM=$$__SAVED_TERM; export TERM; \
$(am__tty_colors); \
xfailed=PASS; \
for xfail in : $(XFAIL_TESTS); do \
case $$src in \
$$xfail | */$$xfail) xfailed=XFAIL; break; \
esac; \
done; \
case $$estatus:$$xfailed in \
0:XFAIL) col=$$red; res=XPASS;; \
0:*) col=$$grn; res=PASS ;; \
77:*) col=$$blu; res=SKIP ;; \
177:*) col=$$red; res=FAIL ;; \
*:XFAIL) col=$$lgn; res=XFAIL;; \
*:*) col=$$red; res=FAIL ;; \
esac; \
echo "$${col}$$res$${std}: $@"; \
echo "$$res: $@ (exit: $$estatus)" | \
$(am__rst_section) >$@; \
cat $@-t >>$@; \
rm $@-t
SUFFIXES += .html .log
# From a test (with no extension) to a log file.
if GNU_MAKE
%.log: %
@src='$<'; $(am__check_pre) "$$dir$$src" $(am__check_post)
else
# With POSIX 'make', inference rules cannot have FOO.log depend on FOO.
# Work around the problem by calculating the dependency dynamically, and
# then invoking a submake with the calculated dependency.
CHECK-FORCE:
DEPENDENCY = CHECK-FORCE
$(TEST_LOGS): $(DEPENDENCY)
@if test '$(DEPENDENCY)' = CHECK-FORCE; then \
dst=$@; src=$${dst%.log}; \
test -x "$$src" || src='$(srcdir)'/$$src; \
exec $(MAKE) $(AM_MAKEFLAGS) DEPENDENCY="$$src" $@; \
else \
src='$(DEPENDENCY)'; \
$(am__check_pre) "$$dir$$src" $(am__check_post); \
fi
endif
#TEST_LOGS = $(TESTS:.test=.log)
TEST_SUITE_LOG = test-suite.log
$(TEST_SUITE_LOG): $(TEST_LOGS)
@$(SH_E_WORKAROUND); \
results=$$(for f in $(TEST_LOGS); do sed 1q $$f; done); \
all=$$(echo "$$results" | wc -l | sed -e 's/^[ \t]*//'); \
fail=$$(echo "$$results" | grep -c '^FAIL'); \
pass=$$(echo "$$results" | grep -c '^PASS'); \
skip=$$(echo "$$results" | grep -c '^SKIP'); \
xfail=$$(echo "$$results" | grep -c '^XFAIL'); \
xpass=$$(echo "$$results" | grep -c '^XPASS'); \
failures=$$(expr $$fail + $$xpass); \
case fail=$$fail:xpass=$$xpass:xfail=$$xfail in \
fail=0:xpass=0:xfail=0) \
msg="All $$all tests passed. "; \
exit=true;; \
fail=0:xpass=0:xfail=*) \
msg="All $$all tests behaved as expected"; \
msg="$$msg ($$xfail expected failures). "; \
exit=true;; \
fail=*:xpass=0:xfail=*) \
msg="$$fail of $$all tests failed. "; \
exit=false;; \
fail=*:xpass=*:xfail=*) \
msg="$$failures of $$all tests did not behave as expected"; \
msg="$$msg ($$xpass unexpected passes). "; \
exit=false;; \
*) \
echo >&2 "incorrect case"; exit 4;; \
esac; \
if test "$$skip" -ne 0; then \
msg="$$msg($$skip tests were not run). "; \
fi; \
if test "$$failures" -ne 0; then \
{ \
echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
$(am__rst_title); \
echo "$$msg"; \
echo; \
echo ".. contents:: :depth: 2"; \
echo; \
for f in $(TEST_LOGS); \
do \
case $$(sed 1q $$f) in \
SKIP:*|PASS:*|XFAIL:*);; \
*) echo; cat $$f;; \
esac; \
done; \
} >$(TEST_SUITE_LOG).tmp; \
mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
msg="$${msg}See $(subdir)/$(TEST_SUITE_LOG). "; \
if test -n "$(PACKAGE_BUGREPORT)"; then \
msg="$${msg}Please report it to $(PACKAGE_BUGREPORT). "; \
fi; \
fi; \
$(am__tty_colors); \
if $$exit; then echo $$grn; else echo $$red; fi; \
echo "$$msg" | $(am__text_box); \
echo $$std; \
test x"$$VERBOSE" = x || $$exit || cat $(TEST_SUITE_LOG); \
$$exit
# if test x"$$VERBOSE" != x && ! $exit; then
# Run all the tests.
check-TESTS:
@if test -z '$(LAZY_TEST_SUITE)'; then \
rm -f $(TEST_SUITE_LOG) $(TEST_LOGS); \
fi
@$(MAKE) $(TEST_SUITE_LOG)
## -------------- ##
## Produce HTML. ##
## -------------- ##
TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
.log.html:
@for r2h in $(RST2HTML) $$RST2HTML rst2html rst2html.py; \
do \
if ($$r2h --version) >/dev/null 2>&1; then \
R2H=$$r2h; \
fi; \
done; \
if test -z "$$R2H"; then \
echo >&2 "cannot find rst2html, cannot create $@"; \
exit 2; \
fi; \
$$R2H $< >$@.tmp
@mv $@.tmp $@
# Be sure to run check-TESTS first, and then to convert the result.
# Beware of concurrent executions. And expect check-TESTS to fail.
check-html:
@if $(MAKE) $(AM_MAKEFLAGS) check-TESTS; then :; else \
rv=$$?; \
$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML); \
exit $$rv; \
fi
.PHONY: check-html
## ------- ##
## Clean. ##
## ------- ##
check-clean:
rm -f $(CHECK_CLEANFILES) $(TEST_SUITE_LOG) $(TEST_SUITE_HTML) $(TEST_LOGS)
.PHONY: check-clean
clean-local: check-clean

22
cfg.mk
View File

@@ -31,21 +31,20 @@ url_dir_list = \
gpg_key_ID = B9AB9A16
# Tests not to run as part of "make distcheck".
# Exclude changelog-check here so that there's less churn in ChangeLog
# files -- otherwise, you'd need to have the upcoming version number
# at the top of the file for each `make distcheck' run.
local-checks-to-skip = changelog-check strftime-check
local-checks-to-skip += patch-check
local-checks-to-skip = strftime-check
# The local directory containing the checked-out copy of gnulib used in this
# release. Used solely to get gnulib's SHA1 for the "announcement" target.
gnulib_dir = /gnulib
# release. Used to get gnulib's SHA1 for the "announcement" target and
# for signing release tags.
gnulib_dir = gnulib
# Now that we have better (check.mk) tests, make this the default.
# Tools used to bootstrap this package, used for "announcement".
bootstrap-tools = autoconf,automake,gnulib,bison
# Now that we have better tests, make this the default.
export VERBOSE = yes
old_NEWS_hash = fa6cba1740b3f385520c1b54d90859ca
old_NEWS_hash = 40279d1aa0a0ef3ca9d1f0a001eb9e2f
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
dd = $(srcdir)/src/dd.c
@@ -167,6 +166,7 @@ sc_sun_os_names:
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
exit 1; } || :
ALL_RECURSIVE_TARGETS += sc_tight_scope
sc_tight_scope:
@$(MAKE) -C src $@
@@ -195,3 +195,5 @@ sc_strftime_check:
diff -u $@-src $@-info || exit 1; \
rm -f $@-src $@-info; \
fi
include $(srcdir)/dist-check.mk

View File

@@ -32,7 +32,8 @@ AC_CONFIG_SRCDIR([src/ls.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
AM_INIT_AUTOMAKE([1.10a dist-xz])
AM_INIT_AUTOMAKE([1.10b dist-xz color-tests parallel-tests])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
AC_PROG_CC_STDC
AM_PROG_CC_C_O

135
dist-check.mk Normal file
View File

@@ -0,0 +1,135 @@
# Most of this is probably too coreutils-centric to be useful to other packages.
warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
bin=bin-$$$$
write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
TMPDIR ?= /tmp
t=$(TMPDIR)/$(PACKAGE)/test
pfx=$(t)/i
# More than once, tainted build and source directory names would
# have caused at least one "make check" test to apply "chmod 700"
# to all directories under $HOME. Make sure it doesn't happen again.
tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$")
t_prefix = $(tp)/a
t_taint = '$(t_prefix) b'
fake_home = $(tp)/home
# Ensure that tests run from tainted build and src dir names work,
# and don't affect anything in $HOME. Create witness files in $HOME,
# record their attributes, and build/test. Then ensure that the
# witnesses were not affected.
ALL_RECURSIVE_TARGETS += taint-distcheck
taint-distcheck: $(DIST_ARCHIVES)
test -d $(t_taint) && chmod -R 700 $(t_taint) || :
-rm -rf $(t_taint) $(fake_home)
mkdir -p $(t_prefix) $(t_taint) $(fake_home)
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t_taint) -zxf $(distdir).tar.gz
mkfifo $(fake_home)/fifo
touch $(fake_home)/f
mkdir -p $(fake_home)/d/e
ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
cd $(t_taint)/$(distdir) \
&& ./configure \
&& $(MAKE) \
&& HOME=$(fake_home) $(MAKE) check \
&& ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
&& diff $(tp)/.ls-before $(tp)/.ls-after \
&& test -d $(t_prefix)
rm -rf $(tp)
# Verify that a twisted use of --program-transform-name=PROGRAM works.
define install-transform-check
echo running install-transform-check \
&& rm -rf $(pfx) \
&& $(MAKE) program_transform_name='s/.*/zyx/' \
prefix=$(pfx) install \
&& test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
&& test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
endef
# Install, then verify that all binaries and man pages are in place.
# Note that neither the binary, ginstall, nor the ].1 man page is installed.
define my-instcheck
$(MAKE) prefix=$(pfx) install \
&& test ! -f $(pfx)/bin/ginstall \
&& { fail=0; \
for i in $(built_programs); do \
test "$$i" = ginstall && i=install; \
for j in "$(pfx)/bin/$$i" \
"$(pfx)/share/man/man1/$$i.1"; do \
case $$j in *'[.1') continue;; esac; \
test -f "$$j" && : \
|| { echo "$$j not installed"; fail=1; }; \
done; \
done; \
test $$fail = 1 && exit 1 || :; \
}
endef
define coreutils-path-check
{ \
if test -f $(srcdir)/src/true.c; then \
fail=1; \
mkdir $(bin) \
&& ($(write_loser)) > $(bin)/loser \
&& chmod a+x $(bin)/loser \
&& for i in $(built_programs); do \
case $$i in \
rm|expr|basename|echo|sort|ls|tr);; \
cat|dirname|mv|wc);; \
*) ln $(bin)/loser $(bin)/$$i;; \
esac; \
done \
&& ln -sf ../src/true $(bin)/false \
&& PATH=`pwd`/$(bin)$(PATH_SEPARATOR)$$PATH \
$(MAKE) -C tests check \
&& { test -d gnulib-tests \
&& $(MAKE) -C gnulib-tests check \
|| :; } \
&& rm -rf $(bin) \
&& fail=0; \
else \
fail=0; \
fi; \
test $$fail = 1 && exit 1 || :; \
}
endef
# Use -Wformat -Werror to detect format-string/arg-list mismatches.
# Also, check for shadowing problems with -Wshadow, and for pointer
# arithmetic problems with -Wpointer-arith.
# These CFLAGS are pretty strict. If you build this target, you probably
# have to have a recent version of gcc and glibc headers.
# The hard-linking for-loop below ensures that there is a bin/ directory
# full of all of the programs under test (except the ones that are required
# for basic Makefile rules), all symlinked to the just-built "false" program.
# This is to ensure that if ever a test neglects to make PATH include
# the build srcdir, these always-failing programs will run.
# Otherwise, it is too easy to test the wrong programs.
# Note that "false" itself is a symlink to true, so it too will malfunction.
ALL_RECURSIVE_TARGETS += my-distcheck
my-distcheck: $(DIST_ARCHIVES) $(local-check)
$(MAKE) syntax-check
$(MAKE) check
-rm -rf $(t)
mkdir -p $(t)
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
cd $(t)/$(distdir) \
&& ./configure --disable-nls \
&& $(MAKE) CFLAGS='$(warn_cflags)' \
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
&& $(MAKE) dvi \
&& $(install-transform-check) \
&& $(my-instcheck) \
&& $(coreutils-path-check) \
&& $(MAKE) distclean
(cd $(t) && mv $(distdir) $(distdir).old \
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
-rm -rf $(t)
@echo "========================"; \
echo "$(distdir).tar.gz is ready for distribution"; \
echo "========================"

View File

@@ -60,45 +60,45 @@ syntax_checks = \
# List words/regexps here that should not appear in the texinfo documentation.
check-texinfo: $(syntax_checks)
@fail=0; \
grep '@url{' $(srcdir)/*.texi && fail=1; \
grep '\$$@"' $(srcdir)/*.texi && fail=1; \
grep -n '[^[:punct:]]@footnote' $(srcdir)/*.texi && fail=1; \
grep -n filename $(srcdir)/*.texi \
| $(EGREP) -v 'setfilename|[{]filename[}]' \
&& fail=1; \
$(PERL) -e 1 2> /dev/null && { $(PERL) -ne \
$(AM_V_GEN)fail=0; \
grep '@url{' $(srcdir)/*.texi && fail=1; \
grep '\$$@"' $(srcdir)/*.texi && fail=1; \
grep -n '[^[:punct:]]@footnote' $(srcdir)/*.texi && fail=1; \
grep -n filename $(srcdir)/*.texi \
| $(EGREP) -v 'setfilename|[{]filename[}]' \
&& fail=1; \
$(PERL) -e 1 2> /dev/null && { $(PERL) -ne \
'/\bPOSIX\b/ && !/\@acronym{POSIX}/ && !/^\* / || /{posix}/ and print,exit 1' \
$(srcdir)/*.texi 2> /dev/null || fail=1; }; \
$(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi && fail=1; \
$(EGREP) -i '$(_W)path(name)?s?$(W_)' $(srcdir)/*.texi \
$(srcdir)/*.texi 2> /dev/null || fail=1; }; \
$(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi && fail=1; \
$(EGREP) -i '$(_W)path(name)?s?$(W_)' $(srcdir)/*.texi \
| $(EGREP) -v 'search path|@vindex PATH$$|@env[{]PATH[}]' && fail=1; \
exit $$fail
# Use `time zone', not `timezone'.
sc-avoid-timezone:
@$(EGREP) timezone $(srcdir)/*.texi && exit 1 || :
$(AM_V_GEN)$(EGREP) timezone $(srcdir)/*.texi && exit 1 || :
# Check for insufficient exponent grouping, e.g.,
# @math{2^64} should be @math{2^{64}}.
sc-exponent-grouping:
@$(EGREP) '\{.*\^[0-9][0-9]' $(srcdir)/*.texi && exit 1 || :
$(AM_V_GEN)$(EGREP) '\{.*\^[0-9][0-9]' $(srcdir)/*.texi && exit 1 || :
# E.g., use @sc{nul}, not NUL.
sc-use-small-caps-NUL:
@$(EGREP) '$(_W)NUL$(W_)' $(srcdir)/*.texi && exit 1 || :
$(AM_V_GEN)$(EGREP) '$(_W)NUL$(W_)' $(srcdir)/*.texi && exit 1 || :
# Say I/O, not IO.
sc-avoid-io:
@$(EGREP) '$(_W)IO$(W_)' $(srcdir)/*.texi && exit 1 || :
$(AM_V_GEN)$(EGREP) '$(_W)IO$(W_)' $(srcdir)/*.texi && exit 1 || :
# I prefer nonzero over non-zero.
sc-avoid-non-zero:
@$(EGREP) non-zero $(srcdir)/*.texi && exit 1 || :
$(AM_V_GEN)$(EGREP) non-zero $(srcdir)/*.texi && exit 1 || :
# Use `zeros', not `zeroes' (nothing wrong with `zeroes'. just be consistent).
sc-avoid-zeroes:
@$(EGREP) -i '$(_W)zeroes$(W_)' $(srcdir)/*.texi && exit 1 || :
$(AM_V_GEN)$(EGREP) -i '$(_W)zeroes$(W_)' $(srcdir)/*.texi && exit 1 || :
# ME = $(subdir)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ME = doc/Makefile
@@ -115,7 +115,7 @@ find_upper_case_var = \
} \
END {$$m and (warn "$(ME): do not use upper case in \@var{...}\n"), exit 1}'
sc-lower-case-var:
@$(PERL) -e 1 2> /dev/null && \
$(PERL) -lne $(find_upper_case_var) $(srcdir)/*.texi
$(AM_V_GEN)$(PERL) -e 1 \
&& $(PERL) -lne $(find_upper_case_var) $(srcdir)/*.texi
check: check-texinfo

View File

@@ -1,8 +0,0 @@
perl -pi -e \
's/\@code\{('"$(echo cp dd df dir dircolors du install ln ls mkdir mkfifo mknod mv shred touch vdir|tr ' ' '|')"')\}/\@command{$1}/' coreutils.texi
perl -pi -e \
's/\@code\{('"$(echo cp dd df dir dircolors du install ln ls mkdir mkfifo mknod mv shred touch vdir|tr ' ' '|')"')\}/\@command{$1}/' coreutils.texi
regex=$((textutils; shellutils) | tr -s ' ' '|')
perl -pi -e 's/\@code\{('"$regex"')\}/\@command{$1}/' coreutils.texi

View File

@@ -1139,12 +1139,19 @@ sometimes need random data to do their work. For example, @samp{sort
-R} must choose a hash function at random, and it needs random data to
make this selection.
Normally these commands use the device file @file{/dev/urandom} as the
By default these commands use an internal pseudorandom generator
initialized by a small amount of entropy, but can be directed to use
an external source with the @option{--random-source=@var{file}} option.
An error is reported if @var{file} does not contain enough bytes.
For example, the device file @file{/dev/urandom} could be used as the
source of random data. Typically, this device gathers environmental
noise from device drivers and other sources into an entropy pool, and
uses the pool to generate random bits. If the pool is short of data,
the device reuses the internal pool to produce more bits, using a
cryptographically secure pseudorandom number generator.
cryptographically secure pseudorandom number generator. But be aware
that this device is not designed for bulk random data generation
and is relatively slow.
@file{/dev/urandom} suffices for most practical uses, but applications
requiring high-value or long-term protection of private data may
@@ -1152,21 +1159,10 @@ require an alternate data source like @file{/dev/random} or
@file{/dev/arandom}. The set of available sources depends on your
operating system.
To use such a source, specify the @option{--random-source=@var{file}}
option, e.g., @samp{shuf --random-source=/dev/random}. The contents
of @var{file} should be as random as possible. An error is reported
if @var{file} does not contain enough bytes to randomize the input
adequately.
To reproduce the results of an earlier invocation of a command, you
can save some random data into a file and then use that file as the
random source in earlier and later invocations of the command.
Some old-fashioned or stripped-down operating systems lack support for
@command{/dev/urandom}. On these systems commands like @command{shuf}
by default fall back on an internal pseudorandom generator initialized
by a small amount of entropy.
@node Target directory
@section Target directory
@@ -6540,6 +6536,16 @@ it also affects the HP-UX @command{ls} program.
@optSi
@item -Z
@itemx --context
@opindex -Z
@opindex --context
@cindex SELinux
@cindex security context
Display the SELinux security context or @samp{?} if none is found.
When used with the @option{-l} option, print the security context
to the left of the size column.
@end table
@@ -8045,6 +8051,15 @@ ownership of installed files or directories to @var{owner}. The default
is @code{root}. @var{owner} may be either a user name or a numeric user
ID.
@item --preserve-context
@opindex --preserve-context
@cindex SELinux
@cindex security context
Preserve the SELinux security context of files and directories.
Failure to preserve the context in all of the files or directories
will result in an exit status of 1. If SELinux is disabled then
print a warning and ignore the option.
@item -p
@itemx --preserve-timestamps
@opindex -p
@@ -8083,6 +8098,16 @@ Program used to strip binaries.
@opindex --verbose
Print the name of each file before copying it.
@item -Z @var{context}
@itemx --context=@var{context}
@opindex -Z
@opindex --context
@cindex SELinux
@cindex security context
Set the default SELinux security context to be used for any
created files and directories. If SELinux is disabled then
print a warning and ignore the option.
@end table
@exitstatus
@@ -8917,6 +8942,15 @@ newly-created parent directories are inherited.
@opindex --verbose
Print a message for each created directory. This is most useful with
@option{--parents}.
@item -Z @var{context}
@itemx --context=@var{context}
@opindex -Z
@opindex --context
@cindex SELinux
@cindex security context
Set the default SELinux security context to be used for created directories.
@end table
@exitstatus
@@ -8956,6 +8990,14 @@ Set the mode of created FIFOs to @var{mode}, which is symbolic as in
for the point of departure. @var{mode} should specify only file
permission bits. @xref{File permissions}.
@item -Z @var{context}
@itemx --context=@var{context}
@opindex -Z
@opindex --context
@cindex SELinux
@cindex security context
Set the default SELinux security context to be used for created FIFOs.
@end table
@exitstatus
@@ -9031,6 +9073,14 @@ Set the mode of created files to @var{mode}, which is symbolic as in
@var{mode} should specify only file permission bits.
@xref{File permissions}.
@item -Z @var{context}
@itemx --context=@var{context}
@opindex -Z
@opindex --context
@cindex SELinux
@cindex security context
Set the default SELinux security context to be used for created files.
@end table
@exitstatus
@@ -12737,6 +12787,16 @@ Print the real, instead of effective, user or group ID. Requires
@opindex --user
Print only the user ID.
@item -Z
@itemx --context
@opindex -Z
@opindex --context
@cindex SELinux
@cindex security context
Print only the security context of the current user.
If SELinux is disabled then print a warning and
set the exit status to 1.
@end table
@exitstatus
@@ -15421,7 +15481,7 @@ that your spelling is incorrect. So, we need a dictionary.
The conventional location for a dictionary is @file{/usr/dict/words}.
On my GNU/Linux system,@footnote{Redhat Linux 6.1, for the November 2000
revision of this article.}
this is a is a sorted, 45,402 word dictionary.
this is a sorted, 45,402 word dictionary.
Now, how to compare our file with the dictionary? As before, we generate
a sorted list of words, one per line:

236
gl/lib/mbsalign.c Normal file
View File

@@ -0,0 +1,236 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Pádraig Brady. */
#include <config.h>
#include "mbsalign.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <limits.h>
#include <wchar.h>
#include <wctype.h>
#ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/* Replace non printable chars.
Return 1 if replacement made, 0 otherwise. */
static bool
wc_ensure_printable (wchar_t *wchars)
{
bool replaced = false;
wchar_t *wc = wchars;
while (*wc)
{
if (!iswprint ((wint_t) *wc))
{
*wc = 0xFFFD; /* L'\uFFFD' (replacement char) */
replaced = true;
}
wc++;
}
return replaced;
}
/* Truncate wchar string to width cells.
* Returns number of cells used. */
static size_t
wc_truncate (wchar_t *wc, size_t width)
{
size_t cells = 0;
int next_cells = 0;
while (*wc)
{
next_cells = wcwidth (*wc);
if (next_cells == -1) /* non printable */
{
*wc = 0xFFFD; /* L'\uFFFD' (replacement char) */
next_cells = 1;
}
if (cells + next_cells > width)
break;
cells += next_cells;
wc++;
}
*wc = L'\0';
return cells;
}
/* FIXME: move this function to gnulib as it's missing on:
OpenBSD 3.8, IRIX 5.3, Solaris 2.5.1, mingw, BeOS */
static int
rpl_wcswidth (const wchar_t *s, size_t n)
{
int ret = 0;
while (n-- > 0 && *s != L'\0')
{
int nwidth = wcwidth (*s++);
if (nwidth == -1) /* non printable */
return -1;
if (ret > (INT_MAX - nwidth)) /* overflow */
return -1;
ret += nwidth;
}
return ret;
}
/* Write N_SPACES space characters to DEST while ensuring
nothing is written beyond DEST_END. A terminating NUL
is always added to DEST.
A pointer to the terminating NUL is returned. */
static char*
mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces)
{
/* FIXME: Should we pad with "figure space" (\u2007)
if non ascii data present? */
while (n_spaces-- && (dest < dest_end))
*dest++ = ' ';
*dest = '\0';
return dest;
}
/* Align a string, SRC, in a field of *WIDTH columns, handling multi-byte
characters; write the result into the DEST_SIZE-byte buffer, DEST.
ALIGNMENT specifies whether to left- or right-justify or to center.
If SRC requires more than *WIDTH columns, truncate it to fit.
When centering, the number of trailing spaces may be one less than the
number of leading spaces. The FLAGS parameter is unused at present.
Return the length in bytes required for the final result, not counting
the trailing NUL. A return value of DEST_SIZE or larger means there
wasn't enough space. DEST will be NUL terminated in any case.
Return (size_t) -1 upon error (invalid multi-byte sequence in SRC,
or malloc failure).
Update *WIDTH to indicate how many columns were used before padding. */
size_t
mbsalign (const char *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags)
{
size_t ret = -1;
size_t src_size = strlen (src) + 1;
char *newstr = NULL;
wchar_t *str_wc = NULL;
const char *str_to_print = src;
size_t n_cols = src_size - 1;
size_t n_used_bytes = n_cols; /* Not including NUL */
size_t n_spaces = 0;
bool conversion = false;
bool wc_enabled = false;
/* In multi-byte locales convert to wide characters
to allow easy truncation. Also determine number
of screen columns used. */
if (MB_CUR_MAX > 1)
{
size_t src_chars = mbstowcs (NULL, src, 0);
if (src_chars == (size_t) -1)
goto mbsalign_cleanup;
src_chars += 1; /* make space for NUL */
str_wc = malloc (src_chars * sizeof (wchar_t));
if (str_wc == NULL)
goto mbsalign_cleanup;
if (mbstowcs (str_wc, src, src_chars) > 0)
{
str_wc[src_chars - 1] = L'\0';
wc_enabled = true;
conversion = wc_ensure_printable (str_wc);
n_cols = rpl_wcswidth (str_wc, src_chars);
}
}
/* If we transformed or need to truncate the source string
then create a modified copy of it. */
if (conversion || (n_cols > *width))
{
newstr = malloc (src_size);
if (newstr == NULL)
goto mbsalign_cleanup;
str_to_print = newstr;
if (wc_enabled)
{
n_cols = wc_truncate (str_wc, *width);
n_used_bytes = wcstombs (newstr, str_wc, src_size);
}
else
{
n_cols = *width;
n_used_bytes = n_cols;
memcpy (newstr, src, n_cols);
newstr[n_cols] = '\0';
}
}
if (*width > n_cols)
n_spaces = *width - n_cols;
/* indicate to caller how many cells needed (not including padding). */
*width = n_cols;
/* indicate to caller how many bytes needed (not including NUL). */
ret = n_used_bytes + (n_spaces * 1);
/* Write as much NUL terminated output to DEST as possible. */
if (dest_size != 0)
{
char *dest_end = dest + dest_size - 1;
size_t start_spaces = n_spaces / 2 + n_spaces % 2;
size_t end_spaces = n_spaces / 2;
switch (align)
{
case MBS_ALIGN_CENTER:
start_spaces = n_spaces / 2 + n_spaces % 2;
end_spaces = n_spaces / 2;
break;
case MBS_ALIGN_LEFT:
start_spaces = 0;
end_spaces = n_spaces;
break;
case MBS_ALIGN_RIGHT:
start_spaces = n_spaces;
end_spaces = 0;
break;
}
dest = mbs_align_pad (dest, dest_end, start_spaces);
dest = mempcpy(dest, str_to_print, MIN (n_used_bytes, dest_end - dest));
dest = mbs_align_pad (dest, dest_end, end_spaces);
}
mbsalign_cleanup:
free (str_wc);
free (newstr);
return ret;
}
/*
* Local variables:
* indent-tabs-mode: nil
* End:
*/

23
gl/lib/mbsalign.h Normal file
View File

@@ -0,0 +1,23 @@
/* Align/Truncate a string in a given screen width
Copyright (C) 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stddef.h>
typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
size_t
mbsalign (const char *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags);

View File

@@ -81,10 +81,16 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
while (1)
{
GETGROUPS_T *h;
int last_n_groups = max_n_groups;
/* getgrouplist updates max_n_groups to num required. */
ng = getgrouplist (username, gid, g, &max_n_groups);
/* Some systems (like Darwin) have a bug where they
never increase max_n_groups. */
if (ng < 0 && last_n_groups == max_n_groups)
max_n_groups *= 2;
if ((h = realloc_groupbuf (g, max_n_groups)) == NULL)
{
int saved_errno = errno;
@@ -97,7 +103,9 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
if (0 <= ng)
{
*groups = g;
return ng;
/* On success some systems just return 0 from getgrouplist,
so return max_n_groups rather than ng. */
return max_n_groups;
}
}
}

View File

@@ -50,10 +50,6 @@ main (int argc, char **argv)
#include "xalloc.h"
#ifndef MAX
# define MAX(a,b) ((a) < (b) ? (b) : (a))
#endif
/* A source of random data for generating random integers. */
struct randint_source
{

View File

@@ -39,6 +39,16 @@
#include "unlocked-io.h"
#include "xalloc.h"
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x) /* empty */
# endif
#endif
#ifndef ATTRIBUTE_NORETURN
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
#endif
#ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
@@ -50,10 +60,6 @@
# define ALIGNED_POINTER(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
#endif
#ifndef DEFAULT_RANDOM_FILE
# define DEFAULT_RANDOM_FILE "/dev/urandom"
#endif
/* The maximum buffer size used for reads of random data. Using the
value 2 * ISAAC_BYTES makes this the largest power of two that
would not otherwise cause struct randread_source to grow. */
@@ -62,10 +68,8 @@
/* A source of random data for generating random buffers. */
struct randread_source
{
/* Stream to read random bytes from. If null, the behavior is
undefined; the current implementation uses ISAAC in this case,
but this is for old-fashioned implementations that lack
/dev/urandom and callers should not rely on this. */
/* Stream to read random bytes from. If null, the current
implementation uses an internal PRNG (ISAAC). */
FILE *source;
/* Function to call, and its argument, if there is an input error or
@@ -106,7 +110,7 @@ struct randread_source
/* The default error handler. */
static void
static void ATTRIBUTE_NORETURN
randread_error (void const *file_name)
{
if (file_name)
@@ -147,18 +151,14 @@ randread_new (char const *name, size_t bytes_bound)
return simple_new (NULL, NULL);
else
{
char const *file_name = (name ? name : DEFAULT_RANDOM_FILE);
FILE *source = fopen_safer (file_name, "rb");
FILE *source = NULL;
struct randread_source *s;
if (! source)
{
if (name)
return NULL;
file_name = NULL;
}
if (name)
if (! (source = fopen_safer (name, "rb")))
return NULL;
s = simple_new (source, file_name);
s = simple_new (source, name);
if (source)
setvbuf (source, s->buf.c, _IOFBF, MIN (sizeof s->buf.c, bytes_bound));

26
gl/modules/mbsalign Normal file
View File

@@ -0,0 +1,26 @@
Description:
Align/Truncate a string in a given screen width.
Files:
lib/mbsalign.c
lib/mbsalign.h
Depends-on:
wchar
wctype
wcwidth
mempcpy
configure.ac:
Makefile.am:
lib_SOURCES += mbsalign.c mbsalign.h
Include:
"mbsalign.h"
License:
LGPL
Maintainer:
Pádraig Brady

2
gnulib

Submodule gnulib updated: 5a1286a9f8...278d609ead

View File

@@ -1,6 +1 @@
include gnulib.mk
TEST_LOGS = $(TESTS:=.log)
# Parallel replacement of Automake's check-TESTS target.
include $(top_srcdir)/build-aux/check.mk

View File

@@ -1,74 +0,0 @@
/* stdopen.c - ensure that the three standard file descriptors are in use
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Paul Eggert and Jim Meyering. */
#include <config.h>
#include "stdopen.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
/* Try to ensure that all of the standard file numbers (0, 1, 2)
are in use. Without this, each application would have to guard
every call to open, dup, fopen, etc. with tests to ensure they
don't use one of the special file numbers when opening a file.
Return false if at least one of the file descriptors is initially
closed and an attempt to reopen it fails. Otherwise, return true. */
bool
stdopen (void)
{
int fd;
bool ok = true;
for (fd = 0; fd <= 2; fd++)
{
if (fcntl (fd, F_GETFD) < 0)
{
if (errno != EBADF)
ok = false;
else
{
static const int contrary_mode[]
= { O_WRONLY, O_RDONLY, O_RDONLY };
int mode = contrary_mode[fd];
int new_fd;
/* Open /dev/null with the contrary mode so that the typical
read (stdin) or write (stdout, stderr) operation will fail.
With descriptor 0, we can do even better on systems that
have /dev/full, by opening that write-only instead of
/dev/null. The only drawback is that a write-provoked
failure comes with a misleading errno value, ENOSPC. */
if (mode == O_RDONLY
|| (new_fd = open ("/dev/full", mode) != fd))
new_fd = open ("/dev/null", mode);
if (new_fd != fd)
{
if (0 <= new_fd)
close (new_fd);
ok = false;
}
}
}
}
return ok;
}

View File

@@ -1,16 +0,0 @@
#ifndef STDOPEN_H
# define STDOPEN_H 1
# include <stdbool.h>
# ifdef __cplusplus
extern "C" {
# endif
bool stdopen (void);
# ifdef __cplusplus
}
# endif
#endif

View File

@@ -1,13 +0,0 @@
#serial 1
dnl Copyright (C) 2005 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_STDOPEN],
[
AC_LIBSOURCES([stdopen.c, stdopen.h])
AC_LIBOBJ([stdopen])
dnl Prerequisites.
])

881
maint.mk
View File

@@ -1,881 +0,0 @@
# -*-Makefile-*-
# This Makefile fragment tries to be general-purpose enough to be
# used by at least coreutils, idutils, CPPI, Bison, and Autoconf.
## Copyright (C) 2001-2009 Free Software Foundation, Inc.
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
# This is reported not to work with make-3.79.1
# ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ME := maint.mk
# Do not save the original name or timestamp in the .tar.gz file.
# Use --rsyncable if available.
gzip_rsyncable := \
$(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null && echo --rsyncable)
GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
GIT = git
VC = $(GIT)
VC-tag = git tag -s -m '$(VERSION)'
VC_LIST = $(srcdir)/build-aux/vc-list-files
VC_LIST_EXCEPT = \
$(VC_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi
ifeq ($(origin prev_version_file), undefined)
prev_version_file = $(srcdir)/.prev-version
endif
PREV_VERSION := $(shell cat $(prev_version_file))
VERSION_REGEXP = $(subst .,\.,$(VERSION))
PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION))
ifeq ($(VC),$(GIT))
this-vc-tag = v$(VERSION)
this-vc-tag-regexp = v$(VERSION_REGEXP)
else
tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
tag-this-version = $(subst .,_,$(VERSION))
this-vc-tag = $(tag-package)-$(tag-this-version)
this-vc-tag-regexp = $(this-vc-tag)
endif
my_distdir = $(PACKAGE)-$(VERSION)
# Old releases are stored here.
release_archive_dir ?= ../release
# Prevent programs like 'sort' from considering distinct strings to be equal.
# Doing it here saves us from having to set LC_ALL elsewhere in this file.
export LC_ALL = C
## --------------- ##
## Sanity checks. ##
## --------------- ##
# Collect the names of rules starting with `sc_'.
syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
$(srcdir)/$(ME) $(srcdir)/cfg.mk)
.PHONY: $(syntax-check-rules)
local-checks-available = \
patch-check $(syntax-check-rules) \
makefile-check check-AUTHORS
.PHONY: $(local-checks-available)
# Arrange to print the name of each syntax-checking rule just before running it.
$(syntax-check-rules): %: %.m
$(patsubst %, %.m, $(syntax-check-rules)):
@echo $(patsubst sc_%.m, %, $@)
local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available))
syntax-check: $(local-check)
# @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
# $$(find -type f -name '*.[chly]') && \
# { echo '$(ME): found conditional include' 1>&2; \
# exit 1; } || :
# grep -nE '^# *include <(string|stdlib)\.h>' \
# $(srcdir)/{lib,src}/*.[chy] && \
# { echo '$(ME): FIXME' 1>&2; \
# exit 1; } || :
# FIXME: don't allow `#include .strings\.h' anywhere
# By default, _prohibit_regexp does not ignore case.
export ignore_case =
_ignore_case = $$(test -n "$$ignore_case" && echo -i || :)
# There are many rules below that prohibit constructs in this package.
# If the offending construct can be matched with a grep-E-style regexp,
# use this macro. The shell variables "re" and "msg" must be defined.
define _prohibit_regexp
dummy=; : so we do not need a semicolon before each use \
test "x$$re" != x || { echo '$(ME): re not defined' 1>&2; exit 1; }; \
test "x$$msg" != x || { echo '$(ME): msg not defined' 1>&2; exit 1; };\
grep $(_ignore_case) -nE "$$re" $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): '"$$msg" 1>&2; exit 1; } || :
endef
sc_avoid_if_before_free:
@$(srcdir)/build-aux/useless-if-before-free \
$(useless_free_options) \
$$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found useless "if" before "free" above' 1>&2; \
exit 1; } || :
sc_cast_of_argument_to_free:
@re='\<free *\( *\(' msg='don'\''t cast free argument' \
$(_prohibit_regexp)
sc_cast_of_x_alloc_return_value:
@re='\*\) *x(m|c|re)alloc\>' \
msg='don'\''t cast x*alloc return value' \
$(_prohibit_regexp)
sc_cast_of_alloca_return_value:
@re='\*\) *alloca\>' msg='don'\''t cast alloca return value' \
$(_prohibit_regexp)
sc_space_tab:
@re='[ ] ' msg='found SPACE-TAB sequence; remove the SPACE' \
$(_prohibit_regexp)
# Don't use *scanf or the old ato* functions in `real' code.
# They provide no error checking mechanism.
# Instead, use strto* functions.
sc_prohibit_atoi_atof:
@re='\<([fs]?scanf|ato([filq]|ll)) *\(' \
msg='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
$(_prohibit_regexp)
# Use STREQ rather than comparing strcmp == 0, or != 0.
sc_prohibit_strcmp:
@grep -nE '! *str''cmp *\(|\<str''cmp *\([^)]+\) *==' \
$$($(VC_LIST_EXCEPT)) \
| grep -vE ':# *define STREQ\(' && \
{ echo '$(ME): use STREQ in place of the above uses of str''cmp' \
1>&2; exit 1; } || :
# Using EXIT_SUCCESS as the first argument to error is misleading,
# since when that parameter is 0, error does not exit. Use `0' instead.
sc_error_exit_success:
@grep -nE 'error \(EXIT_SUCCESS,' \
$$($(VC_LIST_EXCEPT) | grep -E '\.[chly]$$') && \
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; exit 1; } || :
# `FATAL:' should be fully upper-cased in error messages
# `WARNING:' should be fully upper-cased, or fully lower-cased
sc_error_message_warn_fatal:
@grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
| grep -E '"Warning|"Fatal|"fatal' && \
{ echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
exit 1; } || :
# Error messages should not start with a capital letter
sc_error_message_uppercase:
@grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
| grep -E '"[A-Z]' \
| grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
{ echo '$(ME): found capitalized error message' 1>&2; \
exit 1; } || :
# Error messages should not end with a period
sc_error_message_period:
@grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
| grep -E '[^."]\."' && \
{ echo '$(ME): found error message ending in period' 1>&2; \
exit 1; } || :
sc_file_system:
@re=file''system ignore_case=1 \
msg='found use of "file''system"; spell it "file system"' \
$(_prohibit_regexp)
# Don't use cpp tests of this symbol. All code assumes config.h is included.
sc_prohibit_have_config_h:
@grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found use of HAVE''_CONFIG_H; remove' \
1>&2; exit 1; } || :
# Nearly all .c files must include <config.h>.
sc_require_config_h:
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
grep -L '^# *include <config\.h>' \
$$($(VC_LIST_EXCEPT) | grep '\.c$$') \
| grep . && \
{ echo '$(ME): the above files do not include <config.h>' \
1>&2; exit 1; } || :; \
else :; \
fi
# You must include <config.h> before including any other header file.
sc_require_config_h_first:
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
fail=0; \
for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do \
grep '^# *include\>' $$i | sed 1q \
| grep '^# *include <config\.h>' > /dev/null \
|| { echo $$i; fail=1; }; \
done; \
test $$fail = 1 && \
{ echo '$(ME): the above files include some other header' \
'before <config.h>' 1>&2; exit 1; } || :; \
else :; \
fi
sc_prohibit_HAVE_MBRTOWC:
@re='\bHAVE_MBRTOWC\b' msg="do not use $$re; it is always defined" \
$(_prohibit_regexp)
# To use this "command" macro, you must first define two shell variables:
# h: the header, enclosed in <> or ""
# re: a regular expression that matches IFF something provided by $h is used.
define _header_without_use
h_esc=`echo "$$h"|sed 's/\./\\./'`; \
if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
files=$$(grep -l '^# *include '"$$h_esc" \
$$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \
grep -LE "$$re" $$files | grep . && \
{ echo "$(ME): the above files include $$h but don't use it" \
1>&2; exit 1; } || :; \
else :; \
fi
endef
# Prohibit the inclusion of assert.h without an actual use of assert.
sc_prohibit_assert_without_use:
@h='<assert.h>' re='\<assert *\(' $(_header_without_use)
# Prohibit the inclusion of getopt.h without an actual use.
sc_prohibit_getopt_without_use:
@h='<getopt.h>' re='\<getopt(_long)? *\(' $(_header_without_use)
# Don't include quotearg.h unless you use one of its functions.
sc_prohibit_quotearg_without_use:
@h='"quotearg.h"' re='\<quotearg(_[^ ]+)? *\(' $(_header_without_use)
# Don't include quote.h unless you use one of its functions.
sc_prohibit_quote_without_use:
@h='"quote.h"' re='\<quote(_n)? *\(' $(_header_without_use)
# Don't include this header unless you use one of its functions.
sc_prohibit_long_options_without_use:
@h='"long-options.h"' re='\<parse_long_options *\(' \
$(_header_without_use)
# Don't include this header unless you use one of its functions.
sc_prohibit_inttostr_without_use:
@h='"inttostr.h"' re='\<(off|[iu]max|uint)tostr *\(' \
$(_header_without_use)
# Don't include this header unless you use one of its functions.
sc_prohibit_error_without_use:
@h='"error.h"' \
re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
$(_header_without_use)
sc_prohibit_safe_read_without_use:
@h='"safe-read.h"' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
$(_header_without_use)
sc_prohibit_argmatch_without_use:
@h='"argmatch.h"' \
re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<argmatch(_exit_fn|_(in)?valid) *\()' \
$(_header_without_use)
sc_prohibit_root_dev_ino_without_use:
@h='"root-dev-ino.h"' \
re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
$(_header_without_use)
# Prohibit the inclusion of c-ctype.h without an actual use.
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
sc_prohibit_c_ctype_without_use:
@h='[<"]c-ctype.h[">]' re='\<c_($(ctype_re)) *\(' $(_header_without_use)
_empty =
_sp = $(_empty) $(_empty)
# The following list was generated by running:
# man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
# | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
_sig_functions = \
bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \
sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \
siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \
sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
_sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions)))
# The following were extracted from "man signal.h" manually.
_sig_types_and_consts = \
MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \
SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \
SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \
SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \
sigstack sigval stack_t ucontext_t
# generated via this:
# perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
_sig_names = \
SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \
SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \
SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \
SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \
SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \
SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \
SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \
SIGXCPU SIGXFSZ
_sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts)))
# Prohibit the inclusion of signal.h without an actual use.
sc_prohibit_signal_without_use:
@h='<signal.h>' \
re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \
$(_header_without_use)
sc_obsolete_symbols:
@re='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
msg='do not use HAVE''_FCNTL_H or O'_NDELAY \
$(_prohibit_regexp)
# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
# Each nonempty line must start with a year number, or a TAB.
sc_changelog:
@grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \
{ echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
exit 1; } || :
# Ensure that each .c file containing a "main" function also
# calls set_program_name.
sc_program_name:
@if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$')); \
grep -LE 'set_program_name *\(m?argv\[0\]\);' $$files \
| grep . && \
{ echo '$(ME): the above files do not call set_program_name' \
1>&2; exit 1; } || :; \
else :; \
fi
# Require that the final line of each test-lib.sh-using test be this one:
# Exit $fail
# Note: this test requires GNU grep's --label= option.
sc_require_test_exit_idiom:
@if test -f $(srcdir)/tests/test-lib.sh; then \
die=0; \
for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \
tail -n1 $$i | grep '^Exit \$$fail$$' > /dev/null \
&& : || { die=1; echo $$i; } \
done; \
test $$die = 1 && \
{ echo 1>&2 '$(ME): the final line in each of the above is not:'; \
echo 1>&2 'Exit $$fail'; \
exit 1; } || :; \
fi
sc_the_the:
@re='\<the ''the\>' \
ignore_case=1 msg='found use of "the ''the";' \
$(_prohibit_regexp)
sc_trailing_blank:
@re='[ ]$$' \
msg='found trailing blank(s)' \
$(_prohibit_regexp)
# Match lines like the following, but where there is only one space
# between the options and the description:
# -D, --all-repeated[=delimit-method] print all duplicate lines\n
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
sc_two_space_separator_in_usage:
@grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
$$($(VC_LIST_EXCEPT)) && \
{ echo "$(ME): help2man requires at least two spaces between"; \
echo "$(ME): an option and its description"; \
1>&2; exit 1; } || :
# Look for diagnostics that aren't marked for translation.
# This won't find any for which error's format string is on a separate line.
sc_unmarked_diagnostics:
@grep -nE \
'\<error \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
| grep -v '_''(' && \
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
# Avoid useless parentheses like those in this example:
# #if defined (SYMBOL) || defined (SYM2)
sc_useless_cpp_parens:
@grep -n '^# *if .*defined *(' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found useless parentheses in cpp directive' \
1>&2; exit 1; } || :
# Require the latest GPL.
sc_GPL_version:
@re='either ''version [^3]' msg='GPL vN, N!=3' \
$(_prohibit_regexp)
cvs_keywords = \
Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
sc_prohibit_cvs_keyword:
@re='\$$($(cvs_keywords))\$$' \
msg='do not use CVS keyword expansion' \
$(_prohibit_regexp)
# Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
# This is a bit of a kludge, since it prevents use of the string
# even in comments, but for now it does the job with no false positives.
sc_prohibit_stat_st_blocks:
@re='[.>]st_blocks' msg='do not use st_blocks; use ST_NBLOCKS' \
$(_prohibit_regexp)
# Make sure we don't define any S_IS* macros in src/*.c files.
# They're already defined via gnulib's sys/stat.h replacement.
sc_prohibit_S_IS_definition:
@re='^ *# *define *S_IS' \
msg='do not define S_IS* macros; include <sys/stat.h>' \
$(_prohibit_regexp)
# Each program that uses proper_name_utf8 must link with
# one of the ICONV libraries.
sc_proper_name_utf8_requires_ICONV:
@progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
if test "x$$progs" != x; then \
fail=0; \
for p in $$progs; do \
dir=$$(dirname "$$p"); \
base=$$(basename "$$p" .c); \
grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \
|| { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
done; \
test $$fail = 1 && \
{ echo 1>&2 '$(ME): the above do not link with any ICONV library'; \
exit 1; } || :; \
fi
# Warn about "c0nst struct Foo const foo[]",
# but not about "char const *const foo" or "#define const const".
sc_redundant_const:
@re='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
msg='redundant "const" in declarations' \
$(_prohibit_regexp)
sc_const_long_option:
@grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
| grep -Ev 'const struct option|struct option const' && { \
echo 1>&2 '$(ME): add "const" to the above declarations'; \
exit 1; } || :
NEWS_hash = \
$$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
$(srcdir)/NEWS \
| grep -v '^Copyright .*Free Software' \
| md5sum - \
| sed 's/ .*//')
# Ensure that we don't accidentally insert an entry into an old NEWS block.
sc_immutable_NEWS:
@if test -f $(srcdir)/NEWS; then \
test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
{ echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
fi
# Update the hash stored above. Do this after each release and
# for any corrections to old entries.
update-NEWS-hash: NEWS
perl -pi -e 's/^(old_NEWS_hash = ).*/$${1}'"$(NEWS_hash)/" \
$(srcdir)/cfg.mk
epoch_date = 1970-01-01 00:00:00.000000000 +0000
# Ensure that the c99-to-c89 patch applies cleanly.
patch-check:
rm -rf src-c89 $@.1 $@.2
cp -a $(srcdir)/src src-c89
if test "x$(srcdir)" != x.; then \
cp -a src/* src-c89; \
dotfiles=`ls src/.[!.]* 2>/dev/null`; \
test -z "$$dotfiles" || cp -a src/.[!.]* src-c89; \
fi
(cd src-c89; patch -p1 -V never --fuzz=0) < $(srcdir)/src/c99-to-c89.diff \
> $@.1 2>&1
if test "$(REGEN_PATCH)" = yes; then \
diff -upr $(srcdir)/src src-c89 | sed 's,$(srcdir)/src-c89/,src/,' \
| grep -vE '^(Only in|File )' \
| perl -pe 's/^((?:\+\+\+|---) \S+\t).*/$${1}$(epoch_date)/;' \
-e 's/^ $$//' \
> new-diff || : ; fi
grep -v '^patching file ' $@.1 > $@.2 || :
msg=ok; test -s $@.2 && msg='fuzzy patch' || : ; \
rm -f src-c89/*.o || msg='rm failed'; \
$(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \
|| msg='compile failure with extra options'; \
test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \
test "$$msg" = ok
check-AUTHORS:
$(MAKE) -C src $@
# Ensure that we use only the standard $(VAR) notation,
# not @...@ in Makefile.am, now that we can rely on automake
# to emit a definition for each substituted variable.
# We use perl rather than "grep -nE ..." to exempt a single
# use of an @...@-delimited variable name in src/Makefile.am.
makefile-check:
@perl -ne '/\@[A-Z_0-9]+\@/ && !/^cu_install_program =/' \
-e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
$$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
news-date-check: NEWS
today=`date +%Y-%m-%d`; \
if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
>/dev/null; then \
:; \
else \
echo "version or today's date is not in NEWS" 1>&2; \
exit 1; \
fi
changelog-check:
if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
>/dev/null; then \
:; \
else \
echo "$(VERSION) not in ChangeLog" 1>&2; \
exit 1; \
fi
sc_makefile_TAB_only_indentation:
@grep -nE '^ [ ]{8}' \
$$($(VC_LIST_EXCEPT) | grep -E 'akefile|\.mk$$') \
&& { echo '$(ME): found TAB-8-space indentation' 1>&2; \
exit 1; } || :
sc_m4_quote_check:
@grep -nE '(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
$$($(VC_LIST_EXCEPT) | grep -E '(^configure\.ac|\.m4)$$') \
&& { echo '$(ME): quote the first arg to AC_DEF*' 1>&2; \
exit 1; } || :
fix_po_file_diag = \
'you have changed the set of files with translatable diagnostics;\n\
apply the above patch\n'
# Verify that all source files using _() are listed in po/POTFILES.in.
po_file = po/POTFILES.in
sc_po_check:
@if test -f $(po_file); then \
grep -E -v '^(#|$$)' $(po_file) \
| grep -v '^src/false\.c$$' | sort > $@-1; \
files=; \
for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do \
case $$file in \
*.?|*.??) ;; \
*) continue;; \
esac; \
case $$file in \
*.[ch]) \
base=`expr " $$file" : ' \(.*\)\..'`; \
{ test -f $$base.l || test -f $$base.y; } && continue;; \
esac; \
files="$$files $$file"; \
done; \
grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
| sort -u > $@-2; \
diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
|| { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \
rm -f $@-1 $@-2; \
fi
# Sometimes it is useful to change the PATH environment variable
# in Makefiles. When doing so, it's better not to use the Unix-centric
# path separator of `:', but rather the automake-provided `$(PATH_SEPARATOR)'.
msg = '$(ME): Do not use `:'\'' above; use $$(PATH_SEPARATOR) instead'
sc_makefile_path_separator_check:
@grep -nE 'PATH[=].*:' \
$$($(VC_LIST_EXCEPT) | grep -E 'akefile|\.mk$$') \
&& { echo $(msg) 1>&2; exit 1; } || :
# Check that `make alpha' will not fail at the end of the process.
writable-files:
if test -d $(release_archive_dir); then :; else \
for file in $(distdir).tar.gz \
$(release_archive_dir)/$(distdir).tar.gz; do \
test -e $$file || continue; \
test -w $$file \
|| { echo ERROR: $$file is not writable; fail=1; }; \
done; \
test "$$fail" && exit 1 || : ; \
fi
v_etc_file = lib/version-etc.c
sample-test = tests/sample-test
texi = doc/$(PACKAGE).texi
# Make sure that the copyright date in $(v_etc_file) is up to date.
# Do the same for the $(sample-test) and the main doc/.texi file.
sc_copyright_check:
@if test -f $(v_etc_file); then \
grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
>/dev/null \
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
exit 1; }; \
fi
@if test -f $(sample-test); then \
grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
>/dev/null \
|| { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
exit 1; }; \
fi
@if test -f $(texi); then \
grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
>/dev/null \
|| { echo 'out of date copyright in $(texi); update it' 1>&2; \
exit 1; }; \
fi
vc-diff-check:
$(VC) diff > vc-diffs || :
if test -s vc-diffs; then \
cat vc-diffs; \
echo "Some files are locally modified:" 1>&2; \
exit 1; \
else \
rm vc-diffs; \
fi
cvs-check: vc-diff-check
maintainer-distcheck:
$(MAKE) distcheck
$(MAKE) taint-distcheck
$(MAKE) my-distcheck
# Don't make a distribution if checks fail.
# Also, make sure the NEWS file is up-to-date.
vc-dist: $(local-check) cvs-check maintainer-distcheck
XZ_OPT=-9ev $(MAKE) dist
# Use this to make sure we don't run these programs when building
# from a virgin tgz file, below.
null_AM_MAKEFLAGS = \
ACLOCAL=false \
AUTOCONF=false \
AUTOMAKE=false \
AUTOHEADER=false \
MAKEINFO=false
built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
bin=bin-$$$$
write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
TMPDIR ?= /tmp
t=$(TMPDIR)/$(PACKAGE)/test
pfx=$(t)/i
# More than once, tainted build and source directory names would
# have caused at least one "make check" test to apply "chmod 700"
# to all directories under $HOME. Make sure it doesn't happen again.
tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$")
t_prefix = $(tp)/a
t_taint = '$(t_prefix) b'
fake_home = $(tp)/home
# Ensure that tests run from tainted build and src dir names work,
# and don't affect anything in $HOME. Create witness files in $HOME,
# record their attributes, and build/test. Then ensure that the
# witnesses were not affected.
taint-distcheck: $(DIST_ARCHIVES)
test -d $(t_taint) && chmod -R 700 $(t_taint) || :
-rm -rf $(t_taint) $(fake_home)
mkdir -p $(t_prefix) $(t_taint) $(fake_home)
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t_taint) -zxf $(distdir).tar.gz
mkfifo $(fake_home)/fifo
touch $(fake_home)/f
mkdir -p $(fake_home)/d/e
ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
cd $(t_taint)/$(distdir) \
&& ./configure \
&& $(MAKE) \
&& HOME=$(fake_home) $(MAKE) check \
&& ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
&& diff $(tp)/.ls-before $(tp)/.ls-after \
&& test -d $(t_prefix)
rm -rf $(tp)
# Verify that a twisted use of --program-transform-name=PROGRAM works.
define install-transform-check
echo running install-transform-check \
&& rm -rf $(pfx) \
&& $(MAKE) program_transform_name='s/.*/zyx/' \
prefix=$(pfx) install \
&& test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
&& test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
endef
# Install, then verify that all binaries and man pages are in place.
# Note that neither the binary, ginstall, nor the ].1 man page is installed.
define my-instcheck
$(MAKE) prefix=$(pfx) install \
&& test ! -f $(pfx)/bin/ginstall \
&& { fail=0; \
for i in $(built_programs); do \
test "$$i" = ginstall && i=install; \
for j in "$(pfx)/bin/$$i" \
"$(pfx)/share/man/man1/$$i.1"; do \
case $$j in *'[.1') continue;; esac; \
test -f "$$j" && : \
|| { echo "$$j not installed"; fail=1; }; \
done; \
done; \
test $$fail = 1 && exit 1 || :; \
}
endef
define coreutils-path-check
{ \
if test -f $(srcdir)/src/true.c; then \
fail=1; \
mkdir $(bin) \
&& ($(write_loser)) > $(bin)/loser \
&& chmod a+x $(bin)/loser \
&& for i in $(built_programs); do \
case $$i in \
rm|expr|basename|echo|sort|ls|tr);; \
cat|dirname|mv|wc);; \
*) ln $(bin)/loser $(bin)/$$i;; \
esac; \
done \
&& ln -sf ../src/true $(bin)/false \
&& PATH=`pwd`/$(bin)$(PATH_SEPARATOR)$$PATH \
$(MAKE) -C tests check \
&& { test -d gnulib-tests \
&& $(MAKE) -C gnulib-tests check \
|| :; } \
&& rm -rf $(bin) \
&& fail=0; \
else \
fail=0; \
fi; \
test $$fail = 1 && exit 1 || :; \
}
endef
# Use -Wformat -Werror to detect format-string/arg-list mismatches.
# Also, check for shadowing problems with -Wshadow, and for pointer
# arithmetic problems with -Wpointer-arith.
# These CFLAGS are pretty strict. If you build this target, you probably
# have to have a recent version of gcc and glibc headers.
# The hard-linking for-loop below ensures that there is a bin/ directory
# full of all of the programs under test (except the ones that are required
# for basic Makefile rules), all symlinked to the just-built "false" program.
# This is to ensure that if ever a test neglects to make PATH include
# the build srcdir, these always-failing programs will run.
# Otherwise, it is too easy to test the wrong programs.
# Note that "false" itself is a symlink to true, so it too will malfunction.
my-distcheck: $(DIST_ARCHIVES) $(local-check)
$(MAKE) syntax-check
$(MAKE) check
-rm -rf $(t)
mkdir -p $(t)
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
cd $(t)/$(distdir) \
&& ./configure --disable-nls \
&& $(MAKE) CFLAGS='$(warn_cflags)' \
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
&& $(MAKE) dvi \
&& $(install-transform-check) \
&& $(my-instcheck) \
&& $(coreutils-path-check) \
&& $(MAKE) distclean
(cd $(t) && mv $(distdir) $(distdir).old \
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
-rm -rf $(t)
@echo "========================"; \
echo "$(distdir).tar.gz is ready for distribution"; \
echo "========================"
WGET = wget
WGETFLAGS = -C off
rel-check:
tarz=/tmp/rel-check-tarz-$$$$; \
md5_tmp=/tmp/rel-check-md5-$$$$; \
set -e; \
trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
$(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
echo "$(md5) -" > $$md5_tmp; \
md5sum -c $$md5_tmp < $$tarz
rel-files = $(DIST_ARCHIVES)
gnulib-version = $$(cd $(gnulib_dir) && git describe)
announcement: NEWS ChangeLog $(rel-files)
@./build-aux/announce-gen \
--release-type=$(RELEASE_TYPE) \
--package=$(PACKAGE) \
--prev=$(PREV_VERSION) \
--curr=$(VERSION) \
--gpg-key-id=$(gpg_key_ID) \
--news=NEWS \
--bootstrap-tools=autoconf,automake,bison,gnulib \
--gnulib-version=$(gnulib-version) \
--no-print-checksums \
$(addprefix --url-dir=, $(url_dir_list))
## ---------------- ##
## Updating files. ##
## ---------------- ##
ftp-gnu = ftp://ftp.gnu.org/gnu
www-gnu = http://www.gnu.org
# Use mv, if you don't have/want move-if-change.
move_if_change ?= move-if-change
emit_upload_commands:
@echo =====================================
@echo =====================================
@echo "$(srcdir)/build-aux/gnupload $(GNUPLOADFLAGS) \\"
@echo " --to $(gnu_rel_host):$(PACKAGE) \\"
@echo " $(rel-files)"
@echo '# send the /tmp/announcement e-mail'
@echo =====================================
@echo =====================================
noteworthy = * Noteworthy changes in release ?.? (????-??-??) [?]
define emit-commit-log
printf '%s\n' 'post-release administrivia' '' \
'* NEWS: Add header line for next release.' \
'* .prev-version: Record previous version.' \
'* cfg.mk (old_NEWS_hash): Auto-update.'
endef
.PHONY: alpha beta major
alpha beta major: $(local-check) writable-files
test $@ = major \
&& { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
|| :
$(MAKE) vc-dist
$(MAKE) news-date-check
$(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
if test -d $(release_archive_dir); then \
ln $(rel-files) $(release_archive_dir); \
chmod a-w $(rel-files); \
fi
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
echo $(VERSION) > $(prev_version_file)
$(MAKE) update-NEWS-hash
perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS
$(emit-commit-log) > .ci-msg
$(VC) commit -F .ci-msg -a
.PHONY: web-manual
web-manual:
@test -z "$(manual_title)" \
&& { echo define manual_title in cfg.mk 1>&2; exit 1; } || :
@cd '$(srcdir)/doc'; \
$(SHELL) ../build-aux/gendocs.sh -o '$(abs_builddir)/doc/manual' \
--email $(PACKAGE_BUGREPORT) $(PACKAGE) \
"$(PACKAGE_NAME) - $(manual_title)"
@echo " *** Upload the doc/manual directory to web-cvs."

View File

@@ -69,6 +69,10 @@ EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
BUILT_SOURCES =
CLEANFILES = $(SCRIPTS) su
# Also remove these sometimes-built programs.
# For example, even when excluded, they're built via check-AUTHORS.
CLEANFILES += $(no_install__progs)
AM_CPPFLAGS = -I$(top_srcdir)/lib
noinst_LIBRARIES = libver.a
@@ -286,26 +290,26 @@ editpl = sed -e 's,@''PERL''@,$(PERL),g'
BUILT_SOURCES += dircolors.h
dircolors.h: dcgen dircolors.hin
@rm -f $@ $@-t
$(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
@chmod a-w $@-t
mv $@-t $@
$(AM_V_GEN)rm -f $@ $@-t
$(AM_V_at)$(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
$(AM_V_at)chmod a-w $@-t
$(AM_V_at)mv $@-t $@
wheel_size = 5
BUILT_SOURCES += wheel-size.h
wheel-size.h: Makefile.am
@rm -f $@ $@-t
echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
@chmod a-w $@-t
mv $@-t $@
$(AM_V_GEN)rm -f $@ $@-t
$(AM_V_at)echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
$(AM_V_at)chmod a-w $@-t
$(AM_V_at)mv $@-t $@
BUILT_SOURCES += wheel.h
wheel.h: wheel-gen.pl Makefile.am
@rm -f $@ $@-t
$(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
@chmod a-w $@-t
mv $@-t $@
$(AM_V_GEN)rm -f $@ $@-t
$(AM_V_at)$(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
$(AM_V_at)chmod a-w $@-t
$(AM_V_at)mv $@-t $@
# false exits nonzero even with --help or --version.
# test doesn't support --help or --version.
@@ -314,25 +318,25 @@ AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
BUILT_SOURCES += fs.h
fs.h: stat.c extract-magic
rm -f $@
$(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
@chmod a-w $@t
mv $@t $@
$(AM_V_GEN)rm -f $@
$(AM_V_at)$(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
$(AM_V_at)chmod a-w $@t
$(AM_V_at)mv $@t $@
BUILT_SOURCES += version.c
version.c: Makefile
rm -f $@
printf '#include <config.h>\n' > $@t
printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
@chmod a-w $@t
mv $@t $@
$(AM_V_GEN)rm -f $@
$(AM_V_at)printf '#include <config.h>\n' > $@t
$(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
$(AM_V_at)chmod a-w $@t
$(AM_V_at)mv $@t $@
BUILT_SOURCES += version.h
version.h: Makefile
rm -f $@
printf 'extern char const *Version;\n' > $@t
@chmod a-w $@t
mv $@t $@
$(AM_V_GEN)rm -f $@
$(AM_V_at)printf 'extern char const *Version;\n' > $@t
$(AM_V_at)chmod a-w $@t
$(AM_V_at)mv $@t $@
DISTCLEANFILES = version.c version.h
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
@@ -359,7 +363,7 @@ pm = progs-makefile
pr = progs-readme
# Ensure that the list of programs in README matches the list
# of programs we can build.
check: check-README check-duplicate-no-install
check: check-README check-duplicate-no-install check-AUTHORS
.PHONY: check-README
check-README:
rm -rf $(pr) $(pm)
@@ -378,12 +382,17 @@ check-duplicate-no-install: tr
test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
# Ensure that the list of programs and author names is accurate.
# We need a UTF8 locale, and any one should do, but since configure
# already tries to find a French one, use it. It's fine to skip this test.
au_dotdot = authors-dotdot
au_actual = authors-actual
.PHONY: check-AUTHORS
check-AUTHORS: $(all_programs)
@rm -f $(au_actual) $(au_dotdot)
@for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
@locale='$(LOCALE_FR_UTF8)'; \
case "$$locale" in \
''|none) echo "$@: skipping this check"; exit 0;; esac; \
rm -f $(au_actual) $(au_dotdot); \
for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
| $(ASSORT) -u`; do \
test "$$i" = '[' && continue; \
exe=$$i; \
@@ -392,37 +401,13 @@ check-AUTHORS: $(all_programs)
elif test "$$i" = test; then \
exe='['; \
fi; \
LC_ALL=en_US.UTF-8 ./$$exe --version \
LC_ALL="$$locale" ./$$exe --version \
| perl -0 -pi -e 's/,\n/, /gm' \
|sed -n '/Written by /{ s//'"$$i"': /; s/,* and /, /; s/\.$$//; p; }'; \
done > $(au_actual)
@sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot)
@diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
# Extract the list of authors from each file.
sed_filter = s/^ *//;s/N_ (//;s/^"//;s/")*$$//
# Sometimes the string is on the same line as the #define...
s1 = '/^\#define AUTHORS \([^\\]\)/{;s//\1/;$(sed_filter);p;q;}'
# Sometimes the string is on the backslash-continued line after the #define.
s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
../AUTHORS: $(SOURCES)
rm -f $@-t
( \
set -e; \
echo "Here are the names of the programs in this package,"; \
echo "each followed by the name(s) of its author(s)."; \
echo; \
for i in $(SOURCES); do \
a=`sed -n $(s1) $$i`; \
test "$$a" && : \
|| a=`sed -n $(s2) $$i`; \
if test "$$a"; then \
prog=`echo $$i|sed 's/\.c$$//'`; \
echo "$$prog: $$a"; \
fi; \
done | $(ASSORT) -u ) > $@-t
chmod a-w $@-t
mv $@-t $@
| sed -n -e '/Written by /{ s//'"$$i"': /;' \
-e 's/,* and /, /; s/\.$$//; p; }'; \
done > $(au_actual) && \
sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot) && \
diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
# The following rule is not designed to be portable,
# and relies on tools that not everyone has.
@@ -434,7 +419,7 @@ s2 = '/^\#define AUTHORS \\\\/{;n;$(sed_filter);p;q;}'
#
# The second nm|grep checks for file-scope variables with `extern' scope.
.PHONY: sc_tight_scope
sc_tight_scope: $(all_programs)
sc_tight_scope: $(bin_PROGRAMS)
@t=exceptions-$$$$; \
trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
src=`for f in $(SOURCES); do \

View File

@@ -422,7 +422,7 @@ change_file_owner (FTS *fts, FTSENT *ent,
}
}
/* On some systems (e.g., Linux-2.4.x),
/* On some systems (e.g., GNU/Linux 2.4.x),
the chown function resets the `special' permission bits.
Do *not* restore those bits; doing so would open a window in
which a malicious user, M, could subvert a chown command run

View File

@@ -131,6 +131,12 @@ is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
return false;
}
static bool
errno_unsupported (int err)
{
return err == ENOTSUP || err == ENODATA;
}
#if USE_XATTR
static void
copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED,
@@ -139,6 +145,23 @@ copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED,
int err = errno;
va_list ap;
if (!errno_unsupported (errno))
if (errno != ENOTSUP && errno != ENODATA)
{
/* use verror module to print error message */
va_start (ap, fmt);
verror (0, err, fmt, ap);
va_end (ap);
}
}
static void
copy_attr_allerror (struct error_context *ctx ATTRIBUTE_UNUSED,
char const *fmt, ...)
{
int err = errno;
va_list ap;
/* use verror module to print error message */
va_start (ap, fmt);
verror (0, err, fmt, ap);
@@ -163,12 +186,13 @@ copy_attr_by_fd (char const *src_path, int src_fd,
{
struct error_context ctx =
{
.error = copy_attr_error,
.error = x->require_preserve_xattr ? copy_attr_allerror : copy_attr_error,
.quote = copy_attr_quote,
.quote_free = copy_attr_free
};
return 0 == attr_copy_fd (src_path, src_fd, dst_path, dst_fd, 0,
x->reduce_diagnostics ? NULL : &ctx);
(x->reduce_diagnostics
&& !x->require_preserve_xattr)? NULL : &ctx);
}
static bool
@@ -177,12 +201,13 @@ copy_attr_by_name (char const *src_path, char const *dst_path,
{
struct error_context ctx =
{
.error = copy_attr_error,
.error = x->require_preserve_xattr ? copy_attr_allerror : copy_attr_error,
.quote = copy_attr_quote,
.quote_free = copy_attr_free
};
return 0 == attr_copy_file (src_path, dst_path, 0,
x-> reduce_diagnostics ? NULL :&ctx);
(x-> reduce_diagnostics
&& !x->require_preserve_xattr) ? NULL : &ctx);
}
#else /* USE_XATTR */
@@ -465,7 +490,7 @@ copy_reg (char const *src_name, char const *dst_name,
security_context_t con = NULL;
if (getfscreatecon (&con) < 0)
{
if (!x->reduce_diagnostics)
if (!x->reduce_diagnostics || x->require_preserve_context)
error (0, errno, _("failed to get file system create context"));
if (x->require_preserve_context)
{
@@ -478,7 +503,7 @@ copy_reg (char const *src_name, char const *dst_name,
{
if (fsetfilecon (dest_desc, con) < 0)
{
if (!x->reduce_diagnostics)
if (!x->reduce_diagnostics || x->require_preserve_context)
error (0, errno,
_("failed to set the security context of %s to %s"),
quote_n (0, dst_name), quote_n (1, con));
@@ -700,9 +725,10 @@ copy_reg (char const *src_name, char const *dst_name,
}
last_write_made_hole = false;
/* A short read on a regular file means EOF. */
if (n_read != buf_size && S_ISREG (src_open_sb.st_mode))
break;
/* It is tempting to return early here upon a short read from a
regular file. That would save the final read syscall for each
file. Unfortunately that doesn't work for certain files in
/proc with linux kernels from at least 2.6.9 .. 2.6.29. */
}
}
@@ -1731,7 +1757,7 @@ copy_internal (char const *src_name, char const *dst_name,
{
if (setfscreatecon (con) < 0)
{
if (!x->reduce_diagnostics)
if (!x->reduce_diagnostics || x->require_preserve_context)
error (0, errno,
_("failed to set default file creation context to %s"),
quote (con));
@@ -1745,9 +1771,9 @@ copy_internal (char const *src_name, char const *dst_name,
}
else
{
if (errno != ENOTSUP && errno != ENODATA)
if (!errno_unsupported (errno) || x->require_preserve_context)
{
if (!x->reduce_diagnostics)
if (!x->reduce_diagnostics || x->require_preserve_context)
error (0, errno,
_("failed to get security context of %s"),
quote (src_name));

View File

@@ -850,7 +850,7 @@ iwrite (int fd, char const *buf, size_t size)
else if (nwritten == 0)
{
/* Some buggy drivers return 0 when one tries to write beyond
a device's end. (Example: Linux 1.2.13 on /dev/fd0.)
a device's end. (Example: Linux kernel 1.2.13 on /dev/fd0.)
Set errno to ENOSPC so they get a sensible diagnostic. */
errno = ENOSPC;
break;
@@ -1201,7 +1201,7 @@ advance_input_offset (uintmax_t offset)
to indicate that lseek failed.
The offending behavior has been confirmed with an Exabyte SCSI tape
drive accessed via /dev/nst0 on both Linux-2.2.17 and Linux-2.4.16. */
drive accessed via /dev/nst0 on both Linux 2.2.17 and 2.4.16 kernels. */
#ifdef __linux__
@@ -1565,7 +1565,7 @@ dd_copy (void)
the input buffer; thus we allocate 2 pages of slop in the
real buffer. 8k above the blocksize shouldn't bother anyone.
The page alignment is necessary on any linux system that supports
The page alignment is necessary on any Linux kernel that supports
either the SGI raw I/O patch or Steven Tweedies raw I/O patch.
It is necessary when accessing raw (i.e. character special) disk
devices on Unixware or other SVR4-derived system. */
@@ -1887,7 +1887,7 @@ main (int argc, char **argv)
/* Complain only when ftruncate fails on a regular file, a
directory, or a shared memory object, as POSIX 1003.1-2004
specifies ftruncate's behavior only for these file types.
For example, do not complain when Linux 2.4 ftruncate
For example, do not complain when Linux kernel 2.4 ftruncate
fails on /dev/fd0. */
int ftruncate_errno = errno;
struct stat stdout_stat;

View File

@@ -1,5 +1,5 @@
/* df - summarize free disk space
Copyright (C) 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 91, 1995-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -70,7 +70,7 @@ static bool file_systems_processed;
/* If true, invoke the `sync' system call before getting any usage data.
Using this option can make df very slow, especially with many or very
busy disks. Note that this may make a difference on some systems --
SunOS 4.1.3, for one. It is *not* necessary on Linux. */
SunOS 4.1.3, for one. It is *not* necessary on GNU/Linux. */
static bool require_sync;
/* Desired exit status. */
@@ -988,17 +988,21 @@ main (int argc, char **argv)
{
int i;
/* stat all the given entries to make sure they get automounted,
if necessary, before reading the file system table. */
/* Open each of the given entries to make sure any corresponding
partition is automounted. This must be done before reading the
file system table. */
stats = xnmalloc (argc - optind, sizeof *stats);
for (i = optind; i < argc; ++i)
{
if (stat (argv[i], &stats[i - optind]))
int fd = open (argv[i], O_RDONLY | O_NOCTTY);
if (fd < 0 || fstat (fd, &stats[i - optind]))
{
error (0, errno, "%s", quote (argv[i]));
exit_status = EXIT_FAILURE;
argv[i] = NULL;
}
if (0 <= fd)
close (fd);
}
}

View File

@@ -134,6 +134,7 @@ static char const *strip_program = "strip";
enum
{
PRESERVE_CONTEXT_OPTION = CHAR_MAX + 1,
PRESERVE_CONTEXT_OPTION_DEPRECATED,
STRIP_PROGRAM_OPTION
};
@@ -149,10 +150,9 @@ static struct option const long_options[] =
{"owner", required_argument, NULL, 'o'},
{"preserve-timestamps", no_argument, NULL, 'p'},
{"preserve-context", no_argument, NULL, PRESERVE_CONTEXT_OPTION},
/* Continue silent support for --preserve_context until Jan 2008. FIXME-obs
After that, FIXME-obs: warn in, say, late 2008, and disable altogether
a year or two later. */
{"preserve_context", no_argument, NULL, PRESERVE_CONTEXT_OPTION},
/* --preserve_context was silently supported until Apr 2009.
FIXME: disable altogether in a year or so. */
{"preserve_context", no_argument, NULL, PRESERVE_CONTEXT_OPTION_DEPRECATED},
{"strip", no_argument, NULL, 's'},
{"strip-program", required_argument, NULL, STRIP_PROGRAM_OPTION},
{"suffix", required_argument, NULL, 'S'},
@@ -530,6 +530,10 @@ main (int argc, char **argv)
no_target_directory = true;
break;
case PRESERVE_CONTEXT_OPTION_DEPRECATED:
error (0, 0, _("WARNING: --preserve_context is deprecated; "
"use --preserve-context instead"));
/* fall through */
case PRESERVE_CONTEXT_OPTION:
if ( ! selinux_enabled)
{

106
src/ls.c
View File

@@ -67,6 +67,10 @@
#include <selinux/selinux.h>
#include <wchar.h>
#if HAVE_LANGINFO_CODESET
# include <langinfo.h>
#endif
/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
present. */
#ifndef SA_NOCLDSTOP
@@ -105,6 +109,7 @@
#include "strftime.h"
#include "xstrtol.h"
#include "areadlink.h"
#include "mbsalign.h"
#define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \
: (ls_mode == LS_MULTI_COL \
@@ -695,6 +700,11 @@ static char const *long_time_format[2] =
screen columns small, because many people work in windows with
only 80 columns. But make this as wide as the other string
below, for recent files. */
/* TRANSLATORS: ls output needs to be aligned for ease of reading,
so be wary of using variable width fields from the locale.
Note %b is handled specially by ls and aligned correctly.
Note also that specifying a width as in %5b is erroneous as strftime
will count bytes rather than characters in multibyte locales. */
N_("%b %e %Y"),
/* strftime format for recent files (younger than 6 months), in -l
output. This should contain the month, day and time (at
@@ -703,6 +713,11 @@ static char const *long_time_format[2] =
screen columns small, because many people work in windows with
only 80 columns. But make this as wide as the other string
above, for non-recent files. */
/* TRANSLATORS: ls output needs to be aligned for ease of reading,
so be wary of using variable width fields from the locale.
Note %b is handled specially by ls and aligned correctly.
Note also that specifying a width as in %5b is erroneous as strftime
will count bytes rather than characters in multibyte locales. */
N_("%b %e %H:%M")
};
@@ -978,6 +993,56 @@ dired_dump_obstack (const char *prefix, struct obstack *os)
}
}
/* Read the abbreviated month names from the locale, to align them
and to determine the max width of the field and to truncate names
greater than our max allowed.
Note even though this handles multibyte locales correctly
it's not restricted to them as single byte locales can have
variable width abbreviated months and also precomputing/caching
the names was seen to increase the performance of ls significantly. */
/* max number of display cells to use */
enum { MAX_MON_WIDTH = 5 };
/* In the unlikely event that the abmon[] storage is not big enough
an error message will be displayed, and we revert to using
unmodified abbreviated month names from the locale database. */
static char abmon[12][MAX_MON_WIDTH * 2 * MB_LEN_MAX + 1];
/* minimum width needed to align %b, 0 => don't use precomputed values. */
static size_t required_mon_width;
static size_t
abmon_init (void)
{
#ifdef HAVE_NL_LANGINFO
required_mon_width = MAX_MON_WIDTH;
size_t curr_max_width;
do
{
curr_max_width = required_mon_width;
required_mon_width = 0;
for (int i = 0; i < 12; i++)
{
size_t width = curr_max_width;
size_t req = mbsalign (nl_langinfo (ABMON_1 + i),
abmon[i], sizeof (abmon[i]),
&width, MBS_ALIGN_LEFT, 0);
if (req == (size_t) -1 || req >= sizeof (abmon[i]))
{
required_mon_width = 0; /* ignore precomputed strings. */
return required_mon_width;
}
required_mon_width = MAX (required_mon_width, width);
}
}
while (curr_max_width > required_mon_width);
#endif
return required_mon_width;
}
static size_t
dev_ino_hash (void const *x, size_t table_size)
{
@@ -1953,6 +2018,10 @@ decode_switches (int argc, char **argv)
}
}
}
/* Note we leave %5b etc. alone so user widths/flags are honored. */
if (strstr (long_time_format[0],"%b") || strstr (long_time_format[1],"%b"))
if (!abmon_init ())
error (0, 0, _("error initializing month strings"));
}
return optind;
@@ -3317,6 +3386,35 @@ print_current_files (void)
}
}
/* Replace the first %b with precomputed aligned month names.
Note on glibc-2.7 at least, this speeds up the whole `ls -lU`
process by around 17%, compared to letting strftime() handle the %b. */
static size_t
align_nstrftime (char *buf, size_t size, char const *fmt, struct tm const *tm,
int __utc, int __ns)
{
const char *nfmt = fmt;
/* In the unlikely event that rpl_fmt below is not large enough,
the replacement is not done. A malloc here slows ls down by 2% */
char rpl_fmt[sizeof (abmon[0]) + 100];
const char *pb;
if (required_mon_width && (pb = strstr (fmt, "%b")))
{
if (strlen (fmt) < (sizeof (rpl_fmt) - sizeof (abmon[0]) + 2))
{
char *pfmt = rpl_fmt;
nfmt = rpl_fmt;
pfmt = mempcpy (pfmt, fmt, pb - fmt);
pfmt = stpcpy (pfmt, abmon[tm->tm_mon]);
strcpy (pfmt, pb + 2);
}
}
size_t ret = nstrftime (buf, size, nfmt, tm, __utc, __ns);
return ret;
}
/* Return the expected number of columns in a long-format time stamp,
or zero if it cannot be calculated. */
@@ -3341,7 +3439,7 @@ long_time_expected_width (void)
if (tm)
{
size_t len =
nstrftime (buf, sizeof buf, long_time_format[0], tm, 0, 0);
align_nstrftime (buf, sizeof buf, long_time_format[0], tm, 0, 0);
if (len != 0)
width = mbsnwidth (buf, len, 0);
}
@@ -3616,8 +3714,8 @@ print_long_format (const struct fileinfo *f)
/* We assume here that all time zones are offset from UTC by a
whole number of seconds. */
s = nstrftime (p, TIME_STAMP_LEN_MAXIMUM + 1, fmt,
when_local, 0, when_timespec.tv_nsec);
s = align_nstrftime (p, TIME_STAMP_LEN_MAXIMUM + 1, fmt,
when_local, 0, when_timespec.tv_nsec);
}
if (s || !*p)
@@ -4533,7 +4631,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
with -l: show access time and sort by name\n\
otherwise: sort by access time\n\
-U do not sort; list entries in directory order\n\
-v sort by version\n\
-v natural sort of (version) numbers within text\n\
"), stdout);
fputs (_("\
-w, --width=COLS assume screen width instead of current value\n\

View File

@@ -243,9 +243,9 @@ movefile (char *source, char *dest, bool dest_is_dir,
/* This code was introduced to handle the ambiguity in the semantics
of mv that is induced by the varying semantics of the rename function.
Some systems (e.g., Linux) have a rename function that honors a
Some systems (e.g., GNU/Linux) have a rename function that honors a
trailing slash, while others (like Solaris 5,6,7) have a rename
function that ignores a trailing slash. I believe the Linux
function that ignores a trailing slash. I believe the GNU/Linux
rename semantics are POSIX and susv2 compliant. */
if (remove_trailing_slashes)

View File

@@ -73,7 +73,7 @@
The interference of the POSIX-compliant small letter options -w and -s:
(`interference' means `setting a _separator_ with -s switches off the
column sturctur and the default - not generally - page_width,
column structure and the default - not generally - page_width,
acts on -w option')
options: text form / separator: equivalent new options:
-w l -s[x]
@@ -92,7 +92,7 @@
Options:
Including version 1.22i:
Some SMALL LETTER options has been redefined with the object of a
Some SMALL LETTER options have been redefined with the object of a
better POSIX compliance. The output of some further cases has been
adapted to other UNIXes. A violation of downward compatibility has to
be accepted.

View File

@@ -244,7 +244,7 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name,
The getcwd function performs nearly the same task, but is typically
unable to handle names longer than PATH_MAX. This function has
no such limitation. However, this function *can* fail due to
permission problems or a lack of memory, while Linux's getcwd
permission problems or a lack of memory, while GNU/Linux's getcwd
function works regardless of restricted permissions on parent
directories. Upon failure, give a diagnostic and exit nonzero.

View File

@@ -1125,9 +1125,9 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename,
DO_UNLINK (fd_cwd, filename, x);
/* Upon a failed attempt to unlink a directory, most non-Linux systems
set errno to the POSIX-required value EPERM. In that case, change
errno to EISDIR so that we emit a better diagnostic. */
/* Upon a failed attempt to unlink a directory, most non GNU/Linux
systems set errno to the POSIX-required value EPERM. In that case,
change errno to EISDIR so that we emit a better diagnostic. */
if (! x->recursive && errno == EPERM && is_dir_lstat (fd_cwd,
filename, st))
errno = EISDIR;

View File

@@ -167,7 +167,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
printf (_("\
-f, --force change permissions to allow writing if necessary\n\
-n, --iterations=N overwrite N times instead of the default (%d)\n\
--random-source=FILE get random bytes from FILE (default /dev/urandom)\n\
--random-source=FILE get random bytes from FILE\n\
-s, --size=N shred this many bytes (suffixes like K, M, G accepted)\n\
"), DEFAULT_PASSES);
fputs (_("\
@@ -450,8 +450,8 @@ dopass (int fd, char const *qname, off_t *sizep, int type,
/* If the first write of the first pass for a given file
has just failed with EINVAL, turn off direct mode I/O
and try again. This works around a bug in linux-2.4
whereby opening with O_DIRECT would succeed for some
and try again. This works around a bug in Linux kernel
2.4 whereby opening with O_DIRECT would succeed for some
file system types (e.g., ext3), but any attempt to
access a file through the resulting descriptor would
fail with EINVAL. */

View File

@@ -62,7 +62,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-i, --input-range=LO-HI treat each number LO through HI as an input line\n\
-n, --head-count=COUNT output at most COUNT lines\n\
-o, --output=FILE write result to FILE instead of standard output\n\
--random-source=FILE get random bytes from FILE (default /dev/urandom)\n\
--random-source=FILE get random bytes from FILE\n\
-z, --zero-terminated end lines with 0 byte, not newline\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);

View File

@@ -1,5 +1,5 @@
/* sort - sort lines of text (with all kinds of options).
Copyright (C) 1988, 1991-2008 Free Software Foundation, Inc.
Copyright (C) 1988, 1991-2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -339,14 +339,14 @@ Ordering options:\n\
fputs (_("\
-n, --numeric-sort compare according to string numerical value\n\
-R, --random-sort sort by random hash of keys\n\
--random-source=FILE get random bytes from FILE (default /dev/urandom)\n\
--random-source=FILE get random bytes from FILE\n\
-r, --reverse reverse the result of comparisons\n\
"), stdout);
fputs (_("\
--sort=WORD sort according to WORD:\n\
general-numeric -g, month -M, numeric -n,\n\
random -R, version -V\n\
-V, --version-sort sort by numeric version\n\
-V, --version-sort natural sort of (version) numbers within text\n\
\n\
"), stdout);
fputs (_("\
@@ -2602,18 +2602,20 @@ avoid_trashing_input (struct sortfile *files, size_t ntemps,
pid_t pid;
char *temp = create_temp (&tftp, &pid);
size_t num_merged = 0;
while (i + num_merged < nfiles)
do
{
num_merged += mergefiles (&files[i], 0, nfiles - i, tftp, temp);
files[i].name = temp;
files[i].pid = pid;
memmove(&files[i], &files[i + num_merged],
num_merged * sizeof *files);
if (i + num_merged < nfiles)
memmove(&files[i + 1], &files[i + num_merged],
num_merged * sizeof *files);
ntemps += 1;
nfiles -= num_merged - 1;;
i += num_merged;
}
while (i < nfiles);
}
}

View File

@@ -184,7 +184,7 @@ static char const *trailing_delim = "";
Some systems have statfvs.f_basetype[FSTYPSZ] (AIX, HP-UX, and Solaris).
Others have statvfs.f_fstypename[_VFS_NAMELEN] (NetBSD 3.0).
Others have statfs.f_fstypename[MFSNAMELEN] (NetBSD 1.5.2).
Still others have neither and have to get by with f_type (Linux).
Still others have neither and have to get by with f_type (GNU/Linux).
But f_type may only exist in statfs (Cygwin). */
static char const *
human_fstype (STRUCT_STATVFS const *statfsbuf)

View File

@@ -471,7 +471,7 @@ main (int argc, char **argv)
error (EXIT_FAILURE, 0, _("user %s does not exist"), new_user);
/* Make a copy of the password information and point pw at the local
copy instead. Otherwise, some systems (e.g. Linux) would clobber
copy instead. Otherwise, some systems (e.g. GNU/Linux) would clobber
the static data through the getlogin call from log_su.
Also, make sure pw->pw_shell is a nonempty string.
It may be NULL when NEW_USER is a username that is retrieved via NIS (YP),

View File

@@ -683,7 +683,7 @@ bad_cast (char const *s)
Note that this is to minimize system call overhead.
Other values may be appropriate to minimize file system
or disk overhead. For example on my current linux system
or disk overhead. For example on my current GNU/Linux system
the readahead setting is 128KiB which was read using:
file="."

View File

@@ -73,7 +73,7 @@
#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
/* Note ETIMEDOUT is 110 on linux but this is non standard */
/* Note ETIMEDOUT is 110 on GNU/Linux systems but this is non standard */
#define EXIT_TIMEDOUT 124
/* Internal failure. */
@@ -311,11 +311,11 @@ main (int argc, char **argv)
alarm (timeout);
/* We're just waiting for a single process here, so wait() suffices.
Note the signal() calls above on linux and BSD at least, essentially
call the lower level sigaction() with the SA_RESTART flag set, which
ensures the following wait call will only return if the child exits,
not on this process receiving a signal. Also we're not passing
WUNTRACED | WCONTINUED to a waitpid() call and so will not get
Note the signal() calls above on GNU/Linux and BSD at least,
essentially call the lower level sigaction() with the SA_RESTART flag
set, which ensures the following wait call will only return if the
child exits, not on this process receiving a signal. Also we're not
passing WUNTRACED | WCONTINUED to a waitpid() call and so will not get
indication that the child has stopped or continued. */
wait (&status);

View File

@@ -229,7 +229,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode)
/* Complain only when ftruncate fails on a regular file, a
directory, or a shared memory object, as POSIX 1003.1-2004
specifies ftruncate's behavior only for these file types.
For example, do not complain when Linux 2.4 ftruncate
For example, do not complain when Linux kernel 2.4 ftruncate
fails on /dev/fd0. */
int const ftruncate_errno = errno;
if (fstat (fd, &sb) != 0)

View File

@@ -49,16 +49,9 @@ sub chmod_tree
defined $dir
or return;
if (chdir $dir)
{
# Perform the equivalent of find . -type d -print0|xargs -0 chmod -R 700.
my $options = {untaint => 1, wanted => \&chmod_1};
find ($options, '.');
}
else
{
warn "$ME: failed to chdir to $dir: $!\n";
}
# Perform the equivalent of find "$dir" -type d -print0|xargs -0 chmod -R 700.
my $options = {untaint => 1, wanted => \&chmod_1};
find ($options, $dir);
}
sub import {
@@ -105,6 +98,11 @@ sub import {
}
END {
# Move cwd out of the directory we're about to remove.
# This is required on some systems, and by some versions of File::Temp.
chdir '..'
or warn "$ME: failed to chdir to .. from $dir: $!\n";
my $saved_errno = $?;
chmod_tree;
$? = $saved_errno;

View File

@@ -23,6 +23,7 @@ root_tests = \
cp/cp-a-selinux \
cp/preserve-gid \
cp/special-bits \
cp/cp-mv-enotsup-xattr \
dd/skip-seek-past-dev \
install/install-C-root \
ls/capability \
@@ -171,6 +172,7 @@ TESTS = \
misc/head-c \
misc/head-pos \
misc/id-context \
misc/id-groups \
misc/md5sum \
misc/md5sum-newline \
misc/mknod \
@@ -280,6 +282,7 @@ TESTS = \
cp/parent-perm-race \
cp/perm \
cp/preserve-2 \
cp/proc-short-read \
cp/proc-zero-len \
cp/r-vs-symlink \
cp/same-file \
@@ -331,6 +334,7 @@ TESTS = \
ln/misc \
ln/sf-1 \
ln/target-1 \
ls/abmon-align \
ls/color-clear-to-eol \
ls/color-dtype-dir \
ls/dangle \
@@ -587,5 +591,4 @@ pr_data = \
pr/ttb3-FF \
pr/w72l24f-ll
AUTOMAKE_OPTIONS =
include $(srcdir)/check.mk

View File

@@ -58,7 +58,7 @@ TESTS_ENVIRONMENT = \
if $(PERL) -e 'use warnings' > /dev/null 2>&1; then \
grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=T || T_=; \
$(PERL) -w$$T_ -I$(srcdir) -MCoreutils \
-M"CuTmpdir qw($$tst)" -- "$$1"; \
-M"CuTmpdir qw($$f)" -- "$$1"; \
else \
echo 1>&2 "$$tst: configure did not find a usable version of Perl," \
"so skipping this test"; \
@@ -94,10 +94,4 @@ TESTS_ENVIRONMENT = \
PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
; shell_or_perl_
TEST_LOGS = $(TESTS:=.log)
# Parallel replacement of Automake's check-TESTS target.
SUFFIXES =
include $(top_srcdir)/build-aux/check.mk
VERBOSE = yes

View File

@@ -78,6 +78,14 @@ cp --preserve=context f g 2> out && fail=1
# Here, we *do* expect the destination to be empty.
test -s g && fail=1
rm -f g
echo > g
# Check if -a option doesn't silence --preserve=context option diagnostics
cp -a --preserve=context f g 2> out2 && fail=1
# Here, we *do* expect the destination to be empty.
test -s g && fail=1
# An alternative to the current approach would be to run in a confined
# domain (maybe creating/loading it) that lacks the required permissions
# to the file type.
@@ -87,11 +95,14 @@ test -s g && fail=1
# Operation not supported
sed "s/ .g' to .*//" out > k
mv k out
sed "s/ .g' to .*//" out2 > k
mv k out2
cat <<\EOF > exp || fail=1
cp: failed to set the security context of
EOF
compare out exp || fail=1
compare out2 exp || fail=1
Exit $fail

90
tests/cp/cp-mv-enotsup-xattr Executable file
View File

@@ -0,0 +1,90 @@
#!/bin/sh
# Ensure that mv, cp -a and cp --preserve=xattr(all) options do work
# as expected on file system without their support and do show correct
# diagnostics when required
# Copyright (C) 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
mv --version
fi
. $srcdir/test-lib.sh
require_root_
cwd=`pwd`
cleanup_() { cd /; umount "$cwd/mnt"; }
# Create a file system without user xattr support, then mount it.
dd if=/dev/zero of=blob bs=8192 count=200 > /dev/null 2>&1 \
|| framework_failure
mkdir mnt || framework_failure
mkfs -t ext2 -F blob ||
skip_test_ "failed to create ext2 file system"
mount -oloop,nouser_xattr blob mnt || framework_failure
echo test > mnt/f || framework_failure
test -s mnt/f || framework_failure
# testing xattr name-value pair
xattr_name="user.foo"
xattr_value="bar"
xattr_pair="$xattr_name=\"$xattr_value\""
echo test > a || framework_failure
getfattr -d a >out_a || skip_test_ "failed to get xattr of file"
grep -F "$xattr_pair" out_a >/dev/null && framework_failure
setfattr -n "$xattr_name" -v "$xattr_value" a >out_a \
|| skip_test_ "failed to set xattr of file"
getfattr -d a >out_a || skip_test_ "failed to get xattr of file"
grep -F "$xattr_pair" out_a >/dev/null \
|| skip_test_ "failed to set xattr of file"
fail=0 || framework_failure
# This should pass without diagnostics
cp -a a mnt/ 2>err || fail=1
test -s mnt/a || fail=1 # destination file must not be empty
test -s err && fail=1 # there must be no stderr output
rm -f err mnt/a
# This should pass without diagnostics
cp --preserve=all a mnt/ 2>err || fail=1
test -s mnt/a || fail=1 # destination file must not be empty
test -s err && fail=1 # there must be no stderr output
rm -f err mnt/a
# This should fail with coresponding diagnostics
cp -a --preserve=xattr a mnt/ 2>err && fail=1
cat <<\EOF > exp || fail=1
cp: setting attributes for `mnt/a': Operation not supported
EOF
compare err exp || fail=1
rm -f err mnt/a
# This should pass without diagnostics
mv a mnt/ 2>err || fail=1
test -s mnt/a || fail=1 # destination file must not be empty
test -s err && fail=1 # there must be no stderr output
Exit $fail

45
tests/cp/proc-short-read Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/sh
# exercise cp's short-read failure when operating on >4KB files in /proc
# Copyright (C) 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
fail=0
kall=/proc/kallsyms
test -r $kall || skip_test_ "your system lacks $kall"
# Before coreutils-7.3, cp would copy less than 4KiB of this 1MB+ file.
cp $kall 1 || fail=1
cat $kall > 2 || fail=1
compare 1 2 || fail=1
# Also check md5sum, just for good measure.
md5sum $kall > 3 || fail=1
md5sum 2 > 4 || fail=1
# Remove each file name before comparing checksums.
sed 's/ .*//' 3 > sum.proc || fail=1
sed 's/ .*//' 4 > sum.2 || fail=1
compare sum.proc sum.2 || fail=1
Exit $fail

View File

@@ -84,7 +84,7 @@ if ! truncate --size=$OFF_T_MAX in 2>/dev/null; then
# so just check for the skip warning.
compare skip_err err || fail=1
else
# On Linux at least lseek(>max file size) fails.
# On Linux kernels at least, lseek(>max file size) fails.
# error message should be "... cannot skip: strerror(EINVAL)"
grep "cannot skip:" err >/dev/null || fail=1
fi

View File

@@ -26,7 +26,7 @@ skip_if_setgid_
mode1=0644
mode2=0755
mode3=1755
mode3=2755
fail=0

51
tests/ls/abmon-align Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
# Ensure ls output is aligned when using abbreviated months from the locale
# Copyright (C) 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
ls --version
fi
. $srcdir/test-lib.sh
for mon in $(seq -w 12); do
touch -d"+$mon month" $mon.ts || framework_failure
done
fail=0
# Note some of the following locales may be missing but if so
# we should fail back to the C locale which should be aligned
for format in "%b" "[%b" "%b]" "[%b]"; do
for LOC in C gv_GB ga_IE fi_FI.utf8 zh_CN ar_SY $LOCALE_FR_UTF8; do
n_widths=$(
LC_ALL=$LOC TIME_STYLE=+"$format" ls -lgG *.ts |
LC_ALL=C sed '1d; s/.\{15\}\(.*\) ...ts$/\1/; s/ /./g' |
while read mon; do echo "$mon" | LC_ALL=$LOC wc -L; done |
uniq | wc -l
)
test "$n_widths" = "1" || { fail=1; break 2; }
done
done
if test "$fail" = "1"; then
echo "misalignment detected in $LOC locale:"
LC_ALL=$LOC TIME_STYLE=+%b ls -lgG *.ts
fi
Exit $fail

28
tests/misc/id-groups Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/sh
# Ensure that "id" outputs groups for a user
# Copyright (C) 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
id --version
fi
. $srcdir/test-lib.sh
fail=0
id -G $(id -nu) || fail=1
Exit $fail

View File

@@ -240,10 +240,10 @@ $fail
and exit 1;
# Be careful to use the just-build dircolors.
my $e = `$ENV{abs_top_builddir}/src/dircolors -b`;
$e =~ s/^LS_COLORS=\'//;
$e =~ s/\';.*//sm;
$ENV{LS_COLORS} = $e;
my $env = `$ENV{abs_top_builddir}/src/dircolors -b`;
$env =~ s/^LS_COLORS=\'//;
$env =~ s/\';.*//sm;
$ENV{LS_COLORS} = $env;
setuid_setup;
$fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);

View File

@@ -1,6 +1,6 @@
#!/usr/bin/perl
# Copyright (C) 2008 Free Software Foundation, Inc.
# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -339,6 +339,21 @@ my @Tests =
["sort-numeric", '--sort=numeric', {IN=>".01\n0\n"}, {OUT=>"0\n.01\n"}],
["sort-gennum", '--sort=general-numeric',
{IN=>"1e2\n2e1\n"}, {OUT=>"2e1\n1e2\n"}],
# -m with output file also used as an input file
# In coreutils-7.2, this caused a segfault.
# This test looks a little strange. Here's why:
# since we're using "-o f", standard output will be empty, hence OUT=>''
# We still want to ensure that the output file, "f" has expected contents,
# hence the added CMP=> directive.
["output-is-input", '-m -o f', {IN=> {f=> "a\n"}}, {OUT=>''},
{CMP=> ["a\n", {'f'=> undef}]} ],
["output-is-input-2", '-m -o f', {OUT=>''},
{IN=> {f=> "a\n"}}, {IN=> {g=> "b\n"}}, {IN=> {h=> "c\n"}},
{CMP=> ["a\nb\nc\n", {'f'=> undef}]} ],
["output-is-input-3", '-m -o f', {OUT=>''},
{IN=> {g=> "a\n"}}, {IN=> {h=> "b\n"}}, {IN=> {f=> "c\n"}},
{CMP=> ["a\nb\nc\n", {'f'=> undef}]} ],
);
# Add _POSIX2_VERSION=199209 to the environment of each test
@@ -354,6 +369,14 @@ foreach my $t (@Tests)
@Tests = triple_test \@Tests;
# Remember that triple_test creates from each test with exactly one "IN"
# file two more tests (.p and .r suffix on name) corresponding to reading
# input from a file and from a pipe. The pipe-reading test would fail
# due to a race condition about 1 in 20 times.
# Remove the IN_PIPE version of the "output-is-input" test above.
# The others aren't susceptible because they have three inputs each.
@Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests;
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};

View File

@@ -35,6 +35,9 @@ fail=0
ls /dev/stdin >/dev/null 2>&1 \
|| skip_test_ 'there is no /dev/stdin file'
test -r /dev/stdin 2>&1 \
|| skip_test_ '/dev/stdin is not readable'
mv f g < /dev/stdin > out 2>&1 & pid=$!
sleep 1
kill $pid