Compare commits

...

303 Commits
v8.4 ... v8.6

Author SHA1 Message Date
Jim Meyering
7612e5c5c6 version 8.6
* NEWS: Record release date.
2010-10-15 16:50:15 +02:00
Jim Meyering
ff8d38e100 build: update gnulib for vasnprintf fix 2010-10-15 07:49:54 +02:00
Paul Eggert
6b9ab1831f bug#7213: [PATCH] sort: fix buffer overrun on 32-bit hosts when warning re obsolete keys
* src/sort.c (key_warnings): Local buffer should be of size
INT_BUFSIZE_BOUND (uintmax_t), not INT_BUFSIZE_BOUND (sword).
This bug was discovered by running 'make check' on a 32-bit
Solaris 8 sparc host, using Sun cc.  I saw several other instances
of invoking umaxtostr on a buffer declared to be of size
INT_BUFSIZE_BOUND (VAR), and these instances should at some point
be replaced by INT_BUFSIZE_BOUND (uintmax_t) too, as that's a
less error-prone style.
2010-10-14 11:39:14 +02:00
Paul Eggert
7324fba675 tests: work around portability and clock-skew problems
* tests/misc/ls-misc (push_ls_colors): Don't assume LS_COLORS
is set.  This part of the fix is by Jim Meyering.
(sl-dangle2, sl-dangle3, sl-dangle4, sl-dangle5): Don't assume
that newly-created files will have time stamps in the past.  They
might not, due to clock skew, if the file systems are remote.
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/21322/focus=21346
2010-10-14 09:23:51 +02:00
Paul Eggert
c586bff1c0 install: avoid warning with Solaris 10 cc
* src/install.c (extra_mode): Don't assign ~S_IRWXUGO & ~S_IFMT
to a mode_t variable, as the number might be too big to fit.
Solaris 10 cc warns about this, and the C standard says it
has undefined behavior.
2010-10-13 22:41:21 -07:00
Paul Eggert
4015f93d30 mbsalign: avoid warning with Solaris 10 cc
* gl/lib/mbsalign.c: Include <stdint.h> for SIZE_MAX.
Use SIZE_MAX rather than (size_t) -1, to avoid warning for
"size_t x = -1" on Solaris 10 cc.
* gl/modules/mbsalign (Depends-on): Add stdint.
2010-10-13 22:41:17 -07:00
Paul Eggert
34ef0a01f0 sort: fix unportable cast of unsigned char * -> char *
* src/sort.c (fold_toupper): Change this back from char to
unsigned char, fixing a portability issue introduced in commit
59e2e55d0f dated February 26, as the
C Standard doesn't let you convert from unsigned char * to char *
without a cast, and the (in theory more portable) style here is to
convert char values, not pointer values.
(getmonth): Convert char to unsigned char when needed for
comparison.
2010-10-13 22:41:13 -07:00
Jim Meyering
71a3fd73a1 build: prepare to enable -Werror also for gnulib-tests/
* configure.ac (GNULIB_WARN_CFLAGS): Define new variable, for use
in gnulib-tests.
* gnulib-tests/Makefile.am: Disable specific -W___ options,
but only for a few specific offending tests:
(test_xvasprintf_CFLAGS): Define.
(test_lock_CFLAGS, test_tls_CFLAGS): Define.
2010-10-13 11:20:18 +02:00
Paul Eggert
9300fffcb5 tests: fix rand-isaac test
* gl/tests/test-rand-isaac.c (main): Fix swapped arguments to strtol.
2010-10-13 09:03:41 +02:00
Pádraig Brady
61b77891c2 tail: fix checking of currently unavailable directories
* src/tail.c (tail_forever_inotify): Handle the case where
tail --follow=name with inotify, is not able to add a watch on
a specified directory.  This may happen due to inotify resource
limits or if the directory is currently missing or inaccessible.
In all these cases, revert to polling which will try to reopen
the file later.  Note inotify returns ENOSPC when it runs out
of resources, and instead we report a particular error message,
lest users think one of their file systems is full.
(main): Document another caveat with using inotify, where we
currently don't recheck directories recreated after the
initial watch is setup.
* tests/tail-2/F-vs-rename: Fix the endless loop triggered by
the above issue.
* tests/tail-2/inotify-hash-abuse: Likewise.
* tests/tail-2/wait: Don't fail in the resource exhaustion case.
* tests/tail-2/F-vs-missing: A new test for this failure mode
which was until now just triggered on older buggy linux kernels
which returned ENOSPC constantly from inotify_add_watch().
* NEWS: Mention the fix.
2010-10-12 11:41:17 +01:00
Jim Meyering
9f4744534f build: update gnulib to latest; to fix failing Solaris 5.11 test 2010-10-11 22:41:12 +02:00
Jim Meyering
938435ee30 maint: add new file: .mailmap
* .mailmap: Map git author names and email addresses to
canonical/preferred form.  This file is used e.g., by "git shortlog".
2010-10-11 19:50:44 +02:00
Jim Meyering
9af44d937e build: update gnulib, to fix OpenBSD test failures 2010-10-08 22:15:15 +02:00
Jim Meyering
fdfc5cf0c1 build: update gnulib to latest; for parse-datetime.y fix 2010-10-08 08:15:34 +02:00
Jim Meyering
ab9d2d2d46 build: update gnulib to latest, to avoid FreeBSD compilation failure:
http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/23501
2010-10-08 08:15:34 +02:00
Pádraig Brady
758916b49e split: fix reporting of read errors
The bug was introduced with commit 23f6d41f, 19-02-2003.

* src/split.c (bytes_split, lines_split, line_bytes_split):
Correctly check the return from full_read().
* tests/misc/split-fail: Ensure split fails when
it can't read its input.
* NEWS: Mention the fix.
2010-10-07 20:08:16 +01:00
Jim Meyering
6483f0e1bd build: update gnulib to latest, for memmem/strstr fix 2010-10-06 09:31:21 +02:00
Jim Meyering
61d1c5cb3c maint: describe coreutils' policy on copyright year number ranges
* README: Mention coreutils' long-standing policy on use of M-N
ranges in copyright year lists.  Requested by Richard Stallman.
2010-10-06 00:38:25 +02:00
Eric Blake
2f41f563d1 build: complete the rename of get_date
* gnulib: Update to latest.
* src/date.c (includes, batch_convert, main): Track rename.
* src/touch.c (includes, get_reldate): Likewise.
* doc/coreutils.texi (Top, Date input formats): Likewise.
* bootstrap.conf (gnulib_modules): Likewise.
* doc/Makefile.am (EXTRA_DIST): Likewise.
* doc/.gitignore: Likewise.
* bootstrap: Synchronize from upstream.
2010-10-05 12:12:30 -06:00
Eric Blake
b7459696dc stat: drop %C support when printing file system details
* src/stat.c (print_statfs, usage): Drop %C, since it applies to
files, not file systems.
(out_file_context): Match style of other out_* functions.
(print_stat): Update caller.
* doc/coreutils.texi (stat invocation): Document %C.
* NEWS: Document the change.
2010-10-05 09:07:58 -06:00
Eric Blake
4c286d341a build: fix build on Solaris 10
* gnulib: Update to latest, for reduced -lgen scope.
* bootstrap: Synchronize from upstream.
Reported by Clemens Brogi, as bug #7142.
2010-10-05 08:38:22 -06:00
Pádraig Brady
77063bf819 stat: adjust the printing of SELinux context
* src/stat.c (default_format): Don't print SELinux context
when in file system (-f) mode, as the context is associated
with the file, not the file system.
Fix logic inversion, so that in terse mode, %C is included
only when is_selinux_enabled and not vice versa.
2010-10-05 11:00:10 +01:00
Pádraig Brady
6ad89f2233 tests: refactor the stat-birthtime test to use retry_delay_
* tests/misc/stat-birthtime: This recently added test
fits the pattern of requiring a delay to pass, so get
it to use retry_delay_()
2010-10-04 16:54:22 +01:00
Jim Meyering
2006aeba9d maint: add a release prerequisite: check the NixOS/Hydra autobuilder
* README-release: Add a note to check the autobuilder.
2010-10-03 20:48:53 +02:00
Jim Meyering
c333ff1b0c build: update gnulib submodule to latest 2010-10-03 20:42:41 +02:00
Jim Meyering
5862b677f1 maint: suppress a bogus used-uninitialized warning in tr.c
* src/tr.c (string2_extend): Insert an abort call to tell
gcc that char_to_repeat is not used uninitialized.
2010-10-03 20:42:41 +02:00
Eric Blake
d4f304d721 tests: output --version of program under test
This touches all new tests added since commit b062bbd9, when
init.cfg was added.  Older tests still exist that could use
conversion, but we can address those later.

* tests/sample-test: Restore hint for --version output.
* tests/misc/stat-birthtime: Include --version if verbose.
* tests/misc/tr-case-class: Likewise.
* tests/misc/stat-mount: Likewise.
* tests/misc/sort-unique: Likewise.
* tests/misc/sort-benchmark-random: Likewise.
Suggested by Jim Meyering.
2010-10-01 15:43:23 -06:00
Eric Blake
7a5ecae996 stat: print SELinux context when available
* src/stat.c (default_format): Include context when present.
* NEWS: Update blurb explaining the replacement for -Z.
2010-10-01 15:27:27 -06:00
Eric Blake
2c14ec962a stat: optimize and translate default format strings
Yes, this patch intentionally leaks the results of default_format(),
since it is called only twice, and since the results are in scope
until main() exits.  Not worth the extra code to pacify valgrind.

* src/stat.c (main): Hoist default format computation out of loop.
(do_statfs, do_stat): Move default format generation...
(default_format): ...into new function.  Allocate the result in
pieces, rather than repeating mostly-similar chunks.  Allow
translation of verbose format.  Pass a second format to do_stat,
for the one aspect of the default format that is conditional on
file type.
* NEWS: Document the translation aspect.
2010-10-01 15:24:39 -06:00
Eric Blake
9069af45e6 stat: print timestamps to full resolution
* src/stat.c (epoch_time): New function.
(print_stat): Use it for %[WXYZ].
* NEWS: Document this.
* tests/touch/60-seconds: Adjust test to match.
* tests/misc/stat-birthtime: Likewise.
2010-10-01 10:43:41 -06:00
Eric Blake
abe5c1f9bc stat: support printing birthtime
* src/stat.c (print_stat): New %w and %W formats.
(do_stat): Include %w in default format.
(usage): Document new specifiers.
* doc/coreutils.texi (stat invocation): Likewise.
* NEWS: Likewise.
2010-10-01 10:43:25 -06:00
Eric Blake
1129cb58ba maint: update sample test template
* tests/sample-test: Recommend modern idiom.
2010-10-01 10:20:39 -06:00
Pádraig Brady
288bfea72c maint: ensure the mbsalign module is C89 compatible
This module may be moved to gnulib at some stage,
so keep it C89 compatible.

* gl/lib/mbsalign.c (mbsalign): Declare variables at start of scope
(ambsalign): Likewise
* gl/lib/mbsalign.h: Remove trailing comma from enum
Reported by Andrei Suhan
2010-10-01 16:30:31 +01:00
Eric Blake
6067d05228 maint: update gnulib
* gnulib: Update to latest.
* doc/coreutils.texi (date): Reflect new module name.
* doc/Makefile.am (EXTRA_DIST): Likewise.
* doc/.gitignore: Likewise.
2010-09-30 15:57:19 -06:00
Eric Blake
68062ca607 maint: update gnulib
* gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Reflect new module name.
* bootstrap: Resync from upstream.
2010-09-30 15:29:07 -06:00
Jim Meyering
65b50c6cdd maint: mention the du-exclude--vs--cycle-dir fix
* NEWS (Bug fixes): Mention the du-exclude--vs--cycle-dir fix.
Reported by Graham Cobb in http://bugs.debian.org/598438,
that bug was fixed by the 2010-07-24 commit, 77428214f,
"du: tune, and fix some -L bugs with dangling or cyclic symlinks"
2010-09-30 14:24:42 +02:00
Jim Meyering
724e993104 build: update gnulib submodule to latest 2010-09-29 16:27:15 +02:00
Pádraig Brady
3f48829c29 tr: fix various issues with case conversion
This valid translation spec aborted:
  LC_ALL=en_US.iso-8859-1 tr '[:upper:]- ' '[:lower:]_'
This invalid translation spec aborted:
  LC_ALL=en_US.iso-8859-1 tr '[:upper:] '  '[:lower:]'
This was caused by commit 6efd1046, 05-01-2008,
"Avoid tr case-conversion failure in some locales"

This misaligned conversion spec was allowed:
  LC_ALL=C tr 'A-Y[:lower:]' 'a-z[:upper:]'
This was caused by commit af5d0c36, 21-10-2007,
"tr: do not reject an unmatched [:lower:] or [:upper:] in SET1"

This misaligned spec was allowed by extending the class:
  LC_ALL=C tr '[:upper:] ' '[:lower:]'

* src/tr.c (validate_case_classes): A new function to check
alignment of case conversion classes.  Also it adjusts the
length of the sets so that locales with different numbers of
upper and lower case characters, don't cause issues.
(string2_extend): Disallow extending the case conversion
class as in the above example.  That is locale dependent
and most likely not what the user wants.
(validate): Do the simple test for "restricted" char classes
earlier, so we don't redundantly do more expensive validation.
(main): Remove the case class validation, and simplify.
* tests/misc/tr-case-class: A new test to test the various
alignment and locale issues, associated with case conversion.
* tests/misc/tr: Move case conversion tests to new tr-case-class.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the fixes.
2010-09-29 11:05:12 +01:00
Paul Eggert
704eedab03 build: update gnulib submodule to latest 2010-09-20 16:28:00 -07:00
Paul Eggert
9065006ccb sort: destroy spin locks portably
* src/sort.c (sortlines, sort): Use pthread_spin_destroy when a
spin lock is no longer used.  This isn't needed on GNU/Linux or
Solaris, but POSIX says it may free up resources on some platforms.
2010-09-20 15:45:49 -07:00
Pádraig Brady
4727aab1b1 tests: fix a printf portability issue
* tests/misc/sort-debug-keys: Don't depend on
printf supporting \xhh format, which isn't supported
by dash for example.  Also change from double quoted
strings to single quoted, when we don't need any
variable interpolation.
2010-09-20 15:23:20 +01:00
Pádraig Brady
f57cb371fa tests: fix an erroneous stat failure with bind mounts
* tests/misc/stat-mount: Don't try to correlate the
mount points output by df and stat, as they're similar,
but sometimes different in the presence of bind mounts.
* doc/coretuils.texi (stat invocation): Clarify the
bind mount difference between stat and df.
2010-09-20 15:07:02 +01:00
Jim Meyering
0a238bcb87 build: update gnulib submodule to latest 2010-09-18 22:35:04 +02:00
Jim Meyering
390133df25 tests: sync tests/init.sh from gnulib
* tests/init.sh: Update from gnulib.
2010-09-18 21:32:18 +02:00
Jim Meyering
c12d83920f build: use gnulib's new termios module
With it, we can remove the two sole tests of HAVE_TERMIOS_H.
* bootstrap.conf (gnulib_modules): Add termios.
* src/ls.c: Don't test HAVE_TERMIOS_H.
* src/stty.c: Likewise.
* m4/jm-macros.m4 (gl_CHECK_ALL_TYPES): Remove configure-time
test for termios.h.
2010-09-18 21:32:18 +02:00
Jim Meyering
edc69f9158 maint: don't use obsolete gnulib modules
* bootstrap.conf (gnulib_modules): Use calloc-gnu, malloc-gnu
and realloc-gnu modules, rather than calloc, malloc and realloc.
The shorter-named modules are now deprecated.
(obsolete_gnulib_modules): Remove.
(gnulib_modules): Remove raise, strbprk; they're obsolete, too.
Move strtod, strtol here, from obsolete_gnulib_modules.
2010-09-18 21:22:36 +02:00
Eric Blake
2dd21704d6 maint: update to latest gnulib
* gnulib: Update to latest.
* src/copy.c (copy_reg): Use fdutimens instead of gl_futimens.
* src/touch.c (touch): Adjust parameter order.
* tests/init.sh: Resync from upstream.
2010-09-17 15:57:49 -06:00
Eric Blake
95732b834e rm: remove no-op -d option
* src/rm.c (long_opts, main): Resolve a fixme.
* NEWS: Document the change.
Based on a report by William Plusnick.
2010-09-17 08:44:31 -06:00
Eric Blake
3bb942c426 maint: update to latest gnulib
* gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Add fdutimensat.
* src/touch.c (touch): Use fdutimensat instead of gl_futimens.
2010-09-17 08:42:52 -06:00
Dmitry V. Levin
42681e9e4d dircolors: add rxvt-unicode-256color terminal type
rxvt-unicode introduced new terminal type:
http://cvs.schmorp.de/rxvt-unicode/src/rxvt.h?r1=1.398&r2=1.399

* src/dircolors.hin: Add rxvt-unicode-256color terminal type.
Reported by Alexey I. Froloff in <http://bugzilla.altlinux.org/24052>.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2010-09-13 16:53:33 -06:00
Pádraig Brady
ea1b8bafc0 tests: work around a failure with dash 0.5.4
* tests/misc/env: Check that the shell can support
the operation, before filtering through `env`.
Note dash 0.5.5 is unaffected by this issue.
2010-09-07 17:33:16 +01:00
Pádraig Brady
c52d220c30 tests: make various timeouts more robust
* tests/init.cfg (retry_delay_): Describe
the backoff method used.
* tests/ls/readdir-mountpoint-inode: Add a timeout
to the stat call to eliminate the chance of hangups.
* tests/mv/i-3: Change the timeout required to pass
from 1 second to a range of .1s - 3.1s.
* tests/rm/dangling-symlink: Likewise.
2010-09-07 14:02:56 +01:00
Pádraig Brady
437671accc tests: exclude some tests when running on NFS
All tests currently pass on NFS on Linux kernel 2.6.22 at least,
but some fail on 2.6.9, so we exclude those here.

* tests/init.cfg (is_local_dir_): A new function
returning if the specified directory is on a local file system.
(require_local_dir_): A new function to skip tests
if the current directory is not on a local file system.
* tests/cp/existing-perm-race: Skip if non local.
* tests/cp/file-perm-race: Likewise.
* tests/cp/parent-perm: Likewise.
* tests/cp/parent-perm-race: Likewise.
* tests/cp/preserve-2: Likewise.
* tests/mv/part-symlink: Likewise.
* tests/du/basic: Use refactored function.
* tests/install/basic-1: Likewise.
* tests/mkdir/p-3: Likewise.
* tests/dd/skip-seek-past-dev: Likewise.
* tests/du/slink: Likewise.  Remove redundant test
for NFS file system.
* tests/misc/join: s/local/locale/.
2010-09-07 10:49:55 +01:00
Jim Meyering
0e295c88bc build: update gnulib submodule to latest 2010-09-04 18:17:57 +02:00
Jim Meyering
041c9c472a build: use gettext-h, not gettext
* bootstrap.conf (gnulib_modules): Use gettext-h, not gettext.
The latter is overkill for a package that uses
AM_GNU_GETTEXT([external]...
2010-09-04 14:24:57 +02:00
Jim Meyering
fc9d948d7e tac: suppress technically unneeded "free"
* src/tac.c (main): Guard final free with #ifdef lint.
Suggested by Paul Eggert.
2010-09-01 17:17:31 +02:00
Pádraig Brady
126d59542f join: improve performance when operating on whole lines
Following on from commit f86bb696, 01-02-2010,
"join: make -t '' operate on the whole line".
Bypassing the delimiter search in this case,
gives about an 8% performance boost.

* src/join (xfields): Don't bother looking for '\n'
in the data, which we know won't be present.
2010-09-01 16:12:45 +01:00
Jim Meyering
777024889c tac: avoid double free
* src/tac.c (main): Reading a line longer than 16KiB would cause
tac to realloc its primary buffer.  Then, just before exit, tac
would mistakenly free the original (now free'd) buffer.
This bug was introduced by commit be6c13e7, "maint: always free a
buffer, to avoid even semblance of a leak".
* NEWS (Bug fixes): Mention it.
* tests/misc/tac (double-free): New test, to exercise this.
Reported by Salvo Tomaselli in <http://bugs.debian.org/594666>.
2010-08-28 19:28:20 +02:00
Pádraig Brady
c984948ff5 doc: clarify that stat -f implies -L (follows symlinks)
* doc/coreutils.texi (stat invocation). Since there is
no lstatfs, document that -L is implicit with -f.
2010-08-27 22:28:44 +01:00
Aaron Burgemeister
ddf6fb8686 stat: add %m to output the mount point for a file
* src/find-mount-point.c: A new file refactoring
find_mount_point() out from df.c
* src/find-mount-point.h: Likewise.
* src/df.c: Use the new find-mount-point module.
* src/stat.c (print_stat): Handle the new %m format.
(find_bind_mount): A new function to
return the bind mount for a file if any.
(out_mount_mount): Print the bind mount for a file, or else
the standard mount point given by the find-mount-point module.
(usage): Document the %m format directive.
* src/Makefile.am: Reference the refactored find-mount-point.c
* po/POTFILES.in: Add find_mount_point.c to the translation list
* doc/coreutils.texi (stat invocation): Document %m,
and how it may differ from the mount point that df outputs.
* test/misc/stat-mount: A new test to correlate mount points
output from df and stat.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the new feature
* THANKS: Add the author

Signed-off-by: Pádraig Brady <P@draigBrady.com>
2010-08-27 22:16:10 +01:00
Eric Blake
872f6bb2ba maint: update to latest gnulib
* gnulib: Update to latest, to avoid warnings with latest autoconf.git.
2010-08-26 16:28:31 -06:00
Eric Blake
8ce8ac9de2 maint: avoid a hung 'make syntax-check' in VPATH build
* cfg.mk (sc_system_h_headers): Look for files in correct location.
2010-08-26 16:28:31 -06:00
Pádraig Brady
0380e4c98e df: always print the device name for bind mounted files
* src/df (show_point): Remove the optimization for comparing
the specified path with the device name, as this produces
inconsistent results in the presence of bind mounts.  For bind
mounts, the device name is populated with the bind mount target.
* NEWS: Mention the change in behavior.
2010-08-25 23:02:55 +01:00
Pádraig Brady
2ed90c4c9d stat: fix a small memory leak with %N
* src/stat.c (print_stat): Free the buffer returned
from areadlink_with_size().
2010-08-23 07:15:24 +01:00
Pádraig Brady
6d78c2df58 maint: exclude tests from the set_program_name syntax-check
* .x-sc_program_name: Exclude all current and future
c files in gl/tests from this check
* gl/tests/test-di-set.c: Remove the hack to work around
the set_program_name syntax-check
* gl/tests/test-ino-map.c: Likewise
* gl/tests/test-rand-isaac.c: Likewise
2010-08-15 01:15:51 +01:00
Ralf Wildenhues
4e01bd1dab doc: avoid a warning from newer texinfo
* doc/coreutils.texi (sort invocation): Use @pxref inside parentheses.
2010-08-15 01:11:35 +01:00
Bruno Haible
9e900e81db doc: improve the info on md5sum security weaknesses
* doc/coreutils.texi (md5sum invocation): Mention currently known
security problems. Don't recommend SHA-1 as alternative.
* man/md5sum.x (BUGS): Warn about the vulnerabilities and
reference the SHA-2 based alternatives.
Reported by Simon Josefsson
2010-08-15 01:02:44 +01:00
Paul Eggert
b5f9a6a176 * tests/misc/sort (use-nl): Fix comment to match the test case. 2010-08-13 15:57:52 -07:00
Paul Eggert
9899e6cd85 sort, who: prefer free+malloc to realloc when contents are irrelevant
This change was prompted by the previous one: I audited the code
looking for similar examples.  Too bad valgrind doesn't catch this.
* src/sort.c (check, mergefps): xrealloc -> free + xmalloc
* src/who.c (print_user): Likewise.
2010-08-10 20:25:56 -07:00
Paul Eggert
2050a5913b sort: free/xmalloc rather than xrealloc
* src/sort.c (compare_random): Use free/xmalloc rather than
xrealloc, since the old buffer contents need not be preserved.
Also, don't fail if the guessed-sized malloc fails.  Suggested by
Bruno Haible.
2010-08-10 13:49:57 -07:00
Eric Blake
7861d74ba8 build: update to latest gnulib
Fixes bug 6053 for NFS on HP-UX not recognizing ACL operations.

* gnulib: Update to latest version.
2010-08-10 09:44:28 -06:00
Jim Meyering
ec0d6ddb81 sort: avoid gcc warning: explicitly ignore strtold result
* src/sort.c: Include "ignore-value.h".
(debug_key): Use ignore_value.
2010-08-10 08:11:15 -07:00
Eric Blake
4e6bac4ca3 tests: silence 'make syntax-check'
* gl/tests/test-rand-isaac.c (main): Avoid warnings from
syntax-check.
2010-08-09 14:56:02 -06:00
Mike Frysinger
fbebc507da dircolors: add screen.rxvt & terminator to TERM list
Resolves bug#6793.
* src/dircolors.hin: Add screen.rxvt & terminator.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-08-09 11:32:04 -06:00
Dan Hipschman
24f1af88c7 ls: fix a test failure that should have been skipped
* tests/ls/readdir-mountpoint-inode: Check to see if skip_test_ is
called in a helper function via $() instead of mistakenly failing.
* THANKS: Update.
2010-08-09 08:52:12 -06:00
Paul Eggert
ad31a59a37 sort: speed up -R with long lines in hard locales
* src/sort.c (compare_random): Guess that the output will be
3X the input.  This avoids the overhead of calling strxfrm
twice on typical implementations.  Suggested by Bruno Haible.
2010-08-08 23:15:09 -07:00
Paul Eggert
b877ea4b3e sort: support all combinations of -d, -f, -i, -R, and -V
* NEWS: Document this.
* src/sort.c (getmonth): Omit LEN arg, as MONTH is now null-terminated.
(compare_random): Don't null-terminate keys, as caller now does that.
(compare_version): Remove.
(debug_key): Null-terminate string for getmonth.
(keycompare): Support combining -R with any of -d, -f, -i, -V.
Also, support combining -V with any of -d, -i.
(check_ordering_compatibility): Allow newly-supported combinations.
* tests/misc/sort (02q, 02r, 02s): New tests, for new combinations.
(incompat2): Now test -nR, since -fR are now compatible.
2010-08-06 21:30:50 -07:00
Paul Eggert
bdde34f958 sort: tune and refactor --debug code, and fix minor underlining bug
Formerly, the 'compare' function and some of its subroutines had a
debugging flag, which caused them to output underlines.  This
change refactors the code so that debugging output is
more-separated from the actual sorting.  In the process, the
change fixes a minor error in the debugging output.  The change
shortens the source code and executable size a tad, and improves
CPU performance by 2.4% on my platform with a simple benchmark (C
locale, line sorting, no debug).

* src/sort.c (long_double, strtold): Move back to prelude, since
they're now used by multiple functions again.
(unit_order): Move to file scope, since it's now used by two functions.
(find_unit_order, human_numcompare, numcompare, general_numcompare):
Remove endptr parameter.  All callers changed.
(human_numcompare): Args are now const pointers.
(getmonth): Endptr is now non-const.
(key_numeric): Move up, since it's needed earlier.
(debug_key): Take a line and a key as argument, instead of having
the caller figure out where the field is.
(debug_line): New function.
(keycompare, compare): Omit debug parameter; debug output now done
elsewhere.  All callers changed.
(write_line): Renamed from write_bytes; all callers changed.
Use debug_line (not 'compare') to output debug info.
Use a slightly faster check for whether output file is stdout.
(check): Don't do debugging output; it's not that useful here,
and it confuses the code.
(main): Check for incompatibility between -c and --debug.
Use standard diagnostic for incompatible options.
* tests/misc/sort-debug-keys: Fix test case: "--Mi-1" is not
a number, so its first character should not be underlined when
debugging a numeric sort.
2010-08-05 13:28:54 -07:00
Paul Eggert
2b49b140cc sort: -R now uses less memory on long lines with internal NULs
* lib/Makefile.am (libcoreutils_a_SOURCES): Remove xmemxfrm.c,
xmemxfrm.h.
* lib/memxfrm.c, lib/memxfrm.h, lib/xmemxfrm.c, lib/xmemxfrm.h: Remove.
* m4/memxfrm.m4: Likewise.
* m4/prereq.m4 (gl_PREREQ): Remove gl_MEMXFRM.
* po/POTFILES.in: Remove lib/xmemxfrm.c.
* src/sort.c: Don't include xmemxfrm.h.
(cmp_hashes): Remove.
(xstrxfrm): New function.
(compare_random): If a line contains NULs, don't create a big
buffer that contains the strxfrm output of each string in the line.
Instead, accumulate checksums and differences as we go, so that
at any one time we have to store at most the output of a single
strxfrm call when processing the line.  This removes the need for
an memxfrm function.
2010-08-04 16:10:59 -07:00
Paul Eggert
db48b36241 init.sh: work around trap limitation of some shells
* tests/init.sh (setup_): Move exit trap outside of shell function.
This patch is imported from gnulib.
2010-08-03 13:01:42 -07:00
Paul Eggert
a2cebacf97 sort: fix bug in --debug when \0 is followed by \t
* src/sort.c (debug_width): New function, which does not stop
counting tabs at \0, and also invokes mbsnwidth.  Stamp out strnlen!
(count_tabs): Remove.
(debug_key): Use debug_width instead of mbsnwidth and count_tabs.
* tests/misc/sort-debug-keys: Check that \0 and \t intermix.
2010-08-03 10:25:47 -07:00
Paul Eggert
94615d2acf sort: revert recent -h changes and use a more-conservative approach
* NEWS: Document changes to sort -h, which are now minor with
respect to the pre-July-30th version.
* doc/coreutils.texi (sort invocation): Likewise.  The
documentation now describes how -h comparison is done rather than
being vague with border cases.
* src/sort.c (long_double, strtold): Move back to general_numcompare.
(LD, compute_human): Remove.
(find_unit_order): Remove THOU_SEP parameter, since thousands
separators are now allowed by all callers.  Revert to previous
behavior of sorting by suffix, and returning the order rather than
2 * order + binary, since we no longer care whether binary powers
are being used.  However, treat all zeros the same, instead of
sorting 0M before 0G; this is more consistent with the desired
behavior of sorting -1G before -1M.
* tests/misc/sort (h1, h3, h6): Adjust to match mostly-reverted
behavior.  However, check that all zeros sort together.
* tests/misc/sort-debug-keys: Omit a "_", since the trailing "i"
in "1234Gi" is no longer part of the key.
2010-08-02 19:21:02 -07:00
Paul Eggert
abd040180e sort: -h now handles comparisons such as 6000K vs 5M and 5MiB vs 5MB
* NEWS: Document changes to sort -h.
* doc/coreutils.texi (sort invocation): Likewise.
* src/sort.c (long_double, strtold): Move to prelude, since they're
now used by multiple functions.
(LD): New macro.
(struct keyfield.iec_present): Remove this member.  All uses removed.
(check_mixed_SI_IEC): Remove.  This code was busted in the presence
of multiple threads, as it had a race condition.
(find_unit_order): Remove arg KEY; add arg THOU_SEP; arg ENDPTR is
now char ** rather than char const **.  Return an integer that
distinguishes decimal from binary powers.  Parse the number
consistently with the intersection of strtold and strnumcmp.
Set *ENDPTR unconditionally.
(compute_human): New static function.
(human_numcompare): Remove arg KEY.  Remove 'const' from other args.
Use strnumcmp if possible, but fall back on floating point if not.
(numcompare, general_numcompare): Arg EA is now char ** rather
than char const **.
(numcompare): Adjust to new find_unit_order signature and behavior.
(keycompare): Adjus to new human_numcompare signature.
* tests/misc/sort (h1, h3, h4, h6): Adjust to new behavior.
* tests/misc/sort-debug-keys: Likewise.
2010-07-30 01:53:46 -06:00
Paul Eggert
1bf73ebb97 sort: fix --debug display with very large offsets
* src/sort.c (mark_key): Don't assume offset <= INT_MAX.
Make the code a bit clearer when width != 0.
2010-07-27 11:01:48 -07:00
Paul Eggert
c8d3838681 sort: fix bug with EOF at buffer refill
* src/sort.c (fillbuf): Don't append eol unless the line is nonempty.
This fixes a bug that was partly but not completely fixed by
the aadc67dfdb commit (dated July 15).
* tests/misc/sort (realloc-buf-2): New test, which catches this
bug on 64-bit hosts.
2010-07-26 20:51:19 -07:00
Paul Eggert
247e239698 sort: omit some "inline"s
* src/sort.c (mergelines, queue_destroy, queue_init, queue_insert):
(queue_pop, write_unique, mergelines_node, check_insert):
(update_parent): No longer inline; these uses of "inline"
seemed unlikely to help performance much.
2010-07-26 18:38:36 -07:00
Paul Eggert
802542ff92 sort: don't assume ASCII when parsing K, M, G suffixes
* src/sort.c (find_unit_order): Don't assume ASCII.
2010-07-26 12:12:50 -07:00
Paul R. Eggert
074566823e sort: make struct heap private
* gl/lib/heap.c (struct heap): Move this here...
* gl/lib/heap.h (struct heap): ... from here, as outside code no
longer needs to access any of these members.
2010-07-25 21:18:35 -07:00
Paul R. Eggert
de949fc12d sort: omit unnecessary mutex unlock+lock; simplify heap access
* src/sort.c (queue_pop): Omit unnecessary unlock+lock after
pthread_cond_wait returns.  Don't access "count" member of the
heap; any efficiency gains should be quite minor, the access
complicates this code, and "count" should be private anyway.
2010-07-25 20:55:21 -07:00
Paul R. Eggert
1563ffd2b1 sort: omit 'restrict' in doubtful cases
* src/sort.c (lock_node, unlock_node, queue_destroy, queue_init):
(queue_pop):
Omit 'restrict'; it shouldn't help here, as these functions have just
one pointer parameter and don't access static storage.
(queue_insert, check_insert, update_parent): Omit 'restrict', as
the pointer types differ, and are not char * or unsigned char *,
and therefore can't alias.
(write_unique): Omit 'restrict', as the pointer types are all
read-only.
(merge_loop, sortlines): Omit 'restrict', as any performance
advantages are extremely unlikely and it's not worth cluttering
the code for that.
(struct thread_args): Omit 'restrict': this seems to be incorrect.
It's unlikely for 'restrict' to be correct inside a typedef.
2010-07-25 20:25:55 -07:00
Paul R. Eggert
001700f4a0 sort: omit unnecessary casts
* src/sort.c (inittables, general_numcompare, compare_nodes):
(queue_init, queue_pop): Omit casts that are not needed, typically
because they are between void * and some other pointer type.
2010-07-25 19:59:11 -07:00
Paul R. Eggert
48faad3748 sort: use more-consistent style with const
* src/sort.c (proctab_hasher, proctab_comparator, stream_open, xfopen):
(open_temp, zaptemp, struct_month_cmp, begfield, limfield):
(find_unit_order, human_numcompare, numcompare, general_numcompare):
(count_tabs, keycompare, compare, compare_nodes, lock_node):
(unlock_node, queue_destroy, queue_init, queue_insert, queue_pop):
(write_unique, mergelines_node, check_insert, update_parent):
(merge_loop, sortlines, struct thread_args, set_ordering):
Prefer the style "T const" to "const T".
* gl/lib/heap.h (struct heap, heap_alloc): Likewise.
* gl/lib/heap.c (heap_default_compare, heapify_down, heapify_up):
(heap_alloc): Likewise.
2010-07-25 19:25:09 -07:00
Paul Eggert
01ca128807 du: add NEWS entry for recent du -L fixes 2010-07-25 10:53:42 -07:00
Paul R. Eggert
77428214f1 du: tune, and fix some -L bugs with dangling or cyclic symlinks
* src/du.c (process_file): Avoid recalculation of hashes
and of file-exclusion for directories.  Do not descend into
the same directory more than once, unless -l is given; this is faster.
Calculate stat buffer lazily, since it
need not be computed at all for excluded files.
Count space if FTS_ERR, since stat buffer is always valid then.
No need for 'print' local variable.
(main): Use FTS_NOSTAT.  Use FTS_TIGHT_CYCLE_CHECK only when not
hashing everything, since process_file finds cycles on its own
when hashing everything.
* tests/du/deref: Add test cases for -L bugs.
2010-07-24 00:20:07 -07:00
Paul R. Eggert
9a3c600f11 tests/misc/sort-merge-fdlimit: don't assume -R opens /dev/urandom
* tests/misc/sort-merge-fdlimit: This test was written assuming that
-R typically opens /dev/urandom, but that's no longer the case.
Redo test to specify a random source; this resurrects the point of
checking for file descriptor exhaustion.  Also try plain -R, since
that implementation may change in the future too.
2010-07-23 23:44:25 -07:00
Paul R. Eggert
df906d2e75 randread: run 2x faster on 64-bit hosts, don't assume no padding bits
* gl/lib/rand-isaac.c: 	Remove the I/O; this belongs elsewhere.
Add support for ISAAC64.  Port to hosts with padding bits.
Add self to author list.  Include <limits.h>, for CHAR_BIT.
Don't include string.h, sys/time.h, unistd.h.
(min, just): New functions.
(IF32): New macros.
(ind, ISAAC_STEP, isaac_refill, mix, isaac_init, isaac_seed):
Add support for ISAAC64.  Port to hosts with padding bits.
(ind): Now an inline function rather than a macro; no need for it
to be a macro with modern compilers.
(ISAAC_STEP): Renamed from isaac_step, since it's not function-like.
Don't bother to pass args that are always the same.  All uses changed.
(ISAAC_STEP, ISAAC_SEED): Move to inside the only function body
that can use it.
(ISAAC_MIX): Renamed from isaac_mix, since it's now a macro and is
no longer function-like.  Don't bother saving and restoring state;
no longer needed now that we're not a function.  All uses changed.
(isaac_seed_start, isaac_seed_data, isaac_seed_finish): Remove.
(isaac_seed): Take just the one arg; the caller now sets s->m.
* gl/lib/rand-isaac.h: Use _GL_RAND_ISAAC_H to protect, instead
of RAND_ISAAC_H.  Try out " #" rather than "# " for indenting.
(ISAAC_BITS_LOG, ISAAC_BITS): New macros.
(ISAAC_WORDS_LOG): Renamed from ISAAC_LOG.
(isaac_word): New type.  All uses of uint32_t changed to isaac_word,
to support ISAAC64.
(struct isaac_state): Rename member MM to M, and make it public.
(isaac_seed, isaac_refill): Adjust to new API.
* gl/lib/randread.c: Include sys/time.h.
(get_nonce): New function, containing the nonce stuff that used
to be in rand-isaac.c but better belongs here.
(randread_new): Use it.
* gl/modules/randread (Depends-on): Add inline.
* gl/modules/randread-tests: New file.
* gl/tests/test-rand-isaac.c: New file.
2010-07-23 15:08:36 -07:00
Pádraig Brady
47076e3c7c provide POSIX_FADV_SEQUENTIAL hint to appropriate utils
Following on from commit dae35bac, 01-03-2010,
"sort: inform the system about our input access pattern"
apply the same hint to all appropriate utils.
This currently gives around a 5% speedup for reading
large files from fast flash devices on GNU/Linux.

* src/base64.c: Call fadvise (..., FADVISE_SEQUENTIAL);
* src/cat.c: Likewise.
* src/cksum.c: Likewise.
* src/comm.c: Likewise.
* src/cut.c: Likewise.
* src/expand.c: Likewise.
* src/fmt.c: Likewise.
* src/fold.c: Likewise.
* src/join.c: Likewise.
* src/md5sum.c: Likewise.
* src/nl.c: Likewise.
* src/paste.c: Likewise.
* src/pr.c: Likewise.
* src/ptx.c: Likewise.
* src/shuf.c: Likewise.
* src/sum.c: Likewise.
* src/tee.c: Likewise.
* src/tr.c: Likewise.
* src/tsort.c: Likewise.
* src/unexpand.c: Likewise.
* src/uniq.c: Likewise.
* src/wc.c: Likewise, unless we don't actually read().
2010-07-22 01:04:47 +01:00
Pádraig Brady
63b5e81648 fadvise: new module providing a simpler interface to posix_fadvise
* bootstrap.conf: Include the new module
* gl/lib/fadvise.c: Provide a simpler interface to posix_fadvise.
(fadvise): Provide hint to the whole file associated with a stream.
(fdadvise): Provide hint to the specific portion of a file
associated with a file descriptor.
* gl/lib/fadvise.h: Redefine POSIX_FADV_* to FADVISE_* enums.
* gl/modules/fadvise: New file.
* m4/jm-macros.m4: Remove the no longer needed posix_fadvise check.
* .x-sc_program_name: Exclude test-fadvise.c from this check.
* gl/tests/test-fadvise (main): New test program.
* gl/modules/fadvise-testss: A new index to reference the tests.
* src/sort.c (stream_open): Use the new interface.
* src/dd.c (iwrite): Likewise.
2010-07-22 01:03:48 +01:00
Mike Frysinger
c88cfffb6c build: support fully excluding stdbuf from the build
* configure.ac (optional_pkglib_progs): Only update
after the main programs have been selected, so that
libstdbuf.so can be excluded if stdbuf also is.
2010-07-22 00:34:04 +01:00
Paul R. Eggert
c1d8e6e458 randread: use /dev/urandom to seed, not just getpid etc
* gl/lib/rand-isaac.c (isaac_seed_start): New arg SEEDED.
(isaac_seed): New args FD and BYTES_BOUND.  Read from FD if possible.
Don't bother with low-quality sources if FD has enough bytes.
* gl/lib/rand-isaac.h: New size_t arg for isaac_seed.
* gl/lib/randread.c: Include fcntl.h, unistd.h.
(NAME_OF_NONCE_DEVICE): New #define.
(nonce_device): New static var.
(randread_new): Use nonce device if available.
2010-07-20 09:51:12 -07:00
Paul R. Eggert
e5444fa2a7 sort: -R no longer disables multithreading
* src/sort.c (random_md5_state): New static var.
(random_md5_state_init): New function, to initialize random_md5_state.
(random_state, randread_source): Remove.
(cmp_hashes): Use random_md5_state rather than random_state.
Break ties using memcmp, not by getting more randomness.
If MD5 collisions turn into a problem in practice, we should
simply use a better checksum.
(main): If -R is given, call random_md5_state_init rather than
going single-threaded.
2010-07-19 10:48:00 -07:00
Paul R. Eggert
e7523efb7d randread: don't require -lrt
Programs like 'sort' were linking to -lrt in order to get
clock_gettime, but this was misguided: it wasted considerable
resources while gaining at most 10 bits of entropy.  Almost nobody
needs the entropy, and there are better ways to get much better
entropy for people who do need it.
* gl/lib/rand-isaac.c (isaac_seed): Include <sys/time.h> not
"gethrxtime.h".
(isaac_seed): Use gettimeofday rather than gethrxtime.
* gl/modules/randread (Depends-on): Depend on gettimeofday
and not gethrxtime.
* src/Makefile.am (mktemp_LDADD, shred_LDADD, shuf_LDADD, sort_LDADD):
(tac_LDADD): Omit $(LIB_GETHRXTIME); no longer needed.
2010-07-16 15:49:05 -07:00
Paul R. Eggert
78e6fb0489 sort: add a test case for the sort -u bug
* tests/Makefile.am (TESTS): Add misc/sort-unique.
* tests/misc/sort-unique: New file.
2010-07-15 18:13:55 -07:00
Paul R. Eggert
c580983f70 sort: fix a bug with sort -u and xmemcoll0, and tune keycompare
* src/sort.c (keycompare): Use xmemcoll0, as it avoids
a couple of stores.
(write_bytes): Leave the buffer the way we found it,
as it might be used again for a later comparison,
if -u is used.
2010-07-15 16:24:38 -07:00
Pádraig Brady
aadc67dfdb sort: fix a bug when sorting unterminated lines
* src/sort.c (fillbuf): The previous commit incorrectly
terminated the buffer when the last line of input
didn't contain a terminating character.
2010-07-15 12:09:33 +01:00
Chen Guo
b084d6bcb5 sort: speed up default full line sorting
Don't write NUL after the comparison buffers on each compare,
which increases performance by about 3% for short lines
on a pentium-m with gcc-4.4.1

* src/sort.c: (fillbuf): Delimit input items with NUL.
(write_bytes): Restore the item delimiter char which was
replaced with NUL in fillbuf().
2010-07-15 01:10:12 +01:00
Jim Meyering
c5e350ec56 heap_alloc: avoid integer overflow
* gl/lib/heap.c (heap_alloc): Use xnmalloc rather than xmalloc,
to avoid pathological overflow.
2010-07-14 11:05:50 -05:00
Paul R. Eggert
66af887e57 maint: omit $(POW_LIB) when linking, as this is no longer needed
* src/Makefile.am (printf_LDADD, seq_LDADD, sleep_LDADD, sort_LDADD):
(tail_LDADD, uptime_LDADD): Omit $(POW_LIB), as it's no longer
needed due to recent gnulib changes, where the strtod module no
longer uses the pow function.  strtold needs pow only because it's
sometimes aliased to strtod.  See
http://lists.gnu.org/archive/html/bug-gnulib/2010-07/msg00076.html
2010-07-14 15:45:08 +01:00
Pádraig Brady
4fe3860ebc build: update gnulib submodule to latest; update bootstrap, too
* gnulib: Update for xmemcoll0 and fix for systems without pthreads
* bootstrap: Update for translation project sync fix
2010-07-14 12:16:48 +01:00
Pádraig Brady
4332538dbb maint: reorganize latest NEWS
* NEWS: Add another blank line before the previous version.
(Bug fixes): Move to the start.
(Changes in behavior): Add the item about the du mem usage change
from the "New features" section.
2010-07-13 19:05:31 +01:00
Pádraig Brady
f8574063d5 maint: heap.c: simplify dynamic allocations
* gl/lib/heap.c (heap_alloc): Use the fact that the xalloc
routines will not return NULL.  Also remove the redundant
temporary variables.
(heap_insert): From Jim Meyering, use x2nrealloc() which
is simpler while handling overflow and increasing the
size more efficiently.  This reallocation is currently
unused by coreutils in any case as it preallocates enough.
2010-07-13 16:51:38 +01:00
Chen Guo
9face836f3 sort: parallelize internal sort
This patch is by Gene Auyeung, Chris Dickens, Chen Guo, and Mike
Nichols, based off of a patch by Paul Eggert, Glen Lenker, et. al.,
with a basic heap implementation based off of the GDSL heap,
originally by Nicolas Darnis.

The number of sorts done in parallel is limited to the number
of available processors by default, or can be further restricted
with the --parallel option.

On a dual-die, 8 core Intel Xeon, results show sorting with
8 threads is almost 4 times faster than using a single thread.
Timings when sorting a 96MB file:
THREADS     TIME (s)
1            5.10
2            2.87
4            1.75
8            1.31

Single threaded sorting has also been improved,
especially for cheaper comparison operations:
COMMAND             BEFORE (s)  AFTER (s)
sort                 8.822       8.716
sort -g             10.336      10.222
sort -n              3.077       2.961
LANG=C sort          2.169       2.066

* bootstrap.conf: Add heap, pthread.
* coreutils.texi (sort): Describe the new --parallel option.
* gl/lib/heap.c: New file. Very basic heap implementation.
* gl/lib/heap.h: New file.
* gl/modules/heap: New file.
* src/Makefile.am: Add LIB_PTHREAD.
* src/sort.c: Include heap.h, nproc.h, pthread.h.
(MAX_MERGE): New macro.
(SUBTHREAD_LINES_HEURISTIC, PARALLEL_OPTION): New constants.
(MERGE_END, MERGE_ROOT): New constants.
(struct merge_node): New struct.
(struct merge_node_queue): New struct.
(sortlines temp): Remove declaration.
(usage, long_options, main): New option, --parallel.
(specify_nthreads): New function.
(mergelines): New signature, to emphasize the fact that the HI area
must be part of the destination.  All callers changed.
(sequential_sort): New function, renamed from sortlines. Merge in
the functionality of sortlines_temp.
(compare_nodes): New function.
(lock_node, unlock_node): New functions.
(queue_destroy): New function.
(queue_init): New function.
(queue_insert): New function.
(queue_pop): New function.
(write_unique): New function.
(mergelines_node): New function.
(check_insert): New function.
(update_parent): New function.
(merge_loop): New function.
(sortlines): Rewrite to support and use parallelism, with a new
signature. All callers changed.
(struct thread_args): New struct.
(sortlines_thread): New function.
(sortlines_temp): Remove.
(sort): New argument NTHREADS. All uses changed. Output moved to
mergelines_node.
(main): disable threading if we are sorting at random.
* tests/Makefile.am (TESTS): Add misc/sort-benchmark-random.
* tests/misc/sort-benchmark-random: New file.

Signed-off-by: Pádraig Brady <P@draigBrady.com>
2010-07-13 01:44:46 +01:00
Jim Meyering
f6e8c18f8d di-set, ino-map: adjust a type, improve readability
* gl/lib/ino-map.c (ino_hash): Declare "i" as unsigned int.
Use an intermediate variable for the for-loop upper bound,
so it's a little more readable.  Adjust comment.
* gl/lib/di-set.c (di_ent_hash): Likewise.
2010-07-13 02:20:10 +02:00
Paul R. Eggert
335b59b962 dd: also spell out size on memory exhaustion
* src/dd.c (dd_copy): Use requested blocksize (not adjusted) in
diagnostic, to forestall user complaints that the numbers don't
match exactly.  Report both exact and human-readable sizes, using
a message format that is consistent with both "BBBB bytes (N XB)
copied" in dd.c and "memory exhausted" in lib/xmalloc.c.
2010-07-12 17:13:13 -07:00
Paul Eggert
e5ca54448e chcon, chmod, chown, du: don't translate "%s"
* src/chcon.c (process_file): Replace _("%s") with "%s".
* src/chmod.c (process_file): Likewise.
* src/chown-core.c (change_file_owner): Likewise.
* src/du.c (process_file): Likewise.
2010-07-09 13:56:05 -07:00
Paul Eggert
db4df7dda6 du: avoid spurious warnings with 64-bit gcc -W
Problem reported by Jim Meyering in:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6524#74
* gl/lib/di-set.c (di_ent_hash): Rework so that the compiler does
not incorrectly warn about shifting by 64-bits in unreachable code.
* gl/lib/ino-map.c (ino_hash): Likewise.
2010-07-06 16:16:50 -07:00
Paul Eggert
fb1a26c3f6 du: Hash with a mechanism that's simpler and takes less memory.
* gl/lib/dev-map.c, gl/lib/dev-map.h, gl/modules/dev-map: Remove.
* gl/lib/ino-map.c, gl/lib/ino-map.h, gl/modules/ino-map: New files.
* gl/modules/dev-map-tests, gl/tests/test-dev-map.c: Remove.
* gl/modules/ino-map-tests, gl/tests/test-ino-map.c: New files.
* gl/lib/di-set.h (struct di_set): Renamed from struct di_set_state,
and now private.  All uses changed.
(_ATTRIBUTE_NONNULL_): Don't assume C99.
(di_set_alloc): Renamed from di_set_init, with no size arg.
Now allocates the object rather than initializing it.
For now, this no longer takes an initial size; we can put this
back later if it is needed.
* gl/lib/di-set.c: Include hash.h, ino-map.h, and limits.h instead of
stdio.h, assert.h, stdint.h, sys/types.h (di-set.h includes that
now), sys/stat.h, and verify.h.
(N_DEV_BITS_4, N_INO_BITS_4, N_DEV_BITS_8, N_INO_BITS_8): Remove.
(struct dev_ino_4, struct dev_ino_8, struct dev_ino_full): Remove.
(enum di_mode): Remove.
(hashint): New typedef.
(HASHINT_MAX, LARGE_INO_MIN): New macros.
(struct di_ent): Now maps a dev_t to a inode set, instead of
containing a union.
(struct dev_map_ent): Remove.
(struct di_set): New type.
(is_encoded_ptr, decode_ptr, di_ent_create): Remove.
(di_ent_hash, di_ent_compare, di_ent_free, di_set_alloc, di_set_free):
(di_set_insert): Adjust to new representation.
(di_ino_hash, map_device, map_inode_number): New functions.
* gl/modules/di-set (Depends-on): Replace dev-map with ino-map.
Remove 'verify'.
* gl/tests/test-di-set.c: Adjust to the above changes to API.
* src/du.c (INITIAL_DI_SET_SIZE): Remove.
(hash_ins, main): Adjust to new di-set API.
2010-07-06 14:58:48 -07:00
Jim Meyering
d5427265e3 stat: getfilecon failure now evokes nonzero exit status
Add comments and adjust interfaces to allow low-level failure
to propagate out to callers.
* src/stat.c (out_file_context): Return bool, not void,
so we can tell callers about failure.
(print_statfs, print_stat, print_it): Propagate failure to caller.
(do_statfs): Propagate print_it failure to caller.
(do_stat): Likewise.
I nearly forgot to update do_stat to propagate print_it failure,
and it compiled just fine in spite of that.  To prevent possibility
of a repeat, I've marked each function that returns non-void with
ATTRIBUTE_WARN_UNUSED_RESULT.
2010-07-05 17:39:51 +02:00
Jim Meyering
61aae73f54 system.h: define ATTRIBUTE_WARN_UNUSED_RESULT
* src/system.h (ATTRIBUTE_WARN_UNUSED_RESULT): Define.
2010-07-05 17:39:46 +02:00
Pádraig Brady
09fcf494a1 tests: make tests requiring a delay to pass, more robust
* tests/init.cfg: Introduce a retry_delay_() function to
repeatedly call a test function that requires a delay.
This delay can now be shorter for the common case on fast
systems, but will double until a configurable limit it reached
before failing on slower systems.
* tests/dd/reblock: Use retry_delay_.
* tests/misc/cat-buf: Likewise.
* tests/misc/stdbuf: Likewise.
* tests/tail-2/F-vs-rename: Likewise.
* tests/tail-2/flush-initial: Likewise.
* tests/tail-2/tail-n0f: Likewise.
* tests/tail-2/wait: Likewise.
* test/dd/misc: Comment that delay is needed to trigger failure.
2010-07-05 15:06:07 +01:00
Paul Eggert
1d95457b3e doc: Add advice about ChangeLogs and synchronizing submodules
* README-hacking: Update accordingly.
2010-07-04 15:44:48 -07:00
Jim Meyering
98d48bb0e9 du: increase the initial dev-inode set size
* src/du.c (INITIAL_DI_SET_SIZE): Increase to the prime just under
1024.  This gives a speed-up of about 2% when processing a tree
containing 100,000 files, each with a link count greater than 1,
all pointing to files in some other tree.
2010-07-04 11:15:48 +02:00
Jim Meyering
4cb8268024 du: use less than half as much memory when tracking hard links
When processing a hard-linked file, du must keep track of the file's
device and inode numbers in order to avoid counting its storage
more than once.  When du would process many hard linked files --
as are created by some backup tools -- the amount of memory required
for the supporting data structure could become prohibitively large.
This patch takes advantage of the fact that the amount of information
in the numbers of the typical dev,inode pair is far less than even
32 bits, and hence usually fits in the space of a pointer, be it
32 or 64 bits wide.  A typical du traversal examines files on no
more than a handful of distinct devices, so the device number can
be encoded in just a few bits.  Similarly, few inode numbers use
all of the high bits in an ino_t.  Before, we would represent the
dev,inode pair using a naive struct, and allocate space for each.
Thus, an entry in the hash table consisted of a pointer (to that
struct) and a "next" pointer.  With this change, we encode the
dev,inode information and put those bits in place of the pointer,
and thus do away with the need to allocate additional space for
each dev,inode pair.

* src/du.c: Include "di-set.h".
Don't include "hash.h"; it's no longer used.
(INITIAL_DI_SET_SIZE): Define.
(di_set): New global, to replace "htab".
(entry_hash, entry_compare, hash_init): Remove functions.
(hash_ins): Use di-set functions, rather than ones from the hash module.
(main): Likewise.
* bootstrap.conf (gnulib_modules): Add the new di-set module.
* NEWS (New features): Mention it.
2010-07-04 08:40:40 +02:00
Jim Meyering
f42496b72b di-set: manipulate sets of dev/inode pairs efficiently
* gl/lib/di-set.c: Implementation.
* gl/lib/di-set.h: Declarations.
* gl/modules/di-set: Define module.
* gl/modules/di-set-tests: Define test module.
* gl/tests/test-di-set.c: Likewise.
2010-07-04 08:40:40 +02:00
Jim Meyering
6357909ee6 dev-map: map device number to small non-negative
* gl/lib/dev-map.c: New file.
* gl/lib/dev-map.h: Declarations.
* gl/modules/dev-map: Define primary modules.
* gl/modules/dev-map-tests: Define test module.
* gl/tests/test-dev-map.c: Test it.
2010-07-04 08:40:40 +02:00
Paul Eggert
efe53cc72b du: don't miscount duplicate directories or link-count-1 files
* NEWS: Mention this.
* src/du.c (hash_all): New static var.
(process_file): Use it.
(main): Set it.
* tests/du/hard-link: Add a couple of test cases to help make
sure this bug stays squashed.
* tests/du/files0-from: Adjust existing tests to reflect
change in semantics with duplicate arguments.
2010-07-03 10:28:08 +02:00
Jim Meyering
d27d6d371f build: update gnulib submodule to latest; update bootstrap, too
* gnulib: Update to latest, for hash.c improvement.
* bootstrap: Update from gnulib, too.
2010-07-02 08:38:15 +02:00
Pádraig Brady
1af81dfb4d cp: add an option to only copy the file attributes
* src/copy.c (copy_attr): A new function which merges copy_attr_by_fd
and copy_attr_by_name.  Also display all errors when --attributes-only
* src/copy.c (copy_reg): Skip copying the file contents if specified.
Refactor the SELinux error handling code a little and display all
SELinux errors when only copying attributes.
* src/copy.h (struct cp_options): Add a data_copy_required boolean
* src/cp.c (main): Default to copying data but don't if specified
* src/install.c: Default to copying data
* src/mv.c: Likewise
tests/cp/reflink-perm: Add a test to check that --attributes-only
does not copy data
* tests/cp/acl: Likewise. Also refactor to remove redundant
acl manipulation
* doc/coreutils.texi (cp invocation): Describe the new option
* NEWS: Mention the new feature
2010-07-01 14:33:27 +01:00
Pádraig Brady
8aa15b2be2 ls: use the POSIX date style when the locale does not specify one
Previously we defaulted to "long-iso" format in locales without
specific format translations, like the en_* locales for example.
This reverts part of commit 6837183d, 08-11-2005, "ls ... acts like
--time-style='posix-long-iso' if the locale settings are messed up"
* src/ls.c (decode_switches): Only use the ISO format when specified.
* NEWS: Mention the change in behavior.
Reported by Daniel Qarras at http://bugzilla.redhat.com/525134
2010-07-01 13:12:52 +01:00
Jim Meyering
7336920dd0 tests: fail rather than infloop in tail's inotify-rotate test
* tests/tail-2/inotify-rotate: Switch to new init.sh-based framework.
(grep_timeout): New function.
Use it in place of open-coded loops that might infloop.
This was prompted by my encountering an inexplicable, and so far
unreproducible, infloop in the code that was waiting for "b" to
appear in "out".
2010-06-30 18:12:12 +02:00
Jim Meyering
b062bbd947 tests: move most helper functions from test-lib.sh to new init.cfg
From there, they will be used by both test-lib.sh (as we phase it out)
and the newer init.sh, to which all tests will migrate.
* tests/test-lib.sh: Move most functions from here, ...
* tests/init.cfg: ...to here.  New file.
* tests/Makefile.am (EXTRA_DIST): Add init.cfg.
2010-06-30 18:11:50 +02:00
Jim Meyering
cfee734a41 tests: sync tests/init.sh from gnulib
* tests/init.sh: Update from gnulib.
2010-06-30 18:11:50 +02:00
Jim Meyering
5b3adc0d42 doc: df, du, ls: improve --blocksize description in --help
* src/du.c (usage): Print better --blocksize description.
Prompted by Samuel Thibault in <http://bugs.debian.org/353100>.
* src/df.c (usage): Likewise.
* src/ls.c (usage): Likewise.
2010-06-29 07:06:31 +02:00
Pádraig Brady
91b7b7cf7e doc: reference POS syntax in --help for sort --key
* src/sort.c (usage): Reference the additional description
of the POS syntax.
2010-06-29 01:20:23 +01:00
Benno Schulenberg
825a92240e ln: print a clearer error message when linking fails 2010-06-27 08:47:24 +02:00
Jim Meyering
13f323786c stat: remove support for deprecated --context (-Z) option
* src/stat.c (main): Remove support for the --context (-Z) option.
In upstream releases this option has always been a no-op.  It was
first ignored for compatibility, and since the June 2008 commit,
574f7614 (coreutils-7.0), its use has evoked a warning.
* NEWS (Changes in behavior): Mention it.
2010-06-22 11:42:34 +02:00
Jim Meyering
1419af8243 doc: fix comm's --help output so we generate a better man page
* src/comm.c (usage): Don't align example comments in --help output,
since the extra space (sequence of two spaces) there would be
interpreted by help2man and induce an unwanted line break
in the resulting man page.  Reported by Jari Aalto.
2010-06-21 08:55:22 +02:00
Eric Blake
9f75771efb maint: ignore another gnulib generated file
* .gnulib: Exclude lib/c++defs.h.
2010-06-14 15:49:46 -06:00
Eric Blake
879e8261bb cat: improve documentation
* src/cat.c (usage): Clarify that -b overrides -n.
* doc/coreutils.texi (cat invocation): Likewise.
* THANKS: Update.
Suggested by Chas. Owens, in bug 6383.
2010-06-14 15:42:24 -06:00
Jim Meyering
ceb84598d8 doc: dd: discourage use of very large block sizes
* doc/coreutils.texi (dd invocation): Warn against using a very large
block size.  Suggested by Imre Péntek.
2010-06-14 22:36:28 +02:00
Jim Meyering
280b15249c dd: print a better diagnostic for an invalid block size
* src/dd.c (dd_copy): Give a better diagnostic than
"dd: memory exhausted" for an over-large bs= block size setting.
Same for ibs= and obs=.  Reported by Imre Péntek in
http://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/591969
2010-06-14 22:34:42 +02:00
Jim Meyering
d9ddd4c503 build: update gnulib submodule to latest 2010-06-11 11:32:31 +02:00
Jim Meyering
155c8148ae build: don't let a large sparse temporary file cause "make dist" to fail
* bootstrap.conf (bootstrap_epilogue): Replace the offending grep
command from po/Makefile.in.in's $(DOMAIN).pot-update rule.
2010-06-11 08:01:18 +02:00
Jim Meyering
ea615bf8cd ls: avoid just-introduced buffer overrun
* src/ls.c (gobble_file): Revert part of my preceding change,
to avoid clobbering stack.
2010-06-10 17:53:46 +02:00
Jim Meyering
9e7edd8467 maint: adjust INT_BUFSIZE_BOUND usage for maintainability
* src/tail.c (xlseek): Give INT_BUFSIZE_BOUND a variable name,
not a type name.
* src/ls.c (gobble_file, format_user_or_group_width): Likewise.
* src/head.c (elide_tail_bytes_pipe): Likewise.
(elide_tail_lines_seekable, main): Likewise.
[This change is not complete -- there are doubtless other uses
that can be updated in the same way.]
2010-06-08 13:16:26 +02:00
Jim Meyering
ad89ea6a0d sort: avoid unnecessary use of sprintf
sprintf is relatively heavy-weight.
* src/sort.c (key_warnings): Use umaxtostr and stpcpy rather
than sprintf.
Also, replace each INT_BUFSIZE_BOUND "type_name" argument
with the equivalent variable name.  More maintainable that way.
2010-06-08 13:16:26 +02:00
Eric Blake
04bed02096 dirname: tweak summary wording
* doc/coreutils.texi (dirname invocation): Reword to be more
precise.
* src/dirname.c (usage): Likewise.
* THANKS: Update.
Reported by Filipus Klutiero, bug 6175.
2010-06-08 04:28:19 -06:00
Jim Meyering
dfad4755ca doc: mention the new coreutils@ mailing lists
* README-package-renamed-to-coreutils: Mention the new mailing list
and a mirror.
2010-06-02 17:41:52 +02:00
Jim Meyering
d5a5d83094 touch: remove support for --file=REF_FILE option
* src/touch.c (main): Remove support for the deprecated, long-named
--file option, which is an alternate name for --reference (-r).
That option was undocumented with the arrival of --reference, in
the 1995-10-29 commit, 8b92864e1d.  Since the 2009-02-09 commit,
ed85df444a, use of --file has elicited a warning.  Not only was
this code due for removal, but the long-name-use-detecting code
was buggy in that it would use a stale or uninitialized "long_idx",
as reported by Robin H. Johnson in http://bugs.gentoo.org/322421.
* NEWS (Changes in behavior): Mention it.
2010-06-02 17:14:10 +02:00
Jim Meyering
c0cfa0defe maint: make spacing around "=" consistent, even in IF_LINT
E.g.,
  -  size_t desired_width IF_LINT (= 0);
  +  size_t desired_width IF_LINT ( = 0);
Use this command:
  g grep -l IF_LINT | grep '\.[ch]$' \
    | xargs perl -pi -e 's/(IF_LINT \()= /$1 = /'
2010-05-31 11:02:21 +02:00
Jim Meyering
da7a704cd3 maint: replace each "for (;;)" with "while (true)"
Run this command:
  git ls-files | grep '\.[ch]$' \
    | xargs perl -pi -e 's/for \(;;\)/while (true)/g'
...except for randint.c, which does not include stdbool.h.
In that case, use "while (1)".
* gl/lib/randint.c (randint_genmax): Use "while (1)" for infloops.
* src/cat.c (simple_cat, cat): Use "while (true)" for infloops.
* gl/lib/randread.c (readsource, readisaac): Likewise.
* src/copy.c (copy_reg): Likewise.
* src/csplit.c (record_line_starts, process_regexp): Likewise.
* src/cut.c (set_fields): Likewise.
* src/dd.c (iread, parse_symbols): Likewise.
* src/df.c (find_mount_point, main): Likewise.
* src/du.c (main): Likewise.
* src/expand.c (expand): Likewise.
* src/factor.c (factor_using_division, do_stdin): Likewise.
* src/fmt.c (get_space): Likewise.
* src/ls.c (decode_switches): Likewise.
* src/od.c (main): Likewise.
* src/pr.c (main, read_line): Likewise.
* src/shred.c (dopass, genpattern): Likewise.
* src/sort.c (initbuf, fillbuf, getmonth, keycompare): Likewise.
* src/split.c (bytes_split, lines_split): Likewise.
* src/tac.c (tac_seekable): Likewise.
* src/test.c (and, or): Likewise.
* src/tr.c (squeeze_filter, main): Likewise.
* src/tsort.c (search_item): Likewise.
* src/unexpand.c (unexpand): Likewise.
* src/uniq.c (main): Likewise.
* src/yes.c (main): Likewise.
2010-05-31 11:02:21 +02:00
Jim Meyering
5591f19e9c maint: correct indentation of case_GETOPT_* macro uses
* src/base64.c (main): Correct indentation of syntactically
questionable case_GETOPT_HELP_CHAR and case_GETOPT_VERSION_CHAR macros.
* src/who.c (main): Likewise.
2010-05-31 11:02:21 +02:00
Jim Meyering
78c1111c00 stat: use gnulib's alignof module
* src/stat.c (alignof): Remove definition.
Instead, include "alignof.h", and sort the #include directives.
And get its definition from the gnulib module by that name:
* bootstrap.conf (gnulib_modules): Add alignof.
2010-05-31 11:02:21 +02:00
Jim Meyering
f385d97a41 tests: remove unnecessary single quotes in perl hash use: ->{'SYM'}
Run this command:
  git grep -l "limits->{'" \
    | xargs perl -pi -e "s/limits->{'(.*?)'}/limits->{\$1}/g"
* cfg.mk (sc_prohibit_perl_hash_quotes): New rule to match.
* tests/misc/join: Remove quotes.
* tests/misc/sort: Likewise.
* tests/misc/sort-merge: Likewise.
* tests/misc/test: Likewise.
* tests/misc/unexpand: Likewise.
* tests/misc/uniq: Likewise.
2010-05-31 10:59:11 +02:00
Pádraig Brady
200501052e truncate: improve handling of non regular files
Previously we copied `dd` and suppressed error messages
when truncating neither regular files or shared mem objects.
This was valid for `dd`, as truncation is ancillary to copying
it may also do, but for `truncate` we should display all errors.
Also we used the st_size from non regular files which is undefined,
so we display an error when the user tries this.

* src/truncate (do_truncate):  Error when referencing the size
of non regular files or non shared memory objects.  Display all
errors returned by ftruncate().
(main): Error when referencing the size of non regular files or
non shared memory objects.  Don't suppress error messages for
any file types that can't be opened for writing.
* tests/misc/truncate-dir-fail: Check that referencing the
size of a directory is not supported.
* tests/misc/truncate-fifo: Ensure the test doesn't hang
by using the `timeout` command.  Don't test the return from
running ftruncate on the fifo as it's system dependent as
to whether this fails or not.
NEWS: Mention the change in behavior.
Reported by Jim Meyering.
2010-05-29 10:45:13 +01:00
Pádraig Brady
81b7585ad1 truncate: support sizes relative to an existing file
* doc/coreutils.texi (truncate invocation): Mention that --reference
bases the --size rather than just setting it.
* src/truncate.c (usage): Likewise. Also remove the clause
describing --size and --reference as being mutually exclusive.
(do_truncate): Add an extra parameter to hold the size
of a referenced file, and use it if positive.
(main): Pass the size of a referenced file to do_truncate().
* tests/misc/truncate-parameters: Adjust for the new combinations.
* NEWS: Mention the change
Suggested by Richard W.M. Jones
2010-05-28 14:23:04 +01:00
Jim Meyering
d4201905ab tests: update help-version to work with parted, too
* tests/misc/help-version: Add init code for GNU Parted.
2010-05-26 11:33:53 +02:00
Jim Meyering
5d59808a65 maint: don't emit an extra newline in each of two diagnostics
* src/shuf.c (main): Remove a stray newline in a diagnostic.
* src/od.c (main): Likewise.
Detected via these:
  git grep -A1 'error *(.*,$' | grep -C1 '\\n"[,)]'
  git grep 'error *(.*;$' | grep '\\n"[,)]'
2010-05-25 18:05:29 +02:00
Jim Meyering
55db9a39a8 maint: remove unneeded double quotes on RHS of shell assignments
Run this command:
  git grep -l 'LC_[A-Z]*="' \
    | xargs perl -pi -e 's/(LC_[A-Z]*)="(.*?)"/$1=$2/'
* src/Makefile.am: Write LC_ALL=$$locale, not LC_ALL="$$locale".
* src/date.c (main): Similar, in a comment.
* tests/misc/sort-month: Write LC_ALL=$LOC, not LC_ALL="$LOC".
2010-05-25 12:32:03 +02:00
Pádraig Brady
6bc44b5feb maint: remove a redundant sort parameter from a test
* tests/misc/sort-month: Remove the -b option which
is redundant and ignored.
2010-05-24 13:00:35 +01:00
Pádraig Brady
63761c027c sort: adjust the leading blanks --debug warning
* src/sort.c (key_warnings): Always warn about significant leading
blanks when character offsets are specified, unless they key is
possibly a line offset, i.e. of the form -k1.x,1.y.  Also suppress
this warning if the user could be sorting right aligned indexes.
2010-05-24 12:12:24 +01:00
Jim Meyering
fdff32e183 maint: make copyright comment consistent with all others
* tests/misc/mktemp: Change punctuation to make copyright
paragraph consistent with all of the others.
2010-05-23 18:10:41 +02:00
Jim Meyering
28488c1214 tests: fix cp-a-selinux to skip cleanly upon mkfs failure
* tests/cp/cp-a-selinux: Initialize skip, to avoid a syntax error
in subsequent "test".
Remove redirect-to-/dev/null, now that output is always to a log file.
2010-05-21 20:21:18 +02:00
Jon Ringuette
2b8ecfa6f1 du: recognize -d N as equivalent to --max-depth=N
* NEWS (New features): Mention it.
* src/du.c (DEBUG_OPT): Remove.  Use long-named ---debug instead.
Commented out.
(MAX_DEPTH_OPTION): Remove.  Use 'd' instead.
(main): Insert literal "d:"; remove DEBUG_OPT.
* doc/coreutils.texi (du invocation): Add -d to indices.
* tests/du/max-depth: Exercise -d, too.
2010-05-19 07:28:16 +02:00
Jim Meyering
1be4f180f5 tests: exercise du's --max-depth option
* tests/Makefile.am (TESTS): Add du/max-depth.
* tests/du/max-depth: New file.
2010-05-19 07:28:16 +02:00
Pádraig Brady
9f1d4e3e6f tests: fix sort-debug-keys when fr_FR.utf8 not available
* tests/misc/sort-debug-keys: Correctly check for the absence
of the French UTF8 locale.
2010-05-18 23:44:34 +01:00
Jim Meyering
5e82d241d0 maint: fix the fs-magic-compare rule
* src/Makefile.am (fs-def): Sort definitions.
This is required by fs-magic-compare's use of join.
2010-05-17 16:10:24 +02:00
Jim Meyering
1173dcd632 tests: update init.sh from gnulib
* tests/init.sh: Update from gnulib.
2010-05-17 09:12:22 +02:00
Jim Meyering
fe953ad710 build: avoid a new -Wformat-induced warning
* src/sort.c (mark_key): Add a cast-to-int of a printf field width,
to placate -Wformat.
2010-05-17 09:09:28 +02:00
Pádraig Brady
9464ce2107 doc: fix sort info about version sort skipping blanks
* doc/coreutils.text (sort invocation): leading blanks are
significant for 'V'.
2010-05-16 01:28:32 +01:00
Pádraig Brady
03f6f32c41 sort: --debug: output data independent warnings and info
* src/sort.c (usage): Mention --debug can output warnings to stderr.
Also split the translatable string to aid translation.
(default_key_compare): A new function refactored from main(),
and now also called from the new key_warnings() function.
(key_to_opts): A new function refactored from incompatible_options(),
and now also called from the new key_warnings() function.
(key_numeric): A new function refactored to test if key is numeric.
(key_warnings): A new function to output warnings to stderr,
about questionable use of various options.  Currently it warns
about zero length keys and ineffective global options.
(incompatible_options): Refactor out key_to_opts()
(main): Use key_init() to initialize gkey.  Refactor out
default_key_compare().  Call key_warnings() in debug mode.
* doc/coreutils.texi (sort invocation): Mention that warnings
are output by --debug.
* tests/misc/sort-debug-warn: A new test for debug warnings.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the new feature
2010-05-16 01:08:33 +01:00
Pádraig Brady
144d6e5f53 tests: fix sort-debug-keys when fr_FR.utf8 not available
* tests/misc/sort-debug-keys: Don't verify (or even run)
the fr_FR tests when that locale is not available on the system.
2010-05-12 14:53:45 +01:00
Pádraig Brady
4f5732e27a sort: add a --debug option to highlight key extents
* src/sort (usage): Add description for --debug.
(write_bytes): Pass a line structure so it can subsequently
be passed to compare to highlight the keys when in debug mode.
Also transform TAB and NUL characters written to stdout so
that the highlighting in debug mode aligns correctly.
(human_numcompare): Pass an "endptr" so we can record the extent
of the number matched.
(general_numcompare): Likewise.
(find_unit_order): Likewise.
(getmonth): Likewise.
(numcompare): Likewise.  Note we reuse find_unit_order() for this,
which is a good enough approximation, and means we don't need to
change the strnumcmp() interface.
(check_mixed_SI_IEC): Return whether iec_present, so that can be
used to set the "endptr" in find_unit_order.  Also make the key
parameter optional, which will be the case from numcompare().
(count_tabs): A new function to determine how much to adjust
the mbswidth() values by (TABs don't have a width).
(mark_key): A new function to output the key highlighting to stdout.
(debug_key): A new function to determine the offset and width
of the key highlighting.
(key_compare): Pass the show_debug parameter so the key highlighting
is only displayed when explicitly called.  For each key type, set
the length (lena) and whether leading blanks are auto skipped (skipb)
which are then used by debug_key() to highlight the portion of the
key used in the comparison.
(compare): Pass the show_debug parameter so the key highlighting
is only displayed when explicitly called.  Call debug_key() to
highlight the last resort comparison.
(check): Output highlighting for disorder line to stdout.
(main): Process the --debug option and make it mutually exlusive
with the -o option as I don't see it useful there, even potentially
harmful if someone left a --debug in by mistake when updating a file.
Also restricting debug output to stdout, simplifies the logic
for dealing with temporary files.
* doc/coreutils.texi (sort invocation): Describe the --debug option,
and reference it from the --key description.
* tests/misc/sort-debug-keys: A new test for highlighting keys.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the new feature.
2010-05-12 13:30:37 +01:00
Jim Meyering
7e978a7b2d build: record the gettext-0.18 requirement also in configure.ac
* configure.ac: Require gettext-0.18 here, too.
2010-05-11 10:31:21 +02:00
Jim Meyering
844b2570b3 build: update gnulib submodule to latest
* tests/init.sh: Update from gnulib, to fix typo.
2010-05-11 09:51:16 +02:00
Jim Meyering
0c22e84156 build: record that when building from git, gettext-0.18 is required
* bootstrap.conf (buildreq): Require gettext-0.18.
2010-05-10 12:39:37 +02:00
Jim Meyering
d21812670b tests: avoid a new syntax-check failure
* .x-sc_prohibit_fail_0: Exempt tests/init.sh.
2010-05-10 11:47:27 +02:00
Jim Meyering
88e2f6c860 tests: provide a definition of gl_trap_ in cfg.mk
* cfg.mk (gl_trap_): Define here, now that it's gone from maint.mk.
* gnulib: Update to latest.
2010-05-10 11:45:40 +02:00
Jim Meyering
e080c8a1b0 tests: begin using init.sh
* tests/init.sh: New file.
* tests/Makefile.am (EXTRA_DIST): Add it here.
2010-05-10 11:33:31 +02:00
Jim Meyering
722173444a tests: update help-version
* tests/misc/help-version: Use init.sh, rather than test-lib.sh.
Add idutils' setup.
2010-05-09 21:22:21 +02:00
Jim Meyering
74f07c98d4 tests: move sc_prohibit_always-defined_macros to gnulib's maint.mk
* cfg.mk (sc_prohibit_always-defined_macros): Remove it from here.
* gnulib: Update to latest, for a maint.mk that includes that rule.
2010-05-09 18:54:33 +02:00
Jim Meyering
0f741381c4 tests: rename a syntax-check
* cfg.mk (sc_prohibit_always-defined_macros): Rename from
sc_always_defined_macros.
* .x-sc_prohibit_always-defined_macros: New file, renamed from...
* .x-sc_always_defined_macros: ...removed.
* Makefile.am (syntax_check_exceptions): Rename here, too.
2010-05-09 18:47:34 +02:00
Jim Meyering
6ac165922c tests: loosen/tighten the always_defined_macros check
* cfg.mk (.re-defmac): Generate better regexps: allow white space
before the '#', and append a word-boundary requirement.
Without the latter, #define NULL_DEV ... would evoke a false-positive.
2010-05-09 18:29:22 +02:00
Jim Meyering
cab2119542 tests: improve the always_defined_macros check
* cfg.mk (sc_always_defined_macros): Adjust its helpers not to depend
on the existence of ./lib.  Instead, extract symbols directly from
gnulib/lib/*.in.h files.
2010-05-09 12:08:21 +02:00
Jim Meyering
9e42ecceff doc: factor hard-coded project-specific bits from README-release, ...
using the new --mail-headers option to gnulib's announce-gen, and
the updated maint.mk rules to connect the pieces.
* README-release: Remove hard-coded To:, Cc: etc. parts, now
that they're emitted automatically into the announcement template.
* cfg.mk (announcement_Cc_): Override the default.
* gnulib: Update to latest, to get newer announce-gen and maint.mk.
2010-05-03 22:21:31 +02:00
Jim Meyering
ca41dcff1d doc: update release procedure
* README-release: Rearrange slightly: post the announcement to
Savannah first, so you can include a link to that post in the email.
2010-05-03 20:37:13 +02:00
Jim Meyering
7d501cdd9c maint: factor trap-related code out of two syntax-check rules
* cfg.mk (gl_trap_): Define, using a loop and eval'd trap,
rather than repeated "trap" uses.  Also handle "13", SIGPIPE.
(sc_always_defined_macros): Use it.
(sc_system_h_headers): Likewise.
2010-05-03 15:49:38 +02:00
Jim Meyering
ecf6d16dc7 maint: extend the always_defined_macros syntax-check
* cfg.mk (gl_generated_headers_): Define.
(headers_with_interesting_macro_defs): Remove headers covered
by the above.
(.re-defmac): Extract symbol names from many more files.
(sc_always_defined_macros): Use VC_LIST_EXCEPT, not VC_LIST, so
that we can use the usual exception mechanism.
Test for $(gnulib_dir), not system.h.
* .x-sc_always_defined_macros: New file.  Exempt src/seq.c.
* Makefile.am (syntax_check_exceptions): Add it here.
2010-05-03 13:24:04 +02:00
Jim Meyering
c0e784b923 maint: remove now-redundant definitions provided by signal.h
* src/dd.c (SA_NODEFER, SA_RESETHAND): Remove definitions,
now that gnulib guarantees they are defined in <signal.h>.
* src/ls.c (SA_RESTART): Likewise.
2010-05-03 12:26:20 +02:00
Jim Meyering
a9c542e416 maint: remove now-redundant definitions provided by sys/wait.h
* src/timeout.c (WIFSIGNALED, WTERMSIG): Remove definitions,
now that gnulib guarantees they are defined in <sys/wait.h>.
* src/operand2sig.c: Likewise.
* src/kill.c: Likewise.
2010-05-03 12:26:00 +02:00
Paul Eggert
d861519d2a sort: use long doubles only when effective
* src/sort.c (general_numcompare): Don't use long double if strtold
is not available, as it may introduce needless overhead.
2010-05-01 23:25:39 +01:00
Jim Meyering
5e9a7ae46b build: update gnulib submodule to latest; bootstrap, too 2010-04-30 18:27:19 +02:00
Pádraig Brady
8b5087d4e6 sort: use long doubles for general numeric mode
* src/sort.c (general_numcompare): Use long doubles unconditionally,
and strtold when available, to convert numbers with greater range and
precision.  Performance was seen to be on par with standard doubles.
* doc/coreutils.texi (sort invocation): Amend the -g description to
mention long double rather than double, and strtold rather than strtod.
* src/getlimits.c (main): Output floating point limits for use in tests.
* tests/misc/sort-float: A new test to ensure sort is using long
doubles when possible, and that locale specific floats are handled.
* tests/Makefile.am: Reference the new test.
* tests/test-lib.sh (getlimits_): Normalize indenting.
* NEWS: Mention the new behaviour.
Reported by Nelson Beebe.
2010-04-29 18:55:57 +01:00
Jim Meyering
7905d6d34d build: remove now-duplicate use of AC_SYS_LARGEFILE
* m4/jm-macros.m4 (gl_CHECK_ALL_TYPES): Don't require AC_SYS_LARGEFILE,
now that gnulib does it.
2010-04-29 16:41:22 +02:00
Jim Meyering
518a8664a2 build: remove now-useless configure-time header checks
* m4/jm-macros.m4 (gl_CHECK_ALL_HEADERS): Don't test for headers
that gnulib now provides: sys/ioctl.h, sys/time.h, sys/wait.h.
2010-04-29 16:41:22 +02:00
Jim Meyering
83e4f0ca02 doc: tweak factor-describing wording
* doc/coreutils.texi (factor invocation): Don't say that "factoring
large prime numbers is hard".  A pedant might ding you, since it's
trivial to factor a number that is known to be prime.  Instead, say
that "factoring large numbers... is hard".  Reported by Andreas Eder.
2010-04-25 10:35:51 +02:00
Jim Meyering
2191fe8f8d maint: remove now-unnecessary #if HAVE_header_H tests.
* .x-sc_prohibit_always_true_header_tests: New file.
* Makefile.am (syntax_check_exceptions): Add it.
* src/cat.c: Remove #if HAVE_SYS_IOCTL_H test.
* src/copy.c: Likewise.
* src/ls.c: Likewise.
* src/stty.c: Likewise.
* src/install.c: Remove #if HAVE_SYS_WAIT_H test.
* src/kill.c: Likewise.
* src/operand2sig.c: Likewise.
* src/timeout.c: Likewise.
* src/pathchk.c: Remove #if HAVE_WCHAR_H test.
* src/stat.c: Remove #if HAVE_NETINET_IN_H test.
2010-04-24 17:44:58 +02:00
Jim Meyering
a4ab8d9c55 build: enable gnulib modules for more replacement headers
* bootstrap.conf (gnulib_modules): Add the following:
netinet_in, sys_ioctl, sys_wait, so that we can eliminate
the #if HAVE_<header>_H tests guarding their header inclusions.
2010-04-24 17:16:56 +02:00
Jim Meyering
301c74865e tests: clean up also upon SIGQUIT
* tests/test-lib.sh: Also trap on SIGQUIT.
Spotted by Dmitry V. Levin.
2010-04-24 15:50:41 +02:00
Jim Meyering
765d67410c post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2010-04-23 18:36:32 +02:00
Jim Meyering
1d10eb8b1e version 8.5
* NEWS: Record release date.
2010-04-23 17:18:16 +02:00
Dmitry V. Levin
c0a121c9bc tests: fix exit status of signal handlers in shell scripts
The value of `$?' on entrance to signal handlers in shell scripts
cannot be relied upon, so set the exit code explicitly.

* cfg.mk (sc_always_defined_macros, sc_system_h_headers): Set
the exit code in signal handler explicitly to 128 + SIG<SIGNAL>.
* src/Makefile.am (sc_tight_scope): Likewise.
* tests/test-lib.sh: Likewise.
2010-04-23 15:44:19 +02:00
Eric Blake
c9e4ea6ee2 base64: always treat input in binary mode
Necessary for cygwin.  Technically, this patch is not correct,
in that it clobbers O_APPEND, but it is no different than any
other use of xfreopen to force binary mode, so all such uses
should be fixed at once in a later patch.

* src/base64.c (main): Open input in binary mode.
* THANKS: Update.
Reported by Yutaka Amanai.
2010-04-22 08:42:54 -06:00
Jim Meyering
819265b8be build: update gnulib submodule to latest 2010-04-21 20:05:52 +02:00
Eric Blake
a9b904a282 docs: document transformation of obsolete sort syntax
* doc/coreutils.texi (sort invocation): Mention the conversion.
2010-04-21 07:59:03 -06:00
Pádraig Brady
7dc398a30f maint: update a couple of NEWS items for the pending release
* NEWS: Mention that cp and mv from the previous release did
not support preserving extended attributes (fixed in e489fd04).
Improve the grammar for the "cp capabilities" item.
2010-04-21 07:55:38 +01:00
Pádraig Brady
8fc12909f6 sort: fix parsing of end field in obsolescent key formats
This regression was introduced in commit 224a69b5, 2009-02-24,
"sort: Fix two bugs with determining the end of field".
The specific regression being that we include 1 field too many when
an end field is specified using obsolescent key syntax (+POS -POS).

* src/sort.c (struct keyfield): Clarify the description of the eword
member, as suggested by Alan Curry.
(main): When processing obsolescent format key specifications,
normalize eword to a zero based count when no specific end char is given
for an end field. This matches what's done when keys are specified with -k.
* tests/misc/sort: Add a few more tests for the obsolescent key formats,
with test 07i being the particular failure addressed by this change.
* THANKS: Add Alan Curry who precisely identified the issue.
* NEWS: Mention the fix.
Reported by Santiago Rodríguez
2010-04-20 22:37:18 +01:00
Pádraig Brady
1777d0dfe3 cp: preserve "capabilities" when also preserving file ownership
* src/copy.c (copy_reg): Copy xattrs _after_ setting file ownership
so that capabilities are not cleared when setting ownership.
* tests/cp/capability: A new root test.
* tests/Makefile.am (root_tests): Reference the new test.
* NEWS: Mention the fix.
2010-04-16 23:02:02 +01:00
Jim Meyering
56fce1aed7 * HACKING (Add tests): Change example name, "newtest" to "new-test".
Not that anyone would confuse with something newt-related, but just
because it is more readable that way.

doc: tweak HACKING
2010-04-16 08:42:47 +02:00
Jim Meyering
36cc6ac787 doc: tweak HACKING
* HACKING (Curly braces): Tweak a sentence.  Filter a few
paragraphs through "fmt".
2010-04-16 08:21:32 +02:00
Pádraig Brady
62dd4b63c5 maint: fix build on platforms that replace strsignal
* src/Makefile.am (kill_LDADD): Add $(LIBTHREAD) so that
we link with the appropriate libraries to provide Thread Local Storage
on platforms that replace strsignal (like AIX for example).

Tested-by: Daniel Richard G. <danielg@teragram.com>
2010-04-16 00:55:43 +01:00
Pádraig Brady
3a1595a3fb tests: avoid spurious failure of ls/color-norm test
* tests/ls/color-norm: Use the "time" output by `ls -l`
to check normal style.  Previously we used the size from `ls -s`,
but the size of "empty" files can vary depending on whether
SELinux is enabled for example.
2010-04-16 00:26:21 +01:00
Jim Meyering
f8291d0ec4 doc: document our code formatting policy regarding curly braces
* HACKING (Curly braces: use judiciously): New section.
2010-04-15 18:52:41 +02:00
Jim Meyering
05bee6f116 tests: avoid spurious failure of root-only ls/capability test
* tests/ls/capability: Adjust this test not to expect the no-op escape
sequence that was removed from all other tests by 2010-01-30 commit
5d43617e, "ls --color: don't emit a final no-op escape sequence".
2010-04-14 15:48:31 +02:00
Pádraig Brady
584e38d8b3 cp: treat selinux warnings consistently
* src/copy.c (copy_reg): Suppress SELinux ENOTSUP warnings consistently
between the destination being present or not.  Previously we did
not suppress ENOTSUP messages when the destination was present.
(copy_internal): Use the same ENOTSUP supression method as
copy_reg() even though the issue was not seen in this case.
* tests/cp/cp-a-selinux: Add a test case for the issue and
group the other test cases in the file more coherently.
* tests/cp/cp-mv-enotsup-xattr: Do the same check for xattr
warnings, even though they did not have the issue.
2010-04-13 13:09:50 +01:00
Pádraig Brady
c420cfef77 doc: clarify when cp and mv output xattr warnings
The 2010-03-26 commit, 4c38625e, "doc: fix info on cp --preserve..."
was not entirely correct as cp --preserve=all does produce some
xattr warnings.

* src/copy.h: Update and clarify the comments for reduce_diagnostics
and require_preserve_{xattr,context}.
* doc/coreutils.texi (cp invocation): Update the -a and
--preserve=xattr,context options to say when and which
xattr warnings are output.
(mv invocation): Mention that some warnings are output
when preserving xattrs.
2010-04-12 10:06:11 +01:00
Pádraig Brady
be9a42e7ac doc: mention that "capabilities" are preserved by cp/mv
* doc/coreutils.texi (cp invocation): Mention that
"capabilities" are preserved when implemented using
extended attributes.
(mv invocation): Mention ACLs etc. are maintained
due to xattrs being copied.
2010-04-11 16:37:40 +01:00
Jie Liu
20a5a60c61 build: tell ./bootstrap to check for xz up-front
* bootstrap.conf (buildreq): Add xz to the list.
2010-04-11 17:09:35 +02:00
Jim Meyering
0ba945b050 tests: more syntax-checks
* gnulib: update to latest
* cfg.mk (sc_prohibit_empty_lines_at_EOF): Remove, now that it's
in gnulib's maint.mk.
(_hv_file): Override the default.
2010-04-11 11:29:00 +02:00
Jim Meyering
8c4b6ba09b maint: new syntax-check rule: prohibit empty lines at EOF
* cfg.mk (detect_empty_lines_at_EOF_): Define.
(sc_prohibit_empty_lines_at_EOF): New rule.
* .x-sc_prohibit_empty_lines_at_EOF: New file.  Exempt pr test inputs.
* Makefile.am (syntax_check_exceptions): Add it.
Pádraig Brady suggested to parse the output of tail -n1.
2010-04-10 20:26:39 +02:00
Mike Frysinger
ac6feeb9f2 dircolors: add rxvt-256color and rxvt-unicode256
* src/dircolors.hin: Add them.
2010-04-09 16:28:46 +02:00
Jim Meyering
ef5758c328 maint: ftruncate is always available, even without gnulib
Now that even MinGW provides ftruncate, we know that all
reasonable portability targets provide this function.
Remove the workaround code.  We nearly removed the gnulib
module three years ago:
  http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/9203
and it is now officially "obsolete".
* bootstrap.conf (gnulib_modules): Remove ftruncate.
* src/copy.c (copy_reg): Remove use of HAVE_FTRUNCATE and its
no-longer-used workaround code.
* src/truncate.c: Remove a comment about handling missing ftruncate.
2010-04-09 10:50:43 +02:00
James Youngman
0a9302e7f7 doc: make wc --help say how it defines a 'word'
* src/wc.c (usage): Add wc's definition of "word".
2010-04-08 23:53:12 +02:00
Jim Meyering
9e66806e28 doc: adjust a header in announcement email template
* README-release: Use Mail-Followup-To: rather than Reply-To:.
The former works more reliably, at least with Gnus.
2010-04-08 08:45:23 +02:00
Jim Meyering
f6b2f46714 tests: add a PATH-sanity-check to help-version
* tests/misc/help-version: Sync from gzip's version.
* tests/check.mk (TESTS_ENVIRONMENT): Export VERSION, as required
for new help-version test.
2010-04-07 11:47:28 +02:00
Jim Meyering
f267926f2d maint: fix a masked syntax-check violation
* m4/jm-macros.m4 (ARGMATCH_DIE): Use usage(EXIT_FAILURE), not usage(1).
* .x-sc_prohibit_magic_number_exit: Remove *.m4 exemption that was
masking the above.
2010-04-06 16:02:27 +02:00
Jim Meyering
6f6f599867 build: update gnulib submodule to latest 2010-04-06 16:02:19 +02:00
Jim Meyering
2dc09bf809 build: update gnulib submodule to latest 2010-04-05 09:03:23 +02:00
Marc Kleine-Budde
98dacf492e tail: include sys/vfs.h (if possible) when sys/statfs.h is absent
* src/tail.c [HAVE_INOTIFY && !HAVE_SYS_STATFS_H]: Include <sys/vfs.h>.
2010-04-04 09:15:07 +02:00
Jim Meyering
b48a444e35 build: update gnulib submodule to latest
* cfg.mk: Update to use new _sc_search_regexp interface.  Run this:
perl -pi -e 's/\b_prohibit_regexp\b/_sc_search_regexp/;'
  -e 's/\bmsg=/halt=/; s/\bre=/prohibit=/;' cfg.mk
and then adjust backslashes so they still line up.
2010-04-02 20:31:14 +02:00
Jim Meyering
6416762b73 doc: synchronize parts of README-release from grep's version
* README-release (FIXME): Add Reply-To, use coreutils@gnu.org
for announcements.  Update savannah-verbatim-announcement procedure.
2010-03-31 08:58:40 +02:00
Jim Meyering
a8fc4edca5 build: update gnulib submodule to latest 2010-03-29 08:28:51 +02:00
Jim Meyering
3f7091359a tests: disable new texinfo-acronym syntax-check from gnulib
* cfg.mk (local-checks-to-skip): Add new sc_texinfo_acronym, to skip it.
2010-03-29 08:28:51 +02:00
Bruno Haible
0f5dc96354 build: update after change in gnulib's lib-ignore module
* src/Makefile.am (AM_LDFLAGS): Define.  Use gnulib's new
$(IGNORE_UNUSED_LIBRARIES_CFLAGS).
2010-03-29 08:28:51 +02:00
Jim Meyering
5ef03d6c5b tests: avoid spurious sc_prohibit_test_minus_ao syntax-check failures
* tests/misc/ls-time: Change comments and diagnostics.
* tests/misc/xattr: Likewise.
2010-03-29 08:28:51 +02:00
Jim Meyering
8915368ee3 tests: fix typos in envvar-check script
* tests/envvar-check: Fix variable name typos.
Probably harmless, since no selected shell would fail to unset.
2010-03-26 16:49:48 +01:00
Pádraig Brady
b4f9559537 nice,chroot: use more standard option parsing
Related to the 2010-03-25 commit, 88d4b346,
"timeout: use more standard option parsing".
* src/nice.c (main): Don't use parse_long_options()
which is a helper for commands that don't have any
long options specific to them.
* src/chroot.c (main): Likewise.
* tests/misc/nice-fail: Remove a case that now
passes due to us accepting multiple instances of the
--help and --version options.
* tests/misc/chroot-fail: Likewise.
2010-03-26 14:31:16 +00:00
Kim Hansen
88d4b3461e timeout: use more standard option parsing
* src/timeout.c (main): Don't use parse_long_options()
which is a helper for commands that don't have any
long options specific to them.
* tests/misc/timeout-parameters: Remove a case that now
passes due to us accepting multiple instances of the
--help and --version options.
* THANKS: Add the author.

Signed-off-by: Pádraig Brady <P@draigBrady.com>
2010-03-26 14:27:54 +00:00
Pádraig Brady
4c38625ef3 doc: fix info on cp --preserve=all, which does _not_ give xattr warnings
The info docs have been inaccurate since 2009-04-17, commit 941bd482,
"mv: ignore xattr-preservation failure when not supported by filesystem"
* doc/coreutils.texi (cp invocation): Say that cp --preserve=all
does _not_ output errors when failing to copy xattrs.
2010-03-26 14:19:37 +00:00
Jim Meyering
946359f101 cfg.mk: remove comments with sed rather than cpp -fpreprocessed
* cfg.mk (_sed_remove_comments): Define, starting with gettext's
moopp sed code, but factoring it to be more understandable.
(sc_space_before_open_paren): Adapt.
Prompted by Bruno Haible's suggestion to use gettext's moopp code.
2010-03-21 12:23:16 +01:00
Jim Meyering
9f793def3c cfg.mk: fix copy-paste-o in a diagnostic
* cfg.mk (sc_space_before_open_paren): Mention cpp -fpreprocessed,
not cppi, when cpp -fpreprocessed doesn't work.
Spotted by Eric Blake.
2010-03-20 13:45:56 +01:00
Jim Meyering
628a5e16dd maint: enforce one small aspect of formatting style: space-before-"("
* cfg.mk (sc_space_before_open_paren): New rule.
2010-03-20 12:14:46 +01:00
Jim Meyering
773d15a702 maint: code formatting nit
* src/system.h (ST_NBLOCKS): Add space before paren.
2010-03-20 12:11:50 +01:00
Pádraig Brady
c872a1d8a5 maint: mbsalign: fix an edge case where we truncate too much
* gl/lib/mbsalign.c (mbsalign): Ensure the temporary destination buffer
is big enough, as it may need to be bigger than the source buffer
in the presence of single byte non printable chars.
* gl/tests/test-mbsalign.c (main): Add a test to trigger the issue.
2010-03-19 21:40:05 +00:00
Pádraig Brady
dfe0d336a0 maint: update the mbsalign module
* gl/lib/mbsalign.c (mbsalign):  Support the MBA_UNIBYTE_FALLBACK
flag which reverts to unibyte mode if one can't allocate memory
or if there are invalid multibyte characters present.
Note memory is no longer dynamically allocated in unibyte mode so
one can assume that mbsalign() will not return an error if this
flag is present.  Don't calculate twice, the number of spaces,
when centering.  Suppress a signed/unsigned comparison warning.
(ambsalign): A new wrapper function to dynamically allocate
the minimum memory required to hold the aligned string.
* gl/lib/mbsalign.h: Add the MBA_UNIBYTE_FALLBACK flag and
also document others that may be implemented in future.
(ambsalign): A prototype for the new wrapper.
* gl/tests/test-mbsalign.c (main): New test program.
* gl/modules/mbsalign-tests: A new index to reference the tests.
* .x-sc_program_name: Exclude test-mbsalign.c from this check.
2010-03-19 19:23:45 +00:00
Paolo Bonzini
3dcbcf98f4 tests: change help-version to per-program functions
* help-version: Change each *_args variable to a *_setup function.
2010-03-19 13:13:08 +01:00
Jim Meyering
dd9df4ab02 doc: tweak README-prereq again
* README-prereq: Change one more: s/coreutils/This package/
2010-03-19 11:34:15 +01:00
Jim Meyering
54158a45fa doc: make README-prereq more generic
* README-prereq: Adjust wording and reduce number of mentions of
"coreutils", so it's easier to reuse in another package: grep.
2010-03-19 10:14:46 +01:00
Eric Blake
da2f637888 rm: tweak wording about loss of data warning
* src/rm.c (usage): Update wording to make two points more
apparent: undelete is not trivial, and partial recovery should be
a consideration factor in deciding whether rm is secure enough.
Initially suggested by Reuben Thomas.
2010-03-18 15:41:59 -06:00
Ralf Wildenhues
cab29edcf1 revert "maint: mark makefile "dist-hook" target as PHONY"
* src/Makefile.am (dist-hook): Do not mark this target
as PHONY, explicitly.  Automake does it for us.
2010-03-18 21:08:07 +01:00
Eric Blake
b44d4b6b0e doc: improve ls --help's description of --escape (-b)
* src/ls.c (usage): Be more precise about how --escape (-b) works:
say "C-style escapes", not "octal escapes".  Reported by Jacky Fong.
2010-03-18 17:41:12 +01:00
Jim Meyering
d75820e516 maint: mark makefile "dist-hook" target as PHONY
* src/Makefile.am (dist-hook): Mark target as PHONY.
2010-03-18 08:32:26 +01:00
Jim Meyering
46e0137277 maint: add a space before open-paren, where lacking
* src/copy.c (copy_reg): Likewise.
* src/cut.c (main): Likewise.
* src/dd.c (main): Likewise.
* src/getlimits.c (print_int): Likewise.
* src/join.c (join): Likewise.
* src/pwd.c (logical_getcwd): Likewise.
* src/sort.c (specify_nmerge, mergefps, avoid_trashing_input): Likewise.
(merge): Likewise.
* src/uptime.c (usage): Likewise.
2010-03-17 18:28:28 +01:00
Pádraig Brady
c403c31e88 timeout: add the --kill-after option
Based on a report from Kim Hansen who wanted to
send a KILL signal to the monitored command
when `timeout` itself received a termination signal.
Rather than changing such a signal into a KILL,
we provide the more general mechanism of sending
the KILL after the specified grace period.

* src/timeout.c (cleanup): If a non zero kill delay
is specified, (re)set the alarm to that delay, after
which a KILL signal will be sent to the process group.
(usage): Mention the new option.  Separate the description
of DURATION since it's now specified in 2 places.
Clarify that the duration is an integer.
(parse_duration): A new function refactored from main(),
since this logic is now called for two parameters.
(main): Parse the -k option.
* doc/coreutils.texi (timeout invocation): Describe the
new --kill-after option and use @display rather than
@table to show the duration suffixes.  Clarify that
a duration of 0 disables the associated timeout.
* tests/misc/timeout-parameters: Check invalid --kill-after.
* tests/misc/timeout: Check a valid --kill-after works.
* NEWS: Mention the new feature.
2010-03-16 23:10:15 +00:00
Jim Meyering
4edb86215d build: update gnulib submodule to latest
The latest from gnulib once again passes all tests.
2010-03-13 14:21:16 +01:00
Jim Meyering
64bc4f20e8 revert to previous working version of gnulib
This reverts commit 0c31cdc2d1.
2010-03-13 10:31:15 +01:00
Thien-Thi Nguyen
141645d9c6 doc: use mktemp, not tempfile, in a shred usage example
* doc/coreutils.texi (shred invocation):
Use mktemp(1) instead of Debian-specific tempfile(1).
2010-03-13 08:37:01 +01:00
Jim Meyering
0c31cdc2d1 build: update gnulib submodule to latest 2010-03-12 08:39:11 +01:00
Eric Blake
4323ed2bde maint: drop *.lzma suport
* .gitignore: Remove *.lzma lines.
2010-03-11 11:55:45 -07:00
Eric Blake
c971ed9377 maint: ignore *.xz files
* .gitignore: Ignore *.xz created by 'make dist', now that we
no longer produce *.lzma.
2010-03-10 16:29:44 -07:00
Jim Meyering
998fe29301 remove: without -f, avoid unnecessary-expense/issues with euidaccess
* src/remove.c (write_protected_non_symlink): If faccessat fails,
return 1 or -1 directly, rather than falling back on euidaccess*.
2010-03-10 11:05:18 +01:00
Pádraig Brady
612c2c95c3 doc: Add an example for cutting fields separated by runs of blanks
* doc/coreutils.texi (cut invocation): Show how tr can be used
to process the input for cut in this case.
Suggestion from Dan Jacobson.
2010-03-09 00:32:07 +00:00
Pádraig Brady
a7b4fa01dd maint: rename the si_present variable in sort to iec_present
* src/sort.c: The units containing 'i' are actually IEC not SI.
2010-03-04 10:54:21 +00:00
Joey Degges
dae35bac98 sort: inform the system about our input access pattern
Tell the system that we'll access input sequentially,
so that we more efficiently process uncached files in a few cases:

Reading from faster flash devices. E.g. 21 MB/s key:
  NORMAL     31.6s (26.8 user)
  SEQUENTIAL 27.7s
  WILLNEED   27.7s

Processing in parallel with readahead when using a small 1M buffer:
  NORMAL     24.7s (21.1 user)
  SEQUENTIAL 22.7s
  WILLNEED   25.6s

A small benefit when merging:
  NORMAL     25.0s (16.9 user)
  SEQUENTIAL 24.6s (16.6 user)
  WILLNEED   38.4s (13.1 user)

Note WILLNEED is presented above for comparison to show it
has some unwanted characteristics due to its synchronous
prepopulation of the cache. It has a good benefit on a
mechanical disk @ 80MB/s and a multicore system with
competing processes:
  NORMAL     14.73s
  SEQUENTIAL 10.95s
  WILLNEED   05.22s
However the scheduling differences causing this result
are probably best explicitly managed using `nice` etc.

* m4/jm-macros.m4 (coreutils_MACROS): check for posix_fadvise().
* src/sort.c (fadvise_input): A new function to apply
the POSIX_FADV_SEQUENTIAL hint to an input stream.
(stream_open): Call the above function for all input streams.
2010-03-04 10:42:00 +00:00
Jim Meyering
168a6b6a0f tests: don't let the LANGUAGE envvar perturb tests
* tests/envvar-check (vars): Add LANGUAGE to the list of envvars
to unset.  At least in glibc (as an extension to POSIX), its value
actually trumps LC_ALL:

  $ LC_ALL=es_ES LANGUAGE=fr_FR.UTF-8 /bin/cat no-such
  /bin/cat: no-such: Aucun fichier ou dossier de ce type

but only when the default locale is not C:

  $ LC_ALL=C LANGUAGE=fr_FR.UTF-8 /bin/cat no-such
  /bin/cat: no-such: No such file or directory

Prompted by a report from Mads Kiilerich.
2010-03-04 10:46:11 +01:00
Pádraig Brady
59e2e55d0f sort: fix issues with month sorting in some locales
* src/sort.c (char fold_toupper[]): Change to unsigned
so as the correct comparisons are made in getmonth().
This fixes unibyte locales where abbreviated months
have characters that are > 0x7F, but it also works for
multibyte locales with the caveat that multibyte characters
are matched case sensitively.
With this change, the following example sorts correctly:
  $ echo -e "1 márta\n2 Feabhra" | LANG=ga_IE.utf8 sort -k2,2M
  2 Feabhra
  1 márta
* src/sort.c (inittables): Since we ignore blanks around months
in the input, don't include them when they're present in the locale.
With this change, the following example sorts correctly:
  $ echo -e "1 2月\n2 1月" | LANG=ja_JP.utf8 sort -k2,2M
  2 1月
  1 2月
* tests/misc/sort-month: A new test to exercise the above cases.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the fix.
2010-03-01 10:58:02 +00:00
Eric Blake
2590389aab bootstrap: resynchronize from gnulib
* gnulib: Update to latest.
* bootstrap: Copy from gnulib/build-aux/bootstrap.
* README-hacking: Describe how to use GNULIB_SRCDIR.
2010-02-25 09:29:46 -07:00
Eric Blake
9a6c97eb29 expr: clarify error message
* src/expr.c (eval4, eval3): Clarify that expr expects integers,
and not the broader category of numbers.
* tests/misc/expr: Update test accordingly.
Suggested by Dan Jacobson.
2010-02-25 08:54:49 -07:00
Pádraig Brady
0b5bd805bd maint: clean up the output from syntax-check rules
* cfg.mk (sc_tight_scope): Pass the -s (silent) flag to `make`
so that it doesn't report about calling sub makes.
(sc_check-AUTHORS): Likewise.
(sc_strftime_check): Don't display stderr from `info`.
* src/Makefile.am (sc_tight_scope): Don't annotate with "GEN".
(sc_check-AUTHORS): Likewise.
2010-02-19 11:41:19 +00:00
Moritz Orbach
f5268e2749 ls: fix a regression by honoring NORMAL attributes again
Output the NORMAL attribute before non file name text.
This attribute will continue into file names that would
not otherwise be colored unless FILE is also set.
The regression was introduced with commit 483297d5, 28-02-2009,
"ls --color no longer outputs unnecessary escape sequences".

* src/ls.c (set_normal_color): A new function to output the
NORMAL attribute sequence if it's enabled.
(print_current_files): Output NORMAL before printing long format info.
(print_file_name_and_frills): Output NORMAL before printing file name.
(print_color_indicator): Reset the attributes before a file name with
attributes so that NORMAL attributes will not combine with them.
(print_name_with_quoting): Ensure attributes are reset after printing
the file name if NORMAL attributes were output.
* tests/ls/color-norm: A new test for NORMAL and FILE combinations.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the fix.
Reported in https://savannah.gnu.org/bugs/?26512
2010-02-17 23:25:12 +00:00
Pádraig Brady
cba49d57da maint: fix the man page correlation tests
These checks were not being run as distcheck-hook targets
are only supported in the top-level Makefile.  Instead
these tests are now run during a syntax-check.

* cfg.mk (sc_man_file_correlation):  A new syntax check to
call the 2 existing tests to check the correlation between
the programs and man/*.[1x].
* man/Makefile.am (sc_man_file_correlation): Call the 2 existing
man page correlation tests.
(check-x-vs-1): Remove the "GEN" annotation as it's a bit verbose.
(check-programs-vs-x): Likewise.
* src/Makefile.am (all_programs.list): Exclude libstdbuf.so
from the list of programs.  This issue was not noticed as
the checks were not actually being run.
2010-02-16 15:19:40 +00:00
Pádraig Brady
a2f81776ad tests: fix an unlikely race in tail-2/inotify-hash-abuse2
* tests/tail-2/inotify-hash-abuse2: Explicitly kill the process
by using cleanup_() rather than using a timeout which may trigger
a failure on very slow systems (< 20 iterations of the loop per second).
2010-02-16 00:51:38 +00:00
Pádraig Brady
11d84c10ce doc: fix inconsistent capitalization in --help output
* src/base64.c (usage): Don't capitalize the first character
in an --option description.
* src/stdbuf.c (usage): Likewise.
* src/truncate.c (usage): Likewise.
* cfg.mk (sc_option_desc_uppercase): A new syntax check to
stop this happening in future.
* man/Makefile.am (sc_option_desc_uppercase): Ensure all
man pages are generated, then search for erroneous uppercase chars.
* src/Makefile.am (all_programs): Ensure all
commands are built so that all man pages can be generated.
2010-02-15 23:42:49 +00:00
Jim Meyering
58c98f2342 remove.c: remove three unnecessary #include directives
* src/remove.c: Don't include hash.h, hash-pjw.h or obstack.h.
They have been unused since the fts rewrite.
2010-02-15 19:26:30 +01:00
Eric Blake
7ae60bf26f build: ignore another gnulib artifact
* .gitignore: Add lib/warn-on-use.h.
2010-02-15 06:56:11 -07:00
Eric Blake
d4de2dc83a dirname: improve man page description
* doc/coreutils.texi (dirname invocation): Properly cover behavior
on directory.
* man/dirname.x: Likewise.
* THANKS: Update.
Reported by Emmanuel Lacour.
2010-02-15 06:56:07 -07:00
Pádraig Brady
45b46f4951 doc: remove extraneous periods from --help output
* src/join.c (usage): Mention "fields" rather than repeating "line"
so that it's more obvious that the fields are still parsed, and
thus -o is still honored for headers.  Also remove an extraneous
'.' reported by Stéphane Raimbault.
* src/base64.c (usage): Remove extraneous blank line and order
the options alphabetically.  Also remove an extraneous '.'
* src/chown.c (usage): Remove extraneous '.'
* src/cp.c (usage): Likewise.
* src/mktemp.c (usage): Likewise.
* src/pr.c (usage): Likewise.
* src/stat.c (usage): Likewise.
* src/uniq.c (usage): Likewise.
2010-02-11 08:01:15 +00:00
Jim Meyering
9f650d0870 doc: add a TODO item
* TODO: Consider adding a col implementation.
2010-02-10 07:25:58 +01:00
Jim Meyering
ed509250a2 copy.c: improve a comment
* src/copy.c (copy_reg): The comment about POSIXLY_CORRECT refers
only to cp, not to any other application that uses copy.c.
2010-02-07 21:02:18 +01:00
James R. Van Zandt
543696a9af doc: add a cross reference from tac's man page to "rev"
* man/tac.x: See also "rev".
2010-02-07 17:18:34 +01:00
Jim Meyering
86573d33a7 tests: include help-version test settings used by gzip and grep
* tests/misc/help-version: ...the better to keep this file in sync.
2010-02-07 17:18:02 +01:00
Jim Meyering
cea6d15720 doc: rewrite part of README-release
* README-release (Pre-release testing): Reorganize.
2010-02-07 09:10:53 +01:00
Jim Meyering
69cc8d5cb7 sync with gnulib
* gl/lib/regcomp.c.diff: Update to apply to changed version in gnulib.
* gnulib: Update submodule to latest.
2010-02-05 10:30:31 +01:00
Pádraig Brady
dd2253f49d tests: fix various timeout races
Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/277485

* tests/misc/timeout: Set all expected timeouts to 1s and all
unexpected timeouts to 10s. In this way, tests normally proceed
quickly but may delay up to 10s before reporting failures.
* tests/ls/infloop: Likewise.
* tests/tail-2/pid: Likewise.
* tests/tail-2/pipe-f: Likewise.
* tests/tail-2/wait: Likewise.
* tests/dd/skip-seek-past-dev: Likewise.
2010-02-02 15:16:40 +00:00
Ondřej Vašík
f53a0e1062 tests: cp-a-selinux: skip the test if mounting a loop device fails
* tests/cp/cp-a-selinux: Skip the test (instead of fail) if we
fail to mount a loop device (e.g., none available).
2010-02-01 16:46:34 +01:00
Pádraig Brady
628b1d5e7e maint: fix a typo in NEWS
* NEWS: s/contains/contain/
2010-02-01 15:40:44 +00:00
Pádraig Brady
f86bb6967d join: make -t '' operate on the whole line
Previously passing an empty parameter to -t would
raise an error, but now it means to treat each line
as a single field for matching.  This matches the
default operation of `sort` which is usually used
in conjunction with join.

* src/join.c (main): Set the field delimiter to '\n' if
an empty parameter is passed to -t.
(usage): Mention the operation of -t ''.
* tests/misc/join: Add 2 new tests, for the existing -t '\0'
and the new -t '' functionality.
* doc/coreutils.texi (join invocation): Mention that
join -t '' always operates on the whole line, while
join -t '\0' usually does.
* NEWS: Mention the change in behavior.
2010-02-01 15:36:56 +00:00
Assaf Gordon
819aa9eba7 join: add --header option to always output the first line
This essentially allows one to use --check-order with headings.
Note join without --check-order will already handle the common case
where headings do match in each file, however using --check-order will fail
often when the header sorts after the first line of data.

Note also that this will join header lines from each file even if
they don't match, with headings from the first file being used.

* NEWS: Mention the new option.
* doc/coreutils.texi (join invocation): Describe the new option.
* src/join.c (usage): Likewise.
(join): Join the header lines unconditionally.
* tests/misc/join: Add 5 new tests.
2010-02-01 13:57:42 +00:00
Pádraig Brady
86914603b5 maint: fix an inconsequential memory leak in join
* src/join.c (join): Refactor the code that checks for misorder
at the tail of the files.  The most significant change here is
that freeline() is called thus silencing a valgrind warning about
a definite but inconsequential memory leak.
(freeline): Make more general by doing nothing when passed NULL,
and setting freed pointers to NULL.
2010-02-01 13:52:58 +00:00
Pádraig Brady
6e8f368e07 maint: use $(CONFIG_INCLUDE) rather than the hardcoding lib/config.h
* tests/check.mk (TESTS_ENVIRONMENT): Use the generated CONFIG_INCLUDE
variable.  Note $(abs_builddir)/$(CONFIG_HEADER) also currently works,
but $(CONFIG_HEADER) is deprecated and may not be generated in future.
$(CONFIG_INCLUDE) was made available by gnulib in commit, 22970f8a,
"syntax-check: detect incorrect boolean macro values in config.h"
2010-02-01 13:32:46 +00:00
Jim Meyering
5d43617e8a ls --color: don't emit a final no-op escape sequence
* src/ls.c (main): With --color, avoid emitting the final color-
resetting escape sequence when it would be a no-op.
* tests/ls/color-clear-to-eol: Adjust expected output accordingly.
* tests/ls/color-dtype-dir: Likewise.
* tests/ls/multihardlink: Likewise.
* tests/ls/stat-free-symlinks: Likewise.
* tests/misc/ls-misc: Likewise.
* NEWS (Changes in behavior): Mention it.
C de-Avillez rebased and adapted four of the new sl-dangle*
tests in tests/misc/ls-misc.
Reported by Jim Avera in
http://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/494663
2010-02-01 08:26:12 +01:00
Jim Meyering
5d4952059f maint: move vulnerable-Makefile.in-check to gnulib
* cfg.mk (sc_vulnerable_makefile_CVE-2009-4029): Move rule to...
* gnulib: Update to latest, to get updated "maint.mk".
2010-01-28 09:38:31 +01:00
Jim Meyering
c7ecdb0fcb maint: add a syntax-check rule to check for vulnerable Makefile.in
* cfg.mk (sc_vulnerable_makefile_CVE-2009-4029): New rule.
2010-01-27 22:41:33 +01:00
Kamil Dudka
aad0bde0b5 who --mesg (-T) can use a more accurate test for TTY writability
Enabled when coreutils is configured with --with-tty-group.
Based on a patch written by Piotr Gackiewicz.  Details at
http://bugzilla.redhat.com/454261

* src/who.c (is_tty_writable): A new function returning true if a TTY
device is writable by the group.  Additionally it checks the group to be
the same as TTY_GROUP_NAME when compiled with --with-tty-group.
* m4/jm-macros.m4: Introduce a new configure option --with-tty-group.
* NEWS: Mention the change.
2010-01-25 11:43:49 +01:00
Jim Meyering
0caead1ea0 tests: fix a syntax-check rule to pass in non-srcdir build
* cfg.mk (sc_x_sc_dist_check): This coreutils-specific syntax-check
rule would fail in a non-srcdir build, since in that case, each name
from $(VC_LIST) starts with "$(srcdir)/".  Fix that.
* gnulib: Update to latest, to pull in a required maint.mk change.
2010-01-24 14:51:31 +01:00
Pádraig Brady
9c566ad04a tests: make cp-mv-enotsup-xattr independent of the host file system
* tests/cp-mv-enotsup-xattr: Create a file system from which to copy
the xattrs so that the test is not skipped if the host file system
does not have user_xattr support.  Also don't erroneously fail when
built without xattr support.
2010-01-23 23:44:51 +00:00
Pádraig Brady
3e8586bc54 doc: add nproc to the texinfo overview menu
* doc/coreutils.texi: Add nproc to the System context
command list in the overview menu.
2010-01-23 23:06:59 +00:00
Pádraig Brady
014fead953 maint: ensure test independence from config macro format
* tests/cp/acl: Support USE_ACL not being defined.
* tests/mv/acl: Likewise. Also fix typo in skip message.
* tests/cp/preserve-slink-time: Support HAVE_UTIMENSAT being 0.
* tests/touch/no-dereference: Likewise.
* tests/ls/capability: Normalize so 1 is not required to be last char.
2010-01-23 22:53:52 +00:00
Eric Blake
e489fd04d6 build: fix failure from bogus USE_XATTR definition
* m4/xattr.m4 (gl_FUNC_ADDR): Fix regression introduced in commit
6beca4248.
* THANKS: Update.
Reported by Adam Sampson.
2010-01-19 06:41:57 -07:00
Jim Meyering
31423c76e8 libstdbuf: plug a very unlikely leak
* src/libstdbuf.c (apply_mode): Don't leak "buf" upon setvbuf failure.
2010-01-18 12:03:18 +01:00
Jim Meyering
cd349fdca2 pr: avoid two over-allocations
* src/pr.c (init_store_cols): Allocate N*sizeof(*VAR) bytes,
not N*sizeof(int*).  The latter would mistakenly allocate double
the required space on a system with 8-byte pointers.
2010-01-18 12:03:06 +01:00
Jim Meyering
eccf54368f maint: add missing "post-release push" step to release procedure
* README-release: Push the automated release and post-release
NEWS-updating commits.
Pádraig Brady reported that I'd pushed the tag without also
pushing the followup commit.
2010-01-14 06:39:11 -07:00
Jim Meyering
7ba0e90c55 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2010-01-13 22:14:16 +01:00
234 changed files with 8260 additions and 2932 deletions

6
.gitignore vendored
View File

@@ -40,14 +40,15 @@ coreutils-*.tar.bz2
coreutils-*.tar.bz2.sig
coreutils-*.tar.gz
coreutils-*.tar.gz.sig
coreutils-*.tar.lzma
coreutils-*.tar.lzma.sig
coreutils-*.tar.xz
coreutils-*.tar.xz.sig
gnulib-tests
lib/.cvsignore
lib/.gitignore
lib/arg-nonnull.h
lib/arpa
lib/binary-io.h
lib/c++defs.h
lib/charset.alias
lib/configmake.h
lib/glthread
@@ -60,6 +61,7 @@ lib/selinux
lib/unistr
lib/uniwidth
lib/unused-parameter.h
lib/warn-on-use.h
m4/.cvsignore
m4/.gitignore
maint.mk

10
.mailmap Normal file
View File

@@ -0,0 +1,10 @@
# Map git author names and email addresses to canonical/preferred form.
<jim@meyering.net> <meyering@iou.iou>
<jim@meyering.net> <meyering@rho.meyering.net>
<jim@meyering.net> <meyering@vm.meyering.net.localdomain>
Paul R. Eggert <eggert@cs.ucla.edu> <eggert@penguin.cs.ucla.edu>
Paul R. Eggert <eggert@cs.ucla.edu> <eggert@CS.UCLA.EDU>
# Evan's two changes listed my email address.
Evan Hunt <ethanol@armory.com> Evan Hunt <jim@meyering.net>
<P@draigBrady.com> <P@draigBrady.com (trivial change)>
Pádraig Brady <p@draigbrady.com> <p@draigBrady.com>

View File

@@ -1 +1 @@
8.3
8.5

View File

@@ -1,2 +1,3 @@
gl/lib/randint.c
lib/euidaccess-stat.c
gl/tests/.*\.c

View File

@@ -0,0 +1 @@
src/seq.c

View File

@@ -0,0 +1,2 @@
^m4/stat-prog\.m4$
ChangeLog

View File

@@ -0,0 +1 @@
^tests/pr/

View File

@@ -1,3 +1,4 @@
\.mk$
/Makefile\.am$
^tests/init\.sh$
^tests/test-lib\.sh$

View File

@@ -1,3 +1,2 @@
configure.ac
*.m4
ChangeLog*

105
HACKING
View File

@@ -233,6 +233,107 @@ Try to make the summary line fit one of the following forms:
maint: change-description
Curly braces: use judiciously
=============================
Omit the curly braces around an "if", "while", "for" etc. body only when
that body occupies a single line. In every other case we require the braces.
This ensures that it is trivially easy to identify a single-*statement* loop:
each has only one *line* in its body.
Omitting braces with a single-line body is fine:
while (expr)
single_line_stmt ();
However, the moment your loop/if/else body extends onto a second line,
for whatever reason (even if it's just an added comment), then you should
add braces. Otherwise, it would be too easy to insert a statement just
before that comment (without adding braces), thinking it is already a
multi-statement loop:
while (true)
/* comment... */ // BAD: multi-line body without braces
single_line_stmt ();
Do this instead:
while (true)
{ /* Always put braces around a multi-line body. */
/* explanation... */
single_line_stmt ();
}
There is one exception: when the second body line is not at the same
indentation level as the first body line.
if (expr)
error (0, 0, _("a diagnostic that would make this line"
" extend past the 80-column limit"));
It is safe to omit the braces in the code above, since the
further-indented second body line makes it obvious that this is still
a single-statement body.
To reiterate, don't do this:
if (expr)
while (expr_2) // BAD: multi-line body without braces
{
...
}
Do this, instead:
if (expr)
{
while (expr_2)
{
...
}
}
However, there is one exception in the other direction, when even a
one-line block should have braces. That occurs when that one-line,
brace-less block is an "else" block, and the corresponding "then" block
*does* use braces. In that case, either put braces around the "else"
block, or negate the "if"-condition and swap the bodies, putting the
one-line block first and making the longer, multi-line block be the
"else" block.
if (expr)
{
...
...
}
else
x = y; // BAD: braceless "else" with braced "then"
This is preferred, especially when the multi-line body is more than a
few lines long, because it is easier to read and grasp the semantics of
an if-then-else block when the simpler block occurs first, rather than
after the more involved block:
if (!expr)
x = y; /* more readable */
else
{
...
...
}
If you'd rather not negate the condition, then add braces:
if (expr)
{
...
...
}
else
{
x = y;
}
Use SPACE-only indentation in all[*] files
==========================================
We use space-only indentation in nearly all files.
@@ -310,9 +411,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. Note to run tests/misc/newtest in isolation you can do:
as possible. Note to run tests/misc/new-test in isolation you can do:
(cd tests && make check TESTS=misc/newtest VERBOSE=yes)
(cd tests && make check TESTS=misc/new-test 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

View File

@@ -46,7 +46,9 @@ syntax_check_exceptions = \
.x-sc_obsolete_symbols \
.x-sc_po_check \
.x-sc_program_name \
.x-sc_prohibit_always-defined_macros \
.x-sc_prohibit_atoi_atof \
.x-sc_prohibit_empty_lines_at_EOF \
.x-sc_prohibit_fail_0 \
.x-sc_prohibit_magic_number_exit \
.x-sc_prohibit_stat_st_blocks \
@@ -58,6 +60,7 @@ syntax_check_exceptions = \
.x-sc_sun_os_names \
.x-sc_system_h_headers \
.x-sc_trailing_blank \
.x-sc_prohibit_always_true_header_tests \
.x-sc_unmarked_diagnostics \
.x-sc_useless_cpp_parens

154
NEWS
View File

@@ -1,5 +1,159 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 8.6 (2010-10-15) [stable]
** Bug fixes
du no longer multiply counts a file that is a directory or whose
link count is 1, even if the file is reached multiple times by
following symlinks or via multiple arguments.
du -H and -L now consistently count pointed-to files instead of
symbolic links, and correctly diagnose dangling symlinks.
du --ignore=D now ignores directory D even when that directory is
found to be part of a directory cycle. Before, du would issue a
"NOTIFY YOUR SYSTEM MANAGER" diagnostic and fail.
split now diagnoses read errors rather than silently exiting.
[bug introduced in coreutils-4.5.8]
tac would perform a double-free when given an input line longer than 16KiB.
[bug introduced in coreutils-8.3]
tail -F once again notices changes in a currently unavailable directory,
and works around a Linux kernel bug where inotify runs out of resources.
[bugs introduced in coreutils-7.5]
tr now consistently handles case conversion character classes.
In some locales, valid conversion specifications caused tr to abort,
while in all locales, some invalid specifications were undiagnosed.
[bugs introduced in coreutils 6.9.90 and 6.9.92]
** New features
cp now accepts the --attributes-only option to not copy file data,
which is useful for efficiently modifying files.
du recognizes -d N as equivalent to --max-depth=N, for compatibility
with FreeBSD.
sort now accepts the --debug option, to highlight the part of the
line significant in the sort, and warn about questionable options.
sort now supports -d, -f, -i, -R, and -V in any combination.
stat now accepts the %m format directive to output the mount point
for a file. It also accepts the %w and %W format directives for
outputting the birth time of a file, if one is available.
** Changes in behavior
df now consistently prints the device name for a bind mounted file,
rather than its aliased target.
du now uses less than half as much memory when operating on trees
with many hard-linked files. With --count-links (-l), or when
operating on trees with no hard-linked files, there is no change.
ls -l now uses the traditional three field time style rather than
the wider two field numeric ISO style, in locales where a style has
not been specified. The new approach has nicer behavior in some
locales, including English, which was judged to outweigh the disadvantage
of generating less-predictable and often worse output in poorly-configured
locales where there is an onus to specify appropriate non-default styles.
[The old behavior was introduced in coreutils-6.0 and had been removed
for English only using a different method since coreutils-8.1]
rm's -d now evokes an error; before, it was silently ignored.
sort -g now uses long doubles for greater range and precision.
sort -h no longer rejects numbers with leading or trailing ".", and
no longer accepts numbers with multiple ".". It now considers all
zeros to be equal.
sort now uses the number of available processors to parallelize
the sorting operation. The number of sorts run concurrently can be
limited with the --parallel option or with external process
control like taskset for example.
stat now provides translated output when no format is specified.
stat no longer accepts the --context (-Z) option. Initially it was
merely accepted and ignored, for compatibility. Starting two years
ago, with coreutils-7.0, its use evoked a warning. Printing the
SELinux context of a file can be done with the %C format directive,
and the default output when no format is specified now automatically
includes %C when context information is available.
stat no longer accepts the %C directive when the --file-system
option is in effect, since security context is a file attribute
rather than a file system attribute.
stat now outputs the full sub-second resolution for the atime,
mtime, and ctime values since the Epoch, when using the %X, %Y, and
%Z directives of the --format option. This matches the fact that
%x, %y, and %z were already doing so for the human-readable variant.
touch's --file option is no longer recognized. Use --reference=F (-r)
instead. --file has not been documented for 15 years, and its use has
elicited a warning since coreutils-7.1.
truncate now supports setting file sizes relative to a reference file.
Also errors are no longer suppressed for unsupported file types, and
relative sizes are restricted to supported file types.
* Noteworthy changes in release 8.5 (2010-04-23) [stable]
** Bug fixes
cp and mv once again support preserving extended attributes.
[bug introduced in coreutils-8.4]
cp now preserves "capabilities" when also preserving file ownership.
ls --color once again honors the 'NORMAL' dircolors directive.
[bug introduced in coreutils-6.11]
sort -M now handles abbreviated months that are aligned using blanks
in the locale database. Also locales with 8 bit characters are
handled correctly, including multi byte locales with the caveat
that multi byte characters are matched case sensitively.
sort again handles obsolescent key formats (+POS -POS) correctly.
Previously if -POS was specified, 1 field too many was used in the sort.
[bug introduced in coreutils-7.2]
** New features
join now accepts the --header option, to treat the first line of each
file as a header line to be joined and printed unconditionally.
timeout now accepts the --kill-after option which sends a kill
signal to the monitored command if it's still running the specified
duration after the initial signal was sent.
who: the "+/-" --mesg (-T) indicator of whether a user/tty is accepting
messages could be incorrectly listed as "+", when in fact, the user was
not accepting messages (mesg no). Before, who would examine only the
permission bits, and not consider the group of the TTY device file.
Thus, if a login tty's group would change somehow e.g., to "root",
that would make it unwritable (via write(1)) by normal users, in spite
of whatever the permission bits might imply. Now, when configured
using the --with-tty-group[=NAME] option, who also compares the group
of the TTY device with NAME (or "tty" if no group name is specified).
** Changes in behavior
ls --color no longer emits the final 3-byte color-resetting escape
sequence when it would be a no-op.
join -t '' no longer emits an error and instead operates on
each line as a whole (even if they contain NUL characters).
* Noteworthy changes in release 8.4 (2010-01-13) [stable]
** Bug fixes

3
README
View File

@@ -223,6 +223,9 @@ For general documentation on the coding and usage standards
this distribution follows, see the GNU Coding Standards,
http://www.gnu.org/prep/standards_toc.html.
For any copyright year range specified as YYYY-ZZZZ in this package
note that the range specifies every single year in that closed interval.
Mail suggestions and bug reports for these programs to
the address on the last line of --help output.

View File

@@ -28,11 +28,23 @@ You can get a copy of the source repository like this:
$ git clone git://git.sv.gnu.org/coreutils
$ cd coreutils
As an optional step, if you already have a copy of the gnulib git
repository on your hard drive, then you can use it as a reference to
reduce download time and disk space requirements:
$ export GNULIB_SRCDIR=/path/to/gnulib
The next step is to get and check other files needed to build,
which are extracted from other source packages:
$ ./bootstrap
To use the most-recent gnulib (as opposed to the gnulib version that
the package last synchronized to), do this next:
$ git submodule foreach git pull origin master
$ git commit -m 'build: update gnulib submodule to latest' gnulib
And there you are! Just
$ ./configure --quiet #[--enable-gcc-warnings] [*]
@@ -54,6 +66,29 @@ to use recent system headers. If you configure with this option,
and spot a problem, please be sure to send the report to the bug
reporting address of this package, and not to that of gnulib, even
if the problem seems to originate in a gnulib-provided file.
* Submitting patches
If you develop a fix or a new feature, please send it to the
appropriate bug-reporting address as reported by the --help option of
each program. One way to do this is to use vc-dwim
<http://www.gnu.org/software/vc-dwim/>), as follows.
Run the command "vc-dwim --help", copy its definition of the
"git-changelog-symlink-init" function into your shell, and then run
this function at the top-level directory of the package.
Edit the ChangeLog file that this command creates, creating a
properly-formatted entry according to the GNU coding standards
<http://www.gnu.org/prep/standards/html_node/Change-Logs.html>.
Run the command "vc-dwim" and make sure its output looks good.
Run "vc-dwim --commit".
Run the command "git format-patch --stdout -1", and email its output
in, using the output's subject line.
-----
Copyright (C) 2002-2010 Free Software Foundation, Inc.

View File

@@ -10,9 +10,12 @@ coreutils package, see these:
http://mail.gnu.org/mailman/listinfo/coreutils-announce
http://mail.gnu.org/mailman/listinfo/bug-coreutils
http://mail.gnu.org/mailman/listinfo/coreutils
mailing list archives are here:
http://news.gmane.org/gmane.comp.gnu.coreutils.announce
http://news.gmane.org/gmane.comp.gnu.core-utils.bugs (up to the minute)
http://mail.gnu.org/pipermail/bug-coreutils/ (updated every 12 hours)
http://news.gmane.org/gmane.comp.gnu.coreutils.general
http://mail.gnu.org/pipermail/coreutils/ (updated every 12 hours)

View File

@@ -14,14 +14,18 @@ I.E. the tools checked for by the bootstrap script and include:
- Texinfo <http://www.gnu.org/software/texinfo/>
Note please try to install/build official packages for your system.
If these are not available then one can make them available only to
the coreutils build using the following instructions. Even if the
official packages for your system are too old, please install them
as they may be required to build the newer versions. The examples
below build into $HOME/coreutils/deps/, so first ensure that your
$PATH is set correctly, which can be done for the current shell like:
If these programs are not available use the following instructions
to build them and install the results into a directory that you will
then use when building this package.
export PATH=$HOME/coreutils/deps/bin:$PATH
Even if the official version of a package for your system is too old,
please install it, as it may be required to build the newer versions.
The examples below install into $HOME/coreutils/deps/, so if you are
going to follow these instructions, first ensure that your $PATH is
set correctly by running this command:
prefix=$HOME/coreutils/deps
export PATH=$prefix/bin:$PATH
* autoconf *
@@ -29,7 +33,7 @@ $PATH is set correctly, which can be done for the current shell like:
git clone --depth=1 git://git.sv.gnu.org/autoconf.git
git checkout v2.62
autoreconf -vi
./configure --prefix=$HOME/coreutils/deps
./configure --prefix=$prefix
make install
* automake *
@@ -39,10 +43,10 @@ $PATH is set correctly, which can be done for the current shell like:
cd automake
git checkout v1.11.1
./bootstrap
./configure --prefix=$HOME/coreutils/deps
./configure --prefix=$prefix
make install
coreutils uses XZ utils (successor to LZMA) to create
This package uses XZ utils (successor to LZMA) to create
a compressed distribution tarball. Using this feature of Automake
requires version 1.10a or newer, as well as the xz program itself.
@@ -51,7 +55,7 @@ requires version 1.10a or newer, as well as the xz program itself.
git clone git://ctrl.tukaani.org/xz.git
cd xz
./autogen.sh
./configure --prefix=$HOME/coreutils/deps
./configure --prefix=$prefix
make install
Now one can build coreutils as described in README-hacking.
Now you can build this package as described in README-hacking.

View File

@@ -13,26 +13,39 @@ Here are most of the steps we (maintainers) follow when making a release.
* Ensure that you're on "master" with no uncommitted diffs.
This should produce no output: git checkout master; git diff
* Run bootstrap: ./bootstrap
* Ensure that you've pushed all changes that belong in the release
and that the NixOS/Hydra autobuilder is reporting all is well:
http://hydra.nixos.org/jobset/gnu/coreutils-master
* Run bootstrap one last time. This downloads any new translations:
./bootstrap
FIXME: enable excluded programs like arch? to get their manual pages?
* Pre-release testing:
Ensure that make check syntax-check succeeds.
On at least one SELinux-enabled (enforcing) and one non-SELinux system,
run all tests, both root-only and regular.
Run *all* non-root tests, including expensive and very expensive ones i.e.,
run this: make -j1 check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
Run the root-only tests:
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
Run the following on at least one SELinux-enabled (enforcing) and
one non-SELinux system:
* Run "make distcheck"
make distcheck
make -j1 check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root
Note the -j1 above. If you use -jN, for larger N, some of the expensive
tests are likely to interfere with concurrent performance-measuring or
timing-sensitive tests, resulting in spurious failures.
If "make distcheck" doesn't run "make syntax-check" for you, then run
it manually:
make syntax-check
* Set the date, version number, and release type [stable/alpha/beta] on
line 3 of NEWS, commit that, and tag the release by running e.g.,
build-aux/do-release-commit-and-tag 8.1 beta
build-aux/do-release-commit-and-tag X.Y stable
* Run the following to create release tarballs. Your choice selects the
corresponding upload-to destination in the emitted gnupload command.
@@ -46,7 +59,8 @@ FIXME: enable excluded programs like arch? to get their manual pages?
it builds and passes all tests.
* While that's happening, write the release announcement that you will
soon post.
soon post. Start with the template, $HOME/announce-coreutils-X.Y
that was just created by that "make" command.
Once all the builds and tests have passed,
@@ -56,21 +70,14 @@ Once all the builds and tests have passed,
download all tarball/signature pairs and use gpg --verify to ensure
that they're all valid.
* Push the new tag:
* Push the NEWS-updating changes and the new tag:
v=$(cat .prev-version)
git push origin tag v$v
git push origin master tag v$v
* Send the gpg-signed announcement mail, e.g.,
* Announce it on Savannah first, so you can include the preferable
savannah.org announcement link in the email message.
To: info-gnu@gnu.org, coreutils-announce@gnu.org
Cc: coordinator@translationproject.org, bug-coreutils@gnu.org
Subject: coreutils-8.0 released [beta]
* Approve the announcement here:
http://lists.gnu.org/mailman/admindb/coreutils-announce
* Announce it on Savannah, too:
From here:
https://savannah.gnu.org/projects/coreutils/
click on the "submit news", then write something like the following:
@@ -78,13 +85,19 @@ Once all the builds and tests have passed,
the Main -> "Select Features" menu item, or via this link:
https://savannah.gnu.org/project/admin/editgroupfeatures.php?group=coreutils)
Subject: coreutils-0.0 released [beta]
The announcement is here:
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/54
Subject: coreutils-X.Y released [stable]
+verbatim+
...paste the announcement here...
-verbatim-
Then go here to approve it:
https://savannah.gnu.org/news/approve.php?group=coreutils
* Send the announcement email message.
* Approve the announcement here:
http://lists.gnu.org/mailman/admindb/coreutils-announce
* After each non-alpha release, update the on-line manual accessible via
http://www.gnu.org/software/coreutils/manual/

12
THANKS
View File

@@ -8,14 +8,17 @@ the bug-report mailing list (as seen on last line of e.g., cp --help).
??? kytek@cybercomm.net
A Costa agcosta@gis.net
Aaron Burgemeister dajoker@gmail.com
Aaron Hawley ashawley@uvm.edu
Achim Blumensath blume@corona.oche.de
Adam Jimerson vendion@charter.net
Adam Klein aklein@debian.org
Adam Sampson ats@offog.org
Adrian Bunk bunk@stusta.de
AIDA Shinra shinra@j10n.org
Akim Demaille demaille@inf.enst.fr
Alain Magloire alain@qnx.com
Alan Curry pacman@kosh.dhis.org
Alan Iwi iwi@atm.ox.ac.uk
Albert Chin-A-Young china@thewrittenword.com
Albert Hopkins ahopkins@dynacare.com
@@ -101,6 +104,7 @@ Carl Roth roth@urs.us
Carlos Canau Carlos.Canau@relay.puug.pt
Charles Karney karney@pppl.gov
Charles Randall crandall@matchlogic.com
Chas. Owens chas.owens@gmail.com
Chip Salzenberg chip@valinux.com
Chris Clayton chris2553@googlemail.com
Chris Faylor cgf@cygnus.com
@@ -128,6 +132,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 Hipschman dsh@linux.ucla.edu
Dan Jacobson jidanni@jidanni.org
Dan Pascu dan@services.iiruc.ro
Daniel Bergstrom noa@melody.se
@@ -177,6 +182,7 @@ Elbert Pol elbert.pol@gmail.com
Eli Zaretskii eliz@is.elta.co.il
Elias Pipping pipping@gentoo.org
Emile LeBlanc leblanc@math.toronto.edu
Emmanuel Lacour elacour@home-dn.net
Erik Auerswald auerswal@unix-ag.uni-kl.de
Eric Backus ericb@lsid.hp.com
Eric Blake ebb9@byu.net
@@ -189,6 +195,7 @@ Evan Hunt ethanol@armory.com
Felix Lee flee@teleport.com
Felix Rauch Valenti frauch@cse.unsw.edu.au
Ferdinand fw@scenic.mine.nu
Filipus Klutiero chealer@gmail.com
Fletcher Mattox fletcher@cs.utexas.edu
Florent Bayle florent@sarcelle.net
Florian Schlichting fschlich@cis.fu-berlin.de
@@ -253,6 +260,7 @@ Ilya N. Golubev gin@mo.msk.ru
Ingo Saitz ingo@debian.org
Ivan Labath labath3@st.fmph.uniba.sk
Ivo Timmermans ivo@debian.org
Jacky Fong jacky.fong@utoronto.ca
James james@albion.glarp.com
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
James Lemley James.Lemley@acxiom.com
@@ -334,6 +342,7 @@ Keith Owens kaos@audio.apana.org.au
Keith Thompson kst@cts.com
Ken Pizzini kenp@halcyon.com
Kevin Mudrick kmudrick@healthmarketscience.com
Kim Hansen kim@i9.dk
Kirk Kelsey kirk.kelsey@0x4b.net
Kristin E Thomas kristint@us.ibm.com
Kjetil Torgrim Homme kjetilho@ifi.uio.no
@@ -494,6 +503,7 @@ Philippe Schnoebelen Philippe.Schnoebelen@imag.fr
Phillip Jones mouse@datastacks.com
Piergiorgio Sartor sartor@sony.de
Pieter Bowman bowman@math.utah.edu
Piotr Gackiewicz gacek@intertele.pl
Piotr Kwapulinski kwap@univ.gda.pl
Prashant TR tr@eth.net
Priit Jõerüüt jemm4jemm@yahoo.com
@@ -519,6 +529,7 @@ Robert H. de Vries robert@and.nl
Robert Lindgren robert@orcafat.com
Robert Millan zeratul2@wanadoo.es
Robert Schwebel r.schwebel@pengutronix.de
Robin H. Johnson robbat2@gentoo.org
Rogier Wolff R.E.Wolff@BitWizard.nl
Roland Huebner ro-huebner@gmx.de
Roland Turner raz.tah.bet@raz.cx
@@ -630,6 +641,7 @@ Wolfram Kleff kleff@cs.uni-bonn.de
Won-kyu Park wkpark@chem.skku.ac.kr
Yanko Kaneti yaneti@declera.com
Yann Dirson dirson@debian.org
Yutaka Amanai yasai-itame1942@jade.plala.or.jp
Zvi Har'El rl@math.technion.ac.il
;; Local Variables:

3
TODO
View File

@@ -34,6 +34,9 @@ printf:
platforms where the native *printf(3) is deficient.
Suggestion from Eric Blake.
consider adding some implementation of the "col" utility
Suggested by Karl Berry.
renice: POSIX utility, needs implementing.
suggestion from Karl Berry (among others).
Bob Proulx is working on this.

140
bootstrap
View File

@@ -1,4 +1,6 @@
#! /bin/sh
# Print a version string.
scriptversion=2010-10-05.15; # UTC
# Bootstrap this package from checked-out sources.
@@ -17,7 +19,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Written by Paul Eggert.
# Originally written by Paul Eggert. The canonical version of this
# script is maintained as build-aux/bootstrap in gnulib, however, to
# be useful to your project, you should place a copy of it under
# version control in the top-level directory of your project. The
# intent is that all customization can be done with a bootstrap.conf
# file also maintained in your version control; gnulib comes with a
# template build-aux/bootstrap.conf to get you started.
# Please report bugs or propose patches to bug-gnulib@gnu.org.
nl='
'
@@ -43,7 +53,7 @@ Options:
sources reside. Use this if you already
have gnulib sources on your machine, and
do not want to waste your bandwidth downloading
them again.
them again. Defaults to \$GNULIB_SRCDIR.
--copy Copy files instead of creating symbolic links.
--force Attempt to bootstrap even if the sources seem
not to have been checked out.
@@ -80,7 +90,8 @@ bootstrap_epilogue() { :; }
# options because the latest/%s directory and the .po files within are
# all symlinks.
po_download_command_format=\
"rsync -Lrtvz 'translationproject.org::tp/latest/%s/' '%s'"
"rsync --delete --exclude '*.s1' -Lrtvz \
'translationproject.org::tp/latest/%s/' '%s'"
extract_package_name='
/^AC_INIT(/{
@@ -133,7 +144,8 @@ XGETTEXT_OPTIONS='\\\
--flag=error:3:c-format --flag=error_at_line:5:c-format\\\
'
# Package bug report address for gettext files
# Package bug report address and copyright holder for gettext files
COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
MSGID_BUGS_ADDRESS=bug-$package@gnu.org
# Files we don't want to import.
@@ -160,7 +172,6 @@ vc_ignore=auto
# die otherwise.
find_tool ()
{
# Find sha1sum, named gsha1sum on MacPorts.
find_tool_envvar=$1
shift
find_tool_names=$@
@@ -188,8 +199,8 @@ find_tool ()
eval "export $find_tool_envvar"
}
# Find sha1sum, named gsha1sum on MacPorts.
find_tool SHA1SUM sha1sum gsha1sum
# Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
find_tool SHA1SUM sha1sum gsha1sum shasum
# Override the default configuration, if necessary.
# Make sure that bootstrap.conf is sourced from the current directory
@@ -335,8 +346,12 @@ check_versions() {
ret=0
while read app req_ver; do
# We only need libtoolize from the libtool package.
if test "$app" = libtool; then
app=libtoolize
fi
# Honor $APP variables ($TAR, $AUTOCONF, etc.)
appvar=`echo $app | tr '[a-z]' '[A-Z]'`
appvar=`echo $app | tr '[a-z]-' '[A-Z]_'`
test "$appvar" = TAR && appvar=AMTAR
eval "app=\${$appvar-$app}"
inst_ver=$(get_version $app)
@@ -359,16 +374,30 @@ check_versions() {
print_versions() {
echo "Program Min_version"
echo "----------------------"
printf "$buildreq"
printf %s "$buildreq"
echo "----------------------"
# can't depend on column -t
}
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
if test $use_libtool = 1; then
find_tool LIBTOOLIZE glibtoolize libtoolize
fi
if ! printf "$buildreq" | check_versions; then
test -f README-prereq &&
echo "See README-prereq for notes on obtaining these prerequisite programs:" >&2
echo
print_versions
echo >&2
if test -f README-prereq; then
echo "See README-prereq for notes on obtaining the prerequisite programs" >&2
else
echo "Please install the prerequisite programs" >&2
fi
exit 1
fi
@@ -390,7 +419,7 @@ fi
cleanup_gnulib() {
status=$?
rm -fr gnulib
rm -fr "$gnulib_path"
exit $status
}
@@ -398,6 +427,9 @@ git_modules_config () {
test -f .gitmodules && git config --file .gitmodules "$@"
}
gnulib_path=`git_modules_config submodule.gnulib.path`
: ${gnulib_path=gnulib}
# Get gnulib files.
case ${GNULIB_SRCDIR--} in
@@ -407,30 +439,44 @@ case ${GNULIB_SRCDIR--} in
git submodule init || exit $?
git submodule update || exit $?
elif [ ! -d gnulib ]; then
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib 1 2 13 15
git clone --help|grep depth > /dev/null && shallow='--depth 2' || shallow=
git clone $shallow git://git.sv.gnu.org/gnulib ||
shallow=
git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
cleanup_gnulib
trap - 1 2 13 15
fi
GNULIB_SRCDIR=gnulib
GNULIB_SRCDIR=$gnulib_path
;;
*)
# Redirect the gnulib submodule to the directory on the command line
# if possible.
# Use GNULIB_SRCDIR as a reference.
if test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then
git submodule init
GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
git_modules_config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
echo "$0: getting gnulib files..."
git submodule update || exit $?
GNULIB_SRCDIR=gnulib
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_SRCDIR" \
"$gnulib_path" || exit $?
else
# This fallback allows at least git 1.5.5.
if test -f "$gnulib_path"/gnulib-tool; then
# Since file already exists, assume submodule init already complete.
git submodule update || exit $?
else
# Older git can't clone into an empty directory.
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_SRCDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init && git submodule update \
|| exit $?
fi
fi
GNULIB_SRCDIR=$gnulib_path
fi
;;
esac
@@ -448,22 +494,24 @@ download_po_files() {
eval "$cmd"
}
# Download .po files to $po_dir/.reference and copy only the new
# Mirror .po files to $po_dir/.reference and copy only the new
# or modified ones into $po_dir. Also update $po_dir/LINGUAS.
# Note po files that exist locally only are left in $po_dir but will
# not be included in LINGUAS and hence will not be distributed.
update_po_files() {
# Directory containing primary .po files.
# Overwrite them only when we're sure a .po file is new.
po_dir=$1
domain=$2
# Download *.po files into this dir.
# Mirror *.po files into this dir.
# Usually contains *.s1 checksum files.
ref_po_dir="$po_dir/.reference"
test -d $ref_po_dir || mkdir $ref_po_dir || return
download_po_files $ref_po_dir $domain \
&& ls "$ref_po_dir"/*.po 2>/dev/null |
sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
test "$langs" = '*' && langs=x
@@ -594,7 +642,6 @@ cp_mark_as_generated()
(
echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
echo '#line 1' &&
sed "s!$bt_regex/!!g" "$cp_src"
) > $cp_dst-t &&
if cmp -s "$cp_dst-t" "$cp_dst"; then
@@ -637,7 +684,7 @@ slurp() {
for excluded_file in $excluded_files; do
test "$dir/$file" = "$excluded_file" && continue 2
done
if test $file = Makefile.am; then
if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
copied=$copied${sep}$gnulib_mk; sep=$nl
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || {
@@ -655,7 +702,7 @@ slurp() {
rm -f $dir/$file
sed '
/^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
AC_DEFUN([AM_INTL_SUBDIR], [
AC_DEFUN([AM_INTL_SUBDIR], [])
/^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
$a\
@@ -707,6 +754,12 @@ gnulib_tool_options="\
--local-dir $local_gl_dir\
$gnulib_tool_option_extras\
"
if test $use_libtool = 1; then
case "$gnulib_tool_options " in
*' --libtool '*) ;;
*) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
esac
fi
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
slurp $bt || exit
@@ -749,20 +802,12 @@ grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
for command in \
libtool \
"${ACLOCAL-aclocal} --force -I m4" \
"${ACLOCAL-aclocal} --force -I m4 $ACLOCAL_FLAGS" \
"${AUTOCONF-autoconf} --force" \
"${AUTOHEADER-autoheader} --force" \
"${AUTOMAKE-automake} --add-missing --copy --force-missing"
do
if test "$command" = libtool; then
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"
@@ -788,13 +833,14 @@ if test $with_gettext = yes; then
rm -f po/Makevars
sed '
/^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
/^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
/^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
/^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
/^XGETTEXT_OPTIONS *=/{
s/$/ \\/
a\
'"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
}
' po/Makevars.template >po/Makevars
' po/Makevars.template >po/Makevars || exit 1
if test -d runtime-po; then
# Similarly for runtime-po/Makevars, but not quite the same.
@@ -808,7 +854,7 @@ if test $with_gettext = yes; then
a\
'"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
}
' <po/Makevars.template >runtime-po/Makevars
' po/Makevars.template >runtime-po/Makevars || exit 1
# Copy identical files from po to runtime-po.
(cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
@@ -818,3 +864,11 @@ fi
bootstrap_epilogue
echo "$0: done. Now you can run './configure'."
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

View File

@@ -22,24 +22,12 @@ avoided_gnulib_modules='
--avoid=dummy
'
# These modules are obsolete and can probably be removed soon,
# but leave them in for now to minimize changes.
obsolete_gnulib_modules='
atexit
memcmp
memcpy
memmove
memset
strcspn
strtod
strtol
'
# gnulib modules used by this package.
gnulib_modules="
$avoided_gnulib_modules
$obsolete_gnulib_modules
acl
alignof
alloca
announce-gen
areadlink-with-size
@@ -52,7 +40,7 @@ gnulib_modules="
c-strcase
c-strtod
c-strtold
calloc
calloc-gnu
canon-host
canonicalize
chown
@@ -68,6 +56,7 @@ gnulib_modules="
cycle-check
d-ino
d-type
di-set
diacrit
dirfd
dirname
@@ -79,10 +68,12 @@ gnulib_modules="
exclude
exitfail
faccessat
fadvise
fchdir
fcntl
fcntl-safer
fdl
fdutimensat
file-type
fileblocks
filemode
@@ -97,9 +88,7 @@ gnulib_modules="
fsusage
fsync
ftello
ftruncate
fts
getdate
getgroups
gethrxtime
getline
@@ -108,7 +97,7 @@ gnulib_modules="
getopt-gnu
getpagesize
getpass-gnu
gettext
gettext-h
gettime
gettimeofday
getugroups
@@ -123,6 +112,7 @@ gnulib_modules="
hard-locale
hash
hash-pjw
heap
host-os
human
idcache
@@ -141,7 +131,7 @@ gnulib_modules="
long-options
lstat
maintainer-makefile
malloc
malloc-gnu
manywarnings
mbrtowc
mbsalign
@@ -160,8 +150,10 @@ gnulib_modules="
modechange
mountlist
mpsort
netinet_in
nproc
obstack
parse-datetime
pathmax
perl
physmem
@@ -171,17 +163,17 @@ gnulib_modules="
priv-set
progname
propername
pthread
putenv
quote
quotearg
raise
randint
randperm
readlink
readtokens
readtokens0
readutmp
realloc
realloc-gnu
regex
remove
rename
@@ -206,12 +198,16 @@ gnulib_modules="
stpncpy
strdup-posix
strftime
strpbrk
strsignal
strtod
strtoimax
strtol
strtoumax
symlink
sys_ioctl
sys_stat
sys_wait
termios
timespec
tzset
uname
@@ -314,7 +310,7 @@ autoconf 2.62
automake 1.11.1
autopoint -
bison -
gettext -
gettext 0.18
git 1.4.4
gperf -
gzip -
@@ -322,6 +318,7 @@ makeinfo -
perl 5.5
rsync -
tar -
xz -
"
# Automake requires that ChangeLog exist.
@@ -333,4 +330,15 @@ bootstrap_epilogue()
m=gnulib-tests/gnulib.mk
sed 's,\.\./\.\.,..,g' $m > $m-t
mv -f $m-t $m
# Since this is a "GNU" package, replace this line
# if LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null \
# | grep -v 'libtool:' >/dev/null; then
# with this:
# if true; then
# Why? That pipeline searches all files in $(top_srcdir), and if you
# happen to have large files (or apparently large sparse files), the
# first grep may well run out of memory.
perl -pi -e 's/if LC_ALL=C grep .GNU .PACKAGE.*; then/if true; then/' \
po/Makefile.in.in
}

176
cfg.mk
View File

@@ -18,7 +18,8 @@
manual_title = Core GNU utilities
# Tests not to run as part of "make distcheck".
local-checks-to-skip =
local-checks-to-skip = \
sc_texinfo_acronym
# Tools used to bootstrap this package, used for "announcement".
bootstrap-tools = autoconf,automake,gnulib,bison
@@ -26,11 +27,14 @@ bootstrap-tools = autoconf,automake,gnulib,bison
# Now that we have better tests, make this the default.
export VERBOSE = yes
old_NEWS_hash = beab130e9d41bf8014a0594cfe8b28d4
old_NEWS_hash = 27e765279d5735f99114b57fa097e6bd
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
# Our help-version script is in a slightly different location.
_hv_file ?= $(srcdir)/tests/misc/help-version
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
dd = $(srcdir)/src/dd.c
sc_dd_O_FLAGS:
@@ -93,7 +97,8 @@ sc_root_tests:
# stays in sync with corresponding files in the repository.
sce = syntax_check_exceptions
sc_x_sc_dist_check:
@test "$$( ($(VC_LIST) | sed -n '/^.x-sc_/p'; \
@test "$$( ($(VC_LIST) | sed -n '/\.x-sc_/p' \
| sed 's|^$(_dot_escaped_srcdir)/||'; \
sed -n '/^$(sce) =[ ]*\\$$/,/[^\]$$/p' \
$(srcdir)/Makefile.am \
| sed 's/^ *//;/^$(sce) =/d' \
@@ -101,40 +106,6 @@ sc_x_sc_dist_check:
) | sort | uniq -u)" \
&& { echo 'Makefile.am: $(sce) mismatch' >&2; exit 1; } || :;
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:
@@ -144,13 +115,21 @@ sc_always_defined_macros: .re-defmac
> $@-t
@mv $@-t $@
define gl_trap_
Exit () { set +e; (exit $$1); exit $$1; }; \
for sig in 1 2 3 13 15; do \
eval "trap 'Exit $$(expr $$sig + 128)' $$sig"; \
done
endef
# 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; \
trap 'rc=$$?; rm -f .re-list; exit $$rc' 0; \
$(gl_trap_); \
grep -nE -f .re-list \
$$($(VC_LIST_EXCEPT) | grep '^src/') \
$$($(VC_LIST_EXCEPT) | grep '^\($(srcdir)/\)\?src/') \
&& { echo '$(ME): the above are already included via system.h'\
1>&2; exit 1; } || :; \
fi
@@ -164,11 +143,26 @@ sc_sun_os_names:
ALL_RECURSIVE_TARGETS += sc_tight_scope
sc_tight_scope:
@$(MAKE) -C src $@
@$(MAKE) -s -C src $@
ALL_RECURSIVE_TARGETS += sc_check-AUTHORS
sc_check-AUTHORS:
@$(MAKE) -C src $@
@$(MAKE) -s -C src $@
# Option descriptions should not start with a capital letter
# One could grep source directly as follows:
# grep -E " {2,6}-.*[^.] [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
# but that would miss descriptions not on the same line as the -option.
ALL_RECURSIVE_TARGETS += sc_option_desc_uppercase
sc_option_desc_uppercase:
@$(MAKE) -s -C src all_programs
@$(MAKE) -s -C man $@
# Ensure all man/*.[1x] files are present
ALL_RECURSIVE_TARGETS += sc_man_file_correlation
sc_man_file_correlation:
@$(MAKE) -s -C src all_programs
@$(MAKE) -s -C man $@
# Perl-based tests used to exec perl from a #!/bin/sh script.
# Now they all start with #!/usr/bin/perl and the portability
@@ -183,15 +177,15 @@ sc_no_exec_perl_coreutils:
# Don't use "readlink" or "readlinkat" directly
sc_prohibit_readlink:
@re='\<readlink(at)? \(' \
msg='do not use readlink(at); use via xreadlink or areadlink*' \
$(_prohibit_regexp)
@prohibit='\<readlink(at)? \(' \
halt='do not use readlink(at); use via xreadlink or areadlink*' \
$(_sc_search_regexp)
# Don't use address of "stat" or "lstat" functions
sc_prohibit_stat_macro_address:
@re='\<l?stat '':|&l?stat\>' \
msg='stat() and lstat() may be function-like macros' \
$(_prohibit_regexp)
@prohibit='\<l?stat '':|&l?stat\>' \
halt='stat() and lstat() may be function-like macros' \
$(_sc_search_regexp)
# Ensure that date's --help output stays in sync with the info
# documentation for GNU strftime. The only exception is %N,
@@ -202,7 +196,7 @@ sc_strftime_check:
grep '^ %. ' $(srcdir)/src/date.c | sort \
| $(extract_char) > $@-src; \
{ echo N; \
info libc date calendar format | grep '^ `%.'\' \
info libc date calendar format 2>/dev/null|grep '^ `%.'\'\
| $(extract_char); } | sort > $@-info; \
diff -u $@-src $@-info || exit 1; \
rm -f $@-src $@-info; \
@@ -210,22 +204,22 @@ sc_strftime_check:
# Indent only with spaces.
sc_prohibit_tab_based_indentation:
@re='^ * ' \
msg='TAB in indentation; use only spaces' \
$(_prohibit_regexp)
@prohibit='^ * ' \
halt='TAB in indentation; use only spaces' \
$(_sc_search_regexp)
# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
sc_prohibit_emacs__indent_tabs_mode__setting:
@re='^( *[*#] *)?indent-tabs-mode:' \
msg='use of emacs indent-tabs-mode: setting' \
$(_prohibit_regexp)
@prohibit='^( *[*#] *)?indent-tabs-mode:' \
halt='use of emacs indent-tabs-mode: setting' \
$(_sc_search_regexp)
# Ensure that each file that contains fail=1 also contains fail=0.
# Otherwise, setting file=1 in the environment would make tests fail unexpectedly.
sc_prohibit_fail_0:
@re='\<fail=0\>' \
msg='fail=0 initialization' \
$(_prohibit_regexp)
@prohibit='\<fail=0\>' \
halt='fail=0 initialization' \
$(_sc_search_regexp)
# Ensure that "stdio--.h" is used where appropriate.
sc_require_stdio_safer:
@@ -239,11 +233,73 @@ sc_require_stdio_safer:
else :; \
fi
sc_prohibit_perl_hash_quotes:
@prohibit="\{'[A-Z_]+' *[=}]" \
halt="in Perl code, write \$$hash{KEY}, not \$$hash{'K''EY'}" \
$(_sc_search_regexp)
# Prefer xnanosleep over other less-precise sleep methods
sc_prohibit_sleep:
@re='\<(nano|u)?sleep \(' \
msg='prefer xnanosleep over other sleep interfaces' \
$(_prohibit_regexp)
@prohibit='\<(nano|u)?sleep \(' \
halt='prefer xnanosleep over other sleep interfaces' \
$(_sc_search_regexp)
###########################################################
_p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
_pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
_pre_anchored = ^\($(_pre)\)
_comment_and_close = [^*]\|[*][^/*]\)*[*][*]*/
# help font-lock mode: '
# A sed expression that removes ANSI C and ISO C99 comments.
# Derived from the one in GNU gettext's 'moopp' preprocessor.
_sed_remove_comments = \
/[/][/*]/{ \
ta; \
:a; \
s,$(_pre_anchored)//.*,\1,; \
te; \
s,$(_pre_anchored)/[*]\($(_comment_and_close),\1 ,; \
ta; \
/^$(_pre)[/][*]/{ \
s,$(_pre_anchored)/[*].*,\1 ,; \
tu; \
:u; \
n; \
s,^\($(_comment_and_close),,; \
tv; \
s,^.*$$,,; \
bu; \
:v; \
}; \
:e; \
}
# Quote all single quotes.
_sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
# help font-lock mode: '
_space_before_paren_exempt =? \\n\\$$
_space_before_paren_exempt = \
(^ *\#|\\n\\$$|%s\(to %s|(date|group|character)\(s\))
# Ensure that there is a space before each open parenthesis in C code.
sc_space_before_open_paren:
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
fail=0; \
for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do \
sed '$(_sed_rm_comments_q)' $$c 2>/dev/null \
| grep -i '[[:alnum:]](' \
| grep -vE '$(_space_before_paren_exempt)' \
| grep . && { fail=1; echo "*** $$c"; }; \
done; \
test $$fail = 1 && \
{ echo '$(ME): the above files lack a space-before-open-paren' \
1>&2; exit 1; } || :; \
else :; \
fi
# Override the default Cc: used in generating an announcement.
announcement_Cc_ = $(translation_project_), \
coreutils@gnu.org, coreutils-announce@gnu.org
include $(srcdir)/dist-check.mk

View File

@@ -124,6 +124,13 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wold-style-definition"
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
# For gnulib-tests, the set is slightly smaller still.
nw=
nw="$nw -Wstrict-prototypes"
gl_MANYWARN_COMPLEMENT([GNULIB_TEST_WARN_CFLAGS],
[$GNULIB_WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
fi
AC_FUNC_FORK
@@ -332,7 +339,6 @@ if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
fi
# Limit stdbuf to ELF systems with GCC
optional_pkglib_progs=
AC_MSG_CHECKING([whether this is an ELF system])
AC_EGREP_CPP([yes], [#if __ELF__
yes
@@ -341,7 +347,6 @@ AC_MSG_RESULT([$elf_sys])
if test "$elf_sys" = "yes" && \
test "$GCC" = "yes"; then
gl_ADD_PROG([optional_bin_progs], [stdbuf])
gl_ADD_PROG([optional_pkglib_progs], [libstdbuf.so])
fi
############################################################################
@@ -395,6 +400,13 @@ esac
# corresponding ./configure option argument is comma-separated on input.
gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname,su])
# Now that we know which programs will actually be built up, figure out
# which optional helper progs should be compiled.
optional_pkglib_progs=
case " $optional_bin_progs " in
*' stdbuf '*) gl_ADD_PROG([optional_pkglib_progs], [libstdbuf.so]) ;;
esac
# Set INSTALL_SU if su installation has been requested via
# --enable-install-program=su.
AC_SUBST([INSTALL_SU])
@@ -432,7 +444,7 @@ AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
# As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
# translatable strings, we must use need-formatstring-macros here.
AM_GNU_GETTEXT([external], [need-formatstring-macros])
AM_GNU_GETTEXT_VERSION([0.17])
AM_GNU_GETTEXT_VERSION([0.18])
# For a test of uniq: it uses the $LOCALE_FR envvar.
gt_LOCALE_FR

2
doc/.gitignore vendored
View File

@@ -17,6 +17,8 @@ coreutils.tp
coreutils.vr
fdl.texi
gendocs_template
get_date.texi
getdate.texi
parse-datetime.texi
stamp-vti
version.texi

View File

@@ -17,7 +17,7 @@
info_TEXINFOS = coreutils.texi
EXTRA_DIST = perm.texi getdate.texi constants.texi fdl.texi
EXTRA_DIST = perm.texi parse-datetime.texi constants.texi fdl.texi
# The following is necessary if the package name is 8 characters or longer.
# If the info documentation would be split into 10 or more separate files,

View File

@@ -53,7 +53,7 @@
* df: (coreutils)df invocation. Report file system disk usage.
* dir: (coreutils)dir invocation. List directories briefly.
* dircolors: (coreutils)dircolors invocation. Color setup for ls.
* dirname: (coreutils)dirname invocation. Strip non-directory suffix.
* dirname: (coreutils)dirname invocation. Strip last file name component.
* du: (coreutils)du invocation. Report on disk usage.
* echo: (coreutils)echo invocation. Print a line of text.
* env: (coreutils)env invocation. Modify the environment.
@@ -197,7 +197,7 @@ Free Documentation License''.
* File name manipulation:: dirname basename pathchk mktemp
* Working context:: pwd stty printenv tty
* User information:: id logname whoami groups users who
* System context:: date arch uname hostname hostid uptime
* System context:: date arch nproc uname hostname hostid uptime
* SELinux context:: chcon runcon
* Modified command invocation:: chroot env nice nohup stdbuf su timeout
* Process control:: kill
@@ -377,7 +377,7 @@ Redirection
File name manipulation
* basename invocation:: Strip directory and suffix from a file name
* dirname invocation:: Strip non-directory suffix from a file name
* dirname invocation:: Strip last file name component
* pathchk invocation:: Check file name validity and portability
* mktemp invocation:: Create temporary file or directory
@@ -474,7 +474,7 @@ Date input formats
* Pure numbers in date strings:: 19931219, 1440
* Seconds since the Epoch:: @@1078100502
* Specifying time zone rules:: TZ="America/New_York", TZ="UTC0"
* Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al
* Authors of parse_datetime:: Bellovin, Eggert, Salz, Berets, et al
Opening the software toolbox
@@ -1494,7 +1494,8 @@ Display a @samp{$} after the end of each line.
@itemx --number
@opindex -n
@opindex --number
Number all output lines, starting with 1.
Number all output lines, starting with 1. This option is ignored
if @option{-b} is in effect.
@item -s
@itemx --squeeze-blank
@@ -3413,14 +3414,12 @@ options}.
Note: The MD5 digest is more reliable than a simple CRC (provided by
the @command{cksum} command) for detecting accidental file corruption,
as the chances of accidentally having two files with identical MD5
are vanishingly small. However, it should not be considered truly
secure against malicious tampering: although finding a file with a
given MD5 fingerprint, or modifying a file so as to retain its MD5 are
considered infeasible at the moment, it is known how to produce
different files with identical MD5 (a ``collision''), something which
can be a security issue in certain contexts. For more secure hashes,
consider using SHA-1 or SHA-2. @xref{sha1sum invocation}, and
@ref{sha2 utilities}.
are vanishingly small. However, it should not be considered secure
against malicious tampering: although finding a file with a given MD5
fingerprint is considered infeasible at the moment, it is known how
to modify certain files, including digital certificates, so that they
appear valid when signed with an MD5 digest.
For more secure hashes, consider using SHA-2. @xref{sha2 utilities}.
If a @var{file} is specified as @samp{-} or if no files are given
@command{md5sum} computes the checksum for the standard input.
@@ -3767,8 +3766,8 @@ the final result, after the throwing away.))
@opindex --sort
@cindex general numeric sort
@vindex LC_NUMERIC
Sort numerically, using the standard C function @code{strtod} to convert
a prefix of each line to a double-precision floating point number.
Sort numerically, using the standard C function @code{strtold} to convert
a prefix of each line to a long double-precision floating point number.
This allows floating point numbers to be specified in scientific notation,
like @code{1.0e-34} and @code{10e100}.
The @env{LC_NUMERIC} locale determines the decimal-point character.
@@ -3801,12 +3800,18 @@ converting to floating point.
@opindex --sort
@cindex human numeric sort
@vindex LC_NUMERIC
Sort numerically, as per the @option{--numeric-sort} option below, and in
addition handle IEC or SI suffixes like MiB, MB etc (@ref{Block size}).
Note a mixture of IEC and SI suffixes is not supported and will
be flagged as an error. Also the numbers must be abbreviated uniformly.
I.E. values with different precisions like 6000K and 5M will be sorted
incorrectly.
Sort numerically, first by numeric sign (negative, zero, or positive);
then by @acronym{SI} suffix (either empty, or @samp{k} or @samp{K}, or
one of @samp{MGTPEZY}, in that order; @pxref{Block size}); and finally
by numeric value. For example, @samp{1023M} sorts before @samp{1G}
because @samp{M} (mega) precedes @samp{G} (giga) as an @acronym{SI}
suffix. This option sorts values that are consistently scaled to the
nearest suffix, regardless of whether suffixes denote powers of 1000
or 1024, and it therefore sorts the output of any single invocation of
the @command{df}, @command{du}, or @command{ls} commands that are
invoked with their @option{--human-readable} or @option{--si} options.
The syntax for numbers is the same as for the @option{--numeric-sort}
option; the @acronym{SI} suffix must immediately follow the number.
@item -i
@itemx --ignore-nonprinting
@@ -3939,6 +3944,12 @@ multiple fields.
Example: To sort on the second field, use @option{--key=2,2}
(@option{-k 2,2}). See below for more notes on keys and more examples.
See also the @option{--debug} option to help determine the part
of the line being used in the sort.
@item --debug
Highlight the portion of each line used for sorting.
Also issue warnings about questionable usage to stderr.
@item --batch-size=@var{nmerge}
@opindex --batch-size
@@ -4061,6 +4072,14 @@ have a large sort or merge that is I/O-bound, you can often improve
performance by using this option to specify directories on different
disks and controllers.
@item --parallel=@var{n}
@opindex --parallel
@cindex multithreaded sort
Limit the number of sorts run in parallel to @var{n}. By default,
@var{n} is set to the number of available processors, and values
greater than that are reduced to that limit. Also see
@ref{nproc invocation}.
@item -u
@itemx --unique
@opindex -u
@@ -4114,7 +4133,7 @@ the start and end positions of a field specification, and if it is
inherited from the global options it will be attached to both.
If input lines can contain leading or adjacent blanks and @option{-t}
is not used, then @option{-k} is typically combined with @option{-b} or
an option that implicitly ignores leading blanks (@samp{MghnV}) as otherwise
an option that implicitly ignores leading blanks (@samp{Mghn}) as otherwise
the varying numbers of leading blanks in fields can cause confusing results.
If the start position in a sort field specifier falls after the end of
@@ -4126,6 +4145,11 @@ is counted from the first nonblank character of the field.
@vindex POSIXLY_CORRECT
On older systems, @command{sort} supports an obsolete origin-zero
syntax @samp{+@var{pos1} [-@var{pos2}]} for specifying sort keys.
The obsolete sequence @samp{sort +@var{a}.@var{x} -@var{b}.@var{y}}
is equivalent to @samp{sort -k @var{a+1}.@var{x+1},@var{b}} if @var{y}
is @samp{0} or absent, otherwise it is equivalent to @samp{sort -k
@var{a+1}.@var{x+1},@var{b+1}.@var{y}}.
This obsolete behavior can be enabled or disabled with the
@env{_POSIX2_VERSION} environment variable (@pxref{Standards
conformance}); it can also be enabled when @env{POSIXLY_CORRECT} is
@@ -4150,6 +4174,13 @@ Sort in descending (reverse) numeric order.
sort -n -r
@end example
@item
Run no more that 4 sorts concurrently, using a buffer size of 10M.
@example
sort --parallel=4 -S 10M
@end example
@item
Sort alphabetically, omitting the first and second fields
and the blanks at the start of the third field.
@@ -5318,7 +5349,13 @@ of selected bytes.
Select for printing only the fields listed in @var{field-list}.
Fields are separated by a TAB character by default. Also print any
line that contains no delimiter character, unless the
@option{--only-delimited} (@option{-s}) option is specified
@option{--only-delimited} (@option{-s}) option is specified.
Note @command{cut} does not support specifying runs of whitespace as a
delimiter, so to achieve that common functionality one can pre-process
with @command{tr} like:
@example
tr -s '[:blank:]' '\t' | cut -f@dots{}
@end example
@item -d @var{input_delim_byte}
@itemx --delimiter=@var{input_delim_byte}
@@ -5462,6 +5499,8 @@ locales and options if the output of @command{sort} is fed to
sort a file on its default join field, but if you select a non-default
locale, join field, separator, or comparison options, then you should
do so consistently between @command{join} and @command{sort}.
If @samp{join -t ''} is specified then the whole line is considered which
matches the default operation of sort.
If the input has no unpairable lines, a @acronym{GNU} extension is
available; the sort order can be any order that considers two fields
@@ -5515,6 +5554,15 @@ Do not check that both input files are in sorted order. This is the default.
Replace those output fields that are missing in the input with
@var{string}.
@item --header
@opindex --header
Treat the first line of each input file as a header line. The header lines will
be joined and printed as the first output line. If @option{-o} is used to
specify output format, the header line will be printed according to the
specified format. The header lines will not be checked for ordering even if
@option{--check-order} is specified. Also if the header lines from each file
do not match, the heading fields from the first file will be used.
@item -i
@itemx --ignore-case
@opindex -i
@@ -5563,7 +5611,10 @@ option---are subject to the specified @var{field-list}.
Use character @var{char} as the input and output field separator.
Treat as significant each occurrence of @var{char} in the input file.
Use @samp{sort -t @var{char}}, without the @option{-b} option of
@samp{sort}, to produce this ordering.
@samp{sort}, to produce this ordering. If @samp{join -t ''} is specified,
the whole line is considered, matching the default operation of sort.
If @samp{-t '\0'} is specified then the @acronym{ASCII} @sc{nul}
character is used to delimit the fields.
@item -v @var{file-number}
Print a line for each unpairable line in file @var{file-number}
@@ -6895,11 +6946,10 @@ is 80.
@node Formatting file timestamps
@subsection Formatting file timestamps
By default, file timestamps are listed in abbreviated form. Most
locales use a timestamp like @samp{2002-03-30 23:45}. However, the
default @acronym{POSIX} locale uses a date like @samp{Mar 30@ @ 2002}
for non-recent timestamps, and a date-without-year and time like
@samp{Mar 30 23:45} for recent timestamps.
By default, file timestamps are listed in abbreviated form, using
a date like @samp{Mar 30@ @ 2002} for non-recent timestamps, and a
date-without-year and time like @samp{Mar 30 23:45} for recent timestamps.
This format can change depending on the current locale as detailed below.
A timestamp is considered to be @dfn{recent} if it is less than six
months old, and is not dated in the future. If a timestamp dated
@@ -7326,6 +7376,12 @@ Try to preserve SELinux security context and extended attributes (xattr),
but ignore any failure to do that and print no corresponding diagnostic.
Equivalent to @option{-dR --preserve=all} with the reduced diagnostics.
@itemx --attributes-only
@opindex --attributes-only
Preserve the specified attributes of the original files in the copy,
but do not copy any data. See the @option{--preserve} option for
controlling which attributes to copy.
@item -b
@itemx @w{@kbd{--backup}[=@var{method}]}
@opindex -b
@@ -7487,19 +7543,18 @@ $ mkdir b c; (cd b; : > a; ln -s a b); cp -aL b c; ls -i1 c/b
@end smallexample
@itemx context
Preserve SELinux security context of the file. @command{cp} will fail
if the preserving of SELinux security context is not succesful.
Preserve SELinux security context of the file, or fail with full diagnostics.
@itemx xattr
Preserve extended attributes if @command{cp} is built with xattr support,
and xattrs are supported and enabled on your file system.
If SELinux context and/or ACLs are implemented using xattrs,
Preserve extended attributes of the file, or fail with full diagnostics.
If @command{cp} is built without xattr support, ignore this option.
If SELinux context, ACLs or Capabilities are implemented using xattrs,
they are preserved by this option as well.
@itemx all
Preserve all file attributes.
Equivalent to specifying all of the above, but with the difference
that failure to preserve SELinux security context or extended attributes
does not change @command{cp}'s exit status.
@command{cp} does diagnose such failures.
does not change @command{cp}'s exit status. In contrast to @option{-a},
all but @samp{Operation not supported} warnings are output.
@end table
Using @option{--preserve} with no @var{attribute_list} is equivalent
@@ -7990,6 +8045,11 @@ followed by a multiplier: @samp{b}=512, @samp{c}=1,
@samp{w}=2, @samp{x@var{m}}=@var{m}, or any of the
standard block size suffixes like @samp{k}=1024 (@pxref{Block size}).
Any block size you specify via @samp{bs=}, @samp{ibs=}, @samp{obs=}, @samp{cbs=}
should not be too large---values larger than a few megabytes
are generally wasteful or (as in the gigabyte..exabyte case) downright
counterproductive or error-inducing.
Use different @command{dd} invocations to use different block sizes for
skipping and I/O@. For example, the following shell commands copy data
in 512 KiB blocks between a disk and a tape, but do not save or restore a
@@ -8255,7 +8315,9 @@ the destination partition and the second and third would be left on the
original partition.
@cindex extended attributes, xattr
@command{mv} always tries to copy extended attributes (xattr).
@command{mv} always tries to copy extended attributes (xattr), which may
include SELinux context, ACLs or Capabilities.
Upon failure all but @samp{Operation not supported} warnings are output.
@cindex prompting, and @command{mv}
If a destination file exists but is normally unwritable, standard input
@@ -8425,6 +8487,7 @@ removal is requested. Equivalent to @option{-I}.
When removing a hierarchy recursively, skip any directory that is on a
file system different from that of the corresponding command line argument.
@cindex bind mount
This option is useful when removing a build ``chroot'' hierarchy,
which normally contains no valuable data. However, it is not uncommon
to bind-mount @file{/home} into such a hierarchy, to make it easier to
@@ -8698,7 +8761,7 @@ The intended use of this is to shred a removed temporary file.
For example:
@example
i=`tempfile -m 0600`
i=`mktemp`
exec 3<>"$i"
rm -- "$i"
echo "Hello, world" >&3
@@ -10395,7 +10458,9 @@ This option is equivalent to @option{--block-size=1M}.
For each symbolic links encountered by @command{du},
consider the disk space used by the symbolic link.
@item -d @var{depth}
@item --max-depth=@var{depth}
@opindex -d @var{depth}
@opindex --max-depth=@var{depth}
@cindex limiting output of @command{du}
Show the total for each directory (and file if --all) that is at
@@ -10565,6 +10630,7 @@ Without it, @command{stat} acts on any symbolic link argument directly.
@cindex file systems
Report information about the file systems where the given files are located
instead of information about the files themselves.
This option implies the @option{-L} option.
@item -c
@itemx --format=@var{format}
@@ -10613,6 +10679,7 @@ The valid @var{format} directives for files with @option{--format} and
@item %A - Access rights in human readable form
@item %b - Number of blocks allocated (see @samp{%B})
@item %B - The size in bytes of each block reported by @samp{%b}
@item %C - The SELinux security context of a file, if available
@item %d - Device number in decimal
@item %D - Device number in hex
@item %f - Raw mode in hex
@@ -10621,6 +10688,7 @@ The valid @var{format} directives for files with @option{--format} and
@item %G - Group name of owner
@item %h - Number of hard links
@item %i - Inode number
@item %m - Mount point (See note below)
@item %n - File name
@item %N - Quoted file name with dereference if symbolic link
@item %o - I/O block size
@@ -10629,6 +10697,8 @@ The valid @var{format} directives for files with @option{--format} and
@item %T - Minor device type in hex
@item %u - User ID of owner
@item %U - User name of owner
@item %w - Time of file birth, or @samp{-} if unknown
@item %W - Time of file birth as seconds since Epoch, or @samp{-}
@item %x - Time of last access
@item %X - Time of last access as seconds since Epoch
@item %y - Time of last modification
@@ -10637,6 +10707,23 @@ The valid @var{format} directives for files with @option{--format} and
@item %Z - Time of last change as seconds since Epoch
@end itemize
The mount point printed by @samp{%m} is similar to that output
by @command{df}, except that:
@itemize @bullet
@item
stat does not dereference symlinks by default
(unless @option{-L} is specified)
@item
stat does not search for specified device nodes in the
file system list, instead operating on them directly
@item
@cindex bind mount
stat outputs the alias for a bind mounted file, rather than
the initial mount point of its backing device.
One can recursively call stat until there is no change in output,
to get the current base mount point
@end itemize
When listing file system information (@option{--file-system} (@option{-f})),
you must use a different set of @var{format} directives:
@@ -10733,13 +10820,13 @@ Treat @var{size} as number of I/O blocks of the @var{file} rather than bytes.
@itemx --reference=@var{rfile}
@opindex -r
@opindex --reference
Set the size of each @var{file} to the same size as @var{rfile}.
Base the size of each @var{file} on the size of @var{rfile}.
@item -s @var{size}
@itemx --size=@var{size}
@opindex -s
@opindex --size
Set the size of each @var{file} to this @var{size}.
Set or adjust the size of each @var{file} according to @var{size}.
@multiplierSuffixesNoBlocks{size}
@var{size} may also be prefixed by one of the following to adjust
@@ -11888,7 +11975,7 @@ This section describes commands that manipulate file names.
@menu
* basename invocation:: Strip directory and suffix from a file name.
* dirname invocation:: Strip non-directory suffix from a file name.
* dirname invocation:: Strip last file name component.
* pathchk invocation:: Check file name validity and portability.
* mktemp invocation:: Create temporary file or directory.
@end menu
@@ -11949,7 +12036,7 @@ basename include/stdio.h .h
@node dirname invocation
@section @command{dirname}: Strip non-directory suffix from a file name
@section @command{dirname}: Strip last file name component
@pindex dirname
@cindex directory components, printing
@@ -11957,14 +12044,17 @@ basename include/stdio.h .h
@cindex non-directory suffix, stripping
@command{dirname} prints all but the final slash-delimited component of
a string (presumably a file name). Synopsis:
@var{name}. Slashes on either side of the final component are also
removed. If the string contains no slash, @command{dirname} prints
@samp{.} (meaning the current directory). Synopsis:
@example
dirname @var{name}
@end example
If @var{name} is a single component, @command{dirname} prints @samp{.}
(meaning the current directory).
@var{name} need not be a file name, but if it is, this operation
effectively lists the directory that contains the final component,
including the case when the final component is itself a directory.
@basenameAndDirname
@@ -11983,6 +12073,7 @@ Examples:
@smallexample
# Output "/usr/bin".
dirname /usr/bin/sort
dirname /usr/bin//.//
# Output ".".
dirname stdio.h
@@ -15201,31 +15292,25 @@ might find this idea strange at first.
still running after the specified time interval. Synopsis:
@example
timeout [@var{option}] @var{number}[smhd] @var{command} [@var{arg}]@dots{}
timeout [@var{option}] @var{duration} @var{command} [@var{arg}]@dots{}
@end example
@cindex time units
@var{number} is an integer followed by an optional unit; the default
is seconds. The units are:
@table @samp
@item s
seconds
@item m
minutes
@item h
hours
@item d
days
@end table
@var{command} must not be a special built-in utility (@pxref{Special
built-in utilities}).
The program accepts the following option. Also see @ref{Common options}.
The program accepts the following options. Also see @ref{Common options}.
Options must precede operands.
@table @samp
@item -k @var{duration}
@itemx --kill-after=@var{duration}
@opindex -k
@opindex --kill-after
Ensure the monitored @var{command} is killed by also sending a @samp{KILL}
signal, after the specified @var{duration}. Without this option, if the
selected signal proves not to be fatal, @command{timeout} does not kill
the @var{command}.
@item -s @var{signal}
@itemx --signal=@var{signal}
@opindex -s
@@ -15233,9 +15318,18 @@ Options must precede operands.
Send this @var{signal} to @var{command} on timeout, rather than the
default @samp{TERM} signal. @var{signal} may be a name like @samp{HUP}
or a number. Also see @xref{Signal specifications}.
@end table
@cindex time units
@var{duration} is an integer followed by an optional unit:
@display
@samp{s} for seconds (the default)
@samp{m} for minutes
@samp{h} for hours
@samp{d} for days
@end display
A duration of 0 disables the associated timeout.
@cindex exit status of @command{timeout}
Exit status:
@@ -15441,7 +15535,7 @@ M8=`echo 2^31-1|bc` ; M9=`echo 2^61-1|bc`
Similarly, factoring the eighth Fermat number @math{2^{256}+1} takes
about 20 seconds on the same machine.
Factoring large prime numbers is, in general, hard. The Pollard Rho
Factoring large numbers is, in general, hard. The Pollard Rho
algorithm used by @command{factor} is particularly effective for
numbers with relatively small factors. If you wish to factor large
numbers which do not have small factors (for example, numbers which
@@ -15584,7 +15678,7 @@ outputs 1.0000000000000000007 twice and skips 1.0000000000000000008.
@chapter File permissions
@include perm.texi
@include getdate.texi
@include parse-datetime.texi
@c What's GNU?
@c Arnold Robbins

237
gl/lib/di-set.c Normal file
View File

@@ -0,0 +1,237 @@
/* Set operations for device-inode pairs stored in a space-efficient manner.
Copyright 2009-2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* written by Paul Eggert and Jim Meyering */
#include <config.h>
#include "di-set.h"
#include "hash.h"
#include "ino-map.h"
#include <limits.h>
#include <stdlib.h>
/* The hash package hashes "void *", but this package wants to hash
integers. Use integers that are as large as possible, but no
larger than void *, so that they can be cast to void * and back
without losing information. */
typedef size_t hashint;
#define HASHINT_MAX ((hashint) -1)
/* Integers represent inode numbers. Integers in the range
1..(LARGE_INO_MIN-1) represent inode numbers directly. (The hash
package does not work with null pointers, so inode 0 cannot be used
as a key.) To find the representations of other inode numbers, map
them through INO_MAP. */
#define LARGE_INO_MIN (HASHINT_MAX / 2)
/* Set operations for device-inode pairs stored in a space-efficient
manner. Use a two-level hash table. The top level hashes by
device number, as there are typically a small number of devices.
The lower level hashes by mapped inode numbers. In the typical
case where the inode number is positive and small, the inode number
maps to itself, masquerading as a void * value; otherwise, its
value is the result of hashing the inode value through INO_MAP. */
/* A pair that maps a device number to a set of inode numbers. */
struct di_ent
{
dev_t dev;
struct hash_table *ino_set;
};
/* A two-level hash table that manages and indexes these pairs. */
struct di_set
{
/* Map device numbers to sets of inode number representatives. */
struct hash_table *dev_map;
/* If nonnull, map large inode numbers to their small
representatives. If null, there are no large inode numbers in
this set. */
struct ino_map *ino_map;
/* Cache of the most recently allocated and otherwise-unused storage
for probing this table. */
struct di_ent *probe;
};
/* Hash a device-inode-set entry. */
static size_t
di_ent_hash (void const *x, size_t table_size)
{
struct di_ent const *p = x;
dev_t dev = p->dev;
/* When DEV is wider than size_t, exclusive-OR the words of DEV into H.
This avoids loss of info, without applying % to the wider type,
which could be quite slow on some systems. */
size_t h = dev;
unsigned int i;
unsigned int n_words = sizeof dev / sizeof h + (sizeof dev % sizeof h != 0);
for (i = 1; i < n_words; i++)
h ^= dev >> CHAR_BIT * sizeof h * i;
return h % table_size;
}
/* Return true if two device-inode-set entries are the same. */
static bool
di_ent_compare (void const *x, void const *y)
{
struct di_ent const *a = x;
struct di_ent const *b = y;
return a->dev == b->dev;
}
/* Free a device-inode-set entry. */
static void
di_ent_free (void *v)
{
struct di_ent *a = v;
hash_free (a->ino_set);
free (a);
}
/* Create a set of device-inode pairs. Return NULL on allocation failure. */
struct di_set *
di_set_alloc (void)
{
struct di_set *dis = malloc (sizeof *dis);
if (dis)
{
enum { INITIAL_DEV_MAP_SIZE = 11 };
dis->dev_map = hash_initialize (INITIAL_DEV_MAP_SIZE, NULL,
di_ent_hash, di_ent_compare,
di_ent_free);
if (! dis->dev_map)
{
free (dis);
return NULL;
}
dis->ino_map = NULL;
dis->probe = NULL;
}
return dis;
}
/* Free a set of device-inode pairs. */
void
di_set_free (struct di_set *dis)
{
hash_free (dis->dev_map);
free (dis->ino_map);
free (dis->probe);
free (dis);
}
/* Hash an encoded inode number I. */
static size_t
di_ino_hash (void const *i, size_t table_size)
{
return (hashint) i % table_size;
}
/* Using the DIS table, map a device to a hash table that represents
a set of inode numbers. Return NULL on error. */
static struct hash_table *
map_device (struct di_set *dis, dev_t dev)
{
/* Find space for the probe, reusing the cache if available. */
struct di_ent *ent;
struct di_ent *probe = dis->probe;
if (probe)
{
/* If repeating a recent query, return the cached result. */
if (probe->dev == dev)
return probe->ino_set;
}
else
{
dis->probe = probe = malloc (sizeof *probe);
if (! probe)
return NULL;
}
/* Probe for the device. */
probe->dev = dev;
ent = hash_insert (dis->dev_map, probe);
if (! ent)
return NULL;
if (ent != probe)
{
/* Use the existing entry. */
probe->ino_set = ent->ino_set;
}
else
{
enum { INITIAL_INO_SET_SIZE = 1021 };
/* Prepare to allocate a new probe next time; this one is in use. */
dis->probe = NULL;
/* DEV is new; allocate an inode set for it. */
probe->ino_set = hash_initialize (INITIAL_INO_SET_SIZE, NULL,
di_ino_hash, NULL, NULL);
}
return probe->ino_set;
}
/* Using the DIS table, map an inode number to a mapped value.
Return INO_MAP_INSERT_FAILURE on error. */
static hashint
map_inode_number (struct di_set *dis, ino_t ino)
{
if (0 < ino && ino < LARGE_INO_MIN)
return ino;
if (! dis->ino_map)
{
dis->ino_map = ino_map_alloc (LARGE_INO_MIN);
if (! dis->ino_map)
return INO_MAP_INSERT_FAILURE;
}
return ino_map_insert (dis->ino_map, ino);
}
/* Attempt to insert the DEV,INO pair into the set DIS.
If it matches a pair already in DIS, keep that pair and return 0.
Otherwise, if insertion is successful, return 1.
Upon any failure return -1. */
int
di_set_insert (struct di_set *dis, dev_t dev, ino_t ino)
{
hashint i;
/* Map the device number to a set of inodes. */
struct hash_table *ino_set = map_device (dis, dev);
if (! ino_set)
return -1;
/* Map the inode number to a small representative I. */
i = map_inode_number (dis, ino);
if (i == INO_MAP_INSERT_FAILURE)
return -1;
/* Put I into the inode set. */
return hash_insert0 (ino_set, (void *) i, NULL);
}

12
gl/lib/di-set.h Normal file
View File

@@ -0,0 +1,12 @@
#include <sys/types.h>
#undef _ATTRIBUTE_NONNULL_
#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__
# define _ATTRIBUTE_NONNULL_(m) __attribute__ ((__nonnull__ (m)))
#else
# define _ATTRIBUTE_NONNULL_(m)
#endif
struct di_set *di_set_alloc (void);
int di_set_insert (struct di_set *, dev_t, ino_t) _ATTRIBUTE_NONNULL_ (1);
void di_set_free (struct di_set *) _ATTRIBUTE_NONNULL_ (1);

37
gl/lib/fadvise.c Normal file
View File

@@ -0,0 +1,37 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010 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 "fadvise.h"
#include <stdio.h>
#include <fcntl.h>
#include "ignore-value.h"
void
fdadvise (int fd, off_t offset, off_t len, fadvice_t advice)
{
#if HAVE_POSIX_FADVISE
ignore_value (posix_fadvise (fd, offset, len, advice));
#endif
}
void
fadvise (FILE *fp, fadvice_t advice)
{
if (fp)
fdadvise (fileno (fp), 0, 0, advice);
}

72
gl/lib/fadvise.h Normal file
View File

@@ -0,0 +1,72 @@
/* Declare an access pattern hint for files.
Copyright (C) 2010 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 <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
/* There are a few hints one can provide, which have the
following characteristics on Linux 2.6.31 at least.
POSIX_FADV_SEQUENTIAL
Doubles the size of read ahead done for file
POSIX_FADV_WILLNEED
_synchronously_ prepopulate the buffer cache with the file
POSIX_FADV_NOREUSE
Could lower priority of data in buffer caches,
but currently does nothing.
POSIX_FADV_DONTNEED
Drop the file from cache.
Note this is automatically done when files are unlinked.
We use this enum "type" both to make it explicit that
these options are mutually exclusive, and to discourage
the passing of the possibly undefined POSIX_FADV_... values.
Note we could #undef the POSIX_FADV_ values, but that would
preclude using the posix_fadvise() function with its standard
constants. Using posix_fadvise() might be required if the return
value is needed, but it must be guarded by appropriate #ifdefs. */
#if HAVE_POSIX_FADVISE
typedef enum {
FADVISE_NORMAL = POSIX_FADV_NORMAL,
FADVISE_SEQUENTIAL = POSIX_FADV_SEQUENTIAL,
FADVISE_NOREUSE = POSIX_FADV_NOREUSE,
FADVISE_DONTNEED = POSIX_FADV_DONTNEED,
FADVISE_WILLNEED = POSIX_FADV_WILLNEED,
FADVISE_RANDOM = POSIX_FADV_RANDOM,
} fadvice_t;
#else
typedef enum {
FADVISE_NORMAL,
FADVISE_SEQUENTIAL,
FADVISE_NOREUSE,
FADVISE_DONTNEED,
FADVISE_WILLNEED,
FADVISE_RANDOM,
} fadvice_t;
#endif
/* We ignore any errors as these hints are only advisory.
There is the chance one can pass invalid ADVICE, which will
not be indicated, but given the simplicity of the interface
this is unlikely. Also not returning errors allows the
unconditional passing of descriptors to non standard files,
which will just be ignored if unsupported. */
void fdadvise (int fd, off_t offset, off_t len, fadvice_t advice);
void fadvise (FILE *fp, fadvice_t advice);

149
gl/lib/heap.c Normal file
View File

@@ -0,0 +1,149 @@
/* Barebones heap implementation supporting only insert and pop.
Copyright (C) 2010 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/>. */
/* Full implementation: GDSL (http://gna.org/projects/gdsl/) by Nicolas
Darnis <ndarnis@free.fr>. */
#include <config.h>
#include "heap.h"
#include "stdlib--.h"
#include "xalloc.h"
static int heap_default_compare (void const *, void const *);
static size_t heapify_down (void **, size_t, size_t,
int (*) (void const *, void const *));
static void heapify_up (void **, size_t,
int (*) (void const *, void const *));
struct heap
{
void **array; /* array[0] is not used */
size_t capacity; /* Array size */
size_t count; /* Used as index to last element. Also is num of items. */
int (*compare) (void const *, void const *);
};
/* Allocate memory for the heap. */
struct heap *
heap_alloc (int (*compare) (void const *, void const *), size_t n_reserve)
{
struct heap *heap = xmalloc (sizeof *heap);
if (n_reserve == 0)
n_reserve = 1;
heap->array = xnmalloc (n_reserve, sizeof *(heap->array));
heap->array[0] = NULL;
heap->capacity = n_reserve;
heap->count = 0;
heap->compare = compare ? compare : heap_default_compare;
return heap;
}
static int
heap_default_compare (void const *a, void const *b)
{
return 0;
}
void
heap_free (struct heap *heap)
{
free (heap->array);
free (heap);
}
/* Insert element into heap. */
int
heap_insert (struct heap *heap, void *item)
{
if (heap->capacity - 1 <= heap->count)
heap->array = x2nrealloc (heap->array, &heap->capacity,
sizeof *(heap->array));
heap->array[++heap->count] = item;
heapify_up (heap->array, heap->count, heap->compare);
return 0;
}
/* Pop top element off heap. */
void *
heap_remove_top (struct heap *heap)
{
if (heap->count == 0)
return NULL;
void *top = heap->array[1];
heap->array[1] = heap->array[heap->count--];
heapify_down (heap->array, heap->count, 1, heap->compare);
return top;
}
/* Move element down into appropriate position in heap. */
static size_t
heapify_down (void **array, size_t count, size_t initial,
int (*compare) (void const *, void const *))
{
void *element = array[initial];
size_t parent = initial;
while (parent <= count / 2)
{
size_t child = 2 * parent;
if (child < count && compare (array[child], array[child+1]) < 0)
child++;
if (compare (array[child], element) <= 0)
break;
array[parent] = array[child];
parent = child;
}
array[parent] = element;
return parent;
}
/* Move element up into appropriate position in heap. */
static void
heapify_up (void **array, size_t count,
int (*compare) (void const *, void const *))
{
size_t k = count;
void *new_element = array[k];
while (k != 1 && compare (array[k/2], new_element) <= 0)
{
array[k] = array[k/2];
k /= 2;
}
array[k] = new_element;
}

26
gl/lib/heap.h Normal file
View File

@@ -0,0 +1,26 @@
/* Barebones heap implementation supporting only insert and pop.
Copyright (C) 2010 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/>. */
/* Full implementation: GDSL (http://gna.org/projects/gdsl/) by Nicolas
Darnis <ndarnis@free.fr>. Adapted by Gene Auyeung. */
#include <stddef.h>
struct heap *heap_alloc (int (*) (void const *, void const *), size_t);
void heap_free (struct heap *);
int heap_insert (struct heap *heap, void *item);
void *heap_remove_top (struct heap *heap);

164
gl/lib/ino-map.c Normal file
View File

@@ -0,0 +1,164 @@
/* Map an ino_t inode number to a small integer.
Copyright 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* written by Paul Eggert and Jim Meyering */
#include <config.h>
#include "ino-map.h"
#include "hash.h"
#include "verify.h"
#include <limits.h>
#include <stdlib.h>
/* A pair that maps an inode number to a mapped inode number; the
latter is a small unique ID for the former. */
struct ino_map_ent
{
ino_t ino;
size_t mapped_ino;
};
/* A table that manages and indexes these pairs. */
struct ino_map
{
/* A table of KEY,VAL pairs, where KEY is the raw ino_t value and
VAL is the small number that it maps to. */
struct hash_table *map;
/* The next mapped inode number to hand out. */
size_t next_mapped_ino;
/* Cache of the most recently allocated and otherwise-unused storage
for probing the table. */
struct ino_map_ent *probe;
};
/* Hash an inode map entry. */
static size_t
ino_hash (void const *x, size_t table_size)
{
struct ino_map_ent const *p = x;
ino_t ino = p->ino;
/* When INO is wider than size_t, exclusive-OR the words of INO into H.
This avoids loss of info, without applying % to the wider type,
which could be quite slow on some systems. */
size_t h = ino;
unsigned int i;
unsigned int n_words = sizeof ino / sizeof h + (sizeof ino % sizeof h != 0);
for (i = 1; i < n_words; i++)
h ^= ino >> CHAR_BIT * sizeof h * i;
return h % table_size;
}
/* Return true if two inode map entries are the same. */
static bool
ino_compare (void const *x, void const *y)
{
struct ino_map_ent const *a = x;
struct ino_map_ent const *b = y;
return a->ino == b->ino;
}
/* Allocate an inode map that will hand out integers starting with
NEXT_MAPPED_INO. Return NULL if memory is exhausted. */
struct ino_map *
ino_map_alloc (size_t next_mapped_ino)
{
struct ino_map *im = malloc (sizeof *im);
if (im)
{
enum { INITIAL_INO_MAP_TABLE_SIZE = 1021 };
im->map = hash_initialize (INITIAL_INO_MAP_TABLE_SIZE, NULL,
ino_hash, ino_compare, free);
if (! im->map)
{
free (im);
return NULL;
}
im->next_mapped_ino = next_mapped_ino;
im->probe = NULL;
}
return im;
}
/* Free an inode map. */
void
ino_map_free (struct ino_map *map)
{
hash_free (map->map);
free (map->probe);
free (map);
}
/* Insert into MAP the inode number INO if it's not there already,
and return its nonnegative mapped inode number.
If INO is already in MAP, return the existing mapped inode number.
Return INO_MAP_INSERT_FAILURE on memory or counter exhaustion. */
size_t
ino_map_insert (struct ino_map *im, ino_t ino)
{
struct ino_map_ent *ent;
/* Find space for the probe, reusing the cache if available. */
struct ino_map_ent *probe = im->probe;
if (probe)
{
/* If repeating a recent query, return the cached result. */
if (probe->ino == ino)
return probe->mapped_ino;
}
else
{
im->probe = probe = malloc (sizeof *probe);
if (! probe)
return INO_MAP_INSERT_FAILURE;
}
probe->ino = ino;
ent = hash_insert (im->map, probe);
if (! ent)
return INO_MAP_INSERT_FAILURE;
if (ent != probe)
{
/* Use the existing entry. */
probe->mapped_ino = ent->mapped_ino;
}
else
{
/* If adding 1 to map->next_mapped_ino would cause it to
overflow to zero, then it must equal INO_MAP_INSERT_FAILURE,
which is the value that should be returned in that case.
Verify that this works. */
verify (INO_MAP_INSERT_FAILURE + 1 == 0);
/* Prepare to allocate a new probe next time; this one is in use. */
im->probe = NULL;
/* INO is new; allocate a mapped inode number for it. */
probe->mapped_ino = im->next_mapped_ino++;
}
return probe->mapped_ino;
}

14
gl/lib/ino-map.h Normal file
View File

@@ -0,0 +1,14 @@
#include <sys/types.h>
#undef _ATTRIBUTE_NONNULL_
#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__
# define _ATTRIBUTE_NONNULL_(m) __attribute__ ((__nonnull__ (m)))
#else
# define _ATTRIBUTE_NONNULL_(m)
#endif
#define INO_MAP_INSERT_FAILURE ((size_t) -1)
struct ino_map *ino_map_alloc (size_t);
void ino_map_free (struct ino_map *) _ATTRIBUTE_NONNULL_ (1);
size_t ino_map_insert (struct ino_map *, ino_t) _ATTRIBUTE_NONNULL_ (1);

View File

@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <wchar.h>
@@ -32,6 +33,7 @@
#endif
/* Replace non printable chars.
Note \t and \n etc. are non printable.
Return 1 if replacement made, 0 otherwise. */
static bool
@@ -119,19 +121,19 @@ mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces)
ALIGNMENT specifies whether to left- or right-justify or to center.
If SRC requires more than *WIDTH columns, truncate it to fit.
When centering, the number of trailing spaces may be one less than the
number of leading spaces. The FLAGS parameter is unused at present.
number of leading spaces.
Return the length in bytes required for the final result, not counting
the trailing NUL. A return value of DEST_SIZE or larger means there
wasn't enough space. DEST will be NUL terminated in any case.
Return (size_t) -1 upon error (invalid multi-byte sequence in SRC,
or malloc failure).
Return SIZE_MAX upon error (invalid multi-byte sequence in SRC,
or malloc failure), unless MBA_UNIBYTE_FALLBACK is specified.
Update *WIDTH to indicate how many columns were used before padding. */
size_t
mbsalign (const char *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags _UNUSED_PARAMETER_)
size_t *width, mbs_align_t align, int flags)
{
size_t ret = -1;
size_t ret = SIZE_MAX;
size_t src_size = strlen (src) + 1;
char *newstr = NULL;
wchar_t *str_wc = NULL;
@@ -148,13 +150,23 @@ mbsalign (const char *src, char *dest, size_t dest_size,
if (MB_CUR_MAX > 1)
{
size_t src_chars = mbstowcs (NULL, src, 0);
if (src_chars == (size_t) -1)
goto mbsalign_cleanup;
if (src_chars == SIZE_MAX)
{
if (flags & MBA_UNIBYTE_FALLBACK)
goto mbsalign_unibyte;
else
goto mbsalign_cleanup;
}
src_chars += 1; /* make space for NUL */
str_wc = malloc (src_chars * sizeof (wchar_t));
if (str_wc == NULL)
goto mbsalign_cleanup;
if (mbstowcs (str_wc, src, src_chars) > 0)
{
if (flags & MBA_UNIBYTE_FALLBACK)
goto mbsalign_unibyte;
else
goto mbsalign_cleanup;
}
if (mbstowcs (str_wc, src, src_chars) != 0)
{
str_wc[src_chars - 1] = L'\0';
wc_enabled = true;
@@ -165,27 +177,36 @@ mbsalign (const char *src, char *dest, size_t dest_size,
/* If we transformed or need to truncate the source string
then create a modified copy of it. */
if (conversion || (n_cols > *width))
if (wc_enabled && (conversion || (n_cols > *width)))
{
newstr = malloc (src_size);
if (newstr == NULL)
goto mbsalign_cleanup;
str_to_print = newstr;
if (wc_enabled)
if (conversion)
{
/* May have increased the size by converting
\t to \uFFFD for example. */
src_size = wcstombs (NULL, str_wc, 0) + 1;
}
newstr = malloc (src_size);
if (newstr == NULL)
{
n_cols = wc_truncate (str_wc, *width);
n_used_bytes = wcstombs (newstr, str_wc, src_size);
}
else
{
n_cols = *width;
n_used_bytes = n_cols;
memcpy (newstr, src, n_cols);
newstr[n_cols] = '\0';
if (flags & MBA_UNIBYTE_FALLBACK)
goto mbsalign_unibyte;
else
goto mbsalign_cleanup;
}
str_to_print = newstr;
n_cols = wc_truncate (str_wc, *width);
n_used_bytes = wcstombs (newstr, str_wc, src_size);
}
if (*width > n_cols)
mbsalign_unibyte:
if (n_cols > *width) /* Unibyte truncation required. */
{
n_cols = *width;
n_used_bytes = n_cols;
}
if (*width > n_cols) /* Padding required. */
n_spaces = *width - n_cols;
/* indicate to caller how many cells needed (not including padding). */
@@ -197,16 +218,11 @@ mbsalign (const char *src, char *dest, size_t dest_size,
/* Write as much NUL terminated output to DEST as possible. */
if (dest_size != 0)
{
size_t start_spaces, end_spaces, space_left;
char *dest_end = dest + dest_size - 1;
size_t start_spaces = n_spaces / 2 + n_spaces % 2;
size_t end_spaces = n_spaces / 2;
switch (align)
{
case MBS_ALIGN_CENTER:
start_spaces = n_spaces / 2 + n_spaces % 2;
end_spaces = n_spaces / 2;
break;
case MBS_ALIGN_LEFT:
start_spaces = 0;
end_spaces = n_spaces;
@@ -215,10 +231,16 @@ mbsalign (const char *src, char *dest, size_t dest_size,
start_spaces = n_spaces;
end_spaces = 0;
break;
case MBS_ALIGN_CENTER:
default:
start_spaces = n_spaces / 2 + n_spaces % 2;
end_spaces = n_spaces / 2;
break;
}
dest = mbs_align_pad (dest, dest_end, start_spaces);
dest = mempcpy(dest, str_to_print, MIN (n_used_bytes, dest_end - dest));
space_left = dest_end - dest;
dest = mempcpy (dest, str_to_print, MIN (n_used_bytes, space_left));
mbs_align_pad (dest, dest_end, end_spaces);
}
@@ -229,3 +251,40 @@ mbsalign_cleanup:
return ret;
}
/* A wrapper around mbsalign() to dynamically allocate the
minimum amount of memory to store the result.
Return NULL on failure. */
char *
ambsalign (const char *src, size_t *width, mbs_align_t align, int flags)
{
size_t orig_width = *width;
size_t size = *width; /* Start with enough for unibyte mode. */
size_t req = size;
char *buf = NULL;
while (req >= size)
{
char *nbuf;
size = req + 1; /* Space for NUL. */
nbuf = realloc (buf, size);
if (nbuf == NULL)
{
free (buf);
buf = NULL;
break;
}
buf = nbuf;
*width = orig_width;
req = mbsalign (src, buf, size, width, align, flags);
if (req == SIZE_MAX)
{
free (buf);
buf = NULL;
break;
}
}
return buf;
}

View File

@@ -18,6 +18,29 @@
typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
enum {
/* Use unibyte mode for invalid multibyte strings or
or when heap memory is exhausted. */
MBA_UNIBYTE_FALLBACK = 0x0001
#if 0 /* Other possible options. */
/* Skip invalid multibyte chars rather than failing */
MBA_IGNORE_INVALID = 0x0002,
/* Align multibyte strings using "figure space" (\u2007) */
MBA_USE_FIGURE_SPACE = 0x0004,
/* Don't add any padding */
MBA_TRUNCATE_ONLY = 0x0008,
/* Don't truncate */
MBA_PAD_ONLY = 0x0010,
#endif
};
size_t
mbsalign (const char *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags);
char *
ambsalign (const char *src, size_t *width, mbs_align_t align, int flags);

View File

@@ -1,4 +1,4 @@
/* Bob Jenkins's cryptographic random number generator, ISAAC.
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2006, 2009-2010 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
@@ -16,7 +16,7 @@
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 Colin Plumb. */
Written by Colin Plumb and Paul Eggert. */
/*
* --------------------------------------------------------------------
@@ -34,60 +34,90 @@
#include "rand-isaac.h"
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include "gethrxtime.h"
/* This index operation is more efficient on many processors */
#define ind(mm, x) \
(* (uint32_t *) ((char *) (mm) \
+ ((x) & (ISAAC_WORDS - 1) * sizeof (uint32_t))))
/*
* The central step. This uses two temporaries, x and y. mm is the
* whole state array, while m is a pointer to the current word. off is
* the offset from m to the word ISAAC_WORDS/2 words away in the mm array,
* i.e. +/- ISAAC_WORDS/2.
*/
#define isaac_step(mix, a, b, mm, m, off, r) \
( \
a = ((a) ^ (mix)) + (m)[off], \
x = *(m), \
*(m) = y = ind (mm, x) + (a) + (b), \
*(r) = b = ind (mm, (y) >> ISAAC_LOG) + x \
)
/* Use and update *S to generate random data to fill R. */
void
isaac_refill (struct isaac_state *s, uint32_t r[ISAAC_WORDS])
/* The minimum of two sizes A and B. */
static inline size_t
min (size_t a, size_t b)
{
uint32_t a, b; /* Caches of a and b */
uint32_t x, y; /* Temps needed by isaac_step macro */
uint32_t *m = s->mm; /* Pointer into state array */
return (a < b ? a : b);
}
a = s->a;
b = s->b + (++s->c);
/* A if 32-bit ISAAC, B if 64-bit. This is a macro, not an inline
function, to prevent undefined behavior if the unused argument
shifts by more than a word width. */
#define IF32(a, b) (ISAAC_BITS == 32 ? (a) : (b))
/* Discard bits outside the desired range. On typical machines, any
decent compiler should optimize this function call away to nothing.
But machines with pad bits in integers may need to do more work. */
static inline isaac_word
just (isaac_word a)
{
isaac_word desired_bits = ((isaac_word) 1 << 1 << (ISAAC_BITS - 1)) - 1;
return a & desired_bits;
}
/* The index operation. On typical machines whose words are exactly
the right size, this is optimized to a mask, an addition, and an
indirect load. Atypical machines need more work. */
static inline isaac_word
ind (isaac_word const *m, isaac_word x)
{
return (sizeof *m * CHAR_BIT == ISAAC_BITS
? (* (isaac_word *) ((char *) m
+ (x & ((ISAAC_WORDS - 1) * sizeof *m))))
: m[(x / (ISAAC_BITS / CHAR_BIT)) & (ISAAC_WORDS - 1)]);
}
/* Use and update *S to generate random data to fill RESULT. */
void
isaac_refill (struct isaac_state *s, isaac_word result[ISAAC_WORDS])
{
/* Caches of S->a and S->b. */
isaac_word a = s->a;
isaac_word b = s->b + (++s->c);
/* Pointers into state array and into result. */
isaac_word *m = s->m;
isaac_word *r = result;
enum { HALF = ISAAC_WORDS / 2 };
/* The central step. S->m is the whole state array, while M is a
pointer to the current word. OFF is the offset from M to the
word ISAAC_WORDS/2 words away in the SM array, i.e. +/-
ISAAC_WORDS/2. A and B are state variables, and R the result.
This updates A, B, M[I], and R[I]. */
#define ISAAC_STEP(i, off, mix) \
{ \
isaac_word x, y; \
a = (IF32 (a, 0) ^ (mix)) + m[off + (i)]; \
x = m[i]; \
m[i] = y = ind (s->m, x) + a + b; \
r[i] = b = just (ind (s->m, y >> ISAAC_WORDS_LOG) + x); \
}
do
{
isaac_step (a << 13, a, b, s->mm, m, ISAAC_WORDS / 2, r);
isaac_step (a >> 6, a, b, s->mm, m + 1, ISAAC_WORDS / 2, r + 1);
isaac_step (a << 2, a, b, s->mm, m + 2, ISAAC_WORDS / 2, r + 2);
isaac_step (a >> 16, a, b, s->mm, m + 3, ISAAC_WORDS / 2, r + 3);
ISAAC_STEP (0, HALF, IF32 ( a << 13, ~ (a ^ (a << 21))));
ISAAC_STEP (1, HALF, IF32 (just (a) >> 6, a ^ (just (a) >> 5)));
ISAAC_STEP (2, HALF, IF32 ( a << 2, a ^ ( a << 12)));
ISAAC_STEP (3, HALF, IF32 (just (a) >> 16, a ^ (just (a) >> 33)));
r += 4;
}
while ((m += 4) < s->mm + ISAAC_WORDS / 2);
while ((m += 4) < s->m + HALF);
do
{
isaac_step (a << 13, a, b, s->mm, m, -ISAAC_WORDS / 2, r);
isaac_step (a >> 6, a, b, s->mm, m + 1, -ISAAC_WORDS / 2, r + 1);
isaac_step (a << 2, a, b, s->mm, m + 2, -ISAAC_WORDS / 2, r + 2);
isaac_step (a >> 16, a, b, s->mm, m + 3, -ISAAC_WORDS / 2, r + 3);
ISAAC_STEP (0, -HALF, IF32 ( a << 13, ~ (a ^ (a << 21))));
ISAAC_STEP (1, -HALF, IF32 (just (a) >> 6, a ^ (just (a) >> 5)));
ISAAC_STEP (2, -HALF, IF32 ( a << 2, a ^ ( a << 12)));
ISAAC_STEP (3, -HALF, IF32 (just (a) >> 16, a ^ (just (a) >> 33)));
r += 4;
}
while ((m += 4) < s->mm + ISAAC_WORDS);
while ((m += 4) < s->m + ISAAC_WORDS);
s->a = a;
s->b = b;
}
@@ -96,205 +126,133 @@ isaac_refill (struct isaac_state *s, uint32_t r[ISAAC_WORDS])
* The basic seed-scrambling step for initialization, based on Bob
* Jenkins' 256-bit hash.
*/
#define mix(a,b,c,d,e,f,g,h) \
( a ^= b << 11, d += a, \
b += c, b ^= c >> 2, e += b, \
c += d, c ^= d << 8, f += c, \
d += e, d ^= e >> 16, g += d, \
e += f, e ^= f << 10, h += e, \
f += g, f ^= g >> 4, a += f, \
g += h, g ^= h << 8, b += g, \
h += a, h ^= a >> 9, c += h, \
a += b )
#if ISAAC_BITS == 32
#define mix(a, b, c, d, e, f, g, h) \
{ \
a ^= b << 11; d += a; \
b += c; b ^= just (c) >> 2; e += b; \
c += d; c ^= d << 8; f += c; \
d += e; d ^= just (e) >> 16; g += d; \
e += f; e ^= f << 10; h += e; \
f += g; f ^= just (g) >> 4; a += f; \
g += h; g ^= h << 8; b += g; \
h += a; h ^= just (a) >> 9; c += h; \
a += b; \
}
#else
#define mix(a, b, c, d, e, f, g, h) \
{ \
a -= e; f ^= just (h) >> 9; h += a; \
b -= f; g ^= a << 9; a += b; \
c -= g; h ^= just (b) >> 23; b += c; \
d -= h; a ^= c << 15; c += d; \
e -= a; b ^= just (d) >> 14; d += e; \
f -= b; c ^= e << 20; e += f; \
g -= c; d ^= just (f) >> 17; f += g; \
h -= d; e ^= g << 14; g += h; \
}
#endif
/* The basic ISAAC initialization pass. */
static void
isaac_mix (struct isaac_state *s, uint32_t const seed[/* ISAAC_WORDS */])
{
int i;
uint32_t a = s->iv[0];
uint32_t b = s->iv[1];
uint32_t c = s->iv[2];
uint32_t d = s->iv[3];
uint32_t e = s->iv[4];
uint32_t f = s->iv[5];
uint32_t g = s->iv[6];
uint32_t h = s->iv[7];
for (i = 0; i < ISAAC_WORDS; i += 8)
{
a += seed[i];
b += seed[i + 1];
c += seed[i + 2];
d += seed[i + 3];
e += seed[i + 4];
f += seed[i + 5];
g += seed[i + 6];
h += seed[i + 7];
mix (a, b, c, d, e, f, g, h);
s->mm[i] = a;
s->mm[i + 1] = b;
s->mm[i + 2] = c;
s->mm[i + 3] = d;
s->mm[i + 4] = e;
s->mm[i + 5] = f;
s->mm[i + 6] = g;
s->mm[i + 7] = h;
}
s->iv[0] = a;
s->iv[1] = b;
s->iv[2] = c;
s->iv[3] = d;
s->iv[4] = e;
s->iv[5] = f;
s->iv[6] = g;
s->iv[7] = h;
}
#define ISAAC_MIX(s, a, b, c, d, e, f, g, h, seed) \
{ \
int i; \
\
for (i = 0; i < ISAAC_WORDS; i += 8) \
{ \
a += seed[i]; \
b += seed[i + 1]; \
c += seed[i + 2]; \
d += seed[i + 3]; \
e += seed[i + 4]; \
f += seed[i + 5]; \
g += seed[i + 6]; \
h += seed[i + 7]; \
mix (a, b, c, d, e, f, g, h); \
s->m[i] = a; \
s->m[i + 1] = b; \
s->m[i + 2] = c; \
s->m[i + 3] = d; \
s->m[i + 4] = e; \
s->m[i + 5] = f; \
s->m[i + 6] = g; \
s->m[i + 7] = h; \
} \
}
#if 0 /* Provided for reference only; not used in this code */
/*
* Initialize the ISAAC RNG with the given seed material.
* Its size MUST be a multiple of ISAAC_BYTES, and may be
* stored in the s->mm array.
* stored in the s->m array.
*
* This is a generalization of the original ISAAC initialization code
* to support larger seed sizes. For seed sizes of 0 and ISAAC_BYTES,
* it is identical.
*/
static void
isaac_init (struct isaac_state *s, uint32_t const *seed, size_t seedsize)
isaac_init (struct isaac_state *s, isaac_word const *seed, size_t seedsize)
{
static uint32_t const iv[8] =
{
0x1367df5a, 0x95d90059, 0xc3163e4b, 0x0f421ad8,
0xd92a4a78, 0xa51a3c49, 0xc4efea1b, 0x30609119};
int i;
isaac_word a, b, c, d, e, f, g, h;
# if 0
/* The initialization of iv is a precomputed form of: */
for (i = 0; i < 7; i++)
iv[i] = 0x9e3779b9; /* the golden ratio */
for (i = 0; i < 4; ++i) /* scramble it */
mix (iv[0], iv[1], iv[2], iv[3], iv[4], iv[5], iv[6], iv[7]);
# endif
a = b = c = d = e = f = g = h = /* the golden ratio */
IF32 (UINT32_C (0x9e3779b9), UINT64_C (0x9e3779b97f4a7c13));
for (int i = 0; i < 4; i++) /* scramble it */
mix (a, b, c, d, e, f, g, h);
s->a = s->b = s->c = 0;
for (i = 0; i < 8; i++)
s->iv[i] = iv[i];
if (seedsize)
{
/* First pass (as in reference ISAAC code) */
isaac_mix (s, seed);
ISAAC_MIX (s, a, b, c, d, e, f, g, h, seed);
/* Second and subsequent passes (extension to ISAAC) */
while (seedsize -= ISAAC_BYTES)
{
seed += ISAAC_WORDS;
for (i = 0; i < ISAAC_WORDS; i++)
s->mm[i] += seed[i];
isaac_mix (s, s->mm);
s->m[i] += seed[i];
ISAAC_MIX (s, a, b, c, d, e, f, g, h, s->m);
}
}
else
{
/* The no seed case (as in reference ISAAC code) */
for (i = 0; i < ISAAC_WORDS; i++)
s->mm[i] = 0;
s->m[i] = 0;
}
/* Final pass */
isaac_mix (s, s->mm);
ISAAC_MIX (s, a, b, c, d, e, f, g, h, s->m);
}
#endif
/* Initialize *S to a somewhat-random value. */
static void
isaac_seed_start (struct isaac_state *s)
{
static uint32_t const iv[8] =
{
0x1367df5a, 0x95d90059, 0xc3163e4b, 0x0f421ad8,
0xd92a4a78, 0xa51a3c49, 0xc4efea1b, 0x30609119
};
#if 0
/* The initialization of iv is a precomputed form of: */
int i;
for (i = 0; i < 7; i++)
iv[i] = 0x9e3779b9; /* the golden ratio */
for (i = 0; i < 4; ++i) /* scramble it */
mix (iv[0], iv[1], iv[2], iv[3], iv[4], iv[5], iv[6], iv[7]);
#endif
memset (s->mm, 0, sizeof s->mm);
memcpy (s->iv, iv, sizeof s->iv);
/* s->c gets used for a data pointer during the seeding phase */
s->a = s->b = s->c = 0;
}
/* Add a buffer of seed material. */
static void
isaac_seed_data (struct isaac_state *s, void const *buffer, size_t size)
{
unsigned char const *buf = buffer;
unsigned char *p;
size_t avail;
size_t i;
avail = sizeof s->mm - s->c; /* s->c is used as a write pointer */
/* Do any full buffers that are necessary */
while (size > avail)
{
p = (unsigned char *) s->mm + s->c;
for (i = 0; i < avail; i++)
p[i] ^= buf[i];
buf += avail;
size -= avail;
isaac_mix (s, s->mm);
s->c = 0;
avail = sizeof s->mm;
}
/* And the final partial block */
p = (unsigned char *) s->mm + s->c;
for (i = 0; i < size; i++)
p[i] ^= buf[i];
s->c = size;
}
/* End of seeding phase; get everything ready to produce output. */
static void
isaac_seed_finish (struct isaac_state *s)
{
isaac_mix (s, s->mm);
isaac_mix (s, s->mm);
/* Now reinitialize c to start things off right */
s->c = 0;
}
#define ISAAC_SEED(s,x) isaac_seed_data (s, &(x), sizeof (x))
/* Initialize *S to a somewhat-random value; this starts seeding,
seeds with somewhat-random data, and finishes seeding. */
/* Initialize *S to a somewhat-random value, derived from a seed
stored in S->m. */
void
isaac_seed (struct isaac_state *s)
{
isaac_seed_start (s);
isaac_word a = IF32 (UINT32_C (0x1367df5a), UINT64_C (0x647c4677a2884b7c));
isaac_word b = IF32 (UINT32_C (0x95d90059), UINT64_C (0xb9f8b322c73ac862));
isaac_word c = IF32 (UINT32_C (0xc3163e4b), UINT64_C (0x8c0ea5053d4712a0));
isaac_word d = IF32 (UINT32_C (0x0f421ad8), UINT64_C (0xb29b2e824a595524));
isaac_word e = IF32 (UINT32_C (0xd92a4a78), UINT64_C (0x82f053db8355e0ce));
isaac_word f = IF32 (UINT32_C (0xa51a3c49), UINT64_C (0x48fe4a0fa5a09315));
isaac_word g = IF32 (UINT32_C (0xc4efea1b), UINT64_C (0xae985bf2cbfc89ed));
isaac_word h = IF32 (UINT32_C (0x30609119), UINT64_C (0x98f5704f6c44c0ab));
{ pid_t t = getpid (); ISAAC_SEED (s, t); }
{ pid_t t = getppid (); ISAAC_SEED (s, t); }
{ uid_t t = getuid (); ISAAC_SEED (s, t); }
{ gid_t t = getgid (); ISAAC_SEED (s, t); }
#if 0
/* The initialization of a through h is a precomputed form of: */
a = b = c = d = e = f = g = h = /* the golden ratio */
IF32 (UINT32_C (0x9e3779b9), UINT64_C (0x9e3779b97f4a7c13));
for (int i = 0; i < 4; i++) /* scramble it */
mix (a, b, c, d, e, f, g, h);
#endif
{
xtime_t t = gethrxtime ();
ISAAC_SEED (s, t);
}
/* Mix S->m so that every part of the seed affects every part of the
state. */
ISAAC_MIX (s, a, b, c, d, e, f, g, h, s->m);
ISAAC_MIX (s, a, b, c, d, e, f, g, h, s->m);
isaac_seed_finish (s);
s->a = s->b = s->c = 0;
}

View File

@@ -1,4 +1,4 @@
/* Bob Jenkins's cryptographic random number generator, ISAAC.
/* Bob Jenkins's cryptographic random number generators, ISAAC and ISAAC64.
Copyright (C) 1999-2005, 2009-2010 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
@@ -16,28 +16,50 @@
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 Colin Plumb. */
Written by Colin Plumb and Paul Eggert. */
#ifndef RAND_ISAAC_H
# define RAND_ISAAC_H
#ifndef _GL_RAND_ISAAC_H
#define _GL_RAND_ISAAC_H
# include <stdint.h>
#include <stddef.h>
#include <stdint.h>
/* Size of the state tables to use. ISAAC_LOG should be at least 3,
/* Log base 2 of the number of useful bits in an ISAAC word. It must
be either 5 or 6. By default, this uses a value that should be
faster for this architecture. */
#ifndef ISAAC_BITS_LOG
#if SIZE_MAX >> 31 >> 31 < 3 /* SIZE_MAX < 2**64 - 1 */
#define ISAAC_BITS_LOG 5
#else
#define ISAAC_BITS_LOG 6
#endif
#endif
/* The number of bits in an ISAAC word. */
#define ISAAC_BITS (1 << ISAAC_BITS_LOG)
#if ISAAC_BITS == 32
typedef uint_least32_t isaac_word;
#else
typedef uint_least64_t isaac_word;
#endif
/* Size of the state tables to use. ISAAC_WORDS_LOG should be at least 3,
and smaller values give less security. */
# define ISAAC_LOG 8
# define ISAAC_WORDS (1 << ISAAC_LOG)
# define ISAAC_BYTES (ISAAC_WORDS * sizeof (uint32_t))
#define ISAAC_WORDS_LOG 8
#define ISAAC_WORDS (1 << ISAAC_WORDS_LOG)
#define ISAAC_BYTES (ISAAC_WORDS * sizeof (isaac_word))
/* RNG state variables. The members of this structure are private. */
/* State variables for the random number generator. The M member
should be seeded with nonce data before calling isaac_seed. The
other members are private. */
struct isaac_state
{
uint32_t mm[ISAAC_WORDS]; /* Main state array */
uint32_t iv[8]; /* Seeding initial vector */
uint32_t a, b, c; /* Extra index variables */
isaac_word m[ISAAC_WORDS]; /* Main state array */
isaac_word a, b, c; /* Extra variables */
};
void isaac_seed (struct isaac_state *);
void isaac_refill (struct isaac_state *, uint32_t[ISAAC_WORDS]);
void isaac_refill (struct isaac_state *, isaac_word[ISAAC_WORDS]);
#endif

View File

@@ -125,7 +125,7 @@ randint_genmax (struct randint_source *s, randint genmax)
randint randmax = s->randmax;
randint choices = genmax + 1;
for (;;)
while (1)
{
if (randmax < genmax)
{

View File

@@ -24,12 +24,15 @@
#include <errno.h>
#include <error.h>
#include <exitfail.h>
#include <fcntl.h>
#include <quotearg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include "gettext.h"
#define _(msgid) gettext (msgid)
@@ -60,6 +63,10 @@
# define ALIGNED_POINTER(ptr, type) ((size_t) (ptr) % alignof (type) == 0)
#endif
#ifndef NAME_OF_NONCE_DEVICE
#define NAME_OF_NONCE_DEVICE "/dev/urandom"
#endif
/* The maximum buffer size used for reads of random data. Using the
value 2 * ISAAC_BYTES makes this the largest power of two that
would not otherwise cause struct randread_source to grow. */
@@ -100,7 +107,7 @@ struct randread_source
/* Up to a buffer's worth of pseudorandom data. */
union
{
uint32_t w[ISAAC_WORDS];
isaac_word w[ISAAC_WORDS];
unsigned char b[ISAAC_BYTES];
} data;
} isaac;
@@ -133,6 +140,52 @@ simple_new (FILE *source, void const *handler_arg)
return s;
}
/* Put a nonce value into BUFFER, with size BUFSIZE, but do not get
more than BYTES_BOUND bytes' worth of random information from any
nonce device. */
static void
get_nonce (void *buffer, size_t bufsize, size_t bytes_bound)
{
char *buf = buffer;
ssize_t seeded = 0;
/* Get some data from FD if available. */
int fd = open (NAME_OF_NONCE_DEVICE, O_RDONLY | O_BINARY);
if (0 <= fd)
{
seeded = read (fd, buf, MIN (bufsize, bytes_bound));
if (seeded < 0)
seeded = 0;
close (fd);
}
/* If there's no nonce device, use a poor approximation
by getting the time of day, etc. */
# define ISAAC_SEED(type, initialize_v) \
if (seeded < bufsize) \
{ \
type v; \
size_t nbytes = MIN (sizeof v, bufsize - seeded); \
initialize_v; \
memcpy (buf + seeded, &v, nbytes); \
seeded += nbytes; \
}
ISAAC_SEED (struct timeval, gettimeofday (&v, NULL));
ISAAC_SEED (pid_t, v = getpid ());
ISAAC_SEED (pid_t, v = getppid ());
ISAAC_SEED (uid_t, v = getuid ());
ISAAC_SEED (uid_t, v = getgid ());
#ifdef lint
/* Normally we like having the extra randomness from uninitialized
parts of BUFFER. However, omit this randomness if we want to
avoid false-positives from memory-checking debugging tools. */
memset (buf + seeded, 0, bufsize - seeded);
#endif
}
/* Create and initialize a random data source from NAME, or use a
reasonable default source if NAME is null. BYTES_BOUND is an upper
bound on the number of bytes that will be needed. If zero, it is a
@@ -165,6 +218,8 @@ randread_new (char const *name, size_t bytes_bound)
else
{
s->buf.isaac.buffered = 0;
get_nonce (s->buf.isaac.state.m, sizeof s->buf.isaac.state.m,
bytes_bound);
isaac_seed (&s->buf.isaac.state);
}
@@ -199,7 +254,7 @@ randread_set_handler_arg (struct randread_source *s, void const *handler_arg)
static void
readsource (struct randread_source *s, unsigned char *p, size_t size)
{
for (;;)
while (true)
{
size_t inbytes = fread (p, sizeof *p, size, s->source);
int fread_errno = errno;
@@ -221,7 +276,7 @@ readisaac (struct isaac *isaac, unsigned char *p, size_t size)
{
size_t inbytes = isaac->buffered;
for (;;)
while (true)
{
if (size <= inbytes)
{
@@ -236,9 +291,9 @@ readisaac (struct isaac *isaac, unsigned char *p, size_t size)
/* If P is aligned, write to *P directly to avoid the overhead
of copying from the buffer. */
if (ALIGNED_POINTER (p, uint32_t))
if (ALIGNED_POINTER (p, isaac_word))
{
uint32_t *wp = (uint32_t *) p;
isaac_word *wp = (isaac_word *) p;
while (ISAAC_BYTES <= size)
{
isaac_refill (&isaac->state, wp);

View File

@@ -1,17 +1,8 @@
diff --git c/lib/regcomp.c i/lib/regcomp.c
index 6472ff6..665b2ab 100644
--- c/lib/regcomp.c
+++ i/lib/regcomp.c
@@ -18,6 +18,8 @@
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+#include "intprops.h"
+#include "verify.h"
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
size_t length, reg_syntax_t syntax);
static void re_compile_fastmap_iter (regex_t *bufp,
@@ -541,7 +543,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
diff --git a/lib/regcomp.c b/lib/regcomp.c
index d5968bd..4926676 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -541,7 +541,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
size_t errbuf_size;
#else /* size_t might promote */
size_t
@@ -20,7 +11,7 @@ index 6472ff6..665b2ab 100644
char *_Restrict_ errbuf, size_t errbuf_size)
#endif
{
@@ -1375,7 +1377,7 @@ calc_first (void *extra, bin_tree_t *node)
@@ -1383,7 +1383,7 @@ calc_first (void *extra, bin_tree_t *node)
/* Pass 2: compute NEXT on the tree. Preorder visit. */
static reg_errcode_t
@@ -29,17 +20,7 @@ index 6472ff6..665b2ab 100644
{
switch (node->token.type)
{
@@ -2571,7 +2573,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
/* This loop is actually executed only when end != REG_MISSING,
to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
already created the start+1-th copy. */
- if ((Idx) -1 < 0 || end != REG_MISSING)
+ verify (! TYPE_SIGNED (Idx));
+ if (end != REG_MISSING)
for (i = start + 2; i <= end; ++i)
{
elem = duplicate_tree (elem, dfa);
@@ -2731,7 +2734,8 @@ static reg_errcode_t
@@ -2744,7 +2744,8 @@ static reg_errcode_t
internal_function
build_collating_symbol (bitset_t sbcset,
# ifdef RE_ENABLE_I18N
@@ -49,7 +30,7 @@ index 6472ff6..665b2ab 100644
# endif
const unsigned char *name)
{
@@ -3309,7 +3313,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
@@ -3323,7 +3324,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
static reg_errcode_t
parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
@@ -59,7 +40,7 @@ index 6472ff6..665b2ab 100644
reg_syntax_t syntax, bool accept_hyphen)
{
#ifdef RE_ENABLE_I18N
@@ -3396,8 +3401,9 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
@@ -3410,8 +3412,9 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
static reg_errcode_t
#ifdef RE_ENABLE_I18N
@@ -71,7 +52,7 @@ index 6472ff6..665b2ab 100644
#else /* not RE_ENABLE_I18N */
build_equiv_class (bitset_t sbcset, const unsigned char *name)
#endif /* not RE_ENABLE_I18N */
@@ -3798,7 +3804,7 @@ free_token (re_token_t *node)
@@ -3816,7 +3819,7 @@ free_token (re_token_t *node)
and its children. */
static reg_errcode_t

24
gl/modules/di-set Normal file
View File

@@ -0,0 +1,24 @@
Description:
manipulate sets of device-inode pairs efficiently
Files:
lib/di-set.c
lib/di-set.h
Depends-on:
ino-map
hash
configure.ac:
Makefile.am:
lib_SOURCES += di-set.c di-set.h
Include:
"di-set.h"
License
GPL
Maintainer:
Jim Meyering

10
gl/modules/di-set-tests Normal file
View File

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

24
gl/modules/fadvise Normal file
View File

@@ -0,0 +1,24 @@
Description:
Declare an access pattern hint for files.
Files:
lib/fadvise.c
lib/fadvise.h
Depends-on:
ignore-value
configure.ac:
AC_CHECK_FUNCS_ONCE([posix_fadvise])
Makefile.am:
lib_SOURCES += fadvise.c fadvise.h
Include:
"fadvise.h"
License:
LGPL
Maintainer:
Pádraig Brady

24
gl/modules/heap Normal file
View File

@@ -0,0 +1,24 @@
Description:
Binary heap with minimal number of methods. Used in sort.
Files:
lib/heap.c
lib/heap.h
Depends-on:
stdlib-safer
xalloc
configure.ac:
Makefile.am:
lib_SOURCES += heap.c heap.h
Include:
"heap.h"
License
GPL
Maintainer:
Gene Auyeung

24
gl/modules/ino-map Normal file
View File

@@ -0,0 +1,24 @@
Description:
maintain a mapping of ino_t numbers to small integers
Files:
lib/ino-map.c
lib/ino-map.h
Depends-on:
hash
verify
configure.ac:
Makefile.am:
lib_SOURCES += ino-map.c ino-map.h
Include:
"ino-map.h"
License
GPL
Maintainer:
Jim Meyering

10
gl/modules/ino-map-tests Normal file
View File

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

View File

@@ -10,6 +10,7 @@ wchar
wctype
wcwidth
mempcpy
stdint
configure.ac:

11
gl/modules/mbsalign-tests Normal file
View File

@@ -0,0 +1,11 @@
Files:
tests/test-mbsalign.c
tests/macros.h
Depends-on:
configure.ac:
Makefile.am:
TESTS += test-mbsalign
check_PROGRAMS += test-mbsalign

View File

@@ -10,8 +10,9 @@ lib/randread.h
Depends-on:
error
exitfail
inline
fopen-safer
gethrxtime
gettimeofday
quotearg
stdbool
stdint

10
gl/modules/randread-tests Normal file
View File

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

63
gl/tests/test-di-set.c Normal file
View File

@@ -0,0 +1,63 @@
/* Test the di-set module.
Copyright (C) 2010 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>
#include <stdint.h>
#define ASSERT(expr) \
do \
{ \
if (!(expr)) \
{ \
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
fflush (stderr); \
abort (); \
} \
} \
while (0)
#include "di-set.h"
int
main (void)
{
struct di_set *dis = di_set_alloc ();
ASSERT (dis);
ASSERT (di_set_insert (dis, 2, 5) == 1); /* first insertion succeeds */
ASSERT (di_set_insert (dis, 2, 5) == 0); /* duplicate fails */
ASSERT (di_set_insert (dis, 3, 5) == 1); /* diff dev, duplicate inode is ok */
ASSERT (di_set_insert (dis, 2, 8) == 1); /* same dev, different inode is ok */
/* very large (or negative) inode number */
ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 1);
ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 0); /* dup */
unsigned int i;
for (i = 0; i < 3000; i++)
ASSERT (di_set_insert (dis, 9, i) == 1);
for (i = 0; i < 3000; i++)
ASSERT (di_set_insert (dis, 9, i) == 0); /* duplicate fails */
di_set_free (dis);
return 0;
}

43
gl/tests/test-fadvise.c Normal file
View File

@@ -0,0 +1,43 @@
/* Test that fadvise works as advertised.
Copyright (C) 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Pádraig Brady. */
#include <config.h>
#include <stdio.h>
#include "fadvise.h"
int
main (void)
{
/* Valid. */
fadvise (stdin, FADVISE_SEQUENTIAL);
fdadvise (fileno (stdin), 0, 0, FADVISE_RANDOM);
/* Ignored. */
fadvise (NULL, FADVISE_RANDOM);
/* Invalid. */
fdadvise (42, 0, 0, FADVISE_RANDOM);
/* Unfortunately C enums are not types.
One could hack type safety by wrapping in a struct,
but it's probably not worth the complexity in this case. */
fadvise (stdin, FADVISE_SEQUENTIAL + FADVISE_RANDOM);
fadvise (stdin, 4242);
return 0;
}

62
gl/tests/test-ino-map.c Normal file
View File

@@ -0,0 +1,62 @@
/* Test the ino-map module.
Copyright (C) 2010 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>
/* FIXME: once/if in gnulib, use #include "macros.h" in place of this */
#define ASSERT(expr) \
do \
{ \
if (!(expr)) \
{ \
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
fflush (stderr); \
abort (); \
} \
} \
while (0)
#include "ino-map.h"
int
main ()
{
enum { INO_MAP_INIT = 123 };
struct ino_map *ino_map = ino_map_alloc (INO_MAP_INIT);
ASSERT (ino_map != NULL);
ASSERT (ino_map_insert (ino_map, 42) == INO_MAP_INIT);
ASSERT (ino_map_insert (ino_map, 42) == INO_MAP_INIT);
ASSERT (ino_map_insert (ino_map, 398) == INO_MAP_INIT + 1);
ASSERT (ino_map_insert (ino_map, 398) == INO_MAP_INIT + 1);
ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2);
ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2);
int i;
for (i = 0; i < 100; i++)
{
ASSERT (ino_map_insert (ino_map, 10000 + i) == INO_MAP_INIT + 3 + i);
}
ino_map_free (ino_map);
return 0;
}

100
gl/tests/test-mbsalign.c Normal file
View File

@@ -0,0 +1,100 @@
/* Test that mbsalign works as advertised.
Copyright (C) 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Pádraig Brady. */
#include <config.h>
#include "mbsalign.h"
#include "macros.h"
#include <stdlib.h>
#include <locale.h>
int
main (void)
{
char dest[4 * 16 + 1];
size_t width, n;
/* Test unibyte truncation. */
width = 4;
n = mbsalign ("t\tés", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
ASSERT (n == 4);
/* Test center alignment. */
width = 4;
n = mbsalign ("es", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
if (setlocale (LC_ALL, "en_US.UTF8"))
{
/* Check invalid input is flagged. */
width = 4;
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
ASSERT (n == (size_t) -1);
/* Check invalid input is treated as unibyte */
width = 4;
n = mbsalign ("t\xe1\xe2s", dest, sizeof dest, &width,
MBS_ALIGN_LEFT, MBA_UNIBYTE_FALLBACK);
ASSERT (n == 4);
/* Test multibyte center alignment. */
width = 4;
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_CENTER, 0);
ASSERT (*dest == ' ' && *(dest + n - 1) == ' ');
/* Test multibyte left alignment. */
width = 4;
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
ASSERT (*(dest + n - 1) == ' ' && *(dest + n - 2) == ' ');
/* Test multibyte right alignment. */
width = 4;
n = mbsalign ("és", dest, sizeof dest, &width, MBS_ALIGN_RIGHT, 0);
ASSERT (*(dest) == ' ' && *(dest + 1) == ' ');
/* multibyte multicell truncation. */
width = 4; /* cells */
n = mbsalign ("日月火水", dest, sizeof dest, &width,
MBS_ALIGN_LEFT, 0);
ASSERT (n == 6); /* 2 characters */
/* multibyte unicell truncation. */
width = 3; /* cells */
n = mbsalign ("¹²³⁴", dest, sizeof dest, &width, MBS_ALIGN_LEFT, 0);
ASSERT (n == 6); /* 3 characters */
/* Check independence from dest buffer. */
width = 4; /* cells */
n = mbsalign ("¹²³⁴", dest, 0, &width, MBS_ALIGN_LEFT, 0);
ASSERT (n == 9); /* 4 characters */
/* Check that width is updated with cells required before padding. */
width = 4; /* cells */
n = mbsalign ("¹²³", dest, 0, &width, MBS_ALIGN_LEFT, 0);
ASSERT (width == 3);
/* Test case where output is larger than input
(as tab converted to multi byte replacement char). */
width = 4;
n = mbsalign ("t\tés" /* 6 including NUL */ , dest, sizeof dest,
&width, MBS_ALIGN_LEFT, 0);
ASSERT (n == 7);
}
return 0;
}

604
gl/tests/test-rand-isaac.c Normal file
View File

@@ -0,0 +1,604 @@
/* Test the ISAAC or ISAAC64 pseudorandom number generator.
Copyright (C) 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#include <config.h>
#include "rand-isaac.h"
#include <fcntl.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* FIXME: once/if in gnulib, use #include "macros.h" in place of this */
#define ASSERT(expr) \
do \
{ \
if (!(expr)) \
{ \
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
fflush (stderr); \
abort (); \
} \
} \
while (0)
/* This expected output was generated by running the programs in
<http://burtleburtle.net/bob/rand/isaacafa.html>, as last modified
on 2010-01-22. The 32-bit numbers were output by rand.c, and the
64-bit by isaac64.c, both on x86, as those programs are not
portable to 64-bit platforms. */
static isaac_word const expected[2][ISAAC_WORDS] =
{
#if ISAAC_BITS == 32
{
UINT32_C (0xf650e4c8), UINT32_C (0xe448e96d),
UINT32_C (0x98db2fb4), UINT32_C (0xf5fad54f),
UINT32_C (0x433f1afb), UINT32_C (0xedec154a),
UINT32_C (0xd8370487), UINT32_C (0x46ca4f9a),
UINT32_C (0x5de3743e), UINT32_C (0x88381097),
UINT32_C (0xf1d444eb), UINT32_C (0x823cedb6),
UINT32_C (0x6a83e1e0), UINT32_C (0x4a5f6355),
UINT32_C (0xc7442433), UINT32_C (0x25890e2e),
UINT32_C (0x7452e319), UINT32_C (0x57161df6),
UINT32_C (0x38a824f3), UINT32_C (0x002ed713),
UINT32_C (0x29f55449), UINT32_C (0x51c08d83),
UINT32_C (0xd78cb99e), UINT32_C (0xa0cc74f3),
UINT32_C (0x8f651659), UINT32_C (0xcbc8b7c2),
UINT32_C (0xf5f71c69), UINT32_C (0x12ad6419),
UINT32_C (0xe5792e1b), UINT32_C (0x860536b8),
UINT32_C (0x09b3ce98), UINT32_C (0xd45d6d81),
UINT32_C (0xf3b26129), UINT32_C (0x17e38f85),
UINT32_C (0x29cf72ce), UINT32_C (0x349947b0),
UINT32_C (0xc998f9ff), UINT32_C (0xb5e13dae),
UINT32_C (0x32ae2a2b), UINT32_C (0xf7cf814c),
UINT32_C (0x8ebfa303), UINT32_C (0xcf22e064),
UINT32_C (0x0b923200), UINT32_C (0xeca4d58a),
UINT32_C (0xef53cec4), UINT32_C (0xd0f7b37d),
UINT32_C (0x9c411a2a), UINT32_C (0xffdf8a80),
UINT32_C (0xb40e27bc), UINT32_C (0xb4d2f976),
UINT32_C (0x44b89b08), UINT32_C (0xf37c71d5),
UINT32_C (0x1a70e7e9), UINT32_C (0x0bdb9c30),
UINT32_C (0x60dc5207), UINT32_C (0xb3c3f24b),
UINT32_C (0xd7386806), UINT32_C (0x229749b5),
UINT32_C (0x4e232cd0), UINT32_C (0x91dabc65),
UINT32_C (0xa70e1101), UINT32_C (0x8b87437e),
UINT32_C (0x5781414f), UINT32_C (0xcdbc62e2),
UINT32_C (0x8107c9ff), UINT32_C (0x69d2e4ae),
UINT32_C (0x3b18e752), UINT32_C (0xb143b688),
UINT32_C (0x6f4e0772), UINT32_C (0x95138769),
UINT32_C (0x943c3c74), UINT32_C (0xafc17a97),
UINT32_C (0x0fd43963), UINT32_C (0x6a529b0b),
UINT32_C (0xd8c58a6a), UINT32_C (0xa8bcc22d),
UINT32_C (0x2db35dfe), UINT32_C (0xa7a2f402),
UINT32_C (0x6cb167db), UINT32_C (0x538e1f4e),
UINT32_C (0x7275e277), UINT32_C (0x1d3b8e97),
UINT32_C (0xecc5dc91), UINT32_C (0x15e3a5b9),
UINT32_C (0x03696614), UINT32_C (0x30ab93ec),
UINT32_C (0xac9fe69d), UINT32_C (0x7bc76811),
UINT32_C (0x60eda8da), UINT32_C (0x28833522),
UINT32_C (0xd5295ebc), UINT32_C (0x5adb60e7),
UINT32_C (0xf7e1cdd0), UINT32_C (0x97166d14),
UINT32_C (0xb67ec13a), UINT32_C (0x210f3925),
UINT32_C (0x64af0fef), UINT32_C (0x0d028684),
UINT32_C (0x3aea3dec), UINT32_C (0xb058bafb),
UINT32_C (0xb8b0ccfc), UINT32_C (0xf2b5cc05),
UINT32_C (0xe3a662d9), UINT32_C (0x814bc24c),
UINT32_C (0x2364a1aa), UINT32_C (0x37c0ed05),
UINT32_C (0x2b36505c), UINT32_C (0x451e7ec8),
UINT32_C (0x5d2a542f), UINT32_C (0xe43d0fbb),
UINT32_C (0x91c8d925), UINT32_C (0x60d4d5f8),
UINT32_C (0x12a0594b), UINT32_C (0x9e8a51da),
UINT32_C (0xcd49ebdb), UINT32_C (0x1b0dcdc1),
UINT32_C (0xcd57c7f7), UINT32_C (0xe6344451),
UINT32_C (0x7ded386f), UINT32_C (0x2f36fa86),
UINT32_C (0xa6d12101), UINT32_C (0x33bc405d),
UINT32_C (0xb388d96c), UINT32_C (0xdb6dbe96),
UINT32_C (0xfe29661c), UINT32_C (0x13edc0cb),
UINT32_C (0xcb0eee4a), UINT32_C (0x70cc94ae),
UINT32_C (0xde11ed34), UINT32_C (0x0606cf9f),
UINT32_C (0x3a6ce389), UINT32_C (0x23d74f4e),
UINT32_C (0xa37f63ff), UINT32_C (0x917bdec2),
UINT32_C (0xd73f72d4), UINT32_C (0x0e7e0e67),
UINT32_C (0x3d77d9a2), UINT32_C (0x13add922),
UINT32_C (0x8891b3db), UINT32_C (0x01a9bd70),
UINT32_C (0x56a001e3), UINT32_C (0xd51f093d),
UINT32_C (0xcc033ce3), UINT32_C (0x5ad0d3b0),
UINT32_C (0x34105a8c), UINT32_C (0x6a123f57),
UINT32_C (0xbd2e5024), UINT32_C (0x7364944b),
UINT32_C (0xe89b1a3b), UINT32_C (0x21835c4d),
UINT32_C (0x9f39e2d9), UINT32_C (0xd405ded8),
UINT32_C (0x294d37e5), UINT32_C (0xbccaaeed),
UINT32_C (0x35a124b5), UINT32_C (0x6708a2bc),
UINT32_C (0xb00960ba), UINT32_C (0x2a98121a),
UINT32_C (0x4d8fae82), UINT32_C (0x0bb3263f),
UINT32_C (0x12595a19), UINT32_C (0x6a107589),
UINT32_C (0x0809e494), UINT32_C (0x21c171ec),
UINT32_C (0x884d6825), UINT32_C (0x14c8009b),
UINT32_C (0xb0b84e7b), UINT32_C (0x03fb88f4),
UINT32_C (0x28e7cb78), UINT32_C (0x9388b13b),
UINT32_C (0xdd2dc1d5), UINT32_C (0x848f520a),
UINT32_C (0x07c28cd1), UINT32_C (0x68a39358),
UINT32_C (0x72c9137d), UINT32_C (0x127dd430),
UINT32_C (0xc613f157), UINT32_C (0x8c2f0d55),
UINT32_C (0xf7d3f39f), UINT32_C (0x309bfb78),
UINT32_C (0x8406b137), UINT32_C (0x46c0a6f5),
UINT32_C (0x3718d597), UINT32_C (0x08607f04),
UINT32_C (0x76904b6d), UINT32_C (0x04db4e13),
UINT32_C (0xcd7411a7), UINT32_C (0xb510ce0e),
UINT32_C (0xbfc7f7cc), UINT32_C (0xb83f957a),
UINT32_C (0xfdfef62d), UINT32_C (0xc35e4580),
UINT32_C (0x3ff1e524), UINT32_C (0x4112d96c),
UINT32_C (0x02c9b944), UINT32_C (0xd5990dfb),
UINT32_C (0xe7e26581), UINT32_C (0x0d9c7e7e),
UINT32_C (0x826dfa89), UINT32_C (0x66f1e0ab),
UINT32_C (0x30bcc764), UINT32_C (0xeadebeac),
UINT32_C (0xed35e5ee), UINT32_C (0x0c571a7d),
UINT32_C (0xe4f3a26a), UINT32_C (0xf7f58f7b),
UINT32_C (0xadf6bc23), UINT32_C (0x5d023e65),
UINT32_C (0x1ed3ff4e), UINT32_C (0xec46b0b6),
UINT32_C (0xd2a93b51), UINT32_C (0xe75b41c9),
UINT32_C (0x7e315aeb), UINT32_C (0x61119a5a),
UINT32_C (0x53245b79), UINT32_C (0x33f6d7b1),
UINT32_C (0xcae8deba), UINT32_C (0x50fc8194),
UINT32_C (0xafa92a6d), UINT32_C (0xc87c8006),
UINT32_C (0x4188bfcd), UINT32_C (0x8bace62e),
UINT32_C (0x78ffa568), UINT32_C (0x5597ec0f),
UINT32_C (0xb4415f7d), UINT32_C (0x08294766),
UINT32_C (0xad567643), UINT32_C (0x09c36f90),
UINT32_C (0x3dde9f39), UINT32_C (0x4a0a283c),
UINT32_C (0x18080c8e), UINT32_C (0x080c79ec),
UINT32_C (0x79ae4c10), UINT32_C (0xcb9e1563),
UINT32_C (0x7cdd662f), UINT32_C (0x62d31911),
UINT32_C (0xa4ca0cf1), UINT32_C (0x5cf824cd),
UINT32_C (0x3b708f99), UINT32_C (0x1e16614c),
UINT32_C (0xb6b9d766), UINT32_C (0x5de87abb),
UINT32_C (0x7229ea81), UINT32_C (0xd5b2d750),
UINT32_C (0x56e6cd21), UINT32_C (0xfe1e42d5),
UINT32_C (0x96da2655), UINT32_C (0xc2b9aa36),
UINT32_C (0xb8f6fd4a), UINT32_C (0x6a158d10),
UINT32_C (0x01913fd3), UINT32_C (0xaf7d1fb8),
UINT32_C (0x0b5e435f), UINT32_C (0x90c10757),
UINT32_C (0x6554abda), UINT32_C (0x7a68710f)
},
{
UINT32_C (0x82ac484f), UINT32_C (0xd7e1c7be),
UINT32_C (0x95c85eaa), UINT32_C (0x94a302f4),
UINT32_C (0x4d3cfbda), UINT32_C (0x786b2908),
UINT32_C (0x1010b275), UINT32_C (0x82d53d12),
UINT32_C (0x21e2a51c), UINT32_C (0x3d1e9150),
UINT32_C (0xb059261d), UINT32_C (0xd0638e1a),
UINT32_C (0x31860f05), UINT32_C (0x81f2864d),
UINT32_C (0xff4cfc35), UINT32_C (0x0451516d),
UINT32_C (0xbd086f26), UINT32_C (0xbc5654c1),
UINT32_C (0x65dfa427), UINT32_C (0xa82427f5),
UINT32_C (0x582e3014), UINT32_C (0xb8d2486d),
UINT32_C (0xc79a1749), UINT32_C (0x9a1d7745),
UINT32_C (0x8766bb54), UINT32_C (0x1e04a7f7),
UINT32_C (0x3d3dff8a), UINT32_C (0xd5ec6bf4),
UINT32_C (0xdbef7d9f), UINT32_C (0x36ec0ea3),
UINT32_C (0x1feb2e4f), UINT32_C (0x15cfcc5c),
UINT32_C (0xd8c423fb), UINT32_C (0xd0ef3cc9),
UINT32_C (0xeb244925), UINT32_C (0xba5590c8),
UINT32_C (0xa5f48ac4), UINT32_C (0x33c5321c),
UINT32_C (0x613b67b2), UINT32_C (0x479c3a22),
UINT32_C (0xe21339cc), UINT32_C (0x10d210aa),
UINT32_C (0x931dd7e2), UINT32_C (0xef05ee06),
UINT32_C (0xb82f2703), UINT32_C (0xa385cb2c),
UINT32_C (0x5d67133c), UINT32_C (0x877eb7b4),
UINT32_C (0x1e3437f7), UINT32_C (0x5afb43ae),
UINT32_C (0x53c078f3), UINT32_C (0x94d90481),
UINT32_C (0x1d964589), UINT32_C (0x08063a85),
UINT32_C (0xe1322228), UINT32_C (0x1956b1e5),
UINT32_C (0x31860f13), UINT32_C (0x2e7b022f),
UINT32_C (0x21182ca3), UINT32_C (0x96f703ac),
UINT32_C (0x46819e2e), UINT32_C (0x0d28fe52),
UINT32_C (0x3724d4dc), UINT32_C (0xa0eabe6b),
UINT32_C (0xc66699fd), UINT32_C (0xc6112fdd),
UINT32_C (0x19c1e69c), UINT32_C (0x04d3658a),
UINT32_C (0x4b55dd99), UINT32_C (0x31907d62),
UINT32_C (0xf854b522), UINT32_C (0x4d678f26),
UINT32_C (0x22ae0582), UINT32_C (0xeafed133),
UINT32_C (0xe4a51d21), UINT32_C (0x84bd6dd6),
UINT32_C (0xc1a51375), UINT32_C (0x3f28ee63),
UINT32_C (0xfb737b1a), UINT32_C (0x70a1660e),
UINT32_C (0x8a8dfaa3), UINT32_C (0x1be79937),
UINT32_C (0xf7476978), UINT32_C (0x513c1764),
UINT32_C (0x531ac6bf), UINT32_C (0x12c06908),
UINT32_C (0x001cdb95), UINT32_C (0x1a4b6a53),
UINT32_C (0xd067fce5), UINT32_C (0x12b2cfb6),
UINT32_C (0x9ddb477f), UINT32_C (0x740e0066),
UINT32_C (0x39ddf25a), UINT32_C (0xcc8bfa2d),
UINT32_C (0xf1b20eaf), UINT32_C (0x64f2632c),
UINT32_C (0x9783cdee), UINT32_C (0x63bfd4d8),
UINT32_C (0x0084cfe5), UINT32_C (0x75f4e9e2),
UINT32_C (0x19b48fd0), UINT32_C (0x6c48ddd8),
UINT32_C (0x7a36af93), UINT32_C (0x71865c4c),
UINT32_C (0x9ce0199d), UINT32_C (0x867027d7),
UINT32_C (0x2cb7b77f), UINT32_C (0x84ef01da),
UINT32_C (0x72f5972f), UINT32_C (0x040f7074),
UINT32_C (0xdf9afa29), UINT32_C (0xc921f94e),
UINT32_C (0x75c08a36), UINT32_C (0x18c1ef9a),
UINT32_C (0xd649a428), UINT32_C (0xc5b71937),
UINT32_C (0x8a30738a), UINT32_C (0xd97cd348),
UINT32_C (0x858129a6), UINT32_C (0x239e3b0a),
UINT32_C (0xbbb8abc4), UINT32_C (0x80fac4c2),
UINT32_C (0xecfcf20b), UINT32_C (0xd9d711f9),
UINT32_C (0xe2a4ef71), UINT32_C (0xb5fe87c0),
UINT32_C (0xbe8b06b2), UINT32_C (0xaafef5a7),
UINT32_C (0x9c15db3b), UINT32_C (0x0aeb8165),
UINT32_C (0x4389a84a), UINT32_C (0x253b1d7a),
UINT32_C (0x19047c79), UINT32_C (0x7cdc78a2),
UINT32_C (0xd20adf03), UINT32_C (0x56f55a71),
UINT32_C (0x3e730fa8), UINT32_C (0xfd8650d8),
UINT32_C (0x959e234e), UINT32_C (0xb7546681),
UINT32_C (0xdad1b22a), UINT32_C (0x142a6e85),
UINT32_C (0x8ef4bce6), UINT32_C (0x68235b9d),
UINT32_C (0x85a13f85), UINT32_C (0x74096ae7),
UINT32_C (0xa949bea2), UINT32_C (0x29322d0d),
UINT32_C (0xd5683858), UINT32_C (0x82846526),
UINT32_C (0x403dae08), UINT32_C (0x6dd1943a),
UINT32_C (0xe1279bff), UINT32_C (0x9e7e4f04),
UINT32_C (0x1c3a4524), UINT32_C (0x484525e4),
UINT32_C (0x81d4cc5f), UINT32_C (0xe24124c0),
UINT32_C (0x037464c0), UINT32_C (0xbf1bd691),
UINT32_C (0x26ceb003), UINT32_C (0x275ead3a),
UINT32_C (0xc5bde908), UINT32_C (0x26414ff3),
UINT32_C (0xa30519ad), UINT32_C (0xd7b43abe),
UINT32_C (0x2ce5d3d5), UINT32_C (0x88412761),
UINT32_C (0x97ca2070), UINT32_C (0xe5fbb9c7),
UINT32_C (0x276df0b4), UINT32_C (0x308f751f),
UINT32_C (0x37a97df6), UINT32_C (0xc9cd808c),
UINT32_C (0xfe4cb380), UINT32_C (0x3d469303),
UINT32_C (0xaee19096), UINT32_C (0xc0d5d42a),
UINT32_C (0x4e823ad3), UINT32_C (0xf5f9cc3b),
UINT32_C (0x4286619c), UINT32_C (0x9ca45e1c),
UINT32_C (0x66c97340), UINT32_C (0x891aec49),
UINT32_C (0x45bae606), UINT32_C (0xc798f047),
UINT32_C (0x52649d6c), UINT32_C (0xce86fdfc),
UINT32_C (0x80c6e402), UINT32_C (0xd6ec2f2b),
UINT32_C (0x27c82282), UINT32_C (0x1fe26ce0),
UINT32_C (0x92f57ea7), UINT32_C (0xde462f4d),
UINT32_C (0x07497cae), UINT32_C (0x5a48755c),
UINT32_C (0x721502dd), UINT32_C (0x6cbe7935),
UINT32_C (0x836d8003), UINT32_C (0x9ead7f70),
UINT32_C (0x9ab3a42f), UINT32_C (0x4c8652d6),
UINT32_C (0x32e39273), UINT32_C (0xe8fa3860),
UINT32_C (0x1da4f25a), UINT32_C (0x0cd6ef81),
UINT32_C (0x02503f7d), UINT32_C (0x8854a0a1),
UINT32_C (0x9a30c4e8), UINT32_C (0x88157153),
UINT32_C (0x05efe294), UINT32_C (0x57c4c925),
UINT32_C (0x2887d96f), UINT32_C (0xc1a71e3c),
UINT32_C (0xe9f84163), UINT32_C (0x2d0985de),
UINT32_C (0xd21e796c), UINT32_C (0x6fb5ce56),
UINT32_C (0x02614abf), UINT32_C (0xc3c7be2c),
UINT32_C (0xb54fed6f), UINT32_C (0xa617a083),
UINT32_C (0xc3142d8f), UINT32_C (0x6079e4ce),
UINT32_C (0xceffc147), UINT32_C (0x1d0cb81b),
UINT32_C (0xdc153e5f), UINT32_C (0xe36ef5bb),
UINT32_C (0xd531161a), UINT32_C (0x165b1015),
UINT32_C (0x7aa114ed), UINT32_C (0x3f7579b3),
UINT32_C (0xf7f395f1), UINT32_C (0xbc6172c7),
UINT32_C (0xa86f875e), UINT32_C (0x0e6c51b3),
UINT32_C (0xcdfec2af), UINT32_C (0x73c0e762),
UINT32_C (0x824c2009), UINT32_C (0xc5a87748),
UINT32_C (0x94d40125), UINT32_C (0x8aba3ffb),
UINT32_C (0xd32be060), UINT32_C (0x8c17eff0),
UINT32_C (0x21e2547e), UINT32_C (0x07cffad9),
UINT32_C (0x05340e15), UINT32_C (0xf3310c92),
UINT32_C (0x9d8d1908), UINT32_C (0x86ba527f),
UINT32_C (0xf943f672), UINT32_C (0xef73fbf0),
UINT32_C (0x46d95ca5), UINT32_C (0xc54cd95b),
UINT32_C (0x9d855e89), UINT32_C (0x4bb5af29)
}
#else
{
UINT64_C (0x12a8f216af9418c2), UINT64_C (0xd4490ad526f14431),
UINT64_C (0xb49c3b3995091a36), UINT64_C (0x5b45e522e4b1b4ef),
UINT64_C (0xa1e9300cd8520548), UINT64_C (0x49787fef17af9924),
UINT64_C (0x03219a39ee587a30), UINT64_C (0xebe9ea2adf4321c7),
UINT64_C (0x804456af10f5fb53), UINT64_C (0xd74bbe77e6116ac7),
UINT64_C (0x7c0828dd624ec390), UINT64_C (0x14a195640116f336),
UINT64_C (0x2eab8ca63ce802d7), UINT64_C (0xc6e57a78fbd986e0),
UINT64_C (0x58efc10b06a2068d), UINT64_C (0xabeeddb2dde06ff1),
UINT64_C (0x0b090a7560a968e3), UINT64_C (0x2cf9c8ca052f6e9f),
UINT64_C (0x116d0016cb948f09), UINT64_C (0xa59e0bd101731a28),
UINT64_C (0x63767572ae3d6174), UINT64_C (0xab4f6451cc1d45ec),
UINT64_C (0xc2a1e7b5b459aeb5), UINT64_C (0x2472f6207c2d0484),
UINT64_C (0xe699ed85b0dfb40d), UINT64_C (0xd4347f66ec8941c3),
UINT64_C (0xf4d14597e660f855), UINT64_C (0x8b889d624d44885d),
UINT64_C (0x258e5a80c7204c4b), UINT64_C (0xaf0c317d32adaa8a),
UINT64_C (0x9c4cd6257c5a3603), UINT64_C (0xeb3593803173e0ce),
UINT64_C (0x36f60e2ba4fa6800), UINT64_C (0x38b6525c21a42b0e),
UINT64_C (0xf4f5d05c10cab243), UINT64_C (0xcf3f4688801eb9aa),
UINT64_C (0x1ddc0325259b27de), UINT64_C (0xb9571fa04dc089c8),
UINT64_C (0xd7504dfa8816edbb), UINT64_C (0x1fe2cca76517db90),
UINT64_C (0x261e4e4c0a333a9d), UINT64_C (0x219b97e26ffc81bd),
UINT64_C (0x66b4835d9eafea22), UINT64_C (0x4cc317fb9cddd023),
UINT64_C (0x50b704cab602c329), UINT64_C (0xedb454e7badc0805),
UINT64_C (0x9e17e49642a3e4c1), UINT64_C (0x66c1a2a1a60cd889),
UINT64_C (0x7983eed3740847d5), UINT64_C (0x298af231c85bafab),
UINT64_C (0x2680b122baa28d97), UINT64_C (0x734de8181f6ec39a),
UINT64_C (0x53898e4c3910da55), UINT64_C (0x1761f93a44d5aefe),
UINT64_C (0xe4dbf0634473f5d2), UINT64_C (0x4ed0fe7e9dc91335),
UINT64_C (0xd18d8549d140caea), UINT64_C (0x1cfc8bed0d681639),
UINT64_C (0xca1e3785a9e724e5), UINT64_C (0xb67c1fa481680af8),
UINT64_C (0xdfea21ea9e7557e3), UINT64_C (0xd6b6d0ecc617c699),
UINT64_C (0xfa7e393983325753), UINT64_C (0xa09e8c8c35ab96de),
UINT64_C (0x8fe88b57305e2ab6), UINT64_C (0x89039d79d6fc5c5c),
UINT64_C (0x9bfb227ebdf4c5ce), UINT64_C (0x7f7cc39420a3a545),
UINT64_C (0x3f6c6af859d80055), UINT64_C (0xc8763c5b08d1908c),
UINT64_C (0x469356c504ec9f9d), UINT64_C (0x26e6db8ffdf5adfe),
UINT64_C (0x3a938fee32d29981), UINT64_C (0x2c5e9deb57ef4743),
UINT64_C (0x1e99b96e70a9be8b), UINT64_C (0x764dbeae7fa4f3a6),
UINT64_C (0xaac40a2703d9bea0), UINT64_C (0x1a8c1e992b941148),
UINT64_C (0x73aa8a564fb7ac9e), UINT64_C (0x604d51b25fbf70e2),
UINT64_C (0xdd69a0d8ab3b546d), UINT64_C (0x65ca5b96b7552210),
UINT64_C (0x2fd7e4b9e72cd38c), UINT64_C (0x51d2b1ab2ddfb636),
UINT64_C (0x9d1d84fcce371425), UINT64_C (0xa44cfe79ae538bbe),
UINT64_C (0xde68a2355b93cae6), UINT64_C (0x9fc10d0f989993e0),
UINT64_C (0x94ebc8abcfb56dae), UINT64_C (0xd7a023a73260b45c),
UINT64_C (0x72c8834a5957b511), UINT64_C (0x8f8419a348f296bf),
UINT64_C (0x1e152328f3318dea), UINT64_C (0x4838d65f6ef6748f),
UINT64_C (0xd6bf7baee43cac40), UINT64_C (0x13328503df48229f),
UINT64_C (0x7440fb816508c4fe), UINT64_C (0x9d266d6a1cc0542c),
UINT64_C (0x4dda48153c94938a), UINT64_C (0x74c04bf1790c0efe),
UINT64_C (0xe1925c71285279f5), UINT64_C (0x8a8e849eb32781a5),
UINT64_C (0x073973751f12dd5e), UINT64_C (0xa319ce15b0b4db31),
UINT64_C (0x6dd856d94d259236), UINT64_C (0x67378d8eccef96cb),
UINT64_C (0x9fc477de4ed681da), UINT64_C (0xf3b8b6675a6507ff),
UINT64_C (0xc3a9dc228caac9e9), UINT64_C (0xc37b45b3f8d6f2ba),
UINT64_C (0xb559eb1d04e5e932), UINT64_C (0x1b0cab936e65c744),
UINT64_C (0xaf08da9177dda93d), UINT64_C (0xac12fb171817eee7),
UINT64_C (0x1fff7ac80904bf45), UINT64_C (0xa9119b60369ffebd),
UINT64_C (0xbfced1b0048eac50), UINT64_C (0xb67b7896167b4c84),
UINT64_C (0x9b3cdb65f82ca382), UINT64_C (0xdbc27ab5447822bf),
UINT64_C (0x10dcd78e3851a492), UINT64_C (0xb438c2b67f98e5e9),
UINT64_C (0x43954b3252dc25e5), UINT64_C (0xab9090168dd05f34),
UINT64_C (0xce68341f79893389), UINT64_C (0x36833336d068f707),
UINT64_C (0xdcdd7d20903d0c25), UINT64_C (0xda3a361b1c5157b1),
UINT64_C (0x7f9d1a2e1ebe1327), UINT64_C (0x5d0a12f27ad310d1),
UINT64_C (0x3bc36e078f7515d7), UINT64_C (0x4da8979a0041e8a9),
UINT64_C (0x950113646d1d6e03), UINT64_C (0x7b4a38e32537df62),
UINT64_C (0x8a1b083821f40cb4), UINT64_C (0x3d5774a11d31ab39),
UINT64_C (0x7a76956c3eafb413), UINT64_C (0x7f5126dbba5e0ca7),
UINT64_C (0x12153635b2c0cf57), UINT64_C (0x7b3f0195fc6f290f),
UINT64_C (0x5544f7d774b14aef), UINT64_C (0x56c074a581ea17fe),
UINT64_C (0xe7f28ecd2d49eecd), UINT64_C (0xe479ee5b9930578c),
UINT64_C (0x9ff38fed72e9052f), UINT64_C (0x9f65789a6509a440),
UINT64_C (0x0981dcd296a8736d), UINT64_C (0x5873888850659ae7),
UINT64_C (0xc678b6d860284a1c), UINT64_C (0x63e22c147b9c3403),
UINT64_C (0x92fae24291f2b3f1), UINT64_C (0x829626e3892d95d7),
UINT64_C (0xcffe1939438e9b24), UINT64_C (0x79999cdff70902cb),
UINT64_C (0x8547eddfb81ccb94), UINT64_C (0x7b77497b32503b12),
UINT64_C (0x97fcaacbf030bc24), UINT64_C (0x6ced1983376fa72b),
UINT64_C (0x7e75d99d94a70f4d), UINT64_C (0xd2733c4335c6a72f),
UINT64_C (0xdbc0d2b6ab90a559), UINT64_C (0x94628d38d0c20584),
UINT64_C (0x64972d68dee33360), UINT64_C (0xb9c11d5b1e43a07e),
UINT64_C (0x2de0966daf2f8b1c), UINT64_C (0x2e18bc1ad9704a68),
UINT64_C (0xd4dba84729af48ad), UINT64_C (0xb7a0b174cff6f36e),
UINT64_C (0xe94c39a54a98307f), UINT64_C (0xaa70b5b4f89695a2),
UINT64_C (0x3bdbb92c43b17f26), UINT64_C (0xcccb7005c6b9c28d),
UINT64_C (0x18a6a990c8b35ebd), UINT64_C (0xfc7c95d827357afa),
UINT64_C (0x1fca8a92fd719f85), UINT64_C (0x1dd01aafcd53486a),
UINT64_C (0x49353fea39ba63b1), UINT64_C (0xf85b2b4fbcde44b7),
UINT64_C (0xbe7444e39328a0ac), UINT64_C (0x3e2b8bcbf016d66d),
UINT64_C (0x964e915cd5e2b207), UINT64_C (0x1725cabfcb045b00),
UINT64_C (0x7fbf21ec8a1f45ec), UINT64_C (0x11317ba87905e790),
UINT64_C (0x2fe4b17170e59750), UINT64_C (0xe8d9ecbe2cf3d73f),
UINT64_C (0xb57d2e985e1419c7), UINT64_C (0x0572b974f03ce0bb),
UINT64_C (0xa8d7e4dab780a08d), UINT64_C (0x4715ed43e8a45c0a),
UINT64_C (0xc330de426430f69d), UINT64_C (0x23b70edb1955c4bf),
UINT64_C (0x098954d51fff6580), UINT64_C (0x8107fccf064fcf56),
UINT64_C (0x852f54934da55cc9), UINT64_C (0x09c7e552bc76492f),
UINT64_C (0xe9f6760e32cd8021), UINT64_C (0xa3bc941d0a5061cb),
UINT64_C (0xba89142e007503b8), UINT64_C (0xdc842b7e2819e230),
UINT64_C (0xbbe83f4ecc2bdecb), UINT64_C (0xcd454f8f19c5126a),
UINT64_C (0xc62c58f97dd949bf), UINT64_C (0x693501d628297551),
UINT64_C (0xb9ab4ce57f2d34f3), UINT64_C (0x9255abb50d532280),
UINT64_C (0xebfafa33d7254b59), UINT64_C (0xe9f6082b05542e4e),
UINT64_C (0x35dd37d5871448af), UINT64_C (0xb03031a8b4516e84),
UINT64_C (0xb3f256d8aca0b0b9), UINT64_C (0x0fd22063edc29fca),
UINT64_C (0xd9a11fbb3d9808e4), UINT64_C (0x3a9bf55ba91f81ca),
UINT64_C (0xc8c93882f9475f5f), UINT64_C (0x947ae053ee56e63c),
UINT64_C (0xc7d9f16864a76e94), UINT64_C (0x7bd94e1d8e17debc),
UINT64_C (0xd873db391292ed4f), UINT64_C (0x30f5611484119414),
UINT64_C (0x565c31f7de89ea27), UINT64_C (0xd0e4366228b03343),
UINT64_C (0x325928ee6e6f8794), UINT64_C (0x6f423357e7c6a9f9),
UINT64_C (0x99170a5dc3115544), UINT64_C (0x59b97885e2f2ea28),
UINT64_C (0xbc4097b116c524d2), UINT64_C (0x7a13f18bbedc4ff5),
UINT64_C (0x071582401c38434d), UINT64_C (0xb422061193d6f6a7),
UINT64_C (0xb4b81b3fa97511e2), UINT64_C (0x65d34954daf3cebd),
UINT64_C (0xb344c470397bba52), UINT64_C (0xbac7a9a18531294b),
UINT64_C (0xecb53939887e8175), UINT64_C (0x565601c0364e3228),
UINT64_C (0xef1955914b609f93), UINT64_C (0x16f50edf91e513af),
UINT64_C (0x56963b0dca418fc0), UINT64_C (0xd60f6dcedc314222),
UINT64_C (0x364f6ffa464ee52e), UINT64_C (0x6c3b8e3e336139d3),
UINT64_C (0xf943aee7febf21b8), UINT64_C (0x088e049589c432e0),
UINT64_C (0xd49503536abca345), UINT64_C (0x3a6c27934e31188a),
UINT64_C (0x957baf61700cff4e), UINT64_C (0x37624ae5a48fa6e9),
UINT64_C (0x501f65edb3034d07), UINT64_C (0x907f30421d78c5de),
UINT64_C (0x1a804aadb9cfa741), UINT64_C (0x0ce2a38c344a6eed),
UINT64_C (0xd363eff5f0977996), UINT64_C (0x2cd16e2abd791e33),
UINT64_C (0x58627e1a149bba21), UINT64_C (0x7f9b6af1ebf78baf)
},
{
UINT64_C (0xd20d8c88c8ffe65f), UINT64_C (0x917f1dd5f8886c61),
UINT64_C (0x56986e2ef3ed091b), UINT64_C (0x5fa7867caf35e149),
UINT64_C (0x81a1549fd6573da5), UINT64_C (0x96fbf83a12884624),
UINT64_C (0xe728e8c83c334074), UINT64_C (0xf1bcc3d275afe51a),
UINT64_C (0x71f1ce2490d20b07), UINT64_C (0xe6c42178c4bbb92e),
UINT64_C (0x0a9c32d5eae45305), UINT64_C (0x0c335248857fa9e7),
UINT64_C (0x142de49fff7a7c3d), UINT64_C (0x64a53dc924fe7ac9),
UINT64_C (0x9f6a419d382595f4), UINT64_C (0x150f361dab9dec26),
UINT64_C (0xc61bb3a141e50e8c), UINT64_C (0x2785338347f2ba08),
UINT64_C (0x7ca9723fbb2e8988), UINT64_C (0xce2f8642ca0712dc),
UINT64_C (0x59300222b4561e00), UINT64_C (0xc2b5a03f71471a6f),
UINT64_C (0xd5f9e858292504d5), UINT64_C (0x65fa4f227a2b6d79),
UINT64_C (0x93cbe0b699c2585d), UINT64_C (0x1d95b0a5fcf90bc6),
UINT64_C (0x17efee45b0dee640), UINT64_C (0x9e4c1269baa4bf37),
UINT64_C (0xd79476a84ee20d06), UINT64_C (0x0a56a5f0bfe39272),
UINT64_C (0x7eba726d8c94094b), UINT64_C (0x5e5637885f29bc2b),
UINT64_C (0xd586bd01c5c217f6), UINT64_C (0x233003b5a6cfe6ad),
UINT64_C (0x24c0e332b70019b0), UINT64_C (0x9da058c67844f20c),
UINT64_C (0xe4d9429322cd065a), UINT64_C (0x1fab64ea29a2ddf7),
UINT64_C (0x8af38731c02ba980), UINT64_C (0x7dc7785b8efdfc80),
UINT64_C (0x486289ddcc3d6780), UINT64_C (0x222bbfae61725606),
UINT64_C (0x2bc60a63a6f3b3f2), UINT64_C (0x177e00f9fc32f791),
UINT64_C (0x522e23f3925e319e), UINT64_C (0x9c2ed44081ce5fbd),
UINT64_C (0x964781ce734b3c84), UINT64_C (0xf05d129681949a4c),
UINT64_C (0x046e3ecaaf453ce9), UINT64_C (0x962aceefa82e1c84),
UINT64_C (0xf5b4b0b0d2deeeb4), UINT64_C (0x1af3dbe25d8f45da),
UINT64_C (0xf9f4892ed96bd438), UINT64_C (0xc4c118bfe78feaae),
UINT64_C (0x07a69afdcc42261a), UINT64_C (0xf8549e1a3aa5e00d),
UINT64_C (0x2102ae466ebb1148), UINT64_C (0xe87fbb46217a360e),
UINT64_C (0x310cb380db6f7503), UINT64_C (0xb5fdfc5d3132c498),
UINT64_C (0xdaf8e9829fe96b5f), UINT64_C (0xcac09afbddd2cdb4),
UINT64_C (0xb862225b055b6960), UINT64_C (0x55b6344cf97aafae),
UINT64_C (0xff577222c14f0a3a), UINT64_C (0x4e4b705b92903ba4),
UINT64_C (0x730499af921549ff), UINT64_C (0x13ae978d09fe5557),
UINT64_C (0xd9e92aa246bf719e), UINT64_C (0x7a4c10ec2158c4a6),
UINT64_C (0x49cad48cebf4a71e), UINT64_C (0xcf05daf5ac8d77b0),
UINT64_C (0xabbdcdd7ed5c0860), UINT64_C (0x9853eab63b5e0b35),
UINT64_C (0x352787baa0d7c22f), UINT64_C (0xc7f6aa2de59aea61),
UINT64_C (0x03727073c2e134b1), UINT64_C (0x5a0f544dd2b1fb18),
UINT64_C (0x74f85198b05a2e7d), UINT64_C (0x963ef2c96b33be31),
UINT64_C (0x4659d2b743848a2c), UINT64_C (0x19ebb029435dcb0f),
UINT64_C (0x4e9d2827355fc492), UINT64_C (0xccec0a73b49c9921),
UINT64_C (0x46c9feb55d120902), UINT64_C (0x8d2636b81555a786),
UINT64_C (0x30c05b1ba332f41c), UINT64_C (0xf6f7fd1431714200),
UINT64_C (0x1a4ff12616eefc89), UINT64_C (0x990a98fd5071d263),
UINT64_C (0x84547ddc3e203c94), UINT64_C (0x07a3aec79624c7da),
UINT64_C (0x8a328a1cedfe552c), UINT64_C (0xd1e649de1e7f268b),
UINT64_C (0x2d8d5432157064c8), UINT64_C (0x4ae7d6a36eb5dbcb),
UINT64_C (0x57e3306d881edb4f), UINT64_C (0x0a804d18b7097475),
UINT64_C (0xe74733427b72f0c1), UINT64_C (0x24b33c9d7ed25117),
UINT64_C (0xe805a1e290cf2456), UINT64_C (0x3b544ebe544c19f9),
UINT64_C (0x3e666e6f69ae2c15), UINT64_C (0xfb152fe3ff26da89),
UINT64_C (0xb49b52e587a1ee60), UINT64_C (0xac042e70f8b383f2),
UINT64_C (0x89c350c893ae7dc1), UINT64_C (0xb592bf39b0364963),
UINT64_C (0x190e714fada5156e), UINT64_C (0xec8177f83f900978),
UINT64_C (0x91b534f885818a06), UINT64_C (0x81536d601170fc20),
UINT64_C (0xd4c718bc4ae8ae5f), UINT64_C (0x9eedeca8e272b933),
UINT64_C (0x10e8b35af3eeab37), UINT64_C (0x0e09b88e1914f7af),
UINT64_C (0x3fa9ddfb67e2f199), UINT64_C (0xb10bb459132d0a26),
UINT64_C (0x2c046f22062dc67d), UINT64_C (0x5e90277e7cb39e2d),
UINT64_C (0xd6b04d3b7651dd7e), UINT64_C (0xe34a1d250e7a8d6b),
UINT64_C (0x53c065c6c8e63528), UINT64_C (0x1bdea12e35f6a8c9),
UINT64_C (0x21874b8b4d2dbc4f), UINT64_C (0x3a88a0fbbcb05c63),
UINT64_C (0x43ed7f5a0fae657d), UINT64_C (0x230e343dfba08d33),
UINT64_C (0xb5b4071dbfc73a66), UINT64_C (0x8f9887e6078735a1),
UINT64_C (0x08de8a1c7797da9b), UINT64_C (0xfcb6be43a9f2fe9b),
UINT64_C (0x049a7f41061a9e60), UINT64_C (0x9f91508bffcfc14a),
UINT64_C (0xe3273522064480ca), UINT64_C (0xcd04f3ff001a4778),
UINT64_C (0x6bfa9aae5ec05779), UINT64_C (0x371f77e76bb8417e),
UINT64_C (0x3550c2321fd6109c), UINT64_C (0xfb4a3d794a9a80d2),
UINT64_C (0xf43c732873f24c13), UINT64_C (0xaa9119ff184cccf4),
UINT64_C (0xb69e38a8965c6b65), UINT64_C (0x1f2b1d1f15f6dc9c),
UINT64_C (0x67fef95d92607890), UINT64_C (0x31865ced6120f37d),
UINT64_C (0x3a6853c7e70757a7), UINT64_C (0x32ab0edb696703d3),
UINT64_C (0xee97f453f06791ed), UINT64_C (0x6dc93d9526a50e68),
UINT64_C (0x78edefd694af1eed), UINT64_C (0x9c1169fa2777b874),
UINT64_C (0x50065e535a213cf6), UINT64_C (0xde0c89a556b9ae70),
UINT64_C (0xd1e0ccd25bb9c169), UINT64_C (0x6b17b224bad6bf27),
UINT64_C (0x6b02e63195ad0cf8), UINT64_C (0x455a4b4cfe30e3f5),
UINT64_C (0x9338e69c052b8e7b), UINT64_C (0x5092ef950a16da0b),
UINT64_C (0x7c45d833aff07862), UINT64_C (0xa5b1cfdba0ab4067),
UINT64_C (0x6ad047c430a12104), UINT64_C (0x6c47bec883a7de39),
UINT64_C (0x944f6de09134dfb6), UINT64_C (0x9aeba33ac6ecc6b0),
UINT64_C (0x52e762596bf68235), UINT64_C (0x22af003ab672e811),
UINT64_C (0xb5635c95ff7296e2), UINT64_C (0xed2df21216235097),
UINT64_C (0x4a29c6465a314cd1), UINT64_C (0xd83cc2687a19255f),
UINT64_C (0x506c11b9d90e8b1d), UINT64_C (0x57277707199b8175),
UINT64_C (0xcaf21ecd4377b28c), UINT64_C (0xc0c0f5a60ef4cdcf),
UINT64_C (0x93b633abfa3469f8), UINT64_C (0xe846963877671a17),
UINT64_C (0x59ac2c7873f910a3), UINT64_C (0x660d3257380841ee),
UINT64_C (0xd813f2fab7f5c5ca), UINT64_C (0x4112cf68649a260e),
UINT64_C (0x443f64ec5a371195), UINT64_C (0xb0774d261cc609db),
UINT64_C (0x720bf5f26f4d2eaa), UINT64_C (0x1c2559e30f0946be),
UINT64_C (0xe328e230e3e2b3fb), UINT64_C (0x087e79e5a57d1d13),
UINT64_C (0x08dd9bdfd96b9f63), UINT64_C (0x64d0e29eea8838b3),
UINT64_C (0xddf957bc36d8b9ca), UINT64_C (0x6ffe73e81b637fb3),
UINT64_C (0x1a4e4822eb4d7a59), UINT64_C (0x5d94337fbfaf7f5b),
UINT64_C (0xd30c088ba61ea5ef), UINT64_C (0x9d765e419fb69f6d),
UINT64_C (0x9e21f4f903b33fd9), UINT64_C (0xb4d8f77bc3e56167),
UINT64_C (0x733ea705fae4fa77), UINT64_C (0xa4ec0132764ca04b),
UINT64_C (0x7976033a39f7d952), UINT64_C (0x106f72fe81e2c590),
UINT64_C (0x8c90fd9b083f4558), UINT64_C (0xfd080d236da814ba),
UINT64_C (0x7b64978555326f9f), UINT64_C (0x60e8ed72c0dff5d1),
UINT64_C (0xb063e962e045f54d), UINT64_C (0x959f587d507a8359),
UINT64_C (0x758f450c88572e0b), UINT64_C (0x1b6baca2ae4e125b),
UINT64_C (0x61cf4f94c97df93d), UINT64_C (0x2738259634305c14),
UINT64_C (0xd39bb9c3a48db6cf), UINT64_C (0x8215e577001332c8),
UINT64_C (0xa1082c0466df6c0a), UINT64_C (0xef02cdd06ffdb432),
UINT64_C (0xfc87614baf287e07), UINT64_C (0x240ab57a8b888b20),
UINT64_C (0xbf8d5108e27e0d48), UINT64_C (0x61bdd1307c66e300),
UINT64_C (0xb925a6cd0421aff3), UINT64_C (0x3e003e616a6591e9),
UINT64_C (0x94c3251f06f90cf3), UINT64_C (0xbf84470805e69b5f),
UINT64_C (0x98f076a4f7a2322e), UINT64_C (0x70cb6af7c2d5bcf0),
UINT64_C (0xb64be8d8b25396c1), UINT64_C (0xa9aa4d20db084e9b),
UINT64_C (0x2e6d02c36017f67f), UINT64_C (0xefed53d75fd64e6b),
UINT64_C (0xd9f1f30ccd97fb09), UINT64_C (0xa2ebee47e2fbfce1),
UINT64_C (0xb8d91274b9e9d4fb), UINT64_C (0x1db956e450275779),
UINT64_C (0x4fc8e9560f91b123), UINT64_C (0x63573ff03e224774),
UINT64_C (0x0647dfedcd894a29), UINT64_C (0x7884d9bc6cb569d8),
UINT64_C (0x7fba195410e5ca30), UINT64_C (0x106c09b972d2e822),
UINT64_C (0x241260ed4ad1e87d), UINT64_C (0x64c8e531bff53b55),
UINT64_C (0xca672b91e9e4fa16), UINT64_C (0x3871700761b3f743),
UINT64_C (0xf95cffa23af5f6f4), UINT64_C (0x8d14dedb30be846e),
UINT64_C (0x3b097adaf088f94e), UINT64_C (0x21e0bd5026c619bf),
UINT64_C (0x1bda0492e7e4586e), UINT64_C (0xd23c8e176d113600),
UINT64_C (0x252f59cf0d9f04bb), UINT64_C (0xb3598080ce64a656),
UINT64_C (0x993e1de72d36d310), UINT64_C (0xa2853b80f17f58ee),
UINT64_C (0x1877b51e57a764d5), UINT64_C (0x001f837cc7350524)
}
#endif
};
int
main (int argc, char **argv)
{
unsigned int i;
isaac_word r[ISAAC_WORDS];
int iterations;
/* Seed with zeros, and discard the first buffer of output,
as that's what the standard programs do. */
static struct isaac_state s;
isaac_seed (&s);
isaac_refill (&s, r);
for (i = 0; i < sizeof expected / sizeof expected[0]; i++)
{
isaac_refill (&s, r);
ASSERT (memcmp (r, expected[i], sizeof r) == 0);
}
/* If invoked with a positive argument, run a benchmark;
if with a negative, run a do-nothing benchmark. */
for (iterations = argc <= 1 ? 0 : strtol (argv[1], NULL, 10);
iterations != 0;
iterations += (iterations < 0 ? 1 : -1))
if (0 <= iterations)
isaac_refill (&s, r);
return 0;
}

2
gnulib

Submodule gnulib updated: 7521ea075f...78c0415acc

View File

@@ -1,3 +1,17 @@
include gnulib.mk
AM_CFLAGS = $(GNULIB_WARN_CFLAGS) # $(WERROR_CFLAGS)
AM_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS) # $(WERROR_CFLAGS)
# A few tests are inherently warning-evoking.
# Since we require -Werror, exempt the few offenders.
# test-xvasprintf.c: In function 'test_xasprintf':
# test-xvasprintf.c:100: error: format not a string literal and no \
# format arguments [-Wformat-security]
test_xvasprintf_CFLAGS = $(AM_CFLAGS) -Wno-format-security
# test-lock.c: In function 'lock_mutator_thread':
# test-lock.c:148: error: cast from function call of type 'pthread_t' to \
# non-matching type 'void *' [-Wbad-function-cast]
test_lock_CFLAGS = $(AM_CFLAGS) -Wno-bad-function-cast
test_tls_CFLAGS = $(AM_CFLAGS) -Wno-bad-function-cast

View File

@@ -20,8 +20,7 @@ include gnulib.mk
AM_CFLAGS += $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
libcoreutils_a_SOURCES += \
buffer-lcm.c buffer-lcm.h \
xmemxfrm.c xmemxfrm.h
buffer-lcm.c buffer-lcm.h
libcoreutils_a_LIBADD += $(LIBOBJS)
libcoreutils_a_DEPENDENCIES += $(LIBOBJS)

View File

@@ -1,105 +0,0 @@
/* Locale-specific memory transformation
Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Paul Eggert <eggert@cs.ucla.edu>. */
#include <config.h>
#include "memxfrm.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
/* Store into DEST (of size DESTSIZE) the text in SRC (of size SRCSIZE)
transformed so that the result of memcmp on two transformed texts
(with ties going to the longer text) is the same as the result of
memcoll on the two texts before their transformation. Perhaps
temporarily modify the byte after SRC, but restore its original
contents before returning.
Return the size of the resulting text, or an indeterminate value if
there is an error. Set errno to an error number if there is an
error, and to zero otherwise. DEST contains an indeterminate value
if there is an error or if the resulting size is greater than
DESTSIZE. */
size_t
memxfrm (char *restrict dest, size_t destsize,
char *restrict src, size_t srcsize)
{
#if HAVE_STRXFRM
size_t di = 0;
size_t si = 0;
size_t result = 0;
char ch = src[srcsize];
src[srcsize] = '\0';
while (si < srcsize)
{
size_t slen = strlen (src + si);
size_t result0 = result;
errno = 0;
result += strxfrm (dest + di, src + si, destsize - di) + 1;
if (errno != 0)
break;
if (result <= result0)
{
errno = ERANGE;
break;
}
if (result == destsize + 1 && si + slen == srcsize)
{
/* The destination is exactly the right size, but strxfrm wants
room for a trailing null. Work around the problem with a
temporary buffer. */
size_t bufsize = destsize - di + 1;
char stackbuf[4000];
char *buf = stackbuf;
if (sizeof stackbuf < bufsize)
{
buf = malloc (bufsize);
if (! buf)
break;
}
strxfrm (buf, src + si, bufsize);
memcpy (dest + di, buf, destsize - di);
if (sizeof stackbuf < bufsize)
free (buf);
errno = 0;
}
di = (result < destsize ? result : destsize);
si += slen + 1;
}
src[srcsize] = ch;
return result - (si != srcsize);
#else
if (srcsize < destsize)
memcpy (dest, src, srcsize);
errno = 0;
return srcsize;
#endif
}

View File

@@ -1,2 +0,0 @@
#include <stddef.h>
size_t memxfrm (char *restrict, size_t, char *restrict, size_t);

View File

@@ -1,62 +0,0 @@
/* Locale-specific memory transformation
Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Paul Eggert <eggert@cs.ucla.edu>. */
#include <config.h>
#include "xmemxfrm.h"
#include <errno.h>
#include <stdlib.h>
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "error.h"
#include "exitfail.h"
#include "memxfrm.h"
#include "quotearg.h"
/* Store into DEST (of size DESTSIZE) the text in SRC (of size
SRCSIZE) transformed so that the result of memcmp on two
transformed texts (with ties going to the longer text) is the same
as the result of memcoll on the two texts before their
transformation. Perhaps temporarily modify the byte after SRC, but
restore its original contents before returning.
Return the size of the resulting text. DEST contains an
indeterminate value if the resulting size is greater than DESTSIZE.
Report an error and exit if there is an error. */
size_t
xmemxfrm (char *restrict dest, size_t destsize,
char *restrict src, size_t srcsize)
{
size_t translated_size = memxfrm (dest, destsize, src, srcsize);
if (errno)
{
error (0, errno, _("string transformation failed"));
error (0, 0, _("set LC_ALL='C' to work around the problem"));
error (exit_failure, 0,
_("the untransformed string was %s"),
quotearg_n_style_mem (0, locale_quoting_style, src, srcsize));
}
return translated_size;
}

View File

@@ -1,2 +0,0 @@
#include <stddef.h>
size_t xmemxfrm (char *restrict, size_t, char *restrict, size_t);

View File

@@ -1,4 +1,4 @@
#serial 109 -*- autoconf -*-
#serial 110 -*- autoconf -*-
dnl Misc type-related macros for coreutils.
@@ -35,8 +35,8 @@ AC_DEFUN([coreutils_MACROS],
AC_REQUIRE([AC_FUNC_FSEEKO])
# By default, argmatch should fail calling usage (1).
AC_DEFINE([ARGMATCH_DIE], [usage (1)],
# By default, argmatch should fail calling usage (EXIT_FAILURE).
AC_DEFINE([ARGMATCH_DIE], [usage (EXIT_FAILURE)],
[Define to the function xargmatch calls on failures.])
AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
[Define to the declaration of the xargmatch failure function.])
@@ -144,6 +144,25 @@ AC_DEFUN([coreutils_MACROS],
])
AC_REQUIRE([AM_LANGINFO_CODESET])
# Accept configure options: --with-tty-group[=GROUP], --without-tty-group
# You can determine the group of a TTY via 'stat --format %G /dev/tty'
# Omitting this option is equivalent to using --without-tty-group.
AC_ARG_WITH([tty-group],
AS_HELP_STRING([--with-tty-group[[[=NAME]]]],
[group used by system for TTYs, "tty" when not specified]
[ (default: do not rely on any group used for TTYs)]),
[tty_group_name=$withval],
[tty_group_name=no])
if test "x$tty_group_name" != xno; then
if test "x$tty_group_name" = xyes; then
tty_group_name=tty
fi
AC_MSG_NOTICE([TTY group used by system set to "$tty_group_name"])
AC_DEFINE_UNQUOTED([TTY_GROUP_NAME], ["$tty_group_name"],
[group used by system for TTYs])
fi
])
AC_DEFUN([gl_CHECK_ALL_HEADERS],
@@ -153,14 +172,10 @@ AC_DEFUN([gl_CHECK_ALL_HEADERS],
paths.h \
priv.h \
stropts.h \
sys/ioctl.h \
sys/param.h \
sys/resource.h \
sys/systeminfo.h \
sys/time.h \
sys/wait.h \
syslog.h \
termios.h \
)
AC_CHECK_HEADERS([sys/sysctl.h], [], [],
[AC_INCLUDES_DEFAULT
@@ -172,11 +187,6 @@ AC_DEFUN([gl_CHECK_ALL_HEADERS],
# This macro must be invoked before any tests that run the compiler.
AC_DEFUN([gl_CHECK_ALL_TYPES],
[
dnl This test must come as early as possible after the compiler configuration
dnl tests, because the choice of the file model can (in principle) affect
dnl whether functions and headers are available, whether they work, etc.
AC_REQUIRE([AC_SYS_LARGEFILE])
dnl This test must precede tests of compiler characteristics like
dnl that for the inline keyword, since it may change the degree to
dnl which the compiler supports such features.

View File

@@ -1,15 +0,0 @@
dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_MEMXFRM],
[
AC_LIBSOURCES([memxfrm.c, memxfrm.h])
AC_LIBOBJ([memxfrm])
AC_REQUIRE([AC_C_RESTRICT])
dnl Prerequisites of lib/memcoll.c.
AC_CHECK_FUNCS_ONCE([strxfrm])
])

View File

@@ -1,4 +1,4 @@
#serial 76
#serial 77
dnl We use gl_ for non Autoconf macros.
m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
@@ -40,7 +40,6 @@ AC_DEFUN([gl_PREREQ],
AC_REQUIRE([gl_FD_REOPEN])
AC_REQUIRE([gl_FUNC_XATTR])
AC_REQUIRE([gl_FUNC_XFTS])
AC_REQUIRE([gl_MEMXFRM])
AC_REQUIRE([gl_STRINTCMP])
AC_REQUIRE([gl_STRNUMCMP])
])

View File

@@ -1,4 +1,5 @@
# xattr.m4 - check for Extended Attributes (Linux)
# serial 3
# Copyright (C) 2003, 2008-2010 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -33,11 +34,11 @@ AC_DEFUN([gl_FUNC_XATTR],
use_xattr=yes
fi
fi
AC_DEFINE_UNQUOTED([USE_XATTR], [$use_xattr],
[Define if you want extended attribute support.])
if test $use_xattr = no; then
AC_MSG_WARN([libattr development library was not found or not usable.])
AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
fi
fi
AC_DEFINE_UNQUOTED([USE_XATTR], [`test $use_xattr != yes; echo $?`],
[Define if you want extended attribute support.])
])

View File

@@ -173,7 +173,15 @@ mapped_name = `echo $*|sed 's/^install$$/ginstall/; s/^test$$/[/'`
;; \
esac
distcheck-hook: check-x-vs-1 check-programs-vs-x
# Option descriptions should not start with a capital letter
.PHONY: sc_option_desc_uppercase
sc_option_desc_uppercase: $(dist_man1_MANS) $(NO_INSTALL_PROGS_DEFAULT:%=%.1)
@grep '^\\fB\\-' -A1 *.1 | LC_ALL=C grep '\.1.[A-Z][a-z]' && \
{ echo 1>&2 '$(ME): found initial capitals in --help'; \
exit 1; } || :;
.PHONY: sc_man_file_correlation
sc_man_file_correlation: check-x-vs-1 check-programs-vs-x
# Sort in traditional ASCII order, regardless of the current locale;
# otherwise we may get into trouble with distinct strings that the
@@ -186,7 +194,7 @@ ASSORT = LC_ALL=C sort
# add them here manually.
.PHONY: check-x-vs-1
check-x-vs-1:
$(AM_V_GEN)PATH=../src$(PATH_SEPARATOR)$$PATH; export PATH; \
@PATH=../src$(PATH_SEPARATOR)$$PATH; export PATH; \
t=$@-t; \
(cd $(srcdir) && ls -1 *.x) | sed 's/\.x$$//' | $(ASSORT) > $$t;\
(echo $(dist_man1_MANS) $(NO_INSTALL_PROGS_DEFAULT) \
@@ -200,7 +208,7 @@ all_programs = \
.PHONY: check-programs-vs-x
check-programs-vs-x:
$(AM_V_GEN)status=0; \
@status=0; \
for p in dummy `$(all_programs)`; do \
test $$p = dummy && continue; \
test $$p = ginstall && p=install || : ; \

View File

@@ -1,5 +1,5 @@
[NAME]
dirname \- strip non-directory suffix from file name
dirname \- strip last component from file name
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]

View File

@@ -2,3 +2,7 @@
md5sum \- compute and check MD5 message digest
[DESCRIPTION]
.\" Add any additional description here
[BUGS]
The MD5 algorithm should not be used any more for security related purposes.
Instead, better use an SHA\-2 algorithm, implemented in the programs
sha224sum(1), sha256sum(1), sha384sum(1), sha512sum(1)

View File

@@ -2,3 +2,5 @@
tac \- concatenate and print files in reverse
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
\fBrev\fP(1).

View File

@@ -29,7 +29,6 @@ lib/version-etc.c
lib/xalloc-die.c
lib/xfreopen.c
lib/xmemcoll.c
lib/xmemxfrm.c
lib/xprintf.c
lib/xstrtol-error.c
@@ -62,6 +61,7 @@ src/expand.c
src/expr.c
src/factor.c
src/false.c
src/find-mount-point.c
src/fmt.c
src/fold.c
src/getlimits.c

View File

@@ -145,6 +145,7 @@ noinst_HEADERS = \
copy.h \
cp-hash.h \
dircolors.h \
find-mount-point.h \
fs.h \
group-list.h \
ls.h \
@@ -170,6 +171,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/lib
noinst_LIBRARIES = libver.a
nodist_libver_a_SOURCES = version.c version.h
# Tell the linker to omit references to unused shared libraries.
AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
# Sometimes, the expansion of $(LIBINTL) includes -lc which may
# include modules defining variables like `optind', so libcoreutils.a
# must precede $(LIBINTL) in order to ensure we use GNU getopt.
@@ -325,13 +329,8 @@ ls_LDADD += $(LIB_CLOCK_GETTIME)
pr_LDADD += $(LIB_CLOCK_GETTIME)
touch_LDADD += $(LIB_CLOCK_GETTIME)
# for gethrxtime, randint, randread, gen_tempname, mkstemp
# for gethrxtime
dd_LDADD += $(LIB_GETHRXTIME)
mktemp_LDADD += $(LIB_GETHRXTIME)
shred_LDADD += $(LIB_GETHRXTIME)
shuf_LDADD += $(LIB_GETHRXTIME)
sort_LDADD += $(LIB_GETHRXTIME)
tac_LDADD += $(LIB_GETHRXTIME)
# for cap_get_file
ls_LDADD += $(LIB_CAP)
@@ -340,14 +339,6 @@ ls_LDADD += $(LIB_CAP)
dd_LDADD += $(LIB_FDATASYNC)
shred_LDADD += $(LIB_FDATASYNC)
# for strtod, strtold
printf_LDADD += $(POW_LIB)
seq_LDADD += $(POW_LIB)
sleep_LDADD += $(POW_LIB)
sort_LDADD += $(POW_LIB)
tail_LDADD += $(POW_LIB)
uptime_LDADD += $(POW_LIB)
# for xnanosleep
sleep_LDADD += $(LIB_NANOSLEEP)
sort_LDADD += $(LIB_NANOSLEEP)
@@ -391,6 +382,12 @@ who_LDADD += $(GETADDRINFO_LIB)
hostname_LDADD += $(GETHOSTNAME_LIB)
uname_LDADD += $(GETHOSTNAME_LIB)
# for strsignal
kill_LDADD += $(LIBTHREAD)
# for pthread
sort_LDADD += $(LIB_PTHREAD)
$(PROGRAMS): ../lib/libcoreutils.a
# Get the release year from ../lib/version-etc.c.
@@ -482,6 +479,9 @@ rm_SOURCES = rm.c remove.c
mkdir_SOURCES = mkdir.c prog-fprintf.c
rmdir_SOURCES = rmdir.c prog-fprintf.c
df_SOURCES = df.c find-mount-point.c
stat_SOURCES = stat.c find-mount-point.c
uname_SOURCES = uname.c uname-uname.c
arch_SOURCES = uname.c uname-arch.c
nproc_SOURCES = nproc.c
@@ -551,7 +551,7 @@ fs-magic-compare: fs-magic fs-kernel-magic fs-def
CLEANFILES += fs-def
fs-def: fs.h
grep '^# *define ' $< > $@-t && mv $@-t $@
grep '^# *define ' $< | $(ASSORT) > $@-t && mv $@-t $@
# Massage bits of the statfs man page and definitions from
# /usr/include/linux/magic.h to be in a form consistent with what's in fs.h.
@@ -635,6 +635,7 @@ built_programs.list:
all_programs.list:
@echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
| sed /libstdbuf/d \
| $(ASSORT) -u
# This is required because we have broken inter-directory dependencies:
@@ -642,6 +643,11 @@ all_programs.list:
# install a binary, require that all programs be built at distribution time.
dist-hook: $(all_programs)
# Ensure that all programs are built so we can for example
# subsequently syntax check all man pages.
.PHONY: all_programs
all_programs: $(all_programs)
pm = progs-makefile
pr = progs-readme
# Ensure that the list of programs in README matches the list
@@ -672,8 +678,8 @@ au_dotdot = authors-dotdot
au_actual = authors-actual
.PHONY: sc_check-AUTHORS
sc_check-AUTHORS: $(all_programs)
$(AM_V_GEN)locale=en_US.UTF-8; \
LC_ALL="$$locale" ./cat --version \
@locale=en_US.UTF-8; \
LC_ALL=$$locale ./cat --version \
| grep ' Torbjorn ' > /dev/null \
&& { echo "$@: skipping this check"; exit 0; }; \
rm -f $(au_actual) $(au_dotdot); \
@@ -687,7 +693,7 @@ sc_check-AUTHORS: $(all_programs)
elif test "$$i" = test; then \
exe='['; \
fi; \
LC_ALL="$$locale" ./$$exe --version \
LC_ALL=$$locale ./$$exe --version \
| perl -0 -pi -e 's/,\n/, /gm' \
| sed -n -e '/Written by /{ s//'"$$i"': /;' \
-e 's/,* and /, /; s/\.$$//; p; }'; \
@@ -708,8 +714,11 @@ sc_check-AUTHORS: $(all_programs)
# The second nm|grep checks for file-scope variables with `extern' scope.
.PHONY: sc_tight_scope
sc_tight_scope: $(bin_PROGRAMS)
$(AM_V_GEN)t=exceptions-$$$$; \
trap "s=$$?; rm -f $$t; exit $$s" 0 1 2 13 15; \
@t=exceptions-$$$$; \
trap 's=$$?; rm -f $$t; exit $$s' 0; \
am__exit='(exit $s); exit $s'; \
trap "s=129; $$am__exit" 1; trap "s=130; $$am__exit" 2; \
trap "s=141; $$am__exit" 13; trap "s=143; $$am__exit" 15; \
src=`for f in $(SOURCES); do \
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
hdr=`for f in $(noinst_HEADERS); do \

View File

@@ -26,9 +26,11 @@
#include "system.h"
#include "error.h"
#include "fadvise.h"
#include "xstrtol.h"
#include "quote.h"
#include "quotearg.h"
#include "xfreopen.h"
#include "base64.h"
@@ -61,11 +63,10 @@ Usage: %s [OPTION]... [FILE]\n\
Base64 encode or decode FILE, or standard input, to standard output.\n\
\n"), program_name);
fputs (_("\
-w, --wrap=COLS Wrap encoded lines after COLS character (default 76).\n\
Use 0 to disable line wrapping.\n\
\n\
-d, --decode Decode data.\n\
-i, --ignore-garbage When decoding, ignore non-alphabet characters.\n\
-d, --decode decode data\n\
-i, --ignore-garbage when decoding, ignore non-alphabet characters\n\
-w, --wrap=COLS wrap encoded lines after COLS character (default 76).\n\
Use 0 to disable line wrapping\n\
\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
@@ -269,9 +270,9 @@ main (int argc, char **argv)
ignore_garbage = true;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
usage (EXIT_FAILURE);
@@ -290,14 +291,20 @@ main (int argc, char **argv)
infile = "-";
if (STREQ (infile, "-"))
input_fh = stdin;
{
if (O_BINARY)
xfreopen (NULL, "rb", stdin);
input_fh = stdin;
}
else
{
input_fh = fopen (infile, "r");
input_fh = fopen (infile, "rb");
if (input_fh == NULL)
error (EXIT_FAILURE, errno, "%s", infile);
}
fadvise (input_fh, FADVISE_SEQUENTIAL);
if (decode)
do_decode (input_fh, stdout, ignore_garbage);
else

View File

@@ -30,12 +30,11 @@
#if HAVE_STROPTS_H
# include <stropts.h>
#endif
#if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#include <sys/ioctl.h>
#include "system.h"
#include "error.h"
#include "fadvise.h"
#include "full-write.h"
#include "quote.h"
#include "safe-read.h"
@@ -94,7 +93,7 @@ Usage: %s [OPTION]... [FILE]...\n\
Concatenate FILE(s), or standard input, to standard output.\n\
\n\
-A, --show-all equivalent to -vET\n\
-b, --number-nonblank number nonempty output lines\n\
-b, --number-nonblank number nonempty output lines, overrides -n\n\
-e equivalent to -vE\n\
-E, --show-ends display $ at end of each line\n\
-n, --number number all output lines\n\
@@ -162,7 +161,7 @@ simple_cat (
/* Loop until the end of the file. */
for (;;)
while (true)
{
/* Read a block of input. */
@@ -271,7 +270,7 @@ cat (
bpout = outbuf;
for (;;)
while (true)
{
do
{
@@ -426,7 +425,7 @@ cat (
scan for chars that need conversion. */
if (show_nonprinting)
{
for (;;)
while (true)
{
if (ch >= 32)
{
@@ -477,7 +476,7 @@ cat (
else
{
/* Not quoting, neither of -v, -e, or -t specified. */
for (;;)
while (true)
{
if (ch == '\t' && show_tabs)
{
@@ -702,6 +701,8 @@ main (int argc, char **argv)
}
insize = io_blksize (stat_buf);
fdadvise (input_desc, 0, 0, FADVISE_SEQUENTIAL);
/* Compare the device and i-node numbers of this input file with
the corresponding values of the (output file associated with)
stdout, and skip this input file if they coincide. Input

View File

@@ -257,7 +257,7 @@ process_file (FTS *fts, FTSENT *ent)
break;
case FTS_ERR:
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
error (0, ent->fts_errno, "%s", quote (file_full_name));
ok = false;
break;

View File

@@ -180,8 +180,8 @@ process_file (FTS *fts, FTSENT *ent)
char const *file_full_name = ent->fts_path;
char const *file = ent->fts_accpath;
const struct stat *file_stats = ent->fts_statp;
mode_t old_mode IF_LINT (= 0);
mode_t new_mode IF_LINT (= 0);
mode_t old_mode IF_LINT ( = 0);
mode_t new_mode IF_LINT ( = 0);
bool ok = true;
bool chmod_succeeded = false;
@@ -212,7 +212,7 @@ process_file (FTS *fts, FTSENT *ent)
case FTS_ERR:
if (! force_silent)
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
error (0, ent->fts_errno, "%s", quote (file_full_name));
ok = false;
break;

View File

@@ -305,7 +305,7 @@ change_file_owner (FTS *fts, FTSENT *ent,
case FTS_ERR:
if (! chopt->force_silent)
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
error (0, ent->fts_errno, "%s", quote (file_full_name));
ok = false;
break;

View File

@@ -100,7 +100,7 @@ With --reference, change the owner and group of each FILE to those of RFILE.\n\
change the owner and/or group of each file only if\n\
its current owner and/or group match those specified\n\
here. Either may be omitted, in which case a match\n\
is not required for the omitted attribute.\n\
is not required for the omitted attribute\n\
"), stdout);
fputs (_("\
--no-preserve-root do not treat `/' specially (the default)\n\

View File

@@ -24,7 +24,6 @@
#include "system.h"
#include "error.h"
#include "long-options.h"
#include "quote.h"
#include "userspec.h"
#include "xstrtol.h"
@@ -162,9 +161,6 @@ main (int argc, char **argv)
initialize_exit_failure (EXIT_CANCELED);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
usage, AUTHORS, (char const *) NULL);
while ((c = getopt_long (argc, argv, "+", long_opts, NULL)) != -1)
{
switch (c)
@@ -172,9 +168,15 @@ main (int argc, char **argv)
case USERSPEC:
userspec = optarg;
break;
case GROUPS:
groups = optarg;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
usage (EXIT_CANCELED);
}

View File

@@ -43,6 +43,7 @@
#include <sys/types.h>
#include <stdint.h>
#include "system.h"
#include "fadvise.h"
#include "xfreopen.h"
#ifdef CRCTAB
@@ -205,6 +206,8 @@ cksum (const char *file, bool print_name)
}
}
fadvise (fp, FADVISE_SEQUENTIAL);
while ((bytes_read = fread (buf, 1, BUFLEN, fp)) > 0)
{
unsigned char *cp = buf;

View File

@@ -24,6 +24,7 @@
#include "system.h"
#include "linebuffer.h"
#include "error.h"
#include "fadvise.h"
#include "hard-locale.h"
#include "quote.h"
#include "stdio--.h"
@@ -139,7 +140,7 @@ Note, comparisons honor the rules specified by `LC_COLLATE'.\n\
\n\
Examples:\n\
%s -12 file1 file2 Print only lines present in both file1 and file2.\n\
%s -3 file1 file2 Print lines in file1 not in file2, and vice versa.\n\
%s -3 file1 file2 Print lines in file1 not in file2, and vice versa.\n\
"),
program_name, program_name);
emit_ancillary_info ();
@@ -273,6 +274,8 @@ compare_files (char **infiles)
if (!streams[i])
error (EXIT_FAILURE, errno, "%s", infiles[i]);
fadvise (streams[i], FADVISE_SEQUENTIAL);
thisline[i] = readlinebuffer (all_line[i][alt[i][0]], streams[i]);
if (ferror (streams[i]))
error (EXIT_FAILURE, errno, "%s", infiles[i]);

View File

@@ -61,9 +61,7 @@
# include "verror.h"
#endif
#if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#include <sys/ioctl.h>
#ifndef HAVE_FCHOWN
# define HAVE_FCHOWN false
@@ -179,11 +177,11 @@ static void
copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED,
char const *fmt, ...)
{
int err = errno;
va_list ap;
if (!errno_unsupported (errno))
{
int err = errno;
va_list ap;
/* use verror module to print error message */
va_start (ap, fmt);
verror (0, err, fmt, ap);
@@ -216,51 +214,39 @@ copy_attr_free (struct error_context *ctx ATTRIBUTE_UNUSED,
{
}
static bool
copy_attr_by_fd (char const *src_path, int src_fd,
char const *dst_path, int dst_fd, const struct cp_options *x)
{
struct error_context ctx =
{
.error = x->require_preserve_xattr ? copy_attr_allerror : copy_attr_error,
.quote = copy_attr_quote,
.quote_free = copy_attr_free
};
return 0 == attr_copy_fd (src_path, src_fd, dst_path, dst_fd, 0,
(x->reduce_diagnostics
&& !x->require_preserve_xattr)? NULL : &ctx);
}
/* If positive SRC_FD and DST_FD descriptors are passed,
then copy by fd, otherwise copy by name. */
static bool
copy_attr_by_name (char const *src_path, char const *dst_path,
const struct cp_options *x)
copy_attr (char const *src_path, int src_fd,
char const *dst_path, int dst_fd, struct cp_options const *x)
{
int ret;
bool all_errors = (!x->data_copy_required || x->require_preserve_xattr);
bool some_errors = (!all_errors && !x->reduce_diagnostics);
struct error_context ctx =
{
.error = x->require_preserve_xattr ? copy_attr_allerror : copy_attr_error,
.error = all_errors ? copy_attr_allerror : copy_attr_error,
.quote = copy_attr_quote,
.quote_free = copy_attr_free
};
return 0 == attr_copy_file (src_path, dst_path, 0,
(x-> reduce_diagnostics
&& !x->require_preserve_xattr) ? NULL : &ctx);
if (0 <= src_fd && 0 <= dst_fd)
ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd, 0,
(all_errors || some_errors ? &ctx : NULL));
else
ret = attr_copy_file (src_path, dst_path, 0,
(all_errors || some_errors ? &ctx : NULL));
return ret == 0;
}
#else /* USE_XATTR */
static bool
copy_attr_by_fd (char const *src_path ATTRIBUTE_UNUSED,
int src_fd ATTRIBUTE_UNUSED,
char const *dst_path ATTRIBUTE_UNUSED,
int dst_fd ATTRIBUTE_UNUSED,
const struct cp_options *x ATTRIBUTE_UNUSED)
{
return true;
}
static bool
copy_attr_by_name (char const *src_path ATTRIBUTE_UNUSED,
char const *dst_path ATTRIBUTE_UNUSED,
const struct cp_options *x ATTRIBUTE_UNUSED)
copy_attr (char const *src_path ATTRIBUTE_UNUSED,
int src_fd ATTRIBUTE_UNUSED,
char const *dst_path ATTRIBUTE_UNUSED,
int dst_fd ATTRIBUTE_UNUSED,
struct cp_options const *x ATTRIBUTE_UNUSED)
{
return true;
}
@@ -485,7 +471,7 @@ copy_reg (char const *src_name, char const *dst_name,
struct stat sb;
struct stat src_open_sb;
bool return_val = true;
bool data_copy_required = true;
bool data_copy_required = x->data_copy_required;
source_desc = open (src_name,
(O_RDONLY | O_BINARY
@@ -528,10 +514,14 @@ copy_reg (char const *src_name, char const *dst_name,
that is used when the destination file doesn't already exist. */
if (x->preserve_security_context && 0 <= dest_desc)
{
bool all_errors = (!x->data_copy_required
|| x->require_preserve_context);
bool some_errors = !all_errors && !x->reduce_diagnostics;
security_context_t con = NULL;
if (getfscreatecon (&con) < 0)
{
if (!x->reduce_diagnostics || x->require_preserve_context)
if (all_errors || (some_errors && !errno_unsupported (errno)))
error (0, errno, _("failed to get file system create context"));
if (x->require_preserve_context)
{
@@ -544,7 +534,7 @@ copy_reg (char const *src_name, char const *dst_name,
{
if (fsetfilecon (dest_desc, con) < 0)
{
if (!x->reduce_diagnostics || x->require_preserve_context)
if (all_errors || (some_errors && !errno_unsupported (errno)))
error (0, errno,
_("failed to set the security context of %s to %s"),
quote_n (0, dst_name), quote_n (1, con));
@@ -587,10 +577,11 @@ copy_reg (char const *src_name, char const *dst_name,
lstat'ing the DST_NAME shows that it is a symlink, then we
have a problem: trying to resolve this dangling symlink to
a directory/destination-entry pair is fundamentally racy,
so punt. If POSIXLY_CORRECT is set, simply call open again,
but without O_EXCL (potentially dangerous). If not, fail
with a diagnostic. These shenanigans are necessary only
when copying, i.e., not in move_mode. */
so punt. If x->open_dangling_dest_symlink is set (cp sets
that when POSIXLY_CORRECT is set in the environment), simply
call open again, but without O_EXCL (potentially dangerous).
If not, fail with a diagnostic. These shenanigans are necessary
only when copying, i.e., not in move_mode. */
if (dest_desc < 0 && dest_errno == EEXIST && ! x->move_mode)
{
struct stat dangling_link_sb;
@@ -706,7 +697,7 @@ copy_reg (char const *src_name, char const *dst_name,
buf_alloc = xmalloc (buf_size + buf_alignment_slop);
buf = ptr_align (buf_alloc, buf_alignment);
for (;;)
while (true)
{
word *wp = NULL;
@@ -797,15 +788,9 @@ copy_reg (char const *src_name, char const *dst_name,
if (last_write_made_hole)
{
if (HAVE_FTRUNCATE
? /* ftruncate sets the file size,
so there is no need for a write. */
ftruncate (dest_desc, n_read_total) < 0
: /* Seek backwards one character and write a null. */
(lseek (dest_desc, (off_t) -1, SEEK_CUR) < 0L
|| full_write (dest_desc, "", 1) != 1))
if (ftruncate (dest_desc, n_read_total) < 0)
{
error (0, errno, _("writing %s"), quote (dst_name));
error (0, errno, _("truncating %s"), quote (dst_name));
return_val = false;
goto close_src_and_dst_desc;
}
@@ -818,7 +803,7 @@ copy_reg (char const *src_name, char const *dst_name,
timespec[0] = get_stat_atime (src_sb);
timespec[1] = get_stat_mtime (src_sb);
if (gl_futimens (dest_desc, dst_name, timespec) != 0)
if (fdutimens (dest_desc, dst_name, timespec) != 0)
{
error (0, errno, _("preserving times for %s"), quote (dst_name));
if (x->require_preserve)
@@ -829,24 +814,8 @@ copy_reg (char const *src_name, char const *dst_name,
}
}
/* To allow copying xattrs on read-only files, temporarily chmod u+rw.
This workaround is required as an inode permission check is done
by xattr_permission() in fs/xattr.c of the GNU/Linux kernel tree. */
if (x->preserve_xattr)
{
bool access_changed = false;
if (!(sb.st_mode & S_IWUSR) && geteuid() != 0)
access_changed = fchmod_or_lchmod (dest_desc, dst_name, 0600) == 0;
if (!copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x)
&& x->require_preserve_xattr)
return_val = false;
if (access_changed)
fchmod_or_lchmod (dest_desc, dst_name, dst_mode & ~omitted_permissions);
}
/* Set ownership before xattrs as changing owners will
clear capabilities. */
if (x->preserve_ownership && ! SAME_OWNER_AND_GROUP (*src_sb, sb))
{
switch (set_owner (x, dst_name, dest_desc, src_sb, *new_dst, &sb))
@@ -861,6 +830,24 @@ copy_reg (char const *src_name, char const *dst_name,
}
}
/* To allow copying xattrs on read-only files, temporarily chmod u+rw.
This workaround is required as an inode permission check is done
by xattr_permission() in fs/xattr.c of the GNU/Linux kernel tree. */
if (x->preserve_xattr)
{
bool access_changed = false;
if (!(sb.st_mode & S_IWUSR) && geteuid () != 0)
access_changed = fchmod_or_lchmod (dest_desc, dst_name, 0600) == 0;
if (!copy_attr (src_name, source_desc, dst_name, dest_desc, x)
&& x->require_preserve_xattr)
return_val = false;
if (access_changed)
fchmod_or_lchmod (dest_desc, dst_name, dst_mode & ~omitted_permissions);
}
set_author (dst_name, dest_desc, src_sb);
if (x->preserve_mode || x->move_mode)
@@ -1245,7 +1232,7 @@ copy_internal (char const *src_name, char const *dst_name,
struct stat src_sb;
struct stat dst_sb;
mode_t src_mode;
mode_t dst_mode IF_LINT (= 0);
mode_t dst_mode IF_LINT ( = 0);
mode_t dst_mode_bits;
mode_t omitted_permissions;
bool restore_dst_mode = false;
@@ -1824,13 +1811,15 @@ copy_internal (char const *src_name, char const *dst_name,
if (x->preserve_security_context)
{
bool all_errors = !x->data_copy_required || x->require_preserve_context;
bool some_errors = !all_errors && !x->reduce_diagnostics;
security_context_t con;
if (0 <= lgetfilecon (src_name, &con))
{
if (setfscreatecon (con) < 0)
{
if (!x->reduce_diagnostics || x->require_preserve_context)
if (all_errors || (some_errors && !errno_unsupported (errno)))
error (0, errno,
_("failed to set default file creation context to %s"),
quote (con));
@@ -1844,15 +1833,14 @@ copy_internal (char const *src_name, char const *dst_name,
}
else
{
if (!errno_unsupported (errno) || x->require_preserve_context)
if (all_errors || (some_errors && !errno_unsupported (errno)))
{
if (!x->reduce_diagnostics || x->require_preserve_context)
error (0, errno,
_("failed to get security context of %s"),
quote (src_name));
if (x->require_preserve_context)
return false;
error (0, errno,
_("failed to get security context of %s"),
quote (src_name));
}
if (x->require_preserve_context)
return false;
}
}
@@ -2170,7 +2158,7 @@ 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)
if (x->preserve_xattr && ! copy_attr (src_name, -1, dst_name, -1, x)
&& x->require_preserve_xattr)
return false;

View File

@@ -170,6 +170,10 @@ struct cp_options
will be hard links to the same file (a copy of F). */
bool preserve_links;
/* Optionally don't copy the data, either with CoW reflink files or
explicitly with the --attributes-only option. */
bool data_copy_required;
/* If true and any of the above (for preserve) file attributes cannot
be applied to a destination file, treat it as a failure and return
nonzero immediately. E.g. for cp -p this must be true, for mv it
@@ -180,15 +184,13 @@ struct cp_options
Set this only if the kernel is SELinux enabled. */
bool preserve_security_context;
/* Useful only when preserve_security_context is true.
If true, a failed attempt to preserve a file's security context
propagates failure "out" to the caller. If false, a failure to
preserve a file's security context does not change the invoking
application's exit status. Give diagnostics for failed syscalls
regardless of this setting. For example, with "cp --preserve=context"
this flag is "true", while with "cp -a", it is false. That means
"cp -a" attempts to preserve any security context, but does not
fail if it is unable to do so. */
/* Useful only when preserve_context is true.
If true, a failed attempt to preserve file's security context
propagates failure "out" to the caller, along with full diagnostics.
If false, a failure to preserve file's security context does not
change the invoking application's exit status, but may output diagnostics.
For example, with `cp --preserve=context` this flag is "true",
while with `cp --preserve=all` or `cp -a`, it is "false". */
bool require_preserve_context;
/* If true, attempt to preserve extended attributes using libattr.
@@ -197,16 +199,19 @@ struct cp_options
/* 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. */
propagates failure "out" to the caller, along with full diagnostics.
If false, a failure to preserve file's extended attributes does not
change the invoking application's exit status, but may output diagnostics.
For example, with `cp --preserve=xattr` this flag is "true",
while with `cp --preserve=all` or `cp -a`, 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.
/* This allows us to output warnings in cases 2 and 4 below,
while being quiet for case 1 (when reduce_diagnostics is true).
1. cp -a try to copy xattrs with no errors
2. cp --preserve=all copy xattrs with all but ENOTSUP warnings
3. cp --preserve=xattr,context copy xattrs with all errors
4. mv copy xattrs with all but ENOTSUP warnings
*/
bool reduce_diagnostics;

View File

@@ -72,7 +72,8 @@ struct dir_attr
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
COPY_CONTENTS_OPTION = CHAR_MAX + 1,
ATTRIBUTES_ONLY_OPTION = CHAR_MAX + 1,
COPY_CONTENTS_OPTION,
NO_PRESERVE_ATTRIBUTES_OPTION,
PARENTS_OPTION,
PRESERVE_ATTRIBUTES_OPTION,
@@ -115,6 +116,7 @@ ARGMATCH_VERIFY (reflink_type_string, reflink_type);
static struct option const long_opts[] =
{
{"archive", no_argument, NULL, 'a'},
{"attributes-only", no_argument, NULL, ATTRIBUTES_ONLY_OPTION},
{"backup", optional_argument, NULL, 'b'},
{"copy-contents", no_argument, NULL, COPY_CONTENTS_OPTION},
{"dereference", no_argument, NULL, 'L'},
@@ -167,6 +169,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
-a, --archive same as -dR --preserve=all\n\
--attributes-only don't copy the file data, just the attributes\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\
@@ -202,12 +205,12 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
-R, -r, --recursive copy directories recursively\n\
--reflink[=WHEN] control clone/CoW copies. See below.\n\
--reflink[=WHEN] control clone/CoW copies. See below\n\
--remove-destination remove each existing destination file before\n\
attempting to open it (contrast with --force)\n\
"), stdout);
fputs (_("\
--sparse=WHEN control creation of sparse files. See below.\n\
--sparse=WHEN control creation of sparse files. See below\n\
--strip-trailing-slashes remove any trailing slashes from each SOURCE\n\
argument\n\
"), stdout);
@@ -405,7 +408,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
slash++;
while ((slash = strchr (slash, '/')))
{
struct dir_attr *new IF_LINT (= NULL);
struct dir_attr *new IF_LINT ( = NULL);
bool missing_dir;
*slash = '\0';
@@ -781,6 +784,7 @@ cp_option_init (struct cp_options *x)
x->reduce_diagnostics = false;
x->require_preserve_xattr = false;
x->data_copy_required = true;
x->require_preserve = false;
x->recursive = false;
x->sparse_mode = SPARSE_AUTO;
@@ -962,6 +966,10 @@ main (int argc, char **argv)
version_control_string = optarg;
break;
case ATTRIBUTES_ONLY_OPTION:
x.data_copy_required = false;
break;
case COPY_CONTENTS_OPTION:
copy_contents = true;
break;

View File

@@ -342,7 +342,7 @@ record_line_starts (struct buffer_record *b)
line_start = b->buffer;
bytes_left = b->bytes_used;
for (;;)
while (true)
{
line_end = memchr (line_start, '\n', bytes_left);
if (line_end == NULL)
@@ -773,7 +773,7 @@ process_regexp (struct control *p, uintmax_t repetition)
if (p->offset >= 0)
{
for (;;)
while (true)
{
line = find_line (++current_line);
if (line == NULL)
@@ -813,7 +813,7 @@ process_regexp (struct control *p, uintmax_t repetition)
else
{
/* Buffer the lines. */
for (;;)
while (true)
{
line = find_line (++current_line);
if (line == NULL)

View File

@@ -31,6 +31,7 @@
#include "system.h"
#include "error.h"
#include "fadvise.h"
#include "getndelim2.h"
#include "hash.h"
#include "quote.h"
@@ -358,7 +359,7 @@ set_fields (const char *fieldstr)
/* Collect and store in RP the range end points.
It also sets EOL_RANGE_START if appropriate. */
for (;;)
while (true)
{
if (*fieldstr == '-')
{
@@ -733,6 +734,8 @@ cut_file (char const *file)
}
}
fadvise (stream, FADVISE_SEQUENTIAL);
cut_stream (stream);
if (ferror (stream))
@@ -756,7 +759,7 @@ main (int argc, char **argv)
int optc;
bool ok;
bool delim_specified = false;
char *spec_list_string IF_LINT(= NULL);
char *spec_list_string IF_LINT ( = NULL);
initialize_main (&argc, &argv);
set_program_name (argv[0]);

View File

@@ -27,7 +27,7 @@
#include "system.h"
#include "argmatch.h"
#include "error.h"
#include "getdate.h"
#include "parse-datetime.h"
#include "posixtm.h"
#include "quote.h"
#include "stat-time.h"
@@ -281,7 +281,7 @@ batch_convert (const char *input_filename, const char *format)
break;
}
if (! get_date (&when, line, NULL))
if (! parse_datetime (&when, line, NULL))
{
if (line[line_length - 1] == '\n')
line[line_length - 1] = '\0';
@@ -450,7 +450,7 @@ main (int argc, char **argv)
if (! *format)
{
/* Do not wrap the following literal format string with _(...).
For example, suppose LC_ALL is unset, LC_TIME="POSIX",
For example, suppose LC_ALL is unset, LC_TIME=POSIX,
and LANG="ko_KR". In that case, POSIX says that LC_TIME
determines the format and contents of date and time strings
written by date, which means "date" must generate output
@@ -500,7 +500,7 @@ main (int argc, char **argv)
{
if (set_datestr)
datestr = set_datestr;
valid_date = get_date (&when, datestr, NULL);
valid_date = parse_datetime (&when, datestr, NULL);
}
}

View File

@@ -27,10 +27,10 @@
#include "system.h"
#include "close-stream.h"
#include "error.h"
#include "fadvise.h"
#include "fd-reopen.h"
#include "gethrxtime.h"
#include "human.h"
#include "ignore-value.h"
#include "long-options.h"
#include "quote.h"
#include "quotearg.h"
@@ -57,12 +57,6 @@ static void process_signals (void);
# define siginterrupt(sig, flag) /* empty */
# endif
#endif
#ifndef SA_NODEFER
# define SA_NODEFER 0
#endif
#ifndef SA_RESETHAND
# define SA_RESETHAND 0
#endif
#ifndef SIGINFO
# define SIGINFO SIGUSR1
@@ -802,7 +796,7 @@ process_signals (void)
static ssize_t
iread (int fd, char *buf, size_t size)
{
for (;;)
while (true)
{
ssize_t nread;
process_signals ();
@@ -855,12 +849,9 @@ iwrite (int fd, char const *buf, size_t size)
posix_fadvise to tell the system not to pollute the buffer
cache with this data. Don't bother to diagnose lseek or
posix_fadvise failure. */
#ifdef POSIX_FADV_DONTNEED
off_t off = lseek (STDOUT_FILENO, 0, SEEK_CUR);
if (0 <= off)
ignore_value (posix_fadvise (STDOUT_FILENO,
off, 0, POSIX_FADV_DONTNEED));
#endif
fdadvise (STDOUT_FILENO, off, 0, FADVISE_DONTNEED);
/* Attempt to ensure that that final block is committed
to disk as quickly as possible. */
@@ -932,7 +923,7 @@ parse_symbols (char const *str, struct symbol_value const *table,
{
int value = 0;
for (;;)
while (true)
{
char const *strcomma = strchr (str, ',');
struct symbol_value const *entry;
@@ -1563,6 +1554,16 @@ set_fd_flags (int fd, int add_flags, char const *name)
}
}
static char *
human_size (size_t n)
{
static char hbuf[LONGEST_HUMAN_READABLE + 1];
int human_opts =
(human_autoscale | human_round_to_nearest | human_base_1024
| human_space_before_unit | human_SI | human_B);
return human_readable (n, hbuf, human_opts, 1, 1);
}
/* The main loop. */
static int
@@ -1599,7 +1600,12 @@ dd_copy (void)
It is necessary when accessing raw (i.e. character special) disk
devices on Unixware or other SVR4-derived system. */
real_buf = xmalloc (input_blocksize + INPUT_BLOCK_SLOP);
real_buf = malloc (input_blocksize + INPUT_BLOCK_SLOP);
if (!real_buf)
error (EXIT_FAILURE, 0,
_("memory exhausted by input buffer of size %zu bytes (%s)"),
input_blocksize, human_size (input_blocksize));
ibuf = real_buf;
ibuf += SWAB_ALIGN_OFFSET; /* allow space for swab */
@@ -1608,7 +1614,11 @@ dd_copy (void)
if (conversions_mask & C_TWOBUFS)
{
/* Page-align the output buffer, too. */
real_obuf = xmalloc (output_blocksize + OUTPUT_BLOCK_SLOP);
real_obuf = malloc (output_blocksize + OUTPUT_BLOCK_SLOP);
if (!real_obuf)
error (EXIT_FAILURE, 0,
_("memory exhausted by output buffer of size %zu bytes (%s)"),
output_blocksize, human_size (output_blocksize));
obuf = ptr_align (real_obuf, page_size);
}
else
@@ -1875,7 +1885,7 @@ main (int argc, char **argv)
offset = lseek (STDIN_FILENO, 0, SEEK_CUR);
input_seekable = (0 <= offset);
input_offset = MAX(0, offset);
input_offset = MAX (0, offset);
input_seek_errno = errno;
if (output_file == NULL)

160
src/df.c
View File

@@ -29,8 +29,7 @@
#include "human.h"
#include "mountlist.h"
#include "quote.h"
#include "save-cwd.h"
#include "xgetcwd.h"
#include "find-mount-point.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "df"
@@ -522,94 +521,6 @@ show_dev (char const *disk, char const *mount_point,
putchar ('\n');
}
/* Return the root mountpoint of the file system on which FILE exists, in
malloced storage. FILE_STAT should be the result of stating FILE.
Give a diagnostic and return NULL if unable to determine the mount point.
Exit if unable to restore current working directory. */
static char *
find_mount_point (const char *file, const struct stat *file_stat)
{
struct saved_cwd cwd;
struct stat last_stat;
char *mp = NULL; /* The malloced mount point. */
if (save_cwd (&cwd) != 0)
{
error (0, errno, _("cannot get current directory"));
return NULL;
}
if (S_ISDIR (file_stat->st_mode))
/* FILE is a directory, so just chdir there directly. */
{
last_stat = *file_stat;
if (chdir (file) < 0)
{
error (0, errno, _("cannot change to directory %s"), quote (file));
return NULL;
}
}
else
/* FILE is some other kind of file; use its directory. */
{
char *xdir = dir_name (file);
char *dir;
ASSIGN_STRDUPA (dir, xdir);
free (xdir);
if (chdir (dir) < 0)
{
error (0, errno, _("cannot change to directory %s"), quote (dir));
return NULL;
}
if (stat (".", &last_stat) < 0)
{
error (0, errno, _("cannot stat current directory (now %s)"),
quote (dir));
goto done;
}
}
/* Now walk up FILE's parents until we find another file system or /,
chdiring as we go. LAST_STAT holds stat information for the last place
we visited. */
for (;;)
{
struct stat st;
if (stat ("..", &st) < 0)
{
error (0, errno, _("cannot stat %s"), quote (".."));
goto done;
}
if (st.st_dev != last_stat.st_dev || st.st_ino == last_stat.st_ino)
/* cwd is the mount point. */
break;
if (chdir ("..") < 0)
{
error (0, errno, _("cannot change to directory %s"), quote (".."));
goto done;
}
last_stat = st;
}
/* Finally reached a mount point, see what it's called. */
mp = xgetcwd ();
done:
/* Restore the original cwd. */
{
int save_errno = errno;
if (restore_cwd (&cwd) != 0)
error (EXIT_FAILURE, errno,
_("failed to return to initial working directory"));
free_cwd (&cwd);
errno = save_errno;
}
return mp;
}
/* If DISK corresponds to a mount point, show its usage
and return true. Otherwise, return false. */
static bool
@@ -643,54 +554,35 @@ show_point (const char *point, const struct stat *statp)
struct mount_entry *me;
struct mount_entry const *best_match = NULL;
/* If POINT is an absolute file name, see if we can find the
mount point without performing any extra stat calls at all. */
if (*point == '/')
{
/* Find the best match: prefer non-dummies, and then prefer the
last match if there are ties. */
for (me = mount_list; me; me = me->me_next)
if (STREQ (me->me_mountdir, point) && !STREQ (me->me_type, "lofs")
&& (!best_match || best_match->me_dummy || !me->me_dummy))
best_match = me;
}
/* Calculate the real absolute file name for POINT, and use that to find
the mount point. This avoids statting unavailable mount points,
which can hang df. */
if (! best_match)
char *resolved = canonicalize_file_name (point);
if (resolved && resolved[0] == '/')
{
char *resolved = canonicalize_file_name (point);
size_t resolved_len = strlen (resolved);
size_t best_match_len = 0;
if (resolved && resolved[0] == '/')
for (me = mount_list; me; me = me->me_next)
if (!STREQ (me->me_type, "lofs")
&& (!best_match || best_match->me_dummy || !me->me_dummy))
{
size_t resolved_len = strlen (resolved);
size_t best_match_len = 0;
for (me = mount_list; me; me = me->me_next)
if (!STREQ (me->me_type, "lofs")
&& (!best_match || best_match->me_dummy || !me->me_dummy))
{
size_t len = strlen (me->me_mountdir);
if (best_match_len <= len && len <= resolved_len
&& (len == 1 /* root file system */
|| ((len == resolved_len || resolved[len] == '/')
&& strncmp (me->me_mountdir, resolved, len) == 0)))
{
best_match = me;
best_match_len = len;
}
}
size_t len = strlen (me->me_mountdir);
if (best_match_len <= len && len <= resolved_len
&& (len == 1 /* root file system */
|| ((len == resolved_len || resolved[len] == '/')
&& strncmp (me->me_mountdir, resolved, len) == 0)))
{
best_match = me;
best_match_len = len;
}
}
free (resolved);
if (best_match
&& (stat (best_match->me_mountdir, &disk_stats) != 0
|| disk_stats.st_dev != statp->st_dev))
best_match = NULL;
}
free (resolved);
if (best_match
&& (stat (best_match->me_mountdir, &disk_stats) != 0
|| disk_stats.st_dev != statp->st_dev))
best_match = NULL;
if (! best_match)
for (me = mount_list; me; me = me->me_next)
@@ -819,7 +711,9 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
-a, --all include dummy file systems\n\
-B, --block-size=SIZE use SIZE-byte blocks\n\
-B, --block-size=SIZE scale sizes by SIZE before printing them. E.g.,\n\
`-BM' prints sizes in units of 1,048,576 bytes.\n\
See SIZE format below.\n\
--total produce a grand total\n\
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
-H, --si likewise, but use powers of 1000 not 1024\n\
@@ -850,7 +744,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
int
main (int argc, char **argv)
{
struct stat *stats IF_LINT (= 0);
struct stat *stats IF_LINT ( = 0);
initialize_main (&argc, &argv);
set_program_name (argv[0]);
@@ -873,7 +767,7 @@ main (int argc, char **argv)
print_grand_total = false;
grand_fsu.fsu_blocksize = 1;
for (;;)
while (true)
{
int oi = -1;
int c = getopt_long (argc, argv, "aB:iF:hHklmPTt:vx:", long_options,

View File

@@ -38,15 +38,20 @@ TERM mach-color
TERM mlterm
TERM putty
TERM rxvt
TERM rxvt-256color
TERM rxvt-cygwin
TERM rxvt-cygwin-native
TERM rxvt-unicode
TERM rxvt-unicode-256color
TERM rxvt-unicode256
TERM screen
TERM screen-256color
TERM screen-256color-bce
TERM screen-bce
TERM screen-w
TERM screen.rxvt
TERM screen.linux
TERM terminator
TERM vt100
TERM xterm
TERM xterm-16color

View File

@@ -48,8 +48,8 @@ Usage: %s NAME\n\
"),
program_name, program_name);
fputs (_("\
Print NAME with its trailing /component removed; if NAME contains no /'s,\n\
output `.' (meaning the current directory).\n\
Output NAME with its last non-slash component and trailing slashes removed;\n\
if NAME contains no /'s, output `.' (meaning the current directory).\n\
\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
@@ -57,7 +57,7 @@ output `.' (meaning the current directory).\n\
printf (_("\
\n\
Examples:\n\
%s /usr/bin/sort Output \"/usr/bin\".\n\
%s /usr/bin/ Output \"/usr\".\n\
%s stdio.h Output \".\".\n\
"),
program_name, program_name);

260
src/du.c
View File

@@ -30,10 +30,10 @@
#include "system.h"
#include "argmatch.h"
#include "argv-iter.h"
#include "di-set.h"
#include "error.h"
#include "exclude.h"
#include "fprintftime.h"
#include "hash.h"
#include "human.h"
#include "quote.h"
#include "quotearg.h"
@@ -56,25 +56,12 @@ extern bool fts_debug;
#if DU_DEBUG
# define FTS_CROSS_CHECK(Fts) fts_cross_check (Fts)
# define DEBUG_OPT "d"
#else
# define FTS_CROSS_CHECK(Fts)
# define DEBUG_OPT
#endif
/* Initial size of the hash table. */
#define INITIAL_TABLE_SIZE 103
/* Hash structure for inode and device numbers. The separate entry
structure makes it easier to rehash "in place". */
struct entry
{
ino_t st_ino;
dev_t st_dev;
};
/* A set of dev/ino pairs. */
static Hash_table *htab;
static struct di_set *di_set;
/* Define a class for collecting directory information. */
@@ -134,6 +121,9 @@ static bool apparent_size = false;
/* If true, count each hard link of files with multiple links. */
static bool opt_count_all = false;
/* If true, hash all files to look for hard links. */
static bool hash_all;
/* If true, output the NUL byte instead of a newline at the end of each line. */
static bool opt_nul_terminate_output = false;
@@ -192,7 +182,7 @@ enum
EXCLUDE_OPTION,
FILES0_FROM_OPTION,
HUMAN_SI_OPTION,
MAX_DEPTH_OPTION,
FTS_DEBUG,
TIME_OPTION,
TIME_STYLE_OPTION
};
@@ -204,6 +194,7 @@ static struct option const long_options[] =
{"block-size", required_argument, NULL, 'B'},
{"bytes", no_argument, NULL, 'b'},
{"count-links", no_argument, NULL, 'l'},
/* {"-debug", no_argument, NULL, FTS_DEBUG}, */
{"dereference", no_argument, NULL, 'L'},
{"dereference-args", no_argument, NULL, 'D'},
{"exclude", required_argument, NULL, EXCLUDE_OPTION},
@@ -211,7 +202,7 @@ static struct option const long_options[] =
{"files0-from", required_argument, NULL, FILES0_FROM_OPTION},
{"human-readable", no_argument, NULL, 'h'},
{"si", no_argument, NULL, HUMAN_SI_OPTION},
{"max-depth", required_argument, NULL, MAX_DEPTH_OPTION},
{"max-depth", required_argument, NULL, 'd'},
{"null", no_argument, NULL, '0'},
{"no-dereference", no_argument, NULL, 'P'},
{"one-file-system", no_argument, NULL, 'x'},
@@ -282,7 +273,9 @@ Mandatory arguments to long options are mandatory for short options too.\n\
fragmentation, indirect blocks, and the like\n\
"), stdout);
fputs (_("\
-B, --block-size=SIZE use SIZE-byte blocks\n\
-B, --block-size=SIZE scale sizes by SIZE before printing them. E.g.,\n\
`-BM' prints sizes in units of 1,048,576 bytes.\n\
See SIZE format below.\n\
-b, --bytes equivalent to `--apparent-size --block-size=1'\n\
-c, --total produce a grand total\n\
-D, --dereference-args dereference only symlinks that are listed on the\n\
@@ -312,7 +305,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-x, --one-file-system skip directories on different file systems\n\
-X, --exclude-from=FILE exclude files that match any pattern in FILE\n\
--exclude=PATTERN exclude files that match PATTERN\n\
--max-depth=N print the total for a directory (or file, with --all)\n\
-d, --max-depth=N print the total for a directory (or file, with --all)\n\
only if it is N or fewer levels below the command\n\
line argument; --max-depth=0 is the same as\n\
--summarize\n\
@@ -335,66 +328,16 @@ Mandatory arguments to long options are mandatory for short options too.\n\
exit (status);
}
static size_t
entry_hash (void const *x, size_t table_size)
{
struct entry const *p = x;
/* Ignoring the device number here should be fine. */
/* The cast to uintmax_t prevents negative remainders
if st_ino is negative. */
return (uintmax_t) p->st_ino % table_size;
}
/* Compare two dev/ino pairs. Return true if they are the same. */
static bool
entry_compare (void const *x, void const *y)
{
struct entry const *a = x;
struct entry const *b = y;
return SAME_INODE (*a, *b) ? true : false;
}
/* Try to insert the INO/DEV pair into the global table, HTAB.
Return true if the pair is successfully inserted,
false if the pair is already in the table. */
static bool
hash_ins (ino_t ino, dev_t dev)
{
struct entry *ent;
struct entry *ent_from_table;
ent = xmalloc (sizeof *ent);
ent->st_ino = ino;
ent->st_dev = dev;
ent_from_table = hash_insert (htab, ent);
if (ent_from_table == NULL)
{
/* Insertion failed due to lack of memory. */
xalloc_die ();
}
if (ent_from_table == ent)
{
/* Insertion succeeded. */
return true;
}
/* That pair is already in the table, so ENT was not inserted. Free it. */
free (ent);
return false;
}
/* Initialize the hash table. */
static void
hash_init (void)
{
htab = hash_initialize (INITIAL_TABLE_SIZE, NULL,
entry_hash, entry_compare, free);
if (htab == NULL)
int inserted = di_set_insert (di_set, dev, ino);
if (inserted < 0)
xalloc_die ();
return inserted;
}
/* FIXME: this code is nearly identical to code in date.c */
@@ -449,7 +392,7 @@ print_size (const struct duinfo *pdui, const char *string)
static bool
process_file (FTS *fts, FTSENT *ent)
{
bool ok;
bool ok = true;
struct duinfo dui;
struct duinfo dui_to_print;
size_t level;
@@ -464,79 +407,85 @@ process_file (FTS *fts, FTSENT *ent)
The sum of the sizes of all entries in the hierarchy at or below the
directory at the specified level. */
static struct dulevel *dulvl;
bool print = true;
const char *file = ent->fts_path;
const struct stat *sb = ent->fts_statp;
bool skip;
int info = ent->fts_info;
/* If necessary, set FTS_SKIP before returning. */
skip = excluded_file_name (exclude, file);
if (skip)
fts_set (fts, ent, FTS_SKIP);
switch (ent->fts_info)
if (info == FTS_DNR)
{
case FTS_NS:
error (0, ent->fts_errno, _("cannot access %s"), quote (file));
return false;
case FTS_ERR:
/* if (S_ISDIR (ent->fts_statp->st_mode) && FIXME */
error (0, ent->fts_errno, _("%s"), quote (file));
return false;
case FTS_DNR:
/* Don't return just yet, since although the directory is not readable,
we were able to stat it, so we do have a size. */
/* An error occurred, but the size is known, so count it. */
error (0, ent->fts_errno, _("cannot read directory %s"), quote (file));
ok = false;
break;
case FTS_DC: /* directory that causes cycles */
if (cycle_warning_required (fts, ent))
}
else if (info != FTS_DP)
{
bool excluded = excluded_file_name (exclude, file);
if (! excluded)
{
emit_cycle_warning (file);
return false;
/* Make the stat buffer *SB valid, or fail noisily. */
if (info == FTS_NSOK)
{
fts_set (fts, ent, FTS_AGAIN);
FTSENT const *e = fts_read (fts);
assert (e == ent);
info = ent->fts_info;
}
if (info == FTS_NS || info == FTS_SLNONE)
{
error (0, ent->fts_errno, _("cannot access %s"), quote (file));
return false;
}
}
ok = true;
break;
default:
ok = true;
break;
if (excluded
|| (! opt_count_all
&& (hash_all || (! S_ISDIR (sb->st_mode) && 1 < sb->st_nlink))
&& ! hash_ins (sb->st_ino, sb->st_dev)))
{
/* If ignoring a directory in preorder, skip its children.
Ignore the next fts_read output too, as it's a postorder
visit to the same directory. */
if (info == FTS_D)
{
fts_set (fts, ent, FTS_SKIP);
FTSENT const *e = fts_read (fts);
assert (e == ent);
}
return true;
}
switch (info)
{
case FTS_D:
return true;
case FTS_ERR:
/* An error occurred, but the size is known, so count it. */
error (0, ent->fts_errno, "%s", quote (file));
ok = false;
break;
case FTS_DC:
if (cycle_warning_required (fts, ent))
{
emit_cycle_warning (file);
return false;
}
return true;
}
}
/* If this is the first (pre-order) encounter with a directory,
or if it's the second encounter for a skipped directory, then
return right away. */
if (ent->fts_info == FTS_D || skip)
return ok;
/* If the file is being excluded or if it has already been counted
via a hard link, then don't let it contribute to the sums. */
if (skip
|| (!opt_count_all
&& ! S_ISDIR (sb->st_mode)
&& 1 < sb->st_nlink
&& ! hash_ins (sb->st_ino, sb->st_dev)))
{
/* Note that we must not simply return here.
We still have to update prev_level and maybe propagate
some sums up the hierarchy. */
duinfo_init (&dui);
print = false;
}
else
{
duinfo_set (&dui,
(apparent_size
? sb->st_size
: (uintmax_t) ST_NBLOCKS (*sb) * ST_NBLOCKSIZE),
(time_type == time_mtime ? get_stat_mtime (sb)
: time_type == time_atime ? get_stat_atime (sb)
: get_stat_ctime (sb)));
}
duinfo_set (&dui,
(apparent_size
? sb->st_size
: (uintmax_t) ST_NBLOCKS (*sb) * ST_NBLOCKSIZE),
(time_type == time_mtime ? get_stat_mtime (sb)
: time_type == time_atime ? get_stat_atime (sb)
: get_stat_ctime (sb)));
level = ent->fts_level;
dui_to_print = dui;
@@ -593,20 +542,14 @@ process_file (FTS *fts, FTSENT *ent)
/* Let the size of a directory entry contribute to the total for the
containing directory, unless --separate-dirs (-S) is specified. */
if ( ! (opt_separate_dirs && IS_DIR_TYPE (ent->fts_info)))
if (! (opt_separate_dirs && IS_DIR_TYPE (info)))
duinfo_add (&dulvl[level].ent, &dui);
/* Even if this directory is unreadable or we can't chdir into it,
do let its size contribute to the total. */
duinfo_add (&tot_dui, &dui);
/* If we're not counting an entry, e.g., because it's a hard link
to a file we've already counted (and --count-links), then don't
print a line for it. */
if (!print)
return ok;
if ((IS_DIR_TYPE (ent->fts_info) && level <= max_depth)
if ((IS_DIR_TYPE (info) && level <= max_depth)
|| ((opt_all && level <= max_depth) || level == 0))
print_size (&dui_to_print, file);
@@ -666,7 +609,7 @@ main (int argc, char **argv)
char *files_from = NULL;
/* Bit flags that control how fts works. */
int bit_flags = FTS_TIGHT_CYCLE_CHECK | FTS_DEFER_STAT;
int bit_flags = FTS_NOSTAT;
/* Select one of the three FTS_ options that control if/when
to follow a symlink. */
@@ -691,10 +634,10 @@ main (int argc, char **argv)
human_options (getenv ("DU_BLOCK_SIZE"),
&human_output_opts, &output_block_size);
for (;;)
while (true)
{
int oi = -1;
int c = getopt_long (argc, argv, DEBUG_OPT "0abchHklmsxB:DLPSX:",
int c = getopt_long (argc, argv, "0abd:chHklmsxB:DLPSX:",
long_options, &oi);
if (c == -1)
break;
@@ -702,7 +645,7 @@ main (int argc, char **argv)
switch (c)
{
#if DU_DEBUG
case 'd':
case FTS_DEBUG:
fts_debug = true;
break;
#endif
@@ -744,7 +687,7 @@ main (int argc, char **argv)
output_block_size = 1024;
break;
case MAX_DEPTH_OPTION: /* --max-depth=N */
case 'd': /* --max-depth=N */
{
unsigned long int tmp_ulong;
if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK
@@ -936,18 +879,34 @@ main (int argc, char **argv)
quote (files_from));
ai = argv_iter_init_stream (stdin);
/* It's not easy here to count the arguments, so assume the
worst. */
hash_all = true;
}
else
{
char **files = (optind < argc ? argv + optind : cwd_only);
ai = argv_iter_init_argv (files);
/* Hash all dev,ino pairs if there are multiple arguments, or if
following non-command-line symlinks, because in either case a
file with just one hard link might be seen more than once. */
hash_all = (optind + 1 < argc || symlink_deref_bits == FTS_LOGICAL);
}
if (!ai)
xalloc_die ();
/* Initialize the hash structure for inode numbers. */
hash_init ();
/* Initialize the set of dev,inode pairs. */
di_set = di_set_alloc ();
if (!di_set)
xalloc_die ();
/* If not hashing everything, process_file won't find cycles on its
own, so ask fts_read to check for them accurately. */
if (opt_count_all || ! hash_all)
bit_flags |= FTS_TIGHT_CYCLE_CHECK;
bit_flags |= symlink_deref_bits;
static char *temp_argv[] = { NULL, NULL };
@@ -1018,6 +977,7 @@ main (int argc, char **argv)
}
argv_iter_free (ai);
di_set_free (di_set);
if (files_from && (ferror (stdin) || fclose (stdin) != 0))
error (EXIT_FAILURE, 0, _("error reading %s"), quote (files_from));
@@ -1025,7 +985,5 @@ main (int argc, char **argv)
if (print_grand_total)
print_size (&tot_dui, _("total"));
hash_free (htab);
exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}

View File

@@ -40,6 +40,7 @@
#include <sys/types.h>
#include "system.h"
#include "error.h"
#include "fadvise.h"
#include "quote.h"
#include "xstrndup.h"
@@ -144,8 +145,8 @@ static void
parse_tab_stops (char const *stops)
{
bool have_tabval = false;
uintmax_t tabval IF_LINT (= 0);
char const *num_start IF_LINT (= NULL);
uintmax_t tabval IF_LINT ( = 0);
char const *num_start IF_LINT ( = NULL);
bool ok = true;
for (; *stops; stops++)
@@ -243,13 +244,14 @@ next_file (FILE *fp)
if (STREQ (file, "-"))
{
have_read_stdin = true;
prev_file = file;
return stdin;
fp = stdin;
}
fp = fopen (file, "r");
else
fp = fopen (file, "r");
if (fp)
{
prev_file = file;
fadvise (fp, FADVISE_SEQUENTIAL);
return fp;
}
error (0, errno, "%s", file);
@@ -270,7 +272,7 @@ expand (void)
if (!fp)
return;
for (;;)
while (true)
{
/* Input character, or EOF. */
int c;
@@ -306,7 +308,7 @@ expand (void)
if (tab_size)
next_tab_column = column + (tab_size - column % tab_size);
else
for (;;)
while (true)
if (tab_index == first_free_tab)
{
next_tab_column = column + 1;

View File

@@ -547,7 +547,7 @@ trace (fxn)
static VALUE *
docolon (VALUE *sv, VALUE *pv)
{
VALUE *v IF_LINT (= NULL);
VALUE *v IF_LINT ( = NULL);
const char *errmsg;
struct re_pattern_buffer re_buffer;
char fastmap[UCHAR_MAX + 1];
@@ -787,7 +787,7 @@ eval4 (bool evaluate)
if (evaluate)
{
if (!toarith (l) || !toarith (r))
error (EXPR_INVALID, 0, _("non-numeric argument"));
error (EXPR_INVALID, 0, _("non-integer argument"));
if (fxn != multiply && mpz_sgn (r->u.i) == 0)
error (EXPR_INVALID, 0, _("division by zero"));
((fxn == multiply ? mpz_mul
@@ -824,7 +824,7 @@ eval3 (bool evaluate)
if (evaluate)
{
if (!toarith (l) || !toarith (r))
error (EXPR_INVALID, 0, _("non-numeric argument"));
error (EXPR_INVALID, 0, _("non-integer argument"));
(fxn == plus ? mpz_add : mpz_sub) (l->u.i, l->u.i, r->u.i);
}
freev (r);

View File

@@ -107,7 +107,7 @@ factor_using_division (mpz_t t, unsigned int limit)
--f;
}
for (;;)
while (true)
{
mpz_tdiv_qr_ui (q, r, t, 3);
if (mpz_cmp_ui (r, 0) != 0)
@@ -116,7 +116,7 @@ factor_using_division (mpz_t t, unsigned int limit)
emit_ul_factor (3);
}
for (;;)
while (true)
{
mpz_tdiv_qr_ui (q, r, t, 5);
if (mpz_cmp_ui (r, 0) != 0)
@@ -516,7 +516,7 @@ do_stdin (void)
init_tokenbuffer (&tokenbuffer);
for (;;)
while (true)
{
size_t token_length = readtoken (stdin, DELIM, sizeof (DELIM) - 1,
&tokenbuffer);

113
src/find-mount-point.c Normal file
View File

@@ -0,0 +1,113 @@
/* find-mount-point.c -- find the root mount point for a file.
Copyright (C) 2010 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 <sys/types.h>
#include "system.h"
#include "error.h"
#include "quote.h"
#include "save-cwd.h"
#include "xgetcwd.h"
#include "find-mount-point.h"
/* Return the root mountpoint of the file system on which FILE exists, in
malloced storage. FILE_STAT should be the result of stating FILE.
Give a diagnostic and return NULL if unable to determine the mount point.
Exit if unable to restore current working directory. */
extern char *
find_mount_point (const char *file, const struct stat *file_stat)
{
struct saved_cwd cwd;
struct stat last_stat;
char *mp = NULL; /* The malloced mount point. */
if (save_cwd (&cwd) != 0)
{
error (0, errno, _("cannot get current directory"));
return NULL;
}
if (S_ISDIR (file_stat->st_mode))
/* FILE is a directory, so just chdir there directly. */
{
last_stat = *file_stat;
if (chdir (file) < 0)
{
error (0, errno, _("cannot change to directory %s"), quote (file));
return NULL;
}
}
else
/* FILE is some other kind of file; use its directory. */
{
char *xdir = dir_name (file);
char *dir;
ASSIGN_STRDUPA (dir, xdir);
free (xdir);
if (chdir (dir) < 0)
{
error (0, errno, _("cannot change to directory %s"), quote (dir));
return NULL;
}
if (stat (".", &last_stat) < 0)
{
error (0, errno, _("cannot stat current directory (now %s)"),
quote (dir));
goto done;
}
}
/* Now walk up FILE's parents until we find another file system or /,
chdiring as we go. LAST_STAT holds stat information for the last place
we visited. */
while (true)
{
struct stat st;
if (stat ("..", &st) < 0)
{
error (0, errno, _("cannot stat %s"), quote (".."));
goto done;
}
if (st.st_dev != last_stat.st_dev || st.st_ino == last_stat.st_ino)
/* cwd is the mount point. */
break;
if (chdir ("..") < 0)
{
error (0, errno, _("cannot change to directory %s"), quote (".."));
goto done;
}
last_stat = st;
}
/* Finally reached a mount point, see what it's called. */
mp = xgetcwd ();
done:
/* Restore the original cwd. */
{
int save_errno = errno;
if (restore_cwd (&cwd) != 0)
error (EXIT_FAILURE, errno,
_("failed to return to initial working directory"));
free_cwd (&cwd);
errno = save_errno;
}
return mp;
}

17
src/find-mount-point.h Normal file
View File

@@ -0,0 +1,17 @@
/* find-mount-point.h -- find the root mount point for a file.
Copyright (C) 2010 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/>. */
extern char* find_mount_point (const char *, const struct stat *);

View File

@@ -27,6 +27,7 @@
#include "system.h"
#include "error.h"
#include "fadvise.h"
#include "quote.h"
#include "xstrtol.h"
@@ -463,6 +464,7 @@ set_prefix (char *p)
static void
fmt (FILE *f)
{
fadvise (f, FADVISE_SEQUENTIAL);
tabs = false;
other_indent = 0;
next_char = get_prefix (f);
@@ -728,7 +730,7 @@ get_prefix (FILE *f)
static int
get_space (FILE *f, int c)
{
for (;;)
while (true)
{
if (c == ' ')
in_column++;

View File

@@ -24,6 +24,7 @@
#include "system.h"
#include "error.h"
#include "fadvise.h"
#include "quote.h"
#include "xstrtol.h"
@@ -142,6 +143,8 @@ fold_file (char const *filename, size_t width)
return false;
}
fadvise (stdin, FADVISE_SEQUENTIAL);
while ((c = getc (istream)) != EOF)
{
if (offset_out + 1 >= allocated_out)

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