Compare commits

...

195 Commits
v7.0 ... v7.1

Author SHA1 Message Date
Jim Meyering
74ba433a14 version 7.1
* NEWS: Record release date.
2009-02-21 22:35:33 +01:00
Jim Meyering
c980b0566a * README: Mention that c99-to-c89.diff is no longer maintained. 2009-02-21 21:32:17 +01:00
Jim Meyering
31896c21c6 tests: skip new install-C test if working directory is set-gid
* tests/install/install-C: Use setgid-check.
2009-02-21 19:49:40 +01:00
Jim Meyering
773a88d33f tests: skip newly-modified tests unconditionally, just to be safe
* tests/misc/stty-invalid: Skip.
* tests/misc/stty: Likewise.
* tests/mv/i-3: Likewise.
2009-02-21 16:52:42 +01:00
Jim Meyering
cd78f85b0b tests: don't let SIGTTOU/TTIN hang a backgrounded "make check"
Running "make check &" would hang due to SIGTTOU and SIGTTIN signals.
* tests/misc/stty: Ignore SIGTTOU.
* tests/misc/stty-invalid: Likewise.
* tests/mv/i-3: Ignore SIGTTIN.
2009-02-21 16:52:39 +01:00
Jim Meyering
2061cd8aa6 doc: ls: clarify description of -s
* src/ls.c (usage): Make the description of -s mention "allocated size",
so that it's less likely to be confused with an apparent byte-count.
Suggested by Vito Caputo.
2009-02-20 19:32:02 +01:00
Jim Meyering
0c91ae335d doc: dd: document that the default block size is 512 bytes
* src/dd.c (usage): Document the default block size.
* doc/coreutils.texi (dd invocation): Document that the default
block size (bs, ibs, obs) is 512 bytes.
Reported by Petr Uzel.
2009-02-19 12:45:18 +01:00
Jim Meyering
0e40e9de57 maint: changing NEWS' copyright date must not invalidate checksum
* maint.mk (NEWS_hash): Don't let the Copyright date line contribute
to the checksum.
* cfg.mk (old_NEWS_hash): Update to reflect the new policy.
2009-02-18 16:09:45 +01:00
Jim Meyering
0a3f944791 doc: explain how to recover from changes committed to master
* HACKING: A beginner's commit-to-master is so common,
and causes enough confusion, that we describe how to recover.
2009-02-18 15:40:53 +01:00
Jim Meyering
fa391362e1 maint: add copyright notices
* HACKING: Add copyright notice.
* tests/test-lib.sh: Likewise.
2009-02-18 15:40:44 +01:00
Ondřej Vašík
8c243ff965 cp: -a now preserves SELinux context, with reduced diagnostics
* copy.c (copy_reg): Reduce SELinux context diagnostics for 'cp -a'.
(copy_internal): Likewise
* copy.h (cp_options): Add boolean reduce_diagnostics.
* cp.c (usage): Say that --archive (-a) behaves like -dR --preserve=all.
(cp_option_init): Initialize added reduce_diagnostics.
(main): Add reduce_diagnostics for the -a option, and preserve SELinux
context, if possible.
* mv.c (cp_options_init): Initialize new cp_options booleans.
* install.c (cp_option_init): Likewise.
* NEWS: Mention those behaviour changes.
* doc/coreutils.texi: Document --preserve=context, document that
diagnostics are not shown for failures of non-mandatory attributes
(just SELinux at the moment).
* tests/cp/cp-a-selinux: Check not only failures, but succesful use
of preserving SELinux context in cp.
2009-02-18 15:27:10 +01:00
Eric Blake
86cef85b36 add missing copyright dates
* NEWS: Add 2009 to copyright.
* README: Likewise.
* README-hacking: Likewise.
* TODO: Likewise.
* doc/Makefile.am: Likewise.
* m4/prereq.m4: Likewise.
* src/nl.c: Likewise.
* src/seq.c: Likewise.
* tests/cp/cp-i: Likewise.
* tests/install/install-C: Likewise.
* tests/install/install-C-root: Likewise.
* tests/install/install-C-selinux: Likewise.
* tests/misc/seq: Likewise.
* tests/mv/mv-n: Likewise.
2009-02-18 06:07:30 -07:00
Eric Blake
65ba955988 install: compare files in binary mode
* src/install.c (need_copy): Use O_BINARY when it matters.
2009-02-17 07:58:39 -07:00
Kamil Dudka
dac5f12c6e install: add --compare (-C) option to install file only when necessary
* src/install.c (have_same_content): New function to compare files
content.
(extra_mode): New function checking for non-permission bits in mode.
(need_copy): New function to check if copy is necessary.
(main): Handle new option --compare (-C).
(copy_file): Skip file copying if not necessary.
(usage): Show new option --compare (-C) in --help.
* tests/install/install-C: Basic tests for install --compare (-C).
* tests/install/install-C-root: Tests requiring root privileges.
* tests/install/install-C-selinux: Tests requiring SELinux.
* tests/Makefile.am: Add new tests for install --compare (-C).
* doc/coreutils.texi: Document new install option --compare (-C).
* NEWS: Mention the change.
2009-02-17 14:12:44 +01:00
Ondřej Vašík
26d3d090bd nl: correct long-option name for -v in usage
* nl.c (usage): Use --starting-line-number, not --first-page for -v
2009-02-17 14:10:39 +01:00
Jim Meyering
1eaacac312 doc: id: make --help and .man more descriptive
* src/id.c (usage): Improve description, based on a suggestion
from Brian M. Carlson in http://bugs.debian.org/514675
* man/id.x: Use a better one-liner, based on the one at top of id.c.
2009-02-15 10:17:19 +01:00
Pádraig Brady
5d0b158f4c seq: Fix equal width calculation when '.' added to last number
Issue reported by Samuel Hapák.
<http://lists.gnu.org/archive/html/bug-coreutils/2009-02/msg00139.html>

* src/seq.c: Account for '.' added to "last" number.
* tests/misc/seq: Add corresponding test.
* NEWS: Mention the fix.
2009-02-14 23:47:14 +00:00
Jim Meyering
982504452d du,chgrp,chmod,chown: use FTS_DEFER_STAT
* src/du.c (main): Use FTS_DEFER_STAT, for better locality of inode
reference.  Important when traversing file systems with fake inodes.
* src/chgrp.c (main): Likewise.
* src/chmod.c (main): Likewise.
* src/chown.c (main): Likewise.
The only remaining fts client, chcon, doesn't need this, since it goes
further and uses FTS_NOSTAT, which suppresses all non- directory
stat calls.
2009-02-13 18:41:01 +01:00
Pádraig Brady
48cae1e864 maint: mention how to run a single test in HACKING docs
* HACKING: Give an example of how to run a test in isolation.
* README: Fix/simplify example for running a single test.
* README-hacking: Reference the HACKING file.
2009-02-13 11:13:33 +00:00
Eric Blake
022889a457 ln: add details to --help text
* src/ln.c (usage): Mention more about symlink properties.
* doc/coreutils.texi (ln invocation): Likewise.
* THANKS: Update.
Reported by Vitali Lovich.

Signed-off-by: Eric Blake <ebb9@byu.net>
2009-02-11 21:26:51 -07:00
Jim Meyering
adc62b5d9f ls: clean up after wrapped+colored file names with clear-to-EOL
This change addresses a relatively unusual case: ls --color, with
a highlighted name being printed initially in the last row of a
terminal emulator (possibly followed by other lines of output) such
that it is wrapped onto the following line, as the terminal emulator
scrolls the output.  That would cause the entire following line to
be highlighted, even if the name happened to use only one position.
The least-invasive patch would have made colorized output larger for
all uses.  The approach taken below is more invasive, but limits the
increase in overhead to only those lines that are expected to wrap.
* src/ls.c (enum indicator_no): Add C_CLR_TO_EOL.
(indicator_name): Add "cl".
(color_indicator): Add default escape codes for "cl".
(print_long_format): Propagate width to print_name_with_quoting.
(print_name_with_quoting): Print new C_CLR_TO_EOL string if needed.
Return the width of what we're printing.
(print_file_name_and_frills): Propagate width.
(print_type_indicator): Return bool (aka width).
(print_many_per_line): Pass column position to print_* function.
(print_current_files): Likewise.
(print_horizontal): Likewise.
(print_with_commas): Likewise.
* src/dircolors.c (slack_codes): Add "CLRTOEOL".
(ls_codes): Add "cl".
* tests/ls/color-clear-to-eol: New file.  Test for this fix.
* tests/Makefile.am (TESTS): Add ls/color-clear-to-eol.
* THANKS: Update.
Reported by Alexander V. Lukyanov.  See thread for details:
http://thread.gmane.org/gmane.linux.kernel/740021/focus=14824
Thanks to Jan Engelhardt for helping me reproduce the problem.

Demonstrate with this in an 80-column xterm:
  seq 200 # to start in the "bottom" row
  touch zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.foo
  env LS_COLORS='*.foo=0;31;42' ls -og --color=always

Before the fix, you'd see something like this:
(where the file name is printed in red on a green background,
and each "=" denotes a space on a green background)
...
  -rw-r--r--  1       0 Feb  5 11:31 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\
  zzzzzzzzzzzzzz.foo===================================================

After the patch, the trailing green spaces are gone:

  -rw-r--r--  1       0 Feb  5 11:31 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\
  zzzzzzzzzzzzzz.foo
2009-02-10 14:47:39 +01:00
Jim Meyering
1f4fcd083d * tests/test-lib.sh: Use skip_test_... in place of echo...;exit 77. 2009-02-10 14:39:10 +01:00
Nix
9c8e4f6918 tests: avoid skipping stty-* tests
* tests/test-lib.sh (require_controlling_input_terminal_):
Check stdout, not stdin.
2009-02-10 14:38:42 +01:00
Jim Meyering
ed85df444a touch: deprecate --file option: equivalent to --reference (-r)
* src/touch.c: Mark long-undocumented --file for removal in 2010.
(main): Warn upon use of --file.
2009-02-09 11:44:40 +01:00
Pádraig Brady
0dc4478f13 tests: fix dd skip=greater_max_file_size test on Solaris 10
* tests/dd/skip-seek-past-file: I had previously commented that
on some systems lseek(> max file size) may succeed, but left
the possibility of failure in that case, so that I could determine
specific systems to put in the comments for both failure modes.
2009-02-06 07:46:08 +01:00
Jim Meyering
8ed84c3438 avoid spurious parentheses/arith-op-related warnings from newer gcc
* src/copy.c (set_owner): Use && rather than &.
* src/stty.c (main): Likewise.
* src/wc.c (wc): Likewise.
2009-02-05 14:53:10 +01:00
Jim Meyering
c55c0e7369 maint: tighten atoi/atof-prohibiting regexp, clean up .x-sc- file
* maint.mk (sc_prohibit_atoi_atof): Require "(" after token.
* .x-sc_prohibit_atoi_atof: Remove names that no longer contain a match.
2009-02-02 09:37:48 +01:00
Jim Meyering
e3e9713fad doc: preserve --help line breaks in 'REPORTING BUGS' man page section
* man/help2man: Insert .br between adjacent lines.
2009-02-02 09:37:48 +01:00
Jim Meyering
6b8578af5e * src/system.h (emit_bug_reporting_address): Remove periods. 2009-02-02 09:37:48 +01:00
Jim Meyering
04d49874a2 update copyright dates from recent changes
* src/dd.c: Add 2009 to list of copyright years.
* tests/dd/seek-skip-past-file: Likewise.
* tests/dd/seek-skip-past-dev: Likewise.
* m4/xattr.m4: Likewise.
* src/copy.h: Likewise.
2009-02-02 09:37:48 +01:00
Jim Meyering
18810ae65f * maint.mk (sc_redundant_const): Use $(_prohibit_regexp). 2009-02-02 09:37:48 +01:00
jidanni@jidanni.org
d3dcb10f90 date doc: warn at -d about LC_TIME
We also warn here about LC_TIME, so the user will know even if he
doesn't look in the @xref{Date input formats}.
2009-02-02 08:40:18 +01:00
jidanni@jidanni.org
52b4d2a51a document sort --ignore-case --unique interaction 2009-02-02 08:38:41 +01:00
Jim Meyering
2b32399fdc maint: detect useless inclusion of c-ctype.h
* maint.mk (sc_prohibit_c_ctype_without_use): New rule.
2009-01-31 09:39:12 +01:00
Jim Meyering
44421c22a3 maint: teach "make syntax-check" to print each check name as it's run
* maint.mk (%.m): New rules to print each syntax-checking rule name,
just before running its commands.
($(syntax-check-rules)): Depend on it.
2009-01-29 13:31:28 +01:00
Jim Meyering
61a42e3743 maint: silence some syntax-check rules
* cfg.mk (sc_strftime_check): Silence the rule.
(sc_tight_scope): Likewise.
* src/Makefile.am (check-AUTHORS): Likewise.
2009-01-29 13:31:15 +01:00
Jim Meyering
60ca9e1599 maint: factor syntax-check rules
* maint.mk (_ignore_case): New macro.
(_prohibit_regexp): Use it.
Factor many existing syntax-check rules to use $(_prohibit_regexp).
2009-01-29 13:30:45 +01:00
Kamil Dudka
0889381cbf cp/mv: add xattr support
This patch was originally written by Andreas Grünbacher, nowadays
available at
http://www.suse.de/~agruen/coreutils/5.91/coreutils-xattr.diff

* bootstrap.conf: Add gnulib module verror.
* po/POTFILES.in: Add lib/verror.c.
* m4/xattr.m4: Check for libattr availability, new configure option
--disable-xattr.
* m4/prereq.m4: Require gl_FUNC_XATTR.
* src/Makefile.am: Link cp, mv and ginstall with libattr.
* src/copy.h: Add preserve_xattr and require_preserve_xattr to
cp_options.
* src/copy.c (copy_attr_error): New function to handle errors during
xattr copying.
(copy_attr_quote): New function to quote file name in error messages
printed by libattr.
(copy_attr_free): Empty function requested by libattr to free quoted
string.
(copy_attr_by_fd): New fd-oriented function to copy xattr.
(copy_attr_by_name): New name-oriented function to copy xattr.
(copy_reg, copy_internal): Call copy_extended_attributes function.
* src/cp.c (usage): Mention new --preserve=xattr option.
(decode_preserve_arg): Handle new --preserve=xattr option.
* src/mv.c: Always attempt to preserve xattr.
* src/install.c: Never attempt to preserve xattr.
* tests/misc/xattr: New test for xattr support in cp, mv and install.
* tests/Makefile.am: Add the new test to list.
* doc/coreutils.texi: Mention xattr support, new --preserve=xattr
option.
* NEWS: Mention the change.
2009-01-29 13:26:07 +01:00
Jim Meyering
1bdf77ad52 system.h: add a comment re autoconf's new AC_PACKAGE_URL
* src/system.h (emit_bug_reporting_address): Add a comment
suggesting to use AC_PACKAGE_URL once we require autoconf-2.64.
2009-01-28 18:36:08 +01:00
Pádraig Brady
05a50b7848 tests: Fixup shred-passes test
* tests/misc/shred-passes: Set the $fail variable correctly.
The issue was noticed by Jim Meyering.
2009-01-28 16:43:52 +00:00
Pádraig Brady
2f61473e85 tests: Add a test to verify shred's default operations
* tests/Makefile.am: add new test
* tests/misc/shred-passes: Verify the operations shred
does by default to overwrite and remove a zero length file.
2009-01-28 15:39:18 +00:00
Pádraig Brady
460ebb078e dd: Better handle user specified offsets that are too big
Following are the before and after operations for seekable files,
for the various erroneous offsets handled by this patch:

skip beyond end of file
  before: immediately exit(0);
  after : immediately printf("cannot skip to specified offset"); exit(0);

skip > max file size
  before: read whole file and exit(0);
  after : immediately printf("cannot skip: Invalid argument"); exit(1);
seek > max file size
  before: immediately printf("truncate error: EFBIG"); exit(1);
  after : immediately printf("truncate error: EFBIG"); exit(1);

skip > OFF_T_MAX
  before: read whole device/file and exit(0);
  after : immediately printf("cannot skip:"); exit(1);
seek > OFF_T_MAX
  before: immediately printf("truncate error: offset too large"); exit(1);
  after : immediately printf("truncate error: offset too large"); exit(1);

skip > device size
  before: read whole device and exit(0);
  after : immediately printf("cannot skip: Invalid argument"); exit(1);
seek > device size
  before: read whole device and printf("write error: ENOSPC"); exit(1);
  after : immediately printf("cannot seek: Invalid argument"); exit(1);

* NEWS: Summarize this change in behavior.
* src/dd.c (skip): Add error checking for large seek/skip offsets on
seekable files, rather than deferring to using read() to advance offset.
(dd_copy): Print a warning if skip past EOF, as per FIXME comment.
* test/Makefile.am: Add 2 new tests.
* tests/dd/seek-skip-past-file: Add tests for first 3 cases above.
* tests/dd/seek-skip-past-dev: Add root only test for last case above.
2009-01-28 15:14:57 +00:00
Jim Meyering
0d5508de13 doc: emit better bug-reporting info, to help help2man
* src/system.h (emit_bug_reporting_address): End each "sentence"
with period, mark URLs with <...>.
Based on a suggestion from Eric Blake.
Use fputs on a string without %s, not printf.
2009-01-27 20:20:20 +01:00
Jim Meyering
ddf56e0440 doc: ensure that emit_bug_reporting_address changes propagate to *.1
* man/Makefile.am ($(MAN)): Depend on system.h.
2009-01-27 20:20:07 +01:00
Jim Meyering
2fbee63cc9 doc: restore "REPORTING BUGS" section to generated man pages
* man/help2man ($PAT_BUGS): Update regexp to match the newer
"Report PROG bugs ..." --help output, as well as "Report bugs...".
Reported by Eric Blake.
2009-01-27 19:17:14 +01:00
Jim Meyering
b27275c668 tests: generalize install-transform-check
* maint.mk (install-transform-check): Generalize to work also
in a project that installs manuals in a section other than "1".
2009-01-26 18:54:58 +01:00
Jim Meyering
016f8c9998 build: resolve conflict with new declaration from version-etc.h
* src/system.h (emit_bug_reporting_address): Define away,
now, gnulib's version-etc.h also declares this function.
In this package, we choose to include each program's name in
the diagnostic.  Define away the conflicting declaration.
(emit_bug_reporting_address): Also emit home page and
"General help..." links, like the new function does.
Reported by Bob Proulx.
2009-01-23 18:27:36 +01:00
Pádraig Brady
10f3e12a0d doc: shred: Correct docs on default number of overwrites.
* NEWS: Mention the change to the default number of passes.
* doc/Makefile.am: Update constants.texi with the default
number of passes shred uses, so that the documentation
will automatically reflect any future changes.
* doc/coreutils.texi (shred invocation): Update the description
of the --iterations option to have the correct default number,
while still conveying that there are 25 internal patterns
that may be useful.
2009-01-22 23:42:51 +00:00
Pádraig Brady
83ae1bdd44 shred: change default number of overwrites from 25 to 3
* src/shred.c: The concensus is that a default of 3
passes is appropriate for current drive technologies.
* src/TODO: Reference Paul Eggert's suggestion
of enhancing shred to conform to DoD 5220 rules.
2009-01-22 13:26:04 +00:00
Jim Meyering
2a8f5104cd m4: don't use AC_REQUIRE([AC_C_BIGENDIAN])
* m4/jm-macros.m4: Use AC_REQUIRE([gl_BIGENDIAN]) instead.
This avoids a subtle problem recently documented in autoconf:
http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=34e2c8d5484
2009-01-21 14:48:39 +01:00
Jim Meyering
065f14f471 no longer define *_FILENO constants
* src/system.h (STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO):
Remove definitions.  Now guaranteed by gnulib.
2009-01-19 21:27:57 +01:00
Jim Meyering
9a45c19667 build: use dist-xz, not dist-lzma, cont'd
* README-hacking: mention XZ utils
* README-prereq: Add a FIXME comment.
2009-01-19 13:47:04 +01:00
Jim Meyering
f6240c49df tests: tail-2/infloop-1 is racy
* tests/tail-2/infloop-1: Add a comment to that effect.
2009-01-19 12:09:12 +01:00
Jim Meyering
b52a88607f build: use dist-xz, not dist-lzma
* configure.ac (AM_INIT_AUTOMAKE): s/dist-lzma/dist-xz/.
Requires recent "xz" from git://ctrl.tukaani.org/lzma-utils.git
2009-01-18 13:20:26 +01:00
Jim Meyering
f15842de47 maint: remove obsolete sc_author_mark_check rule
* maint.mk (sc_author_mark_check): Remove rule.
"and" no longer appears in the definition of AUTHORS.
2009-01-16 23:31:04 +01:00
Jim Meyering
c926d002b5 Merge branch 'master' of git://git.sv.gnu.org/coreutils 2009-01-16 23:30:27 +01:00
Jim Meyering
31b6c0489a maint: enforce existing prohibition: no cvs $keywords$
* maint.mk (sc_prohibit_cvs_keyword): New rule.
2009-01-16 23:28:20 +01:00
Jim Meyering
a488f288a2 echo, printf, test: remove unused #include directives
* src/echo.c: Don't include "long-options.h". No longer used.
* src/printf.c: Likewise.
* src/test.c: Likewise.
2009-01-16 13:37:32 +01:00
Pádraig Brady
a7592cfcb2 pathchk: avoid -Wsign-compare warnings
* src/pathchk.c: Compare pathconf limits to _signed_ MAX constants,
as pathconf returns signed values.
2009-01-16 11:06:09 +00:00
Pádraig Brady
3288ebb0d7 pr: avoid -Wsign-compare warnings
* src/pr.c: Use unsigned variables in unsigned comparisons.
2009-01-16 11:06:09 +00:00
Pádraig Brady
9934f50282 shred: avoid -Wsign-compare warnings
* src/shred.c: Use already assigned signed variable sizeof_r,
rather than the unsigned sizeof(r). Don't use signed integer
overflow check that contemporary compilers may remove anyway.
2009-01-16 11:06:09 +00:00
Pádraig Brady
46d6df933e simplify mgetgroups() and avoid -Wsign-compare warnings
* gl/lib/mgetgroups.c: Avoid -Wsign-compare warning by using unsigned
types for the parameters of the new function realloc_groupbuf().
mgetgroups() was refactored to use this function rather than
explicitly allocating and copying from automatic storage itself.
* src/group-list.c: Use int rather than size_t as variable is
used in signed comparisons.
* src/id.c: ditto.
2009-01-16 11:06:09 +00:00
Eric Blake
7b1967351c test, echo, printf: don't accept option abbreviation
* src/test.c (main): Directly parse accepted options, thus
avoiding abbreviations.
* src/echo.c (main): Likewise.
* src/printf.c (main): Likewise.
2009-01-14 14:32:13 -07:00
Kamil Dudka
d01338eb3d cp/mv: add --no-clobber (-n) option to not overwrite target
* src/cp.c (usage): Show new option -n in --help.
(main): Handle new option -n.
* src/mv.c (usage): Show new option -n in --help.
(main): Handle new option -n.
* doc/coreutils.texi: Document new cp/mv option -n.
* tests/cp/cp-i: Add tests for -f, -i and -n options.
* tests/mv/mv-n: New test for mv -n.
* tests/Makefile.am: Add test mv/mv-n to the list.
* NEWS: Mention the change.
2009-01-14 09:09:22 +01:00
Eric Blake
a99c35b04d option handling: make exceptions more consistent
* doc/coreutils.texi (Common options): Not all utilities reject
option abbreviations.
* src/chroot.c (main): Report correct name on failure.
* src/echo.c (usage): Clarify long option usage.
* src/setuidgid.c (usage): Likewise.
* src/hostid.c (usage): Condense.
2009-01-08 07:57:36 -07:00
Jim Meyering
5e3a5ae519 * bootstrap.conf (avoided_gnulib_modules): Add dummy. 2009-01-07 22:57:19 +01:00
Jim Meyering
1fd718e93c * maint.mk: align some backslashes 2009-01-07 22:54:11 +01:00
Pádraig Brady
972967903d doc: pathchk description enhancements
* doc/coreutils.texi (pathchk invocation): Mention pathchk
checks validity (for current system) as well as portability.
Say messages go to stderr, and reorder description of checks
done for the -p option, to match what's done in code.
* src/pathchk.c (usage): Mention pathchk checks name validity.
Suggested clarifications were from Dan Jacobson.
2009-01-05 00:01:21 +00:00
Pádraig Brady
e0035fa4eb src/.gitignore: Ignore getlimits utility
* src/.gitignore: Ignore getlimits
2009-01-03 15:10:42 +00:00
Pádraig Brady
99be907838 tests: refactor to use the new getlimits utility
* tests/Coreutils.pm: Add function to make limits available
* tests/test-lib.sh: ditto
* tests/misc/join: Check for both SIZE_OFLOW and UINTMAX_OFLOW
rather than using arbitrary 2^128
* tests/misc/sort: ditto
* tests/misc/uniq: ditto
* tests/misc/printf: Check for both INT_OFLOW and INT_UFLOW
rather than using arbitrary -2^31
* tests/misc/seq-long-double: Check for INTMAX_OFLOW
rather than using arbitrary 2^63
* tests/misc/split-fail: Check --lines --bytes and --line-bytes
options limits on all platforms. Note getlimits obviates the
need to use expr to check if 32 bit integers are supported,
which I think was invalid anyway as expr now supports bignum?
* tests/misc/test: Check for UINTMAX_OFLOW rather than
using arbitrary 2^64 and 2^128. Check for INTMAX_UFLOW
rather than using arbitrary -2^64
* tests/misc/timeout-parameters: Check for UINT_OFLOW
rather than using arbitrary 2^32
* tests/misc/truncate-overflow: Don't depend on truncate
to determine if we're on a 32 or 64 bit platform and
instead use the various OFF_T limits
* tests/misc/sort-merge: Check for UINTMAX_OFLOW
rather than using arbitrary 2^64+1
* tests/misc/unexpand: ditto
2009-01-03 15:10:42 +00:00
Michael Meskes
1ead085826 stat: print file-system total inode count (%c) as an unsigned number
* src/stat.c (print_statfs): Print statfs.f_files, the total inode
count of a file system, as an unsigned number.
2009-01-03 09:42:39 +01:00
Jim Meyering
695682d514 tests: factor ls-misc (no semantic change)
* tests/misc/ls-misc: Factor out uses of "\e[0m".
2009-01-01 10:05:24 +01:00
Jim Meyering
442d63051c update copyright year
* doc/coreutils.texi: Likewise.
* tests/sample-test: Likewise.
2009-01-01 02:15:07 +01:00
Jim Meyering
7fc5292a29 improve M4 quoting
* configure.ac: Add quotes.
* gl/m4/mgetgroups.m4 (gl_MGETGROUPS): Likewise.
* m4/boottime.m4 (GNULIB_BOOT_TIME): Likewise.
* m4/check-decl.m4 (gl_CHECK_DECLS): Likewise.
* m4/gmp.m4 (cu_GMP): Likewise.
* m4/jm-macros.m4 (coreutils_MACROS, gl_CHECK_ALL_HEADERS): Likewise.
(gl_CHECK_ALL_TYPES): Likewise.
* m4/lib-check.m4 (cu_LIB_CHECK): Likewise.
* m4/stat-prog.m4 (cu_PREREQ_STAT_PROG): Likewise.

FYI, I first ran this command:
git ls-files | grep -E '\.(m4|ac)$' | xargs perl -pi \
-e 's/(AC_[A-Z_]+\()([^[()]+?)([,)])/$1\[$2]$3/g;' \
-e 's/(AC_[A-Z_]+\(\[[^,]+?\], )([^,[()]+?)([,)])/$1\[$2]$3/g;' \
-e 's/(AC_[A-Z_]+\((?:\[[^,]+?\], ){2})([^,[()]+?)([,)])/$1\[$2]$3/g'
Then I updated serial numbers and copyright dates manually.
Also, I manually added two pairs of quotes in boottime.m4.
2009-01-01 02:15:07 +01:00
Jim Meyering
cf5616a0aa bootstrap: don't use cmp's -s option when reading from a pipe
GNU cmp exits without reading all input when given the -s option,
and that can cause termination of the writing process via SIGPIPE.
Instead, when reading from a pipe, just redirect output to /dev/null
so that all input is read.
2009-01-01 02:15:07 +01:00
Jim Meyering
13601dd3cf maint: factor out common code; prohibit use of HAVE_MBRTOWC
* maint.mk (_prohibit_regexp): New macro.
(sc_avoid_if_before_free, sc_cast_of_argument_to_free):
(sc_cast_of_x_alloc_return_value, sc_cast_of_alloca_return_value):
(sc_space_tab, sc_prohibit_atoi_atof, sc_prohibit_strcmp):
(sc_prohibit_stat_st_blocks, sc_prohibit_S_IS_definition): Use it.
(sc_prohibit_HAVE_MBRTOWC): New rule.
2009-01-01 02:15:07 +01:00
Jim Meyering
1ee192a9ff maint: use more sc_-prefixed names
* maint.mk (sc_po_check): Renamed from po-check.
(sc_author_mark_check): Renamed from author_mark_check.
(sc_copyright_check): Renamed from copyright-check.
(sc_makefile_path_separator_check): Renamed from
makefile_path_separator_check.
(local-checks-available): Remove the old names.
* Makefile.am (EXTRA_DIST): Reflect the renaming: .x-sc_po_check
* .x-po-check: Rename to...
* .x-sc_po_check: ...new file.
2009-01-01 02:15:07 +01:00
Jim Meyering
cbecb8cab8 maint: tighten m4 AC_ quoting check
* maint.mk (sc_m4_quote_check): Renamed from m4-check.
Also search for AC_DEFINE and AC_DEFINE_UNQUOTED.
Also search in configure.ac.
* configure.ac: Quote first argument of AC_DEFINE.
* jm-macros.m4 (coreutils_MACROS): Quote the first argument to AC_DEFINE.
2009-01-01 02:15:07 +01:00
Jim Meyering
fb992bae4c maint: move coreutils-specific syntax check rules into cfg.mk
* maint.mk (sc_dd_max_sym_length, sc_prohibit_jm_in_m4):
(sc_root_tests, sc_always_defined_macros, sc_system_h_headers):
(sc_sun_os_names, sc_tight_scope, sc_no_exec_perl_coreutils):
Move rules into cfg.mk.
(sc_strftime_check): Renamed from strftime-check, and moved, too.
* cfg.mk: Add the above rules.
2009-01-01 02:15:07 +01:00
Jim Meyering
ac9e4915ad portability: accommodate gnulib's getaddrinfo change
* src/Makefile.am (pinky_LDADD, who_LDADD): Append $(GETADDRINFO_LIB)
2009-01-01 02:15:07 +01:00
Jim Meyering
92465d59c6 cleanup/modernize: don't test HAVE_MBRTOWC; now gnulib provides it
* bootstrap.conf (gnulib_modules): Include mbrtowc explicitly.
* src/ls.c (quote_name): Don't test HAVE_MBRTOWC, now that we're
guaranteed to have the function.
* src/wc.c (wc): Likewise.
2009-01-01 02:15:07 +01:00
Eric Blake
921feefb12 doc: mention long option abbreviation
* doc/coreutils.texi (Common options): Give example of
abbreviating options.
* THANKS: Update.
Reported by Adam Jimerson.
2008-12-27 10:32:58 -07:00
Jim Meyering
0c65638b0f maint: ensure dd's computation of O_FULLBLOCK uses all O_ symbol names
* src/dd.c (O_FULLBLOCK): Use a more uniform initializer, that makes
it easier to extract all O_ symbol names.
* maint.mk (syntax-check-rules): Also search for sc_ rules in cfg.mk.
(sc_root_tests): Ensure that this rule sets $diff.
* cfg.mk (sc_dd_O_FLAGS): New rule.
2008-12-26 12:08:51 +01:00
Matt Harden
5c065bb0cb dd: add support for opening files in Concurrent I/O (CIO) mode
* src/dd.c (O_CIO): New flag.
* src/dd.c (O_FULLBLOCK): Add O_CIO to the list of flags that
O_FULLBLOCK should be greater than.
* src/dd.c (flags): Give the name "cio" to the new O_CIO flag, mirroring
the treatment of O_DIRECT.
* src/dd.c (usage): Add a description of the new flag when it is available.
* doc/coreutils.text (dd invocation): Describe the new flag.
* NEWS: Mention the new feature.
2008-12-26 10:57:05 +01:00
Jim Meyering
680afe6751 build: do enable $(WERROR_CFLAGS) for src/ files.
This reverts the more recent commit (of two) entitled "build:
add configure-time --enable-gcc-warnings option; avoid warnings".
Pádraig Brady spotted the contradiction between the log message
and actual change.

This reverts commit 292d68565a.
2008-12-23 17:22:57 +01:00
Pádraig Brady
0fcf730104 doc: stty: Clarification of some input and output settings
* doc/coreutils.texi (stty invocation): Clarify any
ambiguity in regard to the direction of input and output settings.
Add some notes on the case changing settings.
Most of the text was supplied by Dan Jacobson.
2008-12-23 14:26:22 +00:00
Pádraig Brady
f144582e17 timeout: remove problematic casts
* src/timeout.c (apply_time_suffix): Change input parameter from
unsigned int to unsigned long, which is the type of the variable it's
actually manipulating.  This removes the need for the cast which was
giving a warning with the gcc options: -fstrict-aliasing
-Wstrict-aliasing.  Also add a check for overflow possible on 16-bit
platforms, and fix indents.
(main): Remove a redundant cast in the alarm() call.
2008-12-23 10:29:05 +00:00
Jim Meyering
9a913a2461 * .x-sc_require_config_h: Remove obsolete regexps. 2008-12-21 17:50:09 +01:00
Jim Meyering
317d2c6384 maint.mk: enforce the "include <config.h> first" rule
* maint.mk (sc_require_config_h_first): New rule.
* .x-sc_require_config_h_first: New file.
2008-12-21 17:49:58 +01:00
Jim Meyering
292d68565a build: add configure-time --enable-gcc-warnings option; avoid warnings
* bootstrap.conf (gnulib_modules): Add "warnings" module.
* configure.ac: Add --enable-gcc-warnings, derived from code in bison.
* src/Makefile.am (AM_CFLAGS): Set to $(WARN_CFLAGS) # $(WERROR_CFLAGS)
* lib/Makefile.am (AM_CFLAGS): Change spelling to $(WARN_CFLAGS)
Don't use $(WERROR_CFLAGS), yet.
* src/system.h (usage): Declare.
* src/base64.c (usage): Declare to be global, for consistency.
* src/timeout.c (usage): Likewise.
* src/truncate.c (usage): Likewise.
* src/getlimits.c (usage): Likewise.
* src/pinky.c (ttyname): Declare with prototype, rather than an
empty argument list.
* src/who.c (ttyname): Likewise.
* src/su.c (crypt, getusershell, setusershell, endusershell): Likewise.
2008-12-21 17:49:58 +01:00
Jim Meyering
c352bb469d build: turn on $(WERROR_CFLAGS) for src/ 2008-12-21 17:49:58 +01:00
Jim Meyering
22a2a43021 build: add configure-time --enable-gcc-warnings option; avoid warnings
* bootstrap.conf (gnulib_modules): Add "warnings" module.
* configure.ac: Add --enable-gcc-warnings, derived from code in bison.
* src/Makefile.am (AM_CFLAGS): Set to $(WARN_CFLAGS) # $(WERROR_CFLAGS)
* lib/Makefile.am (AM_CFLAGS): Change spelling to $(WARN_CFLAGS)
Don't use $(WERROR_CFLAGS), yet.
* src/system.h (usage): Declare.
* src/base64.c (usage): Declare to be global, for consistency.
* src/timeout.c (usage): Likewise.
* src/truncate.c (usage): Likewise.
* src/getlimits.c (usage): Likewise.
* src/pinky.c (ttyname): Declare with prototype, rather than an
empty argument list.
* src/who.c (ttyname): Likewise.
* src/su.c (crypt, getusershell, setusershell, endusershell): Likewise.
2008-12-21 17:49:58 +01:00
Pádraig Brady
4000c35ae3 doc: Remove curly quotes from shell examples in man pages
Use \(aq rather than a literal ' as groff will convert apostrophe
to a right quote (\u2029) in utf8 locales for example.
Stepan Kasal details the issue and fix here:
http://lists.gnu.org/archive/html/bug-coreutils/2008-12/msg00124.html
2008-12-17 10:47:23 +00:00
Jim Meyering
99eccc3359 ChangeLog-2008: say ChangeLog files are no longer manually maintained
and point to HACKING's policy.  Suggestion from Dan Jacobson.
2008-12-16 08:15:39 +01:00
Jim Meyering
9965d234e5 du: -H now does what POSIX requires
* src/du.c (usage): Update --help output.
(main): Move -H-handling code from the --si block to
the one for --dereference-args (-D).
* doc/coreutils.texi (du invocation): Update description.
* NEWS (Changes in behavior): Mention this.
2008-12-16 08:04:01 +01:00
Jim Meyering
a011b01af1 doc: pr: formatting corrections
* doc/coreutils.texi (pr invocation): Fix some overzealous uses of @var.
Reported by Andreas Schwab.
2008-12-13 18:00:47 +01:00
Ralf Wildenhues
28fbe5a487 more portable bootstrap procedure
* bootstrap (get_version): Fix portability issues in sed script.
(check_versions): For buildreq apps, honor the corresponding
$APP variable like $AMTAR, $AUTOCONF.
(usage): Document this.
(update_po_files): Honor $SHA1SUM.
(main): Honor $AUTOPOINT, $ACLOCAL, $AUTOCONF, $AUTOHEADER,
$AUTOMAKE, $LIBTOOLIZE.
2008-12-13 18:00:44 +01:00
Jim Meyering
9b8023e69c tests: ensure that chmod, chgrp and chown honor --silent
* tests/chmod/silent: New file, to test all three programs.
* tests/Makefile.am (TESTS): Add chmod/silent.
* NEWS (Bug fixes): Mention this.
The bug was introduced in 96a5d2ce6a.
2008-12-03 11:02:57 +01:00
Ondřej Vašík
b8497a3a7a chmod, chown, chgrp: honor --silent (-f) once again
* chmod.c (process_file): Make -f suppress fts-related diagnostics.
* chown-core.c (change_file_owner): Likewise.
Reported via <http://bugzilla.redhat.com/474220>.
2008-12-03 11:02:45 +01:00
Jim Meyering
c2e56e0de7 wc: read and process --files0-from= input a name at a time,
when the file name list is not too large.  Before, wc would always read
the entire file name list into memory and *then* process each file name.
wc does read the list into memory when the list is known not to be too
large; this is done in order to be able to align the output numbers,
as it does with arguments specified on the command-line
* src/wc.c: Include "argv-iter.h".
(main): Rewrite to use argv-iter when the input file name list
is known to be too large.
* NEWS (Bug fixes): Mention it.
2008-12-02 13:12:22 +01:00
Jim Meyering
031e2fb5e9 du: read and process --files0-from= input a name at a time,
rather than by reading the entire input into memory and *then*
processing each file name.
* src/du.c: Include "argv-iter.h", not "readtokens0.h".
(main): Rewrite to use argv-iter.
Call xfts_open on each argument, rather than on the entire
argv list at once.
Call print_size here, not from du_files.
Diagnose read failure.
* NEWS (Bug fixes): Mention it.
* THANKS: update.
Reported by Barry Kelly.  More details in
http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/15159/
2008-12-02 13:12:13 +01:00
Jim Meyering
e181802521 seq: plug a leak
* src/factor.c (emit_ul_factor): Call mpz_clear.
2008-12-01 22:44:20 +01:00
Jim Meyering
c58b5daa33 avoid warnings about initialization of automatic aggregates
* src/system.h (DZA_CONCAT0, DZA_CONCAT): New macros.
(DECLARE_ZEROED_AGGREGATE): New macro.
* src/ls.c (quote_name): Use it.
* src/pathchk.c (portable_chars_only): Use it.
* src/shred.c (main): Use it.
* src/stty.c (main): Use it.
* src/wc.c (SUPPORT_OLD_MBRTOWC): Use it.
2008-12-01 21:18:52 +01:00
Jim Meyering
80325aca2d * bootstrap.conf (gnulib_modules): Add argv-iter. 2008-12-01 17:41:18 +01:00
Jim Meyering
d3b5555f10 argv-iter: add tests
* gl/modules/argv-iter-tests: New module.
* gl/tests/test-argv-iter.c: New file.
2008-12-01 17:41:08 +01:00
Jim Meyering
ca738e4414 argv-iter: new module
* gl/lib/argv-iter.h: New file.
* gl/lib/argv-iter.c: New file.
* gl/modules/argv-iter: New file.
With a suggestion for improved memory management by Pádraig Brady.
2008-12-01 17:40:59 +01:00
Jim Meyering
21eb87e6ea * src/hostname.c (sethostname) [!HAVE_SETHOSTNAME]: Remove declaration. 2008-12-01 17:40:27 +01:00
Jim Meyering
7ef56a26fd cp, mv: remove 3-year-deprecated+warned-about --reply option
* src/cp.c (reply_args, reply_vals): Remove globals.
[REPLY_OPTION]: Remove enum.
(long_opts) ["reply"]: Remove initializer.
(main): Remove case stmt.
* src/mv.c: Likewise.
Don't include "argmatch.h".  No longer used.
* NEWS (Changes in behavior): Mention this.
* tests/Makefile.am (TESTS): Remove mv/reply-no.
* tests/mv/reply-no: Remove file.
* tests/mv/i-link-no: Update, now that --reply= is gone.
2008-12-01 17:03:37 +01:00
Pádraig Brady
aa2617b908 doc: Make descriptions of ASCII NUL and --zero-terminated option consistent
doc/coretuils.texi: Refactor shuf, sort and uniq --zero-terminated
option to use the same text. Also refer to NUL characters as
@acronym{ASCII} @sc{nul} consistently.
2008-12-01 14:05:56 +00:00
Jim Meyering
016958f2f0 doc: enforce @var{lower} policy
* doc/coreutils.texi: Fix remaining violations.
* doc/Makefile.am (sc-lower-case-var): New rule.
Add some command-suppressing "@" directives so that a successful
"make check" run is less noisy.
2008-12-01 09:25:06 +01:00
Pádraig Brady
1ce9d86c30 doc: Tweak info docs to standarise on lower-case @var{file}
* doc/coreutils.texi: s/@var{FILE}/@var{file}/
2008-12-01 02:29:57 +00:00
Pádraig Brady
00b5a2db33 doc: Improve description of --files0-from option
* doc/coreutils.texi: Describe the most common
usage of --files0-from=- to read names from stdin.
* src/du.c: Likewise.
* src/sort.c: Likewise.
* src/wc.c: Likewise.
2008-12-01 02:09:19 +00:00
Pádraig Brady
e34894bf3f tests: dd/reblock: Reduce chance of timing related failures
* tests/dd/reblock: Change the IPC mechanism to the dd process
under test, from pipes to fifos. Also change the delay
between data writes to 0.2s for both tests.
This should increase the chance that the dd process
will read the data chunks separately.
2008-12-01 01:20:18 +00:00
Jim Meyering
b14e5c40b9 m4: avoid a warning from gcc's -Wstrict-prototypes
* m4/jm-macros.m4 (ARGMATCH_DIE_DECL): Use proper prototype for usage.
2008-11-30 19:15:51 +01:00
Jim Meyering
90f74735aa tests: df: skip total-verify if df fails
* tests/df/total-verify: Skip the test if df fails.
2008-11-30 19:15:51 +01:00
Jim Meyering
d6a62182f0 build: don't reject definition of STREQ
* maint.mk (sc_prohibit_strcmp): Tighten rule: exclude
macro definitions like the one in system.h.
* .x-sc_prohibit_strcmp: Don't exempt src/system.h.
2008-11-30 19:15:51 +01:00
Jim Meyering
847ab6a518 tests: start long-running cp/link-heap earlier
* tests/Makefile.am (TESTS): Move cp/link-heap nearer the start of the
list, so that its termination doesn't delay a parallel "make check".
2008-11-30 19:15:51 +01:00
Jim Meyering
b5b3690d06 tests: avoid failure of cp/link-heap on some systems
* tests/cp/link-heap: Raise virtual memory limit from 10,000
to 14,000, to avoid failure on Debian/unstable (libc6 2.7-16).
2008-11-30 19:15:51 +01:00
Jim Meyering
57e2022b8d remove explicit declaration of putenv, ...
* src/date.c: ... now that gnulib guarantees that it's in <stdlib.h>.
* src/env.c: Likewise.
2008-11-30 19:14:29 +01:00
Jim Meyering
be6b4218e4 tests: dd/reblock: avoid occasional failure
* tests/dd/reblock: Sleep longer to avoid a race condition.
Reported by Bob Proulx.
2008-11-30 19:01:45 +01:00
James Youngman
48a05a9ce9 pwd: add pwd -P, -L to TODO
* TODO: Add to-do entry for -P and -L options of pwd.
2008-11-27 12:22:59 +01:00
Ondřej Vašík
fc3b301d4f doc: fix typo in units factorization, removed TODO items
* doc/coreutils: switch typo (switched gibibytes/gigabytes)
* TODO:          removed missing chcon and runcon documentation from list
2008-11-26 16:18:50 +01:00
Jim Meyering
c7e971bee0 doc: factor out list of suffix-to-number (e.g., KB->1000B) mappings
* coreutils.texi (multiplierSuffixes, multiplierSuffixesNoBlocks):
New macros.
(od invocation, head invocation, tail invocation, split invocation):
(truncate invocation): Use them.
2008-11-26 15:37:47 +01:00
Jim Meyering
b0312caf6f doc: tail: one more s/bytes/n/ change
* doc/coreutils.texi (tail invocation): Make one more
@var{bytes} -> @var{n} change.
2008-11-26 15:36:55 +01:00
Pádraig Brady
1c318d52de doc: tail: fix description of --bytes=N (-c)
* doc/coreutils.texi (tail invocation): Use @var{n} consistently,
not a mix of that and @var{bytes}.  Reported by anonymous
in <http://savannah.gnu.org/bugs/?24934>.
2008-11-26 14:27:09 +00:00
Karl Berry
186b655094 doc: move @shortcontents and @contents from end to start
* doc/coreutils.texi: Move @shortcontents and @contents from the
end to the beginning, just after "@end titlepage".
2008-11-23 12:45:40 +01:00
Jim Meyering
8333cc3c0f doc (stat): clarify: there are two sets of format directives
* doc/coreutils.texi (stat invocation): Clarify description of
--file-system format directives.
2008-11-23 12:36:13 +01:00
Karl Berry
c27c4a0957 doc (stat): correct formatting in coreutils.texi
* doc/coreutils.texi (stat invocation): Move the list of regular,
non-file-system, format directives from the description of --terse,
out of the enclosing table.
2008-11-23 12:36:08 +01:00
Jim Meyering
a5e53ecc2c tests: dd: add a test for the required behavior
* tests/dd/reblock: New file.  Test for the required functionality.
Based on an example and discussion from this thread:
http://lists.gnu.org/archive/html/bug-coreutils/2008-11/msg00153.html
* tests/Makefile.am (TESTS): Add dd/reblock.
2008-11-22 10:31:08 +01:00
Pádraig Brady
d5ab05998c Revert part of "dd: avoid unnecessary memory copies"
This reverts part of commit fbd87029cf.
Paul Eggert noticed the problem in
http://lists.gnu.org/archive/html/bug-coreutils/2008-11/msg00153.html
* doc/coreutils.texi (dd invocation): Clarify.
2008-11-22 10:20:31 +01:00
Pádraig Brady
a2be861b04 getlimits: A new utility for use in coreutils' tests
* src/getlimits.c: A utility to print platform dependent
limits in a format suitable for use in shell scripts.
* src/Makefile.am: Add getlimits to list of utilities
to build but not install. Also add it to the list linked
with libiconv
* po/POTFILES.in: Add getlimits to translation list.
2008-11-21 15:46:26 +00:00
Pádraig Brady
fbd87029cf dd: avoid unnecessary memory copies
* src/dd.c (scanargs): When not otherwise required (e.g. for
conversion), use two-buffer mode only when the input and output
buffer sizes differ.  Before, some of the most basic invocations of
dd, e.g., dd < in > out, would unnecessarily use separate buffers
and perform memory copies between them.
2008-11-21 11:50:59 +00:00
Jim Meyering
3ece0355d5 cp: use far less memory in some cases
cp --link was "remembering" many name,dev,inode triples unnecessarily.
cp was doing the same, even without --link, for every directory in the
source hierarchy, while it can do its job with entries merely for the
command-line arguments.  Prompted by a report from Patrick Shoenfeld.
Details <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/15081>.
* src/copy.c (copy_internal): Refrain from remembering
name,dev,inode for most files, when invoked via cp --link.
Record an infloop-avoidance triple for each directory specified
on the command line, not for each directory in the source tree.
Don't record a dir-triple when x->hard_link is set.
* NEWS (Buf fixes): Mention it.
* tests/cp/link-heap: New file.  Test for cp's lowered memory usage.
* tests/Makefile.am (TESTS): Add link-heap.
2008-11-20 10:21:52 +01:00
Jim Meyering
1760ade090 tests: add a test of cp --preserve=links
* tests/cp/link-preserve: Add a case and comments.
2008-11-20 10:21:52 +01:00
Jim Meyering
ed017d44b2 cp: remove unused code
* src/cp-hash.c (remember_created): Remove unused function.
Remove thus-obviated headers: <stdio.h>, "quote.h", "error.h".
* src/cp-hash.h (remember_created): Remove declaration.
2008-11-20 10:21:52 +01:00
Jim Meyering
8b09875b59 doc: HACKING: reference http://www.gnu.org/licenses/why-assign.html
Suggestion from Patrick Schoenfeld.
2008-11-17 11:16:19 +01:00
Jim Meyering
4e38e6a19c tests: remove debug code that would try to write into /t/k-env
* tests/ls/no-cap: Remove debugging "tee".
2008-11-16 10:45:41 +01:00
Jim Meyering
b3e779c090 tests: change misc/printf-surprise so that it doesn't segfault anymore
* tests/misc/printf-surprise: Disable MALLOC_PERTURB_, so that "make
check" no longer provokes a segfault from printf(1).  Before, that
would be detected as a known problem and cause the test to be skipped.
Adjust the test so that a segfault once again results in test failure.
2008-11-16 09:53:48 +01:00
Jim Meyering
17409787bb tests: remove df/total
* tests/df/total: Remove file.
* tests/Makefile.am (TESTS): Remove df/total.
It is subsumed by df/total-verify.
2008-11-12 13:29:38 +01:00
Ondřej Vašík
ac819e1044 * tests/df/total-verify [VERBOSE]: Run df --version, not ls --version. 2008-11-12 13:27:23 +01:00
Jim Meyering
36eb45201f avoid spurious test failure when df always fails
* tests/df/total-verify: Skip upon _df_ failure, not tee failure.
Reported by Ondřej Vašík.  Details in
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/15028>.
2008-11-12 12:53:54 +01:00
Eric Blake
b43255473f jm-macros.m4: avoid syntax issue with newer autoconf
* jm-macros.m4 (coreutils_MACROS): Make LIB_CAP assignment persistent.

Signed-off-by: Eric Blake <ebb9@byu.net>
2008-11-11 10:44:59 -07:00
Jim Meyering
90a83264b9 Update references to GFDL: 1.2 -> 1.3
* doc/coreutils.texi: Likewise.
* doc/perm.texi: Likewise.
* old/fileutils/NEWS: Likewise.
* old/sh-utils/NEWS: Likewise.
* old/textutils/NEWS: Likewise.
2008-11-11 09:51:30 +01:00
Jim Meyering
43448b0493 make --help print "Report PROGRAM translation bugs to <...>."
for all but the C/POSIX locale.
* src/system.h: Include "hard-locale.h".
(emit_bug_reporting_address): Tell where to report translation bugs.

don't include "hard-locale.h", now that system.h does
* src/comm.c: Likewise.
* src/join.c: Likewise.
* src/ls.c: Likewise.
* src/pinky.c: Likewise.
* src/pr.c: Likewise.
* src/sort.c: Likewise.
* src/uniq.c: Likewise.
* src/who.c: Likewise.
2008-11-10 08:19:52 +01:00
Jim Meyering
854284f788 avoid warnings about discarding "qualifiers from pointer target type"
Use the new "bad_cast" function or an actual cast-to-"(char *)"
to avoid warnings.
* src/system.h (bad_cast): Define.
* src/chown.c (main):
* src/chroot.c (main):
* src/date.c (main):
* src/du.c (main):
* src/expand.c (stdin_argv):
* src/ls.c (decode_switches):
* src/md5sum.c (main):
* src/paste.c (main):
* src/pr.c (col_sep_string, column_separator, line_separator, main):
* src/sort.c (main):
* src/split.c (main):
* src/tail.c (main):
* src/unexpand.c (stdin_argv):
* src/yes.c (main):
2008-11-10 08:11:59 +01:00
Jim Meyering
0e2ac2de24 avoid a compiler warning
(strip_program): Declare to be const.
2008-11-10 08:11:59 +01:00
Jim Meyering
03911ef780 use xfreopen in place of unchecked freopen
* bootstrap.conf (modules): Add xfreopen.
* src/cat.c (main): Include "xfreopen.h".  Use xfreopen.
* src/cksum.c (cksum): Likewise.
* src/head.c (head_file, main): Likewise.
* src/md5sum.c (digest_file): Likewise.
* src/od.c (open_next_file): Likewise.
* src/split.c (type_undef): Likewise.
* src/sum.c (bsd_sum_file, sysv_sum_file): Likewise.
* src/tac.c (tac_file, main): Likewise.
* src/tail.c (tail_file, main): Likewise.
* src/tee.c (tee_files): Likewise.
* src/tr.c (main): Likewise.
* src/wc.c (wc_file): Likewise.
* po/POTFILES.in: Add lib/xfreopen.c
2008-11-10 08:11:59 +01:00
Jim Meyering
32d4d0dd5e xfreopen: new module
* gl/lib/xfreopen.c: New file.
* gl/lib/xfreopen.h: New file.
* gl/modules/xfreopen: New file.
2008-11-10 08:11:59 +01:00
Jim Meyering
cfa2120e83 Update URL: s!www.iro.umontreal.ca!translationproject.org/team/...!
* Makefile.am (THANKS-to-translators): Update URL template.
2008-11-09 15:35:51 +01:00
James Youngman
1c5e5d6277 install: indicate clearly it's not for installing packages
* src/install.c (usage): Indicate the program copies files,
as opposed to installing packages.
2008-11-09 13:56:00 +01:00
Jim Meyering
41ec3548b0 emit more precise bug-reporting instructions
Hoping that this will decrease the volume of bug reports
mistakenly directed to the coreutils mailing list.
* src/system.h (emit_bug_reporting_address): Specify the program
name in the "Report bugs to <...>." line in each program's --help
output and man page.  Now, it will say "Report PROGRAM_NAME bugs
to <...>."  Suggestion from Ondřej Vašík.
2008-11-08 19:59:52 +01:00
Jim Meyering
5b27ec57b0 include gnulib's strdup module explicitly
* bootstrap.conf (gnulib_modules): Include strdup explicitly, to
keep the latest version of gnulib-tool from omitting this now-marked-
as-obsolete module.
2008-11-05 19:18:59 +01:00
Kamil Dudka
1e48b1fee5 ls: --color now highlights hard linked files, too
* src/ls.c (print_color_indicator): Colorize hard linked files.
* src/dircolors.c: Add color for hard link.
* src/dircolors.hin: Add color for hard link.
* tests/ls/hardlink: Test for ls - colorize hard linked files.
* tests/Makefile.am (TESTS): Add ls/hardlink.
* NEWS: Mention the change.
2008-10-28 21:08:30 +01:00
Jim Meyering
5dc070cc86 tests: ls/stat-failed: don't discard stderr.
* tests/ls/stat-failed: Let stderr be recorded, to ease debugging.
2008-10-28 09:24:01 +01:00
Jim Meyering
b4ec994b26 tests: seq: check for today's extended long double fix
* tests/misc/seq-long-double: New file.  Test for today's bug fix.
* tests/check.mk (TESTS_ENVIRONMENT): Export CC definition.
* tests/Makefile.am (TESTS): Add misc/seq-long-double.
* NEWS (Bug fixes): Mention it.
2008-10-26 10:45:34 +01:00
Paul Eggert
2bf151cd93 seq: improve quality of format-checking code
* src/seq.c (validate_format): Remove. Migrate its checks into...
(long_double_format): Report an error and exit if an error is found,
instead of returning NULL.  All callers changed.
Use a more-consistent format for diagnostics.
* tests/misc/seq: Adjust to the more-consistent format for diagnostics.
2008-10-26 09:51:33 +01:00
Jim Meyering
153477479a factor: avoid compilation failure without libgmp
* src/factor.c (debug) [!HAVE_GMP]: Define.
Reported by Bob Proulx.
2008-10-25 22:57:42 +02:00
Paul Eggert
fec0e89c20 factor: remove --bignum and --no-bignum options
Here's a patch to remove the --bignum and --no-bignum options from
'factor'.  The case for removing --bignum isn't as strong as that for
'expr', but still, it seems to me that these options are not needed and
complicate the documentation unnecessarily.

* doc/coreutils.texi (factor invocation): Remove --bignum, --no-bignum.
* src/factor.c (algorithm, ALGORITHM_CHOICE, USE_BIGNUM, NO_USE_BIGNUM):
Remove; all uses removed.
(extract_factors_multi): Remove, replacing with....
(print_factors_multi): New function, with signature similar to that
of new signature of print_factors_single.
(print_factors_single): Migrate checking code to caller.
(print_factors): Use GMP if it's available; don't bother asking user.
Improve accuracy of check for "large" numbers.
(long_options, main): Remove support for --bignum.
2008-10-25 21:05:41 +02:00
Jim Meyering
407e8f0fdd tests: df/total: don't fail for an inaccessible mount point
* tests/df/total: Ignore nonzero exit status from df.
2008-10-25 16:30:54 +02:00
Paul Eggert
461231f022 seq: revert Solaris 8 work-around that caused x86 regression
* src/seq.c: Don't include <math.h>, <float.h>.
(abs_rel_diff): Remove.
(print_numbers): Test for equality, not for an epsilonish value.
This reverts 4827dd27b0, aka
v6.10-185-g4827dd2, which broke 'seq' on the x86; for example, it
causes "seq 9223372036854775807 9223372036854775808" to incorrectly
output 3 numbers instead of 2.  It's better to punish obsolescent
hosts that have incorrectly-working floating-point than to punish
correctly-working hosts.
* tests/misc/seq: Use 0.9000000000000, rather than
0.90000000000000000000, to avoid tickling a bug in Solaris 8 strtold,
which converts "0.9" and "0.9000000000000" correctly, but incorrectly
converts "0.90000000000000000000" to a smaller value.
2008-10-25 10:59:07 +02:00
Eric Blake
b705e9a9e7 group-list: avoid compiler warning
* src/group-list.c (print_group_list) [!HAVE_GETGROUPS]: Always
return value.
2008-10-24 11:44:48 -06:00
Jim Meyering
b3677e5e38 ls: use '.' (not +) as SELinux-only alt. access flag in ls -l output
* src/ls.c (gobble_file) [long_format]: Map SELinux-only to '.',
any other nonempty combination of MAC and ACL to '+', and all else
to the usual ' '.  Suggested by Michael Stone.
* tests/misc/selinux: Adapt: expect '.', not '+'.
* doc/coreutils.texi (What information is listed): Document this.
* NEWS (Changes in behavior): Mention it.
2008-10-23 14:18:25 +02:00
Pádraig Brady
cc0f637b6d Remove lzma as a specific build requirement
* bootstrap.conf: lzma was added as a build requirement
in the recently added build tools requirements check.
Remove that as it's quite new and also only required
for the make dist stage.
2008-10-22 22:15:10 +01:00
Paul Eggert
7920f2c14a * src/ls.c (usage): Describe exit statuses more concisely. 2008-10-22 18:40:56 +02:00
Pádraig Brady
99f4994982 Add better checks and docs for build tools
Prompted by a report from Ed Avis:
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14710>

* README-hacking: Organise LZMA and Valgrind as
as optional requirements rather than in their own sections.
Mention bootstrap will now check tool versions.
* README-prereq: Make a start on specific instructions
for optaining build tools. Currently we just have notes
for Fedora linux.
* bootstrap.conf: Add the list of tools and versions required.
* bootstrap: Add the logic to check for the required tools,
and list all required tools and versions if any are missing.
2008-10-22 16:31:57 +01:00
Jim Meyering
5afac2aee1 clean up gl/modules/selinux-at
* gl/modules/selinux-at:
Ensure that LIB_SELINUX is cleared, in case it's set in the environment.
m4-quote the first two args to AC_SEARCH_LIBS.
Don't violate autoconf's ac_ namespace: s/ac_save/gl_save/
Drop the useless double quotes around a simple assignment RHS.
2008-10-22 12:44:17 +02:00
Jim Meyering
aa67daf63b move selinux-h module from gl/ to gnulib
* gl/lib/se-context.in.h: Remove file.
* gl/lib/se-selinux.in.h: Likewise.
* gl/m4/selinux-context-h.m4: Likewise.
* gl/m4/selinux-selinux-h.m4: Likewise.
* gl/modules/selinux-h: Likewise.
2008-10-21 18:05:55 +02:00
Jim Meyering
f7a009c17c prepare to move selinux-h module to gnulib
* gl/modules/selinux-h (Makefile.am)
[selinux/selinux.h, selinux/context.h]:
Remove temporary file and target, in case they're read-only.
Use $(MKDIR_P), not mkdir -p.
(License): Relax to LGPLv2+.
Remove vestigial comments.
2008-10-21 15:58:11 +02:00
Jim Meyering
028e12ce3b tests: test today's ls-vs-capability fix
Test for this fix: f3f1ccfd87.
* tests/Makefile.am (TESTS): Add ls/no-cap.
* tests/ls/no-cap: New file.
2008-10-21 13:09:58 +02:00
Kamil Dudka
f3f1ccfd87 ls: make it possible to disable file capabilities checking
* ls.c (print_color_indicator): Do not check for file capability
if that attribute is not being colored.
Since 84f6abfe00, ls --color would check
each file for "capabilities".  In <http://bugzilla.redhat.com/467508>,
James Antill reported that ls --color seemed slower with capabilities
detection.
2008-10-21 11:13:01 +02:00
Jim Meyering
08c38ab7cb reflect gnulib's removal of lstat.h
* src/copy.h: Don't include "lstat.h".
* src/ls.c: Likewise.
* src/remove.c: Likewise.
* src/rm.c: Likewise.
2008-10-21 08:10:29 +02:00
Pádraig Brady
d60e33e241 expr: Fixup authors
* src/expr.c: Standardise the format of AUTHORS to
that used in other utils with multiple authors.
Also add Paul Eggert since he basically rewrote it
with his bignum fixes.
* AUTHORS (expr): Add Paul Eggert.
2008-10-20 15:40:50 +01:00
Jim Meyering
31a884dab7 accommodate gnulib header removals
* src/copy.c: Don't include "euidaccess.h" or "lchmod.h".
* src/cp.c: Don't include "lchmod.h".
* src/ls.c: Don't include "dirfd.h".
* src/mkdir.c: Don't include "lchmod.h".
* src/pwd.c: Don't include "dirfd.h".
* src/remove.c: Don't include "dirfd.h" or "euidaccess.h".
* src/test.c: Don't include "euidaccess.h".
* gl/modules/getloadavg.diff: Adjust diff for changed context.
* src/uptime.c (uptime): Remove declaration.
2008-10-19 14:15:31 +02:00
Jim Meyering
74443830ea * maint.mk (coreutils-path-check): New definition, now run
only if src/true.c exists.  Factored out of...
(my-distcheck):  ...here.
2008-10-18 12:55:04 +02:00
Jim Meyering
2ae61facc7 maint: avoid warning in ls.c
* src/ls.c (has_capability) [!HAVE_CAP]: Add unused attribute.
2008-10-17 08:55:12 +02:00
Jim Meyering
bb7fa1e932 maint: avoid warnings due to attribute warn_unused_result
Now that a (void) cast no longer suffices to ignore warnings from gcc
about uses of functions marked with the warn_unused_result attribute,
we need an alternative.  For the record, here's one of the ignorable
warnings: "copy.c:233: warning: ignoring return value of 'fchown',
declared with attribute warn_unused_result"
* bootstrap.conf (gnulib_modules): Import ignore-value.
* src/copy.c: Include "ignore-value.h".
(set_owner): Use ignore_value in place of "(void)" casts,
to ignore lchown and fchown failures.
* src/cp.c (re_protect): Likewise, to ignore lchown failure.
* src/remove.c (preprocess_dir): Remove unnecessary "(void)" cast.
2008-10-17 07:06:54 +02:00
Jim Meyering
16c8062085 mktemp: diagnose freopen failure
* src/mktemp [--quiet]: Don't ignore freopen failure.
2008-10-16 23:00:22 +02:00
Paul Eggert
17278118ee * src/mktemp.c (main): Add 'const' twice to avoid GCC warning. 2008-10-16 22:27:08 +02:00
Jim Meyering
7f6fb43e7d build: when po-check fails, say why and suggest a fix
* maint.mk (po-check): Before, when this check failed, it just
spat out a diff mentioning two temporary files.  Now, it tells
you what's wrong and suggests a fix with a patch using the name
of the affected file (rather than temporary file names) in the
diff output.
2008-10-16 14:25:53 +02:00
Eric Blake
ddc409b59e csplit: prefer sigaction over signal
* bootstrap.conf (gnulib_modules): Import sigaction.
* src/csplit.c (sigprocmask, siginterrupt) [SA_NOCLDSTOP]: Delete
workarounds.
(interrupt_handler, main): Drop use of signal.  Rely on sigaction
to block fatal signal during cleanup, and to restore it to default
in case of nested signals.
2008-10-16 06:20:50 -06:00
Pádraig Brady
7eb3aab88b tests: add option processing tests for 'expr'
* tests/misc/expr: Add tests for various combinations
of options where the first part of the expression
could be confused with an option.
2008-10-15 16:32:05 +02:00
Paul Eggert
4fb3704c25 expr: remove --bignum and --no-bignum options
* doc/coreutils.texi (expr invocation): Remove the --bignum and
--no-bignum options.  They weren't really needed, and they broke
longstanding (albeit nonportable) scripts.
* src/expr.c: Don't include <assert.h>.  Include "inttostr.h",
"long-options.h", "verify.h".  Check at compile-time that
size_t fits in unsigned long int, as the code assumes this in
several places.
(HAVE_GMP): Define to 0 if not defined, for convenience.
(mpz_t, mpz_clear, mpz_init_set_ui, mpz_init_set_str, mpz_add):
(mpz_sub, mpz_mul, mpz_tdiv_q, mpz_tdiv_r, mpz_get_str, mpz_sgn):
(mpz_fits_ulong_p, mpz_get_ui, mpz_out_str):
Supply substitutes when !HAVE_GMP, which work well enough for
expr's purposes.
(mp_integer): Remove.  All integers are gmp, if gmp is available.
(struct valinfo): Remove 'z' member; no longer needed.  The 'i'
member is always of type mpz_t.
(enum arithmetic_mode, MP_NEVER, MP_ALWAYS, MP_AUTO, mode):
Remove; no longer needed.
(usage): Remove documentation of --bignum and --no-bignum.
(integer_overflow): Abort if error misbehaves, to pacify GCC.
Restore old message on arithmetic overflow, to be conservative.
(die): Omit exit_status parameter; not needed (is always EXPR_FAILURE).
(string_too_long, USE_BIGNUM, NO_USE_BIGNUM, long_options):
Remove; no longer needed.
(main): Don't use getopt_long; this breaks old nonportable scripts.
(int_value): Arg is unsigned, in case we have strings whose length
exceeds LONG_MAX (!).
(int_value, freev, printv, null, tostring, toarith):
(eval6, eval4, eval3):
Always use mpz_ functions, to simplify the code.
(substr_value): Remove; no longer needed.
(getsize): Simplify the API: one arg rather than 3.  Don't assume
unsigned long int fits in size_t.
(promote, domult, dodivide, doadd): Remove; no longer needed.
* tests/misc/expr: Don't use --bignum to test for bignum support.
Instead, use big numbers to test this.
2008-10-15 16:30:28 +02:00
Jim Meyering
514b7fbc00 expr: don't interpret argv[0] as an operand
* src/expr.c (main): Given a first argument like -22 (negative, with
two or more digits), expr would decrement optind to 0 and then attempt
to evaluate argv[0].
2008-10-15 15:34:58 +02:00
Jim Meyering
555c219d9e doc: cp, mv: remove mention of deprecated --reply= option
* doc/coreutils.texi (cp invocation, mv invocation): Don't mention it.
2008-10-15 15:08:58 +02:00
Jim Meyering
59964c164b doc: adjust spacing in ls --help output, for better man formatting
* src/ls.c (usage): Adjust spacing so the "Exit status:" list
renders well in the help2man-generated man page.
2008-10-13 21:08:07 +02:00
Ondřej Vašík
7377f49ea8 doc: ls: clarify exit status description
* src/ls.c (exit_status): Clarify comments.
(usage): Clarify exit status description in --help output.
* doc/coreutils.texi (ls invocation): Clarify exit status documentation
Reported by Greg Metcalfe in <http://bugzilla.redhat.com/446294>.
2008-10-13 09:01:54 +02:00
Jim Meyering
969841cb77 doc: reorder tsort/ptx nodes so body and menu ordering are consistent
* doc/coreutils.texi (tsort invocation, tsort background): Move these
nodes "down", so that they follow the ptx nodes, thus matching the
alphabetized order in the menu.
(tsort background): Make this a subsection.
Suggested by Karl Berry.
2008-10-12 19:53:20 +02:00
Jim Meyering
c3e1fe230b tests: move check-misc targets from src/Makefile.am to maint.mk
* src/Makefile.am (check): Remove check-misc.
(check-misc): Remove target.
* maint.mk (sc_prohibit_stat_st_blocks): New target.
(sc_prohibit_S_IS_definition): New target.
* Makefile.am (EXTRA_DIST): Add .x-sc_prohibit_stat_st_blocks.
* .x-sc_prohibit_stat_st_blocks: New file.
Andreas Schwab reported that "make check" could fail to detect
violation of the no-S_IS*-definition policy.
2008-10-12 11:21:19 +02:00
Jim Meyering
1833a876ae tests: df: avoid test failure when using mawk
* tests/df/total-awk: Rewrite to use $PERL, not $AWK.
mawk can't even count above 2^31.  Reported by Ed Avis.
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14792/focus=14802
* tests/df/total-verify: Rename from total-awk.
* tests/Makefile.am (TESTS): Reflect renaming.
2008-10-12 11:11:38 +02:00
Jim Meyering
0f5695bd59 bootstrap: merge from gnulib 2008-10-10 09:13:58 +02:00
Ondřej Vašík
42df6d7de2 doc: document runcon and chcon in SELinux context section
* doc/coreutils.texi: Document runcon and chcon.
Add minimal SELinux context section.
2008-10-07 23:43:27 +02:00
Ondřej Vašík
9c0c57a1b4 chcon: remove traces of unimplemented --change (-c) option
This option was never supported in upstream coreutils.
* chcon.c (usage): Remove --change (-c) from help message.
(main): Remove 'c' from getopt string.
Remove related and now-unused enums.
2008-10-06 22:53:04 +02:00
Andreas Dilger
a36f4cb451 stat: add lustre filesystem type
* src/stat.c (human_fstype) [S_MAGIC_LUSTRE]: Add case.
Make "stat -f" recognize the "Lustre" filesystem type.
<http://en.wikipedia.org/wiki/Lustre_(file_system)>
* NEWS: Mention this feature.
2008-10-06 22:35:57 +02:00
Jim Meyering
ed0a1c9f94 remove.c: avoid compile failure on OS/2
* src/remove.c (dirent_inode_sort_may_be_useful): Guard also with
"#if defined __linux__".  Reported by Elbert Pol.
2008-10-06 07:31:50 +02:00
Jim Meyering
f9da2d0e87 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2008-10-05 21:27:05 +02:00
182 changed files with 4581 additions and 2547 deletions

View File

@@ -1 +1 @@
6.12
7.0

View File

@@ -1,4 +0,0 @@
ChangeLog(-[0-9]+)?$
^old/
^src/c99-to-c98\.diff$
^gl/.*

1
.x-sc_po_check Normal file
View File

@@ -0,0 +1 @@
^gl/

View File

@@ -1,6 +1 @@
ChangeLog
^TODO$
^lib/euidaccess-stat\.c$
^maint\.mk$
^doc/coreutils.texi$
^tests/misc/stty-invalid$

View File

@@ -0,0 +1,4 @@
src/system.h
tests/du/2g
old/fileutils/ChangeLog-1997
ChangeLog-2005

View File

@@ -1,2 +1 @@
^src/system\.h
ChangeLog

View File

@@ -1,30 +1,9 @@
^lib/at-func\.c$
^lib/bcopy\.c$
^lib/buffer-lcm\.c$
^lib/c-strtold\.c$
^lib/fnmatch_loop\.c$
^lib/full-read\.c$
^lib/imaxtostr\.c$
^lib/mempcpy\.c$
^lib/memset\.c$
^lib/offtostr\.c$
^lib/regcomp\.c$
^lib/regex_internal\.c$
^lib/regexec\.c$
^lib/safe-write\.c$
^lib/strtoll\.c$
^lib/strtoul\.c$
^lib/strtoull\.c$
^lib/strtoumax\.c$
^lib/umaxtostr\.c$
^lib/xstrtold\.c$
^lib/xstrtoul\.c$
^src/false\.c$
^src/lbracket\.c$
^src/ls-dir\.c$
^src/ls-ls\.c$
^src/ls-vdir\.c$
^src/rand-isaac\.c$
^src/tac-pipe\.c$
^src/uname-arch\.c$
^src/uname-uname\.c$

View File

@@ -0,0 +1,9 @@
^lib/buffer-lcm\.c$
^src/false\.c$
^src/lbracket\.c$
^src/ls-dir\.c$
^src/ls-ls\.c$
^src/ls-vdir\.c$
^src/tac-pipe\.c$
^src/uname-arch\.c$
^src/uname-uname\.c$

View File

@@ -25,7 +25,7 @@ du: Torbjörn Granlund, David MacKenzie, Paul Eggert, Jim Meyering
echo: Brian Fox, Chet Ramey
env: Richard Mlynarik, David MacKenzie
expand: David MacKenzie
expr: Mike Parker, James Youngman
expr: Mike Parker, James Youngman, Paul Eggert
factor: Paul Rubin
false: Jim Meyering
fmt: Ross Paterson

View File

@@ -1,3 +1,8 @@
2008-12-16 Jim Meyering <meyering@redhat.com>
NB: ChangeLog files are no longer manually maintained.
See HACKING for details.
2008-02-07 Jim Meyering <meyering@redhat.com>
We *do* need two different version files.

29
HACKING
View File

@@ -32,9 +32,14 @@ inside your new coreutils/ directory:
If you have made *no* changes:
git pull
If you *have* made changes and committed them to "master", do this:
git fetch
git rebase origin
If you *have* made changes and mistakenly committed them to "master",
do the following to put your changes on a private branch, "br", and
to restore master to its unmodified (relative-to-upstream) state:
git checkout -b br
git checkout master
git reset --hard origin
Then "git pull" should work.
*Before* you commit changes
@@ -288,7 +293,9 @@ Nearly every significant change must be accompanied by a test suite
addition that exercises it. If you fix a bug, add at least one test that
fails without the patch, but that succeeds once your patch is applied.
If you add a feature, add tests to exercise as much of the new code
as possible.
as possible. Note to run tests/misc/newtest in isolation you can do:
(cd tests && make check TESTS=misc/newtest VERBOSE=yes)
There are hundreds of tests in the tests/ directories. You can use
tests/sample-test as a template, or one of the various Perl-based ones
@@ -323,6 +330,10 @@ you'd use doc/Copyright/request-assign.future:
You may make assignments for up to four projects at a time.
In case you're wondering why we bother with all of this, read this:
http://www.gnu.org/licenses/why-assign.html
Run "make syntax-check", or even "make distcheck"
================================================
@@ -402,3 +413,13 @@ to generate HTML coverage reports. Follow these steps:
Then just open the index.html file (in the generated lcov-html directory)
in your favorite web browser.
========================================================================
Copyright (C) 2009 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the ``GNU Free
Documentation License'' file as part of this distribution.

View File

@@ -20,12 +20,13 @@ EXTRA_DIST = cfg.mk maint.mk \
.prev-version THANKS-to-translators THANKStt.in \
.version \
.vg-suppressions \
.x-po-check \
.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 \
@@ -101,8 +102,8 @@ MAINTAINERCLEANFILES = THANKS-to-translators
THANKS-to-translators: po/LINGUAS THANKStt.in
( \
cat $(srcdir)/THANKStt.in; \
for lang in `cat $(srcdir)/po/LINGUAS`; do \
echo http://www.iro.umontreal.ca/contrib/po/HTML/team-$$lang.html; \
for lang in `cat $(srcdir)/po/LINGUAS`; do \
echo http://translationproject.org/team/$$lang.html; \
done; \
) > $@-tmp && mv $@-tmp $@

72
NEWS
View File

@@ -1,5 +1,74 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 7.1 (2009-02-21) [stable]
** New features
Add extended attribute support available on certain filesystems like ext2
and XFS.
cp: Tries to copy xattrs when --preserve=xattr or --preserve=all specified
mv: Always tries to copy xattrs
install: Never copies xattrs
cp and mv accept a new option, --no-clobber (-n): silently refrain
from overwriting any existing destination file
dd accepts iflag=cio and oflag=cio to open the file in CIO (concurrent I/O)
mode where this feature is available.
install accepts a new option, --compare (-C): compare each pair of source
and destination files, and if the destination has identical content and
any specified owner, group, permissions, and possibly SELinux context, then
do not modify the destination at all.
ls --color now highlights hard linked files, too
stat -f recognizes the Lustre file system type
** Bug fixes
chgrp, chmod, chown --silent (--quiet, -f) no longer print some diagnostics
[bug introduced in coreutils-5.1]
cp uses much less memory in some situations
cp -a now correctly tries to preserve SELinux context (announced in 6.9.90),
doesn't inform about failure, unlike with --preserve=all
du --files0-from=FILE no longer reads all of FILE into RAM before
processing the first file name
seq 9223372036854775807 9223372036854775808 now prints only two numbers
on systems with extended long double support and good library support.
Even with this patch, on some systems, it still produces invalid output,
from 3 to at least 1026 lines long. [bug introduced in coreutils-6.11]
seq -w now accounts for a decimal point added to the last number
to correctly print all numbers to the same width.
wc --files0-from=FILE no longer reads all of FILE into RAM, before
processing the first file name, unless the list of names is known
to be small enough.
** Changes in behavior
cp and mv: the --reply={yes,no,query} option has been removed.
Using it has elicited a warning for the last three years.
dd: user specified offsets that are too big are handled better.
Previously, erroneous parameters to skip and seek could result
in redundant reading of the file with no warnings or errors.
du: -H (initially equivalent to --si) is now equivalent to
--dereference-args, and thus works as POSIX requires
shred: now does 3 overwrite passes by default rather than 25.
ls -l now marks SELinux-only files with the less obtrusive '.',
rather than '+'. A file with any other combination of MAC and ACL
is still marked with a '+'.
* Noteworthy changes in release 7.0 (2008-10-05) [beta]
** New programs
@@ -2304,8 +2373,7 @@ packages, see ./old/*/NEWS.
========================================================================
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
Foundation, Inc.
Copyright (C) 2001-2009 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or

23
README
View File

@@ -92,11 +92,15 @@ compiler, due to the use of declarations after non-declaration statements
in several files in src/. There is code in configure to find and, if
possible, enable an appropriate compiler. However, if configure doesn't
find a C99 compiler, it continues nonetheless, and your build will fail.
If that happens, simply apply the included patch using the following
If that happens, simply[*] apply the included patch using the following
command, and then run make again:
cd src && patch < c99-to-c89.diff
[*] however, as of coreutils-7.1, the "c99-to-c89.diff" file is no longer
maintained, so even if the patches still apply, the result will be an
incomplete conversion. It's been 10 years. Get a decent compiler! ;-)
***********************
HPUX 11.x build failure
@@ -161,17 +165,13 @@ Reporting bugs:
IMPORTANT: if you take the time to report a test failure,
please be sure to include the output of running `make check'
in verbose mode for each failing test. For example,
if the test that fails is tests/mv/hard-link-1, then you
would run this command:
if the test that fails is tests/misc/df, then you would
run this command:
env VERBOSE=yes make check -C tests/mv TESTS=hard-link-1 >> log 2>&1
(cd tests && make check TESTS=misc/df VERBOSE=yes) >> log 2>&1
For some tests, you can get even more detail by including
DEBUG=yes in the environment:
env DEBUG=yes VERBOSE=yes make check -C tests/mv TESTS=hard-link-1 >> log 2>&1
and then include the contents of the file `log' in your bug report.
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.
***************************************
@@ -231,8 +231,7 @@ the address on the last line of --help output.
========================================================================
Copyright (C) 1998, 2002, 2003, 2004, 2005, 2006 Free Software
Foundation, Inc.
Copyright (C) 1998, 2002-2009 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or

View File

@@ -2,14 +2,15 @@
These notes intend to help people working on the checked-out sources.
These requirements do not apply when building from a distribution tarball.
See also HACKING for more detailed coreutils contribution guidlines.
* Requirements
We've opted to keep only the highest-level sources in the GIT repository.
This eases our maintenance burden, (fewer merges etc.), but imposes more
requirements on anyone wishing to build from the just-checked-out sources.
For example, you have to use the latest stable versions of the maintainer
tools we depend upon, including:
Specific tools and versions will be checked for and listed by the
bootstrap script shown below, and will include:
- Automake <http://www.gnu.org/software/automake/>
- Autoconf <http://www.gnu.org/software/autoconf/>
@@ -22,41 +23,44 @@ tools we depend upon, including:
- Rsync <http://samba.anu.edu.au/rsync/>
- Tar <http://www.gnu.org/software/tar/>
Valgrind <http://valgrind.org/> is also highly recommended, if
Valgrind supports your architecture.
Only building the initial full source tree will be a bit painful.
Later, a plain `git pull && make' should be sufficient.
* LZMA
- Valgrind
This package's build procedure uses LZMA to create a compressed
Valgrind <http://valgrind.org/> is also highly recommended, if
Valgrind supports your architecture. See also README-valgrind.
- XZ utils (successor to LZMA)
This package's build procedure uses XZ to create a compressed
distribution tarball. Using this feature of Automake requires
version 1.10.1 or newer, as well as the lzma program itself.
Make sure you have the latest stable version of the LZMA Utils
from <http://tukaani.org/lzma/>.
version 1.10a or newer, as well as the xz program itself.
Make sure you have the latest version of the XZ Utils from
<http://tukaani.org/lzma/download>.
* First GIT checkout
You can get a copy of the source repository like this:
$ git clone git://git.sv.gnu.org/coreutils
$ git clone git://git.sv.gnu.org/coreutils
$ cd coreutils
The next step is to get other files needed to build, which are
extracted from other source packages:
The next step is to get and check other files needed to build,
which are extracted from other source packages:
$ ./bootstrap
$ ./bootstrap
And there you are! Just
$ ./configure
$ make
$ make check
$ ./configure
$ make
$ make check
At this point, there should be no difference between your local copy,
and the GIT master copy:
$ git diff
$ git diff
should output no difference.
@@ -64,7 +68,7 @@ Enjoy!
-----
Copyright (C) 2002-2008 Free Software Foundation, Inc.
Copyright (C) 2002-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
@@ -78,3 +82,7 @@ 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/>.
Local Variables:
indent-tabs-mode: nil
End:

31
README-prereq Normal file
View File

@@ -0,0 +1,31 @@
Detailed below are concrete examples for
getting the prerequisites for particular systems.
- 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.
1. Make sure offical distro git package is installed
# yum install git
2. The distro autoconf is too old, but there is a newer one available
so we rebuild that and make it available to the full system:
# 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
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
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
$ make install
Now we can build coreutils as described in README-hacking
as long as $PATH starts with $HOME/coreutils/deps

11
THANKS
View File

@@ -10,6 +10,7 @@ the bug-report mailing list (as seen on last line of e.g., cp --help).
A Costa agcosta@gis.net
Aaron Hawley ashawley@uvm.edu
Achim Blumensath blume@corona.oche.de
Adam Jimerson vendion@charter.net
Adam Klein aklein@debian.org
Adrian Bunk bunk@stusta.de
AIDA Shinra shinra@j10n.org
@@ -21,6 +22,7 @@ Albert Hopkins ahopkins@dynacare.com
Alberto Accomazzi alberto@cfa0.harvard.edu
aldomel aldomel@ix.netcom.com
Alen Muzinic zveki@fly.cc.fer.hr
Alexander V. Lukyanov lav@netis.ru
Allen Hewes allen@decisiv.net
Axel Dörfler axeld@pinc-software.de
Alexandre Duret-Lutz duret_g@epita.fr
@@ -58,6 +60,7 @@ Augey Mikus mikus@dqc.org
Aurelien Jarno aurel32@debian.org
Austin Donnelly Austin.Donnelly@cl.cam.ac.uk
Axel Kittenberger Anshil@gmx.net
Barry Kelly http://barrkel.blogspot.com/
Bauke Jan Douma bjdouma@xs4all.nl
Ben Elliston bje@air.net.au
Ben Harris bjh21@netbsd.org
@@ -79,6 +82,7 @@ Bob Proulx rwp@fc.hp.com
Branden Robinson branden@necrotic.deadbeast.net
Brendan O'Dea bod@compusol.com.au
Brian Kimball bfk@footbag.org
Brian M. Carlson sandals@crustytoothpaste.ath.cx
Brian Silverman bsilverman@conceptxdesign.com
Brian Youmans 3diff@gnu.org
Bruce Korb bkorb@veritas.com
@@ -114,7 +118,7 @@ Cyril Bouthors cyril@bouthors.org
Dale Scheetz dwarf@polaris.net
Dameon G. Rogers dgr03@uark.edu
Dan Hagerty hag@gnu.ai.it.edu
Dan Jacobson http://www.geocities.com/jidani
Dan Jacobson jidanni@jidanni.org
Dan Pascu dan@services.iiruc.ro
Daniel Bergstrom noa@melody.se
Daniel Dunbar ddunbar@stanford.edu
@@ -201,6 +205,7 @@ Guochun Shi gshi@ncsa.uiuc.edu
GOTO Masanori gotom@debian.or.jp
Greg Louis glouis@dynamicro.on.ca
Greg McGary gkm@gnu.org
Greg Metcalfe metcalfegreg@qwest.net
Greg Schafer gschafer@zip.com.au
Greg Troxel gdt@bbn.com
Greg Wooledge gawooledge@sherwin.com
@@ -240,6 +245,7 @@ James Tanis jtt@soscorp.com
James Youngman james+usenet@free-lunch.demon.co.uk
Jamie Lokier jamie@imbolc.ucc.ie
Jamie McClelland jm@mayfirst.org
Jan Engelhardt jengelh@medozas.de
Jan Fedak J.Fedak@sh.cvut.cz
Jan Moringen jan.moringen@uni-bielefeld.de
Jan Nieuwenhuizen janneke@gnu.org
@@ -440,6 +446,7 @@ Peter Moulder reiter@netspace.net.au
Peter O'Gorman bug-coreutils@mlists.thewrittenword.com
Peter Samuelson psamuels@sampo.creighton.edu
Peter Seebach seebs@taniemarie.solon.com
Petr Uzel petr.uzel@suse.cz
Petter Reinholdtsen pere@hungry.com
Phelippe Neveu pneveu@pcigeomatics.com
Phil Richards phil.richards@vf.vodafone.co.uk
@@ -548,7 +555,9 @@ Uwe H. Steinfeld usteinfeld@gmx.net
Vesselin Atanasov vesselin@bgnet.bg
Vin Shelton acs@alumni.princeton.edu
Vineet Chadha chadha@acis.ufl.edu
Vitali Lovich vlovich@gmail.com
Vitaly A. Ostanin vyt@altlinux.org
Vito Caputo vcaputo@pengaru.com
Vlada Macek tuttle@bbs.fsik.cvut.cz
Volker Borchert bt@teknon.de
Volker Paul vpaul@dohle.com

12
TODO
View File

@@ -12,8 +12,6 @@ Modify chmod so that it does not change an inode's st_ctime
Discussed more recently on <http://bugs.debian.org/497514>.
document the following in coreutils.texi:
runcon
chcon
mktemp
[
pinky
@@ -38,6 +36,11 @@ printf:
platforms where the native *printf(3) is deficient.
Suggestion from Eric Blake.
pwd:
Implement the options -P and -L in a POSIX-compatible way.
Note the instructions in the initial paragraph of this file
before starting.
renice: POSIX utility, needs implementing.
suggestion from Karl Berry (among others).
Bob Proulx is working on this.
@@ -104,6 +107,9 @@ sort: Investigate better sorting algorithms; see Knuth vol. 3.
5.3.1, who credits Lester Ford, Jr. and Selmer Johnson, American
Mathematical Monthly 66 (1959), 387-389.
shred: Update shred as described here to conform to DoD 5220 rules:
http://lists.gnu.org/archive/html/bug-coreutils/2007-05/msg00075.html
Remove suspicious uses of alloca (ones that may allocate more than
about 4k)
@@ -170,7 +176,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer
-----
Copyright (C) 2002-2008 Free Software Foundation, Inc.
Copyright (C) 2002-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

134
bootstrap
View File

@@ -52,6 +52,9 @@ Options:
If the file $0.conf exists in the same directory as this script, its
contents are read as shell variables to configure the bootstrap.
For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
are honored.
Running without arguments will suffice in most cases.
"
}
@@ -195,7 +198,7 @@ insert_sorted_if_absent() {
file=$1
str=$2
test -f $file || touch $file
echo "$str" | sort -u - $file | cmp -s - $file \
echo "$str" | sort -u - $file | cmp - $file > /dev/null \
|| echo "$str" | sort -u - $file -o $file \
|| exit 1
}
@@ -222,6 +225,100 @@ if test ! -d $build_aux; then
done
fi
# Note this deviates from the version comparison in automake
# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
# but this should suffice as we won't be specifying old
# 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
ver1="$1"
ver2="$2"
#split on '.' and compare each component
i=1
while : ; do
p1=$(echo "$ver1" | cut -d. -f$i)
p2=$(echo "$ver2" | cut -d. -f$i)
if [ ! "$p1" ]; then
echo "$1 $2"
break
elif [ ! "$p2" ]; then
echo "$2 $1"
break
elif [ ! "$p1" = "$p2" ]; then
if [ "$p1" -gt "$p2" ] 2>/dev/null; then #numeric comparision
echo "$2 $1"
elif [ "$p2" -gt "$p1" ] 2>/dev/null; then #numeric comparision
echo "$1 $2"
else #numeric, then lexographic comparison
lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
if [ "$lp" = "$p2" ]; then
echo "$1 $2"
else
echo "$2 $1"
fi
fi
break
fi
i=$(($i+1))
done
}
get_version() {
app=$1
$app --version >/dev/null 2>&1 || return 1
$app --version 2>&1 |
sed -n 's/[^0-9.]*\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/p
t done
d
:done
q'
}
check_versions() {
ret=0
while read app req_ver; do
# Honor $APP variables ($TAR, $AUTOCONF, etc.)
appvar=`echo $app | tr '[a-z]' '[A-Z]'`
test "$appvar" = TAR && appvar=AMTAR
eval "app=\${$appvar-$app}"
inst_ver=$(get_version $app)
if [ ! "$inst_ver" ]; then
echo "Error: '$app' not found" >&2
ret=1
elif [ ! "$req_ver" = "-" ]; then
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
if [ ! "$latest_ver" = "$inst_ver" ]; then
echo "Error: '$app' version == $inst_ver is too old" >&2
echo " '$app' version >= $req_ver is required" >&2
ret=1
fi
fi
done
return $ret
}
print_versions() {
echo "Program Min_version"
echo "----------------------"
printf "$buildreq"
echo "----------------------"
#can't depend on column -t
}
if ! printf "$buildreq" | check_versions; then
test -f README-prereq &&
echo "Please see README-prereq for notes on obtaining these prerequisite programs:" >&2
echo
print_versions
exit 1
fi
echo "$0: Bootstrapping from checked-out $package sources..."
# See if we can use gnulib's git-merge-changelog merge driver.
@@ -262,7 +359,8 @@ case ${GNULIB_SRCDIR--} in
trap cleanup_gnulib 1 2 13 15
git clone --depth 2 git://git.sv.gnu.org/gnulib ||
git clone --help|grep depth > /dev/null && depth='--depth 2' || depth=
git clone $depth git://git.sv.gnu.org/gnulib ||
cleanup_gnulib
trap - 1 2 13 15
@@ -322,9 +420,9 @@ update_po_files() {
cksum_file="$ref_po_dir/$po.s1"
if ! test -f "$cksum_file" ||
! test -f "$po_dir/$po.po" ||
! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then
! ${SHA1SUM-sha1sum} -c --status "$cksum_file" < "$new_po" > /dev/null; then
echo "updated $po_dir/$po.po..."
cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
cp "$new_po" "$po_dir/$po.po" && ${SHA1SUM-sha1sum} < "$new_po" > "$cksum_file"
fi
done
}
@@ -487,7 +585,7 @@ slurp() {
if test $file = Makefile.am; then
copied=$copied${sep}$gnulib_mk; sep=$nl
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || {
echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
rm -f $dir/$gnulib_mk &&
sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
@@ -569,9 +667,9 @@ grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
with_gettext=no
if test $with_gettext = yes; then
echo "$0: (cd $bt2; autopoint) ..."
echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
cp configure.ac $bt2 &&
(cd $bt2 && autopoint && rm configure.ac) &&
(cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
slurp $bt2 $bt || exit
fi
rm -fr $bt $bt2 || exit
@@ -592,15 +690,23 @@ find "$m4_base" "$source_base" \
for command in \
libtool \
'aclocal --force -I m4' \
'autoconf --force' \
'autoheader --force' \
'automake --add-missing --copy --force-missing';
"${ACLOCAL-aclocal} --force -I m4" \
"${AUTOCONF-autoconf} --force" \
"${AUTOHEADER-autoheader} --force" \
"${AUTOMAKE-automake} --add-missing --copy --force-missing"
do
if test "$command" = libtool; then
grep '^[ ]*AM_PROG_LIBTOOL\>' configure.ac >/dev/null ||
continue
command='libtoolize -c -f'
use_libtool=0
# We'd like to use grep -E, to see if any of LT_INIT,
# AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
# but that's not portable enough (e.g., for Solaris).
grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
&& use_libtool=1
grep '^[ ]*LT_INIT' configure.ac >/dev/null \
&& use_libtool=1
test $use_libtool = 0 \
&& continue
command="${LIBTOOLIZE-libtoolize} -c -f"
fi
echo "$0: $command ..."
$command || exit

View File

@@ -1,6 +1,6 @@
# Bootstrap configuration.
# Copyright (C) 2006-2008 Free Software Foundation, Inc.
# Copyright (C) 2006-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
@@ -16,11 +16,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# We don't need these modules, even though gnulib-tool mistakenly
# includes them because of gettext and fchdir dependencies.
# We don't need these modules.
avoided_gnulib_modules='
--avoid=lock
--avoid=canonicalize-lgpl
--avoid=dummy
--avoid=lock
'
# These modules are obsolete and can probably be removed soon,
@@ -34,7 +34,9 @@ obsolete_gnulib_modules='
gnulib_modules="
$avoided_gnulib_modules
$obsolete_gnulib_modules
acl alloca announce-gen argmatch assert
acl alloca announce-gen argmatch
argv-iter
assert
autobuild
backupfile base64
c-strcase c-strtod
@@ -61,9 +63,13 @@ gnulib_modules="
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 mbswidth memcasecmp mempcpy
long-options lstat malloc
mbrtowc
mbswidth
memcasecmp mempcpy
memrchr mgetgroups
mkancesdirs mkdir mkdir-p mkstemp mktime modechange
mountlist mpsort obstack pathmax perl physmem
@@ -84,9 +90,10 @@ gnulib_modules="
safe-read same
save-cwd savedir savewd
selinux-at
settime sig2str ssize_t stat-macros
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
@@ -95,9 +102,12 @@ gnulib_modules="
userspec utimecmp utimens
vasprintf-posix
vc-list-files
verify version-etc-fsf
verify version-etc-fsf verror
warnings
wcwidth winsz-ioctl winsz-termios write-any-file
xalloc xgetcwd xgethostname
xalloc
xfreopen
xgetcwd xgethostname
xmemcoll xnanosleep
xprintf
xprintf-posix
@@ -160,5 +170,21 @@ fi
gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
# Build prerequisites
buildreq="\
autoconf 2.61
automake 1.10a
autopoint -
bison -
gettext -
git 1.4.4
gperf -
gzip -
makeinfo -
perl 5.5
rsync -
tar -
"
# Automake requires that ChangeLog exist.
touch ChangeLog

153
cfg.mk
View File

@@ -1,5 +1,5 @@
# Customize maint.mk -*- makefile -*-
# Copyright (C) 2003-2008 Free Software Foundation, Inc.
# Copyright (C) 2003-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
@@ -42,4 +42,153 @@ gnulib_dir = /gnulib
# Now that we have better (check.mk) tests, make this the default.
export VERBOSE = yes
old_NEWS_hash = 95fc7a26fa253d57cabe4b058167a4f9 -
old_NEWS_hash = 791cf10529d00853f6363ca67f360747 -
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
dd = $(srcdir)/src/dd.c
sc_dd_O_FLAGS:
@rm -f $@.1 $@.2
@{ echo O_FULLBLOCK; perl -nle '/MAX \((O_\w*),/ and print $$1' \
$(dd); } | sort > $@.1
@{ echo O_NOFOLLOW; perl -nle '/{"[a-z]+",\s*(O_\w+)},/ and print $$1' \
$(dd); } | sort > $@.2
@diff -u $@.1 $@.2 || diff=1 || diff=; \
rm -f $@.1 $@.2; \
test "$$diff" \
&& { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2; \
exit 1; } || :
# Ensure that dd's definition of LONGEST_SYMBOL stays in sync
# with the strings from the two affected variables.
dd_c = $(srcdir)/src/dd.c
sc_dd_max_sym_length:
ifneq ($(wildcard $(dd_c)),)
@len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
|sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
| wc --max-line-length); \
max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
|tr -d '"' | wc --max-line-length); \
if test "$$len" = "$$max"; then :; else \
echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
exit 1; \
fi
endif
# Many m4 macros names once began with `jm_'.
# On 2004-04-13, they were all changed to start with gl_ instead.
# Make sure that none are inadvertently reintroduced.
sc_prohibit_jm_in_m4:
@grep -nE 'jm_[A-Z]' \
$$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
{ echo '$(ME): do not use jm_ in m4 macro names' \
1>&2; exit 1; } || :
# Ensure that each root-requiring test is run via the "check-root" rule.
sc_root_tests:
@if test -d tests \
&& grep check-root tests/Makefile.am>/dev/null 2>&1; then \
t1=sc-root.expected; t2=sc-root.actual; \
grep -nl '^require_root_$$' \
$$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1; \
sed -n '/^root_tests =[ ]*\\$$/,/[^\]$$/p' \
$(srcdir)/tests/Makefile.am \
| sed 's/^ *//;/^root_tests =/d' \
| tr -s '\012\\' ' ' | fmt -1 | sort > $$t2; \
diff -u $$t1 $$t2 || diff=1 || diff=; \
rm -f $$t1 $$t2; \
test "$$diff" \
&& { echo 'tests/Makefile.am: missing check-root action'>&2; \
exit 1; } || :; \
fi
headers_with_interesting_macro_defs = \
exit.h \
fcntl_.h \
fnmatch_.h \
intprops.h \
inttypes_.h \
lchown.h \
openat.h \
stat-macros.h \
stdint_.h
# Create a list of regular expressions matching the names
# of macros that are guaranteed by parts of gnulib to be defined.
.re-defmac:
@(cd $(srcdir)/lib; \
for f in $(headers_with_interesting_macro_defs); do \
test -f $$f && \
sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
done; \
) | sort -u \
| grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
| sed 's/^/^# *define /' \
> $@-t
@mv $@-t $@
# Don't define macros that we already get from gnulib header files.
sc_always_defined_macros: .re-defmac
@if test -f $(srcdir)/src/system.h; then \
trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
grep -f .re-defmac $$($(VC_LIST)) \
&& { echo '$(ME): define the above via some gnulib .h file' \
1>&2; exit 1; } || :; \
fi
# Create a list of regular expressions matching the names
# of files included from system.h. Exclude a couple.
.re-list:
@sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
| grep -Ev 'sys/(param|file)\.h' \
| sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
> $@-t
@mv $@-t $@
# Files in src/ should not include directly any of
# the headers already included via system.h.
sc_system_h_headers: .re-list
@if test -f $(srcdir)/src/system.h; then \
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
grep -nE -f .re-list \
$$($(VC_LIST) src | \
grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
&& { echo '$(ME): the above are already included via system.h'\
1>&2; exit 1; } || :; \
fi
sc_sun_os_names:
@grep -nEi \
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
$$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
exit 1; } || :
sc_tight_scope:
@$(MAKE) -C src $@
# Perl-based tests used to exec perl from a #!/bin/sh script.
# Now they all start with #!/usr/bin/perl and the portability
# infrastructure is in tests/Makefile.am. Make sure no old-style
# script sneaks back in.
sc_no_exec_perl_coreutils:
@if test -f $(srcdir)/tests/Coreutils.pm; then \
grep '^exec *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) && \
{ echo 1>&2 '$(ME): found anachronistic Perl-based tests'; \
exit 1; } || :; \
fi
# Ensure that date's --help output stays in sync with the info
# documentation for GNU strftime. The only exception is %N,
# which date accepts but GNU strftime does not.
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
sc_strftime_check:
@if test -f $(srcdir)/src/date.c; then \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
{ echo N; \
info libc date calendar format | grep '^ `%.'\' \
| $(extract_char); } | sort > $@-info; \
diff -u $@-src $@-info || exit 1; \
rm -f $@-src $@-info; \
fi

View File

@@ -18,7 +18,7 @@
dnl Written by Jim Meyering.
AC_PREREQ(2.61)
AC_PREREQ([2.61])
# Make inter-release version strings look like, e.g., v6.9-219-g58ddd, which
# indicates that it is built from the 219th delta (in _some_ repository)
@@ -27,12 +27,12 @@ AC_INIT([GNU coreutils],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[bug-coreutils@gnu.org])
AC_CONFIG_SRCDIR(src/ls.c)
AC_CONFIG_SRCDIR([src/ls.c])
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
AM_INIT_AUTOMAKE([1.10a dist-lzma])
AM_INIT_AUTOMAKE([1.10a dist-xz])
AC_PROG_CC_STDC
AM_PROG_CC_C_O
@@ -44,20 +44,53 @@ gl_EARLY
gl_INIT
coreutils_MACROS
AC_ARG_ENABLE([gcc-warnings],
[AS_HELP_STRING([--enable-gcc-warnings],
[turn on lots of GCC warnings (not recommended)])],
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
esac
gl_gcc_warnings=$enableval],
[gl_gcc_warnings=no]
)
if test "$gl_gcc_warnings" = yes; then
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
AC_SUBST([WERROR_CFLAGS])
gl_WARN_ADD([-Wall])
gl_WARN_ADD([-Wextra])
gl_WARN_ADD([-Wshadow])
gl_WARN_ADD([-Wno-sign-compare])
gl_WARN_ADD([-Wformat])
gl_WARN_ADD([-Wformat-security])
gl_WARN_ADD([-Wcast-align])
gl_WARN_ADD([-Wpointer-arith])
gl_WARN_ADD([-Wwrite-strings])
gl_WARN_ADD([-Wbad-function-cast])
gl_WARN_ADD([-Wmissing-declarations])
gl_WARN_ADD([-Wmissing-prototypes])
gl_WARN_ADD([-Wstrict-prototypes])
AC_SUBST([WARN_CFLAGS])
AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
AC_DEFINE([_FORTIFY_SOURCE], [2],
[enable compile-time and run-time bounds-checking, and some warnings])
fi
AC_FUNC_FORK
optional_bin_progs=
AC_CHECK_FUNCS(uname,
AC_CHECK_FUNCS([uname],
gl_ADD_PROG([optional_bin_progs], [uname]))
AC_CHECK_FUNCS(chroot,
AC_CHECK_FUNCS([chroot],
gl_ADD_PROG([optional_bin_progs], [chroot]))
AC_CHECK_FUNCS(gethostid,
AC_CHECK_FUNCS([gethostid],
gl_ADD_PROG([optional_bin_progs], [hostid]))
gl_WINSIZE_IN_PTEM
AC_MSG_CHECKING(whether localtime caches TZ)
AC_CACHE_VAL(utils_cv_localtime_cache,
AC_MSG_CHECKING([whether localtime caches TZ])
AC_CACHE_VAL([utils_cv_localtime_cache],
[if test x$ac_cv_func_tzset = xyes; then
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
#if STDC_HEADERS
@@ -98,22 +131,22 @@ else
# since we can't invalidate the cache if we don't have tzset.
utils_cv_localtime_cache=no
fi])dnl
AC_MSG_RESULT($utils_cv_localtime_cache)
AC_MSG_RESULT([$utils_cv_localtime_cache])
if test $utils_cv_localtime_cache = yes; then
AC_DEFINE(LOCALTIME_CACHE, 1, [FIXME])
AC_DEFINE([LOCALTIME_CACHE], [1], [FIXME])
fi
# SCO-ODT-3.0 is reported to need -los to link programs using initgroups
AC_CHECK_FUNCS(initgroups)
AC_CHECK_FUNCS([initgroups])
if test $ac_cv_func_initgroups = no; then
AC_CHECK_LIB(os, initgroups)
AC_CHECK_LIB([os], [initgroups])
fi
AC_CHECK_FUNCS(syslog)
AC_CHECK_FUNCS([syslog])
if test $ac_cv_func_syslog = no; then
# syslog is not in the default libraries. See if it's in some other.
for lib in bsd socket inet; do
AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG, 1, [FIXME])
AC_CHECK_LIB([$lib], [syslog], [AC_DEFINE([HAVE_SYSLOG], [1], [FIXME])
LIBS="$LIBS -l$lib"; break])
done
fi
@@ -147,29 +180,29 @@ AC_DEFUN([coreutils_DUMMY_1],
])
coreutils_DUMMY_1
AC_MSG_CHECKING(ut_host in struct utmp)
AC_CACHE_VAL(su_cv_func_ut_host_in_utmp,
AC_MSG_CHECKING([ut_host in struct utmp])
AC_CACHE_VAL([su_cv_func_ut_host_in_utmp],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <utmp.h>]], [[struct utmp ut; return !sizeof ut.ut_host;]])],
[su_cv_func_ut_host_in_utmp=yes],
[su_cv_func_ut_host_in_utmp=no])])
AC_MSG_RESULT($su_cv_func_ut_host_in_utmp)
AC_MSG_RESULT([$su_cv_func_ut_host_in_utmp])
if test $su_cv_func_ut_host_in_utmp = yes; then
have_ut_host=1
AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
fi
if test -z "$have_ut_host"; then
AC_MSG_CHECKING(ut_host in struct utmpx)
AC_CACHE_VAL(su_cv_func_ut_host_in_utmpx,
AC_MSG_CHECKING([ut_host in struct utmpx])
AC_CACHE_VAL([su_cv_func_ut_host_in_utmpx],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <utmpx.h>]], [[struct utmpx ut; return !sizeof ut.ut_host;]])],
[su_cv_func_ut_host_in_utmpx=yes],
[su_cv_func_ut_host_in_utmpx=no])])
AC_MSG_RESULT($su_cv_func_ut_host_in_utmpx)
AC_MSG_RESULT([$su_cv_func_ut_host_in_utmpx])
if test $su_cv_func_ut_host_in_utmpx = yes; then
AC_DEFINE(HAVE_UTMPX_H, 1, [FIXME])
AC_DEFINE(HAVE_UT_HOST, 1, [FIXME])
AC_DEFINE([HAVE_UTMPX_H], [1], [FIXME])
AC_DEFINE([HAVE_UT_HOST], [1], [FIXME])
fi
fi
@@ -181,24 +214,24 @@ gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
if test $ac_cv_sys_posix_termios = yes; then
gl_ADD_PROG([optional_bin_progs], [stty])
AC_MSG_CHECKING(whether termios.h needs _XOPEN_SOURCE)
AC_CACHE_VAL(su_cv_sys_termios_needs_xopen_source,
[AC_EGREP_CPP(yes, [#include <termios.h>
AC_MSG_CHECKING([whether termios.h needs _XOPEN_SOURCE])
AC_CACHE_VAL([su_cv_sys_termios_needs_xopen_source],
[AC_EGREP_CPP([yes], [#include <termios.h>
#ifdef IUCLC
yes
#endif], su_cv_sys_termios_needs_xopen_source=no,
AC_EGREP_CPP(yes, [#define _XOPEN_SOURCE
AC_EGREP_CPP([yes], [#define _XOPEN_SOURCE
#include <termios.h>
#ifdef IUCLC
yes
#endif], su_cv_sys_termios_needs_xopen_source=yes,
su_cv_sys_termios_needs_xopen_source=no))])
AC_MSG_RESULT($su_cv_sys_termios_needs_xopen_source)
AC_MSG_RESULT([$su_cv_sys_termios_needs_xopen_source])
test $su_cv_sys_termios_needs_xopen_source = yes &&
AC_DEFINE(TERMIOS_NEEDS_XOPEN_SOURCE, 1, [FIXME])
AC_DEFINE([TERMIOS_NEEDS_XOPEN_SOURCE], [1], [FIXME])
AC_MSG_CHECKING(c_line in struct termios)
AC_CACHE_VAL(su_cv_sys_c_line_in_termios,
AC_MSG_CHECKING([c_line in struct termios])
AC_CACHE_VAL([su_cv_sys_c_line_in_termios],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if TERMIOS_NEEDS_XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
@@ -206,9 +239,9 @@ yes
#include <termios.h>]], [[struct termios t; return !sizeof t.c_line;]])],
[su_cv_sys_c_line_in_termios=yes],
[su_cv_sys_c_line_in_termios=no])])
AC_MSG_RESULT($su_cv_sys_c_line_in_termios)
AC_MSG_RESULT([$su_cv_sys_c_line_in_termios])
test $su_cv_sys_c_line_in_termios = yes \
&& AC_DEFINE(HAVE_C_LINE, 1, [FIXME])
&& AC_DEFINE([HAVE_C_LINE], [1], [FIXME])
fi
# FIXME: note that this macro appears above, too.
@@ -219,8 +252,8 @@ gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
test $gl_cv_sys_tiocgwinsz_needs_sys_ioctl_h = no; then
AC_MSG_CHECKING(TIOCGWINSZ in sys/pty.h)
AC_CACHE_VAL(su_cv_sys_tiocgwinsz_in_sys_pty_h,
AC_MSG_CHECKING([TIOCGWINSZ in sys/pty.h])
AC_CACHE_VAL([su_cv_sys_tiocgwinsz_in_sys_pty_h],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#ifdef WINSIZE_IN_PTEM
# include <sys/stream.h>
@@ -231,10 +264,10 @@ if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
#include <sys/pty.h>]], [[int x = TIOCGWINSZ;]])],
[su_cv_sys_tiocgwinsz_in_sys_pty_h=yes],
[su_cv_sys_tiocgwinsz_in_sys_pty_h=no])])
AC_MSG_RESULT($su_cv_sys_tiocgwinsz_in_sys_pty_h)
AC_MSG_RESULT([$su_cv_sys_tiocgwinsz_in_sys_pty_h])
test $su_cv_sys_tiocgwinsz_in_sys_pty_h = yes \
&& AC_DEFINE(GWINSZ_IN_SYS_PTY, 1,
&& AC_DEFINE([GWINSZ_IN_SYS_PTY], [1],
[Define if your system defines TIOCGWINSZ in sys/pty.h.])
fi

View File

@@ -1,6 +1,6 @@
# Make coreutils documentation. -*-Makefile-*-
# Copyright (C) 1995-1998, 2001-2008 Free Software Foundation, Inc.
# Copyright (C) 1995-1998, 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
@@ -29,10 +29,13 @@ EXTRA_DIST = perm.texi getdate.texi constants.texi fdl.texi
# old systems.
AM_MAKEINFOFLAGS = --no-split
constants.texi: $(top_srcdir)/src/tail.c
constants.texi: $(top_srcdir)/src/tail.c $(top_srcdir)/src/shred.c
LC_ALL=C \
sed -n -e 's/^#define \(DEFAULT_MAX[_A-Z]*\) \(.*\)/@set \1 \2/p' \
$(top_srcdir)/src/tail.c > t-$@
LC_ALL=C \
sed -n -e 's/.*\(DEFAULT_PASSES\)[ =]* \([0-9]*\).*/@set SHRED_\1 \2/p'\
$(top_srcdir)/src/shred.c >> t-$@
mv t-$@ $@
MAINTAINERCLEANFILES = constants.texi
@@ -50,13 +53,14 @@ syntax_checks = \
sc-avoid-timezone \
sc-avoid-zeroes \
sc-exponent-grouping \
sc-lower-case-var \
sc-use-small-caps-NUL
.PHONY: $(syntax_checks) check-texinfo
# List words/regexps here that should not appear in the texinfo documentation.
check-texinfo: $(syntax_checks)
fail=0; \
@fail=0; \
grep '@url{' $(srcdir)/*.texi && fail=1; \
grep '\$$@"' $(srcdir)/*.texi && fail=1; \
grep -n '[^[:punct:]]@footnote' $(srcdir)/*.texi && fail=1; \
@@ -73,27 +77,45 @@ check-texinfo: $(syntax_checks)
# Use `time zone', not `timezone'.
sc-avoid-timezone:
$(EGREP) timezone $(srcdir)/*.texi && exit 1 || :
@$(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 || :
@$(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 || :
@$(EGREP) '$(_W)NUL$(W_)' $(srcdir)/*.texi && exit 1 || :
# Say I/O, not IO.
sc-avoid-io:
$(EGREP) '$(_W)IO$(W_)' $(srcdir)/*.texi && exit 1 || :
@$(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 || :
@$(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 || :
@$(EGREP) -i '$(_W)zeroes$(W_)' $(srcdir)/*.texi && exit 1 || :
# ME = $(subdir)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ME = doc/Makefile
# The quantity inside @var{...} should not contain upper case letters.
# The leading backslash exemption is to permit in-macro uses like
# @var{\varName\} where the upper case letter is part of a parameter name.
find_upper_case_var = \
'/\@var{/ or next; \
while (/\@var{(.+?)}/g) \
{ \
$$v = $$1; \
$$v =~ /[A-Z]/ && $$v !~ /^\\/ and (print "$$ARGV:$$.:$$_"), $$m = 1 \
} \
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
check: check-texinfo

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
@c File mode bits
@c Copyright (C) 1994, 1996, 1999, 2000, 2001, 2003, 2004, 2005, 2006
@c Copyright (C) 1994, 1996, 1999-2001, 2003-2006, 2008
@c Free Software Foundation, Inc.
@c Permission is granted to copy, distribute and/or modify this document
@c under the terms of the GNU Free Documentation License, Version 1.2 or
@c under the terms of the GNU Free Documentation License, Version 1.3 or
@c any later version published by the Free Software Foundation; with no
@c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
@c Texts. A copy of the license is included in the ``GNU Free

117
gl/lib/argv-iter.c Normal file
View File

@@ -0,0 +1,117 @@
/* Iterate over arguments from argv or --files0-from=FILE
Copyright (C) 2008 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 Jim Meyering. */
#include <config.h>
#include "argv-iter.h"
#include <stdlib.h>
#include <string.h>
struct argv_iterator
{
/* Test FP to determine whether in read-mode or argv-mode. */
/* file-mode: fp records position */
FILE *fp;
size_t item_idx;
char *tok;
size_t buf_len;
/* argv-mode: record just argv and current pointer */
char **arg_list;
char **p;
};
struct argv_iterator *
argv_iter_init_argv (char **argv)
{
struct argv_iterator *ai = malloc (sizeof *ai);
if (!ai)
return NULL;
ai->fp = NULL;
ai->arg_list = argv;
ai->p = argv;
return ai;
}
/* Initialize to read from the stream, FP.
The input is expected to contain a list of NUL-delimited tokens. */
struct argv_iterator *
argv_iter_init_stream (FILE *fp)
{
struct argv_iterator *ai = malloc (sizeof *ai);
if (!ai)
return NULL;
ai->fp = fp;
ai->tok = NULL;
ai->buf_len = 0;
ai->item_idx = 0;
ai->arg_list = NULL;
return ai;
}
char *
argv_iter (struct argv_iterator *ai, enum argv_iter_err *err)
{
if (ai->fp)
{
ssize_t len = getdelim (&ai->tok, &ai->buf_len, '\0', ai->fp);
if (len < 0)
{
*err = feof (ai->fp) ? AI_ERR_EOF : AI_ERR_READ;
return NULL;
}
*err = AI_ERR_OK;
ai->item_idx++;
return ai->tok;
}
else
{
if (*(ai->p) == NULL)
{
*err = AI_ERR_EOF;
return NULL;
}
else
{
*err = AI_ERR_OK;
return *(ai->p++);
}
}
}
size_t
argv_iter_n_args (struct argv_iterator const *ai)
{
return ai->fp ? ai->item_idx : ai->p - ai->arg_list;
}
void
argv_iter_free (struct argv_iterator *ai)
{
if (ai->fp)
free (ai->tok);
free (ai);
}
/*
* Local variables:
* indent-tabs-mode: nil
* End:
*/

47
gl/lib/argv-iter.h Normal file
View File

@@ -0,0 +1,47 @@
/* Iterate over arguments from argv or --files0-from=FILE
Copyright (C) 2008 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 <stdio.h>
#include <stdbool.h>
struct argv_iterator;
enum argv_iter_err;
#undef _ATTRIBUTE_NONNULL_
#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__
# define _ATTRIBUTE_NONNULL_(m,...) __attribute__ ((__nonnull__ (m)))
#else
# define _ATTRIBUTE_NONNULL_(m,...)
#endif
enum argv_iter_err
{
AI_ERR_OK = 1,
AI_ERR_EOF,
AI_ERR_MEM,
AI_ERR_READ
};
struct argv_iterator *argv_iter_init_argv (char **argv)
_ATTRIBUTE_NONNULL_ (1);
struct argv_iterator *argv_iter_init_stream (FILE *fp)
_ATTRIBUTE_NONNULL_ (1);
char *argv_iter (struct argv_iterator *, enum argv_iter_err *)
_ATTRIBUTE_NONNULL_ (1, 2);
size_t argv_iter_n_args (struct argv_iterator const *)
_ATTRIBUTE_NONNULL_ (1);
void argv_iter_free (struct argv_iterator *)
_ATTRIBUTE_NONNULL_ (1);

View File

@@ -1,6 +1,6 @@
/* mgetgroups.c -- return a list of the groups a user is in
Copyright (C) 2007-2008 Free Software Foundation, Inc.
Copyright (C) 2007-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
@@ -33,16 +33,16 @@
#include "xalloc.h"
static void *
allocate_groupbuf (int size)
static GETGROUPS_T *
realloc_groupbuf (GETGROUPS_T *g, size_t num)
{
if (xalloc_oversized (size, sizeof (GETGROUPS_T)))
if (xalloc_oversized (num, sizeof (*g)))
{
errno = ENOMEM;
return NULL;
}
return malloc (size * sizeof (GETGROUPS_T));
return realloc (g, num * sizeof (*g));
}
/* Like getugroups, but store the result in malloc'd storage.
@@ -65,45 +65,27 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
performance characteristics.
In glibc 2.3.2, getgrouplist is buggy. If you pass a zero as the
size of the output buffer, getgrouplist will still write to the
length of the output buffer, getgrouplist will still write to the
buffer. Contrary to what some versions of the getgrouplist
manpage say, this doesn't happen with nonzero buffer sizes.
Therefore our usage here just avoids a zero sized buffer. */
if (username)
{
enum { N_GROUPS_INIT = 10 };
GETGROUPS_T smallbuf[N_GROUPS_INIT];
max_n_groups = N_GROUPS_INIT;
ng = getgrouplist (username, gid, smallbuf, &max_n_groups);
g = allocate_groupbuf (max_n_groups);
g = realloc_groupbuf (NULL, max_n_groups);
if (g == NULL)
return -1;
if (max_n_groups <= N_GROUPS_INIT)
{
/* smallbuf was big enough, so we already have our data */
memcpy (g, smallbuf, max_n_groups * sizeof *g);
*groups = g;
return max_n_groups;
}
while (1)
{
GETGROUPS_T *h;
/* getgrouplist updates max_n_groups to num required. */
ng = getgrouplist (username, gid, g, &max_n_groups);
if (0 <= ng)
{
*groups = g;
return ng;
}
/* When getgrouplist fails, it guarantees that
max_n_groups reflects the new number of groups. */
if (xalloc_oversized (max_n_groups, sizeof *h)
|| (h = realloc (g, max_n_groups * sizeof *h)) == NULL)
if ((h = realloc_groupbuf (g, max_n_groups)) == NULL)
{
int saved_errno = errno;
free (g);
@@ -111,6 +93,12 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
return -1;
}
g = h;
if (0 <= ng)
{
*groups = g;
return ng;
}
}
}
/* else no username, so fall through and use getgroups. */
@@ -125,7 +113,7 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
if (max_n_groups < 0)
max_n_groups = 5;
g = allocate_groupbuf (max_n_groups);
g = realloc_groupbuf (NULL, max_n_groups);
if (g == NULL)
return -1;

View File

@@ -1,31 +0,0 @@
#ifndef SELINUX_CONTEXT_H
# define SELINUX_CONTEXT_H
# include <errno.h>
/* Some systems don't have ENOTSUP. */
# ifndef ENOTSUP
# ifdef ENOSYS
# define ENOTSUP ENOSYS
# else
/* Some systems don't have ENOSYS either. */
# define ENOTSUP EINVAL
# endif
# endif
typedef int context_t;
static inline context_t context_new (char const *s)
{ errno = ENOTSUP; return 0; }
static inline char *context_str (context_t con)
{ errno = ENOTSUP; return (void *) 0; }
static inline void context_free (context_t c) {}
static inline int context_user_set (context_t sc, char const *s)
{ errno = ENOTSUP; return -1; }
static inline int context_role_set (context_t sc, char const *s)
{ errno = ENOTSUP; return -1; }
static inline int context_range_set (context_t sc, char const *s)
{ errno = ENOTSUP; return -1; }
static inline int context_type_set (context_t sc, char const *s)
{ errno = ENOTSUP; return -1; }
#endif

View File

@@ -1,57 +0,0 @@
#ifndef SELINUX_SELINUX_H
# define SELINUX_SELINUX_H
# include <sys/types.h>
# include <errno.h>
/* Some systems don't have ENOTSUP. */
# ifndef ENOTSUP
# ifdef ENOSYS
# define ENOTSUP ENOSYS
# else
/* Some systems don't have ENOSYS either. */
# define ENOTSUP EINVAL
# endif
# endif
typedef unsigned short security_class_t;
# define security_context_t char*
# define is_selinux_enabled() 0
static inline int getcon (security_context_t *con)
{ errno = ENOTSUP; return -1; }
static inline void freecon (security_context_t con) {}
static inline int getfscreatecon (security_context_t *con)
{ errno = ENOTSUP; return -1; }
static inline int setfscreatecon (security_context_t con)
{ errno = ENOTSUP; return -1; }
static inline int matchpathcon (char const *s, mode_t m,
security_context_t *con)
{ errno = ENOTSUP; return -1; }
static inline int getfilecon (char const *s, security_context_t *con)
{ errno = ENOTSUP; return -1; }
static inline int lgetfilecon (char const *s, security_context_t *con)
{ errno = ENOTSUP; return -1; }
static inline int setfilecon (char const *s, security_context_t con)
{ errno = ENOTSUP; return -1; }
static inline int lsetfilecon (char const *s, security_context_t con)
{ errno = ENOTSUP; return -1; }
static inline int fsetfilecon (int fd, security_context_t con)
{ errno = ENOTSUP; return -1; }
static inline int security_check_context (security_context_t con)
{ errno = ENOTSUP; return -1; }
static inline int security_check_context_raw (security_context_t con)
{ errno = ENOTSUP; return -1; }
static inline int setexeccon (security_context_t con)
{ errno = ENOTSUP; return -1; }
static inline int security_compute_create (security_context_t scon,
security_context_t tcon,
security_class_t tclass,
security_context_t *newcon)
{ errno = ENOTSUP; return -1; }
static inline int matchpathcon_init_prefix (char const *path,
char const *prefix)
{ errno = ENOTSUP; return -1; }
#endif

41
gl/lib/xfreopen.c Normal file
View File

@@ -0,0 +1,41 @@
/* a wrapper for frepoen
Copyright (C) 2008 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 <config.h>
#include "xfreopen.h"
#include <errno.h>
#include "error.h"
#include "exitfail.h"
#include "quote.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
void
xfreopen (char const *filename, char const *mode, FILE *fp)
{
if (!freopen (filename, mode, fp))
{
char const *f = (filename ? filename
: (fp == stdin ? _("stdin")
: (fp == stdout ? _("stdout")
: (fp == stderr ? _("stderr")
: _("unknown stream")))));
error (exit_failure, errno, _("failed to reopen %s with mode %s"),
quote_n (0, f), quote_n (1, mode));
}
}

2
gl/lib/xfreopen.h Normal file
View File

@@ -0,0 +1,2 @@
#include <stdio.h>
void xfreopen (char const *filename, char const *mode, FILE *fp);

View File

@@ -1,4 +1,4 @@
#serial 2
#serial 3
dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,6 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_MGETGROUPS],
[
AC_CHECK_FUNCS(getgrouplist)
AC_CHECK_FUNCS([getgrouplist])
AC_LIBOBJ([mgetgroups])
])

View File

@@ -1,17 +0,0 @@
# serial 1 -*- Autoconf -*-
# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# From Jim Meyering
# Provide <selinux/context.h>, if necessary.
AC_DEFUN([gl_HEADERS_SELINUX_CONTEXT_H],
[
# Check for <selinux/context.h>,
AC_CHECK_HEADERS([selinux/context.h],
[SELINUX_CONTEXT_H=],
[SELINUX_CONTEXT_H=selinux/context.h])
AC_SUBST([SELINUX_CONTEXT_H])
])

View File

@@ -1,17 +0,0 @@
# serial 1 -*- Autoconf -*-
# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# From Jim Meyering
# Provide <selinux/selinux.h>, if necessary.
AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H],
[
# Check for <selinux/selinux.h>,
AC_CHECK_HEADERS([selinux/selinux.h],
[SELINUX_SELINUX_H=],
[SELINUX_SELINUX_H=selinux/selinux.h])
AC_SUBST([SELINUX_SELINUX_H])
])

24
gl/modules/argv-iter Normal file
View File

@@ -0,0 +1,24 @@
Description:
iterate through argv or a --files0-from=-specified file
Files:
lib/argv-iter.c
lib/argv-iter.h
Depends-on:
getdelim
stdbool
configure.ac:
Makefile.am:
lib_SOURCES += argv-iter.c argv-iter.h
Include:
"argv-iter.h"
License
GPL
Maintainer:
Jim Meyering

View File

@@ -0,0 +1,10 @@
Files:
tests/test-argv-iter.c
Depends-on:
configure.ac:
Makefile.am:
TESTS += test-argv-iter
check_PROGRAMS += test-argv-iter

View File

@@ -1,16 +1,13 @@
Index: modules/getloadavg
===================================================================
RCS file: /sources/gnulib/gnulib/modules/getloadavg,v
retrieving revision 1.13
diff -u -p -r1.13 getloadavg
--- modules/getloadavg 22 Sep 2006 12:47:55 -0000 1.13
+++ modules/getloadavg 23 Sep 2006 16:41:36 -0000
@@ -14,7 +14,7 @@ stdbool
diff --git a/modules/getloadavg b/modules/getloadavg
index 2fbeb40..b79aaca 100644
--- a/modules/getloadavg
+++ b/modules/getloadavg
@@ -16,7 +16,7 @@ stdbool
fcntl-safer
configure.ac:
-gl_GETLOADAVG([$gl_source_base])
+gl_GETLOADAVG([lib])
gl_STDLIB_MODULE_INDICATOR([getloadavg])
Makefile.am:

View File

@@ -13,12 +13,13 @@ configure.ac:
# For runcon.
AC_CHECK_HEADERS([selinux/flask.h])
AC_LIBOBJ([selinux-at])
ac_save_LIBS="$LIBS"
AC_SEARCH_LIBS(setfilecon, selinux,
gl_save_LIBS=$LIBS
LIB_SELINUX=
AC_SEARCH_LIBS([setfilecon], [selinux],
[test "$ac_cv_search_setfilecon" = "none required" ||
LIB_SELINUX=$ac_cv_search_setfilecon])
AC_SUBST(LIB_SELINUX)
LIBS="$ac_save_LIBS"
LIBS=$gl_save_LIBS
Makefile.am:

View File

@@ -1,56 +0,0 @@
Description:
SELinux-related headers for systems that lack them.
Files:
lib/se-context.in.h
lib/se-selinux.in.h
m4/selinux-context-h.m4
m4/selinux-selinux-h.m4
Depends-on:
configure.ac:
gl_HEADERS_SELINUX_SELINUX_H
gl_HEADERS_SELINUX_CONTEXT_H
Makefile.am:
lib_SOURCES += se-context.in.h se-selinux.in.h
BUILT_SOURCES += $(SELINUX_SELINUX_H)
selinux/selinux.h: se-selinux.in.h
mkdir -p selinux
cp $(srcdir)/se-selinux.in.h $@-t
chmod a-x $@-t
mv $@-t $@
MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t
BUILT_SOURCES += $(SELINUX_CONTEXT_H)
selinux/context.h: se-context.in.h
mkdir -p selinux
cp $(srcdir)/se-context.in.h $@-t
chmod a-x $@-t
mv $@-t $@
MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t
MOSTLYCLEANDIRS += selinux
Include:
#include <selinux/selinux.h>
#include <selinux/context.h>
License:
LGPL
Maintainer:
Jim Meyering
# lib/selinux-at.c
#
# # For runcon.
# AC_CHECK_HEADERS([selinux/flask.h])
#
# ac_save_LIBS="$LIBS"
# AC_SEARCH_LIBS(setfilecon, selinux,
# [test "$ac_cv_search_setfilecon" = "none required" ||
# LIB_SELINUX=$ac_cv_search_setfilecon])
# AC_SUBST(LIB_SELINUX)
# LIBS="$ac_save_LIBS"

25
gl/modules/xfreopen Normal file
View File

@@ -0,0 +1,25 @@
Description:
a wrapper for frepoen
Files:
lib/xfreopen.c
lib/xfreopen.h
Depends-on:
error
exitfail
quote
configure.ac:
Makefile.am:
lib_SOURCES += xfreopen.c xfreopen.h
Include:
"xfreopen.h"
License:
LGPL
Maintainer:
Jim Meyering

120
gl/tests/test-argv-iter.c Normal file
View File

@@ -0,0 +1,120 @@
/* Test argv iterator
Copyright (C) 2008 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 Jim Meyering. */
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
#define ASSERT(expr) \
do \
{ \
if (!(expr)) \
{ \
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
fflush (stderr); \
abort (); \
} \
} \
while (0)
#include "argv-iter.h"
static FILE *
write_nul_delimited_argv (char **argv)
{
FILE *fp = tmpfile ();
ASSERT (fp);
while (*argv)
{
size_t len = strlen (*argv) + 1;
ASSERT (fwrite (*argv, len, 1, fp) == 1);
argv++;
}
ASSERT (fflush (fp) == 0);
rewind (fp);
return fp;
}
int
main ()
{
/* set_program_name (argv[0]); placate overzealous "syntax-check" test. */
static char *av[][4] = {
{NULL},
{"1", NULL},
{"1", "2", NULL},
{"1", "2", "3", NULL}
};
int use_stream;
for (use_stream = 0; use_stream < 2; use_stream++)
{
size_t i;
for (i = 0; i < ARRAY_CARDINALITY (av); i++)
{
FILE *fp;
struct argv_iterator *ai;
if (use_stream)
{
/* Generate an identical list to be read via FP. */
ASSERT ((fp = write_nul_delimited_argv (av[i])) != NULL);
ai = argv_iter_init_stream (fp);
}
else
{
fp = NULL;
ai = argv_iter_init_argv (av[i]);
}
ASSERT (ai);
size_t n_found = 0;
while (1)
{
enum argv_iter_err ai_err;
char *s = argv_iter (ai, &ai_err);
ASSERT ((i == n_found) == (ai_err == AI_ERR_EOF));
ASSERT ((s == NULL) ^ (ai_err == AI_ERR_OK));
ASSERT (ai_err == AI_ERR_OK || ai_err == AI_ERR_EOF);
if (ai_err == AI_ERR_OK)
++n_found;
if (ai_err == AI_ERR_EOF)
break;
/* In stream mode, the strings are equal, but
in argv mode the actual pointers are equal. */
ASSERT (use_stream
? STREQ (s, av[i][n_found - 1])
: s == av[i][n_found - 1]);
}
ASSERT (argv_iter_n_args (ai) == i);
argv_iter_free (ai);
if (fp)
ASSERT (fclose (fp) == 0);
}
}
return 0;
}
/*
* Local variables:
* indent-tabs-mode: nil
* End:
*/

View File

@@ -17,7 +17,7 @@
include gnulib.mk
AM_CFLAGS = $(WARNING_CFLAGS) $(WERROR_CFLAGS)
AM_CFLAGS = $(WARN_CFLAGS) # $(WERROR_CFLAGS)
libcoreutils_a_SOURCES += \
buffer-lcm.c buffer-lcm.h \

View File

@@ -1,7 +1,7 @@
# boottime.m4 serial 3
# boottime.m4 serial 4
# Determine whether this system has infrastructure for obtaining the boot time.
# Copyright (C) 1996, 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
# Copyright (C) 1996, 2000, 2002-2004, 2006, 2008 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
@@ -20,14 +20,14 @@
* ----------------------------------------------------------
AC_DEFUN([GNULIB_BOOT_TIME],
[
AC_CHECK_FUNCS(sysctl)
AC_CHECK_HEADERS_ONCE(sys/param.h)
AC_CHECK_HEADERS(sys/sysctl.h, [], [],
AC_CHECK_FUNCS([sysctl])
AC_CHECK_HEADERS_ONCE([sys/param.h])
AC_CHECK_HEADERS([sys/sysctl.h], [], [],
[AC_INCLUDES_DEFAULT
[#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif]])
AC_CHECK_HEADERS_ONCE(utmp.h utmpx.h OS.h)
AC_CHECK_HEADERS_ONCE([utmp.h utmpx.h OS.h])
AC_CACHE_CHECK(
[whether we can get the system boot time],
[gnulib_cv_have_boot_time],
@@ -57,8 +57,8 @@ AC_DEFUN([GNULIB_BOOT_TIME],
please_tell_us_how_to_determine_boot_time_on_your_system
#endif
]])],
gnulib_cv_have_boot_time=yes,
gnulib_cv_have_boot_time=no)
[gnulib_cv_have_boot_time=yes],
[gnulib_cv_have_boot_time=no])
])
AS_IF([test $gnulib_cv_have_boot_time = yes], [$1], [$2])
])

View File

@@ -1,7 +1,7 @@
#serial 23
#serial 24
# Check declarations for this package.
dnl Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006
dnl Copyright (C) 1997-2001, 2003-2006, 2008
dnl Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
@@ -16,7 +16,7 @@ AC_DEFUN([gl_CHECK_DECLS],
[
AC_REQUIRE([AC_HEADER_TIME])
AC_CHECK_HEADERS_ONCE(grp.h pwd.h)
AC_CHECK_HEADERS_ONCE([grp.h pwd.h])
headers='
#include <sys/types.h>

View File

@@ -28,7 +28,7 @@ AC_DEFUN([cu_GMP],
[test "$ac_cv_search___gmpz_init" = "none required" ||
{
LIB_GMP=$ac_cv_search___gmpz_init
AC_DEFINE([HAVE_GMP], 1,
AC_DEFINE([HAVE_GMP], [1],
[Define if you have GNU libgmp (or replacement)])
}])
LIBS=$cu_saved_libs

View File

@@ -1,8 +1,8 @@
#serial 107 -*- autoconf -*-
#serial 109 -*- autoconf -*-
dnl Misc type-related macros for coreutils.
# Copyright (C) 1998, 2000-2008 Free Software Foundation, Inc.
# Copyright (C) 1998, 2000-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
@@ -22,7 +22,7 @@ dnl Misc type-related macros for coreutils.
AC_DEFUN([coreutils_MACROS],
[
AM_MISSING_PROG(HELP2MAN, help2man)
AC_SUBST(MAN)
AC_SUBST([MAN])
dnl This macro actually runs replacement code. See isc-posix.m4.
AC_REQUIRE([AC_ISC_POSIX])dnl
@@ -36,15 +36,15 @@ AC_DEFUN([coreutils_MACROS],
AC_REQUIRE([AC_FUNC_FSEEKO])
# By default, argmatch should fail calling usage (1).
AC_DEFINE(ARGMATCH_DIE, [usage (1)],
AC_DEFINE([ARGMATCH_DIE], [usage (1)],
[Define to the function xargmatch calls on failures.])
AC_DEFINE(ARGMATCH_DIE_DECL, [void usage ()],
AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
[Define to the declaration of the xargmatch failure function.])
# used by ls
AC_REQUIRE([gl_CLOCK_TIME])
# used by shred
AC_CHECK_FUNCS_ONCE(directio)
AC_CHECK_FUNCS_ONCE([directio])
# Used by install.c.
AC_CHECK_FUNCS_ONCE([matchpathcon_init_prefix])
@@ -79,7 +79,7 @@ AC_DEFUN([coreutils_MACROS],
[test "$ac_cv_search_fdatasync" = "none required" ||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
AC_SUBST([LIB_FDATASYNC])
AC_CHECK_FUNCS(fdatasync)
AC_CHECK_FUNCS([fdatasync])
LIBS=$coreutils_saved_libs
# Check whether libcap is usable -- for ls --color support
@@ -88,8 +88,9 @@ AC_DEFUN([coreutils_MACROS],
AC_MSG_WARN([libcap support disabled by user]),
[AC_CHECK_LIB([cap], [cap_get_file],
[AC_CHECK_HEADER([sys/capability.h],
[LIB_CAP=-lcap AC_DEFINE([HAVE_CAP], 1, [libcap usability])],
[AC_MSG_WARN([header sys/capability.h was not found, support for libcap will not be built])]
[LIB_CAP=-lcap
AC_DEFINE([HAVE_CAP], [1], [libcap usability])],
[AC_MSG_WARN([header sys/capability.h was not found, support for libcap will not be built])]
)],
[AC_MSG_WARN([libcap library was not found or not usable, support for libcap will not be built])])
])
@@ -100,16 +101,16 @@ AC_DEFUN([coreutils_MACROS],
# BeOS which has all the math functions in the normal runtime library
# and doesn't have a separate math library.
AC_SUBST(SEQ_LIBM)
AC_SUBST([SEQ_LIBM])
ac_seq_body='
static double x, y;
x = floor (x);
x = rint (x);
x = modf (x, &y);'
AC_TRY_LINK([#include <math.h>], $ac_seq_body, ,
AC_TRY_LINK([#include <math.h>], [$ac_seq_body], ,
[ac_seq_save_LIBS="$LIBS"
LIBS="$LIBS -lm"
AC_TRY_LINK([#include <math.h>], $ac_seq_body, SEQ_LIBM=-lm)
AC_TRY_LINK([#include <math.h>], [$ac_seq_body], [SEQ_LIBM=-lm])
LIBS="$ac_seq_save_LIBS"
])
@@ -132,7 +133,7 @@ AC_DEFUN([gl_CHECK_ALL_HEADERS],
syslog.h \
termios.h \
)
AC_CHECK_HEADERS(sys/sysctl.h, [], [],
AC_CHECK_HEADERS([sys/sysctl.h], [], [],
[AC_INCLUDES_DEFAULT
[#if HAVE_SYS_PARAM_H
#include <sys/param.h>
@@ -153,7 +154,7 @@ AC_DEFUN([gl_CHECK_ALL_TYPES],
AC_REQUIRE([AM_C_PROTOTYPES])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_REQUIRE([AC_C_BIGENDIAN])
AC_REQUIRE([gl_BIGENDIAN])
AC_REQUIRE([AC_C_VOLATILE])
AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
@@ -173,12 +174,12 @@ AC_DEFUN([gl_CHECK_ALL_TYPES],
AC_REQUIRE([AC_TYPE_PID_T])
AC_REQUIRE([AC_TYPE_SIZE_T])
AC_REQUIRE([AC_TYPE_UID_T])
AC_CHECK_TYPE(ino_t, unsigned long int)
AC_CHECK_TYPE([ino_t], [unsigned long int])
dnl This relies on the fact that Autoconf's implementation of
dnl AC_CHECK_TYPE checks includes unistd.h.
AC_CHECK_TYPE(major_t, unsigned int)
AC_CHECK_TYPE(minor_t, unsigned int)
AC_CHECK_TYPE([major_t], [unsigned int])
AC_CHECK_TYPE([minor_t], [unsigned int])
AC_REQUIRE([AC_HEADER_MAJOR])
])

View File

@@ -1,9 +1,9 @@
#serial 10
#serial 11
dnl Misc lib-related macros for coreutils.
# Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2004,
# 2005, 2006 Free Software Foundation, Inc.
# Copyright (C) 1993-1997, 2000-2001, 2003-2006, 2008
# 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
@@ -24,20 +24,20 @@ AC_DEFUN([cu_LIB_CHECK],
[
# Check for libypsec.a on Dolphin M88K machines.
AC_CHECK_LIB(ypsec, main)
AC_CHECK_LIB([ypsec], [main])
# m88k running dgux 5.4 needs this
AC_CHECK_LIB(ldgc, main)
AC_CHECK_LIB([ldgc], [main])
# The -lsun library is required for YP support on Irix-4.0.5 systems.
# m88k/svr3 DolphinOS systems using YP need -lypsec for id.
AC_SEARCH_LIBS(yp_match, [sun ypsec])
AC_SEARCH_LIBS([yp_match], [sun ypsec])
# SysV needs -lsec, older versions of Linux need -lshadow for
# shadow passwords. UnixWare 7 needs -lgen.
AC_SEARCH_LIBS(getspnam, [shadow sec gen])
AC_SEARCH_LIBS([getspnam], [shadow sec gen])
AC_CHECK_HEADERS(shadow.h)
AC_CHECK_HEADERS([shadow.h])
# Requirements for su.c.
shadow_includes="\
@@ -47,14 +47,14 @@ $ac_includes_default
#endif
"
AC_CHECK_MEMBERS([struct spwd.sp_pwdp],,,[$shadow_includes])
AC_CHECK_FUNCS(getspnam)
AC_CHECK_FUNCS([getspnam])
# SCO-ODT-3.0 is reported to need -lufc for crypt.
# NetBSD needs -lcrypt for crypt.
cu_saved_libs="$LIBS"
AC_SEARCH_LIBS(crypt, [ufc crypt],
AC_SEARCH_LIBS([crypt], [ufc crypt],
[test "$ac_cv_search_crypt" = "none required" ||
LIB_CRYPT="$ac_cv_search_crypt"])
LIBS="$cu_saved_libs"
AC_SUBST(LIB_CRYPT)
AC_SUBST([LIB_CRYPT])
])

View File

@@ -1,4 +1,4 @@
#serial 75
#serial 76
dnl We use gl_ for non Autoconf macros.
m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
@@ -7,7 +7,7 @@ m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
# directory of the coreutils package.
# Copyright (C) 1998, 2000, 2001, 2003-2008 Free Software Foundation, Inc.
# Copyright (C) 1998, 2000, 2001, 2003-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
@@ -38,6 +38,7 @@ AC_DEFUN([gl_PREREQ],
# handles that; see ../bootstrap.conf.
AC_REQUIRE([gl_EUIDACCESS_STAT])
AC_REQUIRE([gl_FD_REOPEN])
AC_REQUIRE([gl_FUNC_XATTR])
AC_REQUIRE([gl_FUNC_XFTS])
AC_REQUIRE([gl_MEMXFRM])
AC_REQUIRE([gl_STRINTCMP])

View File

@@ -1,7 +1,7 @@
# stat-prog.m4 serial 5
# stat-prog.m4 serial 6
# Record the prerequisites of src/stat.c from the coreutils package.
# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
# Copyright (C) 2002-2004, 2006, 2008 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
@@ -68,7 +68,7 @@ AC_INCLUDES_DEFAULT
[$statvfs_includes],
[static statvfs s;
return (s.s_fsid ^ 0) == 0;])],
[AC_DEFINE([STRUCT_STATVFS_F_FSID_IS_INTEGER], 1,
[AC_DEFINE([STRUCT_STATVFS_F_FSID_IS_INTEGER], [1],
[Define to 1 if the f_fsid member of struct statvfs is an integer.])])
else
AC_CHECK_MEMBERS([struct statfs.f_namelen, struct statfs.f_type],,,
@@ -79,7 +79,7 @@ AC_INCLUDES_DEFAULT
[$statfs_includes],
[static statfs s;
return (s.s_fsid ^ 0) == 0;])],
[AC_DEFINE([STRUCT_STATFS_F_FSID_IS_INTEGER], 1,
[AC_DEFINE([STRUCT_STATFS_F_FSID_IS_INTEGER], [1],
[Define to 1 if the f_fsid member of struct statfs is an integer.])])
fi
fi

36
m4/xattr.m4 Normal file
View File

@@ -0,0 +1,36 @@
# xattr.m4 - check for Extended Attributes (Linux)
# Copyright (C) 2003, 2008-2009 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# Originally written by Andreas Gruenbacher.
# http://www.suse.de/~agruen/coreutils/5.91/coreutils-xattr.diff
AC_DEFUN([gl_FUNC_XATTR],
[
AC_ARG_ENABLE([xattr],
AC_HELP_STRING([--disable-xattr],
[do not support extended attributes]),
[use_xattr=$enableval], [use_xattr=yes])
if test "$use_xattr" = "yes"; then
AC_CHECK_HEADERS([attr/error_context.h attr/libattr.h])
if test $ac_cv_header_attr_libattr_h = yes \
&& test $ac_cv_header_attr_error_context_h = yes; then
use_xattr=1
else
use_xattr=0
fi
AC_DEFINE_UNQUOTED([USE_XATTR], [$use_xattr],
[Define if you want extended attribute support.])
xattr_saved_LIBS=$LIBS
AC_SEARCH_LIBS([attr_copy_file], [attr],
[test "$ac_cv_search_attr_copy_file" = "none required" ||
LIB_XATTR=$ac_cv_search_attr_copy_file])
AC_CHECK_FUNCS([attr_copy_file])
LIBS=$xattr_saved_LIBS
AC_SUBST([LIB_XATTR])
fi
])

413
maint.mk
View File

@@ -2,7 +2,7 @@
# This Makefile fragment tries to be general-purpose enough to be
# used by at least coreutils, idutils, CPPI, Bison, and Autoconf.
## Copyright (C) 2001-2008 Free Software Foundation, Inc.
## 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
@@ -62,24 +62,25 @@ release_archive_dir ?= ../release
# 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)/$(ME) $(srcdir)/cfg.mk)
.PHONY: $(syntax-check-rules)
local-checks-available = \
po-check copyright-check m4-check author_mark_check \
patch-check strftime-check $(syntax-check-rules) \
makefile_path_separator_check \
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)
@@ -94,6 +95,21 @@ syntax-check: $(local-check)
# 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) \
@@ -102,37 +118,35 @@ sc_avoid_if_before_free:
exit 1; } || :
sc_cast_of_argument_to_free:
@grep -nE '\<free *\( *\(' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
exit 1; } || :
@re='\<free *\( *\(' msg='don'\''t cast free argument' \
$(_prohibit_regexp)
sc_cast_of_x_alloc_return_value:
@grep -nE '\*\) *x(m|c|re)alloc\>' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
exit 1; } || :
@re='\*\) *x(m|c|re)alloc\>' \
msg='don'\''t cast x*alloc return value' \
$(_prohibit_regexp)
sc_cast_of_alloca_return_value:
@grep -nE '\*\) *alloca\>' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): don'\''t cast alloca return value' 1>&2; \
exit 1; } || :
@re='\*\) *alloca\>' msg='don'\''t cast alloca return value' \
$(_prohibit_regexp)
sc_space_tab:
@grep -n '[ ] ' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
1>&2; exit 1; } || :
@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:
@grep -nE '\<([fs]?scanf|ato([filq]|ll))\>' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): do not use *scan''f, ato''f, ato''i, ato''l, ato''ll, ato''q, or ss''canf' \
1>&2; exit 1; } || :
@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)) && \
$$($(VC_LIST_EXCEPT)) \
| grep -vE ':# *define STREQ\(' && \
{ echo '$(ME): use STREQ in place of the above uses of str''cmp' \
1>&2; exit 1; } || :
@@ -168,13 +182,12 @@ sc_error_message_period:
exit 1; } || :
sc_file_system:
@grep -ni 'file''system' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found use of "file''system";' \
'rewrite to use "file system"' 1>&2; \
exit 1; } || :
@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_no_have_config_h:
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; } || :
@@ -190,6 +203,25 @@ sc_require_config_h:
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.
@@ -251,11 +283,16 @@ sc_prohibit_root_dev_ino_without_use:
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)
sc_obsolete_symbols:
@grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
$$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
1>&2; exit 1; } || :
@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
@@ -265,105 +302,6 @@ sc_changelog:
{ echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
exit 1; } || :
# Ensure that dd's definition of LONGEST_SYMBOL stays in sync
# with the strings from the two affected variables.
dd_c = $(srcdir)/src/dd.c
sc_dd_max_sym_length:
ifneq ($(wildcard $(dd_c)),)
@len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
|sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
| wc --max-line-length); \
max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
|tr -d '"' | wc --max-line-length); \
if test "$$len" = "$$max"; then :; else \
echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
exit 1; \
fi
endif
# Many m4 macros names once began with `jm_'.
# On 2004-04-13, they were all changed to start with gl_ instead.
# Make sure that none are inadvertently reintroduced.
sc_prohibit_jm_in_m4:
@grep -nE 'jm_[A-Z]' \
$$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
{ echo '$(ME): do not use jm_ in m4 macro names' \
1>&2; exit 1; } || :
# Ensure that each root-requiring test is run via the "check-root" rule.
sc_root_tests:
@if test -d tests \
&& grep check-root tests/Makefile.am>/dev/null 2>&1; then \
t1=sc-root.expected; t2=sc-root.actual; \
grep -nl '^require_root_$$' \
$$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1; \
sed -n '/^root_tests =[ ]*\\$$/,/[^\]$$/p' \
$(srcdir)/tests/Makefile.am \
| sed 's/^ *//;/^root_tests =/d' \
| tr -s '\012\\' ' ' | fmt -1 | sort > $$t2; \
diff -u $$t1 $$t2 || diff=1; \
rm -f $$t1 $$t2; \
test "$$diff" \
&& { echo 'tests/Makefile.am: missing check-root action'>&2; \
exit 1; } || :; \
fi
headers_with_interesting_macro_defs = \
exit.h \
fcntl_.h \
fnmatch_.h \
intprops.h \
inttypes_.h \
lchown.h \
openat.h \
stat-macros.h \
stdint_.h
# Create a list of regular expressions matching the names
# of macros that are guaranteed by parts of gnulib to be defined.
.re-defmac:
@(cd $(srcdir)/lib; \
for f in $(headers_with_interesting_macro_defs); do \
test -f $$f && \
sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
done; \
) | sort -u \
| grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
| sed 's/^/^# *define /' \
> $@-t
@mv $@-t $@
# Don't define macros that we already get from gnulib header files.
sc_always_defined_macros: .re-defmac
@if test -f $(srcdir)/src/system.h; then \
trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
grep -f .re-defmac $$($(VC_LIST)) \
&& { echo '$(ME): define the above via some gnulib .h file' \
1>&2; exit 1; } || :; \
fi
# Create a list of regular expressions matching the names
# of files included from system.h. Exclude a couple.
.re-list:
@sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
| grep -Ev 'sys/(param|file)\.h' \
| sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
> $@-t
@mv $@-t $@
# Files in src/ should not include directly any of
# the headers already included via system.h.
sc_system_h_headers: .re-list
@if test -f $(srcdir)/src/system.h; then \
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
grep -nE -f .re-list \
$$($(VC_LIST) src | \
grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
&& { echo '$(ME): the above are already included via system.h'\
1>&2; exit 1; } || :; \
fi
# Ensure that each .c file containing a "main" function also
# calls set_program_name.
sc_program_name:
@@ -383,34 +321,24 @@ 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 \
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'; \
echo 1>&2 'Exit $$fail'; \
exit 1; } || :; \
fi
sc_sun_os_names:
@grep -nEi \
'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
$$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
exit 1; } || :
sc_the_the:
@grep -ni '\<the ''the\>' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found use of "the ''the";' 1>&2; \
exit 1; } || :
sc_tight_scope:
$(MAKE) -C src $@
@re='\<the ''the\>' \
ignore_case=1 msg='found use of "the ''the";' \
$(_prohibit_regexp)
sc_trailing_blank:
@grep -n '[ ]$$' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found trailing blank(s)' \
1>&2; exit 1; } || :
@re='[ ]$$' \
ignore_case=1 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:
@@ -420,7 +348,7 @@ 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"; \
echo "$(ME): an option and its description"; \
1>&2; exit 1; } || :
# Look for diagnostics that aren't marked for translation.
@@ -441,30 +369,30 @@ sc_useless_cpp_parens:
# Require the latest GPL.
sc_GPL_version:
@grep -n 'either ''version [^3]' $$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || :
@re='either ''version [^3]' msg='GPL vN, N!=3' \
$(_prohibit_regexp)
# Perl-based tests used to exec perl from a #!/bin/sh script.
# Now they all start with #!/usr/bin/perl and the portability
# infrastructure is in tests/Makefile.am. Make sure no old-style
# script sneaks back in.
sc_no_exec_perl_coreutils:
@if test -f $(srcdir)/tests/Coreutils.pm; then \
grep '^exec *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) && \
{ echo 1>&2 '$(ME): found anachronistic Perl-based tests'; \
exit 1; } || :; \
fi
cvs_keywords = \
Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
NEWS_hash = \
$$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
$(srcdir)/NEWS | md5sum -)
sc_prohibit_cvs_keyword:
@re='\$$($(cvs_keywords))\$$' \
msg='do not use CVS keyword expansion' \
$(_prohibit_regexp)
# 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
# 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.
@@ -486,10 +414,9 @@ sc_proper_name_utf8_requires_ICONV:
# Warn about "c0nst struct Foo const foo[]",
# but not about "char const *const foo" or "#define const const".
sc_redundant_const:
@grep -E '\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
$$($(VC_LIST_EXCEPT)) && \
{ echo 1>&2 '$(ME): redundant "const" in declarations'; \
exit 1; } || :
@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)) \
@@ -497,6 +424,17 @@ sc_const_long_option:
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 -)
# 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
@@ -529,21 +467,6 @@ patch-check:
test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \
test "$$msg" = ok
# Ensure that date's --help output stays in sync with the info
# documentation for GNU strftime. The only exception is %N,
# which date accepts but GNU strftime does not.
extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
strftime-check:
if test -f $(srcdir)/src/date.c; then \
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
{ echo N; \
info libc date calendar format | grep '^ `%.'\' \
| $(extract_char); } | sort > $@-info; \
diff -u $@-src $@-info || exit 1; \
rm -f $@-src $@-info; \
fi
check-AUTHORS:
$(MAKE) -C src $@
@@ -577,15 +500,21 @@ changelog-check:
exit 1; \
fi
m4-check:
@grep -n 'AC_DEFUN([^[]' m4/*.m4 \
&& { echo '$(ME): quote the first arg to AC_DEFUN' 1>&2; \
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-check:
@if test -f po/POTFILES.in; then \
grep -E -v '^(#|$$)' 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 \
@@ -602,18 +531,11 @@ po-check:
done; \
grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
| sort -u > $@-2; \
diff -u $@-1 $@-2 || exit 1; \
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
# In a definition of #define AUTHORS "... and ..." where the RHS contains
# the English word `and', the string must be marked with `N_ (...)' so that
# gettext recognizes it as a string requiring translation.
author_mark_check:
@grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
{ echo '$(ME): enclose the above strings in N_ (...)' 1>&2; \
exit 1; } || :
# 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@'.
@@ -621,7 +543,7 @@ author_mark_check:
# and there probably aren't many projects with so many Makefile.am files
# that we'd have to worry about limits on command line length.
msg = '$(ME): Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
makefile_path_separator_check:
sc_makefile_path_separator_check:
@grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
&& { echo $(msg) 1>&2; exit 1; } || :
@@ -642,24 +564,24 @@ 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.
copyright-check:
@if test -f $(v_etc_file); then \
sc_copyright_check:
@if test -f $(v_etc_file); then \
grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
>/dev/null \
>/dev/null \
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
exit 1; }; \
exit 1; }; \
fi
@if test -f $(sample-test); then \
grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
>/dev/null \
@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; }; \
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; }; \
@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:
@@ -737,12 +659,12 @@ taint-distcheck: $(DIST_ARCHIVES)
# Verify that a twisted use of --program-transform-name=PROGRAM works.
define install-transform-check
rm -rf $(pfx); \
$(MAKE) program_transform_name='s/.*/zyx/' \
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 "$$(echo $(pfx)/share/man/man1/*)" = \
"$(pfx)/share/man/man1/zyx.1"
&& test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
endef
# Install, then verify that all binaries and man pages are in place.
@@ -764,6 +686,34 @@ define my-instcheck
}
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 $(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.
@@ -789,22 +739,7 @@ my-distcheck: $(DIST_ARCHIVES) $(local-check)
&& $(MAKE) dvi \
&& $(install-transform-check) \
&& $(my-instcheck) \
&& 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 $(MAKE) -C tests check \
&& { test -d gnulib-tests \
&& $(MAKE) -C gnulib-tests check \
|| :; } \
&& rm -rf $(bin) \
&& $(coreutils-path-check) \
&& $(MAKE) distclean
(cd $(t) && mv $(distdir) $(distdir).old \
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz

View File

@@ -1,6 +1,6 @@
# Make coreutils man pages. -*-Makefile-*-
# Copyright (C) 2002-2008 Free Software Foundation, Inc.
# Copyright (C) 2002-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
@@ -132,6 +132,10 @@ who.1: $(common_dep) $(srcdir)/who.x ../src/who.c
whoami.1: $(common_dep) $(srcdir)/whoami.x ../src/whoami.c
yes.1: $(common_dep) $(srcdir)/yes.x ../src/yes.c
# This is required so that changes to e.g., emit_bug_reporting_address
# provoke regeneration of all $(MAN) files.
$(MAN): $(top_srcdir)/src/system.h
SUFFIXES = .x .1
# Ensure that help2man runs the ../src/ginstall binary as

View File

@@ -19,7 +19,7 @@ will match any files whose names end in
.BR .o .
Therefore, the command
.IP
.B du --exclude='*.o'
.B du --exclude=\(aq*.o\(aq
.PP
will skip all files and subdirectories ending in
.BR .o

View File

@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
# Generate a short man page from --help and --version output.
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009
# Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
@@ -368,7 +368,7 @@ s/^\./\x80/mg;
s/^'/\x81/mg;
s/\\/\x82/g;
my $PAT_BUGS = _('Report +bugs|Email +bug +reports +to');
my $PAT_BUGS = _('Report +(?:\w+ +)?bugs|Email +bug +reports +to');
my $PAT_AUTHOR = _('Written +by');
my $PAT_OPTIONS = _('Options');
my $PAT_EXAMPLES = _('Examples');
@@ -567,7 +567,7 @@ and
.B %s
programs are properly installed at your site, the command
.IP
.B info coreutils '%s invocation'
.B info coreutils \(aq%s invocation\(aq
.PP
should give you access to the complete manual.
EOT
@@ -607,6 +607,9 @@ for my $sect (@pre, (grep ! /^($filter)$/o, @include), @post)
# Convert some latin1 chars to troff equivalents
s/\xa0/\\ /g; # non-breaking space
$sect eq 'REPORTING BUGS'
and s/\n(.)/\n.br\n$1/g;
print;
}
}

View File

@@ -1,4 +1,4 @@
[NAME]
id \- print user identity
id \- print real and effective user and group IDs
[DESCRIPTION]
.\" Add any additional description here

View File

@@ -753,7 +753,7 @@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the ``GNU Free

View File

@@ -277,7 +277,7 @@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the ``GNU Free

View File

@@ -465,7 +465,7 @@ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2006 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the ``GNU Free

View File

@@ -1,5 +1,5 @@
# List of files which contain translatable strings.
# Copyright (C) 1996-2008 Free Software Foundation, Inc.
# Copyright (C) 1996-2009 Free Software Foundation, Inc.
# These are nominally temporary...
lib/argmatch.c
@@ -22,8 +22,10 @@ lib/rpmatch.c
lib/set-mode-acl.c
lib/unicodeio.c
lib/userspec.c
lib/verror.c
lib/version-etc.c
lib/xalloc-die.c
lib/xfreopen.c
lib/xfts.c
lib/xmemcoll.c
lib/xmemxfrm.c
@@ -61,6 +63,7 @@ src/factor.c
src/false.c
src/fmt.c
src/fold.c
src/getlimits.c
src/group-list.c
src/groups.c
src/head.c

1
src/.gitignore vendored
View File

@@ -31,6 +31,7 @@ false
fmt
fold
fs.h
getlimits
ginstall
groups
head

View File

@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-
## Copyright (C) 1990, 1991, 1993-2008 Free Software Foundation, Inc.
## Copyright (C) 1990, 1991, 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
@@ -26,6 +26,8 @@ no_install__progs = \
build_if_possible__progs = \
chroot df hostid nice pinky stty su uname uptime users who
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
EXTRA_PROGRAMS = \
$(no_install__progs) \
$(build_if_possible__progs) \
@@ -44,7 +46,7 @@ EXTRA_PROGRAMS = \
bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
noinst_PROGRAMS = setuidgid
noinst_PROGRAMS = setuidgid getlimits
noinst_HEADERS = \
chown-core.h \
@@ -82,6 +84,7 @@ LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
cat_LDADD = $(LDADD)
df_LDADD = $(LDADD)
du_LDADD = $(LDADD)
getlimits_LDADD = $(LDADD)
ptx_LDADD = $(LDADD)
split_LDADD = $(LDADD)
timeout_LDADD = $(LDADD)
@@ -149,9 +152,9 @@ su_LDADD = $(LDADD) $(LIB_CRYPT)
dir_LDADD += $(LIB_ACL)
ls_LDADD += $(LIB_ACL)
vdir_LDADD += $(LIB_ACL)
cp_LDADD += $(LIB_ACL)
mv_LDADD += $(LIB_ACL)
ginstall_LDADD += $(LIB_ACL)
cp_LDADD += $(LIB_ACL) $(LIB_XATTR)
mv_LDADD += $(LIB_ACL) $(LIB_XATTR)
ginstall_LDADD += $(LIB_ACL) $(LIB_XATTR)
stat_LDADD = $(LDADD) $(LIB_SELINUX)
@@ -160,11 +163,16 @@ cat_LDADD += $(LIBICONV)
cp_LDADD += $(LIBICONV)
df_LDADD += $(LIBICONV)
du_LDADD += $(LIBICONV)
getlimits_LDADD += $(LIBICONV)
ptx_LDADD += $(LIBICONV)
split_LDADD += $(LIBICONV)
timeout_LDADD += $(LIBICONV)
truncate_LDADD += $(LIBICONV)
# programs that use getaddrinfo (e.g., via canon_host)
pinky_LDADD = $(LDADD) $(GETADDRINFO_LIB)
who_LDADD = $(LDADD) $(GETADDRINFO_LIB)
$(PROGRAMS): ../lib/libcoreutils.a
# Get the release year from ../lib/version-etc.c.
@@ -351,7 +359,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-misc check-duplicate-no-install
check: check-README check-duplicate-no-install
.PHONY: check-README
check-README:
rm -rf $(pr) $(pm)
@@ -374,8 +382,8 @@ 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)$$,,' \
@rm -f $(au_actual) $(au_dotdot)
@for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
| $(ASSORT) -u`; do \
test "$$i" = '[' && continue; \
exe=$$i; \
@@ -384,24 +392,12 @@ check-AUTHORS: $(all_programs)
elif test "$$i" = test; then \
exe='['; \
fi; \
LC_ALL=en_US.UTF-8 ./$$exe --version \
LC_ALL=en_US.UTF-8 ./$$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)
# Make sure we don't define any S_IS* macros in src/*.c files.
# Not a big deal, but they're already defined via system.h.
#
# Also 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.
.PHONY: check-misc
check-misc:
cd $(srcdir); grep '^# *define *S_IS' $(SOURCES) && exit 1 || :
cd $(srcdir); grep st_blocks $(SOURCES) && exit 1 || :
cd $(srcdir); grep '^# *define .*defined' $(SOURCES) && exit 1 || :
@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/")*$$//

View File

@@ -48,7 +48,7 @@ static struct option const long_options[] =
{NULL, 0, NULL, 0}
};
static void
void
usage (int status)
{
if (status != EXIT_SUCCESS)

View File

@@ -39,6 +39,7 @@
#include "full-write.h"
#include "quote.h"
#include "safe-read.h"
#include "xfreopen.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "cat"
@@ -664,7 +665,7 @@ main (int argc, char **argv)
{
file_open_mode |= O_BINARY;
if (O_BINARY && ! isatty (STDOUT_FILENO))
freopen (NULL, "wb", stdout);
xfreopen (NULL, "wb", stdout);
}
/* Check if any of the input files are the same as the output file. */
@@ -684,7 +685,7 @@ main (int argc, char **argv)
have_read_stdin = true;
input_desc = STDIN_FILENO;
if ((file_open_mode & O_BINARY) && ! isatty (STDIN_FILENO))
freopen (NULL, "rb", stdin);
xfreopen (NULL, "rb", stdin);
}
else
{

View File

@@ -35,26 +35,6 @@
proper_name ("Russell Coker"), \
proper_name ("Jim Meyering")
enum Change_status
{
CH_NOT_APPLIED,
CH_SUCCEEDED,
CH_FAILED,
CH_NO_CHANGE_REQUESTED
};
enum Verbosity
{
/* Print a message for each file that is processed. */
V_high,
/* Print a message for each file whose attributes we change. */
V_changes_only,
/* Do not be verbose. This is the default. */
V_off
};
/* If nonzero, and the systems has support for it, change the context
of symbolic links rather than any files they point to. */
static bool affect_symlink_referent;
@@ -369,7 +349,6 @@ Usage: %s [OPTION]... CONTEXT FILE...\n\
Change the security context of each FILE to CONTEXT.\n\
With --reference, change the security context of each FILE to that of RFILE.\n\
\n\
-c, --changes like verbose but report only when a change is made\n\
-h, --no-dereference affect symbolic links instead of any referenced file\n\
"), stdout);
fputs (_("\
@@ -430,7 +409,7 @@ main (int argc, char **argv)
atexit (close_stdout);
while ((optc = getopt_long (argc, argv, "HLPRchvu:r:t:l:", long_options, NULL))
while ((optc = getopt_long (argc, argv, "HLPRhvu:r:t:l:", long_options, NULL))
!= -1)
{
switch (optc)

View File

@@ -1,5 +1,5 @@
/* chgrp -- change group ownership of files
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 89, 90, 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
@@ -302,6 +302,7 @@ main (int argc, char **argv)
quote ("/"));
}
bit_flags |= FTS_DEFER_STAT;
ok = chown_files (argv + optind, bit_flags,
(uid_t) -1, gid,
(uid_t) -1, (gid_t) -1, &chopt);

View File

@@ -1,5 +1,5 @@
/* chmod -- change permission modes of files
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 89, 90, 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
@@ -67,7 +67,7 @@ static mode_t umask_value;
/* If true, change the modes of directories recursively. */
static bool recurse;
/* If true, force silence (no error messages). */
/* If true, force silence (suppress most of error messages). */
static bool force_silent;
/* If true, diagnose surprises from naive misuses like "chmod -r file".
@@ -121,7 +121,7 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
if (stat (file, &new_stats) != 0)
{
if (!force_silent)
if (! force_silent)
error (0, errno, _("getting new attributes of %s"), quote (file));
return false;
}
@@ -203,24 +203,29 @@ process_file (FTS *fts, FTSENT *ent)
fts_set (fts, ent, FTS_AGAIN);
return true;
}
error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
if (! force_silent)
error (0, ent->fts_errno, _("cannot access %s"),
quote (file_full_name));
ok = false;
break;
case FTS_ERR:
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
if (! force_silent)
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
ok = false;
break;
case FTS_DNR:
error (0, ent->fts_errno, _("cannot read directory %s"),
quote (file_full_name));
if (! force_silent)
error (0, ent->fts_errno, _("cannot read directory %s"),
quote (file_full_name));
ok = false;
break;
case FTS_SLNONE:
error (0, 0, _("cannot operate on dangling symlink %s"),
quote (file_full_name));
if (! force_silent)
error (0, 0, _("cannot operate on dangling symlink %s"),
quote (file_full_name));
ok = false;
default:
@@ -319,7 +324,8 @@ process_files (char **files, int bit_flags)
if (errno != 0)
{
/* FIXME: try to give a better message */
error (0, errno, _("fts_read failed"));
if (! force_silent)
error (0, errno, _("fts_read failed"));
ok = false;
}
break;
@@ -528,7 +534,8 @@ main (int argc, char **argv)
root_dev_ino = NULL;
}
ok = process_files (argv + optind, FTS_COMFOLLOW | FTS_PHYSICAL);
ok = process_files (argv + optind,
FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT);
exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}

View File

@@ -296,18 +296,22 @@ change_file_owner (FTS *fts, FTSENT *ent,
fts_set (fts, ent, FTS_AGAIN);
return true;
}
error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
if (! chopt->force_silent)
error (0, ent->fts_errno, _("cannot access %s"),
quote (file_full_name));
ok = false;
break;
case FTS_ERR:
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
if (! chopt->force_silent)
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
ok = false;
break;
case FTS_DNR:
error (0, ent->fts_errno, _("cannot read directory %s"),
quote (file_full_name));
if (! chopt->force_silent)
error (0, ent->fts_errno, _("cannot read directory %s"),
quote (file_full_name));
ok = false;
break;
@@ -338,8 +342,9 @@ change_file_owner (FTS *fts, FTSENT *ent,
{
if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0)
{
error (0, errno, _("cannot dereference %s"),
quote (file_full_name));
if (! chopt->force_silent)
error (0, errno, _("cannot dereference %s"),
quote (file_full_name));
ok = false;
}
@@ -492,7 +497,8 @@ chown_files (char **files, int bit_flags,
if (errno != 0)
{
/* FIXME: try to give a better message */
error (0, errno, _("fts_read failed"));
if (! chopt->force_silent)
error (0, errno, _("fts_read failed"));
ok = false;
}
break;

View File

@@ -1,5 +1,5 @@
/* chown -- change user and group ownership of files
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 89, 90, 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
@@ -312,7 +312,7 @@ main (int argc, char **argv)
empty string so that diagnostics say "ownership :GROUP"
rather than "group GROUP". */
if (!chopt.user_name && chopt.group_name)
chopt.user_name = "";
chopt.user_name = bad_cast ("");
optind++;
}
@@ -326,6 +326,7 @@ main (int argc, char **argv)
quote ("/"));
}
bit_flags |= FTS_DEFER_STAT;
ok = chown_files (argv + optind, bit_flags,
uid, gid,
required_uid, required_gid, &chopt);

View File

@@ -1,5 +1,5 @@
/* chroot -- run command or shell with special root directory
Copyright (C) 95, 96, 1997, 1999-2004, 2007-2008
Copyright (C) 95, 96, 1997, 1999-2004, 2007-2009
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -83,7 +83,8 @@ main (int argc, char **argv)
}
if (chroot (argv[optind]) != 0)
error (EXIT_FAILURE, errno, _("cannot change root directory to %s"), argv[1]);
error (EXIT_FAILURE, errno, _("cannot change root directory to %s"),
argv[optind]);
if (chdir ("/"))
error (EXIT_FAILURE, errno, _("cannot chdir to root directory"));
@@ -93,9 +94,9 @@ main (int argc, char **argv)
/* No command. Run an interactive shell. */
char *shell = getenv ("SHELL");
if (shell == NULL)
shell = "/bin/sh";
shell = bad_cast ("/bin/sh");
argv[0] = shell;
argv[1] = "-i";
argv[1] = bad_cast ("-i");
argv[2] = NULL;
}
else

View File

@@ -43,6 +43,7 @@
#include <sys/types.h>
#include <stdint.h>
#include "system.h"
#include "xfreopen.h"
#ifdef CRCTAB
@@ -192,7 +193,7 @@ cksum (const char *file, bool print_name)
fp = stdin;
have_read_stdin = true;
if (O_BINARY && ! isatty (STDIN_FILENO))
freopen (NULL, "rb", stdin);
xfreopen (NULL, "rb", stdin);
}
else
{

View File

@@ -23,7 +23,6 @@
#include "system.h"
#include "linebuffer.h"
#include "error.h"
#include "hard-locale.h"
#include "quote.h"
#include "stdio--.h"
#include "xmemcoll.h"

View File

@@ -1,5 +1,5 @@
/* copy.c -- core functions for copying files and directories
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 89, 90, 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
@@ -35,7 +35,6 @@
#include "buffer-lcm.h"
#include "copy.h"
#include "cp-hash.h"
#include "euidaccess.h"
#include "error.h"
#include "fcntl--.h"
#include "file-set.h"
@@ -44,7 +43,7 @@
#include "full-write.h"
#include "hash.h"
#include "hash-triple.h"
#include "lchmod.h"
#include "ignore-value.h"
#include "quote.h"
#include "same.h"
#include "savedir.h"
@@ -55,6 +54,13 @@
#include "areadlink.h"
#include "yesno.h"
#if USE_XATTR
# include <attr/error_context.h>
# include <attr/libattr.h>
# include <stdarg.h>
# include "verror.h"
#endif
#ifndef HAVE_FCHOWN
# define HAVE_FCHOWN false
# define fchown(fd, uid, gid) (-1)
@@ -124,6 +130,72 @@ is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
return false;
}
#if USE_XATTR
static void
copy_attr_error (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);
va_end (ap);
}
static char const *
copy_attr_quote (struct error_context *ctx ATTRIBUTE_UNUSED, char const *str)
{
return quote (str);
}
static void
copy_attr_free (struct error_context *ctx ATTRIBUTE_UNUSED,
char const *str ATTRIBUTE_UNUSED)
{
}
static bool
copy_attr_by_fd (char const *src_path, int src_fd,
char const *dst_path, int dst_fd)
{
struct error_context ctx =
{
.error = 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, &ctx);
}
static bool
copy_attr_by_name (char const *src_path, char const *dst_path)
{
struct error_context ctx =
{
.error = copy_attr_error,
.quote = copy_attr_quote,
.quote_free = copy_attr_free
};
return 0 == attr_copy_file (src_path, dst_path, 0, &ctx);
}
#else /* USE_XATTR */
static bool
copy_attr_by_fd (char const *src_path, int src_fd,
char const *dst_path, int dst_fd)
{
return true;
}
static bool
copy_attr_by_name (char const *src_path, char const *dst_path)
{
return true;
}
#endif /* USE_XATTR */
/* Read the contents of the directory SRC_NAME_IN, and recursively
copy the contents to DST_NAME_IN. NEW_DST is true if
DST_NAME_IN is a directory that was created previously in the
@@ -203,7 +275,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
group. Avoid the window by first changing to a restrictive
temporary mode if necessary. */
if (!new_dst & (x->preserve_mode | x->move_mode | x->set_mode))
if (!new_dst && (x->preserve_mode | x->move_mode | x->set_mode))
{
mode_t old_mode = dst_sb->st_mode;
mode_t new_mode =
@@ -230,7 +302,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
/* We've failed to set *both*. Now, try to set just the group
ID, but ignore any failure here, and don't change errno. */
int saved_errno = errno;
(void) fchown (dest_desc, -1, gid);
ignore_value (fchown (dest_desc, -1, gid));
errno = saved_errno;
}
}
@@ -243,7 +315,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
/* We've failed to set *both*. Now, try to set just the group
ID, but ignore any failure here, and don't change errno. */
int saved_errno = errno;
(void) lchown (dst_name, -1, gid);
ignore_value (lchown (dst_name, -1, gid));
errno = saved_errno;
}
}
@@ -378,7 +450,8 @@ copy_reg (char const *src_name, char const *dst_name,
security_context_t con = NULL;
if (getfscreatecon (&con) < 0)
{
error (0, errno, _("failed to get file system create context"));
if (!x->reduce_diagnostics)
error (0, errno, _("failed to get file system create context"));
if (x->require_preserve_context)
{
return_val = false;
@@ -390,9 +463,10 @@ copy_reg (char const *src_name, char const *dst_name,
{
if (fsetfilecon (dest_desc, con) < 0)
{
error (0, errno,
_("failed to set the security context of %s to %s"),
quote_n (0, dst_name), quote_n (1, con));
if (!x->reduce_diagnostics)
error (0, errno,
_("failed to set the security context of %s to %s"),
quote_n (0, dst_name), quote_n (1, con));
if (x->require_preserve_context)
{
return_val = false;
@@ -400,7 +474,7 @@ copy_reg (char const *src_name, char const *dst_name,
goto close_src_and_dst_desc;
}
}
freecon(con);
freecon (con);
}
}
@@ -423,7 +497,7 @@ copy_reg (char const *src_name, char const *dst_name,
if (*new_dst)
{
int open_flags = O_WRONLY | O_CREAT | O_BINARY;
dest_desc = open (dst_name, open_flags | O_EXCL ,
dest_desc = open (dst_name, open_flags | O_EXCL,
dst_mode & ~omitted_permissions);
dest_errno = errno;
@@ -682,6 +756,11 @@ copy_reg (char const *src_name, char const *dst_name,
set_author (dst_name, dest_desc, src_sb);
if (x->preserve_xattr && ! copy_attr_by_fd (src_name, source_desc,
dst_name, dest_desc)
&& x->require_preserve_xattr)
return false;
if (x->preserve_mode || x->move_mode)
{
if (copy_acl (src_name, source_desc, dst_name, dest_desc, src_mode) != 0
@@ -1412,6 +1491,10 @@ copy_internal (char const *src_name, char const *dst_name,
we can arrange to create a hard link between the corresponding names
in the destination tree.
When using the --link (-l) option, there is no need to take special
measures, because (barring race conditions) files that are hard-linked
in the source tree will also be hard-linked in the destination tree.
Sometimes, when preserving links, we have to record dev/ino even
though st_nlink == 1:
- when in move_mode, since we may be moving a group of N hard-linked
@@ -1430,27 +1513,29 @@ copy_internal (char const *src_name, char const *dst_name,
- likewise for -L except that it applies to all files, not just
command line arguments.
Also record directory dev/ino when using --recursive. We'll use that
info to detect this problem: cp -R dir dir. FIXME-maybe: ideally,
directory info would be recorded in a separate hash table, since
such entries are useful only while a single command line hierarchy
is being copied -- so that separate table could be cleared between
command line args. Using the same hash table to preserve hard
links means that it may not be cleared. */
Also, with --recursive, record dev/ino of each command-line directory.
We'll use that info to detect this problem: cp -R dir dir. */
if (x->move_mode && src_sb.st_nlink == 1)
{
earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev);
}
else if ((x->preserve_links
&& (1 < src_sb.st_nlink
|| (command_line_arg
&& x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
|| x->dereference == DEREF_ALWAYS))
|| (x->recursive && S_ISDIR (src_mode)))
else if (x->preserve_links
&& !x->hard_link
&& (1 < src_sb.st_nlink
|| (command_line_arg
&& x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
|| x->dereference == DEREF_ALWAYS))
{
earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev);
}
else if (x->recursive && S_ISDIR (src_mode))
{
if (command_line_arg)
earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev);
else
earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev);
}
/* Did we copy this inode somewhere else (in this command line argument)
and therefore this is a second hard link to the inode? */
@@ -1638,9 +1723,10 @@ copy_internal (char const *src_name, char const *dst_name,
{
if (setfscreatecon (con) < 0)
{
error (0, errno,
_("failed to set default file creation context to %s"),
quote (con));
if (!x->reduce_diagnostics)
error (0, errno,
_("failed to set default file creation context to %s"),
quote (con));
if (x->require_preserve_context)
{
freecon (con);
@@ -1653,9 +1739,10 @@ copy_internal (char const *src_name, char const *dst_name,
{
if (errno != ENOTSUP && errno != ENODATA)
{
error (0, errno,
_("failed to get security context of %s"),
quote (src_name));
if (!x->reduce_diagnostics)
error (0, errno,
_("failed to get security context of %s"),
quote (src_name));
if (x->require_preserve_context)
return false;
}
@@ -1731,8 +1818,8 @@ copy_internal (char const *src_name, char const *dst_name,
/* Insert the created directory's inode and device
numbers into the search structure, so that we can
avoid copying it again. */
remember_copied (dst_name, dst_sb.st_ino, dst_sb.st_dev);
if (!x->hard_link)
remember_copied (dst_name, dst_sb.st_ino, dst_sb.st_dev);
if (x->verbose)
emit_verbose (src_name, dst_name, NULL);
@@ -1980,6 +2067,10 @@ copy_internal (char const *src_name, char const *dst_name,
set_author (dst_name, -1, &src_sb);
if (x->preserve_xattr && ! copy_attr_by_name (src_name, dst_name)
&& x->require_preserve_xattr)
return false;
if (x->preserve_mode || x->move_mode)
{
if (copy_acl (src_name, -1, dst_name, -1, src_mode) != 0

View File

@@ -1,5 +1,5 @@
/* core functions for copying files and directories
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 89, 90, 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
@@ -21,7 +21,6 @@
# include <stdbool.h>
# include "hash.h"
# include "lstat.h"
/* Control creation of sparse files (files with holes). */
enum Sparse_type
@@ -174,6 +173,25 @@ struct cp_options
fail if it is unable to do so. */
bool require_preserve_context;
/* If true, attempt to preserve extended attributes using libattr.
Ignored if coreutils are compiled without xattr support. */
bool preserve_xattr;
/* Useful only when preserve_xattr is true.
If true, a failed attempt to preserve file's extended attributes
propagates failure "out" to the caller. If false, a failure to
preserve file's extended attributes does not change the invoking
application's exit status. Give diagnostics for failed syscalls
regardless of this setting. For example, with "cp --preserve=xattr"
this flag is "true", while with "cp --preserve=all", it is false. */
bool require_preserve_xattr;
/* Used as difference boolean between cp -a and cp -dR --preserve=all.
If true, non-mandatory failure diagnostics are not displayed. This
should prevent poluting cp -a output.
*/
bool reduce_diagnostics;
/* If true, copy directories recursively and copy special files
as themselves rather than copying their contents. */
bool recursive;

View File

@@ -19,14 +19,11 @@
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include "system.h"
#include "same.h"
#include "quote.h"
#include "hash.h"
#include "error.h"
#include "cp-hash.h"
/* Use ST_DEV and ST_INO as the key, FILENAME as the value.
@@ -97,24 +94,6 @@ forget_created (ino_t ino, dev_t dev)
src_to_dest_free (ent);
}
/* Add FILE to the list of files that we have created.
Return true if successful. */
extern bool
remember_created (char const *file)
{
struct stat sb;
if (stat (file, &sb) < 0)
{
error (0, errno, "%s", quote (file));
return false;
}
remember_copied (file, sb.st_ino, sb.st_dev);
return true;
}
/* If INO/DEV correspond to an already-copied source file, return the
name of the corresponding destination file. Otherwise, return NULL. */

View File

@@ -2,5 +2,4 @@ void hash_init (void);
void forget_all (void);
void forget_created (ino_t ino, dev_t dev);
char *remember_copied (const char *node, ino_t ino, dev_t dev);
bool remember_created (char const *file);
char *src_to_dest_lookup (ino_t ino, dev_t dev);

View File

@@ -1,5 +1,5 @@
/* cp.c -- file copying (main routines)
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 89, 90, 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
@@ -29,7 +29,7 @@
#include "cp-hash.h"
#include "error.h"
#include "filenamecat.h"
#include "lchmod.h"
#include "ignore-value.h"
#include "quote.h"
#include "stat-time.h"
#include "utimens.h"
@@ -76,7 +76,6 @@ enum
NO_PRESERVE_ATTRIBUTES_OPTION,
PARENTS_OPTION,
PRESERVE_ATTRIBUTES_OPTION,
REPLY_OPTION,
SPARSE_OPTION,
STRIP_TRAILING_SLASHES_OPTION,
UNLINK_DEST_BEFORE_OPENING
@@ -108,18 +107,6 @@ static enum Sparse_type const sparse_type[] =
};
ARGMATCH_VERIFY (sparse_type_string, sparse_type);
/* Valid arguments to the `--reply' option. */
static char const* const reply_args[] =
{
"yes", "no", "query", NULL
};
/* The values that correspond to the above strings. */
static int const reply_vals[] =
{
I_ALWAYS_YES, I_ALWAYS_NO, I_ASK_USER
};
ARGMATCH_VERIFY (reply_args, reply_vals);
static struct option const long_opts[] =
{
{"archive", no_argument, NULL, 'a'},
@@ -129,6 +116,7 @@ static struct option const long_opts[] =
{"force", no_argument, NULL, 'f'},
{"interactive", no_argument, NULL, 'i'},
{"link", no_argument, NULL, 'l'},
{"no-clobber", no_argument, NULL, 'n'},
{"no-dereference", no_argument, NULL, 'P'},
{"no-preserve", required_argument, NULL, NO_PRESERVE_ATTRIBUTES_OPTION},
{"no-target-directory", no_argument, NULL, 'T'},
@@ -138,8 +126,6 @@ static struct option const long_opts[] =
{"preserve", optional_argument, NULL, PRESERVE_ATTRIBUTES_OPTION},
{"recursive", no_argument, NULL, 'R'},
{"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING},
{"reply", required_argument, NULL, REPLY_OPTION}, /* Deprecated 2005-07-03,
remove in 2008. */
{"sparse", required_argument, NULL, SPARSE_OPTION},
{"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION},
{"suffix", required_argument, NULL, 'S'},
@@ -174,7 +160,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
-a, --archive same as -dpR\n\
-a, --archive same as -dR --preserve=all\n\
--backup[=CONTROL] make a backup of each existing destination file\n\
-b like --backup but does not accept an argument\n\
--copy-contents copy contents of special files when recursive\n\
@@ -182,8 +168,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
-f, --force if an existing destination file cannot be\n\
opened, remove it and try again\n\
-i, --interactive prompt before overwrite\n\
opened, remove it and try again (redundant if\n\
the -n option is used)\n\
-i, --interactive prompt before overwrite (overrides a previous -n\n\
option)\n\
-H follow command-line symbolic links in SOURCE\n\
"), stdout);
fputs (_("\
@@ -191,13 +179,16 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-L, --dereference always follow symbolic links in SOURCE\n\
"), stdout);
fputs (_("\
-n, --no-clobber do not overwrite an existing file (overrides\n\
a previous -i option)\n\
-P, --no-dereference never follow symbolic links in SOURCE\n\
"), stdout);
fputs (_("\
-p same as --preserve=mode,ownership,timestamps\n\
--preserve[=ATTR_LIST] preserve the specified attributes (default:\n\
mode,ownership,timestamps), if possible\n\
additional attributes: context, links, all\n\
additional attributes: context, links, xattr,\n\
all\n\
"), stdout);
fputs (_("\
--no-preserve=ATTR_LIST don't preserve the specified attributes\n\
@@ -326,7 +317,7 @@ re_protect (char const *const_dst_name, size_t src_offset,
}
/* Failing to preserve ownership is OK. Still, try to preserve
the group, but ignore the possible error. */
(void) lchown (dst_name, -1, p->st.st_gid);
ignore_value (lchown (dst_name, -1, p->st.st_gid));
}
}
@@ -774,6 +765,9 @@ cp_option_init (struct cp_options *x)
x->preserve_timestamps = false;
x->preserve_security_context = false;
x->require_preserve_context = false;
x->preserve_xattr = false;
x->reduce_diagnostics = false;
x->require_preserve_xattr = false;
x->require_preserve = false;
x->recursive = false;
@@ -810,18 +804,20 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off)
PRESERVE_OWNERSHIP,
PRESERVE_LINK,
PRESERVE_CONTEXT,
PRESERVE_XATTR,
PRESERVE_ALL
};
static enum File_attribute const preserve_vals[] =
{
PRESERVE_MODE, PRESERVE_TIMESTAMPS,
PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_ALL
PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_XATTR,
PRESERVE_ALL
};
/* Valid arguments to the `--preserve' option. */
static char const* const preserve_args[] =
{
"mode", "timestamps",
"ownership", "links", "context", "all", NULL
"ownership", "links", "context", "xattr", "all", NULL
};
ARGMATCH_VERIFY (preserve_args, preserve_vals);
@@ -862,6 +858,11 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off)
x->require_preserve_context = on_off;
break;
case PRESERVE_XATTR:
x->preserve_xattr = on_off;
x->require_preserve_xattr = on_off;
break;
case PRESERVE_ALL:
x->preserve_mode = on_off;
x->preserve_timestamps = on_off;
@@ -869,6 +870,7 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off)
x->preserve_links = on_off;
if (selinux_enabled)
x->preserve_security_context = on_off;
x->preserve_xattr = on_off;
break;
default:
@@ -909,7 +911,7 @@ main (int argc, char **argv)
we'll actually use backup_suffix_string. */
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
while ((c = getopt_long (argc, argv, "abdfHilLprst:uvxPRS:T",
while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:T",
long_opts, NULL))
!= -1)
{
@@ -920,13 +922,16 @@ main (int argc, char **argv)
sparse_type_string, sparse_type);
break;
case 'a': /* Like -dpR. */
case 'a': /* Like -dR --preserve=all with reduced failure diagnostics. */
x.dereference = DEREF_NEVER;
x.preserve_links = true;
x.preserve_ownership = true;
x.preserve_mode = true;
x.preserve_timestamps = true;
x.require_preserve = true;
if (selinux_enabled)
x.preserve_security_context = true;
x.reduce_diagnostics = true;
x.recursive = true;
break;
@@ -965,6 +970,10 @@ main (int argc, char **argv)
x.dereference = DEREF_ALWAYS;
break;
case 'n':
x.interactive = I_ALWAYS_NO;
break;
case 'P':
x.dereference = DEREF_NEVER;
break;
@@ -1001,13 +1010,6 @@ main (int argc, char **argv)
x.recursive = true;
break;
case REPLY_OPTION: /* Deprecated */
x.interactive = XARGMATCH ("--reply", optarg,
reply_args, reply_vals);
error (0, 0,
_("the --reply option is deprecated; use -i or -f instead"));
break;
case UNLINK_DEST_BEFORE_OPENING:
x.unlink_dest_before_opening = true;
break;
@@ -1072,6 +1074,13 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
if (make_backups && x.interactive == I_ALWAYS_NO)
{
error (0, 0,
_("options --backup and --no-clobber are mutually exclusive"));
usage (EXIT_FAILURE);
}
if (backup_suffix_string)
simple_backup_suffix = xstrdup (backup_suffix_string);
@@ -1105,6 +1114,12 @@ main (int argc, char **argv)
"without an SELinux-enabled kernel"));
}
#if !USE_XATTR
if (x.require_preserve_xattr)
error (EXIT_FAILURE, 0, _("cannot preserve extended attributes, cp is "
"built without xattr support"));
#endif
/* Allocate space for remembering copied and created files. */
hash_init ();

View File

@@ -34,17 +34,6 @@
#include "stdio--.h"
#include "xstrtol.h"
/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
present. */
#ifndef SA_NOCLDSTOP
# define SA_NOCLDSTOP 0
# define sigprocmask(How, Set, Oset) /* empty */
# define sigset_t int
# if ! HAVE_SIGINTERRUPT
# define siginterrupt(sig, flag) /* empty */
# endif
#endif
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "csplit"
@@ -238,12 +227,10 @@ xalloc_die (void)
static void
interrupt_handler (int sig)
{
if (! SA_NOCLDSTOP)
signal (sig, SIG_IGN);
delete_all_files (true);
signal (sig, SIG_DFL);
/* The signal has been reset to SIG_DFL, but blocked during this
handler. Force the default action of this signal once the
handler returns and the block is removed. */
raise (sig);
}
@@ -1421,7 +1408,6 @@ main (int argc, char **argv)
};
enum { nsigs = sizeof sig / sizeof sig[0] };
#if SA_NOCLDSTOP
struct sigaction act;
sigemptyset (&caught_signals);
@@ -1434,19 +1420,11 @@ main (int argc, char **argv)
act.sa_handler = interrupt_handler;
act.sa_mask = caught_signals;
act.sa_flags = 0;
act.sa_flags = SA_NODEFER | SA_RESETHAND;
for (i = 0; i < nsigs; i++)
if (sigismember (&caught_signals, sig[i]))
sigaction (sig[i], &act, NULL);
#else
for (i = 0; i < nsigs; i++)
if (signal (sig[i], SIG_IGN) != SIG_IGN)
{
signal (sig[i], interrupt_handler);
siginterrupt (sig[i], 1);
}
#endif
}
split_file ();

View File

@@ -38,8 +38,6 @@
#define AUTHORS proper_name ("David MacKenzie")
int putenv ();
static bool show_date (const char *format, struct timespec when);
enum Time_spec
@@ -385,7 +383,7 @@ main (int argc, char **argv)
/* POSIX says that `date -u' is equivalent to setting the TZ
environment variable, so this option should do nothing other
than setting TZ. */
if (putenv ("TZ=UTC0") != 0)
if (putenv (bad_cast ("TZ=UTC0")) != 0)
xalloc_die ();
TZSET;
break;

111
src/dd.c
View File

@@ -1,5 +1,5 @@
/* dd -- convert a file while copying it.
Copyright (C) 85, 90, 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 85, 90, 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
@@ -66,6 +66,12 @@ static void process_signals (void);
# define SIGINFO SIGUSR1
#endif
/* This may belong in GNULIB's fcntl module instead.
Define O_CIO to 0 if it is not supported by this OS. */
#ifndef O_CIO
# define O_CIO 0
#endif
#if ! HAVE_FDATASYNC
# define fdatasync(fd) (errno = ENOSYS, -1)
#endif
@@ -194,8 +200,7 @@ static bool input_seekable;
static int input_seek_errno;
/* File offset of the input, in bytes, along with a flag recording
whether it overflowed. The offset is valid only if the input is
seekable and if the offset has not overflowed. */
whether it overflowed. */
static uintmax_t input_offset;
static bool input_offset_overflow;
@@ -264,6 +269,7 @@ enum
/* Use a value that is larger than that of any other O_ symbol. */
O_FULLBLOCK = ((MAX (O_APPEND,
MAX (O_BINARY,
MAX (O_CIO,
MAX (O_DIRECT,
MAX (O_DIRECTORY,
MAX (O_DSYNC,
@@ -272,7 +278,8 @@ enum
MAX (O_NOFOLLOW,
MAX (O_NOLINKS,
MAX (O_NONBLOCK,
MAX (O_SYNC, O_TEXT)))))))))))) << 1)
MAX (O_SYNC,
MAX (O_TEXT, 0)))))))))))))) << 1)
};
/* Ensure that we didn't shift it off the end. */
@@ -288,6 +295,7 @@ static struct symbol_value const flags[] =
{
{"append", O_APPEND},
{"binary", O_BINARY},
{"cio", O_CIO},
{"direct", O_DIRECT},
{"directory", O_DIRECTORY},
{"dsync", O_DSYNC},
@@ -455,16 +463,16 @@ Usage: %s [OPERAND]...\n\
fputs (_("\
Copy a file, converting and formatting according to the operands.\n\
\n\
bs=BYTES force ibs=BYTES and obs=BYTES\n\
bs=BYTES read and write BYTES bytes at a time (also see ibs=,obs=)\n\
cbs=BYTES convert BYTES bytes at a time\n\
conv=CONVS convert the file as per the comma separated symbol list\n\
count=BLOCKS copy only BLOCKS input blocks\n\
ibs=BYTES read BYTES bytes at a time\n\
ibs=BYTES read BYTES bytes at a time (default: 512)\n\
"), stdout);
fputs (_("\
if=FILE read from FILE instead of stdin\n\
iflag=FLAGS read as per the comma separated symbol list\n\
obs=BYTES write BYTES bytes at a time\n\
obs=BYTES write BYTES bytes at a time (default: 512)\n\
of=FILE write to FILE instead of stdout\n\
oflag=FLAGS write as per the comma separated symbol list\n\
seek=BLOCKS skip BLOCKS obs-sized blocks at start of output\n\
@@ -508,6 +516,8 @@ Each FLAG symbol may be:\n\
\n\
append append mode (makes sense only for output; conv=notrunc suggested)\n\
"), stdout);
if (O_CIO)
fputs (_(" cio use concurrent I/O for data\n"), stdout);
if (O_DIRECT)
fputs (_(" direct use direct I/O for data\n"), stdout);
if (O_DIRECTORY)
@@ -998,13 +1008,11 @@ scanargs (int argc, char *const *argv)
{
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP));
input_blocksize = n;
conversions_mask |= C_TWOBUFS;
}
else if (operand_is (name, "obs"))
{
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (OUTPUT_BLOCK_SLOP));
output_blocksize = n;
conversions_mask |= C_TWOBUFS;
}
else if (operand_is (name, "bs"))
{
@@ -1035,12 +1043,13 @@ scanargs (int argc, char *const *argv)
if (blocksize)
input_blocksize = output_blocksize = blocksize;
else
{
/* POSIX says dd aggregates short reads into
output_blocksize if bs= is not specified. */
conversions_mask |= C_TWOBUFS;
}
/* If bs= was given, both `input_blocksize' and `output_blocksize' will
have been set to positive values. If either has not been set,
bs= was not given, so make sure two buffers are used. */
if (input_blocksize == 0 || output_blocksize == 0)
conversions_mask |= C_TWOBUFS;
if (input_blocksize == 0)
input_blocksize = DEFAULT_BLOCKSIZE;
if (output_blocksize == 0)
@@ -1249,12 +1258,62 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize,
&& 0 <= skip_via_lseek (file, fdesc, offset, SEEK_CUR))
{
if (fdesc == STDIN_FILENO)
advance_input_offset (offset);
return 0;
{
struct stat st;
if (fstat (STDIN_FILENO, &st) != 0)
error (EXIT_FAILURE, errno, _("cannot fstat %s"), quote (file));
if (S_ISREG (st.st_mode) && st.st_size < (input_offset + offset))
{
/* When skipping past EOF, return the number of _full_ blocks
* that are not skipped, and set offset to EOF, so the caller
* can determine the requested skip was not satisfied. */
records = ( offset - st.st_size ) / blocksize;
offset = st.st_size - input_offset;
}
else
records = 0;
advance_input_offset (offset);
}
else
records = 0;
return records;
}
else
{
int lseek_errno = errno;
off_t soffset;
/* The seek request may have failed above if it was too big
(> device size, > max file size, etc.)
Or it may not have been done at all (> OFF_T_MAX).
Therefore try to seek to the end of the file,
to avoid redundant reading. */
if ((soffset = skip_via_lseek (file, fdesc, 0, SEEK_END)) >= 0)
{
/* File is seekable, and we're at the end of it, and
size <= OFF_T_MAX. So there's no point using read to advance. */
if (!lseek_errno)
{
/* The original seek was not attempted as offset > OFF_T_MAX.
We should error for write as can't get to the desired
location, even if OFF_T_MAX < max file size.
For read we're not going to read any data anyway,
so we should error for consistency.
It would be nice to not error for /dev/{zero,null}
for any offset, but that's not a significant issue. */
lseek_errno = EOVERFLOW;
}
if (fdesc == STDIN_FILENO)
error (0, lseek_errno, _("%s: cannot skip"), quote (file));
else
error (0, lseek_errno, _("%s: cannot seek"), quote (file));
/* If the file has a specific size and we've asked
to skip/seek beyond the max allowable, then quit. */
quit (EXIT_FAILURE);
}
/* else file_size && offset > OFF_T_MAX or file ! seekable */
do
{
@@ -1527,10 +1586,22 @@ dd_copy (void)
if (skip_records != 0)
{
skip (STDIN_FILENO, input_file, skip_records, input_blocksize, ibuf);
uintmax_t us_bytes = input_offset + (skip_records * input_blocksize);
uintmax_t us_blocks = skip (STDIN_FILENO, input_file,
skip_records, input_blocksize, ibuf);
us_bytes -= input_offset;
/* POSIX doesn't say what to do when dd detects it has been
asked to skip past EOF, so I assume it's non-fatal if the
call to 'skip' returns nonzero. FIXME: maybe give a warning. */
asked to skip past EOF, so I assume it's non-fatal.
There are 3 reasons why there might be unskipped blocks/bytes:
1. file is too small
2. pipe has not enough data
3. short reads */
if (us_blocks || (!input_offset_overflow && us_bytes))
{
error (0, 0,
_("%s: cannot skip to specified offset"), quote (input_file));
}
}
if (seek_records != 0)
@@ -1768,7 +1839,7 @@ main (int argc, char **argv)
offset = lseek (STDIN_FILENO, 0, SEEK_CUR);
input_seekable = (0 <= offset);
input_offset = offset;
input_offset = MAX(0, offset);
input_seek_errno = errno;
if (output_file == NULL)

View File

@@ -63,14 +63,15 @@ static const char *const slack_codes[] =
"SYMLINK", "ORPHAN", "MISSING", "FIFO", "PIPE", "SOCK", "BLK", "BLOCK",
"CHR", "CHAR", "DOOR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE",
"END", "ENDCODE", "SUID", "SETUID", "SGID", "SETGID", "STICKY",
"OTHER_WRITABLE", "OWR", "STICKY_OTHER_WRITABLE", "OWT", "CAPABILITY", NULL
"OTHER_WRITABLE", "OWR", "STICKY_OTHER_WRITABLE", "OWT", "CAPABILITY",
"HARDLINK", "CLRTOEOL", NULL
};
static const char *const ls_codes[] =
{
"no", "no", "fi", "rs", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi",
"so", "bd", "bd", "cd", "cd", "do", "ex", "lc", "lc", "rc", "rc", "ec", "ec",
"su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", "ca", NULL
"su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", "ca", "hl", "cl", NULL
};
#define array_len(Array) (sizeof (Array) / sizeof *(Array))
verify (array_len (slack_codes) == array_len (ls_codes));

View File

@@ -69,6 +69,7 @@ RESET 0 # reset to "normal" color
DIR 01;34 # directory
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
HARDLINK 44;37 # regular file with more than one link
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door

172
src/du.c
View File

@@ -1,5 +1,5 @@
/* du -- summarize disk usage
Copyright (C) 1988-1991, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 1988-1991, 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
@@ -30,6 +30,7 @@
#include <assert.h>
#include "system.h"
#include "argmatch.h"
#include "argv-iter.h"
#include "error.h"
#include "exclude.h"
#include "fprintftime.h"
@@ -37,7 +38,6 @@
#include "human.h"
#include "quote.h"
#include "quotearg.h"
#include "readtokens0.h"
#include "same.h"
#include "stat-time.h"
#include "xfts.h"
@@ -292,9 +292,9 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
--files0-from=F summarize disk usage of the NUL-terminated file\n\
names specified in file F\n\
-H like --si, but also evokes a warning; will soon\n\
change to be equivalent to --dereference-args (-D)\n\
names specified in file F;\n\
If F is - then read names from standard input\n\
-H equivalent to --dereference-args (-D)\n\
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
--si like -h, but use powers of 1000 not 1024\n\
"), stdout);
@@ -648,9 +648,6 @@ du_files (char **files, int bit_flags)
fts_close (fts);
}
if (print_grand_total)
print_size (&tot_dui, _("total"));
return ok;
}
@@ -659,13 +656,11 @@ main (int argc, char **argv)
{
char *cwd_only[2];
bool max_depth_specified = false;
char **files;
bool ok = true;
char *files_from = NULL;
struct Tokens tok;
/* Bit flags that control how fts works. */
int bit_flags = FTS_TIGHT_CYCLE_CHECK;
int bit_flags = FTS_TIGHT_CYCLE_CHECK | FTS_DEFER_STAT;
/* Select one of the three FTS_ options that control if/when
to follow a symlink. */
@@ -674,7 +669,7 @@ main (int argc, char **argv)
/* If true, display only a total for each argument. */
bool opt_summarize_only = false;
cwd_only[0] = ".";
cwd_only[0] = bad_cast (".");
cwd_only[1] = NULL;
initialize_main (&argc, &argv);
@@ -733,11 +728,6 @@ main (int argc, char **argv)
output_block_size = 1;
break;
case 'H': /* FIXME: remove warning and move this "case 'H'" to
precede --dereference-args in late 2006. */
error (0, 0, _("WARNING: use --si, not -H; the meaning of the -H\
option will soon\nchange to be the same as that of --dereference-args (-D)"));
/* fall through */
case HUMAN_SI_OPTION:
human_output_opts = human_autoscale | human_SI;
output_block_size = 1;
@@ -766,7 +756,7 @@ main (int argc, char **argv)
}
break;
case MEGABYTES_LONG_OPTION:
case MEGABYTES_LONG_OPTION: /* FIXME: remove in 2009 */
error (0, 0,
_("the --megabytes option is deprecated; use -m instead"));
/* fall through */
@@ -796,7 +786,8 @@ main (int argc, char **argv)
}
break;
case 'D': /* This will eventually be 'H' (-H), too. */
case 'H': /* NOTE: before 2008-12, -H was equivalent to --si. */
case 'D':
symlink_deref_bits = FTS_COMFOLLOW | FTS_PHYSICAL;
break;
@@ -925,6 +916,7 @@ main (int argc, char **argv)
}
}
struct argv_iterator *ai;
if (files_from)
{
/* When using --files0-from=F, you may not specify any files
@@ -941,78 +933,96 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
quote (files_from));
readtokens0_init (&tok);
if (! readtokens0 (stdin, &tok) || fclose (stdin) != 0)
error (EXIT_FAILURE, 0, _("cannot read file names from %s"),
quote (files_from));
files = tok.tok;
ai = argv_iter_init_stream (stdin);
}
else
{
files = (optind < argc ? argv + optind : cwd_only);
char **files = (optind < argc ? argv + optind : cwd_only);
ai = argv_iter_init_argv (files);
}
if (!ai)
xalloc_die ();
/* Initialize the hash structure for inode numbers. */
hash_init ();
/* Report and filter out any empty file names before invoking fts.
This works around a glitch in fts, which fails immediately
(without looking at the other file names) when given an empty
file name. */
{
size_t i = 0;
size_t j;
for (j = 0; ; j++)
{
if (i != j)
files[i] = files[j];
if ( ! files[i])
break;
if (files_from && STREQ (files_from, "-") && STREQ (files[i], "-"))
{
/* Give a better diagnostic in an unusual case:
printf - | du --files0-from=- */
error (0, 0, _("when reading file names from stdin, "
"no file name of %s allowed"),
quote ("-"));
continue;
}
if (files[i][0])
i++;
else
{
/* Diagnose a zero-length file name. When it's one
among many, knowing the record number may help. */
if (files_from)
{
/* Using the standard `filename:line-number:' prefix here is
not totally appropriate, since NUL is the separator, not NL,
but it might be better than nothing. */
unsigned long int file_number = j + 1;
error (0, 0, "%s:%lu: %s", quotearg_colon (files_from),
file_number, _("invalid zero-length file name"));
}
else
error (0, 0, "%s", _("invalid zero-length file name"));
}
}
ok = (i == j);
}
bit_flags |= symlink_deref_bits;
ok &= du_files (files, bit_flags);
static char *temp_argv[] = { NULL, NULL };
/* This isn't really necessary, but it does ensure we
exercise this function. */
if (files_from)
readtokens0_free (&tok);
while (true)
{
bool skip_file = false;
enum argv_iter_err ai_err;
char *file_name = argv_iter (ai, &ai_err);
if (ai_err == AI_ERR_EOF)
break;
if (!file_name)
{
switch (ai_err)
{
case AI_ERR_READ:
error (0, errno, _("%s: read error"), quote (files_from));
skip_file = true;
continue;
case AI_ERR_MEM:
xalloc_die ();
default:
assert (!"unexpected error code from argv_iter");
}
}
if (files_from && STREQ (files_from, "-") && STREQ (file_name, "-"))
{
/* Give a better diagnostic in an unusual case:
printf - | du --files0-from=- */
error (0, 0, _("when reading file names from stdin, "
"no file name of %s allowed"),
quote (file_name));
skip_file = true;
}
/* Report and skip any empty file names before invoking fts.
This works around a glitch in fts, which fails immediately
(without looking at the other file names) when given an empty
file name. */
if (!file_name[0])
{
/* Diagnose a zero-length file name. When it's one
among many, knowing the record number may help.
FIXME: currently print the record number only with
--files0-from=FILE. Maybe do it for argv, too? */
if (files_from == NULL)
error (0, 0, "%s", _("invalid zero-length file name"));
else
{
/* Using the standard `filename:line-number:' prefix here is
not totally appropriate, since NUL is the separator, not NL,
but it might be better than nothing. */
unsigned long int file_number = argv_iter_n_args (ai);
error (0, 0, "%s:%lu: %s", quotearg_colon (files_from),
file_number, _("invalid zero-length file name"));
}
skip_file = true;
}
if (skip_file)
ok = false;
else
{
temp_argv[0] = file_name;
ok &= du_files (temp_argv, bit_flags);
}
}
argv_iter_free (ai);
if (files_from && (ferror (stdin) || fclose (stdin) != 0))
error (EXIT_FAILURE, 0, _("error reading %s"), quote (files_from));
if (print_grand_total)
print_size (&tot_dui, _("total"));
hash_free (htab);

View File

@@ -1,5 +1,5 @@
/* echo.c, derived from code echo.c in Bash.
Copyright (C) 87,89, 1991-1997, 1999-2005, 2007-2008 Free Software
Copyright (C) 87,89, 1991-1997, 1999-2005, 2007-2009 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <sys/types.h>
#include "system.h"
#include "long-options.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "echo"
@@ -41,7 +40,10 @@ usage (int status)
program_name);
else
{
printf (_("Usage: %s [OPTION]... [STRING]...\n"), program_name);
printf (_("\
Usage: %s [SHORT-OPTION]... [STRING]...\n\
or: %s LONG-OPTION\n\
"), program_name, program_name);
fputs (_("\
Echo the STRING(s) to standard output.\n\
\n\
@@ -121,9 +123,20 @@ main (int argc, char **argv)
atexit (close_stdout);
if (allow_options)
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
usage, AUTHORS, (char const *) NULL);
/* We directly parse options, rather than use parse_long_options, in
order to avoid accepting abbreviations. */
if (allow_options && argc == 2)
{
if (STREQ (argv[1], "--help"))
usage (EXIT_SUCCESS);
if (STREQ (argv[1], "--version"))
{
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
(char *) NULL);
exit (EXIT_SUCCESS);
}
}
--argc;
++argv;

View File

@@ -91,8 +91,6 @@
proper_name ("Richard Mlynarik"), \
proper_name ("David MacKenzie")
int putenv ();
extern char **environ;
static struct option const longopts[] =

View File

@@ -76,7 +76,7 @@ static char **file_list;
/* Default for `file_list' if no files are given on the command line. */
static char *stdin_argv[] =
{
"-", NULL
(char *) "-", NULL
};
/* True if we have ever read standard input. */

View File

@@ -33,20 +33,122 @@
#include <sys/types.h>
#include "system.h"
#include <assert.h>
#include <regex.h>
#if HAVE_GMP
#include <gmp.h>
#endif
#include "error.h"
#include "long-options.h"
#include "quotearg.h"
#include "strnumcmp.h"
#include "xstrtol.h"
/* Various parts of this code assume size_t fits into unsigned long
int, the widest unsigned type that GMP supports. */
verify (SIZE_MAX <= ULONG_MAX);
static void integer_overflow (char) ATTRIBUTE_NORETURN;
#ifndef HAVE_GMP
# define HAVE_GMP 0
#endif
#if HAVE_GMP
# include <gmp.h>
#else
/* Approximate gmp.h well enough for expr.c's purposes. */
typedef intmax_t mpz_t[1];
static void mpz_clear (mpz_t z) {}
static void mpz_init_set_ui (mpz_t z, unsigned long int i) { z[0] = i; }
static int
mpz_init_set_str (mpz_t z, char *s, int base)
{
return xstrtoimax (s, NULL, base, z, NULL) == LONGINT_OK ? 0 : -1;
}
static void
mpz_add (mpz_t r, mpz_t a0, mpz_t b0)
{
intmax_t a = a0[0];
intmax_t b = b0[0];
intmax_t val = a + b;
if ((val < a) != (b < 0))
integer_overflow ('+');
r[0] = val;
}
static void
mpz_sub (mpz_t r, mpz_t a0, mpz_t b0)
{
intmax_t a = a0[0];
intmax_t b = b0[0];
intmax_t val = a - b;
if ((a < val) != (b < 0))
integer_overflow ('-');
r[0] = val;
}
static void
mpz_mul (mpz_t r, mpz_t a0, mpz_t b0)
{
intmax_t a = a0[0];
intmax_t b = b0[0];
intmax_t val = a * b;
if (! (a == 0 || b == 0
|| ((val < 0) == ((a < 0) ^ (b < 0)) && val / a == b)))
integer_overflow ('*');
r[0] = val;
}
static void
mpz_tdiv_q (mpz_t r, mpz_t a0, mpz_t b0)
{
intmax_t a = a0[0];
intmax_t b = b0[0];
/* Some x86-style hosts raise an exception for INT_MIN / -1. */
if (a < - INTMAX_MAX && b == -1)
integer_overflow ('/');
r[0] = a / b;
}
static void
mpz_tdiv_r (mpz_t r, mpz_t a0, mpz_t b0)
{
intmax_t a = a0[0];
intmax_t b = b0[0];
/* Some x86-style hosts raise an exception for INT_MIN % -1. */
r[0] = a < - INTMAX_MAX && b == -1 ? 0 : a % b;
}
static char *
mpz_get_str (char const *str, int base, mpz_t z)
{
char buf[INT_BUFSIZE_BOUND (intmax_t)];
return xstrdup (imaxtostr (z[0], buf));
}
static int
mpz_sgn (mpz_t z)
{
return z[0] < 0 ? -1 : 0 < z[0];
}
static int
mpz_fits_ulong_p (mpz_t z)
{
return 0 <= z[0] && z[0] <= ULONG_MAX;
}
static unsigned long int
mpz_get_ui (mpz_t z)
{
return z[0];
}
static int
mpz_out_str (FILE *stream, int base, mpz_t z)
{
char buf[INT_BUFSIZE_BOUND (intmax_t)];
return fputs (imaxtostr (z[0], buf), stream) != EOF;
}
#endif
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "expr"
#define AUTHORS proper_name ("Mike Parker"), proper_name ("James Youngman")
#define AUTHORS \
proper_name ("Mike Parker"), \
proper_name ("James Youngman"), \
proper_name ("Paul Eggert")
/* Exit statuses. */
enum
@@ -61,14 +163,10 @@ enum
EXPR_FAILURE
};
/* The kinds of value we can have.
In the comments below, a variable is described as "arithmetic" if
it is either integer or mp_integer. Variables are of type mp_integer
only if GNU MP is available, but the type designator is always defined. */
/* The kinds of value we can have. */
enum valtype
{
integer,
mp_integer,
string
};
typedef enum valtype TYPE;
@@ -79,12 +177,7 @@ struct valinfo
TYPE type; /* Which kind. */
union
{ /* The value itself. */
/* We could use intmax_t but that would integrate less well with GMP,
since GMP has mpz_set_si but no intmax_t equivalent. */
signed long int i;
#if HAVE_GMP
mpz_t z;
#endif
mpz_t i;
char *s;
} u;
};
@@ -98,34 +191,6 @@ static bool nomoreargs (void);
static bool null (VALUE *v);
static void printv (VALUE *v);
/* Arithmetic is done in one of three modes.
The --bignum option forces all arithmetic to use bignums other than
string indexing (mode==MP_ALWAYS). The --no-bignum option forces
all arithmetic to use native types rather than bignums
(mode==MP_NEVER).
The default mode is MP_AUTO if GMP is available and MP_NEVER if
not. Most functions will process a bignum if one is found, but
will not convert a native integer to a string if the mode is
MP_NEVER. */
enum arithmetic_mode
{
MP_NEVER, /* Never use bignums */
#if HAVE_GMP
MP_ALWAYS, /* Always use bignums. */
MP_AUTO, /* Switch if result would otherwise overflow */
#endif
};
static enum arithmetic_mode mode =
#if HAVE_GMP
MP_AUTO
#else
MP_NEVER
#endif
;
void
usage (int status)
{
@@ -140,10 +205,6 @@ Usage: %s EXPRESSION\n\
"),
program_name, program_name);
putchar ('\n');
fputs (_("\
--bignum always use arbitrary-precision arithmetic\n\
--no-bignum always use single-precision arithmetic\n"),
stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
fputs (_("\
@@ -220,47 +281,23 @@ syntax_error (void)
static void
integer_overflow (char op)
{
error (EXPR_FAILURE, 0,
_("arithmetic operation %c produced an out of range value, "
"but arbitrary-precision arithmetic is not available"), op);
}
static void die (int exit_status, int errno_val, char const *msg)
ATTRIBUTE_NORETURN;
static void
die (int exit_status, int errno_val, char const *msg)
{
assert (exit_status != 0);
error (exit_status, errno_val, "%s", msg);
error (EXPR_FAILURE, ERANGE, "%c", op);
abort (); /* notreached */
}
static void die (int errno_val, char const *msg)
ATTRIBUTE_NORETURN;
static void
string_too_long (void)
die (int errno_val, char const *msg)
{
die (EXPR_FAILURE, ERANGE, _("string too long"));
error (EXPR_FAILURE, errno_val, "%s", msg);
abort (); /* notreached */
}
enum
{
USE_BIGNUM = CHAR_MAX + 1,
NO_USE_BIGNUM
};
static struct option const long_options[] =
{
{"bignum", no_argument, NULL, USE_BIGNUM},
{"no-bignum", no_argument, NULL, NO_USE_BIGNUM},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
};
int
main (int argc, char **argv)
{
VALUE *v;
int c;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
@@ -271,49 +308,23 @@ main (int argc, char **argv)
initialize_exit_failure (EXPR_FAILURE);
atexit (close_stdout);
/* The argument -0 should not result in an error message. */
opterr = 0;
while ((c = getopt_long (argc, argv, "+", long_options, NULL)) != -1)
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
usage, AUTHORS, (char const *) NULL);
/* The above handles --help and --version.
Since there is no other invocation of getopt, handle `--' here. */
if (argc > 1 && STREQ (argv[1], "--"))
{
/* "expr -0" should interpret the -0 as an integer argument.
arguments like --foo should also be interpreted as a string
argument to be "evaluated".
*/
if ('?' == c)
{
--optind;
break;
}
else
switch (c)
{
case USE_BIGNUM:
#if HAVE_GMP
mode = MP_ALWAYS;
#else
error (EXPR_FAILURE, 0,
_("arbitrary-precision support is not available"));
#endif
break;
case NO_USE_BIGNUM:
mode = MP_NEVER;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
}
--argc;
++argv;
}
if (argc <= optind)
if (argc <= 1)
{
error (0, 0, _("missing operand"));
usage (EXPR_INVALID);
}
args = argv + optind;
args = argv + 1;
v = eval (true);
if (!nomoreargs ())
@@ -326,21 +337,11 @@ main (int argc, char **argv)
/* Return a VALUE for I. */
static VALUE *
int_value (long int i)
int_value (unsigned long int i)
{
VALUE *v = xmalloc (sizeof *v);
#if HAVE_GMP
if (mode == MP_ALWAYS)
{
/* all integer values are handled as bignums. */
mpz_init_set_si (v->u.z, i);
v->type = mp_integer;
return v;
}
#endif
v->type = integer;
v->u.i = i;
mpz_init_set_ui (v->u.i, i);
return v;
}
@@ -355,42 +356,15 @@ str_value (char const *s)
return v;
}
static VALUE *
substr_value (char const *s, size_t len, size_t pos, size_t nchars_wanted)
{
if (pos >= len)
return str_value ("");
else
{
VALUE *v = xmalloc (sizeof *v);
size_t vlen = MIN (nchars_wanted, len - pos + 1);
char *vlim;
v->type = string;
v->u.s = xmalloc (vlen + 1);
vlim = mempcpy (v->u.s, s + pos, vlen);
*vlim = '\0';
return v;
}
}
/* Free VALUE V, including structure components. */
static void
freev (VALUE *v)
{
if (v->type == string)
{
free (v->u.s);
}
else if (v->type == mp_integer)
{
assert (mode != MP_NEVER);
#if HAVE_GMP
mpz_clear (v->u.z);
#endif
}
free (v->u.s);
else
mpz_clear (v->u.i);
free (v);
}
@@ -402,21 +376,15 @@ printv (VALUE *v)
switch (v->type)
{
case integer:
printf ("%ld\n", v->u.i);
mpz_out_str (stdout, 10, v->u.i);
putchar ('\n');
break;
case string:
puts (v->u.s);
break;
#if HAVE_GMP
case mp_integer:
mpz_out_str (stdout, 10, v->u.z);
putchar ('\n');
break;
#endif
default:
abort ();
}
}
/* Return true if V is a null-string or zero-number. */
@@ -427,11 +395,7 @@ null (VALUE *v)
switch (v->type)
{
case integer:
return v->u.i == 0;
#if HAVE_GMP
case mp_integer:
return mpz_sgn (v->u.z) == 0;
#endif
return mpz_sgn (v->u.i) == 0;
case string:
{
char const *cp = v->u.s;
@@ -474,29 +438,16 @@ looks_like_integer (char const *cp)
static void
tostring (VALUE *v)
{
char buf[INT_BUFSIZE_BOUND (long int)];
switch (v->type)
{
case integer:
snprintf (buf, sizeof buf, "%ld", v->u.i);
v->u.s = xstrdup (buf);
v->type = string;
break;
#if HAVE_GMP
case mp_integer:
{
char *s = mpz_get_str (NULL, 10, v->u.z);
if (!s)
{
xalloc_die ();
}
mpz_clear (v->u.z);
char *s = mpz_get_str (NULL, 10, v->u.i);
mpz_clear (v->u.i);
v->u.s = s;
v->type = string;
}
break;
#endif
case string:
break;
default:
@@ -504,8 +455,7 @@ tostring (VALUE *v)
}
}
/* Coerce V to an arithmetic value.
Return true on success, false on failure. */
/* Coerce V to an integer value. Return true on success, false on failure. */
static bool
toarith (VALUE *v)
@@ -513,40 +463,17 @@ toarith (VALUE *v)
switch (v->type)
{
case integer:
case mp_integer:
return true;
case string:
{
long int value;
char *s = v->u.s;
if (! looks_like_integer (v->u.s))
if (! looks_like_integer (s))
return false;
if (xstrtol (v->u.s, NULL, 10, &value, NULL) != LONGINT_OK)
{
#if HAVE_GMP
if (mode != MP_NEVER)
{
char *s = v->u.s;
if (mpz_init_set_str (v->u.z, s, 10))
abort (); /* Bug in looks_like_integer, perhaps. */
v->type = mp_integer;
free (s);
}
else
{
error (EXPR_FAILURE, ERANGE, "%s", v->u.s);
}
#else
error (EXPR_FAILURE, ERANGE, "%s", v->u.s);
#endif
}
else
{
free (v->u.s);
v->u.i = value;
v->type = integer;
}
if (mpz_init_set_str (v->u.i, s, 10) != 0 && !HAVE_GMP)
error (EXPR_FAILURE, ERANGE, "%s", s);
free (s);
v->type = integer;
return true;
}
default:
@@ -554,58 +481,23 @@ toarith (VALUE *v)
}
}
/* Extract a size_t value from a positive arithmetic value, V.
The extracted value is stored in *VAL. */
static bool
getsize (const VALUE *v, size_t *val, bool *negative)
/* Extract a size_t value from a integer value I.
If the value is negative, return SIZE_MAX.
If the value is too large, return SIZE_MAX - 1. */
static size_t
getsize (mpz_t i)
{
if (v->type == integer)
if (mpz_sgn (i) < 0)
return SIZE_MAX;
if (mpz_fits_ulong_p (i))
{
if (v->u.i < 0)
{
*negative = true;
return false;
}
else
{
*negative = false;
*val = v->u.i;
return true;
}
}
else if (v->type == mp_integer)
{
#if HAVE_GMP
if (mpz_sgn (v->u.z) < 0)
{
*negative = true;
return false;
}
else if (mpz_fits_ulong_p (v->u.z))
{
unsigned long ul;
ul = mpz_get_ui (v->u.z);
*val = ul;
return true;
}
else
{
*negative = false;
return false;
}
#else
abort ();
#endif
}
else
{
abort (); /* should not pass a string. */
unsigned long int ul = mpz_get_ui (i);
if (ul < SIZE_MAX)
return ul;
}
return SIZE_MAX - 1;
}
/* Return true and advance if the next token matches STR exactly.
STR must not be NULL. */
@@ -784,41 +676,14 @@ eval6 (bool evaluate)
}
else if (nextarg ("index"))
{
size_t pos, len;
size_t pos;
l = eval6 (evaluate);
r = eval6 (evaluate);
tostring (l);
tostring (r);
pos = strcspn (l->u.s, r->u.s);
len = strlen (l->u.s);
if (pos == len)
{
v = int_value (0);
}
else
{
if (pos < LONG_MAX)
{
v = int_value (pos + 1);
}
else
{
#if HAVE_GMP
if (mode != MP_NEVER
&& pos < ULONG_MAX)
{
v = xmalloc (sizeof *v);
mpz_init_set_ui (v->u.z, pos+1);
v->type = mp_integer;
}
else
#endif
{
string_too_long ();
}
}
}
v = int_value (l->u.s[pos] ? pos + 1 : 0);
freev (l);
freev (r);
return v;
@@ -836,25 +701,21 @@ eval6 (bool evaluate)
v = str_value ("");
else
{
size_t pos, len;
bool negative = false;
size_t pos = getsize (i1->u.i);
size_t len = getsize (i2->u.i);
if (getsize (i1, &pos, &negative))
if (getsize (i2, &len, &negative))
if (pos == 0 || len == 0)
v = str_value ("");
else
v = substr_value (l->u.s, llen, pos-1, len);
else
if (negative)
v = str_value ("");
else
die (EXPR_FAILURE, ERANGE, _("string offset is too large"));
if (llen < pos || pos == 0 || len == 0 || len == SIZE_MAX)
v = str_value ("");
else
if (negative)
v = str_value ("");
else
die (EXPR_FAILURE, ERANGE, _("substring length too large"));
{
size_t vlen = MIN (len, llen - pos + 1);
char *vlim;
v = xmalloc (sizeof *v);
v->type = string;
v->u.s = xmalloc (vlen + 1);
vlim = mempcpy (v->u.s, l->u.s + pos - 1, vlen);
*vlim = '\0';
}
}
freev (l);
freev (i1);
@@ -897,170 +758,6 @@ eval5 (bool evaluate)
}
}
#if HAVE_GMP
static void
promote (VALUE *x)
{
if (x->type == integer)
mpz_init_set_si (x->u.z, x->u.i);
}
#endif
/* L = L * R. Both L and R are arithmetic. */
static void
domult (VALUE *l, VALUE *r)
{
if (l->type == integer && r->type == integer)
{
long int val = 0;
val = l->u.i * r->u.i;
if (! (l->u.i == 0 || r->u.i == 0
|| ((val < 0) == ((l->u.i < 0) ^ (r->u.i < 0))
&& val / l->u.i == r->u.i)))
{
/* Result would (did) overflow. Handle with MP if available. */
if (mode != MP_NEVER)
{
#if HAVE_GMP
mpz_init_set_si (l->u.z, l->u.i);
mpz_mul_si (l->u.z, l->u.z, r->u.i); /* L*=R */
l->type = mp_integer;
#endif
}
else
{
integer_overflow ('*');
}
}
else
{
l->u.i = val;
}
}
else
{
/* At least one operand is already mp_integer, so promote the other. */
#if HAVE_GMP
/* We could use mpz_mul_si here if R is not already mp_integer,
but for the moment we'll try to minimise code paths. */
if (l->type == integer)
mpz_init_set_si (l->u.z, l->u.i);
if (r->type == integer)
mpz_init_set_si (r->u.z, r->u.i);
l->type = r->type = mp_integer;
mpz_mul (l->u.z, l->u.z, r->u.z); /* L*=R */
#else
abort ();
#endif
}
}
/* L = L / R or (if WANT_MODULUS) L = L % R */
static void
dodivide (VALUE *l, VALUE *r, bool want_modulus)
{
if (r->type == integer && r->u.i == 0)
error (EXPR_INVALID, 0, _("division by zero"));
#if HAVE_GMP
if (r->type == mp_integer && mpz_sgn (r->u.z) == 0)
error (EXPR_INVALID, 0, _("division by zero"));
#endif
if (l->type == integer && r->type == integer)
{
if (l->u.i < - INT_MAX && r->u.i == -1)
{
/* Some x86-style hosts raise an exception for
INT_MIN / -1 and INT_MIN % -1, so handle these
problematic cases specially. */
if (want_modulus)
{
/* X mod -1 is zero for all negative X.
Although strictly this is implementation-defined,
we don't want to coredump, so we avoid the calculation. */
l->u.i = 0;
return;
}
else
{
if (mode != MP_NEVER)
{
#if HAVE_GMP
/* Handle the case by promoting. */
mpz_init_set_si (l->u.z, l->u.i);
l->type = mp_integer;
#endif
}
else
{
integer_overflow ('/');
}
}
}
else
{
l->u.i = want_modulus ? l->u.i % r->u.i : l->u.i / r->u.i;
return;
}
}
/* If we get to here, at least one operand is mp_integer
and R is not 0. */
#if HAVE_GMP
{
int sign_l, sign_r;
promote (l);
promote (r);
sign_l = mpz_sgn (l->u.z);
sign_r = mpz_sgn (r->u.z);
if (!want_modulus)
{
if (!sign_l)
{
mpz_set_si (l->u.z, 0);
}
else if (sign_l < 0 || sign_r < 0)
{
/* At least one operand is negative. For integer arithmetic,
it's platform-dependent if the operation rounds up or down.
We mirror what the implementation does. */
switch ((3*sign_l) / (2*sign_r))
{
case 2: /* round toward +inf. */
case -1: /* round toward +inf. */
mpz_cdiv_q (l->u.z, l->u.z, r->u.z);
break;
case -2: /* round toward -inf. */
case 1: /* round toward -inf */
mpz_fdiv_q (l->u.z, l->u.z, r->u.z);
break;
default:
abort ();
}
}
else
{
/* Both operands positive. Round toward -inf. */
mpz_fdiv_q (l->u.z, l->u.z, r->u.z);
}
}
else
{
mpz_mod (l->u.z, l->u.z, r->u.z); /* L = L % R */
/* If either operand is negative, it's platform-dependent if
the remainer is positive or negative. We mirror what the
implementation does. */
if (sign_l % sign_r < 0)
mpz_neg (l->u.z, l->u.z); /* L = (-L) */
}
}
#else
abort ();
#endif
}
/* Handle *, /, % operators. */
static VALUE *
@@ -1089,71 +786,17 @@ eval4 (bool evaluate)
{
if (!toarith (l) || !toarith (r))
error (EXPR_INVALID, 0, _("non-numeric argument"));
switch (fxn)
{
case multiply:
domult (l, r);
break;
case divide:
case mod:
dodivide (l, r, fxn==mod);
break;
}
if (fxn != multiply && mpz_sgn (r->u.i) == 0)
error (EXPR_INVALID, 0, _("division by zero"));
((fxn == multiply ? mpz_mul
: fxn == divide ? mpz_tdiv_q
: mpz_tdiv_r)
(l->u.i, l->u.i, r->u.i));
}
freev (r);
}
}
/* L = L + R, or L = L - R */
static void
doadd (VALUE *l, VALUE *r, bool add)
{
long int val = 0;
if (!toarith (l) || !toarith (r))
error (EXPR_INVALID, 0, _("non-numeric argument"));
if (l->type == integer && r->type == integer)
{
if (add)
{
val = l->u.i + r->u.i;
if ((val < l->u.i) == (r->u.i < 0))
{
l->u.i = val;
return;
}
}
else
{
val = l->u.i - r->u.i;
if ((l->u.i < val) == (r->u.i < 0))
{
l->u.i = val;
return;
}
}
}
/* If we get to here, either the operation overflowed or at least
one operand is an mp_integer. */
if (mode != MP_NEVER)
{
#if HAVE_GMP
promote (l);
promote (r);
if (add)
mpz_add (l->u.z, l->u.z, r->u.z);
else
mpz_sub (l->u.z, l->u.z, r->u.z);
#endif
}
else
{
integer_overflow ('-');
}
}
/* Handle +, - operators. */
static VALUE *
@@ -1161,7 +804,7 @@ eval3 (bool evaluate)
{
VALUE *l;
VALUE *r;
bool add;
enum { plus, minus } fxn;
#ifdef EVAL_TRACE
trace ("eval3");
@@ -1170,15 +813,17 @@ eval3 (bool evaluate)
while (1)
{
if (nextarg ("+"))
add = true;
fxn = plus;
else if (nextarg ("-"))
add = false;
fxn = minus;
else
return l;
r = eval4 (evaluate);
if (evaluate)
{
doadd (l, r, add);
if (!toarith (l) || !toarith (r))
error (EXPR_INVALID, 0, _("non-numeric argument"));
(fxn == plus ? mpz_add : mpz_sub) (l->u.i, l->u.i, r->u.i);
}
freev (r);
}

View File

@@ -49,15 +49,6 @@
static bool verbose = false;
typedef enum
{
ALGO_AUTOSELECT, /* default */
ALGO_GMP, /* --bignum */
ALGO_SINGLE /* --no-bignum */
} ALGORITHM_CHOICE;
static ALGORITHM_CHOICE algorithm = ALGO_AUTOSELECT;
#if HAVE_GMP
static mpz_t *factor = NULL;
static size_t nfactors_found = 0;
@@ -91,6 +82,7 @@ emit_ul_factor (unsigned long int i)
mpz_init (t);
mpz_set_ui (t, i);
emit_factor (t);
mpz_clear (t);
}
static void
@@ -267,51 +259,13 @@ S4:
mpz_clear (y);
}
/* Arbitrary-precision factoring */
static bool
extract_factors_multi (char const *s)
#else
static void
debug (char const *fmt ATTRIBUTE_UNUSED, ...)
{
unsigned int division_limit;
size_t n_bits;
mpz_t t;
mpz_init (t);
if (1 != gmp_sscanf (s, "%Zd", t))
{
error (0, 0, _("%s is not a valid positive integer"), quote (s));
return false;
}
printf ("%s:", s);
if (mpz_sgn (t) == 0)
{
mpz_clear (t);
return true; /* 0; no factors */
}
/* Set the trial division limit according to the size of t. */
n_bits = mpz_sizeinbase (t, 2);
division_limit = MIN (n_bits, 1000);
division_limit *= division_limit;
factor_using_division (t, division_limit);
if (mpz_cmp_ui (t, 1) != 0)
{
debug ("[is number prime?] ");
if (mpz_probab_prime_p (t, 3))
{
emit_factor (t);
}
else
{
factor_using_pollard_rho (t, 1);
}
}
mpz_clear (t);
return true;
}
#endif
/* The maximum number of factors, including -1, for negative numbers. */
@@ -379,30 +333,18 @@ factor_wheel (uintmax_t n0, size_t max_n_factors, uintmax_t *factors)
}
/* Single-precision factoring */
static bool
print_factors_single (char const *s)
static void
print_factors_single (uintmax_t n)
{
uintmax_t factors[MAX_N_FACTORS];
uintmax_t n;
size_t n_factors;
size_t n_factors = factor_wheel (n, MAX_N_FACTORS, factors);
size_t i;
char buf[INT_BUFSIZE_BOUND (uintmax_t)];
strtol_error err;
if ((err = xstrtoumax (s, NULL, 10, &n, "")) != LONGINT_OK)
{
if (err == LONGINT_OVERFLOW)
error (0, 0, _("%s is too large"), quote (s));
else
error (0, 0, _("%s is not a valid positive integer"), quote (s));
return false;
}
n_factors = factor_wheel (n, MAX_N_FACTORS, factors);
printf ("%s:", umaxtostr (n, buf));
for (i = 0; i < n_factors; i++)
printf (" %s", umaxtostr (factors[i], buf));
putchar ('\n');
return true;
}
#if HAVE_GMP
@@ -450,67 +392,93 @@ free_factors (void)
nfactors_found = 0;
}
/* Arbitrary-precision factoring */
static void
print_factors_multi (mpz_t t)
{
mpz_out_str (stdout, 10, t);
putchar (':');
if (mpz_sgn (t) != 0)
{
/* Set the trial division limit according to the size of t. */
size_t n_bits = mpz_sizeinbase (t, 2);
unsigned int division_limit = MIN (n_bits, 1000);
division_limit *= division_limit;
factor_using_division (t, division_limit);
if (mpz_cmp_ui (t, 1) != 0)
{
debug ("[is number prime?] ");
if (mpz_probab_prime_p (t, 3))
emit_factor (t);
else
factor_using_pollard_rho (t, 1);
}
}
mpz_clear (t);
sort_and_print_factors ();
free_factors ();
}
#endif
/* Emit the factors of the indicated number. If we have the option of using
either algorithm, we select on the basis of the length of the number.
For longer numbers, we prefer the MP algorithm even if the native algorithm
has enough digits, because the algorithm is better. The turnover point
depends on the value as well as the length, but since we don't already know
if the number presented has small factors, we just switch over at 6 digits.
*/
has enough digits, because the algorithm is better. The turnover point
depends on the value. */
static bool
print_factors (char const *s)
{
if (ALGO_AUTOSELECT == algorithm)
uintmax_t n;
strtol_error err = xstrtoumax (s, NULL, 10, &n, "");
#if HAVE_GMP
enum { GMP_TURNOVER_POINT = 100000 };
if (err == LONGINT_OVERFLOW
|| (err == LONGINT_OK && GMP_TURNOVER_POINT <= n))
{
const size_t digits = strlen (s); /* upper limit on number of digits */
algorithm = digits < 6 ? ALGO_SINGLE : ALGO_GMP;
}
if (ALGO_GMP == algorithm)
{
debug ("[%s]", _("using arbitrary-precision arithmetic"));
if (extract_factors_multi (s))
mpz_t t;
mpz_init (t);
if (gmp_sscanf (s, "%Zd", t) == 1)
{
sort_and_print_factors ();
free_factors ();
debug ("[%s]", _("using arbitrary-precision arithmetic"));
print_factors_multi (t);
return true;
}
else
{
return false;
}
err = LONGINT_INVALID;
}
else
#endif
switch (err)
{
case LONGINT_OK:
debug ("[%s]", _("using single-precision arithmetic"));
return print_factors_single (s);
}
}
#else
static bool
print_factors (const char *s) /* Single-precision only. */
{
if (ALGO_GMP == algorithm)
{
error (0, 0, _("arbitrary-precision arithmetic is not available"));
print_factors_single (n);
return true;
case LONGINT_OVERFLOW:
error (0, 0, _("%s is too large"), quote (s));
return false;
default:
error (0, 0, _("%s is not a valid positive integer"), quote (s));
return false;
}
return print_factors_single (s);
}
#endif
enum
{
VERBOSE_OPTION = CHAR_MAX + 1,
USE_BIGNUM,
NO_USE_BIGNUM
VERBOSE_OPTION = CHAR_MAX + 1
};
static struct option const long_options[] =
{
{"verbose", no_argument, NULL, VERBOSE_OPTION},
{"bignum", no_argument, NULL, USE_BIGNUM},
{"no-bignum", no_argument, NULL, NO_USE_BIGNUM},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
@@ -534,10 +502,6 @@ Print the prime factors of each specified integer NUMBER. If none\n\
are specified on the command line, read them from standard input.\n\
\n\
"), stdout);
fputs (_("\
--bignum always use arbitrary-precision arithmetic\n\
--no-bignum always use single-precision arithmetic\n"),
stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
@@ -588,14 +552,6 @@ main (int argc, char **argv)
verbose = true;
break;
case USE_BIGNUM:
algorithm = ALGO_GMP;
break;
case NO_USE_BIGNUM:
algorithm = ALGO_SINGLE;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);

180
src/getlimits.c Normal file
View File

@@ -0,0 +1,180 @@
/* getlimits - print various platform dependent limits.
Copyright (C) 2008 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> /* sets _FILE_OFFSET_BITS=64 etc. */
#include <stdio.h>
#include <sys/types.h>
#include "system.h"
#include "c-ctype.h"
#include "long-options.h"
#define PROGRAM_NAME "getlimits"
#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
#ifndef TIME_T_MAX
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
#endif
#ifndef TIME_T_MIN
# define TIME_T_MIN TYPE_MINIMUM (time_t)
#endif
#ifndef SSIZE_MIN
# define SSIZE_MIN TYPE_MINIMUM (ssize_t)
#endif
#ifndef PID_T_MIN
# define PID_T_MIN TYPE_MINIMUM (pid_t)
#endif
/* These are not interesting to print.
* Instead of these defines it would be nice to be able to do
* #ifdef (TYPE##_MIN) in function macro below. */
#define SIZE_MIN 0
#define UCHAR_MIN 0
#define UINT_MIN 0
#define ULONG_MIN 0
#define UINTMAX_MIN 0
#define UID_T_MIN 0
#define GID_T_MIN 0
void
usage (int status)
{
if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
{
printf (_("\
Usage: %s\n\
"), program_name);
fputs (_("\
Output platform dependent limits in a format useful for shell scripts.\n\
\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
}
exit (status);
}
/* Add absolute values of ascii decimal strings.
* Strings can have leading spaces.
* If any string has a '-' it's preserved in the output:
* I.E.
* 1 + 1 -> 2
* -1 + -1 -> -2
* -1 + 1 -> -2
* 1 + -1 -> -2
*/
static char *
decimal_ascii_add (const char *str1, const char *str2)
{
int len1 = strlen (str1);
int len2 = strlen (str2);
int rlen = MAX (len1, len2) + 3; /* space for extra digit or sign + NUL */
char *result = xmalloc (rlen);
char *rp = result + rlen - 1;
const char *d1 = str1 + len1 - 1;
const char *d2 = str2 + len2 - 1;
int carry = 0;
*rp = '\0';
while (1)
{
char c1 = (d1 < str1 ? ' ' : (*d1 == '-' ? ' ' : *d1--));
char c2 = (d2 < str2 ? ' ' : (*d2 == '-' ? ' ' : *d2--));
char t1 = c1 + c2 + carry; /* ASCII digits are BCD */
if (!c_isdigit (c1) && !c_isdigit (c2) && !carry)
break;
carry = t1 > '0' + '9' || t1 == ' ' + '9' + 1;
t1 += 6 * carry;
*--rp = (t1 & 0x0F) | 0x30; /* top nibble to ASCII */
}
if ((d1 >= str1 && *d1 == '-') || (d2 >= str2 && (*d2 == '-')))
*--rp = '-';
if (rp != result)
memmove (result, rp, rlen - (rp - result));
return result;
}
int
main (int argc, char **argv)
{
char limit[64]; /* big enough for 128 bit at least */
char *oflow;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
initialize_exit_failure (EXIT_FAILURE);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
usage, AUTHORS, (char const *) NULL);
#define print_int(TYPE) \
snprintf (limit, sizeof(limit), "%"PRIuMAX, (uintmax_t)TYPE##_MAX); \
printf (#TYPE"_MAX=%s\n", limit); \
oflow = decimal_ascii_add (limit, "1"); \
printf (#TYPE"_OFLOW=%s\n", oflow); \
free (oflow); \
if (TYPE##_MIN) \
{ \
snprintf (limit, sizeof(limit), "%"PRIdMAX, (intmax_t)TYPE##_MIN); \
printf (#TYPE"_MIN=%s\n", limit); \
oflow = decimal_ascii_add (limit, "-1"); \
printf (#TYPE"_UFLOW=%s\n", oflow); \
free (oflow); \
}
/* Variable sized ints */
print_int (CHAR);
print_int (SCHAR);
print_int (UCHAR);
print_int (SHRT);
print_int (INT);
print_int (UINT);
print_int (LONG);
print_int (ULONG);
print_int (SIZE);
print_int (SSIZE);
print_int (TIME_T);
print_int (UID_T);
print_int (GID_T);
print_int (PID_T);
print_int (OFF_T);
print_int (INTMAX);
print_int (UINTMAX);
}
/*
* Local variables:
* indent-tabs-mode: nil
* End:
*/

View File

@@ -1,5 +1,5 @@
/* group-list.c --Print a list of group IDs or names.
Copyright (C) 1989-2008 Free Software Foundation, Inc.
Copyright (C) 1989-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
@@ -57,7 +57,7 @@ print_group_list (const char *username,
#if HAVE_GETGROUPS
{
GETGROUPS_T *groups;
size_t i;
int i;
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&groups);
@@ -83,9 +83,9 @@ print_group_list (const char *username,
ok = false;
}
free (groups);
return ok;
}
#endif /* HAVE_GETGROUPS */
return ok;
}

View File

@@ -36,6 +36,7 @@
#include "full-read.h"
#include "quote.h"
#include "safe-read.h"
#include "xfreopen.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -838,7 +839,7 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines,
fd = STDIN_FILENO;
filename = _("standard input");
if (O_BINARY && ! isatty (STDIN_FILENO))
freopen (NULL, "rb", stdin);
xfreopen (NULL, "rb", stdin);
}
else
{
@@ -1051,7 +1052,7 @@ main (int argc, char **argv)
: default_file_list);
if (O_BINARY && ! isatty (STDOUT_FILENO))
freopen (NULL, "wb", stdout);
xfreopen (NULL, "wb", stdout);
for (i = 0; file_list[i]; ++i)
ok &= head_file (file_list[i], n_units, count_lines, elide_from_end);

View File

@@ -1,6 +1,6 @@
/* print the hexadecimal identifier for the current host
Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2007-2008 Free
Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2007-2009 Free
Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -42,12 +42,10 @@ usage (int status)
else
{
printf (_("\
Usage: %s\n\
or: %s OPTION\n\
Usage: %s [OPTION]\n\
Print the numeric identifier (in hexadecimal) for the current host.\n\
\n\
"),
program_name, program_name);
"), program_name);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();

View File

@@ -32,15 +32,11 @@
#define AUTHORS proper_name ("Jim Meyering")
#if HAVE_SETHOSTNAME && !defined sethostname
int sethostname ();
#endif
#if !defined HAVE_SETHOSTNAME && defined HAVE_SYSINFO && \
defined HAVE_SYS_SYSTEMINFO_H
# include <sys/systeminfo.h>
int
static int
sethostname (char *name, size_t namelen)
{
/* Using sysinfo() is the SVR4 mechanism to set a hostname. */

View File

@@ -1,5 +1,5 @@
/* id -- print real and effective UIDs and GIDs
Copyright (C) 1989-2008 Free Software Foundation, Inc.
Copyright (C) 1989-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
@@ -81,7 +81,8 @@ usage (int status)
{
printf (_("Usage: %s [OPTION]... [USERNAME]\n"), program_name);
fputs (_("\
Print information for USERNAME, or the current user.\n\
Print user and group information for the specified USERNAME,\n\
or (when USERNAME omitted) for the current user.\n\
\n\
-a ignore, for compatibility with other versions\n\
-Z, --context print only the security context of the current user\n\
@@ -294,7 +295,7 @@ print_full_info (const char *username)
#if HAVE_GETGROUPS
{
GETGROUPS_T *groups;
size_t i;
int i;
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&groups);

View File

@@ -1,5 +1,5 @@
/* install - copy files and set attributes
Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 89, 90, 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
@@ -31,6 +31,7 @@
#include "cp-hash.h"
#include "copy.h"
#include "filenamecat.h"
#include "full-read.h"
#include "mkancesdirs.h"
#include "mkdir-p.h"
#include "modechange.h"
@@ -125,6 +126,9 @@ static mode_t dir_mode = DEFAULT_MODE;
or S_ISGID bits. */
static mode_t dir_mode_bits = CHMOD_MODE_BITS;
/* Compare files before installing (-C) */
static bool copy_only_if_needed;
/* If true, strip executable files after copying them. */
static bool strip_files;
@@ -132,7 +136,7 @@ static bool strip_files;
static bool dir_arg;
/* Program used to strip binaries, "strip" is default */
static char *strip_program = "strip";
static char const *strip_program = "strip";
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
@@ -145,6 +149,7 @@ enum
static struct option const long_options[] =
{
{"backup", optional_argument, NULL, 'b'},
{"compare", no_argument, NULL, 'C'},
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
{"directory", no_argument, NULL, 'd'},
{"group", required_argument, NULL, 'g'},
@@ -167,6 +172,107 @@ static struct option const long_options[] =
{NULL, 0, NULL, 0}
};
/* Compare content of opened files using file descriptors A_FD and B_FD. Return
true if files are equal. */
static bool
have_same_content (int a_fd, int b_fd)
{
enum { CMP_BLOCK_SIZE = 4096 };
static char a_buff[CMP_BLOCK_SIZE];
static char b_buff[CMP_BLOCK_SIZE];
size_t size;
while (0 < (size = full_read (a_fd, a_buff, sizeof a_buff))) {
if (size != full_read (b_fd, b_buff, sizeof b_buff))
return false;
if (memcmp (a_buff, b_buff, size) != 0)
return false;
}
return size == 0;
}
/* Return true for mode with non-permission bits. */
static bool
extra_mode (mode_t input)
{
const mode_t mask = ~S_IRWXUGO & ~S_IFMT;
return input & mask;
}
/* Return true if copy of file SRC_NAME to file DEST_NAME is necessary. */
static bool
need_copy (const char *src_name, const char *dest_name,
const struct cp_options *x)
{
struct stat src_sb, dest_sb;
int src_fd, dest_fd;
bool content_match;
if (extra_mode (mode))
return true;
/* compare files using stat */
if (lstat (src_name, &src_sb) != 0)
return true;
if (lstat (dest_name, &dest_sb) != 0)
return true;
if (!S_ISREG (src_sb.st_mode) || !S_ISREG (dest_sb.st_mode)
|| extra_mode (src_sb.st_mode) || extra_mode (dest_sb.st_mode))
return true;
if (src_sb.st_size != dest_sb.st_size
|| (dest_sb.st_mode & CHMOD_MODE_BITS) != mode
|| dest_sb.st_uid != (owner_id == (uid_t) -1 ? getuid () : owner_id)
|| dest_sb.st_gid != (group_id == (gid_t) -1 ? getgid () : group_id))
return true;
/* compare SELinux context if preserving */
if (selinux_enabled && x->preserve_security_context)
{
security_context_t file_scontext = NULL;
security_context_t to_scontext = NULL;
bool scontext_match;
if (getfilecon (src_name, &file_scontext) == -1)
return true;
if (getfilecon (dest_name, &to_scontext) == -1)
{
freecon (file_scontext);
return true;
}
scontext_match = STREQ (file_scontext, to_scontext);
freecon (file_scontext);
freecon (to_scontext);
if (!scontext_match)
return true;
}
/* compare files content */
src_fd = open (src_name, O_RDONLY | O_BINARY);
if (src_fd < 0)
return true;
dest_fd = open (dest_name, O_RDONLY | O_BINARY);
if (dest_fd < 0)
{
close (src_fd);
return true;
}
content_match = have_same_content (src_fd, dest_fd);
close (src_fd);
close (dest_fd);
return !content_match;
}
static void
cp_option_init (struct cp_options *x)
{
@@ -183,8 +289,10 @@ cp_option_init (struct cp_options *x)
x->preserve_links = false;
x->preserve_mode = false;
x->preserve_timestamps = false;
x->reduce_diagnostics=false;
x->require_preserve = false;
x->require_preserve_context = false;
x->require_preserve_xattr = false;
x->recursive = false;
x->sparse_mode = SPARSE_AUTO;
x->symbolic_link = false;
@@ -200,6 +308,7 @@ cp_option_init (struct cp_options *x)
x->open_dangling_dest_symlink = false;
x->update = false;
x->preserve_security_context = false;
x->preserve_xattr = false;
x->verbose = false;
x->dest_info = NULL;
x->src_info = NULL;
@@ -360,7 +469,7 @@ main (int argc, char **argv)
we'll actually use backup_suffix_string. */
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pt:TvS:Z:", long_options,
while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z:", long_options,
NULL)) != -1)
{
switch (optc)
@@ -372,6 +481,9 @@ main (int argc, char **argv)
break;
case 'c':
break;
case 'C':
copy_only_if_needed = true;
break;
case 's':
strip_files = true;
#ifdef SIGCHLD
@@ -528,6 +640,24 @@ main (int argc, char **argv)
error (0, 0, _("WARNING: ignoring --strip-program option as -s option was "
"not specified"));
if (copy_only_if_needed && x.preserve_timestamps)
{
error (0, 0, _("options --compare (-C) and --preserve-timestamps are "
"mutually exclusive"));
usage (EXIT_FAILURE);
}
if (copy_only_if_needed && strip_files)
{
error (0, 0, _("options --compare (-C) and --strip are mutually "
"exclusive"));
usage (EXIT_FAILURE);
}
if (copy_only_if_needed && extra_mode (mode))
error (0, 0, _("the --compare (-C) option is ignored when you"
" specify a mode with non-permission bits"));
get_ids ();
if (dir_arg)
@@ -644,6 +774,9 @@ copy_file (const char *from, const char *to, const struct cp_options *x)
{
bool copy_into_self;
if (copy_only_if_needed && !need_copy (from, to, x))
return true;
/* Allow installing from non-regular files like /dev/null.
Charles Karney reported that some Sun version of install allows that
and that sendmail's installation process relies on the behavior.
@@ -816,6 +949,12 @@ Usage: %s [OPTION]... [-T] SOURCE DEST\n\
"),
program_name, program_name, program_name, program_name);
fputs (_("\
\n\
This install program copies files (often just compiled) into destination\n\
locations you choose. If you want to download and install a ready-to-use\n\
package on a GNU/Linux system, you should instead be using a package manager\n\
like yum(1) or apt-get(1).\n\
\n\
In the first three forms, copy SOURCE to DEST or multiple SOURCE(s) to\n\
the existing DIRECTORY, while setting permission modes and owner/group.\n\
In the 4th form, create all components of the given DIRECTORY(ies).\n\
@@ -828,6 +967,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
--backup[=CONTROL] make a backup of each existing destination file\n\
-b like --backup but does not accept an argument\n\
-c (ignored)\n\
-C, --compare compare each pair of source and destination files, and\n\
in some cases, do not modify the destination at all\n\
-d, --directory treat all arguments as directory names; create all\n\
components of the specified directories\n\
"), stdout);

View File

@@ -24,7 +24,6 @@
#include "system.h"
#include "error.h"
#include "hard-locale.h"
#include "linebuffer.h"
#include "memcasecmp.h"
#include "quote.h"

View File

@@ -1,5 +1,5 @@
/* `ln' program to create links between files.
Copyright (C) 1986, 1989-1991, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 1986, 1989-1991, 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
@@ -359,7 +359,9 @@ In the 1st form, create a link to TARGET with the name LINK_NAME.\n\
In the 2nd form, create a link to TARGET in the current directory.\n\
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.\n\
Create hard links by default, symbolic links with --symbolic.\n\
When creating hard links, each TARGET must exist.\n\
When creating hard links, each TARGET must exist. Symbolic links\n\
can hold arbitrary text; if later resolved, a relative link is\n\
interpreted in relation to its parent directory.\n\
\n\
"), stdout);
fputs (_("\

140
src/ls.c
View File

@@ -1,5 +1,5 @@
/* `dir', `vdir' and `ls' directory listing programs for GNU.
Copyright (C) 85, 88, 90, 91, 1995-2008 Free Software Foundation, Inc.
Copyright (C) 85, 88, 90, 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
@@ -87,17 +87,14 @@
#include "acl.h"
#include "argmatch.h"
#include "dev-ino.h"
#include "dirfd.h"
#include "error.h"
#include "filenamecat.h"
#include "hard-locale.h"
#include "hash.h"
#include "human.h"
#include "filemode.h"
#include "filevercmp.h"
#include "idcache.h"
#include "ls.h"
#include "lstat.h"
#include "mbswidth.h"
#include "mpsort.h"
#include "obstack.h"
@@ -156,6 +153,12 @@ verify (sizeof filetype_letter - 1 == arg_directory + 1);
C_LINK, C_SOCK, C_FILE, C_DIR \
}
enum acl_type
{
ACL_T_NONE,
ACL_T_SELINUX_ONLY,
ACL_T_YES
};
struct fileinfo
{
@@ -184,7 +187,7 @@ struct fileinfo
/* For long listings, true if the file has an access control list,
or an SELinux security context. */
bool have_acl;
enum acl_type acl_type;
};
#define LEN_STR_PAIR(s) sizeof (s) - 1, s
@@ -213,7 +216,8 @@ static uintmax_t gobble_file (char const *name, enum filetype type,
ino_t inode, bool command_line_arg,
char const *dirname);
static bool print_color_indicator (const char *name, mode_t mode, int linkok,
bool stat_ok, enum filetype type);
bool stat_ok, enum filetype type,
nlink_t nlink);
static void put_indicator (const struct bin_str *ind);
static void add_ignore_pattern (const char *pattern);
static void attach (char *dest, const char *dirname, const char *name);
@@ -227,18 +231,21 @@ static size_t calculate_columns (bool by_columns);
static void print_current_files (void);
static void print_dir (char const *name, char const *realname,
bool command_line_arg);
static void print_file_name_and_frills (const struct fileinfo *f);
static size_t print_file_name_and_frills (const struct fileinfo *f,
size_t start_col);
static void print_horizontal (void);
static int format_user_width (uid_t u);
static int format_group_width (gid_t g);
static void print_long_format (const struct fileinfo *f);
static void print_many_per_line (void);
static void print_name_with_quoting (const char *p, mode_t mode,
int linkok, bool stat_ok,
enum filetype type,
struct obstack *stack);
static size_t print_name_with_quoting (const char *p, mode_t mode,
int linkok, bool stat_ok,
enum filetype type,
struct obstack *stack,
nlink_t nlink,
size_t start_col);
static void prep_non_filename_text (void);
static void print_type_indicator (bool stat_ok, mode_t mode,
static bool print_type_indicator (bool stat_ok, mode_t mode,
enum filetype type);
static void print_with_commas (void);
static void queue_directory (char const *name, char const *realname,
@@ -517,14 +524,15 @@ enum indicator_no
C_LEFT, C_RIGHT, C_END, C_RESET, C_NORM, C_FILE, C_DIR, C_LINK,
C_FIFO, C_SOCK,
C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC, C_DOOR, C_SETUID, C_SETGID,
C_STICKY, C_OTHER_WRITABLE, C_STICKY_OTHER_WRITABLE, C_CAP
C_STICKY, C_OTHER_WRITABLE, C_STICKY_OTHER_WRITABLE, C_CAP, C_HARDLINK,
C_CLR_TO_EOL
};
static const char *const indicator_name[]=
{
"lc", "rc", "ec", "rs", "no", "fi", "di", "ln", "pi", "so",
"bd", "cd", "mi", "or", "ex", "do", "su", "sg", "st",
"ow", "tw", "ca", NULL
"ow", "tw", "ca", "hl", "cl", NULL
};
struct color_ext_type
@@ -557,7 +565,9 @@ static struct bin_str color_indicator[] =
{ LEN_STR_PAIR ("37;44") }, /* st: sticky: black on blue */
{ LEN_STR_PAIR ("34;42") }, /* ow: other-writable: blue on green */
{ LEN_STR_PAIR ("30;42") }, /* tw: ow w/ sticky: black on green */
{ LEN_STR_PAIR ("30;41") }, /* capability: black on red */
{ LEN_STR_PAIR ("30;41") }, /* ca: black on red */
{ LEN_STR_PAIR ("44;37") }, /* hl: white on blue */
{ LEN_STR_PAIR ("\033[K") }, /* cl: clear to end of line */
};
/* FIXME: comment */
@@ -715,11 +725,14 @@ static int exit_status;
/* Exit statuses. */
enum
{
/* "ls" had a minor problem (e.g., it could not stat a directory
entry). */
/* "ls" had a minor problem. E.g., while processing a directory,
ls obtained the name of an entry via readdir, yet was later
unable to stat that name. This happens when listing a directory
in which entries are actively being removed or renamed. */
LS_MINOR_PROBLEM = 1,
/* "ls" had more serious trouble. */
/* "ls" had more serious trouble (e.g., memory exhausted, invalid
option or failure to stat a command line argument. */
LS_FAILURE = 2
};
@@ -1760,7 +1773,7 @@ decode_switches (int argc, char **argv)
case FULL_TIME_OPTION:
format = long_format;
time_style_option = "full-iso";
time_style_option = bad_cast ("full-iso");
break;
case COLOR_OPTION:
@@ -1878,7 +1891,7 @@ decode_switches (int argc, char **argv)
if (! style)
if (! (style = getenv ("TIME_STYLE")))
style = "locale";
style = bad_cast ("locale");
while (strncmp (style, posix_prefix, sizeof posix_prefix - 1) == 0)
{
@@ -2688,6 +2701,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
if (format == long_format || print_scontext)
{
bool have_selinux = false;
bool have_acl = false;
int attr_len = (do_deref
? getfilecon (absolute_name, &f->scontext)
@@ -2706,7 +2720,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
}
if (err == 0)
have_acl = ! STREQ ("unlabeled", f->scontext);
have_selinux = ! STREQ ("unlabeled", f->scontext);
else
{
f->scontext = UNKNOWN_SECURITY_CONTEXT;
@@ -2719,15 +2733,19 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
err = 0;
}
if (err == 0 && ! have_acl && format == long_format)
if (err == 0 && format == long_format)
{
int n = file_has_acl (absolute_name, &f->stat);
err = (n < 0);
have_acl = (0 < n);
}
f->have_acl = have_acl;
any_has_acl |= have_acl;
f->acl_type = (!have_selinux && !have_acl
? ACL_T_NONE
: (have_selinux && !have_acl
? ACL_T_SELINUX_ONLY
: ACL_T_YES));
any_has_acl |= f->acl_type != ACL_T_NONE;
if (err)
error (0, errno, "%s", quotearg_colon (absolute_name));
@@ -3271,7 +3289,7 @@ print_current_files (void)
case one_per_line:
for (i = 0; i < cwd_n_used; i++)
{
print_file_name_and_frills (sorted_file[i]);
print_file_name_and_frills (sorted_file[i], 0);
putchar ('\n');
}
break;
@@ -3448,7 +3466,9 @@ print_long_format (const struct fileinfo *f)
}
if (! any_has_acl)
modebuf[10] = '\0';
else if (f->have_acl)
else if (f->acl_type == ACL_T_SELINUX_ONLY)
modebuf[10] = '.';
else if (f->acl_type == ACL_T_YES)
modebuf[10] = '+';
switch (time_type)
@@ -3621,8 +3641,9 @@ print_long_format (const struct fileinfo *f)
}
DIRED_FPUTS (buf, stdout, p - buf);
print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), f->linkok,
f->stat_ok, f->filetype, &dired_obstack);
size_t w = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), f->linkok,
f->stat_ok, f->filetype, &dired_obstack,
f->stat.st_nlink, p - buf);
if (f->filetype == symbolic_link)
{
@@ -3630,7 +3651,8 @@ print_long_format (const struct fileinfo *f)
{
DIRED_FPUTS_LITERAL (" -> ", stdout);
print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1,
f->stat_ok, f->filetype, NULL);
f->stat_ok, f->filetype, NULL,
f->stat.st_nlink, (p - buf) + w + 4);
if (indicator_style != none)
print_type_indicator (true, f->linkmode, unknown);
}
@@ -3664,7 +3686,6 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
if (qmark_funny_chars)
{
#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
{
char const *p = buf;
@@ -3704,7 +3725,7 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
reach its end, replacing each non-printable multibyte
character with a single question mark. */
{
mbstate_t mbstate = { 0, };
DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate);
do
{
wchar_t wc;
@@ -3767,7 +3788,6 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
len = q - buf;
}
else
#endif
{
char *p = buf;
char const *plimit = buf + len;
@@ -3783,11 +3803,9 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
}
else if (width != NULL)
{
#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
displayed_width = mbsnwidth (buf, len, 0);
else
#endif
{
char const *p = buf;
char const *plimit = buf + len;
@@ -3809,19 +3827,21 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
return len;
}
static void
static size_t
print_name_with_quoting (const char *p, mode_t mode, int linkok,
bool stat_ok, enum filetype type,
struct obstack *stack)
struct obstack *stack, nlink_t nlink,
size_t start_col)
{
bool used_color_this_time
= (print_with_color
&& print_color_indicator (p, mode, linkok, stat_ok, type));
&& print_color_indicator (p, mode, linkok, stat_ok, type, nlink));
if (stack)
PUSH_CURRENT_DIRED_POS (stack);
dired_pos += quote_name (stdout, p, filename_quoting_options, NULL);
size_t width = quote_name (stdout, p, filename_quoting_options, NULL);
dired_pos += width;
if (stack)
PUSH_CURRENT_DIRED_POS (stack);
@@ -3830,7 +3850,11 @@ print_name_with_quoting (const char *p, mode_t mode, int linkok,
{
process_signals ();
prep_non_filename_text ();
if (start_col / line_length != (start_col + width - 1) / line_length)
put_indicator (&color_indicator[C_CLR_TO_EOL]);
}
return width;
}
static void
@@ -3850,8 +3874,8 @@ prep_non_filename_text (void)
Also print file size, inode number, and filetype indicator character,
as requested by switches. */
static void
print_file_name_and_frills (const struct fileinfo *f)
static size_t
print_file_name_and_frills (const struct fileinfo *f, size_t start_col)
{
char buf[MAX (LONGEST_HUMAN_READABLE + 1, INT_BUFSIZE_BOUND (uintmax_t))];
@@ -3867,11 +3891,14 @@ print_file_name_and_frills (const struct fileinfo *f)
if (print_scontext)
printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext);
print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), f->linkok,
f->stat_ok, f->filetype, NULL);
size_t width = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f),
f->linkok, f->stat_ok, f->filetype,
NULL, f->stat.st_nlink, start_col);
if (indicator_style != none)
print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
width += print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
return width;
}
/* Given these arguments describing a file, return the single-byte
@@ -3908,12 +3935,13 @@ get_type_indicator (bool stat_ok, mode_t mode, enum filetype type)
return c;
}
static void
static bool
print_type_indicator (bool stat_ok, mode_t mode, enum filetype type)
{
char c = get_type_indicator (stat_ok, mode, type);
if (c)
DIRED_PUTCHAR (c);
return !!c;
}
#ifdef HAVE_CAP
@@ -3941,7 +3969,7 @@ has_capability (char const *name)
}
#else
static bool
has_capability (char const *name)
has_capability (char const *name ATTRIBUTE_UNUSED)
{
return false;
}
@@ -3950,7 +3978,8 @@ has_capability (char const *name)
/* Returns whether any color sequence was printed. */
static bool
print_color_indicator (const char *name, mode_t mode, int linkok,
bool stat_ok, enum filetype filetype)
bool stat_ok, enum filetype filetype,
nlink_t nlink)
{
int type;
struct color_ext_type *ext; /* Color extension */
@@ -3974,10 +4003,12 @@ print_color_indicator (const char *name, mode_t mode, int linkok,
type = C_SETUID;
else if ((mode & S_ISGID) != 0)
type = C_SETGID;
else if (has_capability (name))
else if (is_colored (C_CAP) && has_capability (name))
type = C_CAP;
else if ((mode & S_IXUGO) != 0)
type = C_EXEC;
else if (1 < nlink)
type = C_HARDLINK;
}
else if (S_ISDIR (mode))
{
@@ -4112,7 +4143,7 @@ print_many_per_line (void)
struct fileinfo const *f = sorted_file[filesno];
size_t name_length = length_of_file_name_and_frills (f);
size_t max_name_length = line_fmt->col_arr[col++];
print_file_name_and_frills (f);
print_file_name_and_frills (f, pos);
filesno += rows;
if (filesno >= cwd_n_used)
@@ -4137,7 +4168,7 @@ print_horizontal (void)
size_t max_name_length = line_fmt->col_arr[0];
/* Print first entry. */
print_file_name_and_frills (f);
print_file_name_and_frills (f, 0);
/* Now the rest. */
for (filesno = 1; filesno < cwd_n_used; ++filesno)
@@ -4156,7 +4187,7 @@ print_horizontal (void)
}
f = sorted_file[filesno];
print_file_name_and_frills (f);
print_file_name_and_frills (f, pos);
name_length = length_of_file_name_and_frills (f);
max_name_length = line_fmt->col_arr[col];
@@ -4194,7 +4225,7 @@ print_with_commas (void)
putchar (separator);
}
print_file_name_and_frills (f);
print_file_name_and_frills (f, pos);
pos += len;
}
putchar ('\n');
@@ -4472,7 +4503,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
fputs (_("\
-r, --reverse reverse order while sorting\n\
-R, --recursive list subdirectories recursively\n\
-s, --size print the size of each file, in blocks\n\
-s, --size print the allocated size of each file, in blocks\n\
"), stdout);
fputs (_("\
-S sort by file size\n\
@@ -4527,7 +4558,10 @@ colors, and can be set easily by the dircolors command.\n\
"), stdout);
fputs (_("\
\n\
Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble.\n\
Exit status:\n\
0 if OK,\n\
1 if minor problems (e.g., cannot access subdirectory),\n\
2 if serious trouble (e.g., cannot access command-line argument).\n\
"), stdout);
emit_bug_reporting_address ();
}

View File

@@ -37,6 +37,7 @@
#endif
#include "error.h"
#include "stdio--.h"
#include "xfreopen.h"
/* The official name of this program (e.g., no `g' prefix). */
#if HASH_ALGO_MD5
@@ -391,7 +392,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result)
if (*binary < 0)
*binary = ! isatty (STDIN_FILENO);
if (*binary)
freopen (NULL, "rb", stdin);
xfreopen (NULL, "rb", stdin);
}
}
else
@@ -685,7 +686,7 @@ main (int argc, char **argv)
binary = 0;
if (optind == argc)
argv[argc++] = "-";
argv[argc++] = bad_cast ("-");
for (; optind < argc; ++optind)
{

View File

@@ -24,7 +24,6 @@
#include "system.h"
#include "error.h"
#include "lchmod.h"
#include "mkdir-p.h"
#include "modechange.h"
#include "prog-fprintf.h"

Some files were not shown because too many files have changed in this diff Show More