diff --git a/src/bin/coreutils/ChangeLog b/src/bin/coreutils/ChangeLog index 6fae0aa48b..1dba0b319a 100644 --- a/src/bin/coreutils/ChangeLog +++ b/src/bin/coreutils/ChangeLog @@ -1,5 +1,577 @@ +2009-09-11 Jim Meyering + + version 7.6 + * NEWS: Record release date. + +2009-09-10 Jim Meyering + + link,ln: use gnulib's link module to work around Solaris 10 deficiency + Before this change, :>f; ln -T f no-such/ would succeed on Solaris 10. + After it, ln fails, as it should: ln: accessing `z/': Not a directory + The command, link f no-such/, had the same problem on that system. + * bootstrap.conf (gnulib_modules): Add "link". + * tests/ln/slash-decorated-nonexistent-dest: New test. + * tests/Makefile.am (TESTS): Add it. + * NEWS (Portability): Mention the improvement. + + build: update gnulib submodule to latest + +2009-09-10 Ondřej Vašík + + doc: improve various BLOCKSIZE and SIZE help + * doc/coreutils.texi (multiplierSuffixes): Mention that + the suffix can be specified without a leading number + * src/split.c (usage): Refactor SIZE help to within a function + * src/truncate.c (usage): Likewise + * src/ls.c (usage): Likewise + * src/df.c (usage): Likewise. Also add a function with BLOCKSIZE help + * src/du.c (usage): Likewise. + * src/system.h: Define 2 functions to emit common help text + This was prompted by https://bugzilla.redhat.com/show_bug.cgi?id=511188 + +2009-09-10 Jim Meyering + + dd conv=unblock: print final newline consistently + * src/dd.c (dd_copy) [C_UNBLOCK]: Always print the final newline for + non-empty output, not just when output size is a multiple of cbs. + * doc/coreutils.texi (dd invocation) [conv=unblock]: Mention that dd + prints a newline after each output record, not just when replacing + trailing spaces. + Reported by Ulrich Drepper. + * tests/dd/unblock: New file. Test for this. + * tests/Makefile.am (TESTS): Add it. + * NEWS (Bug fixes): Mention it. + +2009-09-09 Jim Meyering + + maint: make cfg.mk slightly more generic + * cfg.mk (url_dir_list): Don't hard-code "coreutils". Use $(PACKAGE). + +2009-09-08 Jim Meyering + + * gnulib: Update submodule to latest. + + tail: make the new piped-stdin test as portable as the old one + * src/tail.c (main): Adapt piped-stdin test to use the same isapipe, + test as was used in the preceding POSIXLY_CORRECT condition. + Remove the now-subsumed POSIXLY_CORRECT test. + Reported by Pádraig Brady. + * doc/coreutils.texi (tail invocation): Document this change. + * NEWS (Changes in behavior): Reclassify, clarify. + +2009-09-08 Pádraig Brady + + tests: tail-2/assert: reduce risk of race condition + * tests/tail2/assert: This reverts commit be853120, 25-08-2009, + "tests: tail-2/assert: avoid risk of race condition" + kill -0 doesn't send a signal and so will only confirm that the + background process was forked, which we know already because + we have its pid. + + tests: address a race condition in misc/cat-buf + * tests/misc/cat-buf: Increase the delay between writes + to decrease the chance that dd will read both at once. + Since the test is inherently racy, print a warning via + skip_test_ rather than failing outright. + Reported by Jim Meyering. + +2009-09-07 Jim Meyering + + tail: syntax-only: use "false", rather than equivalent, 0 + * src/tail.c (record_open_fd): Initialize "->ignore" to false, not 0. + + tail: ignore -f for piped-stdin, as POSIX requires + * src/tail.c (main): Tailing a pipe "forever" is not useful, + and POSIX specifies that tail ignore the -f when there is no + file argument and stdin is a FIFO or pipe. So we do that. + In addition, GNU tail excludes "-" arguments from the list of files + to tail forever, when the associated file descriptor is connected + to a FIFO or pipe. Before this change, ":|tail -f" would hang. + Reported by Ren Yang and Ulrich Drepper. + * tests/tail-2/pipe-f: Test for this. + * tests/tail-2/pipe-f2: Ensure tail doesn't exit early for a fifo. + * tests/Makefile.am (TESTS): Add these tests. + * NEWS (POSIX conformance): Mention it. + +2009-09-07 Pádraig Brady + + tests: tail-2/flush-initial should not rely on stdbuf + * tests/tail-2/flush-initial: stdbuf is not built on all systems. + In any case it's redundant since stdout will automatically be buffered + since we're redirecting to file. So just call tail without using stdbuf. + +2009-09-07 Jim Meyering + + tail: don't give up on inotify mode for an already-ignored "-" + * src/tail.c (main): Adjust today's change to honor the + F[i].ignore flag that may have been set in tail_file. + + tests: misc/cat-buf: clean up syntax + * tests/misc/cat-buf: Don't suppress dd's stderr. + Remove useless quotes. + + tests: ls/color-clear-to-eol: append NL to accommodate old sed + * tests/ls/color-clear-to-eol: Some vendor sed programs fail + to operate on lines that are not NL-terminated. + This affects at least Solaris 10's /bin/sed. + Reported by Pádraig Brady. + + tests: tail-2/infloop-1: avoid rare test failure on a busy system + * tests/tail-2/infloop-1: Sleep 3 seconds, not 1, but in increments + of 0.1 second. Before, this test would fail ~1 time in 20 via + "make -j9 check" on a quad-core system. + Correct comment. + + build: update gnulib submodule to latest + + doc: tweak NEWS + * NEWS (dd): Tweak wording. + Two blank lines between sections. + + tail -f: handle "-"/stdin once again + * src/tail.c (main) [HAVE_INOTIFY]: When stdin (i.e., "-", or no args, + but not /dev/stdin) is specified on the command line, don't use inotify. + Reported by Bill Brelsford in . + * tests/tail-2/follow-stdin: New file. Test for this. + * tests/Makefile.am (TESTS): Add the test. + * NEWS (Bug fixes): Mention it. + This bug was introduced in coreutils-7.5 via commit ae494d4b, + 2009-06-02, "tail: use inotify if it is available". + +2009-09-06 Jim Meyering + + tests: tail-2/flush-initial: correct race avoidance code + * tests/tail-2/flush-initial: Wait for the file to be nonempty, + not for the process. Based on a suggestion from Pádraig Brady. + + tests: ls-misc: don't let a bogus umask cause test failure + * tests/misc/ls-misc: Set umask to 022. A umask setting permitting + world-write access, e.g., umask o+w, would cause this test to fail. + Report by Mathias Brodala and analysis by Tom Fitzhenry in + . + + tail: flush initial output before possibly blocking + * src/tail.c (main): Flush any output from tail_file, + before calling tail_forever_inotify, which can block. + * tests/tail-2/flush-initial: New file. Test for the bug. + * tests/Makefile.am (TESTS): Add tail-2/flush-initial. + * NEWS (Bug fixes): Mention it. + This bug was introduced in coreutils-7.5 via commit ae494d4b, + 2009-06-02, "tail: use inotify if it is available". + +2009-09-05 Jim Meyering + + maint: remove unused file: lib/fdopendir-glibc.c + * lib/fdopendir-glibc.c: Remove unused file. + + 2009-09-05 Jim Meyering + + tests: ls/stat-vs-dirent: avoid spurious test failure + * tests/ls/stat-vs-dirent: Avoid test failure when run from a + directory whose name (or ancestor directory name) starts with ".". + +2009-09-05 Pádraig Brady + + doc: make the tail --sleep-interval help less confusing + * src/tail.c (usage): I read "approximately S seconds" + as "approximately 5 seconds" for approximately 5 seconds. + + maint: remove some tab indentation from copy.c + * src/copy.c (copy_internal): Remove tabs erroneously added + in commit 3346c0af. + + tests: test old tail -f method even on systems with inotify + * src/tail.c (main): Add an undocumented ---disable-inotify option + to allow disabling inotify. + * tests/tail-2/pid: Run test in both normal and "disable_inotify" modes. + * tests/tail-2/tail-n0f: Likewise. + * tests/tail-2/wait: Likewise. + * tests/tail-2/append-only: Likewise. + +2009-09-05 Jim Meyering + + build: update gnulib submodule to latest + +2009-09-05 Petr Salinger + + stty: use TAB0, TAB1, and TAB2 only if defined + * src/stty.c (mode_info) [TAB0, TAB1, TAB2]: Guard each + entry with #ifdef. Required for GNU/kFreeBSD. + Reported by Petr Salinger in http://bugs.debian.org/520368. + +2009-09-05 Eric Blake + + build: update from gnulib + * gnulib: Update submodule to latest. + +2009-09-04 Eric Blake + + ln: add comments related to POSIX 2008 + * src/ln.c (ENABLE_HARD_LINK_TO_SYMLINK_WARNING): Delete. + (do_link): Update comments per POSIX; add FIXME for -L, -P. + + mv, cp: tweak LINK_FOLLOWS_SYMLINKS logic + * gnulib: Update to latest gnulib. + * src/copy.c (copy_internal): Adjust comment in light of POSIX + 2008, and deal with macro now being tri-state. + +2009-09-04 Petr Salinger + + tests: fix a tail-2/pid failure on GNU/kFreeBSD + * tests/tail-2/wait: Increase the file name recheck frequency to + fix a failure on systems without inotify and a file timestamp precision + of 1 second (like GNU/kFreeBSD). + +2009-09-04 Pádraig Brady + + tests: fix a failure when running tail-2/wait as root + * tests/tail-2/wait: Silently skip a portion of the test + when running as root, rather than failing the whole test. + This regression was introduced with commit 84b5844d, 2009-09-03, + "tests: simplify and fix a race in 2 tail --follow tests". + +2009-09-04 Mike Frysinger + + build: fix libcap configure flag handling + * m4/jm-macros.m4 (coreutils_MACROS): The code to handle configure-time + enabling or disabling of libcap support was broken. It would treat any + libcap configure option as --disable-libcap because it doesn't check + $enableval at all. This change makes sure we do the sane thing: + --disable-libcap -> disable and don't run any tests + --enable-libcap -> run tests and fail if not found + default -> run tests and warn if not found + +2009-09-03 Jim Meyering + + df: don't fail due to an unreadable argument + * src/df.c (main): If open or fstat fails when we're trying to ensure + that all arg-partitions are automounted, fall back on using stat. + Inspired by the report and patch from Olivier Fourdan in + http://bugzilla.redhat.com/520630. + * NEWS (Bug fixes): Mention it. + * tests/df/unreadable: New test for the above. + * tests/Makefile.am (TESTS): Add df/unreadable. + The bug was introduced in coreutils-7.3 via commit dbd17157, + 2009-04-28, "df: use open(2), not stat, to trigger automounting". + +2009-09-03 Kamil Dudka + + doc: install -C: fix bug in the texi documentation + * doc/coreutils.texi: Move the documentation for install --compare (-C) + from the section on fmt to that for install. + Reported by Florian Schlichting. + +2009-09-03 Pádraig Brady + + tests: simplify and fix a race in 2 tail --follow tests + * tests/tail-2/pid: Use the timeout command to determine process + longevity, rather than querying /proc/$pid/status. + The latter was racy in any case when inotify is used, as then + tail wakes up periodically even for unchanging files therefore + causing the check for "S (sleeping)" state to fail intermittently. + * tests/tail-2/wait: Likewise. + +2009-09-03 Ondřej Vašík + + cp: don't leak resources for each xattr preservation failure + * src/copy.c (copy_reg): Don't return from the function after an + unsuccessful and required preservation of extended attributes. + This resulted in leaking the copy buffer and file descriptors. + * NEWS (Bug fixes): Mention the fix. + The bug was introduced in coreutils-7.1 via commit 0889381c, 2009-01-23, + "cp/mv: add xattr support". + +2009-09-01 Pádraig Brady + + chcon, chmod, chgrp, chown, du: report fts_close failure + * src/du.c (du_files): Don't fail silently upon fts_close failure. + * src/chcon.c (process_files): Likewise. + * src/chmod.c (process_files): Likewise. + * src/chown-core.c (chown_files): Likewise. + +2009-09-01 Jim Meyering + + build: update from gnulib + * gnulib: Update submodule to latest. + + chcon, chmod, chgrp, chown, du: do not ignore fts_close failure + This is probably never visible, but who knows... + * src/chcon.c (process_files): Don't ignore fts_close failure. + * src/chmod.c (process_files): Likewise. + * src/chown-core.c (chown_files): Likewise. + * src/du.c (du_files): Likewise. + + maint: du: remove unnecessary initialization + * src/du.c (main): Don't set "skip_file" unnecessarily. + + maint: chown, chgrp, chmod, chcon: remove unnecessary initialization + * src/chown-core.c: Include "ignore-value.h". + (change_file_owner): Don't set "ent" only to ignore it. + * src/chcon.c (process_file): Likewise. + * src/chmod.c: Include "ignore-value.h". + (process_file): Don't set "ent" only to ignore it. + After diagnosing root-dev/ino failure, return false immediately: + Now that we don't set "ent" we must be sure not to use it uninitialized, + and there's no point in issuing --verbose-related output in this case. + + maint: shred: remove unnecessary initialization + * src/shred.c (genpattern): Value stored to "n" is never used. + + maint: dd: remove unnecessary initialization + * src/dd.c (skip): Remove set-but-never-used variable, soffset. + + maint: tail: remove unnecessary initialization + * src/tail.c (tail_bytes): Don't compute "diff" twice. + + maint: mbsalign.c: remove unnecessary assignment + * gl/lib/mbsalign.c (mbsalign): Remove assignment, the result of which + is never used. + +2009-09-01 Pádraig Brady + + timeout: remove a redundant assignment + * src/timeout.c (main): While keeping argc and argv in + sync may be marginally useful, it is redundant to update argc, + so just remove that to suppress the clang warning. + + timeout: defensive handling of all wait() errors + * src/timeout.c (main): Handle all possible cases of unexpected + failures from wait(). This was prompted by the clang tool reporting + the possible non-initialization of the status variable. + +2009-09-01 Jim Meyering + + ls -i: print consistent inode numbers also for mount points + On most unix- and linux-based kernels, ls -i DIR_CONTAINING_MOUNT_POINT + would print the wrong inode number for any entry that is a mount point. + It would do that by relying on readdir's dirent.d_ino values, while + most readdir implementations return the inode number of the underlying, + inaccessible directory. Thus, it is not consistent with what you'd + get when applying stat to the same entry. This bug led to surprising + results like "ls -i" and "ls -i --color" printing different numbers (ls + must usually "stat" a file to colorize its name). This change makes it + so that on offending systems, ls must stat non-command-line-arguments + for which otherwise it would be able to use "for free" dirent.d_ino + values. Regardless of this change, ls is already required to stat every + command-line argument. Note: versions of GNU ls prior to coreutils-6.0 + did not perform the invalid optimization, and hence always printed + correct inode numbers. Thus, for the sake of correctness, ls -i is + forgoing the readdir optimization, for any kernel (including linux!) + with POSIX-nonconforming readdir. Note that currently, only Cygwin has + been agile enough to conform. + + * src/ls.c (RELIABLE_D_INO): Define. + (print_dir): Use it. + For plenty of discussion, see this long thread: + http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14020 + This bug was introduced by the 2006-02-26 commit, 33eb3efe: + "In ls, avoid calling stat for --inode (-i), when possible." + * tests/ls/readdir-mountpoint-inode: New test. + * tests/Makefile.am (TESTS): Add it. + * tests/ls/stat-vs-dirent: Don't suppress failure of this test, + now that ls -i is fixed. Though note that it doesn't test well, + since it compares only the always-stat'd command-line arguments. + * NEWS (Bug fixes): Mention it. + +2009-08-31 Jim Meyering + + maint: revert my stdbuf change: the result didn't even compile + This reverts commit c1e158489d88bad418d52ceadf37af0b6f5b2112. + +2009-08-30 Jim Meyering + + maint: stdbuf: move a declaration; no-semantic-change + * src/stdbuf.c (set_program_path): Move a declaration down into + the scope where it's used. + + build: quiet "make check" in src/ + * src/Makefile.am (check-duplicate-no-install): Use $(AM_V_GEN). + (check-README): Likewise. And $(AM_V_at). + + doc: cp: update note on preserving symlink time stamps + * doc/coreutils.texi (cp invocation): Now, we *do* preserve time + stamps on symlinks, when possible. + + build: update bootstrap from gnulib + * bootstrap: Merge from gnulib. + +2009-08-30 Pádraig Brady + + tests: don't misbehave if $TMPDIR contains spaces + * tests/misc/xattr: Add quotes. + * tests/mv/acl: Likewise. + * tests/mv/backup-is-src: Likewise. + * tests/mv/hard-link-1: Likewise. + * tests/mv/leak-fd: Likewise. + * tests/mv/mv-special-1: Likewise. + * tests/mv/part-fail: Likewise. + * tests/mv/part-hardlink: Likewise. + * tests/mv/part-rename: Likewise. + * tests/mv/part-symlink: Likewise. + * tests/mv/partition-perm: Likewise. + * tests/mv/sticky-to-xpart: Likewise. + +2009-08-29 Jim Meyering + + tests: other-fs-tmpdir: don't misbehave for quote-unfriendly $TMPDIR + * tests/other-fs-tmpdir: Quote uses of variables that might expand + to strings containing e.g., whitespace. + + build: update from gnulib + * gnulib: Update submodule to latest. + + tests: move a coreutils-specific test from maint.mk to Makefile.am + * Makefile.am (distcheck-hook): Make taint-distcheck here, since it's + no longer done via maint.mk. + + tests: cp/reflink-auto guard against a pathological $TMPDIR + * tests/cp/reflink-auto: Add quotes. + +2009-08-29 Pádraig Brady + + cp --reflink: preserve attributes on cloned files if asked + * src/copy.c (copy_reg): When cloning only skip the data copying + * tests/cp/reflink-perm: New test to check times and modes copied + * tests/Makefile.am: Reference the new test + * NEWS: Mention the fix + + cp --reflink: add an "auto" parameter to fall back to a normal copy + * doc/coreutils.texi (cp invocation): Document the new + "auto" and "always" options to --reflink. + * src/copy.c (copy_reg): Fall back to a standard copy + when reflink() is not supported and --reflink=auto specified. + * src/copy.h [struct cp_options] (reflink): Change type s/bool/enum/. + * src/cp.c (usage): Describe the --reflink={always,auto} options + and expand a little on what --reflink does. + (main): parse the new parameters to --reflink and allow all + --sparse options with --reflink=auto. + * src/install.c (cp_option_init): Init the enum instead of bool. + * src/mv.c (cp_option_init): Likewise. + * tests/cp/reflink-auto: A new test for falling back to normal copy. + * tests/Makefile.am: Reference the new test. + * NEWS: Mention the new feature. + + stdbuf: fix a small typo in --help output + * src/stdbuf.c (usage): s/then/the/ + +2009-08-28 Eric Blake + + build: avoid unused variable warnings on cygwin + * src/copy.c (clone_file, copy_attr_by_fd, copy_attr_by_name): + Mark up unused variables. + * src/remove.c (dirent_inode_sort_may_be_useful): Likewise. + + dd: detect closed stderr + * src/dd.c (maybe_close_stdout): Always flush stderr; regression + introduced in commit 381e69ea. + * tests/misc/close-stdout (p): Use consistent style. + * tests/dd/stderr: New test, borrowing from misc/close-stdout. + * tests/Makefile.am (TESTS): Run it. + * NEWS: Mention this. + +2009-08-28 Jim Meyering + + maint: ignore only man/*.1, not all *.1 files + * .gitignore: Ignore *.1 only in man/ + +2009-08-27 Jim Meyering + + build: prefix a few rules with $(AM_V_GEN) + * Makefile.am (.version, dist-hook, gen-ChangeLog): Use $(AM_V_GEN) + and $(AM_V_at), so that automake's silent-rules option (make V=1/V=0) + now controls whether the commands are printed at build time. + (THANKS-to-translators, check-ls-dircolors): Likewise. + +2009-08-26 Jim Meyering + + build: stop earlier if touching ChangeLog fails + * bootstrap.conf: Exit right away if touching ChangeLog fails. + Otherwise, the touch failure message is buried under configure output. + + tests: mkdir/selinux: avoid spurious failure on some SELinux systems + * tests/test-lib.sh (require_selinux_enforcing_): New function. + * tests/mkdir/selinux: Use it. + Otherwise, this test would fail on Rawhide with SELinux disabled. + + tests: tail-2/assert: avoid risk of race condition + * tests/tail-2/assert: Avoid spurious failure due to race condition. + Rather than sleeping for 1 second and crossing fingers, + wait explicitly for backgrounded tail process to start. + Otherwise, this test would fail under heavy load. + +2009-08-25 Jim Meyering + + maint: ensure we don't embed Emacs indent-tabs-mode setting lines + Now that we prohibit indentation via TABs, there's no need for + Emacs indent-tabs-mode setting lines, so prohibit those, too. + * cfg.mk (sc_prohibit_emacs__indent_tabs_mode__setting): New rule. + + maint: remove Local Variables: indent-tabs-mode: nil from all sources + * src/getlimits.c: Likewise. + * src/group-list.c: Likewise. + * src/groups.c: Likewise. + * src/mktemp.c: Likewise. + * src/setuidgid.c: Likewise. + * src/stdbuf.c: Likewise. + * src/timeout.c: Likewise. + * src/truncate.c: Likewise. + * gl/lib/mbsalign.c: Likewise. + * tests/test-lib.sh: Likewise. + * bootstrap: Likewise. + * README-hacking: Likewise. + + doc: HACKING: mention the new space-only indentation policy + + maint: teach "make syntax-check" the space-only indentation rule + * cfg.mk (sc_prohibit_tab_based_indentation): New rule. + * .x-sc_prohibit_tab_based_indentation: New file. + * Makefile.am (syntax_check_exceptions): Add file, + .x-sc_prohibit_tab_based_indentation. + + global: convert indentation-TABs to spaces + Transformed via this shell code: + t=$'\t' + git ls-files \ + | grep -vE '(^|/)((GNU)?[Mm]akefile|ChangeLog)|\.(am|mk)$' \ + | grep -vE 'tests/pr/|help2man' \ + | xargs grep -lE "^ *$t" \ + | xargs perl -MText::Tabs -ni -le \ + '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_' + +2009-08-24 Jim Meyering + + cp: ignore obscure failure to preserve symlink time stamps, + ...when run on a kernel older than what was implied by headers and + libraries tested at configure time. + * src/copy.c (utimens_symlink): Ignore failure when errno == ENOSYS. + * NEWS (Bug fixes): Mention it. + Reported by Todd Zullinger and Kamil Dudka. + Details in this thread: + http://thread.gmane.org/gmane.linux.redhat.fedora.devel/119834 + +2009-08-23 Jim Meyering + + tests: skip (don't fail) a cp test, upon mount-related failure + * tests/cp/cp-mv-enotsup-xattr: Upon a set-up failiure, rather than + failing the test with a "framework failure" diagnostic, just skip it. + Russell Whitaker reported that this test failed on slackware. + + build: update from *public* gnulib + * gnulib: Update submodule to latest. + Kamil Dudka reported that bootstrap was broken. + +2009-08-22 Jim Meyering + + build: update from gnulib + * gnulib: Update submodule to latest. + 2009-08-20 Jim Meyering + post-release administrivia + * NEWS: Add header line for next release. + * .prev-version: Record previous version. + * cfg.mk (old_NEWS_hash): Auto-update. + version 7.5 * NEWS: Record release date. diff --git a/src/bin/coreutils/Makefile.am b/src/bin/coreutils/Makefile.am index e6a880d517..6175a8eef0 100644 --- a/src/bin/coreutils/Makefile.am +++ b/src/bin/coreutils/Makefile.am @@ -49,6 +49,7 @@ syntax_check_exceptions = \ .x-sc_prohibit_atoi_atof \ .x-sc_prohibit_stat_st_blocks \ .x-sc_prohibit_strcmp \ + .x-sc_prohibit_tab_based_indentation \ .x-sc_require_config_h \ .x-sc_require_config_h_first \ .x-sc_space_tab \ @@ -97,20 +98,20 @@ rm_subst = \ BUILT_SOURCES = .version .version: - echo $(VERSION) > $@-t && mv $@-t $@ + $(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@ # Arrange so that .tarball-version appears only in the distribution # tarball, and never in a checked-out repository. # The perl substitution is to change some key uses of "rm" to "/bin/rm". # See the rm_subst comment for details. dist-hook: gen-ChangeLog - echo $(VERSION) > $(distdir)/.tarball-version - perl -pi -e '$(rm_subst)' $(distdir)/src/Makefile.in + $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version + $(AM_V_at)perl -pi -e '$(rm_subst)' $(distdir)/src/Makefile.in gen_start_date = 2008-02-08 .PHONY: gen-ChangeLog gen-ChangeLog: - if test -d .git; then \ + $(AM_V_GEN)if test -d .git; then \ $(top_srcdir)/build-aux/gitlog-to-changelog \ --since=$(gen_start_date) > $(distdir)/cl-t; \ rm -f $(distdir)/ChangeLog; \ @@ -120,11 +121,12 @@ gen-ChangeLog: ALL_RECURSIVE_TARGETS += distcheck-hook distcheck-hook: check-ls-dircolors $(MAKE) my-distcheck + $(MAKE) taint-distcheck DISTCLEANFILES = VERSION MAINTAINERCLEANFILES = THANKS-to-translators THANKS-to-translators: po/LINGUAS THANKStt.in - ( \ + $(AM_V_GEN)( \ cat $(srcdir)/THANKStt.in; \ for lang in `cat $(srcdir)/po/LINGUAS`; do \ echo http://translationproject.org/team/$$lang.html; \ @@ -135,7 +137,7 @@ THANKS-to-translators: po/LINGUAS THANKStt.in # remain in sync. .PHONY: check-ls-dircolors check-ls-dircolors: - dc=$$(sed -n '/static.*ls_codes\[/,/};'/p \ + $(AM_V_GEN)dc=$$(sed -n '/static.*ls_codes\[/,/};'/p \ $(srcdir)/src/dircolors.c \ |sed -n '/^ *"/p'|tr , '\n'|sed 's/^ *//' \ |sed -n 's/^"\(..\)"/\1/p'|sort -u); \ diff --git a/src/bin/coreutils/Makefile.in b/src/bin/coreutils/Makefile.in index 04b938b608..f1993eeaed 100644 --- a/src/bin/coreutils/Makefile.in +++ b/src/bin/coreutils/Makefile.in @@ -76,22 +76,23 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ - $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ - $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ - $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ - $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ - $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ + $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ + $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ + $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ + $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ + $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ - $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ - $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ - $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ + $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ + $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ + $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ + $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ @@ -133,37 +134,38 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ - $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ - $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/long-options.m4 \ - $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ - $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ - $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ - $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ - $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ - $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ - $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbsrtowcs.m4 \ - $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/mbswidth.m4 \ - $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memcasecmp.m4 \ - $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/memcmp.m4 \ - $(top_srcdir)/m4/memcoll.m4 $(top_srcdir)/m4/memcpy.m4 \ - $(top_srcdir)/m4/memmove.m4 $(top_srcdir)/m4/mempcpy.m4 \ - $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/memset.m4 \ - $(top_srcdir)/m4/memxfrm.m4 $(top_srcdir)/m4/mgetgroups.m4 \ - $(top_srcdir)/m4/mkancesdirs.m4 $(top_srcdir)/m4/mkdir-p.m4 \ - $(top_srcdir)/m4/mkdir-slash.m4 $(top_srcdir)/m4/mkstemp.m4 \ - $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ - $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/modechange.m4 \ - $(top_srcdir)/m4/mountlist.m4 $(top_srcdir)/m4/mpsort.m4 \ - $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/nanosleep.m4 \ - $(top_srcdir)/m4/netdb_h.m4 $(top_srcdir)/m4/netinet_in_h.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/nocrash.m4 \ - $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ - $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ - $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ - $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ - $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ + $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ + $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ + $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ + $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ + $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ + $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ + $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ + $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ + $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ + $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/memcmp.m4 $(top_srcdir)/m4/memcoll.m4 \ + $(top_srcdir)/m4/memcpy.m4 $(top_srcdir)/m4/memmove.m4 \ + $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ + $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ + $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ + $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ + $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ + $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ + $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ + $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ + $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ + $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ + $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ @@ -352,6 +354,7 @@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNULIB_ACCEPT = @GNULIB_ACCEPT@ +GNULIB_ACCEPT4 = @GNULIB_ACCEPT4@ GNULIB_ALPHASORT = @GNULIB_ALPHASORT@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ @@ -365,10 +368,15 @@ GNULIB_CONNECT = @GNULIB_CONNECT@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ +GNULIB_DUP3 = @GNULIB_DUP3@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ +GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ +GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ +GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ GNULIB_FLOORL = @GNULIB_FLOORL@ @@ -383,6 +391,7 @@ GNULIB_FREXP = @GNULIB_FREXP@ GNULIB_FREXPL = @GNULIB_FREXPL@ GNULIB_FSEEK = @GNULIB_FSEEK@ GNULIB_FSEEKO = @GNULIB_FSEEKO@ +GNULIB_FSTATAT = @GNULIB_FSTATAT@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ @@ -446,12 +455,19 @@ GNULIB_MEMCHR = @GNULIB_MEMCHR@ GNULIB_MEMMEM = @GNULIB_MEMMEM@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ +GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNODAT = @GNULIB_MKNODAT@ +GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ +GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ +GNULIB_PIPE2 = @GNULIB_PIPE2@ +GNULIB_POPEN = @GNULIB_POPEN@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -461,9 +477,11 @@ GNULIB_PUTS = @GNULIB_PUTS@ GNULIB_RANDOM_R = @GNULIB_RANDOM_R@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ +GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_RENAME = @GNULIB_RENAME@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -503,11 +521,13 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ @@ -524,6 +544,7 @@ GNULIB_WCTOB = @GNULIB_WCTOB@ GNULIB_WCWIDTH = @GNULIB_WCWIDTH@ GNULIB_WRITE = @GNULIB_WRITE@ GREP = @GREP@ +HAVE_ACCEPT4 = @HAVE_ACCEPT4@ HAVE_ALPHASORT = @HAVE_ALPHASORT@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ @@ -574,8 +595,14 @@ HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@ HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@ HAVE_DPRINTF = @HAVE_DPRINTF@ HAVE_DUP2 = @HAVE_DUP2@ +HAVE_DUP3 = @HAVE_DUP3@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ +HAVE_FACCESSAT = @HAVE_FACCESSAT@ +HAVE_FCHMODAT = @HAVE_FCHMODAT@ +HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ HAVE_FSEEKO = @HAVE_FSEEKO@ +HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ @@ -601,15 +628,22 @@ HAVE_MBSINIT = @HAVE_MBSINIT@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ +HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNODAT = @HAVE_MKNODAT@ +HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ +HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ +HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ @@ -627,7 +661,6 @@ HAVE_STPCPY = @HAVE_STPCPY@ HAVE_STPNCPY = @HAVE_STPNCPY@ HAVE_STRCASESTR = @HAVE_STRCASESTR@ HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ -HAVE_STRNDUP = @HAVE_STRNDUP@ HAVE_STRPBRK = @HAVE_STRPBRK@ HAVE_STRSEP = @HAVE_STRSEP@ HAVE_STRTOD = @HAVE_STRTOD@ @@ -639,6 +672,8 @@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ +HAVE_SYMLINK = @HAVE_SYMLINK@ +HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@ HAVE_SYS_IOCTL_H = @HAVE_SYS_IOCTL_H@ @@ -650,6 +685,7 @@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ +HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ @@ -802,6 +838,7 @@ REPLACE_CLOSE = @REPLACE_CLOSE@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ REPLACE_DUP2 = @REPLACE_DUP2@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ +REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ @@ -814,6 +851,7 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ REPLACE_GETCWD = @REPLACE_GETCWD@ @@ -830,6 +868,7 @@ REPLACE_ISNAN = @REPLACE_ISNAN@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ +REPLACE_LINK = @REPLACE_LINK@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -850,8 +889,10 @@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ REPLACE_PERROR = @REPLACE_PERROR@ +REPLACE_POPEN = @REPLACE_POPEN@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ @@ -864,10 +905,12 @@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ REPLACE_STRERROR = @REPLACE_STRERROR@ +REPLACE_STRNDUP = @REPLACE_STRNDUP@ REPLACE_STRPTIME = @REPLACE_STRPTIME@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ +REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ @@ -900,13 +943,13 @@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ -SYS_STAT_H = @SYS_STAT_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ U = @U@ UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@ UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@ +UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ USE_ACL = @USE_ACL@ @@ -1013,6 +1056,7 @@ syntax_check_exceptions = \ .x-sc_prohibit_atoi_atof \ .x-sc_prohibit_stat_st_blocks \ .x-sc_prohibit_strcmp \ + .x-sc_prohibit_tab_based_indentation \ .x-sc_require_config_h \ .x-sc_require_config_h_first \ .x-sc_space_tab \ @@ -1534,18 +1578,18 @@ install-root: check-root: cd tests && $(MAKE) $@ SUBDIRS= .version: - echo $(VERSION) > $@-t && mv $@-t $@ + $(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@ # Arrange so that .tarball-version appears only in the distribution # tarball, and never in a checked-out repository. # The perl substitution is to change some key uses of "rm" to "/bin/rm". # See the rm_subst comment for details. dist-hook: gen-ChangeLog - echo $(VERSION) > $(distdir)/.tarball-version - perl -pi -e '$(rm_subst)' $(distdir)/src/Makefile.in + $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version + $(AM_V_at)perl -pi -e '$(rm_subst)' $(distdir)/src/Makefile.in .PHONY: gen-ChangeLog gen-ChangeLog: - if test -d .git; then \ + $(AM_V_GEN)if test -d .git; then \ $(top_srcdir)/build-aux/gitlog-to-changelog \ --since=$(gen_start_date) > $(distdir)/cl-t; \ rm -f $(distdir)/ChangeLog; \ @@ -1553,8 +1597,9 @@ gen-ChangeLog: fi distcheck-hook: check-ls-dircolors $(MAKE) my-distcheck + $(MAKE) taint-distcheck THANKS-to-translators: po/LINGUAS THANKStt.in - ( \ + $(AM_V_GEN)( \ cat $(srcdir)/THANKStt.in; \ for lang in `cat $(srcdir)/po/LINGUAS`; do \ echo http://translationproject.org/team/$$lang.html; \ @@ -1565,7 +1610,7 @@ THANKS-to-translators: po/LINGUAS THANKStt.in # remain in sync. .PHONY: check-ls-dircolors check-ls-dircolors: - dc=$$(sed -n '/static.*ls_codes\[/,/};'/p \ + $(AM_V_GEN)dc=$$(sed -n '/static.*ls_codes\[/,/};'/p \ $(srcdir)/src/dircolors.c \ |sed -n '/^ *"/p'|tr , '\n'|sed 's/^ *//' \ |sed -n 's/^"\(..\)"/\1/p'|sort -u); \ diff --git a/src/bin/coreutils/NEWS b/src/bin/coreutils/NEWS index 601d73251c..fdc42818f8 100644 --- a/src/bin/coreutils/NEWS +++ b/src/bin/coreutils/NEWS @@ -1,5 +1,72 @@ GNU coreutils NEWS -*- outline -*- +* Noteworthy changes in release 7.6 (2009-09-11) [stable] + +** Bug fixes + + cp, mv now ignore failure to preserve a symlink time stamp, when it is + due to their running on a kernel older than what was implied by headers + and libraries tested at configure time. + [bug introduced in coreutils-7.5] + + cp --reflink --preserve now preserves attributes when cloning a file. + [bug introduced in coreutils-7.5] + + cp --preserve=xattr no longer leaks resources on each preservation failure. + [bug introduced in coreutils-7.1] + + dd now exits with non-zero status when it encounters a write error while + printing a summary to stderr. + [bug introduced in coreutils-6.11] + + dd cbs=N conv=unblock would fail to print a final newline when the size + of the input was not a multiple of N bytes. + [the non-conforming behavior dates back to the initial implementation] + + df no longer requires that each command-line argument be readable + [bug introduced in coreutils-7.3] + + ls -i now prints consistent inode numbers also for mount points. + This makes ls -i DIR less efficient on systems with dysfunctional readdir, + because ls must stat every file in order to obtain a guaranteed-valid + inode number. [bug introduced in coreutils-6.0] + + tail -f (inotify-enabled) now flushes any initial output before blocking. + Before, this would print nothing and wait: stdbuf -o 4K tail -f /etc/passwd + Note that this bug affects tail -f only when its standard output is buffered, + which is relatively unusual. + [bug introduced in coreutils-7.5] + + tail -f once again works with standard input. inotify-enabled tail -f + would fail when operating on a nameless stdin. I.e., tail -f < /etc/passwd + would say "tail: cannot watch `-': No such file or directory", yet the + relatively baroque tail -f /dev/stdin < /etc/passwd would work. Now, the + offending usage causes tail to revert to its conventional sleep-based + (i.e., not inotify-based) implementation. + [bug introduced in coreutils-7.5] + +** Portability + + ln, link: link f z/ would mistakenly succeed on Solaris 10, given an + existing file, f, and nothing named "z". ln -T f z/ has the same problem. + Each would mistakenly create "z" as a link to "f". Now, even on such a + system, each command reports the error, e.g., + link: cannot create link `z/' to `f': Not a directory + +** New features + + cp --reflink accepts a new "auto" parameter which falls back to + a standard copy if creating a copy-on-write clone is not possible. + +** Changes in behavior + + tail -f now ignores "-" when stdin is a pipe or FIFO. + tail-with-no-args now ignores -f unconditionally when stdin is a pipe or FIFO. + Before, it would ignore -f only when no file argument was specified, + and then only when POSIXLY_CORRECT was set. Now, :|tail -f - terminates + immediately. Before, it would block indefinitely. + + * Noteworthy changes in release 7.5 (2009-08-20) [stable] ** Bug fixes diff --git a/src/bin/coreutils/THANKS b/src/bin/coreutils/THANKS index bd078db1f7..c6655eb785 100644 --- a/src/bin/coreutils/THANKS +++ b/src/bin/coreutils/THANKS @@ -78,6 +78,7 @@ Bernhard Rosenkraenzer bero@redhat.de Bernhard Voelker bernhard.voelker@siemens-enterprise.com Bert Deknuydt Bert.Deknuydt@esat.kuleuven.ac.be Bert Wesarg bert.wesarg@googlemail.com +Bill Brelsford wb@k2di.net Bill Peters peters@gaffel.as.arizona.edu Bjorn Helgaas helgaas@rsn.hp.com Bob McCracken kerouac@ravenet.com @@ -185,6 +186,7 @@ Felix Rauch Valenti frauch@cse.unsw.edu.au Ferdinand fw@scenic.mine.nu Fletcher Mattox fletcher@cs.utexas.edu Florent Bayle florent@sarcelle.net +Florian Schlichting fschlich@cis.fu-berlin.de Florin Iucha fiucha@hsys.mic.ro Francesco Montorsi fr_m@hotmail.com François Pinard pinard@iro.umontreal.ca @@ -385,6 +387,7 @@ Matthew Swift swift@alum.mit.edu Matthew Woehlke mw_triad@users.sourceforge.net Matthias Urlichs smurf@noris.de Matti Aarnio matti.aarnio@zmailer.org +Mathias Brodala info@noctus.net Mattias Wadenstein maswan@acc.umu.se Max Chang maxchang@ucla.edu Meelis Roos mroos@tartu.cyber.ee @@ -439,6 +442,7 @@ Olatunji Oluwabukunmi Ruwase tjruwase@stanford.edu Olav Morkrid olav@funcom.com Ole Laursen olau@hardworking.dk Oliver Kiddle okiddle@yahoo.co.uk +Olivier Fourdan ofourdan@redhat.com Ørn E. Hansen oehansen@daimi.aau.dk Oskar Liljeblad osk@hem.passagen.se Otavio Salvador otavio@ossystems.com.br @@ -486,6 +490,7 @@ Ralph Loader loader@maths.ox.ac.uk Raul Miller moth@magenta.com Raúl Núñez de Arenas Coronado raul@pleyades.net Reuben Thomas rrt@sc3d.org +Ren Yang ryang@redhat.com Richard A Downing richard.downing@bcs.org.uk Richard Braakman dark@xs4all.nl Richard Dawe rich@phekda.freeserve.co.uk @@ -560,6 +565,7 @@ Tim Waugh twaugh@redhat Tobias Stoeckmann tobias@bugol.de Toby Peterson toby@opendarwin.org Todd A. Jacobs tjacobs@codegnome.org +Tom Fitzhenry tom@tom-fitzhenry.me.uk Tom Haynes thomas@netapp.com Tom Quinn trq@dionysos.thphys.ox.ac.uk Tomas Pospisek tpo@sourcepole.ch diff --git a/src/bin/coreutils/aclocal.m4 b/src/bin/coreutils/aclocal.m4 index 800d44a08d..359166dc74 100644 --- a/src/bin/coreutils/aclocal.m4 +++ b/src/bin/coreutils/aclocal.m4 @@ -13,8 +13,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64.16-4cdf58],, -[m4_warning([this file was generated for autoconf 2.64.16-4cdf58. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64.27-5b5d],, +[m4_warning([this file was generated for autoconf 2.64.27-5b5d. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) @@ -804,22 +804,19 @@ AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES]) # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008, 2009 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 +# serial 6 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -839,23 +836,30 @@ esac # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi + for am_try in 1 2; do + echo timestamp > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken + alias in your environment]) + fi + if test "$[2]" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + done test "$[2]" = conftest.file ) then @@ -1068,6 +1072,7 @@ m4_include([m4/config-h.m4]) m4_include([m4/cycle-check.m4]) m4_include([m4/d-ino.m4]) m4_include([m4/d-type.m4]) +m4_include([m4/dirent-safer.m4]) m4_include([m4/dirent_h.m4]) m4_include([m4/dirfd.m4]) m4_include([m4/dirname.m4]) @@ -1091,6 +1096,7 @@ m4_include([m4/fclose.m4]) m4_include([m4/fcntl-safer.m4]) m4_include([m4/fcntl_h.m4]) m4_include([m4/fd-reopen.m4]) +m4_include([m4/fdopendir.m4]) m4_include([m4/fflush.m4]) m4_include([m4/file-type.m4]) m4_include([m4/fileblocks.m4]) @@ -1099,6 +1105,7 @@ m4_include([m4/filenamecat.m4]) m4_include([m4/flexmember.m4]) m4_include([m4/float_h.m4]) m4_include([m4/fnmatch.m4]) +m4_include([m4/fopen.m4]) m4_include([m4/fpending.m4]) m4_include([m4/fpieee.m4]) m4_include([m4/fprintftime.m4]) @@ -1175,6 +1182,7 @@ m4_include([m4/lib-ld.m4]) m4_include([m4/lib-link.m4]) m4_include([m4/lib-prefix.m4]) m4_include([m4/link-follow.m4]) +m4_include([m4/link.m4]) m4_include([m4/localcharset.m4]) m4_include([m4/locale-fr.m4]) m4_include([m4/locale-ja.m4]) diff --git a/src/bin/coreutils/bootstrap b/src/bin/coreutils/bootstrap index 4b5d6497e4..4be24b6aab 100755 --- a/src/bin/coreutils/bootstrap +++ b/src/bin/coreutils/bootstrap @@ -34,7 +34,7 @@ bt_regex=`echo "$bt"| sed 's/\./[.]/g'` bt2=${bt}2 usage() { - echo >&2 "\ + cat </dev/null 2>&1; then + find_tool_res=$i + break + fi + done + fi + if test x"$find_tool_res" = x; then + echo >&2 "$0: $find_tool_name is required" + exit 1 + fi + ($find_tool_res --version /dev/null 2>&1 || { + echo >&2 "$0: cannot run $find_tool_res --version" + exit 1 + } + eval "$find_tool_envvar=\"$find_tool_res\"" + eval "export $find_tool_envvar" +} + +# Find sha1sum, named gsha1sum on MacPorts. +find_tool SHA1SUM sha1sum gsha1sum + # Override the default configuration, if necessary. # Make sure that bootstrap.conf is sourced from the current directory # if we were invoked as "sh bootstrap". @@ -420,11 +451,11 @@ update_po_files() { cksum_file="$ref_po_dir/$po.s1" if ! test -f "$cksum_file" || ! test -f "$po_dir/$po.po" || - ! ${SHA1SUM-sha1sum} -c --status "$cksum_file" \ + ! $SHA1SUM -c --status "$cksum_file" \ < "$new_po" > /dev/null; then echo "updated $po_dir/$po.po..." cp "$new_po" "$po_dir/$po.po" \ - && ${SHA1SUM-sha1sum} < "$new_po" > "$cksum_file" + && $SHA1SUM < "$new_po" > "$cksum_file" fi done } @@ -765,7 +796,3 @@ sed 's,\.\./\.\.,..,g' $m > $m-t mv -f $m-t $m echo "$0: done. Now you can run './configure'." - -# Local Variables: -# indent-tabs-mode: nil -# End: diff --git a/src/bin/coreutils/bootstrap.conf b/src/bin/coreutils/bootstrap.conf index 991e5bd45f..c2bf753cc1 100644 --- a/src/bin/coreutils/bootstrap.conf +++ b/src/bin/coreutils/bootstrap.conf @@ -130,6 +130,7 @@ gnulib_modules=" lchown lib-ignore linebuffer + link link-follow long-options lstat @@ -316,4 +317,4 @@ tar - " # Automake requires that ChangeLog exist. -touch ChangeLog +touch ChangeLog || exit 1 diff --git a/src/bin/coreutils/configure b/src/bin/coreutils/configure index 0897736411..f16d284a6b 100755 --- a/src/bin/coreutils/configure +++ b/src/bin/coreutils/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64.16-4cdf58 for GNU coreutils 7.5. +# Generated by GNU Autoconf 2.64.27-5b5d for GNU coreutils 7.6. # # Report bugs to . # @@ -551,8 +551,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='GNU coreutils' PACKAGE_TARNAME='coreutils' -PACKAGE_VERSION='7.5' -PACKAGE_STRING='GNU coreutils 7.5' +PACKAGE_VERSION='7.6' +PACKAGE_STRING='GNU coreutils 7.6' PACKAGE_BUGREPORT='bug-coreutils@gnu.org' PACKAGE_URL='http://www.gnu.org/software/coreutils/' @@ -645,6 +645,7 @@ abs_aux_dir NEXT_AS_FIRST_DIRECTIVE_SYS_IOCTL_H NEXT_SYS_IOCTL_H HAVE_SYS_IOCTL_H +HAVE_SYMLINK LOCALE_TR_UTF8 REPLACE_ISWCNTRL WCTYPE_H @@ -664,7 +665,6 @@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC TIME_H_DEFINES_STRUCT_TIMESPEC NEXT_AS_FIRST_DIRECTIVE_TIME_H NEXT_TIME_H -SYS_STAT_H NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H NEXT_SYS_STAT_H HAVE_LSTAT @@ -719,7 +719,10 @@ REPLACE_STRPTIME REPLACE_NANOSLEEP REPLACE_MKTIME REPLACE_LOCALTIME_R +UNDEFINE_STRTOK_R +REPLACE_STRTOK_R REPLACE_STRSIGNAL +REPLACE_STRNDUP REPLACE_STRERROR REPLACE_STRCASESTR REPLACE_STRSTR @@ -735,7 +738,6 @@ HAVE_STRSEP HAVE_STRPBRK HAVE_DECL_STRNLEN HAVE_DECL_STRNDUP -HAVE_STRNDUP HAVE_DECL_STRDUP HAVE_STRCHRNUL HAVE_STPNCPY @@ -784,11 +786,6 @@ NEXT_AS_FIRST_DIRECTIVE_MATH_H NEXT_MATH_H LOCALCHARSET_TESTS_ENVIRONMENT GLIBC21 -REPLACE_MKDIR -REPLACE_LSTAT -HAVE_LCHMOD -GNULIB_LSTAT -GNULIB_LCHMOD INTTYPES_H UINT64_MAX_EQ_ULONG_MAX UINT32_MAX_LT_UINTMAX_MAX @@ -876,8 +873,10 @@ HAVE_WS2TCPIP_H HAVE_SYS_SOCKET_H NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H NEXT_SYS_SOCKET_H +HAVE_ACCEPT4 HAVE_SA_FAMILY_T HAVE_STRUCT_SOCKADDR_STORAGE +GNULIB_ACCEPT4 GNULIB_SHUTDOWN GNULIB_SETSOCKOPT GNULIB_SENDTO @@ -955,7 +954,25 @@ FCNTL_H NEXT_AS_FIRST_DIRECTIVE_FCNTL_H NEXT_FCNTL_H REPLACE_OPEN +HAVE_OPENAT +GNULIB_OPENAT GNULIB_OPEN +REPLACE_MKDIR +REPLACE_LSTAT +REPLACE_FSTATAT +HAVE_MKNODAT +HAVE_MKFIFOAT +HAVE_MKDIRAT +HAVE_LCHMOD +HAVE_FSTATAT +HAVE_FCHMODAT +GNULIB_MKNODAT +GNULIB_MKFIFOAT +GNULIB_MKDIRAT +GNULIB_LSTAT +GNULIB_LCHMOD +GNULIB_FSTATAT +GNULIB_FCHMODAT LIB_EACCESS EOVERFLOW_VALUE EOVERFLOW_HIDDEN @@ -971,81 +988,87 @@ NEXT_DIRENT_H DIRENT_H HAVE_ALPHASORT HAVE_SCANDIR +HAVE_FDOPENDIR HAVE_DECL_DIRFD GNULIB_ALPHASORT GNULIB_SCANDIR +GNULIB_FDOPENDIR GNULIB_DIRFD +REPLACE_VSPRINTF +REPLACE_VSNPRINTF +REPLACE_VPRINTF +REPLACE_VFPRINTF +REPLACE_VDPRINTF +REPLACE_VASPRINTF +REPLACE_STDIO_WRITE_FUNCS +REPLACE_SPRINTF +REPLACE_SNPRINTF +REPLACE_RENAME +REPLACE_PRINTF +REPLACE_POPEN REPLACE_PERROR +REPLACE_OBSTACK_PRINTF REPLACE_GETLINE +REPLACE_FTELLO +REPLACE_FTELL +REPLACE_FSEEKO +REPLACE_FSEEK +REPLACE_FREOPEN +REPLACE_FPURGE +REPLACE_FPRINTF +REPLACE_FOPEN +REPLACE_FFLUSH +REPLACE_FCLOSE +REPLACE_DPRINTF +HAVE_VDPRINTF +HAVE_VASPRINTF +HAVE_FTELLO +HAVE_FSEEKO +HAVE_DPRINTF +HAVE_DECL_VSNPRINTF +HAVE_DECL_SNPRINTF +HAVE_DECL_OBSTACK_PRINTF HAVE_DECL_GETLINE HAVE_DECL_GETDELIM -REPLACE_FCLOSE HAVE_DECL_FPURGE -REPLACE_FPURGE -REPLACE_FFLUSH -REPLACE_FTELL -REPLACE_FTELLO -HAVE_FTELLO -REPLACE_FSEEK -REPLACE_FSEEKO -HAVE_FSEEKO -REPLACE_FREOPEN -REPLACE_FOPEN -REPLACE_OBSTACK_PRINTF -HAVE_DECL_OBSTACK_PRINTF -REPLACE_VASPRINTF -HAVE_VASPRINTF -REPLACE_VDPRINTF -HAVE_VDPRINTF -REPLACE_DPRINTF -HAVE_DPRINTF -REPLACE_VSPRINTF -REPLACE_SPRINTF -HAVE_DECL_VSNPRINTF -REPLACE_VSNPRINTF -HAVE_DECL_SNPRINTF -REPLACE_SNPRINTF -REPLACE_VPRINTF -REPLACE_PRINTF -REPLACE_VFPRINTF -REPLACE_FPRINTF -REPLACE_STDIO_WRITE_FUNCS -GNULIB_STDIO_H_SIGPIPE -GNULIB_PERROR -GNULIB_GETLINE -GNULIB_GETDELIM -GNULIB_FWRITE -GNULIB_PUTS -GNULIB_FPUTS -GNULIB_PUTCHAR -GNULIB_PUTC -GNULIB_FPUTC -GNULIB_FCLOSE -GNULIB_FPURGE -GNULIB_FFLUSH -GNULIB_FTELLO -GNULIB_FTELL -GNULIB_FSEEKO -GNULIB_FSEEK -GNULIB_FREOPEN -GNULIB_FOPEN -GNULIB_OBSTACK_PRINTF_POSIX -GNULIB_OBSTACK_PRINTF -GNULIB_VASPRINTF -GNULIB_VDPRINTF -GNULIB_DPRINTF GNULIB_VSPRINTF_POSIX GNULIB_VSNPRINTF GNULIB_VPRINTF_POSIX GNULIB_VPRINTF GNULIB_VFPRINTF_POSIX GNULIB_VFPRINTF +GNULIB_VDPRINTF +GNULIB_VASPRINTF +GNULIB_STDIO_H_SIGPIPE GNULIB_SPRINTF_POSIX GNULIB_SNPRINTF +GNULIB_RENAME +GNULIB_PUTS +GNULIB_PUTCHAR +GNULIB_PUTC GNULIB_PRINTF_POSIX GNULIB_PRINTF +GNULIB_POPEN +GNULIB_PERROR +GNULIB_OBSTACK_PRINTF_POSIX +GNULIB_OBSTACK_PRINTF +GNULIB_GETLINE +GNULIB_GETDELIM +GNULIB_FWRITE +GNULIB_FTELLO +GNULIB_FTELL +GNULIB_FSEEKO +GNULIB_FSEEK +GNULIB_FREOPEN +GNULIB_FPUTS +GNULIB_FPUTC +GNULIB_FPURGE GNULIB_FPRINTF_POSIX GNULIB_FPRINTF +GNULIB_FOPEN +GNULIB_FFLUSH +GNULIB_FCLOSE +GNULIB_DPRINTF HAVE_WINSOCK2_H SYS_IOCTL_H SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS @@ -1056,19 +1079,25 @@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS UNISTD_H_HAVE_WINSOCK2_H REPLACE_WRITE REPLACE_LSEEK +REPLACE_LINK REPLACE_LCHOWN REPLACE_GETPAGESIZE REPLACE_GETCWD +REPLACE_FCHOWNAT REPLACE_FCHDIR REPLACE_DUP2 REPLACE_CLOSE REPLACE_CHOWN +HAVE_UNLINKAT HAVE_SYS_PARAM_H HAVE_OS_H HAVE_DECL_GETLOGIN_R HAVE_DECL_ENVIRON +HAVE_SYMLINKAT HAVE_SLEEP +HAVE_READLINKAT HAVE_READLINK +HAVE_PIPE2 HAVE_LINK HAVE_GETUSERSHELL HAVE_GETPAGESIZE @@ -1077,13 +1106,20 @@ HAVE_GETDTABLESIZE HAVE_GETDOMAINNAME HAVE_FTRUNCATE HAVE_FSYNC +HAVE_FCHOWNAT +HAVE_FACCESSAT HAVE_EUIDACCESS +HAVE_DUP3 HAVE_DUP2 GNULIB_WRITE +GNULIB_UNLINKAT GNULIB_UNISTD_H_SIGPIPE GNULIB_UNISTD_H_GETOPT +GNULIB_SYMLINKAT GNULIB_SLEEP +GNULIB_READLINKAT GNULIB_READLINK +GNULIB_PIPE2 GNULIB_LSEEK GNULIB_LINK GNULIB_LCHOWN @@ -1096,9 +1132,12 @@ GNULIB_GETDOMAINNAME GNULIB_GETCWD GNULIB_FTRUNCATE GNULIB_FSYNC +GNULIB_FCHOWNAT GNULIB_FCHDIR +GNULIB_FACCESSAT GNULIB_EUIDACCESS GNULIB_ENVIRON +GNULIB_DUP3 GNULIB_DUP2 GNULIB_CLOSE GNULIB_CHOWN @@ -1117,6 +1156,7 @@ HAVE_SETENV HAVE_RPMATCH HAVE_RANDOM_R HAVE_REALLOC_POSIX +HAVE_MKOSTEMP HAVE_MKDTEMP HAVE_MALLOC_POSIX HAVE_GETSUBOPT @@ -1130,6 +1170,7 @@ GNULIB_RPMATCH GNULIB_RANDOM_R GNULIB_PUTENV GNULIB_MKSTEMP +GNULIB_MKOSTEMP GNULIB_MKDTEMP GNULIB_GETSUBOPT GNULIB_GETLOADAVG @@ -1860,7 +1901,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures GNU coreutils 7.5 to adapt to many kinds of systems. +\`configure' configures GNU coreutils 7.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1930,7 +1971,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU coreutils 7.5:";; + short | recursive ) echo "Configuration of GNU coreutils 7.6:";; esac cat <<\_ACEOF @@ -2063,8 +2104,8 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU coreutils configure 7.5 -generated by GNU Autoconf 2.64.16-4cdf58 +GNU coreutils configure 7.6 +generated by GNU Autoconf 2.64.27-5b5d Copyright (C) 2009 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation @@ -2762,8 +2803,8 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by GNU coreutils $as_me 7.5, which was -generated by GNU Autoconf 2.64.16-4cdf58. Invocation command line was +It was created by GNU coreutils $as_me 7.6, which was +generated by GNU Autoconf 2.64.27-5b5d. Invocation command line was $ $0 $@ @@ -3047,10 +3088,13 @@ as_fn_append ac_func_list " btowc" as_fn_append ac_header_list " sys/param.h" as_fn_append ac_func_list " canonicalize_file_name" as_fn_append ac_func_list " resolvepath" +as_fn_append ac_func_list " chown" as_fn_append ac_header_list " sys/socket.h" as_fn_append ac_header_list " dirent.h" +as_fn_append ac_func_list " fdopendir" as_fn_append ac_func_list " dup2" as_fn_append ac_header_list " errno.h" +as_fn_append ac_func_list " faccessat" as_fn_append ac_header_list " libgen.h" as_fn_append ac_func_list " fchdir" as_fn_append ac_header_list " fcntl.h" @@ -3073,7 +3117,6 @@ as_fn_append ac_header_list " sys/vfs.h" as_fn_append ac_header_list " sys/fs_types.h" as_fn_append ac_func_list " ftruncate" as_fn_append ac_func_list " lchmod" -as_fn_append ac_func_list " fdopendir" as_fn_append ac_func_list " fstatfs" as_fn_append ac_header_list " netdb.h" as_fn_append ac_header_list " netinet/in.h" @@ -3093,6 +3136,8 @@ as_fn_append ac_header_list " iconv.h" as_fn_append ac_header_list " stdint.h" as_fn_append ac_header_list " wchar.h" as_fn_append ac_header_list " inttypes.h" +as_fn_append ac_func_list " link" +as_fn_append ac_func_list " readlink" as_fn_append ac_func_list " lstat" as_fn_append ac_header_list " math.h" as_fn_append ac_func_list " mbsinit" @@ -3107,7 +3152,6 @@ as_fn_append ac_func_list " alarm" as_fn_append ac_header_list " sys/statvfs.h" as_fn_append ac_header_list " sys/select.h" gl_printf_safe=yes -as_fn_append ac_func_list " readlink" as_fn_append ac_header_list " utmp.h" as_fn_append ac_header_list " utmpx.h" as_fn_append ac_func_list " utmpname" @@ -3127,6 +3171,7 @@ as_fn_append ac_header_list " stdio.h" as_fn_append ac_header_list " stdlib.h" as_fn_append ac_func_list " tzset" as_fn_append ac_header_list " string.h" +as_fn_append ac_func_list " strndup" as_fn_append ac_header_list " sys/stat.h" as_fn_append ac_header_list " time.h" as_fn_append ac_func_list " pipe" @@ -3140,6 +3185,7 @@ as_fn_append ac_func_list " vasnprintf" as_fn_append ac_func_list " wcrtomb" as_fn_append ac_func_list " iswcntrl" as_fn_append ac_func_list " wcwidth" +as_fn_append ac_func_list " symlink" as_fn_append ac_header_list " sys/wait.h" as_fn_append ac_header_list " sys/ioctl.h" as_fn_append ac_func_list " wctob" @@ -3361,9 +3407,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } -# Just in case -sleep 1 -echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -3383,23 +3426,30 @@ esac # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error "ls -t appears to fail. Make sure there is not a broken -alias in your environment" "$LINENO" 5 - fi + for am_try in 1 2; do + echo timestamp > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error "ls -t appears to fail. Make sure there is not a broken + alias in your environment" "$LINENO" 5 + fi + if test "$2" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + done test "$2" = conftest.file ) then @@ -3702,7 +3752,7 @@ fi # Define the identity of the package. PACKAGE='coreutils' - VERSION='7.5' + VERSION='7.6' cat >>confdefs.h <<_ACEOF @@ -4147,24 +4197,22 @@ done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include + int main () { -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out" +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: @@ -4226,10 +4274,10 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } if test -z "$ac_file"; then : - $as_echo "$as_me: failed program was:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 @@ -4237,51 +4285,18 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { as_fn_set_status 77 as_fn_error "C compiler cannot create executables See \`config.log' for more details." "$LINENO" 5; }; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" @@ -4321,6 +4336,65 @@ $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if test "${ac_cv_objext+set}" = set; then : @@ -6373,6 +6447,7 @@ else int main () { + #if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__ neither MSDOS nor Windows #endif @@ -6406,6 +6481,7 @@ else int main () { + #if defined __CYGWIN__ drive letters are always absolute #endif @@ -6827,6 +6903,7 @@ $as_echo "$gl_cv_func_malloc_posix" >&6; } GNULIB_GETLOADAVG=0; GNULIB_GETSUBOPT=0; GNULIB_MKDTEMP=0; + GNULIB_MKOSTEMP=0; GNULIB_MKSTEMP=0; GNULIB_PUTENV=0; GNULIB_RANDOM_R=0; @@ -6841,6 +6918,7 @@ $as_echo "$gl_cv_func_malloc_posix" >&6; } HAVE_GETSUBOPT=1; HAVE_MALLOC_POSIX=1; HAVE_MKDTEMP=1; + HAVE_MKOSTEMP=1; HAVE_REALLOC_POSIX=1; HAVE_RANDOM_R=1; HAVE_RPMATCH=1; @@ -6878,9 +6956,12 @@ _ACEOF GNULIB_CHOWN=0; GNULIB_CLOSE=0; GNULIB_DUP2=0; + GNULIB_DUP3=0; GNULIB_ENVIRON=0; GNULIB_EUIDACCESS=0; + GNULIB_FACCESSAT=0; GNULIB_FCHDIR=0; + GNULIB_FCHOWNAT=0; GNULIB_FSYNC=0; GNULIB_FTRUNCATE=0; GNULIB_GETCWD=0; @@ -6893,13 +6974,20 @@ _ACEOF GNULIB_LCHOWN=0; GNULIB_LINK=0; GNULIB_LSEEK=0; + GNULIB_PIPE2=0; GNULIB_READLINK=0; + GNULIB_READLINKAT=0; GNULIB_SLEEP=0; + GNULIB_SYMLINKAT=0; GNULIB_UNISTD_H_GETOPT=0; GNULIB_UNISTD_H_SIGPIPE=0; + GNULIB_UNLINKAT=0; GNULIB_WRITE=0; HAVE_DUP2=1; + HAVE_DUP3=1; HAVE_EUIDACCESS=1; + HAVE_FACCESSAT=1; + HAVE_FCHOWNAT=1; HAVE_FSYNC=1; HAVE_FTRUNCATE=1; HAVE_GETDOMAINNAME=1; @@ -6908,19 +6996,25 @@ _ACEOF HAVE_GETPAGESIZE=1; HAVE_GETUSERSHELL=1; HAVE_LINK=1; + HAVE_PIPE2=1; HAVE_READLINK=1; + HAVE_READLINKAT=1; HAVE_SLEEP=1; + HAVE_SYMLINKAT=1; HAVE_DECL_ENVIRON=1; HAVE_DECL_GETLOGIN_R=1; HAVE_OS_H=0; HAVE_SYS_PARAM_H=0; + HAVE_UNLINKAT=1; REPLACE_CHOWN=0; REPLACE_CLOSE=0; REPLACE_DUP2=0; REPLACE_FCHDIR=0; + REPLACE_FCHOWNAT=0; REPLACE_GETCWD=0; REPLACE_GETPAGESIZE=0; REPLACE_LCHOWN=0; + REPLACE_LINK=0; REPLACE_LSEEK=0; REPLACE_WRITE=0; UNISTD_H_HAVE_WINSOCK2_H=0; @@ -7078,6 +7172,8 @@ $as_echo "#define CHOWN_MODIFIES_SYMLINK 1" >>confdefs.h fi + + GNULIB_IOCTL=0; SYS_IOCTL_H_HAVE_WINSOCK2_H=0; SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; @@ -7087,77 +7183,81 @@ $as_echo "#define CHOWN_MODIFIES_SYMLINK 1" >>confdefs.h + GNULIB_DPRINTF=0; + GNULIB_FCLOSE=0; + GNULIB_FFLUSH=0; + GNULIB_FOPEN=0; GNULIB_FPRINTF=0; GNULIB_FPRINTF_POSIX=0; + GNULIB_FPURGE=0; + GNULIB_FPUTC=0; + GNULIB_FPUTS=0; + GNULIB_FREOPEN=0; + GNULIB_FSEEK=0; + GNULIB_FSEEKO=0; + GNULIB_FTELL=0; + GNULIB_FTELLO=0; + GNULIB_FWRITE=0; + GNULIB_GETDELIM=0; + GNULIB_GETLINE=0; + GNULIB_OBSTACK_PRINTF=0; + GNULIB_OBSTACK_PRINTF_POSIX=0; + GNULIB_PERROR=0; + GNULIB_POPEN=0; GNULIB_PRINTF=0; GNULIB_PRINTF_POSIX=0; + GNULIB_PUTC=0; + GNULIB_PUTCHAR=0; + GNULIB_PUTS=0; + GNULIB_RENAME=0; GNULIB_SNPRINTF=0; GNULIB_SPRINTF_POSIX=0; + GNULIB_STDIO_H_SIGPIPE=0; + GNULIB_VASPRINTF=0; + GNULIB_VDPRINTF=0; GNULIB_VFPRINTF=0; GNULIB_VFPRINTF_POSIX=0; GNULIB_VPRINTF=0; GNULIB_VPRINTF_POSIX=0; GNULIB_VSNPRINTF=0; GNULIB_VSPRINTF_POSIX=0; - GNULIB_DPRINTF=0; - GNULIB_VDPRINTF=0; - GNULIB_VASPRINTF=0; - GNULIB_OBSTACK_PRINTF=0; - GNULIB_OBSTACK_PRINTF_POSIX=0; - GNULIB_FOPEN=0; - GNULIB_FREOPEN=0; - GNULIB_FSEEK=0; - GNULIB_FSEEKO=0; - GNULIB_FTELL=0; - GNULIB_FTELLO=0; - GNULIB_FFLUSH=0; - GNULIB_FPURGE=0; - GNULIB_FCLOSE=0; - GNULIB_FPUTC=0; - GNULIB_PUTC=0; - GNULIB_PUTCHAR=0; - GNULIB_FPUTS=0; - GNULIB_PUTS=0; - GNULIB_FWRITE=0; - GNULIB_GETDELIM=0; - GNULIB_GETLINE=0; - GNULIB_PERROR=0; - GNULIB_STDIO_H_SIGPIPE=0; - REPLACE_STDIO_WRITE_FUNCS=0; - REPLACE_FPRINTF=0; - REPLACE_VFPRINTF=0; - REPLACE_PRINTF=0; - REPLACE_VPRINTF=0; - REPLACE_SNPRINTF=0; - HAVE_DECL_SNPRINTF=1; - REPLACE_VSNPRINTF=0; - HAVE_DECL_VSNPRINTF=1; - REPLACE_SPRINTF=0; - REPLACE_VSPRINTF=0; - HAVE_DPRINTF=1; - REPLACE_DPRINTF=0; - HAVE_VDPRINTF=1; - REPLACE_VDPRINTF=0; - HAVE_VASPRINTF=1; - REPLACE_VASPRINTF=0; - HAVE_DECL_OBSTACK_PRINTF=1; - REPLACE_OBSTACK_PRINTF=0; - REPLACE_FOPEN=0; - REPLACE_FREOPEN=0; - HAVE_FSEEKO=1; - REPLACE_FSEEKO=0; - REPLACE_FSEEK=0; - HAVE_FTELLO=1; - REPLACE_FTELLO=0; - REPLACE_FTELL=0; - REPLACE_FFLUSH=0; - REPLACE_FPURGE=0; - HAVE_DECL_FPURGE=1; - REPLACE_FCLOSE=0; + HAVE_DECL_FPURGE=1; HAVE_DECL_GETDELIM=1; HAVE_DECL_GETLINE=1; + HAVE_DECL_OBSTACK_PRINTF=1; + HAVE_DECL_SNPRINTF=1; + HAVE_DECL_VSNPRINTF=1; + HAVE_DPRINTF=1; + HAVE_FSEEKO=1; + HAVE_FTELLO=1; + HAVE_VASPRINTF=1; + HAVE_VDPRINTF=1; + REPLACE_DPRINTF=0; + REPLACE_FCLOSE=0; + REPLACE_FFLUSH=0; + REPLACE_FOPEN=0; + REPLACE_FPRINTF=0; + REPLACE_FPURGE=0; + REPLACE_FREOPEN=0; + REPLACE_FSEEK=0; + REPLACE_FSEEKO=0; + REPLACE_FTELL=0; + REPLACE_FTELLO=0; REPLACE_GETLINE=0; + REPLACE_OBSTACK_PRINTF=0; REPLACE_PERROR=0; + REPLACE_POPEN=0; + REPLACE_PRINTF=0; + REPLACE_RENAME=0; + REPLACE_SNPRINTF=0; + REPLACE_SPRINTF=0; + REPLACE_STDIO_WRITE_FUNCS=0; + REPLACE_VASPRINTF=0; + REPLACE_VDPRINTF=0; + REPLACE_VFPRINTF=0; + REPLACE_VPRINTF=0; + REPLACE_VSNPRINTF=0; + REPLACE_VSPRINTF=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 @@ -7387,9 +7487,11 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h GNULIB_DIRFD=0; + GNULIB_FDOPENDIR=0; GNULIB_SCANDIR=0; GNULIB_ALPHASORT=0; HAVE_DECL_DIRFD=1; + HAVE_FDOPENDIR=1; HAVE_SCANDIR=1; HAVE_ALPHASORT=1; DIRENT_H=''; @@ -7398,6 +7500,8 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether // is distinct from /" >&5 $as_echo_n "checking whether // is distinct from /... " >&6; } if test "${gl_cv_double_slash_root+set}" = set; then : @@ -7865,6 +7969,8 @@ fi + + ac_fn_c_check_decl "$LINENO" "setregid" "ac_cv_have_decl_setregid" "$ac_includes_default" if test "x$ac_cv_have_decl_setregid" = x""yes; then : ac_have_decl=1 @@ -8042,10 +8148,30 @@ fi LIBS=$ac_save_LIBS + GNULIB_FCHMODAT=0; + GNULIB_FSTATAT=0; + GNULIB_LCHMOD=0; + GNULIB_LSTAT=0; + GNULIB_MKDIRAT=0; + GNULIB_MKFIFOAT=0; + GNULIB_MKNODAT=0; + HAVE_FCHMODAT=1; + HAVE_FSTATAT=1; + HAVE_LCHMOD=1; + HAVE_MKDIRAT=1; + HAVE_MKFIFOAT=1; + HAVE_MKNODAT=1; + REPLACE_FSTATAT=0; + REPLACE_LSTAT=0; + REPLACE_MKDIR=0; + + GNULIB_OPEN=0; - REPLACE_OPEN=0; + GNULIB_OPENAT=0; + HAVE_OPENAT=1; + REPLACE_OPEN=0; ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" if test "x$ac_cv_type_mode_t" = x""yes; then : @@ -8102,6 +8228,7 @@ if test "${ac_cv_struct_st_dm_mode+set}" = set; then : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + #include #include int @@ -8307,8 +8434,6 @@ $as_echo "$gl_cv_var_stdin_large_offset" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 $as_echo_n "checking whether lstat dereferences a symlink specified with a trailing slash... " >&6; } if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then : @@ -8392,8 +8517,10 @@ fi GNULIB_SENDTO=0; GNULIB_SETSOCKOPT=0; GNULIB_SHUTDOWN=0; + GNULIB_ACCEPT4=0; HAVE_STRUCT_SOCKADDR_STORAGE=1; HAVE_SA_FAMILY_T=1; + HAVE_ACCEPT4=1; @@ -9064,27 +9191,46 @@ if test "${gl_cv_func_getcwd_null+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : - gl_cv_func_getcwd_null=no + + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_getcwd_null="guessing yes";; + # Guess yes on Cygwin. + cygwin*) gl_cv_func_getcwd_null="guessing yes";; + # Guess yes on mingw. + mingw*) gl_cv_func_getcwd_null="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_getcwd_null="guessing no";; + esac + else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# include # include # ifndef getcwd char *getcwd (); # endif - int - main () - { + +int +main () +{ + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +/* mingw cwd does not start with '/', but getcwd does allocate. */ +#else if (chdir ("/") != 0) - exit (1); + return 1; else { char *f = getcwd (NULL, 0); - exit (! (f && f[0] == '/' && !f[1])); + return ! (f && f[0] == '/' && !f[1]); } - } +#endif + + ; + return 0; +} _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_getcwd_null=yes @@ -11720,11 +11866,8 @@ _ACEOF esac - GNULIB_LCHMOD=0; - GNULIB_LSTAT=0; - HAVE_LCHMOD=1; - REPLACE_LSTAT=0; - REPLACE_MKDIR=0; + + ac_fn_c_check_decl "$LINENO" "getc_unlocked" "ac_cv_have_decl_getc_unlocked" "$ac_includes_default" if test "x$ac_cv_have_decl_getc_unlocked" = x""yes; then : @@ -12611,7 +12754,6 @@ $as_echo "#define MBRTOWC_NUL_RETVAL_BUG 1" >>confdefs.h HAVE_STPNCPY=1; HAVE_STRCHRNUL=1; HAVE_DECL_STRDUP=1; - HAVE_STRNDUP=1; HAVE_DECL_STRNDUP=1; HAVE_DECL_STRNLEN=1; HAVE_STRPBRK=1; @@ -12627,7 +12769,10 @@ $as_echo "#define MBRTOWC_NUL_RETVAL_BUG 1" >>confdefs.h REPLACE_STRSTR=0; REPLACE_STRCASESTR=0; REPLACE_STRERROR=0; + REPLACE_STRNDUP=0; REPLACE_STRSIGNAL=0; + REPLACE_STRTOK_R=0; + UNDEFINE_STRTOK_R=0; @@ -13147,8 +13292,6 @@ $as_echo "$gl_default_posix2_version" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat accepts an empty string" >&5 $as_echo_n "checking whether lstat accepts an empty string... " >&6; } if test "${ac_cv_func_lstat_empty_string_bug+set}" = set; then : @@ -13705,6 +13848,8 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRNDUP $ac_have_decl _ACEOF + + ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default" if test "x$ac_cv_have_decl_strnlen" = x""yes; then : ac_have_decl=1 @@ -15728,6 +15873,8 @@ _ACEOF + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ungetc works on arbitrary bytes" >&5 $as_echo_n "checking whether ungetc works on arbitrary bytes... " >&6; } if test "${gl_cv_func_ungetc_works+set}" = set; then : @@ -16691,6 +16838,7 @@ $as_echo "$gl_cv_have_arbitrary_file_name_length_limit" >&6; } + if test $ac_cv_func_chown_works = no; then $as_echo "#define CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE 1" >>confdefs.h @@ -17167,6 +17315,24 @@ $as_echo "$gl_cv_next_dirent_h" >&6; } + + + + + + + gl_LIBOBJS="$gl_LIBOBJS opendir-safer.$ac_objext" + + + + +$as_echo "#define GNULIB_DIRENT_SAFER 1" >>confdefs.h + + + + + + DIRENT_H='dirent.h' @@ -17269,7 +17435,8 @@ else CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include + + #include #include int main () @@ -17412,21 +17579,30 @@ else gl_cv_func_dup2_works=no;; cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0 gl_cv_func_dup2_works=no;; + linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a + # closed fd may yield -EBADF instead of -1 / errno=EBADF. + gl_cv_func_dup2_works=no;; *) gl_cv_func_dup2_works=yes;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include - + #include int main () { -return 1 - dup2 (1, 1); +if (dup2 (1, 1) == 0) + return 1; + close (0); + if (dup2 (0, 0) != -1) + return 1; + return 0; + ; return 0; } + _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_dup2_works=yes @@ -17437,11 +17613,14 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_dup2_works" >&5 $as_echo "$gl_cv_func_dup2_works" >&6; } if test "$gl_cv_func_dup2_works" = no; then - REPLACE_DUP2=1 + + + REPLACE_DUP2=1 @@ -17452,6 +17631,7 @@ $as_echo "$gl_cv_func_dup2_works" >&6; } gl_LIBOBJS="$gl_LIBOBJS dup2.$ac_objext" + fi fi @@ -17614,6 +17794,7 @@ done + # Solaris 9 needs -lgen to get the eaccess function. # Save and restore LIBS so -lgen isn't added to it. Otherwise, *all* # programs in the package would end up linked with that potentially-shared @@ -17726,6 +17907,7 @@ done + if test $ac_cv_func_fchdir = no; then REPLACE_FCHDIR=1 @@ -17740,8 +17922,9 @@ done : -$as_echo "#define FCHDIR_REPLACEMENT 1" >>confdefs.h +$as_echo "#define REPLACE_FCHDIR 1" >>confdefs.h + REPLACE_FSTAT=1 REPLACE_OPEN=1 @@ -17791,8 +17974,59 @@ $as_echo "#define FCHDIR_REPLACEMENT 1" >>confdefs.h + REPLACE_DUP2=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS dup2.$ac_objext" + + + + DIRENT_H='dirent.h' + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open can visit directories" >&5 +$as_echo_n "checking whether open can visit directories... " >&6; } +if test "${gl_cv_func_open_directory_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_open_directory_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +return open(".", O_RDONLY); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_open_directory_works=yes +else + gl_cv_func_open_directory_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_open_directory_works" >&5 +$as_echo "$gl_cv_func_open_directory_works" >&6; } + if test "$gl_cv_func_open_directory_works" != yes; then + +$as_echo "#define REPLACE_OPEN_DIRECTORY 1" >>confdefs.h + + fi fi @@ -17988,6 +18222,41 @@ $as_echo "#define GNULIB_FCNTL_SAFER 1" >>confdefs.h + + + if test $ac_cv_func_fdopendir = no; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS openat-proc.$ac_objext" + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fdopendir.$ac_objext" + + + + DIRENT_H='dirent.h' + + HAVE_FDOPENDIR=0 + fi + + + + GNULIB_FDOPENDIR=1 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fflush works on input streams" >&5 $as_echo_n "checking whether fflush works on input streams... " >&6; } if test "${gl_cv_func_fflush_stdin+set}" = set; then : @@ -18414,6 +18683,84 @@ _ACEOF + case "$host_os" in + mingw* | pw*) + REPLACE_FOPEN=1 + gl_cv_func_fopen_slash="guessing no" + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fopen recognizes a trailing slash" >&5 +$as_echo_n "checking whether fopen recognizes a trailing slash... " >&6; } +if test "${gl_cv_func_fopen_slash+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + + case "$host_os" in + solaris2.[0-9]*) gl_cv_func_fopen_slash="guessing no" ;; + hpux*) gl_cv_func_fopen_slash="guessing no" ;; + *) gl_cv_func_fopen_slash="guessing yes" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +int main () +{ + return fopen ("conftest.sl/", "w") != NULL; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_fopen_slash=yes +else + gl_cv_func_fopen_slash=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.sl + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fopen_slash" >&5 +$as_echo "$gl_cv_func_fopen_slash" >&6; } + ;; + esac + case "$gl_cv_func_fopen_slash" in + *no) + +$as_echo "#define FOPEN_TRAILING_SLASH_BUG 1" >>confdefs.h + + REPLACE_FOPEN=1 + ;; + esac + if test $REPLACE_FOPEN = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fopen.$ac_objext" + + + + + fi + + + + GNULIB_FOPEN=1 + + + + @@ -18495,7 +18842,6 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - int main () { @@ -19217,6 +19563,7 @@ else else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + #include #include int @@ -19259,6 +19606,7 @@ else else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + #include #ifdef HAVE_SYS_PARAM_H #include @@ -19307,6 +19655,7 @@ else else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ + #include #ifdef HAVE_SYS_PARAM_H #include @@ -19358,7 +19707,7 @@ if ac_fn_c_try_cpp "$LINENO"; then : $as_echo "#define STAT_READ_FILSYS 1" >>confdefs.h - ac_fsusage_space=yes + ac_fsusage_space=yes fi rm -f conftest.err conftest.$ac_ext fi @@ -19414,7 +19763,7 @@ int main () { struct statfs t; long c = *(t.f_spare); - if (c) return 0; + if (c) return 0; ; return 0; } @@ -19578,6 +19927,18 @@ See \`config.log' for more details." "$LINENO" 5; } + GNULIB_OPENAT=1 + + + GNULIB_FCHMODAT=1 + GNULIB_FSTATAT=1 + GNULIB_MKDIRAT=1 + + + GNULIB_FCHOWNAT=1 + GNULIB_UNLINKAT=1 + + @@ -19609,7 +19970,6 @@ See \`config.log' for more details." "$LINENO" 5; } - for ac_func in fchmodat mkdirat openat @@ -19641,30 +20001,29 @@ done + gl_LIBOBJS="$gl_LIBOBJS fstatat.$ac_objext" -;; + + REPLACE_FSTATAT=1 + ;; *) - -$as_echo "#define __OPENAT_PREFIX rpl_" >>confdefs.h - + HAVE_OPENAT=0 + HAVE_UNLINKAT=0 # No known system with unlinkat but not openat + HAVE_FSTATAT=0 # No known system with fstatat but not openat : ;; esac - - # Assume we'll use the replacement function. - # The only case in which we won't is when we have fchownat, and it works. - use_replacement_fchownat=yes + if test $ac_cv_func_fchmodat != yes; then + HAVE_FCHMODAT=0 + fi + if test $ac_cv_func_mkdirat != yes; then + HAVE_MKDIRAT=0 + fi ac_fn_c_check_func "$LINENO" "fchownat" "ac_cv_func_fchownat" if test "x$ac_cv_func_fchownat" = x""yes; then : - have_fchownat=yes -else - have_fchownat=no -fi - - if test $have_fchownat = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fchownat works with AT_SYMLINK_NOFOLLOW" >&5 $as_echo_n "checking whether fchownat works with AT_SYMLINK_NOFOLLOW... " >&6; } @@ -19712,14 +20071,14 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fchownat_nofollow_works" >&5 $as_echo "$gl_cv_func_fchownat_nofollow_works" >&6; } if test $gl_cv_func_fchownat_nofollow_works = no; then : - -else - use_replacement_fchownat=no + REPLACE_FCHOWNAT=1 fi - fi +else + HAVE_FCHOWNAT=0 +fi - if test $use_replacement_fchownat = yes; then + if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then @@ -19730,9 +20089,6 @@ fi gl_LIBOBJS="$gl_LIBOBJS fchownat.$ac_objext" - -$as_echo "#define fchownat rpl_fchownat" >>confdefs.h - fi @@ -20153,8 +20509,10 @@ fi gl_abort_bug=no - case $gl_cv_func_getcwd_null in - yes) + case $gl_cv_func_getcwd_null,$host_os in + *,mingw*) + gl_cv_func_getcwd_path_max=yes;; + yes,*) @@ -20466,7 +20824,7 @@ fi esac case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max,$gl_abort_bug in - yes,yes,no) ;; + *yes,yes,no) ;; *) REPLACE_GETCWD=1 @@ -21535,11 +21893,11 @@ int main () { struct nlist x; - #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME - x.n_un.n_name = ""; - #else - x.n_name = ""; - #endif + #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME + x.n_un.n_name = ""; + #else + x.n_name = ""; + #endif ; return 0; } @@ -22773,10 +23131,11 @@ rm -f conftest* if test $gl_func_iconv_gnu = no; then iconv_flavor= case "$host_os" in - aix*) iconv_flavor=ICONV_FLAVOR_AIX ;; - irix*) iconv_flavor=ICONV_FLAVOR_IRIX ;; - hpux*) iconv_flavor=ICONV_FLAVOR_HPUX ;; - osf*) iconv_flavor=ICONV_FLAVOR_OSF ;; + aix*) iconv_flavor=ICONV_FLAVOR_AIX ;; + irix*) iconv_flavor=ICONV_FLAVOR_IRIX ;; + hpux*) iconv_flavor=ICONV_FLAVOR_HPUX ;; + osf*) iconv_flavor=ICONV_FLAVOR_OSF ;; + solaris*) iconv_flavor=ICONV_FLAVOR_SOLARIS ;; esac if test -n "$iconv_flavor"; then @@ -24713,16 +25072,88 @@ $as_echo "$gl_cv_ignore_unused_libraries" >&6; } test "$gl_cv_ignore_unused_libraries" != none && LDFLAGS="$LDFLAGS $gl_cv_ignore_unused_libraries" + + + + if test $ac_cv_func_link = no; then + HAVE_LINK=0 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS link.$ac_objext" + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether link handles trailing slash correctly" >&5 +$as_echo_n "checking whether link handles trailing slash correctly... " >&6; } +if test "${gl_cv_func_link_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + touch conftest.a + if test "$cross_compiling" = yes; then : + gl_cv_func_link_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +return !link ("conftest.a", "conftest.b/"); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_link_works=yes +else + gl_cv_func_link_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.a conftest.b +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_link_works" >&5 +$as_echo "$gl_cv_func_link_works" >&6; } + if test $gl_cv_func_link_works != yes; then + REPLACE_LINK=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS link.$ac_objext" + + fi + fi + + + + GNULIB_LINK=1 + + + gl_link_follows_symlinks=0 # assume GNU behavior + if test $ac_cv_func_readlink = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether link(2) dereferences a symlink" >&5 $as_echo_n "checking whether link(2) dereferences a symlink... " >&6; } -if test "${gl_ac_cv_func_link_follows_symlink+set}" = set; then : +if test "${gl_cv_func_link_follows_symlink+set}" = set; then : $as_echo_n "(cached) " >&6 else - # Create a regular file. - echo > conftest.file - if test "$cross_compiling" = yes; then : - gl_ac_cv_func_link_follows_symlink=yes + # Create a regular file. + echo > conftest.file + if test "$cross_compiling" = yes; then : + gl_cv_func_link_follows_symlink=unknown else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -24759,14 +25190,14 @@ else /* If the dev/inode of hard and file are the same, then the link call followed the symlink. */ - return SAME_INODE (sb_hard, sb_file) ? 0 : 1; + return SAME_INODE (sb_hard, sb_file) ? 1 : 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : - gl_ac_cv_func_link_follows_symlink=yes + gl_cv_func_link_follows_symlink=no else - gl_ac_cv_func_link_follows_symlink=no + gl_cv_func_link_follows_symlink=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext @@ -24774,14 +25205,20 @@ fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_ac_cv_func_link_follows_symlink" >&5 -$as_echo "$gl_ac_cv_func_link_follows_symlink" >&6; } - if test $gl_ac_cv_func_link_follows_symlink = yes; then - -$as_echo "#define LINK_FOLLOWS_SYMLINKS 1" >>confdefs.h - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_link_follows_symlink" >&5 +$as_echo "$gl_cv_func_link_follows_symlink" >&6; } + case $gl_cv_func_link_follows_symlink in + yes) gl_link_follows_symlinks=1 ;; + no) ;; # already defaulted to 0 + *) gl_link_follows_symlinks=-1 ;; + esac fi +cat >>confdefs.h <<_ACEOF +#define LINK_FOLLOWS_SYMLINKS $gl_link_follows_symlinks +_ACEOF + + @@ -27265,7 +27702,7 @@ int main () { struct mntent *mnt = 0; char *table = MOUNTED; - if (sizeof mnt && sizeof table) return 0; + if (sizeof mnt && sizeof table) return 0; ; return 0; } @@ -27357,8 +27794,8 @@ int main () { struct statfs *stats; - int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); - char *t = FS_TYPE (*stats); + int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); + char *t = FS_TYPE (*stats); ; return 0; } @@ -28207,6 +28644,18 @@ $as_echo "#define GNULIB_OPEN 1" >>confdefs.h + GNULIB_OPENAT=1 + + + GNULIB_FCHMODAT=1 + GNULIB_FSTATAT=1 + GNULIB_MKDIRAT=1 + + + GNULIB_FCHOWNAT=1 + GNULIB_UNLINKAT=1 + + @@ -28238,7 +28687,6 @@ $as_echo "#define GNULIB_OPEN 1" >>confdefs.h - for ac_func in fchmodat mkdirat openat @@ -28270,30 +28718,29 @@ done + gl_LIBOBJS="$gl_LIBOBJS fstatat.$ac_objext" -;; + + REPLACE_FSTATAT=1 + ;; *) - -$as_echo "#define __OPENAT_PREFIX rpl_" >>confdefs.h - + HAVE_OPENAT=0 + HAVE_UNLINKAT=0 # No known system with unlinkat but not openat + HAVE_FSTATAT=0 # No known system with fstatat but not openat : ;; esac - - # Assume we'll use the replacement function. - # The only case in which we won't is when we have fchownat, and it works. - use_replacement_fchownat=yes + if test $ac_cv_func_fchmodat != yes; then + HAVE_FCHMODAT=0 + fi + if test $ac_cv_func_mkdirat != yes; then + HAVE_MKDIRAT=0 + fi ac_fn_c_check_func "$LINENO" "fchownat" "ac_cv_func_fchownat" if test "x$ac_cv_func_fchownat" = x""yes; then : - have_fchownat=yes -else - have_fchownat=no -fi - - if test $have_fchownat = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fchownat works with AT_SYMLINK_NOFOLLOW" >&5 $as_echo_n "checking whether fchownat works with AT_SYMLINK_NOFOLLOW... " >&6; } @@ -28341,14 +28788,14 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fchownat_nofollow_works" >&5 $as_echo "$gl_cv_func_fchownat_nofollow_works" >&6; } if test $gl_cv_func_fchownat_nofollow_works = no; then : - -else - use_replacement_fchownat=no + REPLACE_FCHOWNAT=1 fi - fi +else + HAVE_FCHOWNAT=0 +fi - if test $use_replacement_fchownat = yes; then + if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then @@ -28359,9 +28806,6 @@ fi gl_LIBOBJS="$gl_LIBOBJS fchownat.$ac_objext" - -$as_echo "#define fchownat rpl_fchownat" >>confdefs.h - fi @@ -28370,6 +28814,24 @@ $as_echo "#define fchownat rpl_fchownat" >>confdefs.h + + + + + + gl_LIBOBJS="$gl_LIBOBJS openat-safer.$ac_objext" + + + + +$as_echo "#define GNULIB_OPENAT_SAFER 1" >>confdefs.h + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl5.005 or newer" >&5 $as_echo_n "checking for perl5.005 or newer... " >&6; } if test "${PERL+set}" = set; then @@ -28952,6 +29414,18 @@ fi done + ac_fn_c_check_decl "$LINENO" "program_invocation_name" "ac_cv_have_decl_program_invocation_name" "#include +" +if test "x$ac_cv_have_decl_program_invocation_name" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_PROGRAM_INVOCATION_NAME $ac_have_decl +_ACEOF + XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS --keyword='proper_name:1,\"This is a proper name. See the gettext manual, section Names.\"'" @@ -29758,7 +30232,8 @@ _ACEOF - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename is broken with a trailing slash" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename is broken with a trailing slash" >&5 $as_echo_n "checking whether rename is broken with a trailing slash... " >&6; } if test "${gl_cv_func_rename_trailing_slash_bug+set}" = set; then : $as_echo_n "(cached) " >&6 @@ -29823,9 +30298,7 @@ $as_echo "$gl_cv_func_rename_dest_exists_bug" >&6; } gl_LIBOBJS="$gl_LIBOBJS rename.$ac_objext" - -$as_echo "#define rename rpl_rename" >>confdefs.h - + REPLACE_RENAME=1 if test $gl_cv_func_rename_trailing_slash_bug = yes; then $as_echo "#define RENAME_TRAILING_SLASH_BUG 1" >>confdefs.h @@ -29840,6 +30313,10 @@ $as_echo "#define RENAME_DEST_EXISTS_BUG 1" >>confdefs.h fi + + GNULIB_RENAME=1 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename is broken with respect to destination slashes" >&5 $as_echo_n "checking whether rename is broken with respect to destination slashes... " >&6; } if test "${gl_cv_func_rename_trailing_dest_slash_bug+set}" = set; then : @@ -33129,6 +33606,11 @@ fi +$as_echo "#define GNULIB_STDLIB_SAFER 1" >>confdefs.h + + + + @@ -33441,45 +33923,29 @@ $as_echo "#define my_strftime nstrftime" >>confdefs.h + if test $ac_cv_have_decl_strndup = no; then HAVE_DECL_STRNDUP=0 fi - # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strndup" >&5 + if test $ac_cv_func_strndup = yes; then + # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strndup" >&5 $as_echo_n "checking for working strndup... " >&6; } -if test "${gl_cv_func_strndup+set}" = set; then : +if test "${gl_cv_func_strndup_works+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : - ac_fn_c_check_func "$LINENO" "strndup" "ac_cv_func_strndup" -if test "x$ac_cv_func_strndup" = x""yes; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef _AIX - too risky -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "too risky" >/dev/null 2>&1; then : - gl_cv_func_strndup=no -else - gl_cv_func_strndup=yes -fi -rm -f conftest* - -else - gl_cv_func_strndup=no -fi - + case $host_os in + aix*) gl_cv_func_strndup_works="guessing no";; + *) gl_cv_func_strndup_works="guessing yes";; + esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include + #include + #include int main () { @@ -33497,23 +33963,33 @@ main () } _ACEOF if ac_fn_c_try_run "$LINENO"; then : - gl_cv_func_strndup=yes + gl_cv_func_strndup_works=yes else - gl_cv_func_strndup=no + gl_cv_func_strndup_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strndup" >&5 -$as_echo "$gl_cv_func_strndup" >&6; } - if test $gl_cv_func_strndup = yes; then - -$as_echo "#define HAVE_STRNDUP 1" >>confdefs.h - - else - HAVE_STRNDUP=0 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strndup_works" >&5 +$as_echo "$gl_cv_func_strndup_works" >&6; } + case $gl_cv_func_strndup_works in + *no) + REPLACE_STRNDUP=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS strndup.$ac_objext" + + ;; + esac + else @@ -33524,7 +34000,6 @@ $as_echo "#define HAVE_STRNDUP 1" >>confdefs.h gl_LIBOBJS="$gl_LIBOBJS strndup.$ac_objext" - : fi @@ -34745,8 +35220,6 @@ $as_echo "$gl_cv_next_sys_stat_h" >&6; } - SYS_STAT_H='sys/stat.h' - ac_fn_c_check_type "$LINENO" "nlink_t" "ac_cv_type_nlink_t" "#include #include @@ -35054,6 +35527,11 @@ $as_echo "$gl_cv_next_unistd_h" >&6; } +$as_echo "#define GNULIB_UNISTD_SAFER 1" >>confdefs.h + + + + $as_echo "#define GNULIB_UNISTR_U8_UCTOMB 1" >>confdefs.h @@ -36535,6 +37013,7 @@ $as_echo "$gl_cv_func_wcrtomb_retval" >&6; } + if test $ac_cv_func_iswcntrl = yes; then HAVE_ISWCNTRL=1 else @@ -36607,7 +37086,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_iswcntrl_works" >&5 $as_echo "$gl_cv_func_iswcntrl_works" >&6; } if test $gl_cv_func_iswcntrl_works = yes; then - WCTYPE_H= + case "$host_os" in + mingw*) + ;; + *) + WCTYPE_H= + ;; + esac fi fi @@ -36884,7 +37369,7 @@ int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -36902,7 +37387,7 @@ int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -37559,6 +38044,9 @@ $as_echo "$gt_cv_locale_tr_utf8" >&6; } + HAVE_SYMLINK=$ac_cv_func_symlink + + if test "$ac_cv_header_winsock2_h" = yes; then @@ -41230,7 +41718,7 @@ ac_res=$ac_cv_search_attr_copy_file if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" test "$ac_cv_search_attr_copy_file" = "none required" || - LIB_XATTR=$ac_cv_search_attr_copy_file + LIB_XATTR=$ac_cv_search_attr_copy_file fi for ac_func in attr_copy_file @@ -41495,14 +41983,14 @@ _ACEOF else case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in - no:*) # SELinux disabled - ;; - *:no) # SELinux disabled - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: SELinux enabled, but matchpathcon_init_prefix not found" >&5 + no:*) # SELinux disabled + ;; + *:no) # SELinux disabled + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: SELinux enabled, but matchpathcon_init_prefix not found" >&5 $as_echo "$as_me: WARNING: SELinux enabled, but matchpathcon_init_prefix not found" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The install utility may run slowly" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The install utility may run slowly" >&5 $as_echo "$as_me: WARNING: The install utility may run slowly" >&2;} esac @@ -41609,9 +42097,9 @@ _ACEOF fi - test $ac_cv_member_struct_statvfs_f_fstypename = yes || - { test $ac_cv_member_struct_statfs_f_fstypename != yes && - { ac_fn_c_check_member "$LINENO" "struct statvfs" "f_type" "ac_cv_member_struct_statvfs_f_type" "$statvfs_includes + test $ac_cv_member_struct_statvfs_f_fstypename = yes || + { test $ac_cv_member_struct_statfs_f_fstypename != yes && + { ac_fn_c_check_member "$LINENO" "struct statvfs" "f_type" "ac_cv_member_struct_statvfs_f_type" "$statvfs_includes " if test "x$ac_cv_member_struct_statvfs_f_type" = x""yes; then : @@ -41622,7 +42110,7 @@ _ACEOF fi - test $ac_cv_member_struct_statvfs_f_type = yes; }; }; }; } + test $ac_cv_member_struct_statvfs_f_type = yes; }; }; }; } then ac_fn_c_check_member "$LINENO" "struct statvfs" "f_namemax" "ac_cv_member_struct_statvfs_f_namemax" "$statvfs_includes " @@ -41642,7 +42130,7 @@ int main () { static statvfs s; - return (s.s_fsid ^ 0) == 0; + return (s.s_fsid ^ 0) == 0; ; return 0; } @@ -41683,7 +42171,7 @@ int main () { static statfs s; - return (s.s_fsid ^ 0) == 0; + return (s.s_fsid ^ 0) == 0; ; return 0; } @@ -41754,7 +42242,7 @@ ac_res=$ac_cv_search_fdatasync if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" test "$ac_cv_search_fdatasync" = "none required" || - LIB_FDATASYNC=$ac_cv_search_fdatasync + LIB_FDATASYNC=$ac_cv_search_fdatasync fi @@ -41772,12 +42260,14 @@ done LIBS=$coreutils_saved_libs # Check whether libcap is usable -- for ls --color support + LIB_CAP= # Check whether --enable-libcap was given. if test "${enable_libcap+set}" = set; then : - enableval=$enable_libcap; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcap support disabled by user" >&5 -$as_echo "$as_me: WARNING: libcap support disabled by user" >&2;} -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cap_get_file in -lcap" >&5 + enableval=$enable_libcap; +fi + + if test "X$enable_libcap" != "Xno"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cap_get_file in -lcap" >&5 $as_echo_n "checking for cap_get_file in -lcap... " >&6; } if test "${ac_cv_lib_cap_cap_get_file+set}" = set; then : $as_echo_n "(cached) " >&6 @@ -41820,21 +42310,24 @@ if test "x$ac_cv_header_sys_capability_h" = x""yes; then : $as_echo "#define HAVE_CAP 1" >>confdefs.h -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: header sys/capability.h was not found, support for libcap will not be built" >&5 -$as_echo "$as_me: WARNING: header sys/capability.h was not found, support for libcap will not be built" >&2;} fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcap library was not found or not usable, support for libcap will not be built" >&5 +fi + + if test "X$LIB_CAP" = "X"; then + if test "X$enable_libcap" = "Xyes"; then + as_fn_error "libcap library was not found or not usable" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcap library was not found or not usable, support for libcap will not be built" >&5 $as_echo "$as_me: WARNING: libcap library was not found or not usable, support for libcap will not be built" >&2;} -fi - - -fi - + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcap support disabled by user" >&5 +$as_echo "$as_me: WARNING: libcap support disabled by user" >&2;} + fi # See if linking `seq' requires -lm. @@ -42637,7 +43130,7 @@ int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -42655,7 +43148,7 @@ int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -42729,9 +43222,9 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ fi else - # If we lack tzset, report that localtime does not cache TZ, - # since we can't invalidate the cache if we don't have tzset. - utils_cv_localtime_cache=no + # If we lack tzset, report that localtime does not cache TZ, + # since we can't invalidate the cache if we don't have tzset. + utils_cv_localtime_cache=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $utils_cv_localtime_cache" >&5 @@ -42873,7 +43366,7 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include + #include int main () @@ -43282,7 +43775,7 @@ int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -43300,7 +43793,7 @@ int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -43748,7 +44241,7 @@ ac_res=$ac_cv_search_crypt if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" test "$ac_cv_search_crypt" = "none required" || - LIB_CRYPT="$ac_cv_search_crypt" + LIB_CRYPT="$ac_cv_search_crypt" fi LIBS="$cu_saved_libs" @@ -43927,7 +44420,7 @@ case $t in *) { as_fn_set_status 1 as_fn_error "internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t, does not match the list of default-not-installed programs - ($no_install_progs_default) also recorded in $mk" "$LINENO" 5; } ;; + ($no_install_progs_default) also recorded in $mk" "$LINENO" 5; } ;; esac # Given the name of a variable containing a space-separated list of @@ -43991,7 +44484,7 @@ fi # Warn about a request not to install a program that is # already on the default-no-install list. case " $gl_no_install_progs_default " in - *" $gl_i "*) gl_msg="by default, '$gl_i' is not installed" ;; + *" $gl_i "*) gl_msg="by default, '$gl_i' is not installed" ;; esac fi @@ -46038,8 +46531,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by GNU coreutils $as_me 7.5, which was -generated by GNU Autoconf 2.64.16-4cdf58. Invocation command line was +This file was extended by GNU coreutils $as_me 7.6, which was +generated by GNU Autoconf 2.64.27-5b5d. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -46108,8 +46601,8 @@ General help using GNU software: ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -GNU coreutils config.status 7.5 -configured by $0, generated by GNU Autoconf 2.64.16-4cdf58, +GNU coreutils config.status 7.6 +configured by $0, generated by GNU Autoconf 2.64.27-5b5d, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2009 Free Software Foundation, Inc. diff --git a/src/bin/coreutils/configure.ac b/src/bin/coreutils/configure.ac index 2793060da0..e718b36b37 100644 --- a/src/bin/coreutils/configure.ac +++ b/src/bin/coreutils/configure.ac @@ -24,8 +24,8 @@ AC_PREREQ([2.61]) # indicates that it is built from the 219th delta (in _some_ repository) # following the v6.9 tag, and that 58ddd is a prefix of the commit SHA1. AC_INIT([GNU coreutils], - m4_esyscmd([build-aux/git-version-gen .tarball-version]), - [bug-coreutils@gnu.org]) + m4_esyscmd([build-aux/git-version-gen .tarball-version]), + [bug-coreutils@gnu.org]) AC_CONFIG_SRCDIR([src/ls.c]) @@ -47,7 +47,7 @@ coreutils_MACROS AC_ARG_ENABLE([gcc-warnings], [AS_HELP_STRING([--enable-gcc-warnings], - [turn on lots of GCC warnings (for developers)])], + [turn on lots of GCC warnings (for developers)])], [case $enableval in yes|no) ;; *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;; @@ -122,11 +122,11 @@ AC_FUNC_FORK optional_bin_progs= AC_CHECK_FUNCS([uname], - gl_ADD_PROG([optional_bin_progs], [uname])) + gl_ADD_PROG([optional_bin_progs], [uname])) AC_CHECK_FUNCS([chroot], - gl_ADD_PROG([optional_bin_progs], [chroot])) + gl_ADD_PROG([optional_bin_progs], [chroot])) AC_CHECK_FUNCS([gethostid], - gl_ADD_PROG([optional_bin_progs], [hostid])) + gl_ADD_PROG([optional_bin_progs], [hostid])) gl_WINSIZE_IN_PTEM @@ -168,9 +168,9 @@ int main() [# If we have tzset, assume the worst when cross-compiling. utils_cv_localtime_cache=yes]) else - # If we lack tzset, report that localtime does not cache TZ, - # since we can't invalidate the cache if we don't have tzset. - utils_cv_localtime_cache=no + # If we lack tzset, report that localtime does not cache TZ, + # since we can't invalidate the cache if we don't have tzset. + utils_cv_localtime_cache=no fi])dnl AC_MSG_RESULT([$utils_cv_localtime_cache]) if test $utils_cv_localtime_cache = yes; then @@ -197,7 +197,7 @@ AC_CACHE_CHECK([for 3-argument setpriority function], [AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include - #include + #include ]], [[setpriority (0, 0, 0);]])], [utils_cv_func_setpriority=yes], @@ -374,8 +374,8 @@ case $t in $no_install_progs_default) ;; *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t, does not match the list of default-not-installed programs - ($no_install_progs_default) also recorded in $mk]], - 1) ;; + ($no_install_progs_default) also recorded in $mk]], + 1) ;; esac # Given the name of a variable containing a space-separated list of diff --git a/src/bin/coreutils/doc/Makefile.in b/src/bin/coreutils/doc/Makefile.in index 30e7d91e40..c87f9fc761 100644 --- a/src/bin/coreutils/doc/Makefile.in +++ b/src/bin/coreutils/doc/Makefile.in @@ -71,22 +71,23 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ - $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ - $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ - $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ - $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ - $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ + $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ + $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ + $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ + $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ + $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ - $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ - $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ - $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ + $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ + $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ + $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ + $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ @@ -128,37 +129,38 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ - $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ - $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/long-options.m4 \ - $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ - $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ - $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ - $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ - $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ - $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ - $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbsrtowcs.m4 \ - $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/mbswidth.m4 \ - $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memcasecmp.m4 \ - $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/memcmp.m4 \ - $(top_srcdir)/m4/memcoll.m4 $(top_srcdir)/m4/memcpy.m4 \ - $(top_srcdir)/m4/memmove.m4 $(top_srcdir)/m4/mempcpy.m4 \ - $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/memset.m4 \ - $(top_srcdir)/m4/memxfrm.m4 $(top_srcdir)/m4/mgetgroups.m4 \ - $(top_srcdir)/m4/mkancesdirs.m4 $(top_srcdir)/m4/mkdir-p.m4 \ - $(top_srcdir)/m4/mkdir-slash.m4 $(top_srcdir)/m4/mkstemp.m4 \ - $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ - $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/modechange.m4 \ - $(top_srcdir)/m4/mountlist.m4 $(top_srcdir)/m4/mpsort.m4 \ - $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/nanosleep.m4 \ - $(top_srcdir)/m4/netdb_h.m4 $(top_srcdir)/m4/netinet_in_h.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/nocrash.m4 \ - $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ - $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ - $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ - $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ - $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ + $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ + $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ + $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ + $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ + $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ + $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ + $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ + $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ + $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ + $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/memcmp.m4 $(top_srcdir)/m4/memcoll.m4 \ + $(top_srcdir)/m4/memcpy.m4 $(top_srcdir)/m4/memmove.m4 \ + $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ + $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ + $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ + $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ + $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ + $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ + $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ + $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ + $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ + $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ + $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ @@ -330,6 +332,7 @@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNULIB_ACCEPT = @GNULIB_ACCEPT@ +GNULIB_ACCEPT4 = @GNULIB_ACCEPT4@ GNULIB_ALPHASORT = @GNULIB_ALPHASORT@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ @@ -343,10 +346,15 @@ GNULIB_CONNECT = @GNULIB_CONNECT@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ +GNULIB_DUP3 = @GNULIB_DUP3@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ +GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ +GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ +GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ GNULIB_FLOORL = @GNULIB_FLOORL@ @@ -361,6 +369,7 @@ GNULIB_FREXP = @GNULIB_FREXP@ GNULIB_FREXPL = @GNULIB_FREXPL@ GNULIB_FSEEK = @GNULIB_FSEEK@ GNULIB_FSEEKO = @GNULIB_FSEEKO@ +GNULIB_FSTATAT = @GNULIB_FSTATAT@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ @@ -424,12 +433,19 @@ GNULIB_MEMCHR = @GNULIB_MEMCHR@ GNULIB_MEMMEM = @GNULIB_MEMMEM@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ +GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNODAT = @GNULIB_MKNODAT@ +GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ +GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ +GNULIB_PIPE2 = @GNULIB_PIPE2@ +GNULIB_POPEN = @GNULIB_POPEN@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -439,9 +455,11 @@ GNULIB_PUTS = @GNULIB_PUTS@ GNULIB_RANDOM_R = @GNULIB_RANDOM_R@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ +GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_RENAME = @GNULIB_RENAME@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -481,11 +499,13 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ @@ -502,6 +522,7 @@ GNULIB_WCTOB = @GNULIB_WCTOB@ GNULIB_WCWIDTH = @GNULIB_WCWIDTH@ GNULIB_WRITE = @GNULIB_WRITE@ GREP = @GREP@ +HAVE_ACCEPT4 = @HAVE_ACCEPT4@ HAVE_ALPHASORT = @HAVE_ALPHASORT@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ @@ -552,8 +573,14 @@ HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@ HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@ HAVE_DPRINTF = @HAVE_DPRINTF@ HAVE_DUP2 = @HAVE_DUP2@ +HAVE_DUP3 = @HAVE_DUP3@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ +HAVE_FACCESSAT = @HAVE_FACCESSAT@ +HAVE_FCHMODAT = @HAVE_FCHMODAT@ +HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ HAVE_FSEEKO = @HAVE_FSEEKO@ +HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ @@ -579,15 +606,22 @@ HAVE_MBSINIT = @HAVE_MBSINIT@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ +HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNODAT = @HAVE_MKNODAT@ +HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ +HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ +HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ @@ -605,7 +639,6 @@ HAVE_STPCPY = @HAVE_STPCPY@ HAVE_STPNCPY = @HAVE_STPNCPY@ HAVE_STRCASESTR = @HAVE_STRCASESTR@ HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ -HAVE_STRNDUP = @HAVE_STRNDUP@ HAVE_STRPBRK = @HAVE_STRPBRK@ HAVE_STRSEP = @HAVE_STRSEP@ HAVE_STRTOD = @HAVE_STRTOD@ @@ -617,6 +650,8 @@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ +HAVE_SYMLINK = @HAVE_SYMLINK@ +HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@ HAVE_SYS_IOCTL_H = @HAVE_SYS_IOCTL_H@ @@ -628,6 +663,7 @@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ +HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ @@ -780,6 +816,7 @@ REPLACE_CLOSE = @REPLACE_CLOSE@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ REPLACE_DUP2 = @REPLACE_DUP2@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ +REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ @@ -792,6 +829,7 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ REPLACE_GETCWD = @REPLACE_GETCWD@ @@ -808,6 +846,7 @@ REPLACE_ISNAN = @REPLACE_ISNAN@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ +REPLACE_LINK = @REPLACE_LINK@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -828,8 +867,10 @@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ REPLACE_PERROR = @REPLACE_PERROR@ +REPLACE_POPEN = @REPLACE_POPEN@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ @@ -842,10 +883,12 @@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ REPLACE_STRERROR = @REPLACE_STRERROR@ +REPLACE_STRNDUP = @REPLACE_STRNDUP@ REPLACE_STRPTIME = @REPLACE_STRPTIME@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ +REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ @@ -878,13 +921,13 @@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ -SYS_STAT_H = @SYS_STAT_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ U = @U@ UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@ UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@ +UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ USE_ACL = @USE_ACL@ diff --git a/src/bin/coreutils/doc/coreutils.info b/src/bin/coreutils/doc/coreutils.info index 6bde17237d..708729178c 100644 --- a/src/bin/coreutils/doc/coreutils.info +++ b/src/bin/coreutils/doc/coreutils.info @@ -110,7 +110,7 @@ START-INFO-DIR-ENTRY * yes: (coreutils)yes invocation. Print a string indefinitely. END-INFO-DIR-ENTRY - This manual documents version 7.5 of the GNU core utilities, + This manual documents version 7.6 of the GNU core utilities, including the standard programs for text and file manipulation. Copyright (C) 1994-1996, 2000-2009 Free Software Foundation, Inc. @@ -128,7 +128,7 @@ File: coreutils.info, Node: Top, Next: Introduction, Up: (dir) GNU Coreutils ************* -This manual documents version 7.5 of the GNU core utilities, including +This manual documents version 7.6 of the GNU core utilities, including the standard programs for text and file manipulation. Copyright (C) 1994-1996, 2000-2009 Free Software Foundation, Inc. @@ -1480,8 +1480,8 @@ options::. Skip BYTES input bytes before formatting and writing. If BYTES begins with `0x' or `0X', it is interpreted in hexadecimal; otherwise, if it begins with `0', in octal; otherwise, in decimal. - BYTES is a number which may have one of the following - multiplicative suffixes: + BYTES may be, or may be an integer optionally followed by, one of + the following multiplicative suffixes: `b' => 512 ("blocks") `KB' => 1000 (KiloBytes) `K' => 1024 (KibiBytes) @@ -1732,13 +1732,6 @@ Experience' 11, 11 (November 1981), 1119-1184. The program accepts the following options. Also see *note Common options::. -`-C' -`--compare' - Compare each pair of source and destination files, and if the - destination has identical content and any specified owner, group, - permissions, and possibly SELinux context, then do not modify the - destination at all. - `-c' `--crown-margin' "Crown margin" mode: preserve the indentation of the first two @@ -2141,8 +2134,8 @@ options::. `--bytes=K' Print the first K bytes, instead of initial lines. However, if K starts with a `-', print all but the last K bytes of each file. K - is a number which may have one of the following multiplicative - suffixes: + may be, or may be an integer optionally followed by, one of the + following multiplicative suffixes: `b' => 512 ("blocks") `KB' => 1000 (KiloBytes) `K' => 1024 (KibiBytes) @@ -2214,8 +2207,9 @@ options::. `--bytes=K' Output the last K bytes, instead of final lines. However, if K starts with a `+', start printing with the Kth byte from the start - of each file, instead of from the end. K is a number which may - have one of the following multiplicative suffixes: + of each file, instead of from the end. K may be, or may be an + integer optionally followed by, one of the following + multiplicative suffixes: `b' => 512 ("blocks") `KB' => 1000 (KiloBytes) `K' => 1024 (KibiBytes) @@ -2261,8 +2255,10 @@ options::. The option values `descriptor' and `name' may be specified only with the long form of the option, not with `-f'. - If `POSIXLY_CORRECT' is set, the `-f' option is ignored if no FILE - operand is specified and standard input is a FIFO or a pipe. + The `-f' option is ignored if no FILE operand is specified and + standard input is a FIFO or a pipe. Likewise, the `-f' option has + no effect for any operand specified as `-', when standard input is + a FIFO or a pipe. `-F' This option is the same as `--follow=name --retry'. That is, tail @@ -2396,8 +2392,9 @@ options::. `-b SIZE' `--bytes=SIZE' - Put SIZE bytes of INPUT into each output file. SIZE is a number - which may have one of the following multiplicative suffixes: + Put SIZE bytes of INPUT into each output file. SIZE may be, or + may be an integer optionally followed by, one of the following + multiplicative suffixes: `b' => 512 ("blocks") `KB' => 1000 (KiloBytes) `K' => 1024 (KibiBytes) @@ -6110,11 +6107,10 @@ options::. `timestamps' Preserve the times of last access and last modification, when - possible. In general, it is not possible to preserve these - attributes when the affected file is a symbolic link. - However, FreeBSD now provides the `lutimes' function, which - makes it possible even for symbolic links. However, this - implementation does not yet take advantage of that. + possible. On older systems, it is not possible to preserve + these attributes when the affected file is a symbolic link. + However, many systems now provide the `utimensat' function, + which makes it possible even for symbolic links. `links' Preserve in the destination files any links between @@ -6192,13 +6188,24 @@ options::. specify `-P', as POSIX allows implementations that dereference symbolic links by default. -`--reflink' +`--reflink[=WHEN]' Perform a lightweight, copy-on-write (COW) copy. Copying with - this option can succeed only on some relatively new file systems. - Once it has succeeded, beware that the source and destination files - share the same disk data blocks as long as they remain unmodified. - Thus, if a disk I/O error affects data blocks of one of the files, - the other suffers the exact same fate. + this option can succeed only on some file systems. Once it has + succeeded, beware that the source and destination files share the + same disk data blocks as long as they remain unmodified. Thus, if + a disk I/O error affects data blocks of one of the files, the + other suffers the exact same fate. + + The WHEN value can be one of the following: + + `always' + The default behavior: if the copy-on-write operation is not + supported then report the failure for each file and exit with + a failure status. + + `auto' + If the copy-on-write operation is not supported then fall back + to the standard copy behaviour. `--remove-destination' Remove each existing destination file before attempting to open it @@ -6375,8 +6382,8 @@ options::. `dd' accepts the following operands. necessary. `unblock' - Replace trailing spaces in each `cbs'-sized input block with a - newline. + Remove any trailing spaces in each `cbs'-sized input block, + and append a newline. The `block' and `unblock' conversions are mutually exclusive. @@ -6601,6 +6608,13 @@ options::. *Note Backup options::. Make a backup of each file that would otherwise be overwritten or removed. +`-C' +`--compare' + Compare each pair of source and destination files, and if the + destination has identical content and any specified owner, group, + permissions, and possibly SELinux context, then do not modify the + destination at all. + `-c' Ignored; for compatibility with old Unix versions of `install'. @@ -8693,8 +8707,9 @@ options::. `-s SIZE' `--size=SIZE' - Set the size of each FILE to this SIZE. SIZE is a number which - may have one of the following multiplicative suffixes: + Set the size of each FILE to this SIZE. SIZE may be, or may be an + integer optionally followed by, one of the following + multiplicative suffixes: `KB' => 1000 (KiloBytes) `K' => 1024 (KibiBytes) `MB' => 1000*1000 (MegaBytes) @@ -11820,8 +11835,8 @@ options::. `SIZE' Specify the size of the buffer to use in fully buffered mode. - SIZE is a number which may have one of the following - multiplicative suffixes: + SIZE may be, or may be an integer optionally followed by, one of + the following multiplicative suffixes: `KB' => 1000 (KiloBytes) `K' => 1024 (KibiBytes) `MB' => 1000*1000 (MegaBytes) @@ -14371,20 +14386,20 @@ Index (line 21) * --columns: pr invocation. (line 68) * --command: su invocation. (line 39) -* --compare: fmt invocation. (line 34) +* --compare: install invocation. (line 47) * --complement: cut invocation. (line 71) * --compute: runcon invocation. (line 27) * --context <1>: id invocation. (line 45) * --context <2>: mknod invocation. (line 54) * --context <3>: mkfifo invocation. (line 28) * --context <4>: mkdir invocation. (line 56) -* --context <5>: install invocation. (line 126) +* --context <5>: install invocation. (line 133) * --context: What information is listed. (line 268) * --count <1>: who invocation. (line 70) * --count: uniq invocation. (line 55) * --count-links: du invocation. (line 96) -* --crown-margin: fmt invocation. (line 41) +* --crown-margin: fmt invocation. (line 34) * --csh: dircolors invocation. (line 40) * --date <1>: Options for date. (line 11) @@ -14408,7 +14423,7 @@ Index * --dictionary-order: sort invocation. (line 87) * --digits: csplit invocation. (line 80) * --directory <1>: ln invocation. (line 83) -* --directory <2>: install invocation. (line 55) +* --directory <2>: install invocation. (line 62) * --directory: Which files are listed. (line 28) * --dired: What information is listed. @@ -14436,7 +14451,7 @@ Index * --files0-from=FILE <2>: sort invocation. (line 218) * --files0-from=FILE: wc invocation. (line 62) * --first-line-number: pr invocation. (line 194) -* --follow: tail invocation. (line 47) +* --follow: tail invocation. (line 48) * --footer-numbering: nl invocation. (line 75) * --force <1>: ln invocation. (line 89) * --force <2>: shred invocation. (line 101) @@ -14456,7 +14471,7 @@ Index (line 100) * --general-numeric-sort: sort invocation. (line 105) * --group <1>: id invocation. (line 23) -* --group: install invocation. (line 61) +* --group: install invocation. (line 68) * --group-directories-first: Which files are listed. (line 50) * --groups <1>: chroot invocation. (line 29) @@ -14513,11 +14528,11 @@ Index * --kernel-version: uname invocation. (line 76) * --key: sort invocation. (line 231) * --length: pr invocation. (line 153) -* --line-bytes: split invocation. (line 46) +* --line-bytes: split invocation. (line 47) * --line-increment: nl invocation. (line 83) * --lines <1>: wc invocation. (line 55) * --lines <2>: split invocation. (line 26) -* --lines <3>: tail invocation. (line 136) +* --lines <3>: tail invocation. (line 139) * --lines: head invocation. (line 39) * --link: cp invocation. (line 139) * --literal: Formatting the file names. @@ -14530,7 +14545,7 @@ Index * --machine: uname invocation. (line 41) * --max-depth=DEPTH: du invocation. (line 116) * --max-line-length: wc invocation. (line 59) -* --max-unchanged-stats: tail invocation. (line 124) +* --max-unchanged-stats: tail invocation. (line 127) * --merge <1>: sort invocation. (line 32) * --merge: pr invocation. (line 160) * --mesg: who invocation. (line 95) @@ -14538,7 +14553,7 @@ Index * --mode <1>: mknod invocation. (line 48) * --mode <2>: mkfifo invocation. (line 21) * --mode <3>: mkdir invocation. (line 19) -* --mode: install invocation. (line 67) +* --mode: install invocation. (line 74) * --month-sort: sort invocation. (line 149) * --name: id invocation. (line 31) * --no-clobber <1>: mv invocation. (line 74) @@ -14563,8 +14578,8 @@ Index * --no-sync: df invocation. (line 73) * --no-target-directory <1>: ln invocation. (line 131) * --no-target-directory <2>: mv invocation. (line 107) -* --no-target-directory <3>: install invocation. (line 117) -* --no-target-directory <4>: cp invocation. (line 330) +* --no-target-directory <3>: install invocation. (line 124) +* --no-target-directory <4>: cp invocation. (line 340) * --no-target-directory: Target directory. (line 15) * --nodename: uname invocation. (line 46) * --null: du invocation. (line 122) @@ -14575,14 +14590,14 @@ Index * --number-separator: nl invocation. (line 112) * --number-width: nl invocation. (line 122) * --numeric-sort: sort invocation. (line 159) -* --numeric-suffixes: split invocation. (line 57) +* --numeric-suffixes: split invocation. (line 58) * --numeric-uid-gid: What information is listed. (line 234) * --omit-header: pr invocation. (line 231) * --omit-pagination: pr invocation. (line 242) * --one-file-system <1>: du invocation. (line 201) * --one-file-system <2>: rm invocation. (line 63) -* --one-file-system: cp invocation. (line 349) +* --one-file-system: cp invocation. (line 359) * --only-delimited: cut invocation. (line 59) * --operating-system: uname invocation. (line 57) * --output <1>: stdbuf invocation. (line 23) @@ -14591,25 +14606,25 @@ Index * --output-delimiter: cut invocation. (line 64) * --output-duplicates: od invocation. (line 155) * --output-tabs: pr invocation. (line 137) -* --owner: install invocation. (line 79) +* --owner: install invocation. (line 86) * --page_width: pr invocation. (line 260) * --pages=PAGE_RANGE: pr invocation. (line 58) * --parents <1>: rmdir invocation. (line 22) * --parents <2>: mkdir invocation. (line 34) -* --parents: cp invocation. (line 236) +* --parents: cp invocation. (line 235) * --physical: pwd invocation. (line 22) -* --pid: tail invocation. (line 104) +* --pid: tail invocation. (line 107) * --portability <1>: pathchk invocation. (line 46) * --portability: df invocation. (line 80) * --prefix: csplit invocation. (line 62) * --preserve: cp invocation. (line 163) -* --preserve-context: install invocation. (line 84) +* --preserve-context: install invocation. (line 91) * --preserve-environment: su invocation. (line 64) * --preserve-root <1>: chmod invocation. (line 49) * --preserve-root <2>: chgrp invocation. (line 43) * --preserve-root <3>: chown invocation. (line 116) * --preserve-root: rm invocation. (line 79) -* --preserve-timestamps: install invocation. (line 91) +* --preserve-timestamps: install invocation. (line 98) * --print-database: dircolors invocation. (line 45) * --print-type: df invocation. (line 119) @@ -14623,7 +14638,7 @@ Index * --quiet <5>: readlink invocation. (line 52) * --quiet <6>: md5sum invocation. (line 69) * --quiet <7>: csplit invocation. (line 100) -* --quiet <8>: tail invocation. (line 144) +* --quiet <8>: tail invocation. (line 147) * --quiet: head invocation. (line 46) * --quote-name: Formatting the file names. (line 30) @@ -14642,7 +14657,7 @@ Index * --recursive <3>: chgrp invocation. (line 66) * --recursive <4>: chown invocation. (line 140) * --recursive <5>: rm invocation. (line 91) -* --recursive <6>: cp invocation. (line 249) +* --recursive <6>: cp invocation. (line 248) * --recursive: Which files are listed. (line 91) * --reference <1>: chcon invocation. (line 25) @@ -14652,12 +14667,12 @@ Index * --reference <5>: chmod invocation. (line 62) * --reference <6>: chgrp invocation. (line 52) * --reference: chown invocation. (line 125) -* --reflink: cp invocation. (line 262) +* --reflink[=WHEN]: cp invocation. (line 261) * --regex: tac invocation. (line 26) * --remove: shred invocation. (line 123) -* --remove-destination: cp invocation. (line 270) +* --remove-destination: cp invocation. (line 280) * --repeated: uniq invocation. (line 63) -* --retry: tail invocation. (line 90) +* --retry: tail invocation. (line 93) * --reverse <1>: Sorting the output. (line 27) * --reverse: sort invocation. (line 182) * --rfc-2822: Options for date. (line 40) @@ -14697,7 +14712,7 @@ Index * --silent <4>: chown invocation. (line 76) * --silent <5>: readlink invocation. (line 52) * --silent <6>: csplit invocation. (line 100) -* --silent <7>: tail invocation. (line 144) +* --silent <7>: tail invocation. (line 147) * --silent: head invocation. (line 46) * --size <1>: truncate invocation. (line 34) * --size: What information is listed. @@ -14706,42 +14721,42 @@ Index * --skip-bytes: od invocation. (line 55) * --skip-chars: uniq invocation. (line 41) * --skip-fields: uniq invocation. (line 31) -* --sleep-interval: tail invocation. (line 96) +* --sleep-interval: tail invocation. (line 99) * --sort <1>: Sorting the output. (line 32) * --sort: sort invocation. (line 105) * --spaces: fold invocation. (line 29) -* --sparse=WHEN: cp invocation. (line 274) -* --split-only: fmt invocation. (line 54) +* --sparse=WHEN: cp invocation. (line 284) +* --split-only: fmt invocation. (line 47) * --squeeze-blank: cat invocation. (line 35) * --stable: sort invocation. (line 294) * --starting-line-number: nl invocation. (line 117) * --status: md5sum invocation. (line 77) * --strings: od invocation. (line 76) -* --strip: install invocation. (line 101) -* --strip-program: install invocation. (line 104) +* --strip: install invocation. (line 108) +* --strip-program: install invocation. (line 111) * --strip-trailing-slashes <1>: mv invocation. (line 93) -* --strip-trailing-slashes: cp invocation. (line 308) +* --strip-trailing-slashes: cp invocation. (line 318) * --suffix <1>: ln invocation. (line 122) * --suffix <2>: mv invocation. (line 98) -* --suffix <3>: install invocation. (line 108) -* --suffix <4>: cp invocation. (line 321) +* --suffix <3>: install invocation. (line 115) +* --suffix <4>: cp invocation. (line 331) * --suffix <5>: csplit invocation. (line 66) * --suffix: Backup options. (line 50) -* --suffix-length: split invocation. (line 53) +* --suffix-length: split invocation. (line 54) * --summarize: du invocation. (line 136) * --symbolic: ln invocation. (line 116) -* --symbolic-link: cp invocation. (line 313) +* --symbolic-link: cp invocation. (line 323) * --sync: df invocation. (line 106) * --sysv: sum invocation. (line 31) * --tabs <1>: unexpand invocation. (line 24) * --tabs: expand invocation. (line 22) * --tabsize: General output formatting. (line 92) -* --tagged-paragraph: fmt invocation. (line 47) +* --tagged-paragraph: fmt invocation. (line 40) * --target-directory <1>: ln invocation. (line 127) * --target-directory <2>: mv invocation. (line 103) -* --target-directory <3>: install invocation. (line 113) -* --target-directory <4>: cp invocation. (line 326) +* --target-directory <3>: install invocation. (line 120) +* --target-directory <4>: cp invocation. (line 336) * --target-directory: Target directory. (line 31) * --temporary-directory: sort invocation. (line 336) * --terse: stat invocation. (line 53) @@ -14759,13 +14774,13 @@ Index * --type <1>: runcon invocation. (line 39) * --type <2>: chcon invocation. (line 59) * --type: df invocation. (line 113) -* --uniform-spacing: fmt invocation. (line 60) +* --uniform-spacing: fmt invocation. (line 53) * --unique <1>: uniq invocation. (line 101) * --unique: sort invocation. (line 345) * --universal: Options for date. (line 87) * --unset: env invocation. (line 38) * --update <1>: mv invocation. (line 80) -* --update: cp invocation. (line 335) +* --update: cp invocation. (line 345) * --user <1>: runcon invocation. (line 31) * --user <2>: chcon invocation. (line 51) * --user: id invocation. (line 41) @@ -14782,10 +14797,10 @@ Index * --verbose <9>: shred invocation. (line 129) * --verbose <10>: rm invocation. (line 95) * --verbose <11>: mv invocation. (line 90) -* --verbose <12>: install invocation. (line 122) -* --verbose <13>: cp invocation. (line 345) -* --verbose <14>: split invocation. (line 60) -* --verbose <15>: tail invocation. (line 148) +* --verbose <12>: install invocation. (line 129) +* --verbose <13>: cp invocation. (line 355) +* --verbose <14>: split invocation. (line 61) +* --verbose <15>: tail invocation. (line 151) * --verbose: head invocation. (line 50) * --version: Common options. (line 41) * --version-sort: sort invocation. (line 176) @@ -14794,7 +14809,7 @@ Index (line 104) * --width <2>: fold invocation. (line 35) * --width <3>: pr invocation. (line 251) -* --width <4>: fmt invocation. (line 66) +* --width <4>: fmt invocation. (line 59) * --width: od invocation. (line 162) * --words: wc invocation. (line 51) * --wrap: base64 invocation. (line 22) @@ -14827,7 +14842,7 @@ Index (line 13) * -a <2>: unexpand invocation. (line 37) * -a <3>: join invocation. (line 73) -* -a <4>: split invocation. (line 53) +* -a <4>: split invocation. (line 54) * -a <5>: pr invocation. (line 82) * -a: od invocation. (line 175) * -A <1>: od invocation. (line 36) @@ -14868,7 +14883,8 @@ Index * -c <8>: chmod invocation. (line 39) * -c <9>: chgrp invocation. (line 20) * -c <10>: chown invocation. (line 70) -* -c <11>: install invocation. (line 46) +* -c: install invocation. (line 53) +* -C: install invocation. (line 47) * -c: dircolors invocation. (line 40) * -C: General output formatting. @@ -14879,12 +14895,11 @@ Index * -c <4>: shuf invocation. (line 19) * -c <5>: sort invocation. (line 18) * -c: wc invocation. (line 43) -* -C: split invocation. (line 46) +* -C: split invocation. (line 47) * -c <1>: tail invocation. (line 32) * -c <2>: head invocation. (line 24) * -c <3>: pr invocation. (line 88) -* -c: fmt invocation. (line 41) -* -C: fmt invocation. (line 34) +* -c <4>: fmt invocation. (line 34) * -c: od invocation. (line 181) * -COLUMN: pr invocation. (line 68) * -d <1>: Options for date. (line 11) @@ -14893,8 +14908,8 @@ Index * -D: du invocation. (line 61) * -d <1>: touch invocation. (line 58) * -d <2>: ln invocation. (line 83) -* -d: install invocation. (line 55) -* -D: install invocation. (line 49) +* -d: install invocation. (line 62) +* -D: install invocation. (line 56) * -d: cp invocation. (line 103) * -D: What information is listed. (line 16) @@ -14905,7 +14920,7 @@ Index * -D: uniq invocation. (line 69) * -d <1>: uniq invocation. (line 63) * -d <2>: sort invocation. (line 87) -* -d <3>: split invocation. (line 57) +* -d <3>: split invocation. (line 58) * -d <4>: pr invocation. (line 94) * -d <5>: base64 invocation. (line 30) * -d <6>: od invocation. (line 185) @@ -14946,8 +14961,8 @@ Index * -f <3>: uniq invocation. (line 31) * -f <4>: sort invocation. (line 94) * -f: csplit invocation. (line 62) -* -F: tail invocation. (line 85) -* -f <1>: tail invocation. (line 47) +* -F: tail invocation. (line 88) +* -f <1>: tail invocation. (line 48) * -f: pr invocation. (line 126) * -F: pr invocation. (line 126) * -f <1>: od invocation. (line 188) @@ -14960,7 +14975,7 @@ Index (line 31) * -g <1>: Access permission tests. (line 9) -* -g: install invocation. (line 61) +* -g: install invocation. (line 68) * -G: What information is listed. (line 110) * -g <1>: What information is listed. @@ -15061,7 +15076,7 @@ Index * -m <7>: mknod invocation. (line 48) * -m <8>: mkfifo invocation. (line 21) * -m <9>: mkdir invocation. (line 19) -* -m <10>: install invocation. (line 67) +* -m <10>: install invocation. (line 74) * -m: General output formatting. (line 78) * -M: sort invocation. (line 149) @@ -15085,7 +15100,7 @@ Index * -n <3>: shuf invocation. (line 32) * -n <4>: sort invocation. (line 159) * -n <5>: csplit invocation. (line 80) -* -n <6>: tail invocation. (line 136) +* -n <6>: tail invocation. (line 139) * -n: head invocation. (line 39) * -N: pr invocation. (line 194) * -n: pr invocation. (line 173) @@ -15103,7 +15118,7 @@ Index * -O: Access permission tests. (line 28) * -o <1>: truncate invocation. (line 26) -* -o <2>: install invocation. (line 79) +* -o <2>: install invocation. (line 86) * -o <3>: What information is listed. (line 238) * -o <4>: shuf invocation. (line 37) @@ -15126,7 +15141,7 @@ Index * -P: chown invocation. (line 152) * -p <1>: rmdir invocation. (line 22) * -p <2>: mkdir invocation. (line 34) -* -p <3>: install invocation. (line 91) +* -p <3>: install invocation. (line 98) * -p: cp invocation. (line 163) * -P: cp invocation. (line 156) * -p <1>: dircolors invocation. @@ -15142,7 +15157,7 @@ Index * -q <1>: Formatting the file names. (line 23) * -q <2>: csplit invocation. (line 100) -* -q <3>: tail invocation. (line 144) +* -q <3>: tail invocation. (line 147) * -q: head invocation. (line 46) * -r <1>: runcon invocation. (line 35) * -r: chcon invocation. (line 55) @@ -15161,8 +15176,8 @@ Index * -R <3>: chown invocation. (line 140) * -R: rm invocation. (line 91) * -r <1>: rm invocation. (line 91) -* -r: cp invocation. (line 249) -* -R: cp invocation. (line 249) +* -r: cp invocation. (line 248) +* -R: cp invocation. (line 248) * -r: Sorting the output. (line 27) * -R <1>: Which files are listed. (line 91) @@ -15187,10 +15202,10 @@ Index * -S: ln invocation. (line 122) * -s: ln invocation. (line 116) * -S <1>: mv invocation. (line 98) -* -S: install invocation. (line 108) -* -s: install invocation. (line 101) -* -S: cp invocation. (line 321) -* -s: cp invocation. (line 313) +* -S: install invocation. (line 115) +* -s: install invocation. (line 108) +* -S: cp invocation. (line 331) +* -s: cp invocation. (line 323) * -S: Sorting the output. (line 32) * -s <1>: What information is listed. (line 244) @@ -15204,7 +15219,7 @@ Index * -s: fold invocation. (line 29) * -S: pr invocation. (line 221) * -s <1>: pr invocation. (line 212) -* -s <2>: fmt invocation. (line 54) +* -s <2>: fmt invocation. (line 47) * -s: od invocation. (line 200) * -S: od invocation. (line 76) * -s <1>: nl invocation. (line 112) @@ -15225,10 +15240,10 @@ Index * -t: ln invocation. (line 127) * -T: mv invocation. (line 107) * -t: mv invocation. (line 103) -* -T: install invocation. (line 117) -* -t: install invocation. (line 113) -* -T: cp invocation. (line 330) -* -t: cp invocation. (line 326) +* -T: install invocation. (line 124) +* -t: install invocation. (line 120) +* -T: cp invocation. (line 340) +* -t: cp invocation. (line 336) * -T: General output formatting. (line 92) * -t <1>: Sorting the output. (line 36) @@ -15239,7 +15254,7 @@ Index * -t: md5sum invocation. (line 87) * -T: pr invocation. (line 242) * -t <1>: pr invocation. (line 231) -* -t <2>: fmt invocation. (line 47) +* -t <2>: fmt invocation. (line 40) * -t: od invocation. (line 85) * -T: cat invocation. (line 43) * -t: cat invocation. (line 39) @@ -15253,12 +15268,12 @@ Index (line 18) * -u <8>: shred invocation. (line 123) * -u <9>: mv invocation. (line 80) -* -u: cp invocation. (line 335) +* -u: cp invocation. (line 345) * -U: Sorting the output. (line 49) * -u <1>: Sorting the output. (line 42) * -u <2>: uniq invocation. (line 101) * -u <3>: sort invocation. (line 345) -* -u <4>: fmt invocation. (line 60) +* -u <4>: fmt invocation. (line 53) * -u: cat invocation. (line 46) * -v <1>: chcon invocation. (line 47) * -v <2>: uname invocation. (line 76) @@ -15272,11 +15287,11 @@ Index * -v <10>: shred invocation. (line 129) * -v <11>: rm invocation. (line 95) * -v <12>: mv invocation. (line 90) -* -v <13>: install invocation. (line 122) -* -v <14>: cp invocation. (line 345) +* -v <13>: install invocation. (line 129) +* -v <14>: cp invocation. (line 355) * -v: Sorting the output. (line 56) * -V: sort invocation. (line 176) -* -v <1>: tail invocation. (line 148) +* -v <1>: tail invocation. (line 151) * -v <2>: head invocation. (line 50) * -v <3>: pr invocation. (line 247) * -v <4>: od invocation. (line 155) @@ -15293,17 +15308,17 @@ Index * -w: fold invocation. (line 35) * -W: pr invocation. (line 260) * -w <1>: pr invocation. (line 251) -* -w <2>: fmt invocation. (line 66) +* -w <2>: fmt invocation. (line 59) * -w <3>: base64 invocation. (line 22) * -w <4>: od invocation. (line 162) * -w: nl invocation. (line 122) -* -WIDTH: fmt invocation. (line 66) +* -WIDTH: fmt invocation. (line 59) * -x <1>: Access permission tests. (line 24) * -x <2>: du invocation. (line 201) * -x <3>: df invocation. (line 144) * -x <4>: shred invocation. (line 134) -* -x <5>: cp invocation. (line 349) +* -x <5>: cp invocation. (line 359) * -x: General output formatting. (line 88) * -X: Sorting the output. (line 63) @@ -15315,7 +15330,7 @@ Index * -Z <2>: mkfifo invocation. (line 28) * -Z: mkdir invocation. (line 56) * -z: shred invocation. (line 144) -* -Z <1>: install invocation. (line 126) +* -Z <1>: install invocation. (line 133) * -Z: What information is listed. (line 268) * -z <1>: uniq invocation. (line 112) @@ -15354,7 +15369,7 @@ Index * _POSIX2_VERSION <1>: touch invocation. (line 93) * _POSIX2_VERSION <2>: uniq invocation. (line 46) * _POSIX2_VERSION <3>: sort invocation. (line 392) -* _POSIX2_VERSION <4>: tail invocation. (line 159) +* _POSIX2_VERSION <4>: tail invocation. (line 162) * _POSIX2_VERSION: Standards conformance. (line 19) * abbreviations for months: Calendar date items. (line 38) @@ -15390,7 +15405,7 @@ Index * appropriate privileges <1>: nice invocation. (line 6) * appropriate privileges <2>: hostname invocation. (line 6) * appropriate privileges <3>: Setting the time. (line 6) -* appropriate privileges: install invocation. (line 79) +* appropriate privileges: install invocation. (line 86) * arbitrary date strings, parsing: Options for date. (line 11) * arbitrary text, displaying: echo invocation. (line 6) * arch: arch invocation. (line 6) @@ -15537,6 +15552,7 @@ Index * cio: dd invocation. (line 155) * cksum: cksum invocation. (line 6) * clocal: Control. (line 33) +* clone: cp invocation. (line 261) * cntrl: Character sets. (line 100) * color database, printing: dircolors invocation. (line 45) @@ -15609,6 +15625,7 @@ Index * converting while copying a file: dd invocation. (line 6) * cooked: Combination. (line 37) * Coordinated Universal Time: Options for date. (line 87) +* copy on write: cp invocation. (line 261) * copying directories recursively: cp invocation. (line 90) * copying existing permissions: Copying Permissions. (line 6) * copying files: cat invocation. (line 6) @@ -15616,6 +15633,7 @@ Index * copying files and setting attributes: install invocation. (line 6) * core utilities: Top. (line 18) * count: dd invocation. (line 51) +* COW: cp invocation. (line 261) * cp: cp invocation. (line 6) * crashes and corruption: sync invocation. (line 11) * CRC checksum: cksum invocation. (line 6) @@ -15627,7 +15645,7 @@ Index * creating output file, avoiding: dd invocation. (line 109) * creating output file, requiring: dd invocation. (line 113) * crN: Output. (line 45) -* crown margin: fmt invocation. (line 41) +* crown margin: fmt invocation. (line 34) * crt: Combination. (line 75) * crterase: Local. (line 22) * crtkill: Local. (line 56) @@ -15664,11 +15682,11 @@ Index * delaying commands: Delaying. (line 6) * deleting characters: Squeezing. (line 6) * dereferencing symbolic links: ln invocation. (line 40) -* descriptor follow option: tail invocation. (line 47) +* descriptor follow option: tail invocation. (line 48) * destination directory <1>: ln invocation. (line 127) * destination directory <2>: mv invocation. (line 103) -* destination directory <3>: install invocation. (line 113) -* destination directory <4>: cp invocation. (line 326) +* destination directory <3>: install invocation. (line 120) +* destination directory <4>: cp invocation. (line 336) * destination directory: Target directory. (line 15) * destinations, multiple output: tee invocation. (line 6) * device file, disk: df invocation. (line 19) @@ -15687,7 +15705,7 @@ Index * directories, copying recursively: cp invocation. (line 90) * directories, creating: mkdir invocation. (line 6) * directories, creating with given attributes: install invocation. - (line 55) + (line 62) * directories, removing (recursively): rm invocation. (line 91) * directories, removing empty: rmdir invocation. (line 6) * directory: dd invocation. (line 169) @@ -15831,7 +15849,7 @@ Index * file characteristic tests: File characteristic tests. (line 6) * file contents, dumping unambiguously: od invocation. (line 6) -* file information, preserving: cp invocation. (line 232) +* file information, preserving: cp invocation. (line 231) * file information, preserving, extended attributes, xattr: cp invocation. (line 163) * file mode bits, numeric: Numeric Modes. (line 6) @@ -15859,7 +15877,7 @@ Index * file system types, printing: df invocation. (line 119) * file systems: stat invocation. (line 28) * file systems and hard links: ln invocation. (line 6) -* file systems, omitting copying to different: cp invocation. (line 349) +* file systems, omitting copying to different: cp invocation. (line 359) * file timestamps, changing: touch invocation. (line 6) * file type and executables, marking: General output formatting. (line 36) @@ -15919,13 +15937,13 @@ Index (line 6) * group owner, default: Mode Structure. (line 31) * group ownership of installed files, setting: install invocation. - (line 61) + (line 68) * group ownership, changing <1>: chgrp invocation. (line 6) * group ownership, changing: chown invocation. (line 6) * group wheel, not supported: su invocation. (line 87) * group, permissions for: Setting Permissions. (line 26) * groups: groups invocation. (line 6) -* growing files: tail invocation. (line 47) +* growing files: tail invocation. (line 48) * hangups, immunity to: nohup invocation. (line 6) * hard link check: File characteristic tests. (line 23) @@ -15947,7 +15965,7 @@ Index * help, online: Common options. (line 37) * hex dump of files: od invocation. (line 6) * High Sierra file system: df invocation. (line 135) -* holes, copying files with: cp invocation. (line 274) +* holes, copying files with: cp invocation. (line 284) * holes, creating files with: truncate invocation. (line 13) * HOME: su invocation. (line 18) * horizontal, listing files: General output formatting. @@ -16059,7 +16077,7 @@ Index * lcase, converting to: dd invocation. (line 93) * lchown <1>: chgrp invocation. (line 30) * lchown: chown invocation. (line 103) -* leading directories, creating missing: install invocation. (line 55) +* leading directories, creating missing: install invocation. (line 62) * leading directory components, stripping: basename invocation. (line 6) * left margin: pr invocation. (line 200) @@ -16170,13 +16188,13 @@ Index * multiplication: Numeric expressions. (line 16) * multipliers after numbers: dd invocation. (line 227) * mv: mv invocation. (line 6) -* name follow option: tail invocation. (line 47) +* name follow option: tail invocation. (line 48) * name of kernel: uname invocation. (line 65) * named pipe check: File type tests. (line 28) * named pipes, creating: mkfifo invocation. (line 6) * network node name: uname invocation. (line 46) * never interactive option: rm invocation. (line 52) -* newer files, copying only: cp invocation. (line 335) +* newer files, copying only: cp invocation. (line 345) * newer files, moving only: mv invocation. (line 80) * newer-than file check: File characteristic tests. (line 15) @@ -16297,7 +16315,7 @@ Index (line 28) * owner of file, permissions for: Setting Permissions. (line 23) * owner, default: Mode Structure. (line 31) -* ownership of installed files, setting: install invocation. (line 79) +* ownership of installed files, setting: install invocation. (line 86) * p for FIFO file: mknod invocation. (line 28) * pad character: Output. (line 34) * pad instead of timing for delaying: Output. (line 30) @@ -16305,9 +16323,9 @@ Index (line 6) * paragraphs, reformatting: fmt invocation. (line 6) * parenb: Control. (line 9) -* parent directories and cp: cp invocation. (line 236) +* parent directories and cp: cp invocation. (line 235) * parent directories, creating: mkdir invocation. (line 34) -* parent directories, creating missing: install invocation. (line 55) +* parent directories, creating missing: install invocation. (line 62) * parent directories, removing: rmdir invocation. (line 22) * parentheses for grouping: expr invocation. (line 31) * parity: Combination. (line 10) @@ -16332,7 +16350,7 @@ Index * permission tests: Access permission tests. (line 6) * permissions of installed files, setting: install invocation. - (line 67) + (line 74) * permissions, changing access: chmod invocation. (line 6) * permissions, copying existing: Copying Permissions. (line 6) * permissions, for changing file timestamps: touch invocation. @@ -16356,9 +16374,8 @@ Index * POSIXLY_CORRECT <2>: echo invocation. (line 73) * POSIXLY_CORRECT <3>: dd invocation. (line 261) * POSIXLY_CORRECT <4>: sort invocation. (line 284) -* POSIXLY_CORRECT <5>: tail invocation. (line 81) -* POSIXLY_CORRECT <6>: pr invocation. (line 105) -* POSIXLY_CORRECT <7>: Standards conformance. +* POSIXLY_CORRECT <5>: pr invocation. (line 105) +* POSIXLY_CORRECT <6>: Standards conformance. (line 6) * POSIXLY_CORRECT: Common options. (line 11) * POSIXLY_CORRECT, and block size: Block size. (line 12) @@ -16420,7 +16437,7 @@ Index (line 6) * read permission: Mode Structure. (line 12) * read permission, symbolic: Setting Permissions. (line 57) -* read system call, and holes: cp invocation. (line 274) +* read system call, and holes: cp invocation. (line 284) * readable file check: Access permission tests. (line 15) * readlink: readlink invocation. (line 6) @@ -16463,7 +16480,7 @@ Index * rm: rm invocation. (line 6) * rmdir: rmdir invocation. (line 6) * rn format for nl: nl invocation. (line 101) -* root as default owner: install invocation. (line 79) +* root as default owner: install invocation. (line 86) * root directory, allow recursive destruction: rm invocation. (line 84) * root directory, allow recursive modification <1>: chmod invocation. (line 54) @@ -16506,7 +16523,7 @@ Index * security context <2>: mknod invocation. (line 54) * security context <3>: mkfifo invocation. (line 28) * security context <4>: mkdir invocation. (line 56) -* security context <5>: install invocation. (line 84) +* security context <5>: install invocation. (line 91) * security context: What information is listed. (line 268) * seek: dd invocation. (line 48) @@ -16515,7 +16532,7 @@ Index * SELinux <2>: mknod invocation. (line 54) * SELinux <3>: mkfifo invocation. (line 28) * SELinux <4>: mkdir invocation. (line 56) -* SELinux <5>: install invocation. (line 84) +* SELinux <5>: install invocation. (line 91) * SELinux: What information is listed. (line 268) * SELinux context: SELinux context. (line 6) @@ -16584,7 +16601,7 @@ Index * sorting files: sort invocation. (line 6) * sorting ls output: Sorting the output. (line 6) * space: Character sets. (line 118) -* sparse files, copying: cp invocation. (line 274) +* sparse files, copying: cp invocation. (line 284) * sparse files, creating: truncate invocation. (line 13) * special characters: Characters. (line 6) * special file types: Special file types. (line 6) @@ -16619,9 +16636,9 @@ Index * strip directory and suffix from file names: basename invocation. (line 6) * stripping non-directory suffix: dirname invocation. (line 6) -* stripping symbol table information: install invocation. (line 101) +* stripping symbol table information: install invocation. (line 108) * stripping trailing slashes <1>: mv invocation. (line 93) -* stripping trailing slashes: cp invocation. (line 308) +* stripping trailing slashes: cp invocation. (line 318) * stty: stty invocation. (line 6) * su: su invocation. (line 6) * substitute user and group IDs: su invocation. (line 6) @@ -16639,9 +16656,9 @@ Index * swab (byte-swapping): dd invocation. (line 101) * swap space, saving text image in: Mode Structure. (line 56) * swtch: Characters. (line 41) -* symbol table information, stripping: install invocation. (line 101) +* symbol table information, stripping: install invocation. (line 108) * symbol table information, stripping, program: install invocation. - (line 104) + (line 111) * symbolic (soft) links, creating: ln invocation. (line 6) * symbolic link check: File type tests. (line 23) * symbolic link to directory, controlling traversal of: Traversing symlinks. @@ -16676,7 +16693,7 @@ Index * symbolic links, changing owner <1>: chgrp invocation. (line 30) * symbolic links, changing owner: chown invocation. (line 80) * symbolic links, copying: cp invocation. (line 103) -* symbolic links, copying with: cp invocation. (line 313) +* symbolic links, copying with: cp invocation. (line 323) * symbolic links, dereferencing: Which files are listed. (line 36) * symbolic links, dereferencing in du: du invocation. (line 101) @@ -16704,13 +16721,13 @@ Index * tabs: Combination. (line 66) * tabs to spaces, converting: expand invocation. (line 6) * tac: tac invocation. (line 6) -* tagged paragraphs: fmt invocation. (line 47) +* tagged paragraphs: fmt invocation. (line 40) * tail: tail invocation. (line 6) * tandem: Input. (line 45) * target directory <1>: ln invocation. (line 127) * target directory <2>: mv invocation. (line 103) -* target directory <3>: install invocation. (line 113) -* target directory <4>: cp invocation. (line 326) +* target directory <3>: install invocation. (line 120) +* target directory <4>: cp invocation. (line 336) * target directory: Target directory. (line 6) * tebibyte, definition of: Block size. (line 106) * tee: tee invocation. (line 6) @@ -16758,7 +16775,7 @@ Index (line 106) * timeout: timeout invocation. (line 6) * timestamps of installed files, preserving: install invocation. - (line 91) + (line 98) * timestamps, changing file: touch invocation. (line 6) * TMPDIR: sort invocation. (line 64) * today in date strings: Relative items in date strings. @@ -16907,198 +16924,198 @@ Node: cat invocation50013 Node: tac invocation51769 Node: nl invocation53031 Node: od invocation56910 -Node: base64 invocation63732 -Node: Formatting file contents65111 -Node: fmt invocation65562 -Node: pr invocation68627 -Node: fold invocation81084 -Node: Output of parts of files82544 -Node: head invocation83052 -Node: tail invocation85211 -Node: split invocation93561 -Node: csplit invocation95891 -Node: Summarizing files100642 -Node: wc invocation101290 -Node: sum invocation104364 -Node: cksum invocation105769 -Node: md5sum invocation106909 -Node: sha1sum invocation111970 -Node: sha2 utilities112750 -Node: Operating on sorted files113374 -Node: sort invocation113975 -Ref: sort invocation-Footnote-1136826 -Node: shuf invocation137378 -Node: uniq invocation139957 -Node: comm invocation144649 -Node: ptx invocation147070 -Node: General options in ptx149874 -Node: Charset selection in ptx150455 -Node: Input processing in ptx151357 -Node: Output formatting in ptx156778 -Node: Compatibility in ptx163344 -Node: tsort invocation166577 -Node: tsort background169736 -Node: Operating on fields within a line171384 -Node: cut invocation171788 -Node: paste invocation175105 -Node: join invocation176433 -Node: Operating on characters181568 -Node: tr invocation182004 -Node: Character sets183722 -Node: Translating188153 -Node: Squeezing190244 -Node: expand invocation193311 -Node: unexpand invocation194793 -Node: Directory listing196611 -Node: ls invocation197097 -Ref: ls invocation-Footnote-1199171 -Node: Which files are listed199393 -Node: What information is listed203133 -Node: Sorting the output212380 -Node: More details about version sort214700 -Node: General output formatting216427 -Node: Formatting file timestamps220335 -Node: Formatting the file names225676 -Node: dir invocation228592 -Node: vdir invocation229003 -Node: dircolors invocation229381 -Node: Basic operations231079 -Node: cp invocation231699 -Node: dd invocation246687 -Node: install invocation256395 -Node: mv invocation261418 -Node: rm invocation265854 -Node: shred invocation270158 -Node: Special file types277671 -Node: link invocation279177 -Node: ln invocation280183 -Node: mkdir invocation286550 -Node: mkfifo invocation288921 -Node: mknod invocation290041 -Node: readlink invocation292171 -Node: rmdir invocation294037 -Node: unlink invocation295311 -Node: Changing file attributes296270 -Node: chown invocation297084 -Node: chgrp invocation303270 -Node: chmod invocation306320 -Node: touch invocation309075 -Node: Disk usage313721 -Node: df invocation314382 -Node: du invocation320324 -Node: stat invocation328850 -Node: sync invocation332832 -Node: truncate invocation333787 -Node: Printing text335515 -Node: echo invocation335889 -Node: printf invocation338318 -Node: yes invocation343554 -Node: Conditions344166 -Node: false invocation344757 -Node: true invocation345792 -Node: test invocation347071 -Node: File type tests349111 -Node: Access permission tests349993 -Node: File characteristic tests350878 -Node: String tests351643 -Node: Numeric tests352308 -Node: Connectives for test353114 -Node: expr invocation353467 -Node: String expressions355908 -Node: Numeric expressions358492 -Node: Relations for expr359189 -Node: Examples of expr360383 -Node: Redirection361107 -Node: tee invocation361565 -Node: File name manipulation366355 -Node: basename invocation366816 -Node: dirname invocation368263 -Node: pathchk invocation369469 -Node: Working context371207 -Node: pwd invocation371851 -Node: stty invocation373195 -Node: Control375955 -Node: Input376715 -Node: Output378388 -Node: Local379708 -Node: Combination381290 -Node: Characters383511 -Node: Special385065 -Node: printenv invocation386722 -Node: tty invocation387485 -Node: User information388191 -Node: id invocation388826 -Node: logname invocation390597 -Node: whoami invocation391224 -Node: groups invocation391711 -Node: users invocation392916 -Node: who invocation393863 -Node: System context396799 -Node: date invocation397400 -Node: Time conversion specifiers399117 -Node: Date conversion specifiers401517 -Node: Literal conversion specifiers404641 -Node: Padding and other flags404999 -Node: Setting the time407190 -Node: Options for date408196 -Node: Examples of date411672 -Ref: %s-examples413090 -Node: arch invocation415275 -Node: uname invocation415724 -Node: hostname invocation418297 -Node: hostid invocation418910 -Node: uptime invocation419621 -Node: SELinux context420744 -Node: chcon invocation421119 -Node: runcon invocation422941 -Node: Modified command invocation424407 -Node: chroot invocation425157 -Ref: chroot invocation-Footnote-1427725 -Node: env invocation428027 -Node: nice invocation430085 -Node: nohup invocation433799 -Node: stdbuf invocation435959 -Node: su invocation438134 -Node: timeout invocation442635 -Node: Process control443794 -Node: kill invocation444017 -Node: Delaying447088 -Node: sleep invocation447285 -Node: Numeric operations448405 -Node: factor invocation448737 -Node: seq invocation450488 -Node: File permissions454108 -Node: Mode Structure454726 -Node: Symbolic Modes458421 -Node: Setting Permissions459519 -Node: Copying Permissions462132 -Node: Changing Special Mode Bits462951 -Node: Conditional Executability464773 -Node: Multiple Changes465317 -Node: Umask and Protection466984 -Node: Numeric Modes468089 -Node: Directory Setuid and Setgid469989 -Node: Date input formats472251 -Node: General date syntax474604 -Node: Calendar date items477563 -Node: Time of day items479568 -Node: Time zone items481772 -Node: Day of week items483014 -Node: Relative items in date strings484011 -Node: Pure numbers in date strings486821 -Node: Seconds since the Epoch487810 -Node: Specifying time zone rules489439 -Node: Authors of get_date491811 -Node: Opening the software toolbox492571 -Node: Toolbox introduction493243 -Node: I/O redirection495966 -Node: The who command498800 -Node: The cut command499697 -Node: The sort command500760 -Node: The uniq command501464 -Node: Putting the tools together502154 -Ref: Putting the tools together-Footnote-1514106 -Node: GNU Free Documentation License514180 -Node: Concept index539373 +Node: base64 invocation63758 +Node: Formatting file contents65137 +Node: fmt invocation65588 +Node: pr invocation68401 +Node: fold invocation80858 +Node: Output of parts of files82318 +Node: head invocation82826 +Node: tail invocation85011 +Node: split invocation93489 +Node: csplit invocation95850 +Node: Summarizing files100601 +Node: wc invocation101249 +Node: sum invocation104323 +Node: cksum invocation105728 +Node: md5sum invocation106868 +Node: sha1sum invocation111929 +Node: sha2 utilities112709 +Node: Operating on sorted files113333 +Node: sort invocation113934 +Ref: sort invocation-Footnote-1136785 +Node: shuf invocation137337 +Node: uniq invocation139916 +Node: comm invocation144608 +Node: ptx invocation147029 +Node: General options in ptx149833 +Node: Charset selection in ptx150414 +Node: Input processing in ptx151316 +Node: Output formatting in ptx156737 +Node: Compatibility in ptx163303 +Node: tsort invocation166536 +Node: tsort background169695 +Node: Operating on fields within a line171343 +Node: cut invocation171747 +Node: paste invocation175064 +Node: join invocation176392 +Node: Operating on characters181527 +Node: tr invocation181963 +Node: Character sets183681 +Node: Translating188112 +Node: Squeezing190203 +Node: expand invocation193270 +Node: unexpand invocation194752 +Node: Directory listing196570 +Node: ls invocation197056 +Ref: ls invocation-Footnote-1199130 +Node: Which files are listed199352 +Node: What information is listed203092 +Node: Sorting the output212339 +Node: More details about version sort214659 +Node: General output formatting216386 +Node: Formatting file timestamps220294 +Node: Formatting the file names225635 +Node: dir invocation228551 +Node: vdir invocation228962 +Node: dircolors invocation229340 +Node: Basic operations231038 +Node: cp invocation231658 +Node: dd invocation246936 +Node: install invocation256654 +Node: mv invocation261929 +Node: rm invocation266365 +Node: shred invocation270669 +Node: Special file types278182 +Node: link invocation279688 +Node: ln invocation280694 +Node: mkdir invocation287061 +Node: mkfifo invocation289432 +Node: mknod invocation290552 +Node: readlink invocation292682 +Node: rmdir invocation294548 +Node: unlink invocation295822 +Node: Changing file attributes296781 +Node: chown invocation297595 +Node: chgrp invocation303781 +Node: chmod invocation306831 +Node: touch invocation309586 +Node: Disk usage314232 +Node: df invocation314893 +Node: du invocation320835 +Node: stat invocation329361 +Node: sync invocation333343 +Node: truncate invocation334298 +Node: Printing text336057 +Node: echo invocation336431 +Node: printf invocation338860 +Node: yes invocation344096 +Node: Conditions344708 +Node: false invocation345299 +Node: true invocation346334 +Node: test invocation347613 +Node: File type tests349653 +Node: Access permission tests350535 +Node: File characteristic tests351420 +Node: String tests352185 +Node: Numeric tests352850 +Node: Connectives for test353656 +Node: expr invocation354009 +Node: String expressions356450 +Node: Numeric expressions359034 +Node: Relations for expr359731 +Node: Examples of expr360925 +Node: Redirection361649 +Node: tee invocation362107 +Node: File name manipulation366897 +Node: basename invocation367358 +Node: dirname invocation368805 +Node: pathchk invocation370011 +Node: Working context371749 +Node: pwd invocation372393 +Node: stty invocation373737 +Node: Control376497 +Node: Input377257 +Node: Output378930 +Node: Local380250 +Node: Combination381832 +Node: Characters384053 +Node: Special385607 +Node: printenv invocation387264 +Node: tty invocation388027 +Node: User information388733 +Node: id invocation389368 +Node: logname invocation391139 +Node: whoami invocation391766 +Node: groups invocation392253 +Node: users invocation393458 +Node: who invocation394405 +Node: System context397341 +Node: date invocation397942 +Node: Time conversion specifiers399659 +Node: Date conversion specifiers402059 +Node: Literal conversion specifiers405183 +Node: Padding and other flags405541 +Node: Setting the time407732 +Node: Options for date408738 +Node: Examples of date412214 +Ref: %s-examples413632 +Node: arch invocation415817 +Node: uname invocation416266 +Node: hostname invocation418839 +Node: hostid invocation419452 +Node: uptime invocation420163 +Node: SELinux context421286 +Node: chcon invocation421661 +Node: runcon invocation423483 +Node: Modified command invocation424949 +Node: chroot invocation425699 +Ref: chroot invocation-Footnote-1428267 +Node: env invocation428569 +Node: nice invocation430627 +Node: nohup invocation434341 +Node: stdbuf invocation436501 +Node: su invocation438702 +Node: timeout invocation443203 +Node: Process control444362 +Node: kill invocation444585 +Node: Delaying447656 +Node: sleep invocation447853 +Node: Numeric operations448973 +Node: factor invocation449305 +Node: seq invocation451056 +Node: File permissions454676 +Node: Mode Structure455294 +Node: Symbolic Modes458989 +Node: Setting Permissions460087 +Node: Copying Permissions462700 +Node: Changing Special Mode Bits463519 +Node: Conditional Executability465341 +Node: Multiple Changes465885 +Node: Umask and Protection467552 +Node: Numeric Modes468657 +Node: Directory Setuid and Setgid470557 +Node: Date input formats472819 +Node: General date syntax475172 +Node: Calendar date items478131 +Node: Time of day items480136 +Node: Time zone items482340 +Node: Day of week items483582 +Node: Relative items in date strings484579 +Node: Pure numbers in date strings487389 +Node: Seconds since the Epoch488378 +Node: Specifying time zone rules490007 +Node: Authors of get_date492379 +Node: Opening the software toolbox493139 +Node: Toolbox introduction493811 +Node: I/O redirection496534 +Node: The who command499368 +Node: The cut command500265 +Node: The sort command501328 +Node: The uniq command502032 +Node: Putting the tools together502722 +Ref: Putting the tools together-Footnote-1514674 +Node: GNU Free Documentation License514748 +Node: Concept index539941  End Tag Table diff --git a/src/bin/coreutils/doc/coreutils.texi b/src/bin/coreutils/doc/coreutils.texi index 8e1b73d637..22d307a998 100644 --- a/src/bin/coreutils/doc/coreutils.texi +++ b/src/bin/coreutils/doc/coreutils.texi @@ -618,15 +618,8 @@ from the shell. @end macro @macro multiplierSuffixes{varName} -@ignore -Appending @samp{b} multiplies @var{\varName\} by 512, -@samp{kB} by 1000, @samp{K} by 1024, -@samp{MB} by 1000*1000, @samp{M} by 1024*1024, -@samp{GB} by 1000*1000*1000, @samp{G} by 1024*1024*1024, -and so on for @samp{T}, @samp{P}, @samp{E}, @samp{Z}, and @samp{Y}. -@end ignore -@var{\varName\} is a number which may have one of the following -multiplicative suffixes: +@var{\varName\} may be, or may be an integer optionally followed by, +one of the following multiplicative suffixes: @example @samp{b} => 512 ("blocks") @samp{KB} => 1000 (KiloBytes) @@ -641,8 +634,8 @@ and so on for @samp{T}, @samp{P}, @samp{E}, @samp{Z}, and @samp{Y}. @c FIXME: same as above, but no ``blocks'' line. @macro multiplierSuffixesNoBlocks{varName} -@var{\varName\} is a number which may have one of the following -multiplicative suffixes: +@var{\varName\} may be, or may be an integer optionally followed by, +one of the following multiplicative suffixes: @example @samp{KB} => 1000 (KiloBytes) @samp{K} => 1024 (KibiBytes) @@ -2122,14 +2115,6 @@ The program accepts the following options. Also see @ref{Common options}. @table @samp -@item -C -@itemx --compare -@opindex -C -@opindex --compare -Compare each pair of source and destination files, and if the destination has -identical content and any specified owner, group, permissions, and possibly -SELinux context, then do not modify the destination at all. - @item -c @itemx --crown-margin @opindex -c @@ -2790,9 +2775,10 @@ growing. The option values @samp{descriptor} and @samp{name} may be specified only with the long form of the option, not with @option{-f}. -@vindex POSIXLY_CORRECT -If @env{POSIXLY_CORRECT} is set, the @option{-f} option is ignored if +The @option{-f} option is ignored if no @var{file} operand is specified and standard input is a FIFO or a pipe. +Likewise, the @option{-f} option has no effect for any +operand specified as @samp{-}, when standard input is a FIFO or a pipe. @item -F @opindex -F @@ -7445,12 +7431,10 @@ may preserve the group ownership of a file only if they happen to be a member of the desired group. @itemx timestamps Preserve the times of last access and last modification, when possible. -In general, it is not possible to preserve these attributes +On older systems, it is not possible to preserve these attributes when the affected file is a symbolic link. -However, FreeBSD now provides the @code{lutimes} function, which makes -it possible even for symbolic links. However, this implementation does -not yet take advantage of that. -@c FIXME: once we provide lutimes support, update the above. +However, many systems now provide the @code{utimensat} function, +which makes it possible even for symbolic links. @itemx links Preserve in the destination files any links between corresponding source files. @@ -7543,15 +7527,31 @@ Also, it is not portable to use @option{-R} to copy symbolic links unless you also specify @option{-P}, as @acronym{POSIX} allows implementations that dereference symbolic links by default. -@item --reflink -@opindex --reflink +@item --reflink[=@var{when}] +@opindex --reflink[=@var{when}] +@cindex COW +@cindex clone +@cindex copy on write Perform a lightweight, copy-on-write (COW) copy. -Copying with this option can succeed only on some relatively new file systems. +Copying with this option can succeed only on some file systems. Once it has succeeded, beware that the source and destination files share the same disk data blocks as long as they remain unmodified. Thus, if a disk I/O error affects data blocks of one of the files, the other suffers the exact same fate. +The @var{when} value can be one of the following: + +@table @samp +@item always +The default behavior: if the copy-on-write operation is not supported +then report the failure for each file and exit with a failure status. + +@item auto +If the copy-on-write operation is not supported then fall back +to the standard copy behaviour. +@end table + + @item --remove-destination @opindex --remove-destination Remove each existing destination file before attempting to open it @@ -7768,8 +7768,8 @@ input newline with a space and padding with spaces as necessary. @item unblock @opindex unblock -Replace trailing spaces in each @samp{cbs}-sized input block with a -newline. +Remove any trailing spaces in each @samp{cbs}-sized input block, +and append a newline. The @samp{block} and @samp{unblock} conversions are mutually exclusive. @@ -8058,6 +8058,14 @@ The program accepts the following options. Also see @ref{Common options}. @optBackup +@item -C +@itemx --compare +@opindex -C +@opindex --compare +Compare each pair of source and destination files, and if the destination has +identical content and any specified owner, group, permissions, and possibly +SELinux context, then do not modify the destination at all. + @item -c @opindex -c Ignored; for compatibility with old Unix versions of @command{install}. diff --git a/src/bin/coreutils/doc/stamp-vti b/src/bin/coreutils/doc/stamp-vti index ff98e44c49..39a3ddb05d 100644 --- a/src/bin/coreutils/doc/stamp-vti +++ b/src/bin/coreutils/doc/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 18 August 2009 -@set UPDATED-MONTH August 2009 -@set EDITION 7.5 -@set VERSION 7.5 +@set UPDATED 10 September 2009 +@set UPDATED-MONTH September 2009 +@set EDITION 7.6 +@set VERSION 7.6 diff --git a/src/bin/coreutils/doc/version.texi b/src/bin/coreutils/doc/version.texi index ff98e44c49..39a3ddb05d 100644 --- a/src/bin/coreutils/doc/version.texi +++ b/src/bin/coreutils/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 18 August 2009 -@set UPDATED-MONTH August 2009 -@set EDITION 7.5 -@set VERSION 7.5 +@set UPDATED 10 September 2009 +@set UPDATED-MONTH September 2009 +@set EDITION 7.6 +@set VERSION 7.6 diff --git a/src/bin/coreutils/lib/Jamfile b/src/bin/coreutils/lib/Jamfile index 74499fca7b..69d4a6b98d 100644 --- a/src/bin/coreutils/lib/Jamfile +++ b/src/bin/coreutils/lib/Jamfile @@ -4,7 +4,7 @@ SubDir HAIKU_TOP src bin coreutils lib ; TARGET_WARNING_CCFLAGS = [ FFilter $(TARGET_WARNING_CCFLAGS) : -Wall -Wmissing-prototypes -Wsign-compare ] ; -SubDirCcFlags -DHAVE_CONFIG_H ; +SubDirCcFlags -DHAVE_CONFIG_H -DB_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT ; SubDirSysHdrs $(SUBDIR) ; #SubDirSysHdrs $(SUBDIR) $(DOTDOT) ; @@ -139,6 +139,7 @@ StaticLibrary libfetish.a : openat-die.c openat-proc.c openat.c + opendir-safer.c physmem.c posixtm.c posixver.c diff --git a/src/bin/coreutils/lib/Makefile.in b/src/bin/coreutils/lib/Makefile.in index a619d6980d..8181cd0ad4 100644 --- a/src/bin/coreutils/lib/Makefile.in +++ b/src/bin/coreutils/lib/Makefile.in @@ -26,7 +26,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --avoid=lock --no-libtool --macro-prefix=gl acl alloca announce-gen areadlink-with-size argmatch argv-iter assert atexit autobuild backupfile base64 c-strcase c-strtod c-strtold calloc canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type diacrit dirfd dirname dup2 error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu fopen-safer fprintftime fseeko fsusage ftello ftruncate fts gendocs getdate getgroups gethrxtime getline getloadavg getndelim2 getopt-gnu getpagesize getpass-gnu gettext gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnumakefile gnupload group-member hard-locale hash hash-pjw host-os human idcache ignore-value inttostr inttypes isapipe lchmod lchown lib-ignore linebuffer link-follow long-options lstat maintainer-makefile malloc manywarnings mbrtowc mbsalign mbswidth memcasecmp memchr memcmp memcmp2 memcpy memmove mempcpy memrchr memset mgetgroups mkancesdirs mkdir mkdir-p mkstemp mktime modechange mountlist mpsort obstack pathmax perl physmem posix-shell posixtm posixver priv-set progname propername putenv quote quotearg raise randint randperm readlink readtokens readtokens0 readutmp realloc regex rename rename-dest-slash rmdir rmdir-errno root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at settime sig2str sigaction ssize_t stat-macros stat-time stdbool stdlib-safer stpcpy stpncpy strcspn strdup strftime strpbrk strtod strtoimax strtol strtoumax strverscmp sys_stat timespec tzset unicodeio unistd-safer unlink-busy unlinkdir unlocked-io update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf warnings wcwidth winsz-ioctl winsz-termios write-any-file xalloc xfreopen xgetcwd xgethostname xmemcoll xnanosleep xprintf xprintf-posix xstrtod xstrtoimax xstrtol xstrtold xstrtoumax yesno +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --avoid=lock --no-libtool --macro-prefix=gl acl alloca announce-gen areadlink-with-size argmatch argv-iter assert atexit autobuild backupfile base64 c-strcase c-strtod c-strtold calloc canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type diacrit dirfd dirname dup2 error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu fopen-safer fprintftime fseeko fsusage ftello ftruncate fts gendocs getdate getgroups gethrxtime getline getloadavg getndelim2 getopt-gnu getpagesize getpass-gnu gettext gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnumakefile gnupload group-member hard-locale hash hash-pjw host-os human idcache ignore-value inttostr inttypes isapipe lchmod lchown lib-ignore linebuffer link link-follow long-options lstat maintainer-makefile malloc manywarnings mbrtowc mbsalign mbswidth memcasecmp memchr memcmp memcmp2 memcpy memmove mempcpy memrchr memset mgetgroups mkancesdirs mkdir mkdir-p mkstemp mktime modechange mountlist mpsort obstack pathmax perl physmem posix-shell posixtm posixver priv-set progname propername putenv quote quotearg raise randint randperm readlink readtokens readtokens0 readutmp realloc regex rename rename-dest-slash rmdir rmdir-errno root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at settime sig2str sigaction ssize_t stat-macros stat-time stdbool stdlib-safer stpcpy stpncpy strcspn strdup strftime strpbrk strtod strtoimax strtol strtoumax strverscmp sys_stat timespec tzset unicodeio unistd-safer unlink-busy unlinkdir unlocked-io update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf warnings wcwidth winsz-ioctl winsz-termios write-any-file xalloc xfreopen xgetcwd xgethostname xmemcoll xnanosleep xprintf xprintf-posix xstrtod xstrtoimax xstrtol xstrtold xstrtoumax yesno @@ -73,22 +73,23 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ - $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ - $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ - $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ - $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ - $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ + $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ + $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ + $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ + $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ + $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ - $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ - $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ - $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ + $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ + $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ + $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ + $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ @@ -130,37 +131,38 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ - $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ - $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/long-options.m4 \ - $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ - $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ - $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ - $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ - $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ - $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ - $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbsrtowcs.m4 \ - $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/mbswidth.m4 \ - $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memcasecmp.m4 \ - $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/memcmp.m4 \ - $(top_srcdir)/m4/memcoll.m4 $(top_srcdir)/m4/memcpy.m4 \ - $(top_srcdir)/m4/memmove.m4 $(top_srcdir)/m4/mempcpy.m4 \ - $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/memset.m4 \ - $(top_srcdir)/m4/memxfrm.m4 $(top_srcdir)/m4/mgetgroups.m4 \ - $(top_srcdir)/m4/mkancesdirs.m4 $(top_srcdir)/m4/mkdir-p.m4 \ - $(top_srcdir)/m4/mkdir-slash.m4 $(top_srcdir)/m4/mkstemp.m4 \ - $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ - $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/modechange.m4 \ - $(top_srcdir)/m4/mountlist.m4 $(top_srcdir)/m4/mpsort.m4 \ - $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/nanosleep.m4 \ - $(top_srcdir)/m4/netdb_h.m4 $(top_srcdir)/m4/netinet_in_h.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/nocrash.m4 \ - $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ - $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ - $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ - $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ - $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ + $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ + $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ + $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ + $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ + $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ + $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ + $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ + $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ + $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ + $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/memcmp.m4 $(top_srcdir)/m4/memcoll.m4 \ + $(top_srcdir)/m4/memcpy.m4 $(top_srcdir)/m4/memmove.m4 \ + $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ + $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ + $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ + $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ + $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ + $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ + $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ + $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ + $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ + $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ + $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ @@ -395,6 +397,7 @@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNULIB_ACCEPT = @GNULIB_ACCEPT@ +GNULIB_ACCEPT4 = @GNULIB_ACCEPT4@ GNULIB_ALPHASORT = @GNULIB_ALPHASORT@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ @@ -408,10 +411,15 @@ GNULIB_CONNECT = @GNULIB_CONNECT@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ +GNULIB_DUP3 = @GNULIB_DUP3@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ +GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ +GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ +GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ GNULIB_FLOORL = @GNULIB_FLOORL@ @@ -426,6 +434,7 @@ GNULIB_FREXP = @GNULIB_FREXP@ GNULIB_FREXPL = @GNULIB_FREXPL@ GNULIB_FSEEK = @GNULIB_FSEEK@ GNULIB_FSEEKO = @GNULIB_FSEEKO@ +GNULIB_FSTATAT = @GNULIB_FSTATAT@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ @@ -489,12 +498,19 @@ GNULIB_MEMCHR = @GNULIB_MEMCHR@ GNULIB_MEMMEM = @GNULIB_MEMMEM@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ +GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNODAT = @GNULIB_MKNODAT@ +GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ +GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ +GNULIB_PIPE2 = @GNULIB_PIPE2@ +GNULIB_POPEN = @GNULIB_POPEN@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -504,9 +520,11 @@ GNULIB_PUTS = @GNULIB_PUTS@ GNULIB_RANDOM_R = @GNULIB_RANDOM_R@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ +GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_RENAME = @GNULIB_RENAME@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -546,11 +564,13 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ @@ -567,6 +587,7 @@ GNULIB_WCTOB = @GNULIB_WCTOB@ GNULIB_WCWIDTH = @GNULIB_WCWIDTH@ GNULIB_WRITE = @GNULIB_WRITE@ GREP = @GREP@ +HAVE_ACCEPT4 = @HAVE_ACCEPT4@ HAVE_ALPHASORT = @HAVE_ALPHASORT@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ @@ -617,8 +638,14 @@ HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@ HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@ HAVE_DPRINTF = @HAVE_DPRINTF@ HAVE_DUP2 = @HAVE_DUP2@ +HAVE_DUP3 = @HAVE_DUP3@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ +HAVE_FACCESSAT = @HAVE_FACCESSAT@ +HAVE_FCHMODAT = @HAVE_FCHMODAT@ +HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ HAVE_FSEEKO = @HAVE_FSEEKO@ +HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ @@ -644,15 +671,22 @@ HAVE_MBSINIT = @HAVE_MBSINIT@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ +HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNODAT = @HAVE_MKNODAT@ +HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ +HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ +HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ @@ -670,7 +704,6 @@ HAVE_STPCPY = @HAVE_STPCPY@ HAVE_STPNCPY = @HAVE_STPNCPY@ HAVE_STRCASESTR = @HAVE_STRCASESTR@ HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ -HAVE_STRNDUP = @HAVE_STRNDUP@ HAVE_STRPBRK = @HAVE_STRPBRK@ HAVE_STRSEP = @HAVE_STRSEP@ HAVE_STRTOD = @HAVE_STRTOD@ @@ -682,6 +715,8 @@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ +HAVE_SYMLINK = @HAVE_SYMLINK@ +HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@ HAVE_SYS_IOCTL_H = @HAVE_SYS_IOCTL_H@ @@ -693,6 +728,7 @@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ +HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ @@ -845,6 +881,7 @@ REPLACE_CLOSE = @REPLACE_CLOSE@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ REPLACE_DUP2 = @REPLACE_DUP2@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ +REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ @@ -857,6 +894,7 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ REPLACE_GETCWD = @REPLACE_GETCWD@ @@ -873,6 +911,7 @@ REPLACE_ISNAN = @REPLACE_ISNAN@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ +REPLACE_LINK = @REPLACE_LINK@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -893,8 +932,10 @@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ REPLACE_PERROR = @REPLACE_PERROR@ +REPLACE_POPEN = @REPLACE_POPEN@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ @@ -907,10 +948,12 @@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ REPLACE_STRERROR = @REPLACE_STRERROR@ +REPLACE_STRNDUP = @REPLACE_STRNDUP@ REPLACE_STRPTIME = @REPLACE_STRPTIME@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ +REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ @@ -943,13 +986,13 @@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ -SYS_STAT_H = @SYS_STAT_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ U = @U@ UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@ UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@ +UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ USE_ACL = @USE_ACL@ @@ -1057,15 +1100,16 @@ EXTRA_DIST = acl-internal.h acl.h acl_entries.c alignof.h alloca.c \ cloexec.h close.c close-hook.h close-stream.c close-stream.h \ closein.c closein.h closeout.c closeout.h md5.c md5.h sha1.c \ sha1.h sha256.c sha256.h sha512.c sha512.h cycle-check.c \ - cycle-check.h dev-ino.h dirent.in.h dirfd.c basename.c \ - dirname.c dirname.h stripslash.c dup2.c errno.in.h error.c \ - error.h euidaccess.c exclude.c exclude.h exitfail.c exitfail.h \ - fchdir.c fclose.c fcntl.in.h creat-safer.c fcntl--.h \ - fcntl-safer.h open-safer.c fflush.c stdio-impl.h file-set.h \ - file-type.c file-type.h fileblocks.c filemode.c filemode.h \ - filenamecat.c filenamecat.h filevercmp.h float.in.h fnmatch.c \ - fnmatch.in.h fnmatch_loop.c fopen-safer.c stdio--.h \ - stdio-safer.h fpending.c fpending.h fprintftime.c \ + cycle-check.h dev-ino.h dirent.in.h dirent--.h dirent-safer.h \ + opendir-safer.c dirfd.c basename.c dirname.c dirname.h \ + stripslash.c dup2.c errno.in.h error.c error.h euidaccess.c \ + exclude.c exclude.h exitfail.c exitfail.h fchdir.c fclose.c \ + fcntl.in.h creat-safer.c fcntl--.h fcntl-safer.h open-safer.c \ + fdopendir.c openat-priv.h openat-proc.c fflush.c stdio-impl.h \ + file-set.h file-type.c file-type.h fileblocks.c filemode.c \ + filemode.h filenamecat.c filenamecat.h filevercmp.h float.in.h \ + fnmatch.c fnmatch.in.h fnmatch_loop.c fopen.c fopen-safer.c \ + stdio--.h stdio-safer.h fpending.c fpending.h fprintftime.c \ fprintftime.h fpucw.h fpurge.c stdio-impl.h freadahead.h \ stdio-impl.h freading.h stdio-impl.h freadptr.h stdio-impl.h \ freadseek.h stdio-impl.h frexp.c frexp.c frexpl.c fseeko.c \ @@ -1085,14 +1129,15 @@ EXTRA_DIST = acl-internal.h acl.h acl_entries.c alignof.h alloca.c \ hash.c hash.h hash-triple.h \ $(top_srcdir)/build-aux/config.rpath human.c human.h i-ring.c \ i-ring.h iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h \ - iconv_open-osf.h iconv.in.h iconv_open-aix.gperf \ - iconv_open-hpux.gperf iconv_open-irix.gperf \ - iconv_open-osf.gperf iconv_open.c idcache.c idcache.h \ + iconv_open-osf.h iconv_open-solaris.h iconv.in.h \ + iconv_open-aix.gperf iconv_open-hpux.gperf \ + iconv_open-irix.gperf iconv_open-osf.gperf \ + iconv_open-solaris.gperf iconv_open.c idcache.c idcache.h \ inet_ntop.c intprops.h imaxtostr.c inttostr.c inttostr.h \ offtostr.c uinttostr.c umaxtostr.c inttypes.in.h isapipe.c \ isapipe.h float+.h isnan.c isnand-nolibm.h isnand.c float+.h \ isnan.c isnanf-nolibm.h isnanf.c float+.h isnan.c \ - isnanl-nolibm.h isnanl.c lchown.c \ + isnanl-nolibm.h isnanl.c lchown.c link.c \ $(top_srcdir)/build-aux/link-warning.h config.charset \ ref-add.sin ref-del.sin long-options.c long-options.h lseek.c \ lstat.c $(top_srcdir)/maint.mk malloc.c malloc.c malloca.h \ @@ -1107,31 +1152,32 @@ EXTRA_DIST = acl-internal.h acl.h acl_entries.c alignof.h alloca.c \ mpsort.h nanosleep.c netdb.in.h netinet_in.in.h obstack.c \ obstack.h open.c at-func.c fchmodat.c fchownat.c fstatat.c \ mkdirat.c openat-priv.h openat-proc.c openat.c openat.h \ - pathmax.h physmem.c physmem.h posixtm.c posixtm.h posixver.c \ - posixver.h printf-frexp.h printf-frexp.c printf-frexpl.h \ - priv-set.h putenv.c quote.c quote.h quotearg.c quotearg.h \ - raise.c readlink.c readtokens.c readtokens.h readutmp.c \ - readutmp.h realloc.c realloc.c regcomp.c regex.c regex.h \ - regex_internal.c regex_internal.h regexec.c rename.c \ - rename-dest-slash.c rmdir.c root-dev-ino.c root-dev-ino.h \ - rpmatch.c safe-read.c safe-read.h safe-write.c safe-write.h \ - same.c same.h same-inode.h save-cwd.c save-cwd.h savedir.c \ - savedir.h select.c selinux-at.c selinux-at.h setenv.c \ - settime.c sig2str.c sig2str.h sig-handler.h sigaction.c \ - signal.in.h float+.h signbitd.c signbitf.c signbitl.c \ - sigprocmask.c snprintf.c w32sock.h stat-macros.h stat-time.h \ - stdarg.in.h stdbool.in.h stddef.in.h stdint.in.h stdio-write.c \ - stdio.in.h stdlib.in.h mkstemp-safer.c stdlib--.h \ - stdlib-safer.h stpcpy.c stpncpy.c strcspn.c strdup.c strdup.c \ - streq.h strerror.c strftime.c strftime.h string.in.h strndup.c \ - strnlen.c strpbrk.c str-two-way.h strstr.c strtod.c \ - strtoimax.c strtol.c strtoll.c strtoul.c strtoull.c \ - strtoumax.c strverscmp.c sys_select.in.h sys_socket.in.h \ - sys_stat.in.h sys_time.in.h tempname.c tempname.h time.in.h \ - time_r.c timespec.h trim.h u64.h unistd.in.h dup-safer.c \ - fd-safer.c pipe-safer.c unistd--.h unistd-safer.h unistr.h \ - unitypes.h localcharset.h uniwidth.h uniwidth/cjk.h \ - unlinkdir.c unlinkdir.h unlocked-io.h unsetenv.c \ + fcntl--.h fcntl-safer.h openat-safer.c pathmax.h physmem.c \ + physmem.h posixtm.c posixtm.h posixver.c posixver.h \ + printf-frexp.h printf-frexp.c printf-frexpl.h priv-set.h \ + putenv.c quote.c quote.h quotearg.c quotearg.h raise.c \ + readlink.c readtokens.c readtokens.h readutmp.c readutmp.h \ + realloc.c realloc.c regcomp.c regex.c regex.h regex_internal.c \ + regex_internal.h regexec.c rename.c rename-dest-slash.c \ + rmdir.c root-dev-ino.c root-dev-ino.h rpmatch.c safe-read.c \ + safe-read.h safe-write.c safe-write.h same.c same.h \ + same-inode.h save-cwd.c save-cwd.h savedir.c savedir.h \ + select.c selinux-at.c selinux-at.h setenv.c settime.c \ + sig2str.c sig2str.h sig-handler.h sigaction.c signal.in.h \ + float+.h signbitd.c signbitf.c signbitl.c sigprocmask.c \ + snprintf.c w32sock.h stat-macros.h stat-time.h stdarg.in.h \ + stdbool.in.h stddef.in.h stdint.in.h stdio-write.c stdio.in.h \ + stdlib.in.h mkstemp-safer.c stdlib--.h stdlib-safer.h stpcpy.c \ + stpncpy.c strcspn.c strdup.c strdup.c streq.h strerror.c \ + strftime.c strftime.h string.in.h strndup.c strnlen.c \ + strpbrk.c str-two-way.h strstr.c strtod.c strtoimax.c strtol.c \ + strtoll.c strtoul.c strtoull.c strtoumax.c strverscmp.c \ + sys_select.in.h sys_socket.in.h sys_stat.in.h sys_time.in.h \ + tempname.c tempname.h time.in.h time_r.c timespec.h trim.h \ + u64.h unistd.in.h dup-safer.c fd-safer.c pipe-safer.c \ + unistd--.h unistd-safer.h unistr.h unitypes.h localcharset.h \ + uniwidth.h uniwidth/cjk.h unlinkdir.c unlinkdir.h \ + unlocked-io.h unsetenv.c \ $(top_srcdir)/build-aux/update-copyright \ $(top_srcdir)/build-aux/useless-if-before-free inttostr.h \ userspec.c userspec.h utimecmp.c utimecmp.h utimens.c \ @@ -1147,11 +1193,11 @@ EXTRA_DIST = acl-internal.h acl.h acl_entries.c alignof.h alloca.c \ BUILT_SOURCES = $(ALLOCA_H) $(ARPA_INET_H) configmake.h $(DIRENT_H) \ $(ERRNO_H) $(FCNTL_H) $(FLOAT_H) $(FNMATCH_H) getdate.c \ $(GETOPT_H) $(ICONV_H) iconv_open-aix.h iconv_open-hpux.h \ - iconv_open-irix.h iconv_open-osf.h $(INTTYPES_H) math.h \ - $(NETDB_H) $(NETINET_IN_H) $(SELINUX_SELINUX_H) \ - $(SELINUX_CONTEXT_H) signal.h $(STDARG_H) $(STDBOOL_H) \ - $(STDDEF_H) $(STDINT_H) stdio.h stdlib.h string.h \ - $(SYS_SELECT_H) $(SYS_SOCKET_H) $(SYS_STAT_H) $(SYS_TIME_H) \ + iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h \ + $(INTTYPES_H) math.h $(NETDB_H) $(NETINET_IN_H) \ + $(SELINUX_SELINUX_H) $(SELINUX_CONTEXT_H) signal.h $(STDARG_H) \ + $(STDBOOL_H) $(STDDEF_H) $(STDINT_H) stdio.h stdlib.h string.h \ + $(SYS_SELECT_H) $(SYS_SOCKET_H) sys/stat.h $(SYS_TIME_H) \ time.h unistd.h $(WCHAR_H) $(WCTYPE_H) SUFFIXES = .sed .sin MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arpa/inet.h \ @@ -1159,21 +1205,22 @@ MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arpa/inet.h \ fcntl.h-t float.h float.h-t fnmatch.h fnmatch.h-t getopt.h \ getopt.h-t iconv.h iconv.h-t iconv_open-aix.h-t \ iconv_open-hpux.h-t iconv_open-irix.h-t iconv_open-osf.h-t \ - inttypes.h inttypes.h-t math.h math.h-t netdb.h netdb.h-t \ - netinet/in.h netinet/in.h-t selinux/selinux.h \ - selinux/selinux.h-t selinux/context.h selinux/context.h-t \ - signal.h signal.h-t stdarg.h stdarg.h-t stdbool.h stdbool.h-t \ - stddef.h stddef.h-t stdint.h stdint.h-t stdio.h stdio.h-t \ - stdlib.h stdlib.h-t string.h string.h-t sys/select.h \ - sys/select.h-t sys/socket.h sys/socket.h-t sys/stat.h \ - sys/stat.h-t sys/time.h sys/time.h-t time.h time.h-t unistd.h \ - unistd.h-t wchar.h wchar.h-t wctype.h wctype.h-t + iconv_open-solaris.h-t inttypes.h inttypes.h-t math.h math.h-t \ + netdb.h netdb.h-t netinet/in.h netinet/in.h-t \ + selinux/selinux.h selinux/selinux.h-t selinux/context.h \ + selinux/context.h-t signal.h signal.h-t stdarg.h stdarg.h-t \ + stdbool.h stdbool.h-t stddef.h stddef.h-t stdint.h stdint.h-t \ + stdio.h stdio.h-t stdlib.h stdlib.h-t string.h string.h-t \ + sys/select.h sys/select.h-t sys/socket.h sys/socket.h-t \ + sys/stat.h sys/stat.h-t sys/time.h sys/time.h-t time.h \ + time.h-t unistd.h unistd.h-t wchar.h wchar.h-t wctype.h \ + wctype.h-t MOSTLYCLEANDIRS = arpa netinet selinux sys sys sys CLEANFILES = configmake.h configmake.h-t charset.alias ref-add.sed \ ref-del.sed DISTCLEANFILES = MAINTAINERCLEANFILES = getdate.c iconv_open-aix.h iconv_open-hpux.h \ - iconv_open-irix.h iconv_open-osf.h + iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h AM_CPPFLAGS = AM_CFLAGS = $(WARN_CFLAGS) # $(WERROR_CFLAGS) libcoreutils_a_SOURCES = set-mode-acl.c copy-acl.c file-has-acl.c \ @@ -1208,20 +1255,21 @@ EXTRA_libcoreutils_a_SOURCES = acl_entries.c alloca.c argmatch.c \ c-strtold.c calloc.c calloc.c canon-host.c canonicalize.c \ chdir-long.c chown.c fchown-stub.c cloexec.c close.c \ close-stream.c closein.c closeout.c md5.c sha1.c sha256.c \ - sha512.c cycle-check.c dirfd.c basename.c dirname.c \ - stripslash.c dup2.c error.c euidaccess.c exclude.c exitfail.c \ - fchdir.c fclose.c creat-safer.c open-safer.c fflush.c \ - file-type.c fileblocks.c filemode.c filenamecat.c fnmatch.c \ - fnmatch_loop.c fopen-safer.c fpending.c fprintftime.c fpurge.c \ - frexp.c frexp.c frexpl.c fseeko.c fsusage.c ftello.c \ - ftruncate.c fts-cycle.c fts.c gai_strerror.c getaddrinfo.c \ - getcwd.c getdelim.c getgroups.c gethostname.c gethrxtime.c \ - getline.c getloadavg.c getndelim2.c getopt.c getopt1.c \ - getpagesize.c getpass.c gettime.c gettimeofday.c getugroups.c \ - getusershell.c group-member.c hard-locale.c hash.c human.c \ - i-ring.c iconv_open.c idcache.c inet_ntop.c imaxtostr.c \ - inttostr.c offtostr.c uinttostr.c umaxtostr.c isapipe.c \ - isnan.c isnand.c isnan.c isnanf.c isnan.c isnanl.c lchown.c \ + sha512.c cycle-check.c opendir-safer.c dirfd.c basename.c \ + dirname.c stripslash.c dup2.c error.c euidaccess.c exclude.c \ + exitfail.c fchdir.c fclose.c creat-safer.c open-safer.c \ + fdopendir.c openat-proc.c fflush.c file-type.c fileblocks.c \ + filemode.c filenamecat.c fnmatch.c fnmatch_loop.c fopen.c \ + fopen-safer.c fpending.c fprintftime.c fpurge.c frexp.c \ + frexp.c frexpl.c fseeko.c fsusage.c ftello.c ftruncate.c \ + fts-cycle.c fts.c gai_strerror.c getaddrinfo.c getcwd.c \ + getdelim.c getgroups.c gethostname.c gethrxtime.c getline.c \ + getloadavg.c getndelim2.c getopt.c getopt1.c getpagesize.c \ + getpass.c gettime.c gettimeofday.c getugroups.c getusershell.c \ + group-member.c hard-locale.c hash.c human.c i-ring.c \ + iconv_open.c idcache.c inet_ntop.c imaxtostr.c inttostr.c \ + offtostr.c uinttostr.c umaxtostr.c isapipe.c isnan.c isnand.c \ + isnan.c isnanf.c isnan.c isnanl.c lchown.c link.c \ long-options.c lseek.c lstat.c malloc.c malloc.c mbrlen.c \ mbrtowc.c mbsinit.c mbsrtowcs-state.c mbsrtowcs.c memcasecmp.c \ memchr.c memcmp.c memcoll.c memcpy.c memmove.c mempcpy.c \ @@ -1229,9 +1277,9 @@ EXTRA_libcoreutils_a_SOURCES = acl_entries.c alloca.c argmatch.c \ dirchownmod.c mkdir-p.c mkstemp.c mktime.c modechange.c \ mountlist.c mpsort.c nanosleep.c obstack.c open.c at-func.c \ fchmodat.c fchownat.c fstatat.c mkdirat.c openat-proc.c \ - openat.c physmem.c posixtm.c posixver.c printf-frexp.c \ - putenv.c quote.c quotearg.c raise.c readlink.c readtokens.c \ - readutmp.c realloc.c realloc.c regcomp.c regex.c \ + openat.c openat-safer.c physmem.c posixtm.c posixver.c \ + printf-frexp.c putenv.c quote.c quotearg.c raise.c readlink.c \ + readtokens.c readutmp.c realloc.c realloc.c regcomp.c regex.c \ regex_internal.c regexec.c rename.c rename-dest-slash.c \ rmdir.c root-dev-ino.c rpmatch.c safe-read.c safe-write.c \ same.c save-cwd.c savedir.c select.c selinux-at.c setenv.c \ @@ -1403,6 +1451,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchownat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fclose.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-safer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdopendir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fflush.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-has-acl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-set.Po@am__quote@ @@ -1414,6 +1463,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch_loop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fopen-safer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fopen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpending.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fprintftime.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpurge.Po@am__quote@ @@ -1471,6 +1521,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnanl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linebuffer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localcharset.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/long-options.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lseek.Po@am__quote@ @@ -1518,7 +1569,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-die.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-proc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-safer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opendir-safer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/physmem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipe-safer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posixtm.Po@am__quote@ @@ -1995,16 +2048,17 @@ uninstall-am: uninstall-local # We need the following in order to create when the system # doesn't have one that works with the given compiler. alloca.h: alloca.in.h + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/alloca.in.h; \ - } > $@-t + } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # doesn't have one. arpa/inet.h: arpa_inet.in.h - @MKDIR_P@ arpa - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) arpa + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2016,7 +2070,7 @@ arpa/inet.h: arpa_inet.in.h -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/arpa_inet.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # Retrieve values of the variables through 'configure' followed by @@ -2037,7 +2091,7 @@ arpa/inet.h: arpa_inet.in.h # The Automake-defined pkg* macros are appended, in the order # listed in the Automake 1.10a+ documentation. configmake.h: Makefile - rm -f $@-t + $(AM_V_GEN)rm -f $@-t && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ echo '#define PREFIX "$(prefix)"'; \ echo '#define EXEC_PREFIX "$(exec_prefix)"'; \ @@ -2066,7 +2120,7 @@ configmake.h: Makefile echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \ echo '#define PKGLIBDIR "$(pkglibdir)"'; \ echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \ - } | sed '/""/d' > $@-t + } | sed '/""/d' > $@-t && \ if test -f $@ && cmp $@-t $@ > /dev/null; then \ rm -f $@-t; \ else \ @@ -2076,27 +2130,29 @@ configmake.h: Makefile # We need the following in order to create when the system # doesn't have one that works with the given compiler. dirent.h: dirent.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \ -e 's|@''GNULIB_DIRFD''@|$(GNULIB_DIRFD)|g' \ + -e 's|@''GNULIB_FDOPENDIR''@|$(GNULIB_FDOPENDIR)|g' \ -e 's|@''GNULIB_SCANDIR''@|$(GNULIB_SCANDIR)|g' \ -e 's|@''GNULIB_ALPHASORT''@|$(GNULIB_ALPHASORT)|g' \ -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \ + -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \ -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/dirent.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that is POSIX compliant. errno.h: errno.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2108,49 +2164,54 @@ errno.h: errno.in.h -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \ -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \ < $(srcdir)/errno.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. fcntl.h: fcntl.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \ + -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \ -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ + -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/fcntl.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. float.h: float.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ < $(srcdir)/float.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that supports the required API. fnmatch.h: fnmatch.in.h + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/fnmatch.in.h; \ - } > $@-t + } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. getopt.h: getopt.in.h + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/getopt.in.h; \ - } > $@-t + } > $@-t && \ mv -f $@-t $@ #if GNU_MAKE @@ -2168,7 +2229,7 @@ clean-GNUmakefile: # We need the following in order to create when the system # doesn't have one that works with the given compiler. iconv.h: iconv.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2178,7 +2239,7 @@ iconv.h: iconv.in.h -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \ -e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \ < $(srcdir)/iconv.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ iconv_open-aix.h: iconv_open-aix.gperf @@ -2193,11 +2254,14 @@ iconv_open-irix.h: iconv_open-irix.gperf iconv_open-osf.h: iconv_open-osf.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-osf.gperf > $(srcdir)/iconv_open-osf.h-t mv $(srcdir)/iconv_open-osf.h-t $(srcdir)/iconv_open-osf.h +iconv_open-solaris.h: iconv_open-solaris.gperf + $(GPERF) -m 10 $(srcdir)/iconv_open-solaris.gperf > $(srcdir)/iconv_open-solaris.h-t + mv $(srcdir)/iconv_open-solaris.h-t $(srcdir)/iconv_open-solaris.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. inttypes.h: inttypes.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2222,7 +2286,7 @@ inttypes.h: inttypes.in.h -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/inttypes.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to install a simple file in $(libdir) @@ -2276,18 +2340,18 @@ uninstall-localcharset: all-local fi charset.alias: config.charset - rm -f t-$@ $@ - $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ + $(AM_V_GEN)rm -f t-$@ $@ && \ + $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \ mv t-$@ $@ .sin.sed: - rm -f t-$@ $@ - sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ + $(AM_V_GEN)rm -f t-$@ $@ && \ + sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \ mv t-$@ $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. math.h: math.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2349,13 +2413,13 @@ math.h: math.in.h -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/math.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. netdb.h: netdb.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2368,39 +2432,39 @@ netdb.h: netdb.in.h -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ < $(srcdir)/netdb.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one. netinet/in.h: netinet_in.in.h - @MKDIR_P@ netinet - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) netinet + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ < $(srcdir)/netinet_in.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ selinux/selinux.h: se-selinux.in.h - rm -f $@-t $@ - $(MKDIR_P) selinux - cp $(srcdir)/se-selinux.in.h $@-t - chmod a-x $@-t + $(AM_V_at)$(MKDIR_P) selinux + $(AM_V_GEN)rm -f $@-t $@ && \ + cp $(srcdir)/se-selinux.in.h $@-t && \ + chmod a-x $@-t && \ mv $@-t $@ selinux/context.h: se-context.in.h - rm -f $@-t $@ - $(MKDIR_P) selinux - cp $(srcdir)/se-context.in.h $@-t - chmod a-x $@-t + $(AM_V_at)$(MKDIR_P) selinux + $(AM_V_GEN)rm -f $@-t $@ && \ + cp $(srcdir)/se-context.in.h $@-t && \ + chmod a-x $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have a complete one. signal.h: signal.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2416,34 +2480,34 @@ signal.h: signal.in.h -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/signal.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdarg.h: stdarg.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \ < $(srcdir)/stdarg.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works. stdbool.h: stdbool.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. stddef.h: stddef.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2451,13 +2515,13 @@ stddef.h: stddef.in.h -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ < $(srcdir)/stddef.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdint.h: stdint.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2484,95 +2548,99 @@ stdint.h: stdint.in.h -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ < $(srcdir)/stdint.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdio.h: stdio.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ + -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \ + -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ + -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ + -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \ -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \ -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \ + -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \ + -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \ + -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \ + -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \ + -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \ + -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \ + -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \ + -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ + -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \ + -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \ + -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \ + -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \ + -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \ + -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \ + -e 's|@''GNULIB_POPEN''@|$(GNULIB_POPEN)|g' \ -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \ -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \ + -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ + -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \ + -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \ + -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \ -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \ + -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ + -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ + -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \ -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \ -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \ -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \ -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \ -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \ -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \ - -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \ - -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \ - -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ - -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \ - -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \ - -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \ - -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \ - -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \ - -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \ - -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \ - -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ - -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ - -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \ - -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ - -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \ - -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ - -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \ - -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \ - -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \ - -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \ - -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \ - -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \ - -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \ - -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ - -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ - -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ - -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ - -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ - -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ - -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ - -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ - -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ - -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ - -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ - -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ - -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ - -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ - -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ - -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ - -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ - -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ - -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ - -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \ - -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ - -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ - -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ - -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ - -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ - -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ - -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ - -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ - -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ + -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ + -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ + -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ + -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ + -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ + -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ + -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ + -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ + -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ + -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ + -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ + -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ + -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ + -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ + -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ + -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ + -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \ + -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \ -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \ + -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \ + -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ + -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \ + -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ + -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ + -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ + -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ + -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ + -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ + -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ + -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ + -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/stdio.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdlib.h: stdlib.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2585,6 +2653,7 @@ stdlib.h: stdlib.in.h -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \ -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \ + -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \ -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \ -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \ -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \ @@ -2599,6 +2668,7 @@ stdlib.h: stdlib.in.h -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ + -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ @@ -2616,13 +2686,13 @@ stdlib.h: stdlib.in.h -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/stdlib.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. string.h: string.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2668,7 +2738,6 @@ string.h: string.in.h -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ - -e 's|@''HAVE_STRNDUP''@|$(HAVE_STRNDUP)|g' \ -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ @@ -2684,17 +2753,20 @@ string.h: string.in.h -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ + -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ + -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ + -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/string.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/select.h: sys_select.in.h - @MKDIR_P@ sys - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2705,13 +2777,14 @@ sys/select.h: sys_select.in.h -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/sys_select.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/socket.h: sys_socket.in.h - @MKDIR_P@ sys + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2732,40 +2805,54 @@ sys/socket.h: sys_socket.in.h -e 's|@''GNULIB_SENDTO''@|$(GNULIB_SENDTO)|g' \ -e 's|@''GNULIB_SETSOCKOPT''@|$(GNULIB_SETSOCKOPT)|g' \ -e 's|@''GNULIB_SHUTDOWN''@|$(GNULIB_SHUTDOWN)|g' \ + -e 's|@''GNULIB_ACCEPT4''@|$(GNULIB_ACCEPT4)|g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \ -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ + -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/sys_socket.in.h; \ - } > $@-t + } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # has one that is incomplete. sys/stat.h: sys_stat.in.h - @MKDIR_P@ sys - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ + -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \ + -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \ -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \ -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \ + -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \ + -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \ + -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \ + -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ + -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ + -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ + -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ + -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ + -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/sys_stat.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/time.h: sys_time.in.h - @MKDIR_P@ sys - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2774,13 +2861,13 @@ sys/time.h: sys_time.in.h -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ < $(srcdir)/sys_time.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. time.h: time.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2793,13 +2880,13 @@ time.h: time.in.h -e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ < $(srcdir)/time.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create an empty placeholder for # when the system doesn't have one. unistd.h: unistd.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2808,9 +2895,12 @@ unistd.h: unistd.in.h -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \ + -e 's|@''GNULIB_DUP3''@|$(GNULIB_DUP3)|g' \ -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \ -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \ + -e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \ -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ + -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \ -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \ -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ @@ -2823,13 +2913,20 @@ unistd.h: unistd.in.h -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ + -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ + -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ + -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \ -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \ -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \ + -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \ -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ + -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ + -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ + -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \ @@ -2838,8 +2935,12 @@ unistd.h: unistd.in.h -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ + -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ + -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ + -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ + -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ @@ -2848,22 +2949,24 @@ unistd.h: unistd.in.h -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ + -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/unistd.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # version does not work standalone. wchar.h: wchar.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2906,13 +3009,13 @@ wchar.h: wchar.in.h -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/wchar.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. wctype.h: wctype.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2922,7 +3025,7 @@ wctype.h: wctype.in.h -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ < $(srcdir)/wctype.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ mostlyclean-local: mostlyclean-generic diff --git a/src/bin/coreutils/lib/at-func.c b/src/bin/coreutils/lib/at-func.c index c7963fe3d2..3188770c65 100644 --- a/src/bin/coreutils/lib/at-func.c +++ b/src/bin/coreutils/lib/at-func.c @@ -1,5 +1,5 @@ /* Define an at-style functions like fstatat, unlinkat, fchownat, etc. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,35 +16,58 @@ /* written by Jim Meyering */ -#define CALL_FUNC(F) \ - (AT_FUNC_USE_F1_COND \ +#ifdef AT_FUNC_USE_F1_COND +# define CALL_FUNC(F) \ + (flag == AT_FUNC_USE_F1_COND \ ? AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS) \ : AT_FUNC_F2 (F AT_FUNC_POST_FILE_ARGS)) +# define VALIDATE_FLAG(F) \ + if (flag & ~AT_FUNC_USE_F1_COND) \ + { \ + errno = EINVAL; \ + return -1; \ + } +#else +# define CALL_FUNC(F) (AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS)) +# define VALIDATE_FLAG(F) /* empty */ +#endif -/* Call AT_FUNC_F1 or AT_FUNC_F2 (testing AT_FUNC_USE_F1_COND to - determine which) to operate on FILE, which is in the directory - open on descriptor FD. If possible, do it without changing the +#ifdef AT_FUNC_RESULT +# define FUNC_RESULT AT_FUNC_RESULT +#else +# define FUNC_RESULT int +#endif + +/* Call AT_FUNC_F1 to operate on FILE, which is in the directory + open on descriptor FD. If AT_FUNC_USE_F1_COND is defined to a value, + AT_FUNC_POST_FILE_PARAM_DECLS must inlude a parameter named flag; + call AT_FUNC_F2 if FLAG is 0 or fail if FLAG contains more bits than + AT_FUNC_USE_F1_COND. If possible, do it without changing the working directory. Otherwise, resort to using save_cwd/fchdir, then AT_FUNC_F?/restore_cwd. If either the save_cwd or the restore_cwd fails, then give a diagnostic and exit nonzero. */ -int +FUNC_RESULT AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS) { + /* Be careful to choose names unlikely to conflict with + AT_FUNC_POST_FILE_PARAM_DECLS. */ struct saved_cwd saved_cwd; int saved_errno; - int err; + FUNC_RESULT err; + + VALIDATE_FLAG (flag); if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file)) return CALL_FUNC (file); { - char buf[OPENAT_BUFFER_SIZE]; - char *proc_file = openat_proc_name (buf, fd, file); + char proc_buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (proc_buf, fd, file); if (proc_file) { - int proc_result = CALL_FUNC (proc_file); + FUNC_RESULT proc_result = CALL_FUNC (proc_file); int proc_errno = errno; - if (proc_file != buf) + if (proc_file != proc_buf) free (proc_file); /* If the syscall succeeds, or if it fails with an unexpected errno value, then return right away. Otherwise, fall through @@ -83,3 +106,4 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS) return err; } #undef CALL_FUNC +#undef FUNC_RESULT diff --git a/src/bin/coreutils/lib/backupfile.c b/src/bin/coreutils/lib/backupfile.c index 1420edd8cd..f6cf73779b 100644 --- a/src/bin/coreutils/lib/backupfile.c +++ b/src/bin/coreutils/lib/backupfile.c @@ -1,7 +1,7 @@ /* backupfile.c -- make Emacs style backup file names Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -37,7 +37,7 @@ #include -#include +#include "dirent--.h" #ifndef _D_EXACT_NAMLEN # define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) #endif @@ -80,11 +80,6 @@ of `digit' even when the host does not conform to POSIX. */ #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) -/* The results of opendir() in this file are not used with dirfd and fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef opendir -#undef closedir - /* The extension added to file names to produce a simple (as opposed to numbered) backup file name. */ char const *simple_backup_suffix = "~"; diff --git a/src/bin/coreutils/lib/buffer-lcm.c b/src/bin/coreutils/lib/buffer-lcm.c index b8d87d31d7..ee901741da 100644 --- a/src/bin/coreutils/lib/buffer-lcm.c +++ b/src/bin/coreutils/lib/buffer-lcm.c @@ -34,22 +34,22 @@ buffer_lcm (size_t a, size_t b, size_t lcm_max) else { if (b) - { - /* Return lcm (A, B) if it is in range; otherwise, fall back - on A. */ + { + /* Return lcm (A, B) if it is in range; otherwise, fall back + on A. */ - size_t lcm, m, n, q, r; + size_t lcm, m, n, q, r; - /* N = gcd (A, B). */ - for (m = a, n = b; (r = m % n) != 0; m = n, n = r) - continue; + /* N = gcd (A, B). */ + for (m = a, n = b; (r = m % n) != 0; m = n, n = r) + continue; - /* LCM = lcm (A, B), if in range. */ - q = a / n; - lcm = q * b; - if (lcm <= lcm_max && lcm / b == q) - return lcm; - } + /* LCM = lcm (A, B), if in range. */ + q = a / n; + lcm = q * b; + if (lcm <= lcm_max && lcm / b == q) + return lcm; + } size = a; } diff --git a/src/bin/coreutils/lib/canonicalize.c b/src/bin/coreutils/lib/canonicalize.c index 4f348398fd..523e08204c 100644 --- a/src/bin/coreutils/lib/canonicalize.c +++ b/src/bin/coreutils/lib/canonicalize.c @@ -1,5 +1,5 @@ /* Return the canonical absolute name of a given file. - Copyright (C) 1996-2008 Free Software Foundation, Inc. + Copyright (C) 1996-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,9 +38,6 @@ #include "xalloc.h" #include "xgetcwd.h" -#ifndef ELOOP -# define ELOOP 0 -#endif #ifndef __set_errno # define __set_errno(Val) errno = (Val) #endif @@ -199,7 +196,7 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) dest = rname + 1; } - for (start = end = name; *start; start = end) + for (start = name; *start; start = end) { /* Skip sequence of multiple file name separators. */ while (*start == '/') diff --git a/src/bin/coreutils/lib/chdir-long.c b/src/bin/coreutils/lib/chdir-long.c index 291b58c289..ba47d59973 100644 --- a/src/bin/coreutils/lib/chdir-long.c +++ b/src/bin/coreutils/lib/chdir-long.c @@ -1,5 +1,5 @@ /* provide a chdir function that tries not to fail due to ENAMETOOLONG - Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2004-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,6 @@ #include "chdir-long.h" -#include #include #include #include @@ -28,7 +27,7 @@ #include #include -#include "openat.h" +#include "fcntl--.h" #ifndef PATH_MAX # error "compile this file only if your system defines PATH_MAX" diff --git a/src/bin/coreutils/lib/chown.c b/src/bin/coreutils/lib/chown.c index 3582b04d67..b851cbc4c0 100644 --- a/src/bin/coreutils/lib/chown.c +++ b/src/bin/coreutils/lib/chown.c @@ -1,7 +1,7 @@ /* provide consistent interface to chown for systems that don't interpret an ID of -1 as meaning `don't change the corresponding ID'. - Copyright (C) 1997, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1997, 2004-2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,7 +46,8 @@ int rpl_chown (const char *file, uid_t uid, gid_t gid) { -#if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE +#if HAVE_CHOWN +# if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE if (gid == (gid_t) -1 || uid == (uid_t) -1) { struct stat file_stats; @@ -61,9 +62,9 @@ rpl_chown (const char *file, uid_t uid, gid_t gid) if (uid == (uid_t) -1) uid = file_stats.st_uid; } -#endif +# endif -#if CHOWN_MODIFIES_SYMLINK +# if CHOWN_MODIFIES_SYMLINK { /* Handle the case in which the system-supplied chown function does *not* follow symlinks. Instead, it changes permissions @@ -97,7 +98,12 @@ rpl_chown (const char *file, uid_t uid, gid_t gid) else if (errno != EACCES) return -1; } -#endif +# endif return chown (file, uid, gid); + +#else /* !HAVE_CHOWN */ + errno = ENOSYS; + return -1; +#endif } diff --git a/src/bin/coreutils/lib/cloexec.c b/src/bin/coreutils/lib/cloexec.c index ff8105ba02..0fb227c0a2 100644 --- a/src/bin/coreutils/lib/cloexec.c +++ b/src/bin/coreutils/lib/cloexec.c @@ -24,10 +24,6 @@ #include #include -#ifndef FD_CLOEXEC -# define FD_CLOEXEC 1 -#endif - /* Set the `FD_CLOEXEC' flag of DESC if VALUE is true, or clear the flag if VALUE is false. Return 0 on success, or -1 on error with `errno' set. */ diff --git a/src/bin/coreutils/lib/close.c b/src/bin/coreutils/lib/close.c index 0e56dcb27f..5278f24bba 100644 --- a/src/bin/coreutils/lib/close.c +++ b/src/bin/coreutils/lib/close.c @@ -33,7 +33,7 @@ rpl_close (int fd) int retval = close (fd); #endif -#ifdef FCHDIR_REPLACEMENT +#if REPLACE_FCHDIR if (retval >= 0) _gl_unregister_fd (fd); #endif diff --git a/src/bin/coreutils/lib/config.h b/src/bin/coreutils/lib/config.h index 1d8d87195b..c61c9d5045 100644 --- a/src/bin/coreutils/lib/config.h +++ b/src/bin/coreutils/lib/config.h @@ -1747,7 +1747,7 @@ /* #undef LDBL_SIGNBIT_WORD */ /* Define if `link(2)' dereferences symbolic links. */ -/* #undef LINK_FOLLOWS_SYMLINKS */ +#define LINK_FOLLOWS_SYMLINKS -1 /* FIXME */ /* #undef LOCALTIME_CACHE */ diff --git a/src/bin/coreutils/lib/config.hin b/src/bin/coreutils/lib/config.hin index 8236a0cf97..20f5195bf1 100644 --- a/src/bin/coreutils/lib/config.hin +++ b/src/bin/coreutils/lib/config.hin @@ -97,9 +97,6 @@ language is requested. */ #undef ENABLE_NLS -/* Define if gnulib's fchdir() replacement is used. */ -#undef FCHDIR_REPLACEMENT - /* Define on systems for which file names may have a so-called `drive letter' prefix, define this to compute the length of that prefix, including the colon. */ @@ -135,6 +132,9 @@ /* Define as the word index where to find the sign of 'float'. */ #undef FLT_SIGNBIT_WORD +/* Define to 1 if fopen() fails to recognize a trailing slash. */ +#undef FOPEN_TRAILING_SLASH_BUG + /* Define to 1 if ungetc is broken when used on arbitrary bytes. */ #undef FUNC_UNGETC_BROKEN @@ -158,6 +158,9 @@ /* Define to 1 when using the gnulib module close-stream. */ #undef GNULIB_CLOSE_STREAM +/* Define to 1 when using the gnulib module dirent-safer. */ +#undef GNULIB_DIRENT_SAFER + /* Define to 1 when using the gnulib module fcntl-safer. */ #undef GNULIB_FCNTL_SAFER @@ -179,12 +182,21 @@ /* Define to 1 when using the gnulib module open. */ #undef GNULIB_OPEN +/* Define to 1 when using the gnulib module openat-safer. */ +#undef GNULIB_OPENAT_SAFER + /* enable some gnulib portability checks */ #undef GNULIB_PORTCHECK /* Define to indicate the 'realloc' module. */ #undef GNULIB_REALLOC_GNU +/* Define to 1 when using the gnulib module stdlib-safer. */ +#undef GNULIB_STDLIB_SAFER + +/* Define to 1 when using the gnulib module unistd-safer. */ +#undef GNULIB_UNISTD_SAFER + /* Define to 1 when using the gnulib module unistr/u8-uctomb. */ #undef GNULIB_UNISTR_U8_UCTOMB @@ -322,7 +334,7 @@ the CoreFoundation framework. */ #undef HAVE_CFPREFERENCESCOPYAPPVALUE -/* Define to 1 if your system has a working `chown' function. */ +/* Define to 1 if you have the `chown' function. */ #undef HAVE_CHOWN /* Define to 1 if you have the `chroot' function. */ @@ -547,6 +559,10 @@ don't. */ #undef HAVE_DECL_MEMRCHR +/* Define to 1 if you have the declaration of `program_invocation_name', and + to 0 if you don't. */ +#undef HAVE_DECL_PROGRAM_INVOCATION_NAME + /* Define to 1 if you have the declaration of `putchar_unlocked', and to 0 if you don't. */ #undef HAVE_DECL_PUTCHAR_UNLOCKED @@ -688,6 +704,9 @@ /* Define to 1 if you have the `euidaccess' function. */ #undef HAVE_EUIDACCESS +/* Define to 1 if you have the `faccessat' function. */ +#undef HAVE_FACCESSAT + /* Define to 1 if you have the `fchdir' function. */ #undef HAVE_FCHDIR @@ -941,6 +960,9 @@ /* Define to 1 if you have the `ypsec' library (-lypsec). */ #undef HAVE_LIBYPSEC +/* Define to 1 if you have the `link' function. */ +#undef HAVE_LINK + /* Define to 1 if you have the `listmntent' function. */ #undef HAVE_LISTMNTENT @@ -1253,7 +1275,7 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H -/* Define if you have the strndup() function and it works. */ +/* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP /* Define to 1 if you have the `strnlen' function. */ @@ -1439,6 +1461,9 @@ /* Define if struct stat has an st_dm_mode member. */ #undef HAVE_ST_DM_MODE +/* Define to 1 if you have the `symlink' function. */ +#undef HAVE_SYMLINK + /* Define to 1 if you have the `sync' function. */ #undef HAVE_SYNC @@ -1745,7 +1770,8 @@ /* Define as the word index where to find the sign of 'long double'. */ #undef LDBL_SIGNBIT_WORD -/* Define if `link(2)' dereferences symbolic links. */ +/* Define to 1 if `link(2)' dereferences symbolic links, 0 if it creates hard + links to symlinks, and -1 if unknown. */ #undef LINK_FOLLOWS_SYMLINKS /* FIXME */ @@ -1962,6 +1988,13 @@ /* Define to 1 if dup2 returns 0 instead of the target fd. */ #undef REPLACE_DUP2 +/* Define to 1 if gnulib's fchdir() replacement is used. */ +#undef REPLACE_FCHDIR + +/* Define to 1 if open() should work around the inability to open a directory. + */ +#undef REPLACE_OPEN_DIRECTORY + /* Define this to 1 if strerror is broken. */ #undef REPLACE_STRERROR @@ -2170,9 +2203,6 @@ used. */ #undef __GETOPT_PREFIX -/* Define to rpl_ if the openat replacement function should be used. */ -#undef __OPENAT_PREFIX - /* Define like PROTOTYPES; this can be used by system headers. */ #undef __PROTOTYPES @@ -2186,9 +2216,6 @@ /* Define to rpl_calloc if the replacement function should be used. */ #undef calloc -/* Define to rpl_fchownat if the replacement function should be used. */ -#undef fchownat - /* Define to a replacement function name for fnmatch(). */ #undef fnmatch diff --git a/src/bin/coreutils/lib/dirent--.h b/src/bin/coreutils/lib/dirent--.h new file mode 100644 index 0000000000..088aafdc6c --- /dev/null +++ b/src/bin/coreutils/lib/dirent--.h @@ -0,0 +1,23 @@ +/* Like dirent.h, but redefine some names to avoid glitches. + + Copyright (C) 2009 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake. */ + +#include "dirent-safer.h" + +#undef opendir +#define opendir opendir_safer diff --git a/src/bin/coreutils/lib/dirent-safer.h b/src/bin/coreutils/lib/dirent-safer.h new file mode 100644 index 0000000000..0debe26bf7 --- /dev/null +++ b/src/bin/coreutils/lib/dirent-safer.h @@ -0,0 +1,22 @@ +/* Invoke dirent-like functions, but avoid some glitches. + + Copyright (C) 2009 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake. */ + +#include + +DIR *opendir_safer (const char *name); diff --git a/src/bin/coreutils/lib/dirent.in.h b/src/bin/coreutils/lib/dirent.in.h index 15f0245b09..8930765672 100644 --- a/src/bin/coreutils/lib/dirent.in.h +++ b/src/bin/coreutils/lib/dirent.in.h @@ -58,6 +58,23 @@ extern int dirfd (DIR const *dir); dirfd (d)) #endif +#if @GNULIB_FDOPENDIR@ +# if !@HAVE_FDOPENDIR@ +/* Open a directory stream visiting the given directory file + descriptor. Return NULL and set errno if fd is not visiting a + directory. On success, this function consumes fd (it will be + implicitly closed either by this function or by a subsequent + closedir). */ +extern DIR *fdopendir (int fd); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fdopendir +# define fdopendir(f) \ + (GL_LINK_WARNING ("fdopendir is unportable - " \ + "use gnulib module fdopendir for portability"), \ + fdopendir (f)) +#endif + #if @GNULIB_SCANDIR@ /* Scan the directory DIR, calling FILTER on each directory entry. Entries for which FILTER returns nonzero are individually malloc'd, diff --git a/src/bin/coreutils/lib/dup-safer.c b/src/bin/coreutils/lib/dup-safer.c index 7d9b2be349..22b96babf5 100644 --- a/src/bin/coreutils/lib/dup-safer.c +++ b/src/bin/coreutils/lib/dup-safer.c @@ -32,7 +32,7 @@ int dup_safer (int fd) { -#if defined F_DUPFD && !defined FCHDIR_REPLACEMENT +#if defined F_DUPFD && !REPLACE_FCHDIR return fcntl (fd, F_DUPFD, STDERR_FILENO + 1); #else /* fd_safer calls us back, but eventually the recursion unwinds and diff --git a/src/bin/coreutils/lib/dup2.c b/src/bin/coreutils/lib/dup2.c index 6d61829343..140af1b9fb 100644 --- a/src/bin/coreutils/lib/dup2.c +++ b/src/bin/coreutils/lib/dup2.c @@ -55,8 +55,25 @@ rpl_dup2 (int fd, int desired_fd) } # endif result = dup2 (fd, desired_fd); +# ifdef __linux__ + /* Correct a Linux return value. + + */ + if (fd == desired_fd && result == (unsigned int) -EBADF) + { + errno = EBADF; + result = -1; + } +# endif if (result == 0) result = desired_fd; + /* Correct a cygwin 1.5.x errno value. */ + else if (result == -1 && errno == EMFILE) + errno = EBADF; +#if REPLACE_FCHDIR + if (fd != desired_fd && result == desired_fd) + result = _gl_register_dup (fd, desired_fd); +#endif return result; } @@ -85,13 +102,19 @@ dupfd (int fd, int desired_fd) int dup2 (int fd, int desired_fd) { + int result; if (fd == desired_fd) - return fd; + return fcntl (fd, F_GETFL) < 0 ? -1 : fd; close (desired_fd); # ifdef F_DUPFD - return fcntl (fd, F_DUPFD, desired_fd); + result = fcntl (fd, F_DUPFD, desired_fd); # else - return dupfd (fd, desired_fd); + result = dupfd (fd, desired_fd); # endif +#if REPLACE_FCHDIR + if (0 <= result) + result = _gl_register_dup (fd, desired_fd); +#endif + return result; } #endif /* !REPLACE_DUP2 */ diff --git a/src/bin/coreutils/lib/euidaccess-stat.c b/src/bin/coreutils/lib/euidaccess-stat.c index 0213c93fcd..98ce28157e 100644 --- a/src/bin/coreutils/lib/euidaccess-stat.c +++ b/src/bin/coreutils/lib/euidaccess-stat.c @@ -57,8 +57,8 @@ euidaccess_stat (struct stat const *st, int mode) mode &= 7; else mode = ((mode & R_OK ? 4 : 0) - + (mode & W_OK ? 2 : 0) - + (mode & X_OK ? 1 : 0)); + + (mode & W_OK ? 2 : 0) + + (mode & X_OK ? 1 : 0)); if (mode == 0) return true; /* The file exists. */ @@ -68,7 +68,7 @@ euidaccess_stat (struct stat const *st, int mode) /* The super-user can read and write any file, and execute any file that anyone can execute. */ if (euid == 0 && ((mode & X_OK) == 0 - || (st->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))) + || (st->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))) return true; /* Convert the file's permission bits to traditional form. */ @@ -84,14 +84,14 @@ euidaccess_stat (struct stat const *st, int mode) granted = st->st_mode; else granted = ( (st->st_mode & S_IRUSR ? 4 << 6 : 0) - + (st->st_mode & S_IWUSR ? 2 << 6 : 0) - + (st->st_mode & S_IXUSR ? 1 << 6 : 0) - + (st->st_mode & S_IRGRP ? 4 << 3 : 0) - + (st->st_mode & S_IWGRP ? 2 << 3 : 0) - + (st->st_mode & S_IXGRP ? 1 << 3 : 0) - + (st->st_mode & S_IROTH ? 4 << 0 : 0) - + (st->st_mode & S_IWOTH ? 2 << 0 : 0) - + (st->st_mode & S_IXOTH ? 1 << 0 : 0)); + + (st->st_mode & S_IWUSR ? 2 << 6 : 0) + + (st->st_mode & S_IXUSR ? 1 << 6 : 0) + + (st->st_mode & S_IRGRP ? 4 << 3 : 0) + + (st->st_mode & S_IWGRP ? 2 << 3 : 0) + + (st->st_mode & S_IXGRP ? 1 << 3 : 0) + + (st->st_mode & S_IROTH ? 4 << 0 : 0) + + (st->st_mode & S_IWOTH ? 2 << 0 : 0) + + (st->st_mode & S_IXOTH ? 1 << 0 : 0)); if (euid == st->st_uid) granted >>= 6; @@ -99,7 +99,7 @@ euidaccess_stat (struct stat const *st, int mode) { gid_t egid = getegid (); if (egid == st->st_gid || group_member (st->st_gid)) - granted >>= 3; + granted >>= 3; } if ((mode & ~granted) == 0) diff --git a/src/bin/coreutils/lib/euidaccess.c b/src/bin/coreutils/lib/euidaccess.c index 17eb724972..dcb6e3a931 100644 --- a/src/bin/coreutils/lib/euidaccess.c +++ b/src/bin/coreutils/lib/euidaccess.c @@ -1,7 +1,7 @@ /* euidaccess -- check if effective user id can access file - Copyright (C) 1990, 1991, 1995, 1998, 2000, 2003, 2004, 2005, 2006, 2008 - Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1995, 1998, 2000, 2003, 2004, 2005, 2006, + 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -25,6 +25,7 @@ # include #endif +#include #include #include #include @@ -77,7 +78,9 @@ int euidaccess (const char *file, int mode) { -#if defined EFF_ONLY_OK +#if HAVE_FACCESSAT + return faccessat (AT_FDCWD, file, mode, AT_EACCESS); +#elif defined EFF_ONLY_OK return access (file, mode | EFF_ONLY_OK); #elif defined ACC_SELF return accessx (file, mode, ACC_SELF); diff --git a/src/bin/coreutils/lib/exclude.c b/src/bin/coreutils/lib/exclude.c index d4baab51c2..3ceeed7bef 100644 --- a/src/bin/coreutils/lib/exclude.c +++ b/src/bin/coreutils/lib/exclude.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "exclude.h" #include "hash.h" @@ -113,7 +114,7 @@ struct exclude bool fnmatch_pattern_has_wildcards (const char *str, int options) { - char *cset = "\\?*[]"; + const char *cset = "\\?*[]"; if (options & FNM_NOESCAPE) cset++; while (*str) @@ -199,7 +200,7 @@ string_free (void *data) /* Create new exclude segment of given TYPE and OPTIONS, and attach it to the tail of list in EX */ -struct exclude_segment * +static struct exclude_segment * new_exclude_segment (struct exclude *ex, enum exclude_type type, int options) { struct exclude_segment *sp = xzalloc (sizeof (struct exclude_segment)); @@ -328,7 +329,7 @@ exclude_fnmatch (char const *pattern, char const *f, int options) /* Return true if the exclude_pattern segment SEG excludes F. */ -bool +static bool excluded_file_pattern_p (struct exclude_segment const *seg, char const *f) { size_t exclude_count = seg->v.pat.exclude_count; @@ -350,7 +351,7 @@ excluded_file_pattern_p (struct exclude_segment const *seg, char const *f) /* Return true if the exclude_hash segment SEG excludes F. BUFFER is an auxiliary storage of the same length as F (with nul terminator included) */ -bool +static bool excluded_file_name_p (struct exclude_segment const *seg, char const *f, char *buffer) { diff --git a/src/bin/coreutils/lib/fchdir.c b/src/bin/coreutils/lib/fchdir.c index d51d9630fe..f35562911a 100644 --- a/src/bin/coreutils/lib/fchdir.c +++ b/src/bin/coreutils/lib/fchdir.c @@ -19,10 +19,11 @@ /* Specification. */ #include +#include #include #include #include -#include +#include #include #include #include @@ -30,80 +31,161 @@ #include "canonicalize.h" +#ifndef REPLACE_OPEN_DIRECTORY +# define REPLACE_OPEN_DIRECTORY 0 +#endif + /* This replacement assumes that a directory is not renamed while opened - through a file descriptor. */ + through a file descriptor. + + FIXME: On mingw, this would be possible to enforce if we were to + also open a HANDLE to each directory currently visited by a file + descriptor, since mingw refuses to rename any in-use file system + object. */ /* Array of file descriptors opened. If it points to a directory, it stores - info about this directory; otherwise it stores an errno value of ENOTDIR. */ + info about this directory. */ typedef struct { char *name; /* Absolute name of the directory, or NULL. */ - int saved_errno; /* If name == NULL: The error code describing the failure - reason. */ + /* FIXME - add a DIR* member to make dirfd possible on mingw? */ } dir_info_t; static dir_info_t *dirs; static size_t dirs_allocated; -/* Try to ensure dirs has enough room for a slot at index fd. */ -static void +/* Try to ensure dirs has enough room for a slot at index fd. Return + false and set errno to ENOMEM on allocation failure. */ +static bool ensure_dirs_slot (size_t fd) { if (fd >= dirs_allocated) { size_t new_allocated; dir_info_t *new_dirs; - size_t i; new_allocated = 2 * dirs_allocated + 1; if (new_allocated <= fd) new_allocated = fd + 1; new_dirs = (dirs != NULL - ? (dir_info_t *) realloc (dirs, new_allocated * sizeof (dir_info_t)) - : (dir_info_t *) malloc (new_allocated * sizeof (dir_info_t))); - if (new_dirs != NULL) - { - for (i = dirs_allocated; i < new_allocated; i++) - { - new_dirs[i].name = NULL; - new_dirs[i].saved_errno = ENOTDIR; - } - dirs = new_dirs; - dirs_allocated = new_allocated; - } + ? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs) + : (dir_info_t *) malloc (new_allocated * sizeof *dirs)); + if (new_dirs == NULL) + return false; + memset (new_dirs + dirs_allocated, 0, + (new_allocated - dirs_allocated) * sizeof *dirs); + dirs = new_dirs; + dirs_allocated = new_allocated; } + return true; } /* Hook into the gnulib replacements for open() and close() to keep track of the open file descriptors. */ +/* Close FD, cleaning up any fd to name mapping if fd was visiting a + directory. */ void _gl_unregister_fd (int fd) { if (fd >= 0 && fd < dirs_allocated) { - if (dirs[fd].name != NULL) - free (dirs[fd].name); + free (dirs[fd].name); dirs[fd].name = NULL; - dirs[fd].saved_errno = ENOTDIR; } } -void +/* Mark FD as visiting FILENAME. FD must be non-negative, and refer + to an open file descriptor. If REPLACE_OPEN_DIRECTORY is non-zero, + this should only be called if FD is visiting a directory. Close FD + and return -1 if there is insufficient memory to track the + directory name; otherwise return FD. */ +int _gl_register_fd (int fd, const char *filename) { struct stat statbuf; - ensure_dirs_slot (fd); - if (fd < dirs_allocated - && fstat (fd, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode)) + assert (0 <= fd); + if (REPLACE_OPEN_DIRECTORY + || (fstat (fd, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))) { - dirs[fd].name = canonicalize_file_name (filename); - if (dirs[fd].name == NULL) - dirs[fd].saved_errno = errno; + if (!ensure_dirs_slot (fd) + || (dirs[fd].name = canonicalize_file_name (filename)) == NULL) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + return -1; + } } + return fd; } +/* Mark NEWFD as a duplicate of OLDFD; useful from dup, dup2, dup3, + and fcntl. Both arguments must be valid and distinct file + descriptors. Close NEWFD and return -1 if OLDFD is tracking a + directory, but there is insufficient memory to track the same + directory in NEWFD; otherwise return NEWFD. + + FIXME: Need to implement rpl_fcntl in gnulib, and have it call + this. */ +int +_gl_register_dup (int oldfd, int newfd) +{ + assert (0 <= oldfd && 0 <= newfd && oldfd != newfd); + if (oldfd < dirs_allocated && dirs[oldfd].name) + { + /* Duplicated a directory; must ensure newfd is allocated. */ + if (!ensure_dirs_slot (newfd) + || (dirs[newfd].name = strdup (dirs[oldfd].name)) == NULL) + { + int saved_errno = errno; + close (newfd); + errno = saved_errno; + newfd = -1; + } + } + else if (newfd < dirs_allocated) + { + /* Duplicated a non-directory; ensure newfd is cleared. */ + free (dirs[newfd].name); + dirs[newfd].name = NULL; + } + return newfd; +} + +/* If FD is currently visiting a directory, then return the name of + that directory. Otherwise, return NULL and set errno. */ +const char * +_gl_directory_name (int fd) +{ + if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL) + return dirs[fd].name; + /* At this point, fd is either invalid, or open but not a directory. + If dup2 fails, errno is correctly EBADF. */ + if (0 <= fd) + { + if (dup2 (fd, fd) == fd) + errno = ENOTDIR; + } + else + errno = EBADF; + return NULL; +} + +/* Return stat information about FD in STATBUF. Needed when + rpl_open() used a dummy file to work around an open() that can't + normally visit directories. */ +#if REPLACE_OPEN_DIRECTORY +int +rpl_fstat (int fd, struct stat *statbuf) +{ + if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL) + return stat (dirs[fd].name, statbuf); + return fstat (fd, statbuf); +} +#endif + /* Override opendir() and closedir(), to keep track of the open file descriptors. Needed because there is a function dirfd(). */ @@ -129,13 +211,18 @@ rpl_opendir (const char *filename) if (dp != NULL) { int fd = dirfd (dp); - if (fd >= 0) - _gl_register_fd (fd, filename); + if (0 <= fd && _gl_register_fd (fd, filename) != fd) + { + int saved_errno = errno; + closedir (dp); + errno = saved_errno; + return NULL; + } } return dp; } -/* Override dup() and dup2(), to keep track of open file descriptors. */ +/* Override dup(), to keep track of open file descriptors. */ int rpl_dup (int oldfd) @@ -143,102 +230,17 @@ rpl_dup (int oldfd) { int newfd = dup (oldfd); - if (oldfd >= 0 && newfd >= 0) - { - ensure_dirs_slot (newfd); - if (newfd < dirs_allocated) - { - if (oldfd < dirs_allocated) - { - if (dirs[oldfd].name != NULL) - { - dirs[newfd].name = strdup (dirs[oldfd].name); - if (dirs[newfd].name == NULL) - dirs[newfd].saved_errno = ENOMEM; - } - else - { - dirs[newfd].name = NULL; - dirs[newfd].saved_errno = dirs[oldfd].saved_errno; - } - } - else - { - dirs[newfd].name = NULL; - dirs[newfd].saved_errno = ENOMEM; - } - } - } + if (0 <= newfd) + newfd = _gl_register_dup (oldfd, newfd); return newfd; } -/* Our replacement overrides dup2 twice; be sure to pick - the one we want. */ -#if REPLACE_DUP2 -# undef dup2 -# define dup2 rpl_dup2 -#endif - -int -rpl_dup2_fchdir (int oldfd, int newfd) -{ - int retval = dup2 (oldfd, newfd); - - if (retval >= 0 && newfd != oldfd) - { - ensure_dirs_slot (newfd); - if (newfd < dirs_allocated) - { - if (oldfd < dirs_allocated) - { - if (dirs[oldfd].name != NULL) - { - dirs[newfd].name = strdup (dirs[oldfd].name); - if (dirs[newfd].name == NULL) - dirs[newfd].saved_errno = ENOMEM; - } - else - { - dirs[newfd].name = NULL; - dirs[newfd].saved_errno = dirs[oldfd].saved_errno; - } - } - else - { - dirs[newfd].name = NULL; - dirs[newfd].saved_errno = ENOMEM; - } - } - } - return retval; -} /* Implement fchdir() in terms of chdir(). */ int fchdir (int fd) { - if (fd >= 0) - { - if (fd < dirs_allocated) - { - if (dirs[fd].name != NULL) - return chdir (dirs[fd].name); - else - { - errno = dirs[fd].saved_errno; - return -1; - } - } - else - { - errno = ENOMEM; - return -1; - } - } - else - { - errno = EBADF; - return -1; - } + const char *name = _gl_directory_name (fd); + return name ? chdir (name) : -1; } diff --git a/src/bin/coreutils/lib/fchmodat.c b/src/bin/coreutils/lib/fchmodat.c index 935bdcbca1..53cafe06d5 100644 --- a/src/bin/coreutils/lib/fchmodat.c +++ b/src/bin/coreutils/lib/fchmodat.c @@ -1,5 +1,5 @@ /* Change the protections of file relative to an open directory. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,10 +18,12 @@ #include -#include "openat.h" +#include + #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "save-cwd.h" +#include "openat.h" #include "openat-priv.h" +#include "save-cwd.h" #ifndef HAVE_LCHMOD /* Use a different name, to avoid conflicting with any @@ -35,15 +37,15 @@ static int lchmod (char const *f, mode_t m) { errno = ENOSYS; return -1; } Invoke chmod or lchmod on file, FILE, using mode MODE, in the directory open on descriptor FD. If possible, do it without changing the working directory. Otherwise, resort to using save_cwd/fchdir, - then mkdir/restore_cwd. If either the save_cwd or the restore_cwd - fails, then give a diagnostic and exit nonzero. + then (chmod|lchmod)/restore_cwd. If either the save_cwd or the + restore_cwd fails, then give a diagnostic and exit nonzero. Note that an attempt to use a FLAG value of AT_SYMLINK_NOFOLLOW on a system without lchmod support causes this function to fail. */ #define AT_FUNC_NAME fchmodat #define AT_FUNC_F1 lchmod #define AT_FUNC_F2 chmod -#define AT_FUNC_USE_F1_COND flag == AT_SYMLINK_NOFOLLOW +#define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW #define AT_FUNC_POST_FILE_PARAM_DECLS , mode_t mode, int flag #define AT_FUNC_POST_FILE_ARGS , mode #include "at-func.c" diff --git a/src/bin/coreutils/lib/fchownat.c b/src/bin/coreutils/lib/fchownat.c index a1d5e60f21..6da3537340 100644 --- a/src/bin/coreutils/lib/fchownat.c +++ b/src/bin/coreutils/lib/fchownat.c @@ -4,7 +4,7 @@ when the buggy fchownat-with-AT_SYMLINK_NOFOLLOW operates on a symlink, it mistakenly affects the symlink referent, rather than the symlink itself. - Copyright (C) 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,26 +23,25 @@ #include -#include "openat.h" - #include #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "save-cwd.h" +#include "openat.h" #include "openat-priv.h" +#include "save-cwd.h" /* Replacement for Solaris' function by the same name. Invoke chown or lchown on file, FILE, using OWNER and GROUP, in the directory open on descriptor FD. If FLAG is AT_SYMLINK_NOFOLLOW, then use lchown, otherwise, use chown. If possible, do it without changing the working directory. Otherwise, resort to using save_cwd/fchdir, - then mkdir/restore_cwd. If either the save_cwd or the restore_cwd - fails, then give a diagnostic and exit nonzero. */ + then (chown|lchown)/restore_cwd. If either the save_cwd or the + restore_cwd fails, then give a diagnostic and exit nonzero. */ #define AT_FUNC_NAME fchownat #define AT_FUNC_F1 lchown #define AT_FUNC_F2 chown -#define AT_FUNC_USE_F1_COND flag == AT_SYMLINK_NOFOLLOW +#define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW #define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group, int flag #define AT_FUNC_POST_FILE_ARGS , owner, group #include "at-func.c" diff --git a/src/bin/coreutils/lib/fcntl--.h b/src/bin/coreutils/lib/fcntl--.h index 5a6a8792d0..588b69aab6 100644 --- a/src/bin/coreutils/lib/fcntl--.h +++ b/src/bin/coreutils/lib/fcntl--.h @@ -1,6 +1,6 @@ /* Like fcntl.h, but redefine some names to avoid glitches. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,3 +25,8 @@ #undef creat #define creat creat_safer + +#if GNULIB_OPENAT_SAFER +# undef openat +# define openat openat_safer +#endif diff --git a/src/bin/coreutils/lib/fcntl-safer.h b/src/bin/coreutils/lib/fcntl-safer.h index 99f38656d0..2b10ba68f4 100644 --- a/src/bin/coreutils/lib/fcntl-safer.h +++ b/src/bin/coreutils/lib/fcntl-safer.h @@ -1,6 +1,6 @@ /* Invoke fcntl-like functions, but avoid some glitches. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,3 +21,7 @@ int open_safer (char const *, int, ...); int creat_safer (char const *, mode_t); + +#if GNULIB_OPENAT_SAFER +int openat_safer (int, char const *, int, ...); +#endif diff --git a/src/bin/coreutils/lib/fcntl.in.h b/src/bin/coreutils/lib/fcntl.in.h index fd7520e8da..cadb6a1572 100644 --- a/src/bin/coreutils/lib/fcntl.in.h +++ b/src/bin/coreutils/lib/fcntl.in.h @@ -1,6 +1,6 @@ /* Like , but with non-working flags defined to 0. - Copyright (C) 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2006-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,6 +44,9 @@ #define _GL_FCNTL_H +/* The definition of GL_LINK_WARNING is copied here. */ + + /* Declare overridden functions. */ #ifdef __cplusplus @@ -58,15 +61,29 @@ extern int open (const char *filename, int flags, ...); # endif #endif -#ifdef FCHDIR_REPLACEMENT -/* gnulib internal function. */ -extern void _gl_register_fd (int fd, const char *filename); +#if @GNULIB_OPENAT@ +# if !@HAVE_OPENAT@ +# undef openat +# define openat rpl_openat +int openat (int fd, char const *file, int flags, /* mode_t mode */ ...); +# endif +#elif defined GNULIB_POSIXCHECK +# undef openat +# define openat(f,u,g) \ + (GL_LINK_WARNING ("openat is not portable - " \ + "use gnulib module openat for portability"), \ + openat) #endif #ifdef __cplusplus } #endif +/* Fix up the FD_* macros. */ + +#ifndef FD_CLOEXEC +# define FD_CLOEXEC 1 +#endif /* Fix up the O_* macros. */ @@ -75,6 +92,12 @@ extern void _gl_register_fd (int fd, const char *filename); # define O_DIRECT O_DIRECTIO #endif +#if !defined O_CLOEXEC && defined O_NOINHERIT +/* Mingw spells it `O_NOINHERIT'. Intentionally leave it + undefined if not available. */ +# define O_CLOEXEC O_NOINHERIT +#endif + #ifndef O_DIRECT # define O_DIRECT 0 #endif @@ -119,6 +142,10 @@ extern void _gl_register_fd (int fd, const char *filename); # define O_SYNC 0 #endif +#ifndef O_TTY_INIT +# define O_TTY_INIT 0 +#endif + /* For systems that distinguish between text and binary I/O. O_BINARY is usually declared in fcntl.h */ #if !defined O_BINARY && defined _O_BINARY @@ -138,6 +165,42 @@ extern void _gl_register_fd (int fd, const char *filename); # define O_TEXT 0 #endif +/* Fix up the AT_* macros. */ + +/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its + value exceeds INT_MAX, so its use as an int doesn't conform to the + C standard, and GCC and Sun C complain in some cases. If the bug + is present, undef AT_FDCWD here, so it can be redefined below. */ +#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 +# undef AT_FDCWD +#endif + +/* Use the same bit pattern as Solaris 9, but with the proper + signedness. The bit pattern is important, in case this actually is + Solaris with the above workaround. */ +#ifndef AT_FDCWD +# define AT_FDCWD (-3041965) +#endif + +/* Use the same values as Solaris 9. This shouldn't matter, but + there's no real reason to differ. */ +#ifndef AT_SYMLINK_NOFOLLOW +# define AT_SYMLINK_NOFOLLOW 4096 +#endif + +#ifndef AT_REMOVEDIR +# define AT_REMOVEDIR 1 +#endif + +/* Solaris 9 lacks these two, so just pick unique values. */ +#ifndef AT_SYMLINK_FOLLOW +# define AT_SYMLINK_FOLLOW 2 +#endif + +#ifndef AT_EACCESS +# define AT_EACCESS 4 +#endif + #endif /* _GL_FCNTL_H */ #endif /* _GL_FCNTL_H */ diff --git a/src/bin/coreutils/lib/fdopendir.c b/src/bin/coreutils/lib/fdopendir.c new file mode 100644 index 0000000000..14dc111c81 --- /dev/null +++ b/src/bin/coreutils/lib/fdopendir.c @@ -0,0 +1,107 @@ +/* provide a replacement fdopendir function + Copyright (C) 2004-2009 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering */ + +#include + +#include + +#include +#include + +#include "openat.h" +#include "openat-priv.h" +#include "save-cwd.h" + +#if GNULIB_DIRENT_SAFER +# include "dirent--.h" +#endif + +/* Replacement for Solaris' function by the same name. + + First, try to simulate it via opendir ("/proc/self/fd/FD"). Failing + that, simulate it by using fchdir metadata, or by doing + save_cwd/fchdir/opendir(".")/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, this function works just like Solaris' fdopendir. + + W A R N I N G: + Unlike other fd-related functions, this one effectively consumes + its FD parameter. The caller should not close or otherwise + manipulate FD if this function returns successfully. Also, this + implementation does not guarantee that dirfd(fdopendir(n))==n; + the open directory stream may use a clone of FD, or have no + associated fd at all. */ +DIR * +fdopendir (int fd) +{ + int saved_errno; + DIR *dir; + + char buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (buf, fd, "."); + if (proc_file) + { + dir = opendir (proc_file); + saved_errno = errno; + } + else + { + dir = NULL; + saved_errno = EOPNOTSUPP; + } + + /* If the syscall fails with an expected errno value, resort to + save_cwd/restore_cwd. */ + if (! dir && EXPECTED_ERRNO (saved_errno)) + { +#if REPLACE_FCHDIR + const char *name = _gl_directory_name (fd); + if (name) + dir = opendir (name); + saved_errno = errno; +#else /* !REPLACE_FCHDIR */ + struct saved_cwd saved_cwd; + if (save_cwd (&saved_cwd) != 0) + openat_save_fail (errno); + + if (fchdir (fd) != 0) + { + dir = NULL; + saved_errno = errno; + } + else + { + dir = opendir ("."); + saved_errno = errno; + + if (restore_cwd (&saved_cwd) != 0) + openat_restore_fail (errno); + } + + free_cwd (&saved_cwd); +#endif /* !REPLACE_FCHDIR */ + } + + if (dir) + close (fd); + if (proc_file != buf) + free (proc_file); + errno = saved_errno; + return dir; +} diff --git a/src/bin/coreutils/lib/fopen.c b/src/bin/coreutils/lib/fopen.c new file mode 100644 index 0000000000..72610bd9b4 --- /dev/null +++ b/src/bin/coreutils/lib/fopen.c @@ -0,0 +1,105 @@ +/* Open a stream to a file. + Copyright (C) 2007-2009 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + 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 . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +/* Get the original definition of fopen. It might be defined as a macro. */ +#define __need_FILE +#include +#undef __need_FILE + +static inline FILE * +orig_fopen (const char *filename, const char *mode) +{ + return fopen (filename, mode); +} + +/* Specification. */ +#include + +#include +#include +#include +#include +#include +#include + +FILE * +rpl_fopen (const char *filename, const char *mode) +{ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + if (strcmp (filename, "/dev/null") == 0) + filename = "NUL"; +#endif + +#if FOPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and a mode that requires write access is + specified, then fail. + Rationale: POSIX + says that + "A pathname that contains at least one non-slash character and that + ends with one or more trailing slashes shall be resolved as if a + single dot character ( '.' ) were appended to the pathname." + and + "The special filename dot shall refer to the directory specified by + its predecessor." + If the named file already exists as a directory, then if a mode that + requires write access is specified, fopen() must fail because POSIX + says that it + fails with errno = EISDIR in this case. + If the named file does not exist or does not name a directory, then + fopen() must fail since the file does not contain a '.' directory. */ + { + size_t len = strlen (filename); + if (len > 0 && filename[len - 1] == '/') + { + int fd; + struct stat statbuf; + FILE *fp; + + if (mode[0] == 'w' || mode[0] == 'a') + { + errno = EISDIR; + return NULL; + } + + fd = open (filename, O_RDONLY); + if (fd < 0) + return NULL; + + if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) + { + close (fd); + errno = ENOTDIR; + return NULL; + } + + fp = fdopen (fd, mode); + if (fp == NULL) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + } + return fp; + } + } +# endif + + return orig_fopen (filename, mode); +} diff --git a/src/bin/coreutils/lib/fstatat.c b/src/bin/coreutils/lib/fstatat.c index 8b6291225f..9b0c1afa24 100644 --- a/src/bin/coreutils/lib/fstatat.c +++ b/src/bin/coreutils/lib/fstatat.c @@ -1,6 +1,6 @@ /* Work around an fstatat bug on Solaris 9. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,12 +19,14 @@ #include -#define COMPILING_FSTATAT 1 -#include "openat.h" +#include #include +#include #include +#undef fstatat + /* fstatat should always follow symbolic links that end in /, but on Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified. This is the same problem that lstat.c addresses, so solve it in a similar diff --git a/src/bin/coreutils/lib/fts.c b/src/bin/coreutils/lib/fts.c index bbcd1ff1f1..2893e66959 100644 --- a/src/bin/coreutils/lib/fts.c +++ b/src/bin/coreutils/lib/fts.c @@ -69,8 +69,12 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #if ! _LIBC # include "fcntl--.h" -# include "openat.h" +# include "dirent--.h" # include "unistd--.h" +/* FIXME - use fcntl(F_DUPFD_CLOEXEC)/openat(O_CLOEXEC) once they are + supported. */ +# include "cloexec.h" +# include "openat.h" # include "same-inode.h" #endif @@ -228,10 +232,6 @@ static void free_dir (FTS *fts) {} # define SIZE_MAX ((size_t) -1) #endif -#ifndef O_DIRECTORY -# define O_DIRECTORY 0 -#endif - #define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) #define STREQ(a, b) (strcmp ((a), (b)) == 0) @@ -309,11 +309,13 @@ static inline DIR * internal_function opendirat (int fd, char const *dir) { - int new_fd = openat (fd, dir, O_RDONLY); + int new_fd = openat (fd, dir, + O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); DIR *dirp; if (new_fd < 0) return NULL; + set_cloexec_flag (new_fd, true); dirp = fdopendir (new_fd); if (dirp == NULL) { @@ -365,9 +367,12 @@ diropen (FTS const *sp, char const *dir) int open_flags = (O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK | (ISSET (FTS_PHYSICAL) ? O_NOFOLLOW : 0)); - return (ISSET (FTS_CWDFD) - ? openat (sp->fts_cwd_fd, dir, open_flags) - : open (dir, open_flags)); + int fd = (ISSET (FTS_CWDFD) + ? openat (sp->fts_cwd_fd, dir, open_flags) + : open (dir, open_flags)); + if (0 <= fd) + set_cloexec_flag (fd, true); + return fd; } FTS * @@ -606,14 +611,20 @@ fts_close (FTS *sp) if (ISSET(FTS_CWDFD)) { if (0 <= sp->fts_cwd_fd) - close (sp->fts_cwd_fd); + if (close (sp->fts_cwd_fd)) + saved_errno = errno; } else if (!ISSET(FTS_NOCHDIR)) { /* Return to original directory, save errno if necessary. */ if (fchdir(sp->fts_rfd)) saved_errno = errno; - close(sp->fts_rfd); + + /* If close fails, record errno only if saved_errno is zero, + so that we report the probably-more-meaningful fchdir errno. */ + if (close (sp->fts_rfd)) + if (saved_errno == 0) + saved_errno = errno; } fd_ring_clear (&sp->fts_fd_ring); @@ -1302,7 +1313,10 @@ fts_build (register FTS *sp, int type) if (nlinks || type == BREAD) { int dir_fd = dirfd(dirp); if (ISSET(FTS_CWDFD) && 0 <= dir_fd) - dir_fd = dup (dir_fd); + { + dir_fd = dup (dir_fd); + set_cloexec_flag (dir_fd, true); + } if (dir_fd < 0 || fts_safe_changedir(sp, cur, dir_fd, NULL)) { if (nlinks && type == BREAD) cur->fts_errno = errno; diff --git a/src/bin/coreutils/lib/fts_.h b/src/bin/coreutils/lib/fts_.h index ad339cab5c..0e2d505aff 100644 --- a/src/bin/coreutils/lib/fts_.h +++ b/src/bin/coreutils/lib/fts_.h @@ -233,12 +233,30 @@ typedef struct _ftsent { char fts_name[1]; /* file name */ } FTSENT; +#ifndef __GNUC_PREREQ +# if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +# else +# define __GNUC_PREREQ(maj, min) 0 +# endif +#endif + +#if __GNUC_PREREQ (3,4) +# undef __attribute_warn_unused_result__ +# define __attribute_warn_unused_result__ \ + __attribute__ ((__warn_unused_result__)) +#else +# define __attribute_warn_unused_result__ /* empty */ +#endif + __BEGIN_DECLS -FTSENT *fts_children (FTS *, int) __THROW; -int fts_close (FTS *) __THROW; +FTSENT *fts_children (FTS *, int) __THROW __attribute_warn_unused_result__; +int fts_close (FTS *) __THROW __attribute_warn_unused_result__; FTS *fts_open (char * const *, int, - int (*)(const FTSENT **, const FTSENT **)) __THROW; -FTSENT *fts_read (FTS *) __THROW; + int (*)(const FTSENT **, const FTSENT **)) + __THROW __attribute_warn_unused_result__; +FTSENT *fts_read (FTS *) __THROW __attribute_warn_unused_result__; int fts_set (FTS *, FTSENT *, int) __THROW; __END_DECLS diff --git a/src/bin/coreutils/lib/getcwd.c b/src/bin/coreutils/lib/getcwd.c index b9e57d31a9..6658ed58c0 100644 --- a/src/bin/coreutils/lib/getcwd.c +++ b/src/bin/coreutils/lib/getcwd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1999, 2004-2008 Free Software Foundation, Inc. +/* Copyright (C) 1991-1999, 2004-2009 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -59,20 +59,6 @@ #include -/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its - value exceeds INT_MAX, so its use as an int doesn't conform to the - C standard, and GCC and Sun C complain in some cases. */ -#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 -# undef AT_FDCWD -# define AT_FDCWD (-3041965) -#endif - -#ifdef ENAMETOOLONG -# define is_ENAMETOOLONG(x) ((x) == ENAMETOOLONG) -#else -# define is_ENAMETOOLONG(x) 0 -#endif - #ifndef MAX # define MAX(a, b) ((a) < (b) ? (b) : (a)) #endif @@ -103,7 +89,11 @@ #endif /* The results of opendir() in this file are not used with dirfd and fchdir, - therefore save some unnecessary recursion in fchdir.c. */ + and we do not leak fds to any single-threaded code that could use stdio, + therefore save some unnecessary recursion in fchdir.c. + FIXME - if the kernel ever adds support for multi-thread safety for + avoiding standard fds, then we should use opendir_safer and + openat_safer. */ #undef opendir #undef closedir @@ -160,7 +150,7 @@ __getcwd (char *buf, size_t size) # undef getcwd dir = getcwd (buf, size); - if (dir || (errno != ERANGE && !is_ENAMETOOLONG (errno) && errno != ENOENT)) + if (dir || (errno != ERANGE && errno != ENAMETOOLONG && errno != ENOENT)) return dir; #endif diff --git a/src/bin/coreutils/lib/gnulib.mk b/src/bin/coreutils/lib/gnulib.mk index 97166decf7..699d6df74f 100644 --- a/src/bin/coreutils/lib/gnulib.mk +++ b/src/bin/coreutils/lib/gnulib.mk @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --avoid=lock --no-libtool --macro-prefix=gl acl alloca announce-gen areadlink-with-size argmatch argv-iter assert atexit autobuild backupfile base64 c-strcase c-strtod c-strtold calloc canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type diacrit dirfd dirname dup2 error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu fopen-safer fprintftime fseeko fsusage ftello ftruncate fts gendocs getdate getgroups gethrxtime getline getloadavg getndelim2 getopt-gnu getpagesize getpass-gnu gettext gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnumakefile gnupload group-member hard-locale hash hash-pjw host-os human idcache ignore-value inttostr inttypes isapipe lchmod lchown lib-ignore linebuffer link-follow long-options lstat maintainer-makefile malloc manywarnings mbrtowc mbsalign mbswidth memcasecmp memchr memcmp memcmp2 memcpy memmove mempcpy memrchr memset mgetgroups mkancesdirs mkdir mkdir-p mkstemp mktime modechange mountlist mpsort obstack pathmax perl physmem posix-shell posixtm posixver priv-set progname propername putenv quote quotearg raise randint randperm readlink readtokens readtokens0 readutmp realloc regex rename rename-dest-slash rmdir rmdir-errno root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at settime sig2str sigaction ssize_t stat-macros stat-time stdbool stdlib-safer stpcpy stpncpy strcspn strdup strftime strpbrk strtod strtoimax strtol strtoumax strverscmp sys_stat timespec tzset unicodeio unistd-safer unlink-busy unlinkdir unlocked-io update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf warnings wcwidth winsz-ioctl winsz-termios write-any-file xalloc xfreopen xgetcwd xgethostname xmemcoll xnanosleep xprintf xprintf-posix xstrtod xstrtoimax xstrtol xstrtold xstrtoumax yesno +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --avoid=lock --no-libtool --macro-prefix=gl acl alloca announce-gen areadlink-with-size argmatch argv-iter assert atexit autobuild backupfile base64 c-strcase c-strtod c-strtold calloc canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type diacrit dirfd dirname dup2 error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu fopen-safer fprintftime fseeko fsusage ftello ftruncate fts gendocs getdate getgroups gethrxtime getline getloadavg getndelim2 getopt-gnu getpagesize getpass-gnu gettext gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnumakefile gnupload group-member hard-locale hash hash-pjw host-os human idcache ignore-value inttostr inttypes isapipe lchmod lchown lib-ignore linebuffer link link-follow long-options lstat maintainer-makefile malloc manywarnings mbrtowc mbsalign mbswidth memcasecmp memchr memcmp memcmp2 memcpy memmove mempcpy memrchr memset mgetgroups mkancesdirs mkdir mkdir-p mkstemp mktime modechange mountlist mpsort obstack pathmax perl physmem posix-shell posixtm posixver priv-set progname propername putenv quote quotearg raise randint randperm readlink readtokens readtokens0 readutmp realloc regex rename rename-dest-slash rmdir rmdir-errno root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at settime sig2str sigaction ssize_t stat-macros stat-time stdbool stdlib-safer stpcpy stpncpy strcspn strdup strftime strpbrk strtod strtoimax strtol strtoumax strverscmp sys_stat timespec tzset unicodeio unistd-safer unlink-busy unlinkdir unlocked-io update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf warnings wcwidth winsz-ioctl winsz-termios write-any-file xalloc xfreopen xgetcwd xgethostname xmemcoll xnanosleep xprintf xprintf-posix xstrtod xstrtoimax xstrtol xstrtold xstrtoumax yesno AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects @@ -71,9 +71,10 @@ BUILT_SOURCES += $(ALLOCA_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. alloca.h: alloca.in.h + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/alloca.in.h; \ - } > $@-t + } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += alloca.h alloca.h-t @@ -118,8 +119,8 @@ BUILT_SOURCES += $(ARPA_INET_H) # We need the following in order to create when the system # doesn't have one. arpa/inet.h: arpa_inet.in.h - @MKDIR_P@ arpa - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) arpa + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -131,7 +132,7 @@ arpa/inet.h: arpa_inet.in.h -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/arpa_inet.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t MOSTLYCLEANDIRS += arpa @@ -336,7 +337,7 @@ EXTRA_libcoreutils_a_SOURCES += closeout.c # The Automake-defined pkg* macros are appended, in the order # listed in the Automake 1.10a+ documentation. configmake.h: Makefile - rm -f $@-t + $(AM_V_GEN)rm -f $@-t && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ echo '#define PREFIX "$(prefix)"'; \ echo '#define EXEC_PREFIX "$(exec_prefix)"'; \ @@ -365,7 +366,7 @@ configmake.h: Makefile echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \ echo '#define PKGLIBDIR "$(pkglibdir)"'; \ echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \ - } | sed '/""/d' > $@-t + } | sed '/""/d' > $@-t && \ if test -f $@ && cmp $@-t $@ > /dev/null; then \ rm -f $@-t; \ else \ @@ -442,21 +443,23 @@ BUILT_SOURCES += $(DIRENT_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. dirent.h: dirent.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \ -e 's|@''GNULIB_DIRFD''@|$(GNULIB_DIRFD)|g' \ + -e 's|@''GNULIB_FDOPENDIR''@|$(GNULIB_FDOPENDIR)|g' \ -e 's|@''GNULIB_SCANDIR''@|$(GNULIB_SCANDIR)|g' \ -e 's|@''GNULIB_ALPHASORT''@|$(GNULIB_ALPHASORT)|g' \ -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \ + -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \ -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/dirent.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += dirent.h dirent.h-t @@ -464,6 +467,15 @@ EXTRA_DIST += dirent.in.h ## end gnulib module dirent +## begin gnulib module dirent-safer + + +EXTRA_DIST += dirent--.h dirent-safer.h opendir-safer.c + +EXTRA_libcoreutils_a_SOURCES += opendir-safer.c + +## end gnulib module dirent-safer + ## begin gnulib module dirfd @@ -498,7 +510,7 @@ BUILT_SOURCES += $(ERRNO_H) # We need the following in order to create when the system # doesn't have one that is POSIX compliant. errno.h: errno.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -510,7 +522,7 @@ errno.h: errno.in.h -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \ -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \ < $(srcdir)/errno.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += errno.h errno.h-t @@ -572,28 +584,31 @@ EXTRA_libcoreutils_a_SOURCES += fclose.c ## end gnulib module fclose -## begin gnulib module fcntl +## begin gnulib module fcntl-h BUILT_SOURCES += $(FCNTL_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. fcntl.h: fcntl.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \ + -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \ -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ + -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/fcntl.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += fcntl.h fcntl.h-t EXTRA_DIST += fcntl.in.h -## end gnulib module fcntl +## end gnulib module fcntl-h ## begin gnulib module fcntl-safer @@ -604,6 +619,15 @@ EXTRA_libcoreutils_a_SOURCES += creat-safer.c open-safer.c ## end gnulib module fcntl-safer +## begin gnulib module fdopendir + + +EXTRA_DIST += fdopendir.c openat-priv.h openat-proc.c + +EXTRA_libcoreutils_a_SOURCES += fdopendir.c openat-proc.c + +## end gnulib module fdopendir + ## begin gnulib module fflush @@ -672,13 +696,13 @@ BUILT_SOURCES += $(FLOAT_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. float.h: float.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ < $(srcdir)/float.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += float.h float.h-t @@ -693,9 +717,10 @@ BUILT_SOURCES += $(FNMATCH_H) # We need the following in order to create when the system # doesn't have one that supports the required API. fnmatch.h: fnmatch.in.h + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/fnmatch.in.h; \ - } > $@-t + } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t @@ -705,6 +730,15 @@ EXTRA_libcoreutils_a_SOURCES += fnmatch.c fnmatch_loop.c ## end gnulib module fnmatch +## begin gnulib module fopen + + +EXTRA_DIST += fopen.c + +EXTRA_libcoreutils_a_SOURCES += fopen.c + +## end gnulib module fopen + ## begin gnulib module fopen-safer @@ -969,9 +1003,10 @@ BUILT_SOURCES += $(GETOPT_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. getopt.h: getopt.in.h + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat $(srcdir)/getopt.in.h; \ - } > $@-t + } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += getopt.h getopt.h-t @@ -1180,7 +1215,7 @@ BUILT_SOURCES += $(ICONV_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. iconv.h: iconv.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -1190,7 +1225,7 @@ iconv.h: iconv.in.h -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \ -e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \ < $(srcdir)/iconv.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += iconv.h iconv.h-t @@ -1206,12 +1241,15 @@ iconv_open-irix.h: iconv_open-irix.gperf iconv_open-osf.h: iconv_open-osf.gperf $(GPERF) -m 10 $(srcdir)/iconv_open-osf.gperf > $(srcdir)/iconv_open-osf.h-t mv $(srcdir)/iconv_open-osf.h-t $(srcdir)/iconv_open-osf.h -BUILT_SOURCES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h -MOSTLYCLEANFILES += iconv_open-aix.h-t iconv_open-hpux.h-t iconv_open-irix.h-t iconv_open-osf.h-t -MAINTAINERCLEANFILES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h -EXTRA_DIST += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h +iconv_open-solaris.h: iconv_open-solaris.gperf + $(GPERF) -m 10 $(srcdir)/iconv_open-solaris.gperf > $(srcdir)/iconv_open-solaris.h-t + mv $(srcdir)/iconv_open-solaris.h-t $(srcdir)/iconv_open-solaris.h +BUILT_SOURCES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h +MOSTLYCLEANFILES += iconv_open-aix.h-t iconv_open-hpux.h-t iconv_open-irix.h-t iconv_open-osf.h-t iconv_open-solaris.h-t +MAINTAINERCLEANFILES += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h +EXTRA_DIST += iconv_open-aix.h iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h -EXTRA_DIST += iconv.in.h iconv_open-aix.gperf iconv_open-hpux.gperf iconv_open-irix.gperf iconv_open-osf.gperf iconv_open.c +EXTRA_DIST += iconv.in.h iconv_open-aix.gperf iconv_open-hpux.gperf iconv_open-irix.gperf iconv_open-osf.gperf iconv_open-solaris.gperf iconv_open.c EXTRA_libcoreutils_a_SOURCES += iconv_open.c @@ -1264,7 +1302,7 @@ BUILT_SOURCES += $(INTTYPES_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. inttypes.h: inttypes.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -1289,7 +1327,7 @@ inttypes.h: inttypes.in.h -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/inttypes.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += inttypes.h inttypes.h-t @@ -1348,6 +1386,15 @@ libcoreutils_a_SOURCES += linebuffer.h linebuffer.c ## end gnulib module linebuffer +## begin gnulib module link + + +EXTRA_DIST += link.c + +EXTRA_libcoreutils_a_SOURCES += link.c + +## end gnulib module link + ## begin gnulib module link-warning LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h @@ -1414,14 +1461,14 @@ uninstall-localcharset: all-local fi charset.alias: config.charset - rm -f t-$@ $@ - $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ + $(AM_V_GEN)rm -f t-$@ $@ && \ + $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \ mv t-$@ $@ SUFFIXES += .sed .sin .sin.sed: - rm -f t-$@ $@ - sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ + $(AM_V_GEN)rm -f t-$@ $@ && \ + sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \ mv t-$@ $@ CLEANFILES += charset.alias ref-add.sed ref-del.sed @@ -1496,7 +1543,7 @@ BUILT_SOURCES += math.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. math.h: math.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -1558,7 +1605,7 @@ math.h: math.in.h -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/math.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += math.h math.h-t @@ -1848,7 +1895,7 @@ BUILT_SOURCES += $(NETDB_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. netdb.h: netdb.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -1861,7 +1908,7 @@ netdb.h: netdb.in.h -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ < $(srcdir)/netdb.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += netdb.h netdb.h-t @@ -1876,15 +1923,15 @@ BUILT_SOURCES += $(NETINET_IN_H) # We need the following in order to create when the system # doesn't have one. netinet/in.h: netinet_in.in.h - @MKDIR_P@ netinet - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) netinet + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ < $(srcdir)/netinet_in.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t MOSTLYCLEANDIRS += netinet @@ -1926,6 +1973,15 @@ libcoreutils_a_SOURCES += openat-die.c ## end gnulib module openat-die +## begin gnulib module openat-safer + + +EXTRA_DIST += fcntl--.h fcntl-safer.h openat-safer.c + +EXTRA_libcoreutils_a_SOURCES += openat-safer.c + +## end gnulib module openat-safer + ## begin gnulib module pathmax @@ -2254,19 +2310,19 @@ libcoreutils_a_SOURCES += se-context.in.h se-selinux.in.h BUILT_SOURCES += $(SELINUX_SELINUX_H) selinux/selinux.h: se-selinux.in.h - rm -f $@-t $@ - $(MKDIR_P) selinux - cp $(srcdir)/se-selinux.in.h $@-t - chmod a-x $@-t + $(AM_V_at)$(MKDIR_P) selinux + $(AM_V_GEN)rm -f $@-t $@ && \ + cp $(srcdir)/se-selinux.in.h $@-t && \ + chmod a-x $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t BUILT_SOURCES += $(SELINUX_CONTEXT_H) selinux/context.h: se-context.in.h - rm -f $@-t $@ - $(MKDIR_P) selinux - cp $(srcdir)/se-context.in.h $@-t - chmod a-x $@-t + $(AM_V_at)$(MKDIR_P) selinux + $(AM_V_GEN)rm -f $@-t $@ && \ + cp $(srcdir)/se-context.in.h $@-t && \ + chmod a-x $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t MOSTLYCLEANDIRS += selinux @@ -2316,7 +2372,7 @@ BUILT_SOURCES += signal.h # We need the following in order to create when the system # doesn't have a complete one. signal.h: signal.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2332,7 +2388,7 @@ signal.h: signal.in.h -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/signal.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += signal.h signal.h-t @@ -2402,13 +2458,13 @@ BUILT_SOURCES += $(STDARG_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdarg.h: stdarg.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \ < $(srcdir)/stdarg.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += stdarg.h stdarg.h-t @@ -2423,10 +2479,10 @@ BUILT_SOURCES += $(STDBOOL_H) # We need the following in order to create when the system # doesn't have one that works. stdbool.h: stdbool.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += stdbool.h stdbool.h-t @@ -2441,7 +2497,7 @@ BUILT_SOURCES += $(STDDEF_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. stddef.h: stddef.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2449,7 +2505,7 @@ stddef.h: stddef.in.h -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ < $(srcdir)/stddef.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += stddef.h stddef.h-t @@ -2464,7 +2520,7 @@ BUILT_SOURCES += $(STDINT_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdint.h: stdint.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2491,7 +2547,7 @@ stdint.h: stdint.in.h -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ < $(srcdir)/stdint.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += stdint.h stdint.h-t @@ -2506,83 +2562,87 @@ BUILT_SOURCES += stdio.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdio.h: stdio.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ + -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \ + -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ + -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ + -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \ -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \ -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \ + -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \ + -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \ + -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \ + -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \ + -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \ + -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \ + -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \ + -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ + -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \ + -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \ + -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \ + -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \ + -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \ + -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \ + -e 's|@''GNULIB_POPEN''@|$(GNULIB_POPEN)|g' \ -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \ -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \ + -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ + -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \ + -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \ + -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \ -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \ + -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ + -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ + -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \ -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \ -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \ -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \ -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \ -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \ -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \ - -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \ - -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \ - -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ - -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \ - -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \ - -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \ - -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \ - -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \ - -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \ - -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \ - -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ - -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ - -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \ - -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ - -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \ - -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ - -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \ - -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \ - -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \ - -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \ - -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \ - -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \ - -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \ - -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ - -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ - -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ - -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ - -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ - -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ - -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ - -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ - -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ - -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ - -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ - -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ - -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ - -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ - -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ - -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ - -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ - -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ - -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ - -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \ - -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ - -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ - -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ - -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ - -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ - -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ - -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ - -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ - -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ + -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ + -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ + -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ + -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ + -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ + -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ + -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ + -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ + -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ + -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ + -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ + -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ + -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ + -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ + -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ + -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ + -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \ + -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \ -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \ + -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \ + -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ + -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \ + -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ + -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ + -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ + -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ + -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ + -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ + -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ + -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ + -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/stdio.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += stdio.h stdio.h-t @@ -2599,7 +2659,7 @@ BUILT_SOURCES += stdlib.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. stdlib.h: stdlib.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2612,6 +2672,7 @@ stdlib.h: stdlib.in.h -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \ -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \ + -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \ -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \ -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \ -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \ @@ -2626,6 +2687,7 @@ stdlib.h: stdlib.in.h -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ + -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ @@ -2643,7 +2705,7 @@ stdlib.h: stdlib.in.h -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/stdlib.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += stdlib.h stdlib.h-t @@ -2745,7 +2807,7 @@ BUILT_SOURCES += string.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. string.h: string.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2791,7 +2853,6 @@ string.h: string.in.h -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ - -e 's|@''HAVE_STRNDUP''@|$(HAVE_STRNDUP)|g' \ -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ @@ -2807,10 +2868,13 @@ string.h: string.in.h -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ + -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ + -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ + -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/string.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += string.h string.h-t @@ -2940,8 +3004,8 @@ BUILT_SOURCES += $(SYS_SELECT_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/select.h: sys_select.in.h - @MKDIR_P@ sys - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2952,7 +3016,7 @@ sys/select.h: sys_select.in.h -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/sys_select.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += sys/select.h sys/select.h-t MOSTLYCLEANDIRS += sys @@ -2968,7 +3032,8 @@ BUILT_SOURCES += $(SYS_SOCKET_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/socket.h: sys_socket.in.h - @MKDIR_P@ sys + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -2989,13 +3054,15 @@ sys/socket.h: sys_socket.in.h -e 's|@''GNULIB_SENDTO''@|$(GNULIB_SENDTO)|g' \ -e 's|@''GNULIB_SETSOCKOPT''@|$(GNULIB_SETSOCKOPT)|g' \ -e 's|@''GNULIB_SHUTDOWN''@|$(GNULIB_SHUTDOWN)|g' \ + -e 's|@''GNULIB_ACCEPT4''@|$(GNULIB_ACCEPT4)|g' \ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \ -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ + -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/sys_socket.in.h; \ - } > $@-t + } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t MOSTLYCLEANDIRS += sys @@ -3006,26 +3073,38 @@ EXTRA_DIST += sys_socket.in.h ## begin gnulib module sys_stat -BUILT_SOURCES += $(SYS_STAT_H) +BUILT_SOURCES += sys/stat.h # We need the following in order to create when the system # has one that is incomplete. sys/stat.h: sys_stat.in.h - @MKDIR_P@ sys - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ + -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \ + -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \ -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \ -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \ + -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \ + -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \ + -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \ + -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ + -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ + -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ + -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ + -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ + -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/sys_stat.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t MOSTLYCLEANDIRS += sys @@ -3041,8 +3120,8 @@ BUILT_SOURCES += $(SYS_TIME_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. sys/time.h: sys_time.in.h - @MKDIR_P@ sys - rm -f $@-t $@ + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -3051,7 +3130,7 @@ sys/time.h: sys_time.in.h -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ < $(srcdir)/sys_time.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += sys/time.h sys/time.h-t @@ -3075,7 +3154,7 @@ BUILT_SOURCES += time.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. time.h: time.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -3088,7 +3167,7 @@ time.h: time.in.h -e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ < $(srcdir)/time.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += time.h time.h-t @@ -3139,7 +3218,7 @@ BUILT_SOURCES += unistd.h # We need the following in order to create an empty placeholder for # when the system doesn't have one. unistd.h: unistd.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -3148,9 +3227,12 @@ unistd.h: unistd.in.h -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \ + -e 's|@''GNULIB_DUP3''@|$(GNULIB_DUP3)|g' \ -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \ -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \ + -e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \ -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ + -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \ -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \ -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ @@ -3163,13 +3245,20 @@ unistd.h: unistd.in.h -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ + -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ + -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ + -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \ -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \ -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \ + -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \ -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ + -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ + -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ + -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \ @@ -3178,8 +3267,12 @@ unistd.h: unistd.in.h -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ + -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ + -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ + -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ + -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ @@ -3188,16 +3281,18 @@ unistd.h: unistd.in.h -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ + -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/unistd.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += unistd.h unistd.h-t @@ -3389,7 +3484,7 @@ BUILT_SOURCES += $(WCHAR_H) # We need the following in order to create when the system # version does not work standalone. wchar.h: wchar.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ @@ -3432,7 +3527,7 @@ wchar.h: wchar.in.h -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/wchar.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += wchar.h wchar.h-t @@ -3456,7 +3551,7 @@ BUILT_SOURCES += $(WCTYPE_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. wctype.h: wctype.in.h - rm -f $@-t $@ + $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -3466,7 +3561,7 @@ wctype.h: wctype.in.h -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ < $(srcdir)/wctype.in.h; \ - } > $@-t + } > $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += wctype.h wctype.h-t diff --git a/src/bin/coreutils/lib/iconv_open-solaris.gperf b/src/bin/coreutils/lib/iconv_open-solaris.gperf new file mode 100644 index 0000000000..7d7da38e6e --- /dev/null +++ b/src/bin/coreutils/lib/iconv_open-solaris.gperf @@ -0,0 +1,30 @@ +struct mapping { int standard_name; const char vendor_name[10 + 1]; }; +%struct-type +%language=ANSI-C +%define slot-name standard_name +%define hash-function-name mapping_hash +%define lookup-function-name mapping_lookup +%readonly-tables +%global-table +%define word-array-name mappings +%pic +%% +# On Solaris 10, look in the "iconv -l" output. Some aliases are advertised but +# not actually supported by the iconv() function and by the 'iconv' program. +# For example: +# $ echo abc | iconv -f 646 -t ISO-8859-1 +# Not supported 646 to ISO-8859-1 +# $ echo abc | iconv -f 646 -t ISO8859-1 +$ abc +ASCII, "646" +ISO-8859-1, "ISO8859-1" +ISO-8859-2, "ISO8859-2" +ISO-8859-3, "ISO8859-3" +ISO-8859-4, "ISO8859-4" +ISO-8859-5, "ISO8859-5" +ISO-8859-6, "ISO8859-6" +ISO-8859-7, "ISO8859-7" +ISO-8859-8, "ISO8859-8" +ISO-8859-9, "ISO8859-9" +ISO-8859-15, "ISO8859-15" +CP1251, "ansi-1251" diff --git a/src/bin/coreutils/lib/iconv_open-solaris.h b/src/bin/coreutils/lib/iconv_open-solaris.h new file mode 100644 index 0000000000..2963145be8 --- /dev/null +++ b/src/bin/coreutils/lib/iconv_open-solaris.h @@ -0,0 +1,190 @@ +/* ANSI-C code produced by gperf version 3.0.3 */ +/* Command-line: gperf -m 10 ./iconv_open-solaris.gperf */ +/* Computed positions: -k'10' */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +#error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#endif + +#line 1 "./iconv_open-solaris.gperf" +struct mapping { int standard_name; const char vendor_name[10 + 1]; }; + +#define TOTAL_KEYWORDS 13 +#define MIN_WORD_LENGTH 5 +#define MAX_WORD_LENGTH 11 +#define MIN_HASH_VALUE 5 +#define MAX_HASH_VALUE 19 +/* maximum key range = 15, duplicates = 0 */ + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static unsigned int +mapping_hash (register const char *str, register unsigned int len) +{ + static const unsigned char asso_values[] = + { + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, + 9, 8, 7, 6, 5, 4, 3, 2, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20 + }; + register int hval = len; + + switch (hval) + { + default: + hval += asso_values[(unsigned char)str[9]]; + /*FALLTHROUGH*/ + case 9: + case 8: + case 7: + case 6: + case 5: + break; + } + return hval; +} + +struct stringpool_t + { + char stringpool_str5[sizeof("ASCII")]; + char stringpool_str6[sizeof("CP1251")]; + char stringpool_str7[sizeof("$ abc")]; + char stringpool_str10[sizeof("ISO-8859-1")]; + char stringpool_str11[sizeof("ISO-8859-15")]; + char stringpool_str12[sizeof("ISO-8859-9")]; + char stringpool_str13[sizeof("ISO-8859-8")]; + char stringpool_str14[sizeof("ISO-8859-7")]; + char stringpool_str15[sizeof("ISO-8859-6")]; + char stringpool_str16[sizeof("ISO-8859-5")]; + char stringpool_str17[sizeof("ISO-8859-4")]; + char stringpool_str18[sizeof("ISO-8859-3")]; + char stringpool_str19[sizeof("ISO-8859-2")]; + }; +static const struct stringpool_t stringpool_contents = + { + "ASCII", + "CP1251", + "$ abc", + "ISO-8859-1", + "ISO-8859-15", + "ISO-8859-9", + "ISO-8859-8", + "ISO-8859-7", + "ISO-8859-6", + "ISO-8859-5", + "ISO-8859-4", + "ISO-8859-3", + "ISO-8859-2" + }; +#define stringpool ((const char *) &stringpool_contents) + +static const struct mapping mappings[] = + { + {-1}, {-1}, {-1}, {-1}, {-1}, +#line 19 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str5, "646"}, +#line 30 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str6, "ansi-1251"}, +#line 18 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str7}, + {-1}, {-1}, +#line 20 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str10, "ISO8859-1"}, +#line 29 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str11, "ISO8859-15"}, +#line 28 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str12, "ISO8859-9"}, +#line 27 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str13, "ISO8859-8"}, +#line 26 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str14, "ISO8859-7"}, +#line 25 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str15, "ISO8859-6"}, +#line 24 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str16, "ISO8859-5"}, +#line 23 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str17, "ISO8859-4"}, +#line 22 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str18, "ISO8859-3"}, +#line 21 "./iconv_open-solaris.gperf" + {(int)(long)&((struct stringpool_t *)0)->stringpool_str19, "ISO8859-2"} + }; + +#ifdef __GNUC__ +__inline +#ifdef __GNUC_STDC_INLINE__ +__attribute__ ((__gnu_inline__)) +#endif +#endif +const struct mapping * +mapping_lookup (register const char *str, register unsigned int len) +{ + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) + { + register int key = mapping_hash (str, len); + + if (key <= MAX_HASH_VALUE && key >= 0) + { + register int o = mappings[key].standard_name; + if (o >= 0) + { + register const char *s = o + stringpool; + + if (*str == *s && !strcmp (str + 1, s + 1)) + return &mappings[key]; + } + } + } + return 0; +} diff --git a/src/bin/coreutils/lib/iconv_open.c b/src/bin/coreutils/lib/iconv_open.c index e72b15b3a5..b2e7f54a08 100644 --- a/src/bin/coreutils/lib/iconv_open.c +++ b/src/bin/coreutils/lib/iconv_open.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Character set conversion. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,6 +39,7 @@ #define ICONV_FLAVOR_HPUX "iconv_open-hpux.h" #define ICONV_FLAVOR_IRIX "iconv_open-irix.h" #define ICONV_FLAVOR_OSF "iconv_open-osf.h" +#define ICONV_FLAVOR_SOLARIS "iconv_open-solaris.h" #ifdef ICONV_FLAVOR # include ICONV_FLAVOR diff --git a/src/bin/coreutils/lib/ignore-value.h b/src/bin/coreutils/lib/ignore-value.h index 5f97c91c3f..86cfad77b2 100644 --- a/src/bin/coreutils/lib/ignore-value.h +++ b/src/bin/coreutils/lib/ignore-value.h @@ -1,6 +1,6 @@ -/* ignore a value to quiet a compiler warning +/* ignore a function return without a compiler warning - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,13 +17,7 @@ /* Written by Jim Meyering. */ -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) -# endif -#endif - -/* Use this function to avoid a warning when using a function declared with +/* Use these functions to avoid a warning when using a function declared with gcc's warn_unused_result attribute, but for which you really do want to ignore the result. Traditionally, people have used a "(void)" cast to indicate that a function's return value is deliberately unused. However, @@ -38,8 +32,6 @@ "copy.c:233: warning: ignoring return value of 'fchown', declared with attribute warn_unused_result". */ -static inline void -ignore_value (int i __attribute__ ((__unused__))) -{ - /* empty */ -} +static inline void ignore_value (int i) { (void) i; } +static inline void ignore_ptr (void* p) { (void) p; } +/* FIXME: what about aggregate types? */ diff --git a/src/bin/coreutils/lib/inet_ntop.c b/src/bin/coreutils/lib/inet_ntop.c index 1328bedc9f..b1443f4371 100644 --- a/src/bin/coreutils/lib/inet_ntop.c +++ b/src/bin/coreutils/lib/inet_ntop.c @@ -3,7 +3,7 @@ #line 1 /* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form - Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,10 +45,6 @@ #include #include -#ifndef EAFNOSUPPORT -# define EAFNOSUPPORT EINVAL -#endif - #define NS_IN6ADDRSZ 16 #define NS_INT16SZ 2 diff --git a/src/bin/coreutils/lib/lchown.c b/src/bin/coreutils/lib/lchown.c index 07aef87394..8cf10dd0c2 100644 --- a/src/bin/coreutils/lib/lchown.c +++ b/src/bin/coreutils/lib/lchown.c @@ -1,7 +1,7 @@ /* Provide a stub lchown function for systems that lack it. - Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007 Free Software - Foundation, Inc. + Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007, 2009 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,16 +30,6 @@ #include #include -/* Some systems don't have EOPNOTSUPP. */ -#ifndef EOPNOTSUPP -# ifdef ENOTSUP -# define EOPNOTSUPP ENOTSUP -# else -/* Some systems don't have ENOTSUP either. */ -# define EOPNOTSUPP EINVAL -# endif -#endif - /* Work just like chown, except when FILE is a symbolic link. In that case, set errno to EOPNOTSUPP and return -1. But if autoconf tests determined that chown modifies @@ -48,7 +38,8 @@ int lchown (const char *file, uid_t uid, gid_t gid) { -#if ! CHOWN_MODIFIES_SYMLINK +#if HAVE_CHOWN +# if ! CHOWN_MODIFIES_SYMLINK struct stat stats; if (lstat (file, &stats) == 0 && S_ISLNK (stats.st_mode)) @@ -56,7 +47,12 @@ lchown (const char *file, uid_t uid, gid_t gid) errno = EOPNOTSUPP; return -1; } -#endif +# endif return chown (file, uid, gid); + +#else /* !HAVE_CHOWN */ + errno = ENOSYS; + return -1; +#endif } diff --git a/src/bin/coreutils/lib/link.c b/src/bin/coreutils/lib/link.c new file mode 100644 index 0000000000..0b4fb0cd93 --- /dev/null +++ b/src/bin/coreutils/lib/link.c @@ -0,0 +1,204 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Emulate link on platforms that lack it, namely native Windows platforms. + + Copyright (C) 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include + +#include + +#include +#include +#include +#include + +#if !HAVE_LINK +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN +# include + +/* CreateHardLink was introduced only in Windows 2000. */ +typedef BOOL (WINAPI * CreateHardLinkFuncType) (LPCTSTR lpFileName, + LPCTSTR lpExistingFileName, + LPSECURITY_ATTRIBUTES lpSecurityAttributes); +static CreateHardLinkFuncType CreateHardLinkFunc = NULL; +static BOOL initialized = FALSE; + +static void +initialize (void) +{ + HMODULE kernel32 = LoadLibrary ("kernel32.dll"); + if (kernel32 != NULL) + { + CreateHardLinkFunc = + (CreateHardLinkFuncType) GetProcAddress (kernel32, "CreateHardLinkA"); + } + initialized = TRUE; +} + +int +link (const char *file1, const char *file2) +{ + char *dir; + size_t len1 = strlen (file1); + size_t len2 = strlen (file2); + if (!initialized) + initialize (); + if (CreateHardLinkFunc == NULL) + { + /* System does not support hard links. */ + errno = EPERM; + return -1; + } + /* Reject trailing slashes on non-directories; mingw does not + support hard-linking directories. */ + if ((len1 && (file1[len1 - 1] == '/' || file1[len1 - 1] == '\\')) + || (len2 && (file2[len2 - 1] == '/' || file2[len2 - 1] == '\\'))) + { + struct stat st; + if (stat (file1, &st) == 0 && S_ISDIR (st.st_mode)) + errno = EPERM; + else + errno = ENOTDIR; + return -1; + } + /* CreateHardLink("b/.","a",NULL) creates file "b", so we must check + that dirname(file2) exists. */ + dir = strdup (file2); + if (!dir) + return -1; + { + struct stat st; + char *p = strchr (dir, '\0'); + while (dir < p && (*--p != '/' && *p != '\\')); + *p = '\0'; + if (p != dir && stat (dir, &st) == -1) + { + int saved_errno = errno; + free (dir); + errno = saved_errno; + return -1; + } + free (dir); + } + /* Now create the link. */ + if (CreateHardLinkFunc (file2, file1, NULL) == 0) + { + /* It is not documented which errors CreateHardLink() can produce. + * The following conversions are based on tests on a Windows XP SP2 + * system. */ + DWORD err = GetLastError (); + switch (err) + { + case ERROR_ACCESS_DENIED: + errno = EACCES; + break; + + case ERROR_INVALID_FUNCTION: /* fs does not support hard links */ + errno = EPERM; + break; + + case ERROR_NOT_SAME_DEVICE: + errno = EXDEV; + break; + + case ERROR_PATH_NOT_FOUND: + case ERROR_FILE_NOT_FOUND: + errno = ENOENT; + break; + + case ERROR_INVALID_PARAMETER: + errno = ENAMETOOLONG; + break; + + case ERROR_TOO_MANY_LINKS: + errno = EMLINK; + break; + + case ERROR_ALREADY_EXISTS: + errno = EEXIST; + break; + + default: + errno = EIO; + } + return -1; + } + + return 0; +} + +# else /* !Windows */ + +# error "This platform lacks a link function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib." + +# endif /* !Windows */ +#else /* HAVE_LINK */ + +# undef link + +/* Create a hard link from FILE1 to FILE2, working around platform bugs. */ +int +rpl_link (char const *file1, char const *file2) +{ + /* Reject trailing slashes on non-directories. */ + size_t len1 = strlen (file1); + size_t len2 = strlen (file2); + if ((len1 && file1[len1 - 1] == '/') + || (len2 && file2[len2 - 1] == '/')) + { + /* Let link() decide whether hard-linking directories is legal. + If stat() fails, link() will probably fail for the same + reason; so we only have to worry about successful stat() and + non-directory. */ + struct stat st; + if (stat (file1, &st) == 0 && !S_ISDIR (st.st_mode)) + { + errno = ENOTDIR; + return -1; + } + } + else + { + /* Fix Cygwin 1.5.x bug where link("a","b/.") creates file "b". */ + char *dir = strdup (file2); + struct stat st; + char *p; + if (!dir) + return -1; + /* We already know file2 does not end in slash. Strip off the + basename, then check that the dirname exists. */ + p = strrchr (dir, '/'); + if (p) + { + *p = '\0'; + if (stat (dir, &st) == -1) + { + int saved_errno = errno; + free (dir); + errno = saved_errno; + return -1; + } + } + free (dir); + } + return link (file1, file2); +} +#endif /* HAVE_LINK */ diff --git a/src/bin/coreutils/lib/mbsalign.c b/src/bin/coreutils/lib/mbsalign.c index bf90e05693..a0757471d7 100644 --- a/src/bin/coreutils/lib/mbsalign.c +++ b/src/bin/coreutils/lib/mbsalign.c @@ -219,7 +219,7 @@ mbsalign (const char *src, char *dest, size_t dest_size, dest = mbs_align_pad (dest, dest_end, start_spaces); dest = mempcpy(dest, str_to_print, MIN (n_used_bytes, dest_end - dest)); - dest = mbs_align_pad (dest, dest_end, end_spaces); + mbs_align_pad (dest, dest_end, end_spaces); } mbsalign_cleanup: @@ -229,8 +229,3 @@ mbsalign_cleanup: return ret; } -/* - * Local variables: - * indent-tabs-mode: nil - * End: - */ diff --git a/src/bin/coreutils/lib/memxfrm.c b/src/bin/coreutils/lib/memxfrm.c index 7376b3e970..a186ed87aa 100644 --- a/src/bin/coreutils/lib/memxfrm.c +++ b/src/bin/coreutils/lib/memxfrm.c @@ -40,7 +40,7 @@ size_t memxfrm (char *restrict dest, size_t destsize, - char *restrict src, size_t srcsize) + char *restrict src, size_t srcsize) { #if HAVE_STRXFRM @@ -59,33 +59,33 @@ memxfrm (char *restrict dest, size_t destsize, errno = 0; result += strxfrm (dest + di, src + si, destsize - di) + 1; if (errno != 0) - break; + break; if (result <= result0) - { - errno = ERANGE; - break; - } + { + 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; - } + { + /* 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; diff --git a/src/bin/coreutils/lib/mgetgroups.c b/src/bin/coreutils/lib/mgetgroups.c index 736dd87f38..0ebc2be151 100644 --- a/src/bin/coreutils/lib/mgetgroups.c +++ b/src/bin/coreutils/lib/mgetgroups.c @@ -76,45 +76,45 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups) g = realloc_groupbuf (NULL, max_n_groups); if (g == NULL) - return -1; + return -1; while (1) - { - GETGROUPS_T *h; - int last_n_groups = max_n_groups; + { + GETGROUPS_T *h; + int last_n_groups = max_n_groups; - /* getgrouplist updates max_n_groups to num required. */ - ng = getgrouplist (username, gid, g, &max_n_groups); + /* getgrouplist updates max_n_groups to num required. */ + ng = getgrouplist (username, gid, g, &max_n_groups); - /* Some systems (like Darwin) have a bug where they - never increase max_n_groups. */ - if (ng < 0 && last_n_groups == max_n_groups) - max_n_groups *= 2; + /* Some systems (like Darwin) have a bug where they + never increase max_n_groups. */ + if (ng < 0 && last_n_groups == max_n_groups) + max_n_groups *= 2; - if ((h = realloc_groupbuf (g, max_n_groups)) == NULL) - { - int saved_errno = errno; - free (g); - errno = saved_errno; - return -1; - } - g = h; + if ((h = realloc_groupbuf (g, max_n_groups)) == NULL) + { + int saved_errno = errno; + free (g); + errno = saved_errno; + return -1; + } + g = h; - if (0 <= ng) - { - *groups = g; - /* On success some systems just return 0 from getgrouplist, - so return max_n_groups rather than ng. */ - return max_n_groups; - } - } + if (0 <= ng) + { + *groups = g; + /* On success some systems just return 0 from getgrouplist, + so return max_n_groups rather than ng. */ + return max_n_groups; + } + } } /* else no username, so fall through and use getgroups. */ #endif max_n_groups = (username - ? getugroups (0, NULL, username, gid) - : getgroups (0, NULL)); + ? getugroups (0, NULL, username, gid) + : getgroups (0, NULL)); /* If we failed to count groups with NULL for a buffer, try again with a non-NULL one, just in case. */ @@ -126,8 +126,8 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups) return -1; ng = (username - ? getugroups (max_n_groups, g, username, gid) - : getgroups (max_n_groups, g)); + ? getugroups (max_n_groups, g, username, gid) + : getgroups (max_n_groups, g)); if (ng < 0) { diff --git a/src/bin/coreutils/lib/mkdirat.c b/src/bin/coreutils/lib/mkdirat.c index 6b6278b115..33ece9ccd6 100644 --- a/src/bin/coreutils/lib/mkdirat.c +++ b/src/bin/coreutils/lib/mkdirat.c @@ -1,5 +1,5 @@ /* fd-relative mkdir - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,13 +18,12 @@ #include -#include "openat.h" - #include #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "save-cwd.h" +#include "openat.h" #include "openat-priv.h" +#include "save-cwd.h" /* Solaris 10 has no function like this. Create a subdirectory, FILE, with mode MODE, in the directory @@ -35,8 +34,6 @@ #define AT_FUNC_NAME mkdirat #define AT_FUNC_F1 mkdir -#define AT_FUNC_F2 mkdir -#define AT_FUNC_USE_F1_COND 1 #define AT_FUNC_POST_FILE_PARAM_DECLS , mode_t mode #define AT_FUNC_POST_FILE_ARGS , mode #include "at-func.c" diff --git a/src/bin/coreutils/lib/mkstemp.c b/src/bin/coreutils/lib/mkstemp.c index 1b052f9b7f..ccf7a7beed 100644 --- a/src/bin/coreutils/lib/mkstemp.c +++ b/src/bin/coreutils/lib/mkstemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2001, 2005, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1998, 1999, 2001, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. This file is derived from the one in the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -40,5 +40,5 @@ int mkstemp (template) char *template; { - return __gen_tempname (template, __GT_FILE); + return __gen_tempname (template, 0, __GT_FILE); } diff --git a/src/bin/coreutils/lib/open.c b/src/bin/coreutils/lib/open.c index 326e6d15c0..08ecaff44b 100644 --- a/src/bin/coreutils/lib/open.c +++ b/src/bin/coreutils/lib/open.c @@ -38,6 +38,11 @@ orig_open (const char *filename, int flags, mode_t mode) #include #include #include +#include + +#ifndef REPLACE_OPEN_DIRECTORY +# define REPLACE_OPEN_DIRECTORY 0 +#endif int open (const char *filename, int flags, ...) @@ -98,6 +103,29 @@ open (const char *filename, int flags, ...) fd = orig_open (filename, flags, mode); +#if REPLACE_FCHDIR + /* Implementing fchdir and fdopendir requires the ability to open a + directory file descriptor. If open doesn't support that (as on + mingw), we use a dummy file that behaves the same as directories + on Linux (ie. always reports EOF on attempts to read()), and + override fstat() in fchdir.c to hide the fact that we have a + dummy. */ + if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES + && (mode & O_ACCMODE) == O_RDONLY) + { + struct stat statbuf; + if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) + { + /* Maximum recursion depth of 1. */ + fd = open ("/dev/null", flags, mode); + if (0 <= fd) + fd = _gl_register_fd (fd, filename); + } + else + errno = EACCES; + } +#endif + #if OPEN_TRAILING_SLASH_BUG /* If the filename ends in a slash and fd does not refer to a directory, then fail. @@ -128,9 +156,9 @@ open (const char *filename, int flags, ...) } #endif -#ifdef FCHDIR_REPLACEMENT - if (fd >= 0) - _gl_register_fd (fd, filename); +#if REPLACE_FCHDIR + if (!REPLACE_OPEN_DIRECTORY && 0 <= fd) + fd = _gl_register_fd (fd, filename); #endif return fd; diff --git a/src/bin/coreutils/lib/openat-priv.h b/src/bin/coreutils/lib/openat-priv.h index 9254f6bbad..2280416292 100644 --- a/src/bin/coreutils/lib/openat-priv.h +++ b/src/bin/coreutils/lib/openat-priv.h @@ -1,6 +1,6 @@ /* Internals for openat-like functions. - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,26 +23,6 @@ #define OPENAT_BUFFER_SIZE 512 char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file); -/* Some systems don't have ENOSYS. */ -#ifndef ENOSYS -# ifdef ENOTSUP -# define ENOSYS ENOTSUP -# else -/* Some systems don't have ENOTSUP either. */ -# define ENOSYS EINVAL -# endif -#endif - -/* Some systems don't have EOPNOTSUPP. */ -#ifndef EOPNOTSUPP -# ifdef ENOTSUP -# define EOPNOTSUPP ENOTSUP -# else -/* Some systems don't have ENOTSUP either. */ -# define EOPNOTSUPP EINVAL -# endif -#endif - /* Trying to access a BUILD_PROC_NAME file will fail on systems without /proc support, and even on systems *with* ProcFS support. Return nonzero if the failure may be legitimate, e.g., because /proc is not diff --git a/src/bin/coreutils/lib/openat-proc.c b/src/bin/coreutils/lib/openat-proc.c index e84dc454fb..76e1c6dd51 100644 --- a/src/bin/coreutils/lib/openat-proc.c +++ b/src/bin/coreutils/lib/openat-proc.c @@ -1,6 +1,6 @@ /* Create /proc/self/fd-related names for subfiles of open directories. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,7 +34,10 @@ #include "xalloc.h" /* The results of open() in this file are not used with fchdir, - therefore save some unnecessary work in fchdir.c. */ + and we do not leak fds to any single-threaded code that could use stdio, + therefore save some unnecessary work in fchdir.c. + FIXME - if the kernel ever adds support for multi-thread safety for + avoiding standard fds, then we should use open_safer. */ #undef open #undef close @@ -54,6 +57,13 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file) { static int proc_status = 0; + /* Make sure the caller gets ENOENT when appropriate. */ + if (!*file) + { + buf[0] = '\0'; + return buf; + } + if (! proc_status) { /* Set PROC_STATUS to a positive value if /proc/self/fd is diff --git a/src/bin/coreutils/lib/openat-safer.c b/src/bin/coreutils/lib/openat-safer.c new file mode 100644 index 0000000000..58d9a5e5f0 --- /dev/null +++ b/src/bin/coreutils/lib/openat-safer.c @@ -0,0 +1,46 @@ +/* Invoke openat, but avoid some glitches. + + Copyright (C) 2005, 2006, 2008-2009 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + 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 . */ + +/* Written by Paul Eggert for open, ported by Eric Blake for openat. */ + +#include + +#include "fcntl-safer.h" + +#include +#include +#include "unistd-safer.h" + +int +openat_safer (int fd, char const *file, int flags, ...) +{ + mode_t mode = 0; + + if (flags & O_CREAT) + { + va_list ap; + va_start (ap, flags); + + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (ap, PROMOTED_MODE_T); + + va_end (ap); + } + + return fd_safer (openat (fd, file, flags, mode)); +} diff --git a/src/bin/coreutils/lib/openat.c b/src/bin/coreutils/lib/openat.c index 77a85bffe8..e1471b8c0f 100644 --- a/src/bin/coreutils/lib/openat.c +++ b/src/bin/coreutils/lib/openat.c @@ -25,10 +25,16 @@ #include #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "fcntl--.h" #include "openat-priv.h" #include "save-cwd.h" +/* We can't use "fcntl--.h", so that openat_safer does not interfere. */ +#if GNULIB_FCNTL_SAFER +# include "fcntl-safer.h" +# undef open +# define open open_safer +#endif + /* Replacement for Solaris' openat function. First, try to simulate it via open ("/proc/self/fd/FD/FILE"). @@ -152,74 +158,6 @@ openat_needs_fchdir (void) return needs_fchdir; } -#if !HAVE_FDOPENDIR - -/* Replacement for Solaris' function by the same name. - - First, try to simulate it via opendir ("/proc/self/fd/FD"). Failing - that, simulate it by doing save_cwd/fchdir/opendir(".")/restore_cwd. - If either the save_cwd or the restore_cwd fails (relatively unlikely), - then give a diagnostic and exit nonzero. - Otherwise, this function works just like Solaris' fdopendir. - - W A R N I N G: - Unlike the other fd-related functions here, this one - effectively consumes its FD parameter. The caller should not - close or otherwise manipulate FD if this function returns successfully. */ -DIR * -fdopendir (int fd) -{ - struct saved_cwd saved_cwd; - int saved_errno; - DIR *dir; - - char buf[OPENAT_BUFFER_SIZE]; - char *proc_file = openat_proc_name (buf, fd, "."); - if (proc_file) - { - dir = opendir (proc_file); - saved_errno = errno; - } - else - { - dir = NULL; - saved_errno = EOPNOTSUPP; - } - - /* If the syscall fails with an expected errno value, resort to - save_cwd/restore_cwd. */ - if (! dir && EXPECTED_ERRNO (saved_errno)) - { - if (save_cwd (&saved_cwd) != 0) - openat_save_fail (errno); - - if (fchdir (fd) != 0) - { - dir = NULL; - saved_errno = errno; - } - else - { - dir = opendir ("."); - saved_errno = errno; - - if (restore_cwd (&saved_cwd) != 0) - openat_restore_fail (errno); - } - - free_cwd (&saved_cwd); - } - - if (dir) - close (fd); - if (proc_file != buf) - free (proc_file); - errno = saved_errno; - return dir; -} - -#endif - /* Replacement for Solaris' function by the same name. First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE"). @@ -231,7 +169,7 @@ fdopendir (int fd) #define AT_FUNC_NAME fstatat #define AT_FUNC_F1 lstat #define AT_FUNC_F2 stat -#define AT_FUNC_USE_F1_COND flag == AT_SYMLINK_NOFOLLOW +#define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW #define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat *st, int flag #define AT_FUNC_POST_FILE_ARGS , st #include "at-func.c" @@ -253,7 +191,7 @@ fdopendir (int fd) #define AT_FUNC_NAME unlinkat #define AT_FUNC_F1 rmdir #define AT_FUNC_F2 unlink -#define AT_FUNC_USE_F1_COND flag == AT_REMOVEDIR +#define AT_FUNC_USE_F1_COND AT_REMOVEDIR #define AT_FUNC_POST_FILE_PARAM_DECLS , int flag #define AT_FUNC_POST_FILE_ARGS /* empty */ #include "at-func.c" diff --git a/src/bin/coreutils/lib/openat.h b/src/bin/coreutils/lib/openat.h index 68c7df0b7d..433b9983df 100644 --- a/src/bin/coreutils/lib/openat.h +++ b/src/bin/coreutils/lib/openat.h @@ -1,5 +1,5 @@ /* provide a replacement openat function - Copyright (C) 2004, 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2004-2006, 2008-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,6 +16,9 @@ /* written by Jim Meyering */ +#ifndef _GL_HEADER_OPENAT +#define _GL_HEADER_OPENAT + #include #include @@ -34,46 +37,10 @@ # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) #endif -/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its - value exceeds INT_MAX, so its use as an int doesn't conform to the - C standard, and GCC and Sun C complain in some cases. If the bug - is present, undef AT_FDCWD here, so it can be redefined below. */ -#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 -# undef AT_FDCWD -#endif +#if !HAVE_OPENAT -/* Use the same bit pattern as Solaris 9, but with the proper - signedness. The bit pattern is important, in case this actually is - Solaris with the above workaround. */ -#ifndef AT_FDCWD -# define AT_FDCWD (-3041965) -#endif - -/* Use the same values as Solaris 9. This shouldn't matter, but - there's no real reason to differ. */ -#ifndef AT_SYMLINK_NOFOLLOW -# define AT_SYMLINK_NOFOLLOW 4096 -# define AT_REMOVEDIR 1 -#endif - -#ifdef __OPENAT_PREFIX - -# undef openat -# define __OPENAT_CONCAT(x, y) x ## y -# define __OPENAT_XCONCAT(x, y) __OPENAT_CONCAT (x, y) -# define __OPENAT_ID(y) __OPENAT_XCONCAT (__OPENAT_PREFIX, y) -# define openat __OPENAT_ID (openat) -int openat (int fd, char const *file, int flags, /* mode_t mode */ ...); int openat_permissive (int fd, char const *file, int flags, mode_t mode, int *cwd_errno); -# if ! HAVE_FDOPENDIR -# define fdopendir __OPENAT_ID (fdopendir) -# endif -DIR *fdopendir (int fd); -# define fstatat __OPENAT_ID (fstatat) -int fstatat (int fd, char const *file, struct stat *st, int flag); -# define unlinkat __OPENAT_ID (unlinkat) -int unlinkat (int fd, char const *file, int flag); bool openat_needs_fchdir (void); #else @@ -84,19 +51,8 @@ bool openat_needs_fchdir (void); #endif -#if HAVE_OPENAT && ! LSTAT_FOLLOWS_SLASHED_SYMLINK -int rpl_fstatat (int fd, char const *file, struct stat *st, int flag); -# if !COMPILING_FSTATAT -# undef fstatat -# define fstatat rpl_fstatat -# endif -#endif - -int mkdirat (int fd, char const *file, mode_t mode); void openat_restore_fail (int) ATTRIBUTE_NORETURN; void openat_save_fail (int) ATTRIBUTE_NORETURN; -int fchmodat (int fd, char const *file, mode_t mode, int flag); -int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag); /* Using these function names makes application code slightly more readable than it would be with @@ -124,3 +80,35 @@ lchmodat (int fd, char const *file, mode_t mode) { return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW); } + +static inline int +statat (int fd, char const *name, struct stat *st) +{ + return fstatat (fd, name, st, 0); +} + +static inline int +lstatat (int fd, char const *name, struct stat *st) +{ + return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW); +} + +#if GNULIB_FACCESSAT +/* For now, there are no wrappers named laccessat or leuidaccessat, + since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and + since access rights on symlinks are of limited utility. */ + +static inline int +accessat (int fd, char const *file, int mode) +{ + return faccessat (fd, file, mode, 0); +} + +static inline int +euidaccessat (int fd, char const *file, int mode) +{ + return faccessat (fd, file, mode, AT_EACCESS); +} +#endif + +#endif /* _GL_HEADER_OPENAT */ diff --git a/src/bin/coreutils/lib/opendir-safer.c b/src/bin/coreutils/lib/opendir-safer.c new file mode 100644 index 0000000000..8c399d0ca0 --- /dev/null +++ b/src/bin/coreutils/lib/opendir-safer.c @@ -0,0 +1,68 @@ +/* Invoke opendir, but avoid some glitches. + + Copyright (C) 2009 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake. */ + +#include + +#include "dirent-safer.h" + +#include +#include +#include "unistd-safer.h" + +/* Like opendir, but do not clobber stdin, stdout, or stderr. */ + +DIR * +opendir_safer (char const *name) +{ + DIR *dp = opendir (name); + + if (dp) + { + int fd = dirfd (dp); + + if (0 <= fd && fd <= STDERR_FILENO) + { + /* If fdopendir is native (as on Linux), then it is safe to + assume dirfd(fdopendir(n))==n. If we are using the + gnulib module fdopendir, then this guarantee is not met, + but fdopendir recursively calls opendir_safer up to 3 + times to at least get a safe fd. If fdopendir is not + present but dirfd is accurate (as on cygwin 1.5.x), then + we recurse up to 3 times ourselves. Finally, if dirfd + always fails (as on mingw), then we are already safe. */ + DIR *newdp; + int e; +#if HAVE_FDOPENDIR || GNULIB_FDOPENDIR + int f = dup_safer (fd); + newdp = fdopendir (f); + e = errno; + if (! newdp) + close (f); +#else /* !FDOPENDIR */ + newdp = opendir_safer (name); + e = errno; +#endif + closedir (dp); + errno = e; + dp = newdp; + } + } + + return dp; +} diff --git a/src/bin/coreutils/lib/progname.c b/src/bin/coreutils/lib/progname.c index 9854b5e7cc..19df10ad71 100644 --- a/src/bin/coreutils/lib/progname.c +++ b/src/bin/coreutils/lib/progname.c @@ -22,6 +22,7 @@ #undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */ #include "progname.h" +#include /* get program_invocation_name declaration */ #include @@ -60,4 +61,11 @@ set_program_name (const char *argv0) */ program_name = argv0; + + /* On glibc systems, when the gnulib module 'error' is not used, the error() + function comes from libc and uses the variable program_invocation_name, + not program_name. So set this variable as well. */ +#if HAVE_DECL_PROGRAM_INVOCATION_NAME + program_invocation_name = (char *) argv0; +#endif } diff --git a/src/bin/coreutils/lib/quotearg.c b/src/bin/coreutils/lib/quotearg.c index 339bf34942..8380e9de6c 100644 --- a/src/bin/coreutils/lib/quotearg.c +++ b/src/bin/coreutils/lib/quotearg.c @@ -54,6 +54,12 @@ struct quoting_options /* Quote the characters indicated by this bit vector even if the quoting style would not normally require them to be quoted. */ unsigned int quote_these_too[(UCHAR_MAX / INT_BITS) + 1]; + + /* The left quote for custom_quoting_style. */ + char const *left_quote; + + /* The right quote for custom_quoting_style. */ + char const *right_quote; }; /* Names of quoting styles. */ @@ -146,6 +152,19 @@ set_quoting_flags (struct quoting_options *o, int i) return r; } +void +set_custom_quoting (struct quoting_options *o, + char const *left_quote, char const *right_quote) +{ + if (!o) + o = &default_quoting_options; + o->style = custom_quoting_style; + if (!left_quote || !right_quote) + abort (); + o->left_quote = left_quote; + o->right_quote = right_quote; +} + /* Return quoting options for STYLE, with no extra quoting. */ static struct quoting_options quoting_options_from_style (enum quoting_style style) @@ -185,7 +204,9 @@ static size_t quotearg_buffer_restyled (char *buffer, size_t buffersize, char const *arg, size_t argsize, enum quoting_style quoting_style, int flags, - unsigned int const *quote_these_too) + unsigned int const *quote_these_too, + char const *left_quote, + char const *right_quote) { size_t i; size_t len = 0; @@ -225,34 +246,37 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case locale_quoting_style: case clocale_quoting_style: + case custom_quoting_style: { - /* TRANSLATORS: - Get translations for open and closing quotation marks. + if (quoting_style != custom_quoting_style) + { + /* TRANSLATORS: + Get translations for open and closing quotation marks. - The message catalog should translate "`" to a left - quotation mark suitable for the locale, and similarly for - "'". If the catalog has no translation, - locale_quoting_style quotes `like this', and - clocale_quoting_style quotes "like this". + The message catalog should translate "`" to a left + quotation mark suitable for the locale, and similarly for + "'". If the catalog has no translation, + locale_quoting_style quotes `like this', and + clocale_quoting_style quotes "like this". - For example, an American English Unicode locale should - translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and - should translate "'" to U+201D (RIGHT DOUBLE QUOTATION - MARK). A British English Unicode locale should instead - translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and - U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. + For example, an American English Unicode locale should + translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and + should translate "'" to U+201D (RIGHT DOUBLE QUOTATION + MARK). A British English Unicode locale should instead + translate these to U+2018 (LEFT SINGLE QUOTATION MARK) + and U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. - If you don't know what to put here, please see - - and use glyphs suitable for your language. */ - - char const *left = gettext_quote (N_("`"), quoting_style); - char const *right = gettext_quote (N_("'"), quoting_style); + If you don't know what to put here, please see + + and use glyphs suitable for your language. */ + left_quote = gettext_quote (N_("`"), quoting_style); + right_quote = gettext_quote (N_("'"), quoting_style); + } if (!elide_outer_quotes) - for (quote_string = left; *quote_string; quote_string++) + for (quote_string = left_quote; *quote_string; quote_string++) STORE (*quote_string); backslash_escapes = true; - quote_string = right; + quote_string = right_quote; quote_string_len = strlen (quote_string); } break; @@ -280,6 +304,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, { unsigned char c; unsigned char esc; + bool is_right_quote = false; if (backslash_escapes && quote_string_len @@ -288,7 +313,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, { if (elide_outer_quotes) goto force_outer_quoting_style; - STORE ('\\'); + is_right_quote = true; } c = arg[i]; @@ -300,12 +325,21 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, if (elide_outer_quotes) goto force_outer_quoting_style; STORE ('\\'); + /* If quote_string were to begin with digits, we'd need to + test for the end of the arg as well. However, it's + hard to imagine any locale that would use digits in + quotes, and set_custom_quoting is documented not to + accept them. */ if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9') { STORE ('0'); STORE ('0'); } c = '0'; + /* We don't have to worry that this last '0' will be + backslash-escaped because, again, quote_string should + not start with it and because quote_these_too is + documented as not accepting it. */ } else if (flags & QA_ELIDE_NULL_BYTES) continue; @@ -425,7 +459,15 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': /* These characters don't cause problems, no matter what the - quoting style is. They cannot start multibyte sequences. */ + quoting style is. They cannot start multibyte sequences. + A digit or a special letter would cause trouble if it + appeared at the beginning of quote_string because we'd then + escape by prepending a backslash. However, it's hard to + imagine any locale that would use digits or letters as + quotes, and set_custom_quoting is documented not to accept + them. Also, a digit or a special letter would cause + trouble if it appeared in quote_these_too, but that's also + documented as not accepting them. */ break; default: @@ -521,6 +563,11 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, STORE ('0' + ((c >> 3) & 7)); c = '0' + (c & 7); } + else if (is_right_quote) + { + STORE ('\\'); + is_right_quote = false; + } if (ilim <= i + 1) break; STORE (c); @@ -534,7 +581,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, if (! ((backslash_escapes || elide_outer_quotes) && quote_these_too - && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))) + && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))) + && !is_right_quote) goto store_c; store_escape: @@ -563,7 +611,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, sufficiently quotes the specified characters. */ return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, quoting_style, - flags & ~QA_ELIDE_OUTER_QUOTES, NULL); + flags & ~QA_ELIDE_OUTER_QUOTES, NULL, + left_quote, right_quote); } /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of @@ -583,7 +632,8 @@ quotearg_buffer (char *buffer, size_t buffersize, struct quoting_options const *p = o ? o : &default_quoting_options; int e = errno; size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize, - p->style, p->flags, p->quote_these_too); + p->style, p->flags, p->quote_these_too, + p->left_quote, p->right_quote); errno = e; return r; } @@ -611,10 +661,13 @@ quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size, /* Elide embedded null bytes if we can't return a size. */ int flags = p->flags | (size ? 0 : QA_ELIDE_NULL_BYTES); size_t bufsize = quotearg_buffer_restyled (0, 0, arg, argsize, p->style, - flags, p->quote_these_too) + 1; + flags, p->quote_these_too, + p->left_quote, + p->right_quote) + 1; char *buf = xcharalloc (bufsize); quotearg_buffer_restyled (buf, bufsize, arg, argsize, p->style, flags, - p->quote_these_too); + p->quote_these_too, + p->left_quote, p->right_quote); errno = e; if (size) *size = bufsize - 1; @@ -703,7 +756,9 @@ quotearg_n_options (int n, char const *arg, size_t argsize, int flags = options->flags | QA_ELIDE_NULL_BYTES; size_t qsize = quotearg_buffer_restyled (val, size, arg, argsize, options->style, flags, - options->quote_these_too); + options->quote_these_too, + options->left_quote, + options->right_quote); if (size <= qsize) { @@ -712,7 +767,9 @@ quotearg_n_options (int n, char const *arg, size_t argsize, free (val); sv[n].val = val = xcharalloc (size); quotearg_buffer_restyled (val, size, arg, argsize, options->style, - flags, options->quote_these_too); + flags, options->quote_these_too, + options->left_quote, + options->right_quote); } errno = e; @@ -797,3 +854,36 @@ quotearg_colon_mem (char const *arg, size_t argsize) { return quotearg_char_mem (arg, argsize, ':'); } + +char * +quotearg_n_custom (int n, char const *left_quote, + char const *right_quote, char const *arg) +{ + return quotearg_n_custom_mem (n, left_quote, right_quote, arg, + SIZE_MAX); +} + +char * +quotearg_n_custom_mem (int n, char const *left_quote, + char const *right_quote, + char const *arg, size_t argsize) +{ + struct quoting_options o = default_quoting_options; + set_custom_quoting (&o, left_quote, right_quote); + return quotearg_n_options (n, arg, argsize, &o); +} + +char * +quotearg_custom (char const *left_quote, char const *right_quote, + char const *arg) +{ + return quotearg_n_custom (0, left_quote, right_quote, arg); +} + +char * +quotearg_custom_mem (char const *left_quote, char const *right_quote, + char const *arg, size_t argsize) +{ + return quotearg_n_custom_mem (0, left_quote, right_quote, arg, + argsize); +} diff --git a/src/bin/coreutils/lib/quotearg.h b/src/bin/coreutils/lib/quotearg.h index 7700107001..63c47f13cc 100644 --- a/src/bin/coreutils/lib/quotearg.h +++ b/src/bin/coreutils/lib/quotearg.h @@ -100,7 +100,8 @@ enum quoting_style c_maybe_quoting_style, /* Like c_quoting_style except always omit the surrounding - double-quote characters (ls --quoting-style=escape). + double-quote characters and ignore QA_SPLIT_TRIGRAPHS + (ls --quoting-style=escape). quotearg_buffer: "simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b" @@ -136,7 +137,8 @@ enum quoting_style locale_quoting_style, /* Like c_quoting_style except use quotation marks appropriate for - the locale (ls --quoting-style=clocale). + the locale and ignore QA_SPLIT_TRIGRAPHS + (ls --quoting-style=clocale). LC_MESSAGES=C quotearg_buffer: @@ -157,7 +159,50 @@ enum quoting_style "\302\253simple\302\273", "\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273" */ - clocale_quoting_style + clocale_quoting_style, + + /* Like clocale_quoting_style except use the custom quotation marks + set by set_custom_quoting. If custom quotation marks are not + set, the behavior is undefined. + + left_quote = right_quote = "'" + quotearg_buffer: + "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'" + quotearg: + "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a:b'" + quotearg_colon: + "'simple'", "'\\0 \\t\\n\\'\"\\033??/\\\\'", "'a\\:b'" + + left_quote = "(" and right_quote = ")" + quotearg_buffer: + "(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a:b)" + quotearg: + "(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a:b)" + quotearg_colon: + "(simple)", "(\\0 \\t\\n'\"\\033??/\\\\)", "(a\\:b)" + + left_quote = ":" and right_quote = " " + quotearg_buffer: + ":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a:b " + quotearg: + ":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a:b " + quotearg_colon: + ":simple ", ":\\0\\ \\t\\n'\"\\033??/\\\\ ", ":a\\:b " + + left_quote = "\"'" and right_quote = "'\"" + Notice that this is treated as a single level of quotes or two + levels where the outer quote need not be escaped within the inner + quotes. For two levels where the outer quote must be escaped + within the inner quotes, you must use separate quotearg + invocations. + quotearg_buffer: + "\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a:b'\"" + quotearg: + "\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a:b'\"" + quotearg_colon: + "\"'simple'\"", "\"'\\0 \\t\\n\\'\"\\033??/\\\\'\"", "\"'a\\:b'\"" + */ + custom_quoting_style }; /* Flags for use in set_quoting_flags. */ @@ -210,7 +255,9 @@ void set_quoting_style (struct quoting_options *o, enum quoting_style s); set the value of the quoting options for character C to I. Return the old value. Currently, the only values defined for I are 0 (the default) and 1 (which means to quote the character even if - it would not otherwise be quoted). */ + it would not otherwise be quoted). C must never be a digit or a + letter that has special meaning after a backslash (for example, "\t" + for tab). */ int set_char_quoting (struct quoting_options *o, char c, int i); /* In O (or in the default if O is null), @@ -219,6 +266,19 @@ int set_char_quoting (struct quoting_options *o, char c, int i); behavior. Return the old value. */ int set_quoting_flags (struct quoting_options *o, int i); +/* In O (or in the default if O is null), + set the value of the quoting style to custom_quoting_style, + set the left quote to LEFT_QUOTE, and set the right quote to + RIGHT_QUOTE. Each of LEFT_QUOTE and RIGHT_QUOTE must be + null-terminated and can be the empty string. Because backslashes are + used for escaping, it does not make sense for RIGHT_QUOTE to contain + a backslash. RIGHT_QUOTE must not begin with a digit or a letter + that has special meaning after a backslash (for example, "\t" for + tab). */ +void set_custom_quoting (struct quoting_options *o, + char const *left_quote, + char const *right_quote); + /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of argument ARG (of size ARGSIZE), using O to control quoting. If O is null, use the default. @@ -287,7 +347,8 @@ char *quotearg_style (enum quoting_style s, char const *arg); char *quotearg_style_mem (enum quoting_style s, char const *arg, size_t argsize); -/* Like quotearg (ARG), except also quote any instances of CH. */ +/* Like quotearg (ARG), except also quote any instances of CH. + See set_char_quoting for a description of acceptable CH values. */ char *quotearg_char (char const *arg, char ch); /* Like quotearg_char (ARG, CH), except it can quote null bytes. */ @@ -299,6 +360,29 @@ char *quotearg_colon (char const *arg); /* Like quotearg_colon (ARG), except it can quote null bytes. */ char *quotearg_colon_mem (char const *arg, size_t argsize); +/* Like quotearg_n_style (N, S, ARG) but with S as custom_quoting_style + with left quote as LEFT_QUOTE and right quote as RIGHT_QUOTE. See + set_custom_quoting for a description of acceptable LEFT_QUOTE and + RIGHT_QUOTE values. */ +char *quotearg_n_custom (int n, char const *left_quote, + char const *right_quote, char const *arg); + +/* Like quotearg_n_custom (N, LEFT_QUOTE, RIGHT_QUOTE, ARG) except it + can quote null bytes. */ +char *quotearg_n_custom_mem (int n, char const *left_quote, + char const *right_quote, + char const *arg, size_t argsize); + +/* Equivalent to quotearg_n_custom (0, LEFT_QUOTE, RIGHT_QUOTE, ARG). */ +char *quotearg_custom (char const *left_quote, char const *right_quote, + char const *arg); + +/* Equivalent to quotearg_n_custom_mem (0, LEFT_QUOTE, RIGHT_QUOTE, ARG, + ARGSIZE). */ +char *quotearg_custom_mem (char const *left_quote, + char const *right_quote, + char const *arg, size_t argsize); + /* Free any dynamically allocated memory. */ void quotearg_free (void); diff --git a/src/bin/coreutils/lib/rand-isaac.c b/src/bin/coreutils/lib/rand-isaac.c index 5b6171478c..a1edf4785f 100644 --- a/src/bin/coreutils/lib/rand-isaac.c +++ b/src/bin/coreutils/lib/rand-isaac.c @@ -43,7 +43,7 @@ /* This index operation is more efficient on many processors */ #define ind(mm, x) \ (* (uint32_t *) ((char *) (mm) \ - + ((x) & (ISAAC_WORDS - 1) * sizeof (uint32_t)))) + + ((x) & (ISAAC_WORDS - 1) * sizeof (uint32_t)))) /* * The central step. This uses two temporaries, x and y. mm is the @@ -191,18 +191,18 @@ isaac_init (struct isaac_state *s, uint32_t const *seed, size_t seedsize) isaac_mix (s, 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); - } + { + seed += ISAAC_WORDS; + for (i = 0; i < ISAAC_WORDS; i++) + s->mm[i] += seed[i]; + isaac_mix (s, s->mm); + } } else { /* The no seed case (as in reference ISAAC code) */ for (i = 0; i < ISAAC_WORDS; i++) - s->mm[i] = 0; + s->mm[i] = 0; } /* Final pass */ @@ -252,7 +252,7 @@ isaac_seed_data (struct isaac_state *s, void const *buffer, size_t size) { p = (unsigned char *) s->mm + s->c; for (i = 0; i < avail; i++) - p[i] ^= buf[i]; + p[i] ^= buf[i]; buf += avail; size -= avail; isaac_mix (s, s->mm); diff --git a/src/bin/coreutils/lib/randint.c b/src/bin/coreutils/lib/randint.c index 0edda0aa0e..cfa6e232bb 100644 --- a/src/bin/coreutils/lib/randint.c +++ b/src/bin/coreutils/lib/randint.c @@ -128,75 +128,75 @@ randint_genmax (struct randint_source *s, randint genmax) for (;;) { if (randmax < genmax) - { - /* Calculate how many input bytes will be needed, and read - the bytes. */ + { + /* Calculate how many input bytes will be needed, and read + the bytes. */ - size_t i = 0; - randint rmax = randmax; - unsigned char buf[sizeof randnum]; + size_t i = 0; + randint rmax = randmax; + unsigned char buf[sizeof randnum]; - do - { - rmax = shift_left (rmax) + UCHAR_MAX; - i++; - } - while (rmax < genmax); + do + { + rmax = shift_left (rmax) + UCHAR_MAX; + i++; + } + while (rmax < genmax); - randread (source, buf, i); + randread (source, buf, i); - /* Increase RANDMAX by appending random bytes to RANDNUM and - UCHAR_MAX to RANDMAX until RANDMAX is no less than - GENMAX. This may lose up to CHAR_BIT bits of information - if shift_right (RANDINT_MAX) < GENMAX, but it is not - worth the programming hassle of saving these bits since - GENMAX is rarely that large in practice. */ + /* Increase RANDMAX by appending random bytes to RANDNUM and + UCHAR_MAX to RANDMAX until RANDMAX is no less than + GENMAX. This may lose up to CHAR_BIT bits of information + if shift_right (RANDINT_MAX) < GENMAX, but it is not + worth the programming hassle of saving these bits since + GENMAX is rarely that large in practice. */ - i = 0; + i = 0; - do - { - randnum = shift_left (randnum) + buf[i]; - randmax = shift_left (randmax) + UCHAR_MAX; - i++; - } - while (randmax < genmax); - } + do + { + randnum = shift_left (randnum) + buf[i]; + randmax = shift_left (randmax) + UCHAR_MAX; + i++; + } + while (randmax < genmax); + } if (randmax == genmax) - { - s->randnum = s->randmax = 0; - return randnum; - } + { + s->randnum = s->randmax = 0; + return randnum; + } else - { - /* GENMAX < RANDMAX, so attempt to generate a random number - by taking RANDNUM modulo GENMAX+1. This will choose - fairly so long as RANDNUM falls within an integral - multiple of GENMAX+1; otherwise, LAST_USABLE_CHOICE < RANDNUM, - so discard this attempt and try again. + { + /* GENMAX < RANDMAX, so attempt to generate a random number + by taking RANDNUM modulo GENMAX+1. This will choose + fairly so long as RANDNUM falls within an integral + multiple of GENMAX+1; otherwise, LAST_USABLE_CHOICE < RANDNUM, + so discard this attempt and try again. - Since GENMAX cannot be RANDINT_MAX, CHOICES cannot be - zero and there is no need to worry about dividing by - zero. */ + Since GENMAX cannot be RANDINT_MAX, CHOICES cannot be + zero and there is no need to worry about dividing by + zero. */ - randint excess_choices = randmax - genmax; - randint unusable_choices = excess_choices % choices; - randint last_usable_choice = randmax - unusable_choices; - randint reduced_randnum = randnum % choices; + randint excess_choices = randmax - genmax; + randint unusable_choices = excess_choices % choices; + randint last_usable_choice = randmax - unusable_choices; + randint reduced_randnum = randnum % choices; - if (randnum <= last_usable_choice) - { - s->randnum = randnum / choices; - s->randmax = excess_choices / choices; - return reduced_randnum; - } + if (randnum <= last_usable_choice) + { + s->randnum = randnum / choices; + s->randmax = excess_choices / choices; + return reduced_randnum; + } - /* Retry, but retain the randomness from the fact that RANDNUM fell - into the range LAST_USABLE_CHOICE+1 .. RANDMAX. */ - randnum = reduced_randnum; - randmax = unusable_choices - 1; - } + /* Retry, but retain the randomness from the fact that RANDNUM fell + into the range LAST_USABLE_CHOICE+1 .. RANDMAX. */ + randnum = reduced_randnum; + randmax = unusable_choices - 1; + } } } diff --git a/src/bin/coreutils/lib/randperm.c b/src/bin/coreutils/lib/randperm.c index 507e214604..a03c5b87f6 100644 --- a/src/bin/coreutils/lib/randperm.c +++ b/src/bin/coreutils/lib/randperm.c @@ -79,21 +79,21 @@ randperm_new (struct randint_source *r, size_t h, size_t n) default: { - size_t i; + size_t i; - v = xnmalloc (n, sizeof *v); - for (i = 0; i < n; i++) - v[i] = i; + v = xnmalloc (n, sizeof *v); + for (i = 0; i < n; i++) + v[i] = i; - for (i = 0; i < h; i++) - { - size_t j = i + randint_choose (r, n - i); - size_t t = v[i]; - v[i] = v[j]; - v[j] = t; - } + for (i = 0; i < h; i++) + { + size_t j = i + randint_choose (r, n - i); + size_t t = v[i]; + v[i] = v[j]; + v[j] = t; + } - v = xnrealloc (v, h, sizeof *v); + v = xnrealloc (v, h, sizeof *v); } break; } diff --git a/src/bin/coreutils/lib/randread.c b/src/bin/coreutils/lib/randread.c index 48ce92e9ab..72475017e1 100644 --- a/src/bin/coreutils/lib/randread.c +++ b/src/bin/coreutils/lib/randread.c @@ -100,8 +100,8 @@ struct randread_source /* Up to a buffer's worth of pseudorandom data. */ union { - uint32_t w[ISAAC_WORDS]; - unsigned char b[ISAAC_BYTES]; + uint32_t w[ISAAC_WORDS]; + unsigned char b[ISAAC_BYTES]; } data; } isaac; } buf; @@ -115,8 +115,8 @@ randread_error (void const *file_name) { if (file_name) error (exit_failure, errno, - _(errno == 0 ? "%s: end of file" : "%s: read error"), - quotearg_colon (file_name)); + _(errno == 0 ? "%s: end of file" : "%s: read error"), + quotearg_colon (file_name)); abort (); } @@ -155,18 +155,18 @@ randread_new (char const *name, size_t bytes_bound) struct randread_source *s; if (name) - if (! (source = fopen_safer (name, "rb"))) - return NULL; + if (! (source = fopen_safer (name, "rb"))) + return NULL; s = simple_new (source, name); if (source) - setvbuf (source, s->buf.c, _IOFBF, MIN (sizeof s->buf.c, bytes_bound)); + setvbuf (source, s->buf.c, _IOFBF, MIN (sizeof s->buf.c, bytes_bound)); else - { - s->buf.isaac.buffered = 0; - isaac_seed (&s->buf.isaac.state); - } + { + s->buf.isaac.buffered = 0; + isaac_seed (&s->buf.isaac.state); + } return s; } @@ -206,7 +206,7 @@ readsource (struct randread_source *s, unsigned char *p, size_t size) p += inbytes; size -= inbytes; if (size == 0) - break; + break; errno = (ferror (s->source) ? fread_errno : 0); s->handler (s->handler_arg); } @@ -224,34 +224,34 @@ readisaac (struct isaac *isaac, unsigned char *p, size_t size) for (;;) { if (size <= inbytes) - { - memcpy (p, isaac->data.b + ISAAC_BYTES - inbytes, size); - isaac->buffered = inbytes - size; - return; - } + { + memcpy (p, isaac->data.b + ISAAC_BYTES - inbytes, size); + isaac->buffered = inbytes - size; + return; + } memcpy (p, isaac->data.b + ISAAC_BYTES - inbytes, inbytes); p += inbytes; size -= inbytes; /* If P is aligned, write to *P directly to avoid the overhead - of copying from the buffer. */ + of copying from the buffer. */ if (ALIGNED_POINTER (p, uint32_t)) - { - uint32_t *wp = (uint32_t *) p; - while (ISAAC_BYTES <= size) - { - isaac_refill (&isaac->state, wp); - wp += ISAAC_WORDS; - size -= ISAAC_BYTES; - if (size == 0) - { - isaac->buffered = 0; - return; - } - } - p = (unsigned char *) wp; - } + { + uint32_t *wp = (uint32_t *) p; + while (ISAAC_BYTES <= size) + { + isaac_refill (&isaac->state, wp); + wp += ISAAC_WORDS; + size -= ISAAC_BYTES; + if (size == 0) + { + isaac->buffered = 0; + return; + } + } + p = (unsigned char *) wp; + } isaac_refill (&isaac->state, isaac->data.w); inbytes = ISAAC_BYTES; diff --git a/src/bin/coreutils/lib/rename.c b/src/bin/coreutils/lib/rename.c index b27fd9100d..5cd4dee9b0 100644 --- a/src/bin/coreutils/lib/rename.c +++ b/src/bin/coreutils/lib/rename.c @@ -3,7 +3,8 @@ a trailing slash. On mingw, rename fails when the destination exists. - Copyright (C) 2001, 2002, 2003, 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2005, 2006, 2009 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,16 +22,20 @@ /* written by Volker Borchert */ #include + +#include + #undef rename -#if RENAME_DEST_EXISTS_BUG -/* This replacement must come first, otherwise when cross - * compiling to Windows we will guess that it has the trailing - * slash bug and entirely miss this one. */ -#include +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +/* The mingw rename has problems with trailing slashes; it also + requires use of native Windows calls to allow atomic renames over + existing files. */ -#define WIN32_LEAN_AND_MEAN -#include +# include + +# define WIN32_LEAN_AND_MEAN +# include /* Rename the file SRC to DST. This replacement is necessary on Windows, on which the system rename function will not replace @@ -114,10 +119,10 @@ rpl_rename (char const *src, char const *dst) errno = EPERM; /* ? */ break; -#ifndef ERROR_FILE_TOO_LARGE +# ifndef ERROR_FILE_TOO_LARGE /* This value is documented but not defined in all versions of windows.h. */ -#define ERROR_FILE_TOO_LARGE 223 -#endif +# define ERROR_FILE_TOO_LARGE 223 +# endif case ERROR_FILE_TOO_LARGE: errno = EFBIG; break; @@ -129,13 +134,18 @@ rpl_rename (char const *src, char const *dst) return -1; } -#elif RENAME_TRAILING_SLASH_BUG -#include -#include -#include -#include "dirname.h" -#include "xalloc.h" +#else /* ! W32 platform */ + +# if RENAME_DEST_EXISTS_BUG +# error Please report your platform and this message to bug-gnulib@gnu.org. +# elif RENAME_TRAILING_SLASH_BUG +# include +# include +# include + +# include "dirname.h" +# include "xalloc.h" /* Rename the file SRC to DST, removing any trailing slashes from SRC. Needed for SunOS 4.1.1_U1. */ @@ -162,4 +172,5 @@ rpl_rename (char const *src, char const *dst) return ret_val; } -#endif /* RENAME_TRAILING_SLASH_BUG */ +# endif /* RENAME_TRAILING_SLASH_BUG */ +#endif /* ! W32 platform */ diff --git a/src/bin/coreutils/lib/root-dev-ino.h b/src/bin/coreutils/lib/root-dev-ino.h index 2832096c1b..bec27f0aeb 100644 --- a/src/bin/coreutils/lib/root-dev-ino.h +++ b/src/bin/coreutils/lib/root-dev-ino.h @@ -34,12 +34,12 @@ get_root_dev_ino (struct dev_ino *root_d_i); do \ { \ if (STREQ (Dirname, "/")) \ - error (0, 0, _("it is dangerous to operate recursively on %s"), \ - quote (Dirname)); \ + error (0, 0, _("it is dangerous to operate recursively on %s"), \ + quote (Dirname)); \ else \ - error (0, 0, \ - _("it is dangerous to operate recursively on %s (same as %s)"), \ - quote_n (0, Dirname), quote_n (1, "/")); \ + error (0, 0, \ + _("it is dangerous to operate recursively on %s (same as %s)"), \ + quote_n (0, Dirname), quote_n (1, "/")); \ error (0, 0, _("use --no-preserve-root to override this failsafe")); \ } \ while (0) diff --git a/src/bin/coreutils/lib/savedir.c b/src/bin/coreutils/lib/savedir.c index b837414335..5e69d386f3 100644 --- a/src/bin/coreutils/lib/savedir.c +++ b/src/bin/coreutils/lib/savedir.c @@ -1,7 +1,7 @@ /* savedir.c -- save the list of files in a directory in a string Copyright (C) 1990, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, - 2006 Free Software Foundation, Inc. + 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ #include -#include +#include "dirent--.h" #ifndef _D_EXACT_NAMLEN # define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) #endif @@ -35,18 +35,12 @@ #include #include -#include "openat.h" #include "xalloc.h" #ifndef NAME_SIZE_DEFAULT # define NAME_SIZE_DEFAULT 512 #endif -/* The results of opendir() in this file are not used with dirfd and fchdir, - therefore save some unnecessary work in fchdir.c. */ -#undef opendir -#undef closedir - /* Return a freshly allocated string containing the file names in directory DIRP, separated by '\0' characters; the end is marked by two '\0' characters in a row. diff --git a/src/bin/coreutils/lib/savewd.c b/src/bin/coreutils/lib/savewd.c index c4893ef6f1..f593f94677 100644 --- a/src/bin/coreutils/lib/savewd.c +++ b/src/bin/coreutils/lib/savewd.c @@ -1,6 +1,6 @@ /* Save and restore the working directory, possibly using a child process. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,10 +34,6 @@ #include "dirname.h" #include "fcntl-safer.h" -#ifndef ESTALE -# define ESTALE -1 -#endif - /* Save the working directory into *WD, if it hasn't been saved already. Return true if a child has been forked to do the real work. */ diff --git a/src/bin/coreutils/lib/select.c b/src/bin/coreutils/lib/select.c index 8f30f9d231..41bb35ba08 100644 --- a/src/bin/coreutils/lib/select.c +++ b/src/bin/coreutils/lib/select.c @@ -24,6 +24,7 @@ #include #include +#include #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* Native Win32. */ @@ -79,6 +80,23 @@ typedef DWORD (WINAPI *PNtQueryInformationFile) #define PIPE_BUF 512 #endif +#define IsConsoleHandle(h) (((long) (h) & 3) == 3) + +static BOOL +IsSocketHandle(HANDLE h) +{ + WSANETWORKEVENTS ev; + + if (IsConsoleHandle (h)) + return FALSE; + + /* Under Wine, it seems that getsockopt returns 0 for pipes too. + WSAEnumNetworkEvents instead distinguishes the two correctly. */ + ev.lNetworkEvents = 0xDEADBEEF; + WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev); + return ev.lNetworkEvents != 0xDEADBEEF; +} + /* Compute output fd_sets for libc descriptor FD (whose Win32 handle is H). */ static int @@ -141,19 +159,37 @@ win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits, break; case FILE_TYPE_CHAR: - ret = WaitForSingleObject (h, 0); write = TRUE; + if (!(rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) + break; + + ret = WaitForSingleObject (h, 0); if (ret == WAIT_OBJECT_0) { + if (!IsConsoleHandle (h)) + { + read = TRUE; + break; + } + nbuffer = avail = 0; bRet = GetNumberOfConsoleInputEvents (h, &nbuffer); - if (!bRet || nbuffer == 0) - except = TRUE; + + /* Screen buffers handles are filtered earlier. */ + assert (bRet); + if (nbuffer == 0) + { + except = TRUE; + break; + } irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD)); bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail); if (!bRet || avail == 0) - except = TRUE; + { + except = TRUE; + break; + } for (i = 0; i < avail; i++) if (irbuffer[i].EventType == KEY_EVENT) @@ -202,7 +238,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, fd_set handle_rfds, handle_wfds, handle_xfds; struct bitset rbits, wbits, xbits; unsigned char anyfds_in[FD_SETSIZE / CHAR_BIT]; - DWORD ret, wait_timeout, nhandles, nsock; + DWORD ret, wait_timeout, nhandles, nsock, nbuffer; MSG msg; int i, fd, rc; @@ -230,7 +266,10 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, nhandles = 1; nsock = 0; - /* Copy descriptors to bitsets. */ + /* Copy descriptors to bitsets. At the same time, eliminate + bits in the "wrong" direction for console input buffers + and screen buffers, because screen buffers are waitable + and they will block until a character is available. */ memset (&rbits, 0, sizeof (rbits)); memset (&wbits, 0, sizeof (wbits)); memset (&xbits, 0, sizeof (xbits)); @@ -239,6 +278,11 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, for (i = 0; i < rfds->fd_count; i++) { fd = rfds->fd_array[i]; + h = (HANDLE) _get_osfhandle (fd); + if (IsConsoleHandle (h) + && !GetNumberOfConsoleInputEvents (h, &nbuffer)) + continue; + rbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); } @@ -249,6 +293,11 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, for (i = 0; i < wfds->fd_count; i++) { fd = wfds->fd_array[i]; + h = (HANDLE) _get_osfhandle (fd); + if (IsConsoleHandle (h) + && GetNumberOfConsoleInputEvents (h, &nbuffer)) + continue; + wbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); } @@ -288,11 +337,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, return -1; } - /* Under Wine, it seems that getsockopt returns 0 for pipes too. - WSAEnumNetworkEvents instead distinguishes the two correctly. */ - ev.lNetworkEvents = 0xDEADBEEF; - WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev); - if (ev.lNetworkEvents != 0xDEADBEEF) + if (IsSocketHandle (h)) { int requested = FD_CLOSE; diff --git a/src/bin/coreutils/lib/selinux-at.c b/src/bin/coreutils/lib/selinux-at.c index 18e6b0f40e..65f938b412 100644 --- a/src/bin/coreutils/lib/selinux-at.c +++ b/src/bin/coreutils/lib/selinux-at.c @@ -33,56 +33,40 @@ #define AT_FUNC_NAME getfileconat #define AT_FUNC_F1 getfilecon -#define AT_FUNC_F2 getfilecon -#define AT_FUNC_USE_F1_COND 1 #define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t *con #define AT_FUNC_POST_FILE_ARGS , con #include "at-func.c" #undef AT_FUNC_NAME #undef AT_FUNC_F1 -#undef AT_FUNC_F2 -#undef AT_FUNC_USE_F1_COND #undef AT_FUNC_POST_FILE_PARAM_DECLS #undef AT_FUNC_POST_FILE_ARGS #define AT_FUNC_NAME lgetfileconat #define AT_FUNC_F1 lgetfilecon -#define AT_FUNC_F2 lgetfilecon -#define AT_FUNC_USE_F1_COND 1 #define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t *con #define AT_FUNC_POST_FILE_ARGS , con #include "at-func.c" #undef AT_FUNC_NAME #undef AT_FUNC_F1 -#undef AT_FUNC_F2 -#undef AT_FUNC_USE_F1_COND #undef AT_FUNC_POST_FILE_PARAM_DECLS #undef AT_FUNC_POST_FILE_ARGS #define AT_FUNC_NAME setfileconat #define AT_FUNC_F1 setfilecon -#define AT_FUNC_F2 setfilecon -#define AT_FUNC_USE_F1_COND 1 #define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t con #define AT_FUNC_POST_FILE_ARGS , con #include "at-func.c" #undef AT_FUNC_NAME #undef AT_FUNC_F1 -#undef AT_FUNC_F2 -#undef AT_FUNC_USE_F1_COND #undef AT_FUNC_POST_FILE_PARAM_DECLS #undef AT_FUNC_POST_FILE_ARGS #define AT_FUNC_NAME lsetfileconat #define AT_FUNC_F1 lsetfilecon -#define AT_FUNC_F2 lsetfilecon -#define AT_FUNC_USE_F1_COND 1 #define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t con #define AT_FUNC_POST_FILE_ARGS , con #include "at-func.c" #undef AT_FUNC_NAME #undef AT_FUNC_F1 -#undef AT_FUNC_F2 -#undef AT_FUNC_USE_F1_COND #undef AT_FUNC_POST_FILE_PARAM_DECLS #undef AT_FUNC_POST_FILE_ARGS diff --git a/src/bin/coreutils/lib/selinux-at.h b/src/bin/coreutils/lib/selinux-at.h index 9716fe9e5e..1d84c197ac 100644 --- a/src/bin/coreutils/lib/selinux-at.h +++ b/src/bin/coreutils/lib/selinux-at.h @@ -20,33 +20,33 @@ /* These are the dir-fd-relative variants of the functions without the "at" suffix. For example, getfileconat (AT_FDCWD, file, &c) is usually equivalent to getfilecon (file, &c). The emulation is accomplished - by first attempting getfilecon ("/proc/self/fd/DIRFD/FILE", &c). + by first attempting getfilecon ("/proc/self/fd/DIR_FD/FILE", &c). Failing that, simulate it via save_cwd/fchdir/getfilecon/restore_cwd. If either the save_cwd or the restore_cwd fails (relatively unlikely), then give a diagnostic and exit nonzero. */ /* dir-fd-relative getfilecon. Set *CON to the SELinux security context - of the file specified by DIRFD and FILE and return the length of *CON. - DIRFD and FILE are interpreted as for fstatat[*]. A non-NULL *CON + of the file specified by DIR_FD and FILE and return the length of *CON. + DIR_FD and FILE are interpreted as for fstatat[*]. A non-NULL *CON must be freed with freecon. Upon error, set *CON to NULL, set errno and return -1. [*] with flags=0 here, with flags=AT_SYMLINK_NOFOLLOW for lgetfileconat */ -int getfileconat (int dirfd, char const *file, security_context_t *con); +int getfileconat (int dir_fd, char const *file, security_context_t *con); /* dir-fd-relative lgetfilecon. This function is just like getfileconat, - except when DIRFD and FILE specify a symlink: lgetfileconat operates on + except when DIR_FD and FILE specify a symlink: lgetfileconat operates on the symlink, while getfileconat operates on the referent of the symlink. */ -int lgetfileconat (int dirfd, char const *file, security_context_t *con); +int lgetfileconat (int dir_fd, char const *file, security_context_t *con); /* dir-fd-relative setfilecon. Set the SELinux security context of - the file specified by DIRFD and FILE to CON. DIRFD and FILE are + the file specified by DIR_FD and FILE to CON. DIR_FD and FILE are interpreted as for fstatat[*]. Upon success, return 0. Otherwise, return -1 and set errno. */ -int setfileconat (int dirfd, char const *file, security_context_t con); +int setfileconat (int dir_fd, char const *file, security_context_t con); /* dir-fd-relative lsetfilecon. This function is just like setfileconat, except that rather than dereferencing a symlink, this function affects it. */ /* dir-fd-relative lsetfilecon. This function is just like setfileconat, - except when DIRFD and FILE specify a symlink: lsetfileconat operates on + except when DIR_FD and FILE specify a symlink: lsetfileconat operates on the symlink, while setfileconat operates on the referent of the symlink. */ -int lsetfileconat (int dirfd, char const *file, security_context_t con); +int lsetfileconat (int dir_fd, char const *file, security_context_t con); diff --git a/src/bin/coreutils/lib/set-mode-acl.c b/src/bin/coreutils/lib/set-mode-acl.c index a24b9f348c..34076db202 100644 --- a/src/bin/coreutils/lib/set-mode-acl.c +++ b/src/bin/coreutils/lib/set-mode-acl.c @@ -234,7 +234,7 @@ qset_acl (char const *name, int desc, mode_t mode) acl_free (aclp); if (ret < 0) { - if (saved_errno == ENOSYS) + if (saved_errno == ENOSYS || saved_errno == EOPNOTSUPP) return chmod_or_fchmod (name, desc, mode); errno = saved_errno; return -1; diff --git a/src/bin/coreutils/lib/settime.c b/src/bin/coreutils/lib/settime.c index f565492681..366a298d04 100644 --- a/src/bin/coreutils/lib/settime.c +++ b/src/bin/coreutils/lib/settime.c @@ -1,6 +1,6 @@ /* settime -- set the system clock - Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software + Copyright (C) 2002, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -27,16 +27,6 @@ #include -/* Some systems don't have ENOSYS. */ -#ifndef ENOSYS -# ifdef ENOTSUP -# define ENOSYS ENOTSUP -# else -/* Some systems don't have ENOTSUP either. */ -# define ENOSYS EINVAL -# endif -#endif - /* Set the system time. */ int diff --git a/src/bin/coreutils/lib/stdio--.h b/src/bin/coreutils/lib/stdio--.h index 39fca29200..ed90dda5a5 100644 --- a/src/bin/coreutils/lib/stdio--.h +++ b/src/bin/coreutils/lib/stdio--.h @@ -1,6 +1,6 @@ /* Like stdio.h, but redefine some names to avoid glitches. - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,8 +20,17 @@ #include #include "stdio-safer.h" -#undef fopen -#define fopen fopen_safer +#if GNULIB_FOPEN_SAFER +# undef fopen +# define fopen fopen_safer +#endif -#undef tmpfile -#define tmpfile tmpfile_safer +#if GNULIB_TMPFILE_SAFER +# undef tmpfile +# define tmpfile tmpfile_safer +#endif + +#if GNULIB_POPEN_SAFER +# undef popen +# define popen popen_safer +#endif diff --git a/src/bin/coreutils/lib/stdio-safer.h b/src/bin/coreutils/lib/stdio-safer.h index c881d5a6a6..dde22f1045 100644 --- a/src/bin/coreutils/lib/stdio-safer.h +++ b/src/bin/coreutils/lib/stdio-safer.h @@ -1,6 +1,6 @@ /* Invoke stdio functions, but avoid some glitches. - Copyright (C) 2001, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,4 +20,5 @@ #include FILE *fopen_safer (char const *, char const *); +FILE *popen_safer (char const *, char const *); FILE *tmpfile_safer (void); diff --git a/src/bin/coreutils/lib/stdio.in.h b/src/bin/coreutils/lib/stdio.in.h index 045b126554..14067da9db 100644 --- a/src/bin/coreutils/lib/stdio.in.h +++ b/src/bin/coreutils/lib/stdio.in.h @@ -71,6 +71,70 @@ extern "C" { #endif +#if @GNULIB_DPRINTF@ +# if @REPLACE_DPRINTF@ +# define dprintf rpl_dprintf +# endif +# if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@ +extern int dprintf (int fd, const char *format, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef dprintf +# define dprintf(d,f,a) \ + (GL_LINK_WARNING ("dprintf is unportable - " \ + "use gnulib module dprintf for portability"), \ + dprintf (d, f, a)) +#endif + +#if @GNULIB_FCLOSE@ +# if @REPLACE_FCLOSE@ +# define fclose rpl_fclose + /* Close STREAM and its underlying file descriptor. */ +extern int fclose (FILE *stream); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fclose +# define fclose(f) \ + (GL_LINK_WARNING ("fclose is not always POSIX compliant - " \ + "use gnulib module fclose for portable " \ + "POSIX compliance"), \ + fclose (f)) +#endif + +#if @GNULIB_FFLUSH@ +# if @REPLACE_FFLUSH@ +# define fflush rpl_fflush + /* Flush all pending data on STREAM according to POSIX rules. Both + output and seekable input streams are supported. + Note! LOSS OF DATA can occur if fflush is applied on an input stream + that is _not_seekable_ or on an update stream that is _not_seekable_ + and in which the most recent operation was input. Seekability can + be tested with lseek(fileno(fp),0,SEEK_CUR). */ + extern int fflush (FILE *gl_stream); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fflush +# define fflush(f) \ + (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \ + "use gnulib module fflush for portable " \ + "POSIX compliance"), \ + fflush (f)) +#endif + +#if @GNULIB_FOPEN@ +# if @REPLACE_FOPEN@ +# undef fopen +# define fopen rpl_fopen +extern FILE * fopen (const char *filename, const char *mode); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fopen +# define fopen(f,m) \ + (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \ + "use gnulib module fopen for portability"), \ + fopen (f, m)) +#endif #if @GNULIB_FPRINTF_POSIX@ # if @REPLACE_FPRINTF@ @@ -91,215 +155,37 @@ extern int fprintf (FILE *fp, const char *format, ...) fprintf) #endif -#if @GNULIB_VFPRINTF_POSIX@ -# if @REPLACE_VFPRINTF@ -# define vfprintf rpl_vfprintf -extern int vfprintf (FILE *fp, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); +#if @GNULIB_FPURGE@ +# if @REPLACE_FPURGE@ +# define fpurge rpl_fpurge # endif -#elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ -# define vfprintf rpl_vfprintf -extern int vfprintf (FILE *fp, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); -#elif defined GNULIB_POSIXCHECK -# undef vfprintf -# define vfprintf(s,f,a) \ - (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \ - "use gnulib module vfprintf-posix for portable " \ - "POSIX compliance"), \ - vfprintf (s, f, a)) -#endif - -#if @GNULIB_PRINTF_POSIX@ -# if @REPLACE_PRINTF@ -/* Don't break __attribute__((format(printf,M,N))). */ -# define printf __printf__ -extern int printf (const char *format, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); -# endif -#elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ -/* Don't break __attribute__((format(printf,M,N))). */ -# define printf __printf__ -extern int printf (const char *format, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); -#elif defined GNULIB_POSIXCHECK -# undef printf -# define printf \ - (GL_LINK_WARNING ("printf is not always POSIX compliant - " \ - "use gnulib module printf-posix for portable " \ - "POSIX compliance"), \ - printf) -/* Don't break __attribute__((format(printf,M,N))). */ -# define format(kind,m,n) format (__##kind##__, m, n) -# define __format__(kind,m,n) __format__ (__##kind##__, m, n) -# define ____printf____ __printf__ -# define ____scanf____ __scanf__ -# define ____strftime____ __strftime__ -# define ____strfmon____ __strfmon__ -#endif - -#if @GNULIB_VPRINTF_POSIX@ -# if @REPLACE_VPRINTF@ -# define vprintf rpl_vprintf -extern int vprintf (const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 1, 0))); -# endif -#elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ -# define vprintf rpl_vprintf -extern int vprintf (const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 1, 0))); -#elif defined GNULIB_POSIXCHECK -# undef vprintf -# define vprintf(f,a) \ - (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \ - "use gnulib module vprintf-posix for portable " \ - "POSIX compliance"), \ - vprintf (f, a)) -#endif - -#if @GNULIB_SNPRINTF@ -# if @REPLACE_SNPRINTF@ -# define snprintf rpl_snprintf -# endif -# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@ -extern int snprintf (char *str, size_t size, const char *format, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); +# if @REPLACE_FPURGE@ || !@HAVE_DECL_FPURGE@ + /* Discard all pending buffered I/O data on STREAM. + STREAM must not be wide-character oriented. + When discarding pending output, the file position is set back to where it + was before the write calls. When discarding pending input, the file + position is advanced to match the end of the previously read input. + Return 0 if successful. Upon error, return -1 and set errno. */ + extern int fpurge (FILE *gl_stream); # endif #elif defined GNULIB_POSIXCHECK -# undef snprintf -# define snprintf \ - (GL_LINK_WARNING ("snprintf is unportable - " \ - "use gnulib module snprintf for portability"), \ - snprintf) +# undef fpurge +# define fpurge(f) \ + (GL_LINK_WARNING ("fpurge is not always present - " \ + "use gnulib module fpurge for portability"), \ + fpurge (f)) #endif -#if @GNULIB_VSNPRINTF@ -# if @REPLACE_VSNPRINTF@ -# define vsnprintf rpl_vsnprintf -# endif -# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@ -extern int vsnprintf (char *str, size_t size, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 3, 0))); -# endif -#elif defined GNULIB_POSIXCHECK -# undef vsnprintf -# define vsnprintf(b,s,f,a) \ - (GL_LINK_WARNING ("vsnprintf is unportable - " \ - "use gnulib module vsnprintf for portability"), \ - vsnprintf (b, s, f, a)) +#if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# undef fputc +# define fputc rpl_fputc +extern int fputc (int c, FILE *stream); #endif -#if @GNULIB_SPRINTF_POSIX@ -# if @REPLACE_SPRINTF@ -# define sprintf rpl_sprintf -extern int sprintf (char *str, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); -# endif -#elif defined GNULIB_POSIXCHECK -# undef sprintf -# define sprintf \ - (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \ - "use gnulib module sprintf-posix for portable " \ - "POSIX compliance"), \ - sprintf) -#endif - -#if @GNULIB_VSPRINTF_POSIX@ -# if @REPLACE_VSPRINTF@ -# define vsprintf rpl_vsprintf -extern int vsprintf (char *str, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); -# endif -#elif defined GNULIB_POSIXCHECK -# undef vsprintf -# define vsprintf(b,f,a) \ - (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \ - "use gnulib module vsprintf-posix for portable " \ - "POSIX compliance"), \ - vsprintf (b, f, a)) -#endif - -#if @GNULIB_DPRINTF@ -# if @REPLACE_DPRINTF@ -# define dprintf rpl_dprintf -# endif -# if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@ -extern int dprintf (int fd, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); -# endif -#elif defined GNULIB_POSIXCHECK -# undef dprintf -# define dprintf(d,f,a) \ - (GL_LINK_WARNING ("dprintf is unportable - " \ - "use gnulib module dprintf for portability"), \ - dprintf (d, f, a)) -#endif - -#if @GNULIB_VDPRINTF@ -# if @REPLACE_VDPRINTF@ -# define vdprintf rpl_vdprintf -# endif -# if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@ -extern int vdprintf (int fd, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); -# endif -#elif defined GNULIB_POSIXCHECK -# undef vdprintf -# define vdprintf(d,f,a) \ - (GL_LINK_WARNING ("vdprintf is unportable - " \ - "use gnulib module vdprintf for portability"), \ - vdprintf (d, f, a)) -#endif - -#if @GNULIB_VASPRINTF@ -# if @REPLACE_VASPRINTF@ -# define asprintf rpl_asprintf -# define vasprintf rpl_vasprintf -# endif -# if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@ - /* Write formatted output to a string dynamically allocated with malloc(). - If the memory allocation succeeds, store the address of the string in - *RESULT and return the number of resulting bytes, excluding the trailing - NUL. Upon memory allocation error, or some other error, return -1. */ - extern int asprintf (char **result, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); - extern int vasprintf (char **result, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); -# endif -#endif - -#if @GNULIB_OBSTACK_PRINTF@ -# if @REPLACE_OBSTACK_PRINTF@ -# define obstack_printf rpl_osbtack_printf -# define obstack_vprintf rpl_obstack_vprintf -# endif -# if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@ - struct obstack; - /* Grow an obstack with formatted output. Return the number of - bytes added to OBS. No trailing nul byte is added, and the - object should be closed with obstack_finish before use. Upon - memory allocation error, call obstack_alloc_failed_handler. Upon - other error, return -1. */ - extern int obstack_printf (struct obstack *obs, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); - extern int obstack_vprintf (struct obstack *obs, const char *format, - va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); -# endif -#endif - -#if @GNULIB_FOPEN@ -# if @REPLACE_FOPEN@ -# undef fopen -# define fopen rpl_fopen -extern FILE * fopen (const char *filename, const char *mode); -# endif -#elif defined GNULIB_POSIXCHECK -# undef fopen -# define fopen(f,m) \ - (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \ - "use gnulib module fopen for portability"), \ - fopen (f, m)) +#if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# undef fputs +# define fputs rpl_fputs +extern int fputs (const char *string, FILE *stream); #endif #if @GNULIB_FREOPEN@ @@ -316,22 +202,6 @@ extern FILE * freopen (const char *filename, const char *mode, FILE *stream); freopen (f, m, s)) #endif -#if @GNULIB_FSEEKO@ -# if @REPLACE_FSEEKO@ -/* Provide fseek, fseeko functions that are aware of a preceding - fflush(), and which detect pipes. */ -# define fseeko rpl_fseeko -extern int fseeko (FILE *fp, off_t offset, int whence); -# define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence) -# endif -#elif defined GNULIB_POSIXCHECK -# undef fseeko -# define fseeko(f,o,w) \ - (GL_LINK_WARNING ("fseeko is unportable - " \ - "use gnulib module fseeko for portability"), \ - fseeko (f, o, w)) -#endif - #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@ extern int rpl_fseek (FILE *fp, long offset, int whence); # undef fseek @@ -354,18 +224,20 @@ extern int rpl_fseek (FILE *fp, long offset, int whence); # endif #endif -#if @GNULIB_FTELLO@ -# if @REPLACE_FTELLO@ -# define ftello rpl_ftello -extern off_t ftello (FILE *fp); -# define ftell(fp) ftello (fp) +#if @GNULIB_FSEEKO@ +# if @REPLACE_FSEEKO@ +/* Provide fseek, fseeko functions that are aware of a preceding + fflush(), and which detect pipes. */ +# define fseeko rpl_fseeko +extern int fseeko (FILE *fp, off_t offset, int whence); +# define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence) # endif #elif defined GNULIB_POSIXCHECK -# undef ftello -# define ftello(f) \ - (GL_LINK_WARNING ("ftello is unportable - " \ - "use gnulib module ftello for portability"), \ - ftello (f)) +# undef fseeko +# define fseeko(f,o,w) \ + (GL_LINK_WARNING ("fseeko is unportable - " \ + "use gnulib module fseeko for portability"), \ + fseeko (f, o, w)) #endif #if @GNULIB_FTELL@ && @REPLACE_FTELL@ @@ -390,90 +262,18 @@ extern long rpl_ftell (FILE *fp); # endif #endif -#if @GNULIB_FFLUSH@ -# if @REPLACE_FFLUSH@ -# define fflush rpl_fflush - /* Flush all pending data on STREAM according to POSIX rules. Both - output and seekable input streams are supported. - Note! LOSS OF DATA can occur if fflush is applied on an input stream - that is _not_seekable_ or on an update stream that is _not_seekable_ - and in which the most recent operation was input. Seekability can - be tested with lseek(fileno(fp),0,SEEK_CUR). */ - extern int fflush (FILE *gl_stream); +#if @GNULIB_FTELLO@ +# if @REPLACE_FTELLO@ +# define ftello rpl_ftello +extern off_t ftello (FILE *fp); +# define ftell(fp) ftello (fp) # endif #elif defined GNULIB_POSIXCHECK -# undef fflush -# define fflush(f) \ - (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \ - "use gnulib module fflush for portable " \ - "POSIX compliance"), \ - fflush (f)) -#endif - -#if @GNULIB_FPURGE@ -# if @REPLACE_FPURGE@ -# define fpurge rpl_fpurge -# endif -# if @REPLACE_FPURGE@ || !@HAVE_DECL_FPURGE@ - /* Discard all pending buffered I/O data on STREAM. - STREAM must not be wide-character oriented. - When discarding pending output, the file position is set back to where it - was before the write calls. When discarding pending input, the file - position is advanced to match the end of the previously read input. - Return 0 if successful. Upon error, return -1 and set errno. */ - extern int fpurge (FILE *gl_stream); -# endif -#elif defined GNULIB_POSIXCHECK -# undef fpurge -# define fpurge(f) \ - (GL_LINK_WARNING ("fpurge is not always present - " \ - "use gnulib module fpurge for portability"), \ - fpurge (f)) -#endif - -#if @GNULIB_FCLOSE@ -# if @REPLACE_FCLOSE@ -# define fclose rpl_fclose - /* Close STREAM and its underlying file descriptor. */ -extern int fclose (FILE *stream); -# endif -#elif defined GNULIB_POSIXCHECK -# undef fclose -# define fclose(f) \ - (GL_LINK_WARNING ("fclose is not always POSIX compliant - " \ - "use gnulib module fclose for portable " \ - "POSIX compliance"), \ - fclose (f)) -#endif - -#if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ -# undef fputc -# define fputc rpl_fputc -extern int fputc (int c, FILE *stream); -#endif - -#if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ -# undef putc -# define putc rpl_fputc -extern int putc (int c, FILE *stream); -#endif - -#if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ -# undef putchar -# define putchar rpl_putchar -extern int putchar (int c); -#endif - -#if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ -# undef fputs -# define fputs rpl_fputs -extern int fputs (const char *string, FILE *stream); -#endif - -#if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ -# undef puts -# define puts rpl_puts -extern int puts (const char *string); +# undef ftello +# define ftello(f) \ + (GL_LINK_WARNING ("ftello is unportable - " \ + "use gnulib module ftello for portability"), \ + ftello (f)) #endif #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ @@ -523,6 +323,26 @@ extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream); getline (l, s, f)) #endif +#if @GNULIB_OBSTACK_PRINTF@ +# if @REPLACE_OBSTACK_PRINTF@ +# define obstack_printf rpl_osbtack_printf +# define obstack_vprintf rpl_obstack_vprintf +# endif +# if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@ + struct obstack; + /* Grow an obstack with formatted output. Return the number of + bytes added to OBS. No trailing nul byte is added, and the + object should be closed with obstack_finish before use. Upon + memory allocation error, call obstack_alloc_failed_handler. Upon + other error, return -1. */ + extern int obstack_printf (struct obstack *obs, const char *format, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); + extern int obstack_vprintf (struct obstack *obs, const char *format, + va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))); +# endif +#endif + #if @GNULIB_PERROR@ # if @REPLACE_PERROR@ # define perror rpl_perror @@ -539,6 +359,213 @@ extern void perror (const char *string); perror (s)) #endif +#if @GNULIB_POPEN@ +# if @REPLACE_POPEN@ +# undef popen +# define popen rpl_popen +extern FILE *popen (const char *cmd, const char *mode); +# endif +#elif defined GNULIB_POSIXCHECK +# undef popen +# define popen(c,m) \ + (GL_LINK_WARNING ("popen is buggy on some platforms - " \ + "use gnulib module popen or pipe for more portability"), \ + popen (c, m)) +#endif + +#if @GNULIB_PRINTF_POSIX@ +# if @REPLACE_PRINTF@ +/* Don't break __attribute__((format(printf,M,N))). */ +# define printf __printf__ +extern int printf (const char *format, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); +# endif +#elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +/* Don't break __attribute__((format(printf,M,N))). */ +# define printf __printf__ +extern int printf (const char *format, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); +#elif defined GNULIB_POSIXCHECK +# undef printf +# define printf \ + (GL_LINK_WARNING ("printf is not always POSIX compliant - " \ + "use gnulib module printf-posix for portable " \ + "POSIX compliance"), \ + printf) +/* Don't break __attribute__((format(printf,M,N))). */ +# define format(kind,m,n) format (__##kind##__, m, n) +# define __format__(kind,m,n) __format__ (__##kind##__, m, n) +# define ____printf____ __printf__ +# define ____scanf____ __scanf__ +# define ____strftime____ __strftime__ +# define ____strfmon____ __strfmon__ +#endif + +#if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# undef putc +# define putc rpl_fputc +extern int putc (int c, FILE *stream); +#endif + +#if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# undef putchar +# define putchar rpl_putchar +extern int putchar (int c); +#endif + +#if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# undef puts +# define puts rpl_puts +extern int puts (const char *string); +#endif + +#if @GNULIB_RENAME@ +# if @REPLACE_RENAME@ +# undef rename +# define rename rpl_rename +extern int rename (const char *old, const char *new); +# endif +#elif defined GNULIB_POSIXCHECK +# undef rename +# define rename(o,n) \ + (GL_LINK_WARNING ("rename is buggy on some platforms - " \ + "use gnulib module rename for more portability"), \ + rename (o, n)) +#endif + +#if @GNULIB_SNPRINTF@ +# if @REPLACE_SNPRINTF@ +# define snprintf rpl_snprintf +# endif +# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@ +extern int snprintf (char *str, size_t size, const char *format, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef snprintf +# define snprintf \ + (GL_LINK_WARNING ("snprintf is unportable - " \ + "use gnulib module snprintf for portability"), \ + snprintf) +#endif + +#if @GNULIB_SPRINTF_POSIX@ +# if @REPLACE_SPRINTF@ +# define sprintf rpl_sprintf +extern int sprintf (char *str, const char *format, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef sprintf +# define sprintf \ + (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \ + "use gnulib module sprintf-posix for portable " \ + "POSIX compliance"), \ + sprintf) +#endif + +#if @GNULIB_VASPRINTF@ +# if @REPLACE_VASPRINTF@ +# define asprintf rpl_asprintf +# define vasprintf rpl_vasprintf +# endif +# if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@ + /* Write formatted output to a string dynamically allocated with malloc(). + If the memory allocation succeeds, store the address of the string in + *RESULT and return the number of resulting bytes, excluding the trailing + NUL. Upon memory allocation error, or some other error, return -1. */ + extern int asprintf (char **result, const char *format, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); + extern int vasprintf (char **result, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))); +# endif +#endif + +#if @GNULIB_VDPRINTF@ +# if @REPLACE_VDPRINTF@ +# define vdprintf rpl_vdprintf +# endif +# if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@ +extern int vdprintf (int fd, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vdprintf +# define vdprintf(d,f,a) \ + (GL_LINK_WARNING ("vdprintf is unportable - " \ + "use gnulib module vdprintf for portability"), \ + vdprintf (d, f, a)) +#endif + +#if @GNULIB_VFPRINTF_POSIX@ +# if @REPLACE_VFPRINTF@ +# define vfprintf rpl_vfprintf +extern int vfprintf (FILE *fp, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))); +# endif +#elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# define vfprintf rpl_vfprintf +extern int vfprintf (FILE *fp, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))); +#elif defined GNULIB_POSIXCHECK +# undef vfprintf +# define vfprintf(s,f,a) \ + (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \ + "use gnulib module vfprintf-posix for portable " \ + "POSIX compliance"), \ + vfprintf (s, f, a)) +#endif + +#if @GNULIB_VPRINTF_POSIX@ +# if @REPLACE_VPRINTF@ +# define vprintf rpl_vprintf +extern int vprintf (const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 1, 0))); +# endif +#elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# define vprintf rpl_vprintf +extern int vprintf (const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 1, 0))); +#elif defined GNULIB_POSIXCHECK +# undef vprintf +# define vprintf(f,a) \ + (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \ + "use gnulib module vprintf-posix for portable " \ + "POSIX compliance"), \ + vprintf (f, a)) +#endif + +#if @GNULIB_VSNPRINTF@ +# if @REPLACE_VSNPRINTF@ +# define vsnprintf rpl_vsnprintf +# endif +# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@ +extern int vsnprintf (char *str, size_t size, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 3, 0))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vsnprintf +# define vsnprintf(b,s,f,a) \ + (GL_LINK_WARNING ("vsnprintf is unportable - " \ + "use gnulib module vsnprintf for portability"), \ + vsnprintf (b, s, f, a)) +#endif + +#if @GNULIB_VSPRINTF_POSIX@ +# if @REPLACE_VSPRINTF@ +# define vsprintf rpl_vsprintf +extern int vsprintf (char *str, const char *format, va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))); +# endif +#elif defined GNULIB_POSIXCHECK +# undef vsprintf +# define vsprintf(b,f,a) \ + (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \ + "use gnulib module vsprintf-posix for portable " \ + "POSIX compliance"), \ + vsprintf (b, f, a)) +#endif + #ifdef __cplusplus } #endif diff --git a/src/bin/coreutils/lib/stdlib.in.h b/src/bin/coreutils/lib/stdlib.in.h index c7c8e8fb7f..9ac7199568 100644 --- a/src/bin/coreutils/lib/stdlib.in.h +++ b/src/bin/coreutils/lib/stdlib.in.h @@ -207,6 +207,31 @@ extern char * mkdtemp (char * /*template*/); #endif +#if @GNULIB_MKOSTEMP@ +# if !@HAVE_MKOSTEMP@ +/* Create a unique temporary file from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + The file is then created, with the specified flags, ensuring it didn't exist + before. + The file is created read-write (mask at least 0600 & ~umask), but it may be + world-readable and world-writable (mask 0666 & ~umask), depending on the + implementation. + Returns the open file descriptor if successful, otherwise -1 and errno + set. */ +extern int mkostemp (char * /*template*/, int /*flags*/); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkostemp +# define mkostemp(t,f) \ + (GL_LINK_WARNING ("mkostemp is unportable - " \ + "use gnulib module mkostemp for portability"), \ + mkostemp (t, f)) +#endif + + #if @GNULIB_MKSTEMP@ # if @REPLACE_MKSTEMP@ /* Create a unique temporary file from TEMPLATE. diff --git a/src/bin/coreutils/lib/string.in.h b/src/bin/coreutils/lib/string.in.h index 291379bcb0..c1f825e359 100644 --- a/src/bin/coreutils/lib/string.in.h +++ b/src/bin/coreutils/lib/string.in.h @@ -206,11 +206,11 @@ extern char *strdup (char const *__s); /* Return a newly allocated copy of at most N bytes of STRING. */ #if @GNULIB_STRNDUP@ -# if ! @HAVE_STRNDUP@ +# if @REPLACE_STRNDUP@ # undef strndup # define strndup rpl_strndup # endif -# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@ +# if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@ extern char *strndup (char const *__string, size_t __n); # endif #elif defined GNULIB_POSIXCHECK @@ -402,7 +402,13 @@ extern char *strcasestr (const char *haystack, const char *needle) See also strsep(). */ #if @GNULIB_STRTOK_R@ -# if ! @HAVE_DECL_STRTOK_R@ +# if @REPLACE_STRTOK_R@ +# undef strtok_r +# define strtok_r rpl_strtok_r +# elif @UNDEFINE_STRTOK_R@ +# undef strtok_r +# endif +# if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@ extern char *strtok_r (char *restrict s, char const *restrict delim, char **restrict save_ptr); # endif diff --git a/src/bin/coreutils/lib/strnumcmp-in.h b/src/bin/coreutils/lib/strnumcmp-in.h index db2d15875c..8864274902 100644 --- a/src/bin/coreutils/lib/strnumcmp-in.h +++ b/src/bin/coreutils/lib/strnumcmp-in.h @@ -77,28 +77,28 @@ fraccompare (char const *a, char const *b, char decimal_point) if (*a == decimal_point && *b == decimal_point) { while (*++a == *++b) - if (! ISDIGIT (*a)) - return 0; + if (! ISDIGIT (*a)) + return 0; if (ISDIGIT (*a) && ISDIGIT (*b)) - return *a - *b; + return *a - *b; if (ISDIGIT (*a)) - goto a_trailing_nonzero; + goto a_trailing_nonzero; if (ISDIGIT (*b)) - goto b_trailing_nonzero; + goto b_trailing_nonzero; return 0; } else if (*a++ == decimal_point) { a_trailing_nonzero: while (*a == NUMERIC_ZERO) - a++; + a++; return ISDIGIT (*a); } else if (*b++ == decimal_point) { b_trailing_nonzero: while (*b == NUMERIC_ZERO) - b++; + b++; return - ISDIGIT (*b); } return 0; @@ -113,7 +113,7 @@ fraccompare (char const *a, char const *b, char decimal_point) static inline int numcompare (char const *a, char const *b, - int decimal_point, int thousands_sep) + int decimal_point, int thousands_sep) { unsigned char tmpa = *a; unsigned char tmpb = *b; @@ -124,119 +124,119 @@ numcompare (char const *a, char const *b, if (tmpa == NEGATION_SIGN) { do - tmpa = *++a; + tmpa = *++a; while (tmpa == NUMERIC_ZERO || tmpa == thousands_sep); if (tmpb != NEGATION_SIGN) - { - if (tmpa == decimal_point) - do - tmpa = *++a; - while (tmpa == NUMERIC_ZERO); - if (ISDIGIT (tmpa)) - return -1; - while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep) - tmpb = *++b; - if (tmpb == decimal_point) - do - tmpb = *++b; - while (tmpb == NUMERIC_ZERO); - return - ISDIGIT (tmpb); - } + { + if (tmpa == decimal_point) + do + tmpa = *++a; + while (tmpa == NUMERIC_ZERO); + if (ISDIGIT (tmpa)) + return -1; + while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep) + tmpb = *++b; + if (tmpb == decimal_point) + do + tmpb = *++b; + while (tmpb == NUMERIC_ZERO); + return - ISDIGIT (tmpb); + } do - tmpb = *++b; + tmpb = *++b; while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep); while (tmpa == tmpb && ISDIGIT (tmpa)) - { - do - tmpa = *++a; - while (tmpa == thousands_sep); - do - tmpb = *++b; - while (tmpb == thousands_sep); - } + { + do + tmpa = *++a; + while (tmpa == thousands_sep); + do + tmpb = *++b; + while (tmpb == thousands_sep); + } if ((tmpa == decimal_point && !ISDIGIT (tmpb)) - || (tmpb == decimal_point && !ISDIGIT (tmpa))) - return fraccompare (b, a, decimal_point); + || (tmpb == decimal_point && !ISDIGIT (tmpa))) + return fraccompare (b, a, decimal_point); tmp = tmpb - tmpa; for (log_a = 0; ISDIGIT (tmpa); ++log_a) - do - tmpa = *++a; - while (tmpa == thousands_sep); + do + tmpa = *++a; + while (tmpa == thousands_sep); for (log_b = 0; ISDIGIT (tmpb); ++log_b) - do - tmpb = *++b; - while (tmpb == thousands_sep); + do + tmpb = *++b; + while (tmpb == thousands_sep); if (log_a != log_b) - return log_a < log_b ? 1 : -1; + return log_a < log_b ? 1 : -1; if (!log_a) - return 0; + return 0; return tmp; } else if (tmpb == NEGATION_SIGN) { do - tmpb = *++b; + tmpb = *++b; while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep); if (tmpb == decimal_point) - do - tmpb = *++b; - while (tmpb == NUMERIC_ZERO); + do + tmpb = *++b; + while (tmpb == NUMERIC_ZERO); if (ISDIGIT (tmpb)) - return 1; + return 1; while (tmpa == NUMERIC_ZERO || tmpa == thousands_sep) - tmpa = *++a; + tmpa = *++a; if (tmpa == decimal_point) - do - tmpa = *++a; - while (tmpa == NUMERIC_ZERO); + do + tmpa = *++a; + while (tmpa == NUMERIC_ZERO); return ISDIGIT (tmpa); } else { while (tmpa == NUMERIC_ZERO || tmpa == thousands_sep) - tmpa = *++a; + tmpa = *++a; while (tmpb == NUMERIC_ZERO || tmpb == thousands_sep) - tmpb = *++b; + tmpb = *++b; while (tmpa == tmpb && ISDIGIT (tmpa)) - { - do - tmpa = *++a; - while (tmpa == thousands_sep); - do - tmpb = *++b; - while (tmpb == thousands_sep); - } + { + do + tmpa = *++a; + while (tmpa == thousands_sep); + do + tmpb = *++b; + while (tmpb == thousands_sep); + } if ((tmpa == decimal_point && !ISDIGIT (tmpb)) - || (tmpb == decimal_point && !ISDIGIT (tmpa))) - return fraccompare (a, b, decimal_point); + || (tmpb == decimal_point && !ISDIGIT (tmpa))) + return fraccompare (a, b, decimal_point); tmp = tmpa - tmpb; for (log_a = 0; ISDIGIT (tmpa); ++log_a) - do - tmpa = *++a; - while (tmpa == thousands_sep); + do + tmpa = *++a; + while (tmpa == thousands_sep); for (log_b = 0; ISDIGIT (tmpb); ++log_b) - do - tmpb = *++b; - while (tmpb == thousands_sep); + do + tmpb = *++b; + while (tmpb == thousands_sep); if (log_a != log_b) - return log_a < log_b ? -1 : 1; + return log_a < log_b ? -1 : 1; if (!log_a) - return 0; + return 0; return tmp; } diff --git a/src/bin/coreutils/lib/strnumcmp.c b/src/bin/coreutils/lib/strnumcmp.c index 2a2f2f7295..aae09e1563 100644 --- a/src/bin/coreutils/lib/strnumcmp.c +++ b/src/bin/coreutils/lib/strnumcmp.c @@ -25,7 +25,7 @@ int strnumcmp (char const *a, char const *b, - int decimal_point, int thousands_sep) + int decimal_point, int thousands_sep) { return numcompare (a, b, decimal_point, thousands_sep); } diff --git a/src/bin/coreutils/lib/sys_socket.in.h b/src/bin/coreutils/lib/sys_socket.in.h index 24bfcbc2c5..5d898dfbfe 100644 --- a/src/bin/coreutils/lib/sys_socket.in.h +++ b/src/bin/coreutils/lib/sys_socket.in.h @@ -426,5 +426,32 @@ extern int rpl_shutdown (int, int); #endif /* HAVE_SYS_SOCKET_H */ +#ifdef __cplusplus +extern "C" { +#endif + +#if @GNULIB_ACCEPT4@ +/* Accept a connection on a socket, with specific opening flags. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + See also the Linux man page at + . */ +# if @HAVE_ACCEPT4@ +# define accept4 rpl_accept4 +# endif +extern int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, + int flags); +#elif defined GNULIB_POSIXCHECK +# undef accept4 +# define accept4(s,a,l,f) \ + (GL_LINK_WARNING ("accept4 is unportable - " \ + "use gnulib module accept4 for portability"), \ + accept4 (s, a, l, f)) +#endif + +#ifdef __cplusplus +} +#endif + #endif /* _GL_SYS_SOCKET_H */ #endif /* _GL_SYS_SOCKET_H */ diff --git a/src/bin/coreutils/lib/sys_stat.in.h b/src/bin/coreutils/lib/sys_stat.in.h index 3a2c6e0bef..b8d565e899 100644 --- a/src/bin/coreutils/lib/sys_stat.in.h +++ b/src/bin/coreutils/lib/sys_stat.in.h @@ -306,6 +306,77 @@ extern int rpl_lstat (const char *name, struct stat *buf); #endif +#if @GNULIB_FCHMODAT@ +# if !@HAVE_FCHMODAT@ +extern int fchmodat (int fd, char const *file, mode_t mode, int flag); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fchmodat +# define fchmodat(d,n,m,f) \ + (GL_LINK_WARNING ("fchmodat is not portable - " \ + "use gnulib module openat for portability"), \ + fchmodat (d, n, m, f)) +#endif + + +#if @GNULIB_FSTATAT@ +# if @REPLACE_FSTATAT@ +# undef fstatat +# define fstatat rpl_fstatat +# endif +# if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@ +extern int fstatat (int fd, char const *name, struct stat *st, int flags); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fstatat +# define fstatat(d,n,s,f) \ + (GL_LINK_WARNING ("fstatat is not portable - " \ + "use gnulib module openat for portability"), \ + fstatat (d, n, s, f)) +#endif + + +#if @GNULIB_MKDIRAT@ +# if !@HAVE_MKDIRAT@ +extern int mkdirat (int fd, char const *file, mode_t mode); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkdirat +# define mkdirat(d,n,m) \ + (GL_LINK_WARNING ("mkdirat is not portable - " \ + "use gnulib module openat for portability"), \ + mkdirat (d, n, m)) +#endif + +#if @GNULIB_MKFIFOAT@ +# if !@HAVE_MKFIFOAT@ +int mkfifoat (int fd, char const *file, mode_t mode); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkfifoat +# define mkfifoat(d,n,m) \ + (GL_LINK_WARNING ("mkfifoat is not portable - " \ + "use gnulib module mkfifoat for portability"), \ + mkfifoat (d, n, m)) +#endif + +#if @GNULIB_MKNODAT@ +# if !@HAVE_MKNODAT@ +int mknodat (int fd, char const *file, mode_t mode, dev_t dev); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mknodat +# define mknodat(f,n,m,d) \ + (GL_LINK_WARNING ("mknodat is not portable - " \ + "use gnulib module mkfifoat for portability"), \ + mknodat (f, n, m, d)) +#endif + +#if @REPLACE_FCHDIR@ +# define fstat rpl_fstat +extern int fstat (int fd, struct stat *buf); +#endif + #if @REPLACE_MKDIR@ # undef mkdir # define mkdir rpl_mkdir diff --git a/src/bin/coreutils/lib/tempname.c b/src/bin/coreutils/lib/tempname.c index e9fb606703..01715168d6 100644 --- a/src/bin/coreutils/lib/tempname.c +++ b/src/bin/coreutils/lib/tempname.c @@ -96,7 +96,7 @@ direxists (const char *dir) enough space in TMPL. */ int __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, - int try_tmpdir) + int try_tmpdir) { const char *d; size_t dlen, plen; @@ -110,30 +110,30 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, { plen = strlen (pfx); if (plen > 5) - plen = 5; + plen = 5; } if (try_tmpdir) { d = __secure_getenv ("TMPDIR"); if (d != NULL && direxists (d)) - dir = d; + dir = d; else if (dir != NULL && direxists (dir)) - /* nothing */ ; + /* nothing */ ; else - dir = NULL; + dir = NULL; } if (dir == NULL) { if (direxists (P_tmpdir)) - dir = P_tmpdir; + dir = P_tmpdir; else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp")) - dir = "/tmp"; + dir = "/tmp"; else - { - __set_errno (ENOENT); - return -1; - } + { + __set_errno (ENOENT); + return -1; + } } dlen = strlen (dir); @@ -169,9 +169,9 @@ static const char letters[] = KIND may be one of: __GT_NOCREATE: simply verify that the name does not exist - at the time of the call. + at the time of the call. __GT_FILE: create the file using open(O_CREAT|O_EXCL) - and return a read-write fd. The file is mode 0600. + and return a read-write fd. The file is mode 0600. __GT_BIGFILE: same as __GT_FILE but use open64(). __GT_DIR: create a directory, which will be mode 0700. @@ -205,7 +205,7 @@ gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len) len = strlen (tmpl); if (len < x_suffix_len || ! check_x_suffix (&tmpl[len - x_suffix_len], - x_suffix_len)) + x_suffix_len)) { __set_errno (EINVAL); return -1; @@ -223,60 +223,60 @@ gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len) size_t i; for (i = 0; i < x_suffix_len; i++) - { - XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)]; - } + { + XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)]; + } switch (kind) - { - case __GT_FILE: - fd = small_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); - break; + { + case __GT_FILE: + fd = small_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + break; - case __GT_BIGFILE: - fd = large_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); - break; + case __GT_BIGFILE: + fd = large_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + break; - case __GT_DIR: - fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR); - break; + case __GT_DIR: + fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR); + break; - case __GT_NOCREATE: - /* This case is backward from the other three. This function - succeeds if __xstat fails because the name does not exist. - Note the continue to bypass the common logic at the bottom - of the loop. */ - if (__lxstat64 (_STAT_VER, tmpl, &st) < 0) - { - if (errno == ENOENT) - { - __set_errno (save_errno); - fd = 0; - goto done; - } - else - { - /* Give up now. */ - fd = -1; - goto done; - } - } - continue; + case __GT_NOCREATE: + /* This case is backward from the other three. This function + succeeds if __xstat fails because the name does not exist. + Note the continue to bypass the common logic at the bottom + of the loop. */ + if (__lxstat64 (_STAT_VER, tmpl, &st) < 0) + { + if (errno == ENOENT) + { + __set_errno (save_errno); + fd = 0; + goto done; + } + else + { + /* Give up now. */ + fd = -1; + goto done; + } + } + continue; - default: - assert (! "invalid KIND in __gen_tempname"); - } + default: + assert (! "invalid KIND in __gen_tempname"); + } if (fd >= 0) - { - __set_errno (save_errno); - goto done; - } + { + __set_errno (save_errno); + goto done; + } else if (errno != EEXIST) - { - fd = -1; - goto done; - } + { + fd = -1; + goto done; + } } randint_all_free (rand_src); diff --git a/src/bin/coreutils/lib/tempname.h b/src/bin/coreutils/lib/tempname.h index b7dd3a1019..ee34aca219 100644 --- a/src/bin/coreutils/lib/tempname.h +++ b/src/bin/coreutils/lib/tempname.h @@ -30,9 +30,9 @@ KIND may be one of: GT_NOCREATE: simply verify that the name does not exist - at the time of the call. + at the time of the call. GT_FILE: create a large file using open(O_CREAT|O_EXCL) - and return a read-write fd. The file is mode 0600. + and return a read-write fd. The file is mode 0600. GT_DIR: create a directory, which will be mode 0700. We use a clever algorithm to get hard-to-predict names. */ diff --git a/src/bin/coreutils/lib/unistd.in.h b/src/bin/coreutils/lib/unistd.in.h index 80a005c50a..151d16c5d5 100644 --- a/src/bin/coreutils/lib/unistd.in.h +++ b/src/bin/coreutils/lib/unistd.in.h @@ -109,6 +109,15 @@ # define STDERR_FILENO 2 #endif +/* Ensure *_OK functions exist. */ +#ifndef F_OK +# define F_OK 0 +# define X_OK 1 +# define W_OK 2 +# define R_OK 4 +#endif + + /* Declare overridden functions. */ #ifdef __cplusplus @@ -141,6 +150,72 @@ extern int chown (const char *file, uid_t uid, gid_t gid); #endif +#if @GNULIB_FCHOWNAT@ +# if @REPLACE_FCHOWNAT@ +# undef fchownat +# define fchownat rpl_fchownat +# endif +# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@ +extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fchownat +# define fchownat(d,n,o,g,f) \ + (GL_LINK_WARNING ("fchownat is not portable - " \ + "use gnulib module openat for portability"), \ + fchownat (d, n, o, g, f)) +#endif + + +#if @GNULIB_UNLINKAT@ +# if !@HAVE_UNLINKAT@ +extern int unlinkat (int fd, char const *file, int flag); +# endif +#elif defined GNULIB_POSIXCHECK +# undef unlinkat +# define unlinkat(d,n,f) \ + (GL_LINK_WARNING ("unlinkat is not portable - " \ + "use gnulib module openat for portability"), \ + unlinkat (d, n, f)) +#endif + + +#if @GNULIB_FACCESSAT@ +# if !@HAVE_FACCESSAT@ +int faccessat (int fd, char const *file, int mode, int flag); +# endif +#elif defined GNULIB_POSIXCHECK +# undef faccessat +# define faccessat(d,n,m,f) \ + (GL_LINK_WARNING ("faccessat is not portable - " \ + "use gnulib module faccessat for portability"), \ + faccessat (d, n, m, f)) +#endif + +#if @GNULIB_SYMLINKAT@ +# if !@HAVE_SYMLINKAT@ +int symlinkat (char const *contents, int fd, char const *file); +# endif +#elif defined GNULIB_POSIXCHECK +# undef symlinkat +# define symlinkat(c,d,n) \ + (GL_LINK_WARNING ("symlinkat is not portable - " \ + "use gnulib module symlinkat for portability"), \ + symlinkat (c, d, n)) +#endif + +#if @GNULIB_READLINKAT@ +# if !@HAVE_READLINKAT@ +ssize_t readlinkat (int fd, char const *file, char *buf, size_t len); +# endif +#elif defined GNULIB_POSIXCHECK +# undef readlinkat +# define readlinkat(d,n,b,l) \ + (GL_LINK_WARNING ("readlinkat is not portable - " \ + "use gnulib module symlinkat for portability"), \ + readlinkat (d, n, b, l)) +#endif + #if @GNULIB_CLOSE@ # if @REPLACE_CLOSE@ /* Automatically included by modules that need a replacement for close. */ @@ -181,6 +256,28 @@ extern int dup2 (int oldfd, int newfd); #endif +#if @GNULIB_DUP3@ +/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the + specified flags. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + Close NEWFD first if it is open. + Return newfd if successful, otherwise -1 and errno set. + See the Linux man page at + . */ +# if @HAVE_DUP3@ +# define dup3 rpl_dup3 +# endif +extern int dup3 (int oldfd, int newfd, int flags); +#elif defined GNULIB_POSIXCHECK +# undef dup3 +# define dup3(o,n,f) \ + (GL_LINK_WARNING ("dup3 is unportable - " \ + "use gnulib module dup3 for portability"), \ + dup3 (o, n, f)) +#endif + + #if @GNULIB_ENVIRON@ # if !@HAVE_DECL_ENVIRON@ /* Set of environment variables and values. An array of strings of the form @@ -229,11 +326,11 @@ extern int fchdir (int /*fd*/); # define dup rpl_dup extern int dup (int); -# if @REPLACE_DUP2@ -# undef dup2 -# endif -# define dup2 rpl_dup2_fchdir -extern int dup2 (int, int); +/* Gnulib internal hooks needed to maintain the fchdir metadata. */ +extern int _gl_register_fd (int fd, const char *filename); +extern void _gl_unregister_fd (int fd); +extern int _gl_register_dup (int oldfd, int newfd); +extern const char *_gl_directory_name (int fd); # endif #elif defined GNULIB_POSIXCHECK @@ -331,7 +428,8 @@ extern int getdomainname(char *name, size_t len); #if @GNULIB_GETDTABLESIZE@ # if !@HAVE_GETDTABLESIZE@ -/* Return the maximum number of file descriptors in the current process. */ +/* Return the maximum number of file descriptors in the current process. + In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ extern int getdtablesize (void); # endif #elif defined GNULIB_POSIXCHECK @@ -500,11 +598,14 @@ extern int lchown (char const *file, uid_t owner, gid_t group); #if @GNULIB_LINK@ +# if @REPLACE_LINK@ +# define link rpl_link +# endif /* Create a new hard link for an existing file. Return 0 if successful, otherwise -1 and errno set. See POSIX:2001 specification . */ -# if !@HAVE_LINK@ +# if !@HAVE_LINK@ || @REPLACE_LINK@ extern int link (const char *path1, const char *path2); # endif #elif defined GNULIB_POSIXCHECK @@ -534,6 +635,28 @@ extern int link (const char *path1, const char *path2); #endif +#if @GNULIB_PIPE2@ +/* Create a pipe, applying the given flags when opening the read-end of the + pipe and the write-end of the pipe. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + Store the read-end as fd[0] and the write-end as fd[1]. + Return 0 upon success, or -1 with errno set upon failure. + See also the Linux man page at + . */ +# if @HAVE_PIPE2@ +# define pipe2 rpl_pipe2 +# endif +extern int pipe2 (int fd[2], int flags); +#elif defined GNULIB_POSIXCHECK +# undef pipe2 +# define pipe2(f,o) \ + (GL_LINK_WARNING ("pipe2 is unportable - " \ + "use gnulib module pipe2 for portability"), \ + pipe2 (f, o)) +#endif + + #if @GNULIB_READLINK@ /* Read the contents of the symbolic link FILE and place the first BUFSIZE bytes of it into BUF. Return the number of bytes placed into BUF if @@ -579,12 +702,6 @@ extern ssize_t write (int fd, const void *buf, size_t count); #endif -#ifdef FCHDIR_REPLACEMENT -/* gnulib internal function. */ -extern void _gl_unregister_fd (int fd); -#endif - - #ifdef __cplusplus } #endif diff --git a/src/bin/coreutils/lib/utimens.c b/src/bin/coreutils/lib/utimens.c index 708de10989..f7bc75e653 100644 --- a/src/bin/coreutils/lib/utimens.c +++ b/src/bin/coreutils/lib/utimens.c @@ -1,7 +1,7 @@ /* Set file access and modification times. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software - Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -44,16 +44,6 @@ struct utimbuf }; #endif -/* Some systems don't have ENOSYS. */ -#ifndef ENOSYS -# ifdef ENOTSUP -# define ENOSYS ENOTSUP -# else -/* Some systems don't have ENOTSUP either. */ -# define ENOSYS EINVAL -# endif -#endif - #ifndef __attribute__ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) # define __attribute__(x) diff --git a/src/bin/coreutils/lib/vasnprintf.c b/src/bin/coreutils/lib/vasnprintf.c index f48875bfa6..a6fcd26939 100644 --- a/src/bin/coreutils/lib/vasnprintf.c +++ b/src/bin/coreutils/lib/vasnprintf.c @@ -260,7 +260,7 @@ local_wcsnlen (const wchar_t *s, size_t maxlen) # ifndef decimal_point_char_defined # define decimal_point_char_defined 1 static char -decimal_point_char () +decimal_point_char (void) { const char *point; /* Determine it in a multithread-safe way. We know nl_langinfo is diff --git a/src/bin/coreutils/lib/version.c b/src/bin/coreutils/lib/version.c index 23b9964587..8e23134a35 100644 --- a/src/bin/coreutils/lib/version.c +++ b/src/bin/coreutils/lib/version.c @@ -1,2 +1,2 @@ #include -char const *Version = "7.4"; +char const *Version = "7.6"; diff --git a/src/bin/coreutils/lib/wctype.in.h b/src/bin/coreutils/lib/wctype.in.h index a9c4491f88..1f0db00512 100644 --- a/src/bin/coreutils/lib/wctype.in.h +++ b/src/bin/coreutils/lib/wctype.in.h @@ -3,7 +3,7 @@ #line 1 /* A substitute for ISO C99 , for platforms that lack it. - Copyright (C) 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2006-2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -87,6 +87,8 @@ # undef iswspace # undef iswupper # undef iswxdigit +# undef towlower +# undef towupper /* Linux libc5 has and the functions but they are broken. */ # if @REPLACE_ISWCNTRL@ @@ -102,6 +104,8 @@ # define iswspace rpl_iswspace # define iswupper rpl_iswupper # define iswxdigit rpl_iswxdigit +# define towlower rpl_towlower +# define towupper rpl_towupper # endif static inline int @@ -181,7 +185,50 @@ iswxdigit (wint_t wc) || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); } +static inline wint_t +towlower (wint_t wc) +{ + return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); +} + +static inline wint_t +towupper (wint_t wc) +{ + return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); +} + # endif /* ! HAVE_ISWCNTRL */ +# if defined __MINGW32__ + +/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. + The functions towlower and towupper are implemented in the MSVCRT library + to take a wchar_t argument and return a wchar_t result. mingw declares + these functions to take a wint_t argument and return a wint_t result. + This means that: + 1. When the user passes an argument outside the range 0x0000..0xFFFF, the + function will look only at the lower 16 bits. This is allowed according + to POSIX. + 2. The return value is returned in the lower 16 bits of the result register. + The upper 16 bits are random: whatever happened to be in that part of the + result register. We need to fix this by adding a zero-extend from + wchar_t to wint_t after the call. */ + +static inline wint_t +rpl_towlower (wint_t wc) +{ + return (wint_t) (wchar_t) towlower (wc); +} +# define towlower rpl_towlower + +static inline wint_t +rpl_towupper (wint_t wc) +{ + return (wint_t) (wchar_t) towupper (wc); +} +# define towupper rpl_towupper + +# endif + #endif /* _GL_WCTYPE_H */ #endif /* _GL_WCTYPE_H */ diff --git a/src/bin/coreutils/lib/xfreopen.c b/src/bin/coreutils/lib/xfreopen.c index a20965f252..61091694bb 100644 --- a/src/bin/coreutils/lib/xfreopen.c +++ b/src/bin/coreutils/lib/xfreopen.c @@ -31,11 +31,11 @@ xfreopen (char const *filename, char const *mode, FILE *fp) if (!freopen (filename, mode, fp)) { char const *f = (filename ? filename - : (fp == stdin ? _("stdin") - : (fp == stdout ? _("stdout") - : (fp == stderr ? _("stderr") - : _("unknown stream"))))); + : (fp == stdin ? _("stdin") + : (fp == stdout ? _("stdout") + : (fp == stderr ? _("stderr") + : _("unknown stream"))))); error (exit_failure, errno, _("failed to reopen %s with mode %s"), - quote_n (0, f), quote_n (1, mode)); + quote_n (0, f), quote_n (1, mode)); } } diff --git a/src/bin/coreutils/lib/xfts.c b/src/bin/coreutils/lib/xfts.c index e91ab079e6..5994a5fef3 100644 --- a/src/bin/coreutils/lib/xfts.c +++ b/src/bin/coreutils/lib/xfts.c @@ -35,28 +35,28 @@ FTS * xfts_open (char * const *argv, int options, - int (*compar) (const FTSENT **, const FTSENT **)) + int (*compar) (const FTSENT **, const FTSENT **)) { FTS *fts = fts_open (argv, options | FTS_CWDFD, compar); if (fts == NULL) { /* This can fail in three ways: out of memory, invalid bit_flags, - and one or more of the FILES is an empty string. We could try - to decipher that errno==EINVAL means invalid bit_flags and - errno==ENOENT means there's an empty string, but that seems wrong. - Ideally, fts_open would return a proper error indicator. For now, - we'll presume that the bit_flags are valid and just check for - empty strings. */ + and one or more of the FILES is an empty string. We could try + to decipher that errno==EINVAL means invalid bit_flags and + errno==ENOENT means there's an empty string, but that seems wrong. + Ideally, fts_open would return a proper error indicator. For now, + we'll presume that the bit_flags are valid and just check for + empty strings. */ bool invalid_arg = false; for (; *argv; ++argv) - { - if (**argv == '\0') - invalid_arg = true; - } + { + if (**argv == '\0') + invalid_arg = true; + } if (invalid_arg) - error (EXIT_FAILURE, 0, _("invalid argument: %s"), quote ("")); + error (EXIT_FAILURE, 0, _("invalid argument: %s"), quote ("")); else - xalloc_die (); + xalloc_die (); } return fts; diff --git a/src/bin/coreutils/lib/xfts.h b/src/bin/coreutils/lib/xfts.h index 47906132a9..27ddb5d48e 100644 --- a/src/bin/coreutils/lib/xfts.h +++ b/src/bin/coreutils/lib/xfts.h @@ -2,4 +2,4 @@ FTS * xfts_open (char * const *, int options, - int (*) (const FTSENT **, const FTSENT **)); + int (*) (const FTSENT **, const FTSENT **)); diff --git a/src/bin/coreutils/lib/xgethostname.c b/src/bin/coreutils/lib/xgethostname.c index 875d497618..d649b8dcff 100644 --- a/src/bin/coreutils/lib/xgethostname.c +++ b/src/bin/coreutils/lib/xgethostname.c @@ -1,7 +1,7 @@ /* xgethostname.c -- return current hostname with unlimited length - Copyright (C) 1992, 1996, 2000, 2001, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1992, 1996, 2000, 2001, 2003, 2004, 2005, 2006, 2009 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,10 +29,6 @@ #include "xalloc.h" -#ifndef ENAMETOOLONG -# define ENAMETOOLONG 0 -#endif - #ifndef INITIAL_HOSTNAME_LENGTH # define INITIAL_HOSTNAME_LENGTH 34 #endif diff --git a/src/bin/coreutils/lib/xmemxfrm.c b/src/bin/coreutils/lib/xmemxfrm.c index 2e9979ddb0..bfbf658abd 100644 --- a/src/bin/coreutils/lib/xmemxfrm.c +++ b/src/bin/coreutils/lib/xmemxfrm.c @@ -45,7 +45,7 @@ size_t xmemxfrm (char *restrict dest, size_t destsize, - char *restrict src, size_t srcsize) + char *restrict src, size_t srcsize) { size_t translated_size = memxfrm (dest, destsize, src, srcsize); @@ -54,8 +54,8 @@ xmemxfrm (char *restrict dest, size_t destsize, 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)); + _("the untransformed string was %s"), + quotearg_n_style_mem (0, locale_quoting_style, src, srcsize)); } return translated_size; diff --git a/src/bin/coreutils/man/Makefile.in b/src/bin/coreutils/man/Makefile.in index 2a6c153c9e..b0f0eab1c0 100644 --- a/src/bin/coreutils/man/Makefile.in +++ b/src/bin/coreutils/man/Makefile.in @@ -71,22 +71,23 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ - $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ - $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ - $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ - $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ - $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ + $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ + $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ + $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ + $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ + $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ - $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ - $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ - $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ + $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ + $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ + $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ + $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ @@ -128,37 +129,38 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ - $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ - $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/long-options.m4 \ - $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ - $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ - $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ - $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ - $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ - $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ - $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbsrtowcs.m4 \ - $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/mbswidth.m4 \ - $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memcasecmp.m4 \ - $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/memcmp.m4 \ - $(top_srcdir)/m4/memcoll.m4 $(top_srcdir)/m4/memcpy.m4 \ - $(top_srcdir)/m4/memmove.m4 $(top_srcdir)/m4/mempcpy.m4 \ - $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/memset.m4 \ - $(top_srcdir)/m4/memxfrm.m4 $(top_srcdir)/m4/mgetgroups.m4 \ - $(top_srcdir)/m4/mkancesdirs.m4 $(top_srcdir)/m4/mkdir-p.m4 \ - $(top_srcdir)/m4/mkdir-slash.m4 $(top_srcdir)/m4/mkstemp.m4 \ - $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ - $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/modechange.m4 \ - $(top_srcdir)/m4/mountlist.m4 $(top_srcdir)/m4/mpsort.m4 \ - $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/nanosleep.m4 \ - $(top_srcdir)/m4/netdb_h.m4 $(top_srcdir)/m4/netinet_in_h.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/nocrash.m4 \ - $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ - $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ - $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ - $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ - $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ + $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ + $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ + $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ + $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ + $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ + $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ + $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ + $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ + $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ + $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/memcmp.m4 $(top_srcdir)/m4/memcoll.m4 \ + $(top_srcdir)/m4/memcpy.m4 $(top_srcdir)/m4/memmove.m4 \ + $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ + $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ + $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ + $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ + $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ + $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ + $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ + $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ + $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ + $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ + $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ @@ -320,6 +322,7 @@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNULIB_ACCEPT = @GNULIB_ACCEPT@ +GNULIB_ACCEPT4 = @GNULIB_ACCEPT4@ GNULIB_ALPHASORT = @GNULIB_ALPHASORT@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ @@ -333,10 +336,15 @@ GNULIB_CONNECT = @GNULIB_CONNECT@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ +GNULIB_DUP3 = @GNULIB_DUP3@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ +GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ +GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ +GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ GNULIB_FLOORL = @GNULIB_FLOORL@ @@ -351,6 +359,7 @@ GNULIB_FREXP = @GNULIB_FREXP@ GNULIB_FREXPL = @GNULIB_FREXPL@ GNULIB_FSEEK = @GNULIB_FSEEK@ GNULIB_FSEEKO = @GNULIB_FSEEKO@ +GNULIB_FSTATAT = @GNULIB_FSTATAT@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ @@ -414,12 +423,19 @@ GNULIB_MEMCHR = @GNULIB_MEMCHR@ GNULIB_MEMMEM = @GNULIB_MEMMEM@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ +GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNODAT = @GNULIB_MKNODAT@ +GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ +GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ +GNULIB_PIPE2 = @GNULIB_PIPE2@ +GNULIB_POPEN = @GNULIB_POPEN@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -429,9 +445,11 @@ GNULIB_PUTS = @GNULIB_PUTS@ GNULIB_RANDOM_R = @GNULIB_RANDOM_R@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ +GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_RENAME = @GNULIB_RENAME@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -471,11 +489,13 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ @@ -492,6 +512,7 @@ GNULIB_WCTOB = @GNULIB_WCTOB@ GNULIB_WCWIDTH = @GNULIB_WCWIDTH@ GNULIB_WRITE = @GNULIB_WRITE@ GREP = @GREP@ +HAVE_ACCEPT4 = @HAVE_ACCEPT4@ HAVE_ALPHASORT = @HAVE_ALPHASORT@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ @@ -542,8 +563,14 @@ HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@ HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@ HAVE_DPRINTF = @HAVE_DPRINTF@ HAVE_DUP2 = @HAVE_DUP2@ +HAVE_DUP3 = @HAVE_DUP3@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ +HAVE_FACCESSAT = @HAVE_FACCESSAT@ +HAVE_FCHMODAT = @HAVE_FCHMODAT@ +HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ HAVE_FSEEKO = @HAVE_FSEEKO@ +HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ @@ -569,15 +596,22 @@ HAVE_MBSINIT = @HAVE_MBSINIT@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ +HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNODAT = @HAVE_MKNODAT@ +HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ +HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ +HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ @@ -595,7 +629,6 @@ HAVE_STPCPY = @HAVE_STPCPY@ HAVE_STPNCPY = @HAVE_STPNCPY@ HAVE_STRCASESTR = @HAVE_STRCASESTR@ HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ -HAVE_STRNDUP = @HAVE_STRNDUP@ HAVE_STRPBRK = @HAVE_STRPBRK@ HAVE_STRSEP = @HAVE_STRSEP@ HAVE_STRTOD = @HAVE_STRTOD@ @@ -607,6 +640,8 @@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ +HAVE_SYMLINK = @HAVE_SYMLINK@ +HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@ HAVE_SYS_IOCTL_H = @HAVE_SYS_IOCTL_H@ @@ -618,6 +653,7 @@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ +HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ @@ -770,6 +806,7 @@ REPLACE_CLOSE = @REPLACE_CLOSE@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ REPLACE_DUP2 = @REPLACE_DUP2@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ +REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ @@ -782,6 +819,7 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ REPLACE_GETCWD = @REPLACE_GETCWD@ @@ -798,6 +836,7 @@ REPLACE_ISNAN = @REPLACE_ISNAN@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ +REPLACE_LINK = @REPLACE_LINK@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -818,8 +857,10 @@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ REPLACE_PERROR = @REPLACE_PERROR@ +REPLACE_POPEN = @REPLACE_POPEN@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ @@ -832,10 +873,12 @@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ REPLACE_STRERROR = @REPLACE_STRERROR@ +REPLACE_STRNDUP = @REPLACE_STRNDUP@ REPLACE_STRPTIME = @REPLACE_STRPTIME@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ +REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ @@ -868,13 +911,13 @@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ -SYS_STAT_H = @SYS_STAT_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ U = @U@ UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@ UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@ +UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ USE_ACL = @USE_ACL@ diff --git a/src/bin/coreutils/man/base64.1 b/src/bin/coreutils/man/base64.1 index ffc6aa4b1e..1fcc2c58d3 100644 --- a/src/bin/coreutils/man/base64.1 +++ b/src/bin/coreutils/man/base64.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH BASE64 "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH BASE64 "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME base64 \- base64 encode/decode data and print to standard output .SH SYNOPSIS diff --git a/src/bin/coreutils/man/basename.1 b/src/bin/coreutils/man/basename.1 index d18c0377ab..6062d4a635 100644 --- a/src/bin/coreutils/man/basename.1 +++ b/src/bin/coreutils/man/basename.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH BASENAME "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH BASENAME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME basename \- strip directory and suffix from filenames .SH SYNOPSIS diff --git a/src/bin/coreutils/man/cat.1 b/src/bin/coreutils/man/cat.1 index 1e143e700f..3bc61df380 100644 --- a/src/bin/coreutils/man/cat.1 +++ b/src/bin/coreutils/man/cat.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CAT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CAT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME cat \- concatenate files and print on the standard output .SH SYNOPSIS diff --git a/src/bin/coreutils/man/chcon.1 b/src/bin/coreutils/man/chcon.1 index 9b4819f6da..f5d1e7bfd6 100644 --- a/src/bin/coreutils/man/chcon.1 +++ b/src/bin/coreutils/man/chcon.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHCON "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CHCON "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME chcon \- change file security context .SH SYNOPSIS diff --git a/src/bin/coreutils/man/chgrp.1 b/src/bin/coreutils/man/chgrp.1 index ae43a6f161..186a41635f 100644 --- a/src/bin/coreutils/man/chgrp.1 +++ b/src/bin/coreutils/man/chgrp.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHGRP "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CHGRP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME chgrp \- change group ownership .SH SYNOPSIS diff --git a/src/bin/coreutils/man/chmod.1 b/src/bin/coreutils/man/chmod.1 index 946446eb46..09d62174fb 100644 --- a/src/bin/coreutils/man/chmod.1 +++ b/src/bin/coreutils/man/chmod.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHMOD "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CHMOD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME chmod \- change file mode bits .SH SYNOPSIS diff --git a/src/bin/coreutils/man/chown.1 b/src/bin/coreutils/man/chown.1 index d11d3564c9..8dfb7a50aa 100644 --- a/src/bin/coreutils/man/chown.1 +++ b/src/bin/coreutils/man/chown.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHOWN "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CHOWN "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME chown \- change file owner and group .SH SYNOPSIS diff --git a/src/bin/coreutils/man/chroot.1 b/src/bin/coreutils/man/chroot.1 index 5efb00b732..56474d67fe 100644 --- a/src/bin/coreutils/man/chroot.1 +++ b/src/bin/coreutils/man/chroot.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHROOT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CHROOT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME chroot \- run command or interactive shell with special root directory .SH SYNOPSIS diff --git a/src/bin/coreutils/man/cksum.1 b/src/bin/coreutils/man/cksum.1 index 0ff754153a..98f08e008b 100644 --- a/src/bin/coreutils/man/cksum.1 +++ b/src/bin/coreutils/man/cksum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CKSUM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CKSUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME cksum \- checksum and count the bytes in a file .SH SYNOPSIS diff --git a/src/bin/coreutils/man/comm.1 b/src/bin/coreutils/man/comm.1 index 02d0570147..11f3632056 100644 --- a/src/bin/coreutils/man/comm.1 +++ b/src/bin/coreutils/man/comm.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH COMM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH COMM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME comm \- compare two sorted files line by line .SH SYNOPSIS diff --git a/src/bin/coreutils/man/cp.1 b/src/bin/coreutils/man/cp.1 index bd8bdf2327..0b0d99bbf4 100644 --- a/src/bin/coreutils/man/cp.1 +++ b/src/bin/coreutils/man/cp.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CP "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME cp \- copy files and directories .SH SYNOPSIS @@ -76,15 +76,15 @@ use full source file name under DIRECTORY \fB\-R\fR, \fB\-r\fR, \fB\-\-recursive\fR copy directories recursively .TP -\fB\-\-reflink\fR -perform a lightweight (CoW/clone) copy +\fB\-\-reflink\fR[=\fIWHEN\fR] +control clone/CoW copies. See below. .TP \fB\-\-remove\-destination\fR remove each existing destination file before attempting to open it (contrast with \fB\-\-force\fR) .TP \fB\-\-sparse\fR=\fIWHEN\fR -control creation of sparse files +control creation of sparse files. See below. .TP \fB\-\-strip\-trailing\-slashes\fR remove any trailing slashes from each SOURCE @@ -125,6 +125,10 @@ selected by \fB\-\-sparse\fR=\fIauto\fR. Specify \fB\-\-sparse\fR=\fIalways\fR file whenever the SOURCE file contains a long enough sequence of zero bytes. Use \fB\-\-sparse\fR=\fInever\fR to inhibit creation of sparse files. .PP +When \fB\-\-reflink\fR[=\fIalways\fR] is specified, perform a lightweight copy, where the +data blocks are copied only when modified. If this is not possible the copy +fails, or if \fB\-\-reflink\fR=\fIauto\fR is specified, fall back to a standard copy. +.PP The backup suffix is `~', unless set with \fB\-\-suffix\fR or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the \fB\-\-backup\fR option or through the VERSION_CONTROL environment variable. Here are the values: diff --git a/src/bin/coreutils/man/csplit.1 b/src/bin/coreutils/man/csplit.1 index cf414dabee..e55c3044eb 100644 --- a/src/bin/coreutils/man/csplit.1 +++ b/src/bin/coreutils/man/csplit.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CSPLIT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CSPLIT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME csplit \- split a file into sections determined by context lines .SH SYNOPSIS diff --git a/src/bin/coreutils/man/cut.1 b/src/bin/coreutils/man/cut.1 index 60c18f5a4f..d7e755b586 100644 --- a/src/bin/coreutils/man/cut.1 +++ b/src/bin/coreutils/man/cut.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CUT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH CUT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME cut \- remove sections from each line of files .SH SYNOPSIS diff --git a/src/bin/coreutils/man/date.1 b/src/bin/coreutils/man/date.1 index 6af07f5fda..55f485cc9b 100644 --- a/src/bin/coreutils/man/date.1 +++ b/src/bin/coreutils/man/date.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DATE "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH DATE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME date \- print or set the system date and time .SH SYNOPSIS diff --git a/src/bin/coreutils/man/dd.1 b/src/bin/coreutils/man/dd.1 index bc7161c08c..f6abea59a3 100644 --- a/src/bin/coreutils/man/dd.1 +++ b/src/bin/coreutils/man/dd.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DD "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH DD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME dd \- convert and copy a file .SH SYNOPSIS diff --git a/src/bin/coreutils/man/df.1 b/src/bin/coreutils/man/df.1 index 81ee94b65b..a60bdb53eb 100644 --- a/src/bin/coreutils/man/df.1 +++ b/src/bin/coreutils/man/df.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DF "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH DF "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME df \- report file system disk space usage .SH SYNOPSIS @@ -85,8 +85,12 @@ display this help and exit \fB\-\-version\fR output version information and exit .PP +Display values are in units of the first available SIZE from \fB\-\-block\-size\fR, +and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. +Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set). +.PP SIZE may be (or may be an integer optionally followed by) one of following: -kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. +KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .SH AUTHOR Written by Torbjorn Granlund, David MacKenzie, and Paul Eggert. .SH "REPORTING BUGS" diff --git a/src/bin/coreutils/man/dir.1 b/src/bin/coreutils/man/dir.1 index 7a6e1e4461..f43bd5f50d 100644 --- a/src/bin/coreutils/man/dir.1 +++ b/src/bin/coreutils/man/dir.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DIR "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH DIR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME dir \- list directory contents .SH SYNOPSIS @@ -26,7 +26,7 @@ with \fB\-l\fR, print the author of each file print octal escapes for nongraphic characters .TP \fB\-\-block\-size\fR=\fISIZE\fR -use SIZE\-byte blocks +use SIZE\-byte blocks. See SIZE format below .TP \fB\-B\fR, \fB\-\-ignore\-backups\fR do not list implied entries ending with ~ @@ -219,7 +219,7 @@ display this help and exit output version information and exit .PP SIZE may be (or may be an integer optionally followed by) one of following: -kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. +KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .PP By default, color is not used to distinguish types of files. That is equivalent to using \fB\-\-color\fR=\fInone\fR. Using the \fB\-\-color\fR option without the diff --git a/src/bin/coreutils/man/dircolors.1 b/src/bin/coreutils/man/dircolors.1 index eed77a14d8..a809bec585 100644 --- a/src/bin/coreutils/man/dircolors.1 +++ b/src/bin/coreutils/man/dircolors.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DIRCOLORS "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH DIRCOLORS "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME dircolors \- color setup for ls .SH SYNOPSIS diff --git a/src/bin/coreutils/man/dirname.1 b/src/bin/coreutils/man/dirname.1 index c3cc5809ca..c932f7a90a 100644 --- a/src/bin/coreutils/man/dirname.1 +++ b/src/bin/coreutils/man/dirname.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DIRNAME "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH DIRNAME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME dirname \- strip non-directory suffix from file name .SH SYNOPSIS diff --git a/src/bin/coreutils/man/du.1 b/src/bin/coreutils/man/du.1 index 812ab43688..07dd84e65d 100644 --- a/src/bin/coreutils/man/du.1 +++ b/src/bin/coreutils/man/du.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DU "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH DU "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME du \- estimate file space usage .SH SYNOPSIS @@ -109,8 +109,12 @@ display this help and exit \fB\-\-version\fR output version information and exit .PP +Display values are in units of the first available SIZE from \fB\-\-block\-size\fR, +and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. +Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set). +.PP SIZE may be (or may be an integer optionally followed by) one of following: -kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. +KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .SH PATTERNS PATTERN is a shell pattern (not a regular expression). The pattern .BR ? diff --git a/src/bin/coreutils/man/echo.1 b/src/bin/coreutils/man/echo.1 index 5709355353..09116a4d1e 100644 --- a/src/bin/coreutils/man/echo.1 +++ b/src/bin/coreutils/man/echo.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH ECHO "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH ECHO "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME echo \- display a line of text .SH SYNOPSIS diff --git a/src/bin/coreutils/man/env.1 b/src/bin/coreutils/man/env.1 index b2800fc63b..968f2416d0 100644 --- a/src/bin/coreutils/man/env.1 +++ b/src/bin/coreutils/man/env.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH ENV "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH ENV "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME env \- run a program in a modified environment .SH SYNOPSIS diff --git a/src/bin/coreutils/man/expand.1 b/src/bin/coreutils/man/expand.1 index 4a4c8c29ce..c23ddca735 100644 --- a/src/bin/coreutils/man/expand.1 +++ b/src/bin/coreutils/man/expand.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH EXPAND "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH EXPAND "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME expand \- convert tabs to spaces .SH SYNOPSIS diff --git a/src/bin/coreutils/man/expr.1 b/src/bin/coreutils/man/expr.1 index aec6eb07a7..60a521a85d 100644 --- a/src/bin/coreutils/man/expr.1 +++ b/src/bin/coreutils/man/expr.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH EXPR "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH EXPR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME expr \- evaluate expressions .SH SYNOPSIS diff --git a/src/bin/coreutils/man/factor.1 b/src/bin/coreutils/man/factor.1 index 051721b698..46ec988181 100644 --- a/src/bin/coreutils/man/factor.1 +++ b/src/bin/coreutils/man/factor.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH FACTOR "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH FACTOR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME factor \- factor numbers .SH SYNOPSIS diff --git a/src/bin/coreutils/man/false.1 b/src/bin/coreutils/man/false.1 index 27ee9bcda2..6f0414aefc 100644 --- a/src/bin/coreutils/man/false.1 +++ b/src/bin/coreutils/man/false.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH FALSE "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH FALSE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME false \- do nothing, unsuccessfully .SH SYNOPSIS diff --git a/src/bin/coreutils/man/fmt.1 b/src/bin/coreutils/man/fmt.1 index dac1ca5166..13fc3fae80 100644 --- a/src/bin/coreutils/man/fmt.1 +++ b/src/bin/coreutils/man/fmt.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH FMT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH FMT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME fmt \- simple optimal text formatter .SH SYNOPSIS diff --git a/src/bin/coreutils/man/fold.1 b/src/bin/coreutils/man/fold.1 index 5e84ff17c0..34bbfee02a 100644 --- a/src/bin/coreutils/man/fold.1 +++ b/src/bin/coreutils/man/fold.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH FOLD "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH FOLD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME fold \- wrap each input line to fit in specified width .SH SYNOPSIS diff --git a/src/bin/coreutils/man/groups.1 b/src/bin/coreutils/man/groups.1 index 5f4eb5dc35..37495096c1 100644 --- a/src/bin/coreutils/man/groups.1 +++ b/src/bin/coreutils/man/groups.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH GROUPS "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH GROUPS "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME groups \- print the groups a user is in .SH SYNOPSIS diff --git a/src/bin/coreutils/man/head.1 b/src/bin/coreutils/man/head.1 index f276751248..1aae44e475 100644 --- a/src/bin/coreutils/man/head.1 +++ b/src/bin/coreutils/man/head.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH HEAD "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH HEAD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME head \- output the first part of files .SH SYNOPSIS diff --git a/src/bin/coreutils/man/hostid.1 b/src/bin/coreutils/man/hostid.1 index 6d3cc73032..2bdfa2bf63 100644 --- a/src/bin/coreutils/man/hostid.1 +++ b/src/bin/coreutils/man/hostid.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH HOSTID "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH HOSTID "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME hostid \- print the numeric identifier for the current host .SH SYNOPSIS diff --git a/src/bin/coreutils/man/id.1 b/src/bin/coreutils/man/id.1 index b1fffefc5f..9828ec11e6 100644 --- a/src/bin/coreutils/man/id.1 +++ b/src/bin/coreutils/man/id.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH ID "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH ID "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME id \- print real and effective user and group IDs .SH SYNOPSIS diff --git a/src/bin/coreutils/man/install.1 b/src/bin/coreutils/man/install.1 index 79a9dc07d2..01f3c774f8 100644 --- a/src/bin/coreutils/man/install.1 +++ b/src/bin/coreutils/man/install.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH INSTALL "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH INSTALL "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME install \- copy files and set attributes .SH SYNOPSIS diff --git a/src/bin/coreutils/man/join.1 b/src/bin/coreutils/man/join.1 index d0b8efc0cb..17892c27f7 100644 --- a/src/bin/coreutils/man/join.1 +++ b/src/bin/coreutils/man/join.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH JOIN "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH JOIN "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME join \- join lines of two files on a common field .SH SYNOPSIS diff --git a/src/bin/coreutils/man/kill.1 b/src/bin/coreutils/man/kill.1 index 0bbab0bc37..df84fab3d3 100644 --- a/src/bin/coreutils/man/kill.1 +++ b/src/bin/coreutils/man/kill.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH KILL "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH KILL "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME kill \- send signals to processes, or list signals .SH SYNOPSIS diff --git a/src/bin/coreutils/man/link.1 b/src/bin/coreutils/man/link.1 index ec46947225..3cd7291b97 100644 --- a/src/bin/coreutils/man/link.1 +++ b/src/bin/coreutils/man/link.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH LINK "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH LINK "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME link \- call the link function to create a link to a file .SH SYNOPSIS diff --git a/src/bin/coreutils/man/ln.1 b/src/bin/coreutils/man/ln.1 index 6da8d74d3f..e0d5c6d572 100644 --- a/src/bin/coreutils/man/ln.1 +++ b/src/bin/coreutils/man/ln.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH LN "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH LN "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME ln \- make links between files .SH SYNOPSIS diff --git a/src/bin/coreutils/man/logname.1 b/src/bin/coreutils/man/logname.1 index b3eafaf1b2..a96a9756a9 100644 --- a/src/bin/coreutils/man/logname.1 +++ b/src/bin/coreutils/man/logname.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH LOGNAME "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH LOGNAME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME logname \- print user\'s login name .SH SYNOPSIS diff --git a/src/bin/coreutils/man/ls.1 b/src/bin/coreutils/man/ls.1 index 711592d0ee..d24e1892ef 100644 --- a/src/bin/coreutils/man/ls.1 +++ b/src/bin/coreutils/man/ls.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH LS "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH LS "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME ls \- list directory contents .SH SYNOPSIS @@ -26,7 +26,7 @@ with \fB\-l\fR, print the author of each file print octal escapes for nongraphic characters .TP \fB\-\-block\-size\fR=\fISIZE\fR -use SIZE\-byte blocks +use SIZE\-byte blocks. See SIZE format below .TP \fB\-B\fR, \fB\-\-ignore\-backups\fR do not list implied entries ending with ~ @@ -219,7 +219,7 @@ display this help and exit output version information and exit .PP SIZE may be (or may be an integer optionally followed by) one of following: -kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. +KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .PP By default, color is not used to distinguish types of files. That is equivalent to using \fB\-\-color\fR=\fInone\fR. Using the \fB\-\-color\fR option without the diff --git a/src/bin/coreutils/man/md5sum.1 b/src/bin/coreutils/man/md5sum.1 index ce2050ffa6..61cdbe5999 100644 --- a/src/bin/coreutils/man/md5sum.1 +++ b/src/bin/coreutils/man/md5sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MD5SUM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH MD5SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME md5sum \- compute and check MD5 message digest .SH SYNOPSIS diff --git a/src/bin/coreutils/man/mkdir.1 b/src/bin/coreutils/man/mkdir.1 index eec7739d3b..cd19ae0875 100644 --- a/src/bin/coreutils/man/mkdir.1 +++ b/src/bin/coreutils/man/mkdir.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MKDIR "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH MKDIR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME mkdir \- make directories .SH SYNOPSIS diff --git a/src/bin/coreutils/man/mkfifo.1 b/src/bin/coreutils/man/mkfifo.1 index 7170da1041..d86c1651d8 100644 --- a/src/bin/coreutils/man/mkfifo.1 +++ b/src/bin/coreutils/man/mkfifo.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MKFIFO "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH MKFIFO "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME mkfifo \- make FIFOs (named pipes) .SH SYNOPSIS diff --git a/src/bin/coreutils/man/mknod.1 b/src/bin/coreutils/man/mknod.1 index 17697be0d3..1ebf8dea7a 100644 --- a/src/bin/coreutils/man/mknod.1 +++ b/src/bin/coreutils/man/mknod.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MKNOD "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH MKNOD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME mknod \- make block or character special files .SH SYNOPSIS diff --git a/src/bin/coreutils/man/mktemp.1 b/src/bin/coreutils/man/mktemp.1 index 6a9ec09457..9ec1b6299e 100644 --- a/src/bin/coreutils/man/mktemp.1 +++ b/src/bin/coreutils/man/mktemp.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MKTEMP "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH MKTEMP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME mktemp \- create a temporary file or directory .SH SYNOPSIS diff --git a/src/bin/coreutils/man/mv.1 b/src/bin/coreutils/man/mv.1 index adac335b9c..59e67c5964 100644 --- a/src/bin/coreutils/man/mv.1 +++ b/src/bin/coreutils/man/mv.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MV "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH MV "1" "September 2009" "GNU coreutils 7.6" "User Commands" .SH NAME mv \- move (rename) files .SH SYNOPSIS diff --git a/src/bin/coreutils/man/nice.1 b/src/bin/coreutils/man/nice.1 index a09a589e87..88713994bd 100644 --- a/src/bin/coreutils/man/nice.1 +++ b/src/bin/coreutils/man/nice.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH NICE "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH NICE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME nice \- run a program with modified scheduling priority .SH SYNOPSIS diff --git a/src/bin/coreutils/man/nl.1 b/src/bin/coreutils/man/nl.1 index 8ac41f5b8c..b59eb1a7af 100644 --- a/src/bin/coreutils/man/nl.1 +++ b/src/bin/coreutils/man/nl.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH NL "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH NL "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME nl \- number lines of files .SH SYNOPSIS diff --git a/src/bin/coreutils/man/nohup.1 b/src/bin/coreutils/man/nohup.1 index 5ff20dcf32..26cca3fed2 100644 --- a/src/bin/coreutils/man/nohup.1 +++ b/src/bin/coreutils/man/nohup.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH NOHUP "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH NOHUP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME nohup \- run a command immune to hangups, with output to a non-tty .SH SYNOPSIS diff --git a/src/bin/coreutils/man/od.1 b/src/bin/coreutils/man/od.1 index ea7acb69bc..b484db1291 100644 --- a/src/bin/coreutils/man/od.1 +++ b/src/bin/coreutils/man/od.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH OD "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH OD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME od \- dump files in octal and other formats .SH SYNOPSIS diff --git a/src/bin/coreutils/man/paste.1 b/src/bin/coreutils/man/paste.1 index bde95269c6..60875fdb2a 100644 --- a/src/bin/coreutils/man/paste.1 +++ b/src/bin/coreutils/man/paste.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PASTE "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH PASTE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME paste \- merge lines of files .SH SYNOPSIS diff --git a/src/bin/coreutils/man/pathchk.1 b/src/bin/coreutils/man/pathchk.1 index 5e3ec94782..b3fc4c250a 100644 --- a/src/bin/coreutils/man/pathchk.1 +++ b/src/bin/coreutils/man/pathchk.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PATHCHK "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH PATHCHK "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME pathchk \- check whether file names are valid or portable .SH SYNOPSIS diff --git a/src/bin/coreutils/man/pinky.1 b/src/bin/coreutils/man/pinky.1 index ed52dee25d..b02ad79cbb 100644 --- a/src/bin/coreutils/man/pinky.1 +++ b/src/bin/coreutils/man/pinky.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PINKY "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH PINKY "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME pinky \- lightweight finger .SH SYNOPSIS diff --git a/src/bin/coreutils/man/pr.1 b/src/bin/coreutils/man/pr.1 index 5261713a49..1fde89fb23 100644 --- a/src/bin/coreutils/man/pr.1 +++ b/src/bin/coreutils/man/pr.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PR "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH PR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME pr \- convert text files for printing .SH SYNOPSIS diff --git a/src/bin/coreutils/man/printenv.1 b/src/bin/coreutils/man/printenv.1 index 63a719f521..d5e8ff81ee 100644 --- a/src/bin/coreutils/man/printenv.1 +++ b/src/bin/coreutils/man/printenv.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PRINTENV "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH PRINTENV "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME printenv \- print all or part of environment .SH SYNOPSIS diff --git a/src/bin/coreutils/man/printf.1 b/src/bin/coreutils/man/printf.1 index 9b8325c0c7..402ed4f13d 100644 --- a/src/bin/coreutils/man/printf.1 +++ b/src/bin/coreutils/man/printf.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PRINTF "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH PRINTF "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME printf \- format and print data .SH SYNOPSIS diff --git a/src/bin/coreutils/man/ptx.1 b/src/bin/coreutils/man/ptx.1 index 8f204a3c66..97336989ea 100644 --- a/src/bin/coreutils/man/ptx.1 +++ b/src/bin/coreutils/man/ptx.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PTX "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH PTX "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME ptx \- produce a permuted index of file contents .SH SYNOPSIS diff --git a/src/bin/coreutils/man/pwd.1 b/src/bin/coreutils/man/pwd.1 index 5ada17d343..0b48063ead 100644 --- a/src/bin/coreutils/man/pwd.1 +++ b/src/bin/coreutils/man/pwd.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PWD "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH PWD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME pwd \- print name of current/working directory .SH SYNOPSIS diff --git a/src/bin/coreutils/man/readlink.1 b/src/bin/coreutils/man/readlink.1 index f5c74d4211..afefcc5a21 100644 --- a/src/bin/coreutils/man/readlink.1 +++ b/src/bin/coreutils/man/readlink.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH READLINK "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH READLINK "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME readlink \- print value of a symbolic link or canonical file name .SH SYNOPSIS diff --git a/src/bin/coreutils/man/rm.1 b/src/bin/coreutils/man/rm.1 index e0542b7b73..bf545d6e5b 100644 --- a/src/bin/coreutils/man/rm.1 +++ b/src/bin/coreutils/man/rm.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH RM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH RM "1" "September 2009" "GNU coreutils 7.6" "User Commands" .SH NAME rm \- remove files or directories .SH SYNOPSIS diff --git a/src/bin/coreutils/man/rmdir.1 b/src/bin/coreutils/man/rmdir.1 index c3189e12c5..0389e98ec0 100644 --- a/src/bin/coreutils/man/rmdir.1 +++ b/src/bin/coreutils/man/rmdir.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH RMDIR "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH RMDIR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME rmdir \- remove empty directories .SH SYNOPSIS diff --git a/src/bin/coreutils/man/runcon.1 b/src/bin/coreutils/man/runcon.1 index 4bb0ae7fc4..1dd05c2f43 100644 --- a/src/bin/coreutils/man/runcon.1 +++ b/src/bin/coreutils/man/runcon.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH RUNCON "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH RUNCON "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME runcon \- run command with specified security context .SH SYNOPSIS diff --git a/src/bin/coreutils/man/seq.1 b/src/bin/coreutils/man/seq.1 index 683316173a..6fcc8a24a1 100644 --- a/src/bin/coreutils/man/seq.1 +++ b/src/bin/coreutils/man/seq.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SEQ "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SEQ "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME seq \- print a sequence of numbers .SH SYNOPSIS diff --git a/src/bin/coreutils/man/sha1sum.1 b/src/bin/coreutils/man/sha1sum.1 index 9b85c87beb..7b749c1264 100644 --- a/src/bin/coreutils/man/sha1sum.1 +++ b/src/bin/coreutils/man/sha1sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA1SUM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SHA1SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME sha1sum \- compute and check SHA1 message digest .SH SYNOPSIS diff --git a/src/bin/coreutils/man/sha224sum.1 b/src/bin/coreutils/man/sha224sum.1 index 30ed604353..bf0b12b17e 100644 --- a/src/bin/coreutils/man/sha224sum.1 +++ b/src/bin/coreutils/man/sha224sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA224SUM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SHA224SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME sha224sum \- compute and check SHA224 message digest .SH SYNOPSIS diff --git a/src/bin/coreutils/man/sha256sum.1 b/src/bin/coreutils/man/sha256sum.1 index dc30d40e6f..4b405fcb1f 100644 --- a/src/bin/coreutils/man/sha256sum.1 +++ b/src/bin/coreutils/man/sha256sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA256SUM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SHA256SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME sha256sum \- compute and check SHA256 message digest .SH SYNOPSIS diff --git a/src/bin/coreutils/man/sha384sum.1 b/src/bin/coreutils/man/sha384sum.1 index 5f72be23f4..59f8e1f0f0 100644 --- a/src/bin/coreutils/man/sha384sum.1 +++ b/src/bin/coreutils/man/sha384sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA384SUM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SHA384SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME sha384sum \- compute and check SHA384 message digest .SH SYNOPSIS diff --git a/src/bin/coreutils/man/sha512sum.1 b/src/bin/coreutils/man/sha512sum.1 index 9f1743d233..b643551ad1 100644 --- a/src/bin/coreutils/man/sha512sum.1 +++ b/src/bin/coreutils/man/sha512sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA512SUM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SHA512SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME sha512sum \- compute and check SHA512 message digest .SH SYNOPSIS diff --git a/src/bin/coreutils/man/shred.1 b/src/bin/coreutils/man/shred.1 index 813e66c3ea..e05015e8ba 100644 --- a/src/bin/coreutils/man/shred.1 +++ b/src/bin/coreutils/man/shred.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHRED "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SHRED "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME shred \- overwrite a file to hide its contents, and optionally delete it .SH SYNOPSIS diff --git a/src/bin/coreutils/man/shuf.1 b/src/bin/coreutils/man/shuf.1 index 2c38a7a552..5e31584855 100644 --- a/src/bin/coreutils/man/shuf.1 +++ b/src/bin/coreutils/man/shuf.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHUF "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SHUF "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME shuf \- generate random permutations .SH SYNOPSIS diff --git a/src/bin/coreutils/man/sleep.1 b/src/bin/coreutils/man/sleep.1 index 21c4e00da1..b08123e43d 100644 --- a/src/bin/coreutils/man/sleep.1 +++ b/src/bin/coreutils/man/sleep.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SLEEP "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SLEEP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME sleep \- delay for a specified amount of time .SH SYNOPSIS diff --git a/src/bin/coreutils/man/sort.1 b/src/bin/coreutils/man/sort.1 index 289cecb396..b990929dcf 100644 --- a/src/bin/coreutils/man/sort.1 +++ b/src/bin/coreutils/man/sort.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SORT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SORT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME sort \- sort lines of text files .SH SYNOPSIS diff --git a/src/bin/coreutils/man/split.1 b/src/bin/coreutils/man/split.1 index e744b1b232..2a0870b6ea 100644 --- a/src/bin/coreutils/man/split.1 +++ b/src/bin/coreutils/man/split.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SPLIT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SPLIT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME split \- split a file into pieces .SH SYNOPSIS @@ -39,9 +39,8 @@ display this help and exit \fB\-\-version\fR output version information and exit .PP -SIZE may have a multiplier suffix: -b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, -GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y. +SIZE may be (or may be an integer optionally followed by) one of following: +KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .SH AUTHOR Written by Torbjorn Granlund and Richard M. Stallman. .SH "REPORTING BUGS" diff --git a/src/bin/coreutils/man/stat.1 b/src/bin/coreutils/man/stat.1 index 35bb33fae0..280e6b17d1 100644 --- a/src/bin/coreutils/man/stat.1 +++ b/src/bin/coreutils/man/stat.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH STAT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH STAT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME stat \- display file or file system status .SH SYNOPSIS diff --git a/src/bin/coreutils/man/stdbuf.1 b/src/bin/coreutils/man/stdbuf.1 index 354cea4a22..ae9d862a2e 100644 --- a/src/bin/coreutils/man/stdbuf.1 +++ b/src/bin/coreutils/man/stdbuf.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH STDBUF "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH STDBUF "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME stdbuf \- Run COMMAND, with modified buffering operations for its standard streams. .SH SYNOPSIS @@ -27,10 +27,10 @@ display this help and exit \fB\-\-version\fR output version information and exit .PP -If MODE is `L' then corresponding stream will be line buffered. +If MODE is `L' the corresponding stream will be line buffered. This option is invalid with standard input. .PP -If MODE is `0' then corresponding stream will be unbuffered. +If MODE is `0' the corresponding stream will be unbuffered. .PP Otherwise MODE is a number which may be followed by one of the following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. diff --git a/src/bin/coreutils/man/stty.1 b/src/bin/coreutils/man/stty.1 index 5124bfbcbc..39479e38d4 100644 --- a/src/bin/coreutils/man/stty.1 +++ b/src/bin/coreutils/man/stty.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH STTY "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH STTY "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME stty \- change and print terminal line settings .SH SYNOPSIS diff --git a/src/bin/coreutils/man/sum.1 b/src/bin/coreutils/man/sum.1 index 6d0d4eb4a0..89c2619592 100644 --- a/src/bin/coreutils/man/sum.1 +++ b/src/bin/coreutils/man/sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SUM "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME sum \- checksum and count the blocks in a file .SH SYNOPSIS diff --git a/src/bin/coreutils/man/sync.1 b/src/bin/coreutils/man/sync.1 index 57d9f0c102..af8b707852 100644 --- a/src/bin/coreutils/man/sync.1 +++ b/src/bin/coreutils/man/sync.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SYNC "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH SYNC "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME sync \- flush file system buffers .SH SYNOPSIS diff --git a/src/bin/coreutils/man/tac.1 b/src/bin/coreutils/man/tac.1 index 36e5145d76..744a7655be 100644 --- a/src/bin/coreutils/man/tac.1 +++ b/src/bin/coreutils/man/tac.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TAC "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TAC "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME tac \- concatenate and print files in reverse .SH SYNOPSIS diff --git a/src/bin/coreutils/man/tail.1 b/src/bin/coreutils/man/tail.1 index d2d2636050..2e11a4865e 100644 --- a/src/bin/coreutils/man/tail.1 +++ b/src/bin/coreutils/man/tail.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TAIL "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TAIL "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME tail \- output the last part of files .SH SYNOPSIS @@ -47,8 +47,8 @@ keep trying to open a file even when it is or becomes inaccessible; useful when following by name, i.e., with \fB\-\-follow\fR=\fIname\fR .TP -\fB\-s\fR, \fB\-\-sleep\-interval\fR=\fIS\fR -with \fB\-f\fR, sleep for approximately S seconds +\fB\-s\fR, \fB\-\-sleep\-interval\fR=\fIN\fR +with \fB\-f\fR, sleep for approximately N seconds (default 1.0) between iterations .TP \fB\-v\fR, \fB\-\-verbose\fR diff --git a/src/bin/coreutils/man/tee.1 b/src/bin/coreutils/man/tee.1 index 957a38c172..39e8879f89 100644 --- a/src/bin/coreutils/man/tee.1 +++ b/src/bin/coreutils/man/tee.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TEE "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TEE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME tee \- read from standard input and write to standard output and files .SH SYNOPSIS diff --git a/src/bin/coreutils/man/test.1 b/src/bin/coreutils/man/test.1 index 8ed6dac63c..4736c97c7f 100644 --- a/src/bin/coreutils/man/test.1 +++ b/src/bin/coreutils/man/test.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TEST "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TEST "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME test \- check file types and compare values .SH SYNOPSIS diff --git a/src/bin/coreutils/man/timeout.1 b/src/bin/coreutils/man/timeout.1 index 00b4112f2e..0442eadc9c 100644 --- a/src/bin/coreutils/man/timeout.1 +++ b/src/bin/coreutils/man/timeout.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TIMEOUT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TIMEOUT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME timeout \- run a command with a time limit .SH SYNOPSIS diff --git a/src/bin/coreutils/man/touch.1 b/src/bin/coreutils/man/touch.1 index 1a5819b2ea..13bde42366 100644 --- a/src/bin/coreutils/man/touch.1 +++ b/src/bin/coreutils/man/touch.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TOUCH "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TOUCH "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME touch \- change file timestamps .SH SYNOPSIS diff --git a/src/bin/coreutils/man/tr.1 b/src/bin/coreutils/man/tr.1 index 7e9fb178f1..831178623c 100644 --- a/src/bin/coreutils/man/tr.1 +++ b/src/bin/coreutils/man/tr.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TR "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME tr \- translate or delete characters .SH SYNOPSIS diff --git a/src/bin/coreutils/man/true.1 b/src/bin/coreutils/man/true.1 index 94a61e7071..5f9a205b67 100644 --- a/src/bin/coreutils/man/true.1 +++ b/src/bin/coreutils/man/true.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TRUE "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TRUE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME true \- do nothing, successfully .SH SYNOPSIS diff --git a/src/bin/coreutils/man/truncate.1 b/src/bin/coreutils/man/truncate.1 index 1d4bb2b3c1..d0d1c1a487 100644 --- a/src/bin/coreutils/man/truncate.1 +++ b/src/bin/coreutils/man/truncate.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TRUNCATE "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TRUNCATE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME truncate \- shrink or extend the size of a file to the specified size .SH SYNOPSIS @@ -36,7 +36,7 @@ display this help and exit \fB\-\-version\fR output version information and exit .PP -SIZE is a number which may be followed by one of the following suffixes: +SIZE may be (or may be an integer optionally followed by) one of following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .PP SIZE may also be prefixed by one of the following modifying characters: diff --git a/src/bin/coreutils/man/tsort.1 b/src/bin/coreutils/man/tsort.1 index c9a0b349d4..f83d94ebf7 100644 --- a/src/bin/coreutils/man/tsort.1 +++ b/src/bin/coreutils/man/tsort.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TSORT "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TSORT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME tsort \- perform topological sort .SH SYNOPSIS diff --git a/src/bin/coreutils/man/tty.1 b/src/bin/coreutils/man/tty.1 index cc2340f443..b34f5076e0 100644 --- a/src/bin/coreutils/man/tty.1 +++ b/src/bin/coreutils/man/tty.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TTY "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH TTY "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME tty \- print the file name of the terminal connected to standard input .SH SYNOPSIS diff --git a/src/bin/coreutils/man/uname.1 b/src/bin/coreutils/man/uname.1 index e66364d677..a879de7eb5 100644 --- a/src/bin/coreutils/man/uname.1 +++ b/src/bin/coreutils/man/uname.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UNAME "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH UNAME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME uname \- print system information .SH SYNOPSIS diff --git a/src/bin/coreutils/man/unexpand.1 b/src/bin/coreutils/man/unexpand.1 index d0844ab815..bc63e0dfb2 100644 --- a/src/bin/coreutils/man/unexpand.1 +++ b/src/bin/coreutils/man/unexpand.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UNEXPAND "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH UNEXPAND "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME unexpand \- convert spaces to tabs .SH SYNOPSIS diff --git a/src/bin/coreutils/man/uniq.1 b/src/bin/coreutils/man/uniq.1 index 2f1594c69b..c28d92e040 100644 --- a/src/bin/coreutils/man/uniq.1 +++ b/src/bin/coreutils/man/uniq.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UNIQ "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH UNIQ "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME uniq \- report or omit repeated lines .SH SYNOPSIS diff --git a/src/bin/coreutils/man/unlink.1 b/src/bin/coreutils/man/unlink.1 index 8cb8e0ee95..8209c93d88 100644 --- a/src/bin/coreutils/man/unlink.1 +++ b/src/bin/coreutils/man/unlink.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UNLINK "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH UNLINK "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME unlink \- call the unlink function to remove the specified file .SH SYNOPSIS diff --git a/src/bin/coreutils/man/uptime.1 b/src/bin/coreutils/man/uptime.1 index 578bceca41..4ac0bdf331 100644 --- a/src/bin/coreutils/man/uptime.1 +++ b/src/bin/coreutils/man/uptime.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UPTIME "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH UPTIME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME uptime \- tell how long the system has been running .SH SYNOPSIS diff --git a/src/bin/coreutils/man/users.1 b/src/bin/coreutils/man/users.1 index 4fd766a5c0..a4b6728dc4 100644 --- a/src/bin/coreutils/man/users.1 +++ b/src/bin/coreutils/man/users.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH USERS "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH USERS "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME users \- print the user names of users currently logged in to the current host .SH SYNOPSIS diff --git a/src/bin/coreutils/man/vdir.1 b/src/bin/coreutils/man/vdir.1 index 580080b8b8..baaac9ee36 100644 --- a/src/bin/coreutils/man/vdir.1 +++ b/src/bin/coreutils/man/vdir.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH VDIR "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH VDIR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME vdir \- list directory contents .SH SYNOPSIS @@ -26,7 +26,7 @@ with \fB\-l\fR, print the author of each file print octal escapes for nongraphic characters .TP \fB\-\-block\-size\fR=\fISIZE\fR -use SIZE\-byte blocks +use SIZE\-byte blocks. See SIZE format below .TP \fB\-B\fR, \fB\-\-ignore\-backups\fR do not list implied entries ending with ~ @@ -219,7 +219,7 @@ display this help and exit output version information and exit .PP SIZE may be (or may be an integer optionally followed by) one of following: -kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. +KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .PP By default, color is not used to distinguish types of files. That is equivalent to using \fB\-\-color\fR=\fInone\fR. Using the \fB\-\-color\fR option without the diff --git a/src/bin/coreutils/man/wc.1 b/src/bin/coreutils/man/wc.1 index 21011d0dd2..49bf92f689 100644 --- a/src/bin/coreutils/man/wc.1 +++ b/src/bin/coreutils/man/wc.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH WC "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH WC "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME wc \- print newline, word, and byte counts for each file .SH SYNOPSIS diff --git a/src/bin/coreutils/man/who.1 b/src/bin/coreutils/man/who.1 index cfc2f7f963..e2b002779e 100644 --- a/src/bin/coreutils/man/who.1 +++ b/src/bin/coreutils/man/who.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH WHO "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH WHO "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME who \- show who is logged on .SH SYNOPSIS diff --git a/src/bin/coreutils/man/whoami.1 b/src/bin/coreutils/man/whoami.1 index 39d5895029..393fd34d7c 100644 --- a/src/bin/coreutils/man/whoami.1 +++ b/src/bin/coreutils/man/whoami.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH WHOAMI "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH WHOAMI "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME whoami \- print effective userid .SH SYNOPSIS diff --git a/src/bin/coreutils/man/yes.1 b/src/bin/coreutils/man/yes.1 index d0633c21d8..d31d977be3 100644 --- a/src/bin/coreutils/man/yes.1 +++ b/src/bin/coreutils/man/yes.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH YES "1" "August 2009" "GNU coreutils 7.5" "User Commands" +.TH YES "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" .SH NAME yes \- output a string repeatedly until killed .SH SYNOPSIS diff --git a/src/bin/coreutils/src/Jamfile b/src/bin/coreutils/src/Jamfile index 49bf75ee4e..98d6be9d95 100644 --- a/src/bin/coreutils/src/Jamfile +++ b/src/bin/coreutils/src/Jamfile @@ -4,7 +4,7 @@ SubDir HAIKU_TOP src bin coreutils src ; TARGET_WARNING_CCFLAGS = [ FFilter $(TARGET_WARNING_CCFLAGS) : -Wall -Wmissing-prototypes -Wsign-compare ] ; -SubDirCcFlags -DHAVE_CONFIG_H ; +SubDirCcFlags -DHAVE_CONFIG_H -DB_ENABLE_INCOMPLETE_POSIX_AT_SUPPORT ; SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) lib ] ; local coreutils_rsrc = [ FGristFiles coreutils.rsrc ] ; diff --git a/src/bin/coreutils/src/Makefile.am b/src/bin/coreutils/src/Makefile.am index a03c16eca9..90e11c65a7 100644 --- a/src/bin/coreutils/src/Makefile.am +++ b/src/bin/coreutils/src/Makefile.am @@ -385,21 +385,21 @@ pr = progs-readme check: check-README check-duplicate-no-install .PHONY: check-README check-README: - rm -rf $(pr) $(pm) - echo $(all_programs) \ + $(AM_V_GEN)rm -rf $(pr) $(pm) + $(AM_V_at)echo $(all_programs) \ | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \ | sed /libstdbuf/d \ | $(ASSORT) -u > $(pm) && \ sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \ | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr) - diff $(pm) $(pr) && rm -rf $(pr) $(pm) + $(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm) # Ensure that a by-default-not-installed program (listed in # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because # if that were to happen, it *would* be installed by default. .PHONY: check-duplicate-no-install check-duplicate-no-install: tr - test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`" + $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`" # Ensure that the list of programs and author names is accurate. # We need a UTF8 locale. If a lack of locale support or a missing diff --git a/src/bin/coreutils/src/Makefile.in b/src/bin/coreutils/src/Makefile.in index 880f8e121d..da9a05dbfd 100644 --- a/src/bin/coreutils/src/Makefile.in +++ b/src/bin/coreutils/src/Makefile.in @@ -81,22 +81,23 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ - $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ - $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ - $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ - $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ - $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ + $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ + $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ + $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ + $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ + $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ - $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ - $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ - $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ + $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ + $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ + $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ + $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ @@ -138,37 +139,38 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ - $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ - $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/long-options.m4 \ - $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ - $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ - $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ - $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ - $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ - $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ - $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbsrtowcs.m4 \ - $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/mbswidth.m4 \ - $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memcasecmp.m4 \ - $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/memcmp.m4 \ - $(top_srcdir)/m4/memcoll.m4 $(top_srcdir)/m4/memcpy.m4 \ - $(top_srcdir)/m4/memmove.m4 $(top_srcdir)/m4/mempcpy.m4 \ - $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/memset.m4 \ - $(top_srcdir)/m4/memxfrm.m4 $(top_srcdir)/m4/mgetgroups.m4 \ - $(top_srcdir)/m4/mkancesdirs.m4 $(top_srcdir)/m4/mkdir-p.m4 \ - $(top_srcdir)/m4/mkdir-slash.m4 $(top_srcdir)/m4/mkstemp.m4 \ - $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ - $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/modechange.m4 \ - $(top_srcdir)/m4/mountlist.m4 $(top_srcdir)/m4/mpsort.m4 \ - $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/nanosleep.m4 \ - $(top_srcdir)/m4/netdb_h.m4 $(top_srcdir)/m4/netinet_in_h.m4 \ - $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/nocrash.m4 \ - $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ - $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ - $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ - $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ - $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ + $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ + $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ + $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ + $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ + $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ + $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ + $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ + $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ + $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ + $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/memcmp.m4 $(top_srcdir)/m4/memcoll.m4 \ + $(top_srcdir)/m4/memcpy.m4 $(top_srcdir)/m4/memmove.m4 \ + $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ + $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ + $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ + $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ + $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ + $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ + $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ + $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ + $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ + $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ + $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ @@ -847,6 +849,7 @@ GLIBC21 = @GLIBC21@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GNULIB_ACCEPT = @GNULIB_ACCEPT@ +GNULIB_ACCEPT4 = @GNULIB_ACCEPT4@ GNULIB_ALPHASORT = @GNULIB_ALPHASORT@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ @@ -860,10 +863,15 @@ GNULIB_CONNECT = @GNULIB_CONNECT@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ +GNULIB_DUP3 = @GNULIB_DUP3@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ +GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ +GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ +GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ GNULIB_FLOORL = @GNULIB_FLOORL@ @@ -878,6 +886,7 @@ GNULIB_FREXP = @GNULIB_FREXP@ GNULIB_FREXPL = @GNULIB_FREXPL@ GNULIB_FSEEK = @GNULIB_FSEEK@ GNULIB_FSEEKO = @GNULIB_FSEEKO@ +GNULIB_FSTATAT = @GNULIB_FSTATAT@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ @@ -941,12 +950,19 @@ GNULIB_MEMCHR = @GNULIB_MEMCHR@ GNULIB_MEMMEM = @GNULIB_MEMMEM@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ +GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNODAT = @GNULIB_MKNODAT@ +GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ +GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ +GNULIB_PIPE2 = @GNULIB_PIPE2@ +GNULIB_POPEN = @GNULIB_POPEN@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -956,9 +972,11 @@ GNULIB_PUTS = @GNULIB_PUTS@ GNULIB_RANDOM_R = @GNULIB_RANDOM_R@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ +GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_RENAME = @GNULIB_RENAME@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -998,11 +1016,13 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ @@ -1019,6 +1039,7 @@ GNULIB_WCTOB = @GNULIB_WCTOB@ GNULIB_WCWIDTH = @GNULIB_WCWIDTH@ GNULIB_WRITE = @GNULIB_WRITE@ GREP = @GREP@ +HAVE_ACCEPT4 = @HAVE_ACCEPT4@ HAVE_ALPHASORT = @HAVE_ALPHASORT@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ @@ -1069,8 +1090,14 @@ HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@ HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@ HAVE_DPRINTF = @HAVE_DPRINTF@ HAVE_DUP2 = @HAVE_DUP2@ +HAVE_DUP3 = @HAVE_DUP3@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ +HAVE_FACCESSAT = @HAVE_FACCESSAT@ +HAVE_FCHMODAT = @HAVE_FCHMODAT@ +HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ HAVE_FSEEKO = @HAVE_FSEEKO@ +HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ @@ -1096,15 +1123,22 @@ HAVE_MBSINIT = @HAVE_MBSINIT@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ +HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNODAT = @HAVE_MKNODAT@ +HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ +HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ +HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ @@ -1122,7 +1156,6 @@ HAVE_STPCPY = @HAVE_STPCPY@ HAVE_STPNCPY = @HAVE_STPNCPY@ HAVE_STRCASESTR = @HAVE_STRCASESTR@ HAVE_STRCHRNUL = @HAVE_STRCHRNUL@ -HAVE_STRNDUP = @HAVE_STRNDUP@ HAVE_STRPBRK = @HAVE_STRPBRK@ HAVE_STRSEP = @HAVE_STRSEP@ HAVE_STRTOD = @HAVE_STRTOD@ @@ -1134,6 +1167,8 @@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ +HAVE_SYMLINK = @HAVE_SYMLINK@ +HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@ HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@ HAVE_SYS_IOCTL_H = @HAVE_SYS_IOCTL_H@ @@ -1145,6 +1180,7 @@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ +HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ @@ -1297,6 +1333,7 @@ REPLACE_CLOSE = @REPLACE_CLOSE@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ REPLACE_DUP2 = @REPLACE_DUP2@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ +REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ @@ -1309,6 +1346,7 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ REPLACE_GETCWD = @REPLACE_GETCWD@ @@ -1325,6 +1363,7 @@ REPLACE_ISNAN = @REPLACE_ISNAN@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ +REPLACE_LINK = @REPLACE_LINK@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -1345,8 +1384,10 @@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ REPLACE_PERROR = @REPLACE_PERROR@ +REPLACE_POPEN = @REPLACE_POPEN@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_RENAME = @REPLACE_RENAME@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ @@ -1359,10 +1400,12 @@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ REPLACE_STRERROR = @REPLACE_STRERROR@ +REPLACE_STRNDUP = @REPLACE_STRNDUP@ REPLACE_STRPTIME = @REPLACE_STRPTIME@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ +REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ @@ -1395,13 +1438,13 @@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ -SYS_STAT_H = @SYS_STAT_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@ U = @U@ UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@ UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@ +UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ USE_ACL = @USE_ACL@ @@ -2753,21 +2796,21 @@ dist-hook: $(all_programs) check: check-README check-duplicate-no-install .PHONY: check-README check-README: - rm -rf $(pr) $(pm) - echo $(all_programs) \ + $(AM_V_GEN)rm -rf $(pr) $(pm) + $(AM_V_at)echo $(all_programs) \ | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \ | sed /libstdbuf/d \ | $(ASSORT) -u > $(pm) && \ sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \ | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr) - diff $(pm) $(pr) && rm -rf $(pr) $(pm) + $(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm) # Ensure that a by-default-not-installed program (listed in # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because # if that were to happen, it *would* be installed by default. .PHONY: check-duplicate-no-install check-duplicate-no-install: tr - test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`" + $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`" .PHONY: sc_check-AUTHORS sc_check-AUTHORS: $(all_programs) $(AM_V_GEN)locale=en_US.UTF-8; \ diff --git a/src/bin/coreutils/src/base64.c b/src/bin/coreutils/src/base64.c index e24b111258..c7cf034da4 100644 --- a/src/bin/coreutils/src/base64.c +++ b/src/bin/coreutils/src/base64.c @@ -53,7 +53,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -80,7 +80,7 @@ The data are encoded as described for the base64 alphabet in RFC 3548.\n\ When decoding, the input may contain newlines in addition to the bytes of\n\ the formal base64 alphabet. Use --ignore-garbage to attempt to recover\n\ from any other non-alphabet bytes in the encoded stream.\n"), - stdout); + stdout); emit_bug_reporting_address (); } @@ -99,7 +99,7 @@ from any other non-alphabet bytes in the encoded stream.\n"), static void wrap_write (const char *buffer, size_t len, - uintmax_t wrap_column, size_t *current_column, FILE *out) + uintmax_t wrap_column, size_t *current_column, FILE *out) { size_t written; @@ -107,28 +107,28 @@ wrap_write (const char *buffer, size_t len, { /* Simple write. */ if (fwrite (buffer, 1, len, stdout) < len) - error (EXIT_FAILURE, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); } else for (written = 0; written < len;) { - uintmax_t cols_remaining = wrap_column - *current_column; - size_t to_write = MIN (cols_remaining, SIZE_MAX); - to_write = MIN (to_write, len - written); + uintmax_t cols_remaining = wrap_column - *current_column; + size_t to_write = MIN (cols_remaining, SIZE_MAX); + to_write = MIN (to_write, len - written); - if (to_write == 0) - { - if (fputs ("\n", out) < 0) - error (EXIT_FAILURE, errno, _("write error")); - *current_column = 0; - } - else - { - if (fwrite (buffer + written, 1, to_write, stdout) < to_write) - error (EXIT_FAILURE, errno, _("write error")); - *current_column += to_write; - written += to_write; - } + if (to_write == 0) + { + if (fputs ("\n", out) < 0) + error (EXIT_FAILURE, errno, _("write error")); + *current_column = 0; + } + else + { + if (fwrite (buffer + written, 1, to_write, stdout) < to_write) + error (EXIT_FAILURE, errno, _("write error")); + *current_column += to_write; + written += to_write; + } } } @@ -146,21 +146,21 @@ do_encode (FILE *in, FILE *out, uintmax_t wrap_column) sum = 0; do - { - n = fread (inbuf + sum, 1, BLOCKSIZE - sum, in); - sum += n; - } + { + n = fread (inbuf + sum, 1, BLOCKSIZE - sum, in); + sum += n; + } while (!feof (in) && !ferror (in) && sum < BLOCKSIZE); if (sum > 0) - { - /* Process input one block at a time. Note that BLOCKSIZE % - 3 == 0, so that no base64 pads will appear in output. */ - base64_encode (inbuf, sum, outbuf, BASE64_LENGTH (sum)); + { + /* Process input one block at a time. Note that BLOCKSIZE % + 3 == 0, so that no base64 pads will appear in output. */ + base64_encode (inbuf, sum, outbuf, BASE64_LENGTH (sum)); - wrap_write (outbuf, BASE64_LENGTH (sum), wrap_column, - ¤t_column, out); - } + wrap_write (outbuf, BASE64_LENGTH (sum), wrap_column, + ¤t_column, out); + } } while (!feof (in) && !ferror (in) && sum == BLOCKSIZE); @@ -190,43 +190,43 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage) sum = 0; do - { - n = fread (inbuf + sum, 1, B64BLOCKSIZE - sum, in); + { + n = fread (inbuf + sum, 1, B64BLOCKSIZE - sum, in); - if (ignore_garbage) - { - size_t i; - for (i = 0; n > 0 && i < n;) - if (isbase64 (inbuf[sum + i]) || inbuf[sum + i] == '=') - i++; - else - memmove (inbuf + sum + i, inbuf + sum + i + 1, --n - i); - } + if (ignore_garbage) + { + size_t i; + for (i = 0; n > 0 && i < n;) + if (isbase64 (inbuf[sum + i]) || inbuf[sum + i] == '=') + i++; + else + memmove (inbuf + sum + i, inbuf + sum + i + 1, --n - i); + } - sum += n; + sum += n; - if (ferror (in)) - error (EXIT_FAILURE, errno, _("read error")); - } + if (ferror (in)) + error (EXIT_FAILURE, errno, _("read error")); + } while (sum < B64BLOCKSIZE && !feof (in)); /* The following "loop" is usually iterated just once. - However, when it processes the final input buffer, we want - to iterate it one additional time, but with an indicator - telling it to flush what is in CTX. */ + However, when it processes the final input buffer, we want + to iterate it one additional time, but with an indicator + telling it to flush what is in CTX. */ for (k = 0; k < 1 + !!feof (in); k++) - { - if (k == 1 && ctx.i == 0) - break; - n = BLOCKSIZE; - ok = base64_decode_ctx (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n); + { + if (k == 1 && ctx.i == 0) + break; + n = BLOCKSIZE; + ok = base64_decode_ctx (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n); - if (fwrite (outbuf, 1, n, out) < n) - error (EXIT_FAILURE, errno, _("write error")); + if (fwrite (outbuf, 1, n, out) < n) + error (EXIT_FAILURE, errno, _("write error")); - if (!ok) - error (EXIT_FAILURE, 0, _("invalid input")); - } + if (!ok) + error (EXIT_FAILURE, 0, _("invalid input")); + } } while (!feof (in)); } @@ -257,26 +257,26 @@ main (int argc, char **argv) switch (opt) { case 'd': - decode = true; - break; + decode = true; + break; case 'w': - if (xstrtoumax (optarg, NULL, 0, &wrap_column, NULL) != LONGINT_OK) - error (EXIT_FAILURE, 0, _("invalid wrap size: %s"), - quotearg (optarg)); - break; + if (xstrtoumax (optarg, NULL, 0, &wrap_column, NULL) != LONGINT_OK) + error (EXIT_FAILURE, 0, _("invalid wrap size: %s"), + quotearg (optarg)); + break; case 'i': - ignore_garbage = true; - break; + 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); - break; + usage (EXIT_FAILURE); + break; } if (argc - optind > 1) @@ -296,7 +296,7 @@ main (int argc, char **argv) { input_fh = fopen (infile, "r"); if (input_fh == NULL) - error (EXIT_FAILURE, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); } if (decode) @@ -307,9 +307,9 @@ main (int argc, char **argv) if (fclose (input_fh) == EOF) { if (STREQ (infile, "-")) - error (EXIT_FAILURE, errno, _("closing standard input")); + error (EXIT_FAILURE, errno, _("closing standard input")); else - error (EXIT_FAILURE, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); } exit (EXIT_SUCCESS); diff --git a/src/bin/coreutils/src/basename.c b/src/bin/coreutils/src/basename.c index d79ad209cb..4300d49836 100644 --- a/src/bin/coreutils/src/basename.c +++ b/src/bin/coreutils/src/basename.c @@ -44,14 +44,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s NAME [SUFFIX]\n\ or: %s OPTION\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Print NAME with any leading directory components removed.\n\ If specified, also remove a trailing SUFFIX.\n\ @@ -65,7 +65,7 @@ Examples:\n\ %s /usr/bin/sort Output \"sort\".\n\ %s include/stdio.h .h Output \"stdio\".\n\ "), - program_name, program_name); + program_name, program_name); emit_bug_reporting_address (); } exit (status); @@ -104,7 +104,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "+", NULL, NULL) != -1) usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/c99-to-c89.diff b/src/bin/coreutils/src/c99-to-c89.diff index 51b0a42ca3..a5dd6c9b80 100644 --- a/src/bin/coreutils/src/c99-to-c89.diff +++ b/src/bin/coreutils/src/c99-to-c89.diff @@ -43,21 +43,21 @@ diff -upr src/remove.c src/remove.c && ((x->interactive == RMI_ALWAYS) || x->stdin_tty) && dirent_type != DT_LNK) @@ -889,6 +890,7 @@ prompt (int fd_cwd, Dirstack_state const - break; - } + break; + } + { char const *quoted_name = quote (full_filename (filename)); if (write_protected < 0) @@ -928,6 +930,7 @@ prompt (int fd_cwd, Dirstack_state const - : _("%s: remove %s %s? ")), - program_name, file_type (sbuf), quoted_name); - } + : _("%s: remove %s %s? ")), + program_name, file_type (sbuf), quoted_name); + } + } if (!yesno ()) - return RM_USER_DECLINED; + return RM_USER_DECLINED; @@ -1547,6 +1550,7 @@ rm_1 (Dirstack_state *ds, char const *fi return RM_ERROR; } @@ -72,7 +72,7 @@ diff -upr src/remove.c src/remove.c + { enum RM_status status = remove_entry (AT_FDCWD, ds, filename, - DT_UNKNOWN, &st, x); + DT_UNKNOWN, &st, x); if (status == RM_NONEMPTY_DIR) @@ -1587,6 +1592,8 @@ rm_1 (Dirstack_state *ds, char const *fi ds_clear (ds); @@ -87,7 +87,7 @@ diff -upr src/rm.c src/rm.c --- src/rm.c 1970-01-01 00:00:00.000000000 +0000 +++ src/rm.c 1970-01-01 00:00:00.000000000 +0000 @@ -354,6 +354,7 @@ main (int argc, char **argv) - quote ("/")); + quote ("/")); } + { @@ -96,7 +96,7 @@ diff -upr src/rm.c src/rm.c @@ -367,7 +368,10 @@ main (int argc, char **argv) if (!yesno ()) - exit (EXIT_SUCCESS); + exit (EXIT_SUCCESS); } + { enum RM_status status = rm (n_files, file, &x); @@ -109,37 +109,37 @@ diff -upr src/seq.c src/seq.c --- src/seq.c 1970-01-01 00:00:00.000000000 +0000 +++ src/seq.c 1970-01-01 00:00:00.000000000 +0000 @@ -163,6 +163,7 @@ scan_arg (const char *arg) - : (decimal_point == arg /* .# -> 0.# */ - || ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */ - } + : (decimal_point == arg /* .# -> 0.# */ + || ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */ + } + { char const *e = strchr (arg, 'e'); if (! e) - e = strchr (arg, 'E'); + e = strchr (arg, 'E'); @@ -171,6 +172,7 @@ scan_arg (const char *arg) - long exponent = strtol (e + 1, NULL, 10); - ret.precision += exponent < 0 ? -exponent : 0; - } + long exponent = strtol (e + 1, NULL, 10); + ret.precision += exponent < 0 ? -exponent : 0; + } + } } return ret; @@ -346,6 +348,7 @@ get_default_format (operand first, opera - size_t last_width = last.width + (prec - last.precision); - if (last.precision && prec == 0) - last_width--; /* don't include space for '.' */ + size_t last_width = last.width + (prec - last.precision); + if (last.precision && prec == 0) + last_width--; /* don't include space for '.' */ + { - size_t width = MAX (first_width, last_width); - if (width <= INT_MAX) - { + size_t width = MAX (first_width, last_width); + if (width <= INT_MAX) + { @@ -353,6 +356,7 @@ get_default_format (operand first, opera - sprintf (format_buf, "%%0%d.%dLf", w, prec); - return format_buf; - } + sprintf (format_buf, "%%0%d.%dLf", w, prec); + return format_buf; + } + } - } + } else - { + { @@ -441,6 +445,7 @@ main (int argc, char **argv) if (format_str) { @@ -147,10 +147,10 @@ diff -upr src/seq.c src/seq.c + { char const *f = long_double_format (format_str, &layout); if (! f) - { + { @@ -448,6 +453,7 @@ main (int argc, char **argv) - usage (EXIT_FAILURE); - } + usage (EXIT_FAILURE); + } format_str = f; + } } @@ -160,11 +160,11 @@ diff -upr src/shred.c src/shred.c --- src/shred.c 1970-01-01 00:00:00.000000000 +0000 +++ src/shred.c 1970-01-01 00:00:00.000000000 +0000 @@ -468,7 +468,7 @@ dopass (int fd, char const *qname, off_t - out. Thus, it shouldn't give up on bad blocks. This - code works because lim is always a multiple of - SECTOR_SIZE, except at the end. */ + out. Thus, it shouldn't give up on bad blocks. This + code works because lim is always a multiple of + SECTOR_SIZE, except at the end. */ - verify (sizeof r % SECTOR_SIZE == 0); + { verify (sizeof r % SECTOR_SIZE == 0); } - if (errnum == EIO && 0 <= size && (soff | SECTOR_MASK) < lim) - { - size_t soff1 = (soff | SECTOR_MASK) + 1; + if (errnum == EIO && 0 <= size && (soff | SECTOR_MASK) < lim) + { + size_t soff1 = (soff | SECTOR_MASK) + 1; diff --git a/src/bin/coreutils/src/cat.c b/src/bin/coreutils/src/cat.c index bdc011017b..41b2637f21 100644 --- a/src/bin/coreutils/src/cat.c +++ b/src/bin/coreutils/src/cat.c @@ -83,13 +83,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Concatenate FILE(s), or standard input, to standard output.\n\ \n\ @@ -118,7 +118,7 @@ Examples:\n\ %s f - g Output f's contents, then standard input, then g's contents.\n\ %s Copy standard input to standard output.\n\ "), - program_name, program_name); + program_name, program_name); emit_bug_reporting_address (); } exit (status); @@ -133,7 +133,7 @@ next_line_num (void) do { if ((*endp)++ < '9') - return; + return; *endp-- = '0'; } while (endp >= line_num_start); @@ -168,23 +168,23 @@ simple_cat ( n_read = safe_read (input_desc, buf, bufsize); if (n_read == SAFE_READ_ERROR) - { - error (0, errno, "%s", infile); - return false; - } + { + error (0, errno, "%s", infile); + return false; + } /* End of this file? */ if (n_read == 0) - return true; + return true; /* Write this block out. */ { - /* The following is ok, since we know that 0 < n_read. */ - size_t n = n_read; - if (full_write (STDOUT_FILENO, buf, n) != n) - error (EXIT_FAILURE, errno, _("write error")); + /* The following is ok, since we know that 0 < n_read. */ + size_t n = n_read; + if (full_write (STDOUT_FILENO, buf, n) != n) + error (EXIT_FAILURE, errno, _("write error")); } } } @@ -274,227 +274,227 @@ cat ( for (;;) { do - { - /* Write if there are at least OUTSIZE bytes in OUTBUF. */ + { + /* Write if there are at least OUTSIZE bytes in OUTBUF. */ - if (outbuf + outsize <= bpout) - { - char *wp = outbuf; - size_t remaining_bytes; - do - { - if (full_write (STDOUT_FILENO, wp, outsize) != outsize) - error (EXIT_FAILURE, errno, _("write error")); - wp += outsize; - remaining_bytes = bpout - wp; - } - while (outsize <= remaining_bytes); + if (outbuf + outsize <= bpout) + { + char *wp = outbuf; + size_t remaining_bytes; + do + { + if (full_write (STDOUT_FILENO, wp, outsize) != outsize) + error (EXIT_FAILURE, errno, _("write error")); + wp += outsize; + remaining_bytes = bpout - wp; + } + while (outsize <= remaining_bytes); - /* Move the remaining bytes to the beginning of the - buffer. */ + /* Move the remaining bytes to the beginning of the + buffer. */ - memmove (outbuf, wp, remaining_bytes); - bpout = outbuf + remaining_bytes; - } + memmove (outbuf, wp, remaining_bytes); + bpout = outbuf + remaining_bytes; + } - /* Is INBUF empty? */ + /* Is INBUF empty? */ - if (bpin > eob) - { - bool input_pending = false; + if (bpin > eob) + { + bool input_pending = false; #ifdef FIONREAD - int n_to_read = 0; + int n_to_read = 0; - /* Is there any input to read immediately? - If not, we are about to wait, - so write all buffered output before waiting. */ + /* Is there any input to read immediately? + If not, we are about to wait, + so write all buffered output before waiting. */ - if (use_fionread - && ioctl (input_desc, FIONREAD, &n_to_read) < 0) - { - /* Ultrix returns EOPNOTSUPP on NFS; - HP-UX returns ENOTTY on pipes. - SunOS returns EINVAL and - More/BSD returns ENODEV on special files - like /dev/null. - Irix-5 returns ENOSYS on pipes. */ - if (errno == EOPNOTSUPP || errno == ENOTTY - || errno == EINVAL || errno == ENODEV - || errno == ENOSYS) - use_fionread = false; - else - { - error (0, errno, _("cannot do ioctl on %s"), quote (infile)); - newlines2 = newlines; - return false; - } - } - if (n_to_read != 0) - input_pending = true; + if (use_fionread + && ioctl (input_desc, FIONREAD, &n_to_read) < 0) + { + /* Ultrix returns EOPNOTSUPP on NFS; + HP-UX returns ENOTTY on pipes. + SunOS returns EINVAL and + More/BSD returns ENODEV on special files + like /dev/null. + Irix-5 returns ENOSYS on pipes. */ + if (errno == EOPNOTSUPP || errno == ENOTTY + || errno == EINVAL || errno == ENODEV + || errno == ENOSYS) + use_fionread = false; + else + { + error (0, errno, _("cannot do ioctl on %s"), quote (infile)); + newlines2 = newlines; + return false; + } + } + if (n_to_read != 0) + input_pending = true; #endif - if (!input_pending) - write_pending (outbuf, &bpout); + if (!input_pending) + write_pending (outbuf, &bpout); - /* Read more input into INBUF. */ + /* Read more input into INBUF. */ - n_read = safe_read (input_desc, inbuf, insize); - if (n_read == SAFE_READ_ERROR) - { - error (0, errno, "%s", infile); - write_pending (outbuf, &bpout); - newlines2 = newlines; - return false; - } - if (n_read == 0) - { - write_pending (outbuf, &bpout); - newlines2 = newlines; - return true; - } + n_read = safe_read (input_desc, inbuf, insize); + if (n_read == SAFE_READ_ERROR) + { + error (0, errno, "%s", infile); + write_pending (outbuf, &bpout); + newlines2 = newlines; + return false; + } + if (n_read == 0) + { + write_pending (outbuf, &bpout); + newlines2 = newlines; + return true; + } - /* Update the pointers and insert a sentinel at the buffer - end. */ + /* Update the pointers and insert a sentinel at the buffer + end. */ - bpin = inbuf; - eob = bpin + n_read; - *eob = '\n'; - } - else - { - /* It was a real (not a sentinel) newline. */ + bpin = inbuf; + eob = bpin + n_read; + *eob = '\n'; + } + else + { + /* It was a real (not a sentinel) newline. */ - /* Was the last line empty? - (i.e. have two or more consecutive newlines been read?) */ + /* Was the last line empty? + (i.e. have two or more consecutive newlines been read?) */ - if (++newlines > 0) - { - if (newlines >= 2) - { - /* Limit this to 2 here. Otherwise, with lots of - consecutive newlines, the counter could wrap - around at INT_MAX. */ - newlines = 2; + if (++newlines > 0) + { + if (newlines >= 2) + { + /* Limit this to 2 here. Otherwise, with lots of + consecutive newlines, the counter could wrap + around at INT_MAX. */ + newlines = 2; - /* Are multiple adjacent empty lines to be substituted - by single ditto (-s), and this was the second empty - line? */ - if (squeeze_blank) - { - ch = *bpin++; - continue; - } - } + /* Are multiple adjacent empty lines to be substituted + by single ditto (-s), and this was the second empty + line? */ + if (squeeze_blank) + { + ch = *bpin++; + continue; + } + } - /* Are line numbers to be written at empty lines (-n)? */ + /* Are line numbers to be written at empty lines (-n)? */ - if (number & !number_nonblank) - { - next_line_num (); - bpout = stpcpy (bpout, line_num_print); - } - } + if (number & !number_nonblank) + { + next_line_num (); + bpout = stpcpy (bpout, line_num_print); + } + } - /* Output a currency symbol if requested (-e). */ + /* Output a currency symbol if requested (-e). */ - if (show_ends) - *bpout++ = '$'; + if (show_ends) + *bpout++ = '$'; - /* Output the newline. */ + /* Output the newline. */ - *bpout++ = '\n'; - } - ch = *bpin++; - } + *bpout++ = '\n'; + } + ch = *bpin++; + } while (ch == '\n'); /* Are we at the beginning of a line, and line numbers are requested? */ if (newlines >= 0 && number) - { - next_line_num (); - bpout = stpcpy (bpout, line_num_print); - } + { + next_line_num (); + bpout = stpcpy (bpout, line_num_print); + } /* Here CH cannot contain a newline character. */ /* The loops below continue until a newline character is found, - which means that the buffer is empty or that a proper newline - has been found. */ + which means that the buffer is empty or that a proper newline + has been found. */ /* If quoting, i.e. at least one of -v, -e, or -t specified, - scan for chars that need conversion. */ + scan for chars that need conversion. */ if (show_nonprinting) - { - for (;;) - { - if (ch >= 32) - { - if (ch < 127) - *bpout++ = ch; - else if (ch == 127) - { - *bpout++ = '^'; - *bpout++ = '?'; - } - else - { - *bpout++ = 'M'; - *bpout++ = '-'; - if (ch >= 128 + 32) - { - if (ch < 128 + 127) - *bpout++ = ch - 128; - else - { - *bpout++ = '^'; - *bpout++ = '?'; - } - } - else - { - *bpout++ = '^'; - *bpout++ = ch - 128 + 64; - } - } - } - else if (ch == '\t' && !show_tabs) - *bpout++ = '\t'; - else if (ch == '\n') - { - newlines = -1; - break; - } - else - { - *bpout++ = '^'; - *bpout++ = ch + 64; - } + { + for (;;) + { + if (ch >= 32) + { + if (ch < 127) + *bpout++ = ch; + else if (ch == 127) + { + *bpout++ = '^'; + *bpout++ = '?'; + } + else + { + *bpout++ = 'M'; + *bpout++ = '-'; + if (ch >= 128 + 32) + { + if (ch < 128 + 127) + *bpout++ = ch - 128; + else + { + *bpout++ = '^'; + *bpout++ = '?'; + } + } + else + { + *bpout++ = '^'; + *bpout++ = ch - 128 + 64; + } + } + } + else if (ch == '\t' && !show_tabs) + *bpout++ = '\t'; + else if (ch == '\n') + { + newlines = -1; + break; + } + else + { + *bpout++ = '^'; + *bpout++ = ch + 64; + } - ch = *bpin++; - } - } + ch = *bpin++; + } + } else - { - /* Not quoting, neither of -v, -e, or -t specified. */ - for (;;) - { - if (ch == '\t' && show_tabs) - { - *bpout++ = '^'; - *bpout++ = ch + 64; - } - else if (ch != '\n') - *bpout++ = ch; - else - { - newlines = -1; - break; - } + { + /* Not quoting, neither of -v, -e, or -t specified. */ + for (;;) + { + if (ch == '\t' && show_tabs) + { + *bpout++ = '^'; + *bpout++ = ch + 64; + } + else if (ch != '\n') + *bpout++ = ch; + else + { + newlines = -1; + break; + } - ch = *bpin++; - } - } + ch = *bpin++; + } + } } } @@ -573,62 +573,62 @@ main (int argc, char **argv) /* Parse command line options. */ while ((c = getopt_long (argc, argv, "benstuvAET", long_options, NULL)) - != -1) + != -1) { switch (c) - { - case 'b': - number = true; - number_nonblank = true; - break; + { + case 'b': + number = true; + number_nonblank = true; + break; - case 'e': - show_ends = true; - show_nonprinting = true; - break; + case 'e': + show_ends = true; + show_nonprinting = true; + break; - case 'n': - number = true; - break; + case 'n': + number = true; + break; - case 's': - squeeze_blank = true; - break; + case 's': + squeeze_blank = true; + break; - case 't': - show_tabs = true; - show_nonprinting = true; - break; + case 't': + show_tabs = true; + show_nonprinting = true; + break; - case 'u': - /* We provide the -u feature unconditionally. */ - break; + case 'u': + /* We provide the -u feature unconditionally. */ + break; - case 'v': - show_nonprinting = true; - break; + case 'v': + show_nonprinting = true; + break; - case 'A': - show_nonprinting = true; - show_ends = true; - show_tabs = true; - break; + case 'A': + show_nonprinting = true; + show_ends = true; + show_tabs = true; + break; - case 'E': - show_ends = true; - break; + case 'E': + show_ends = true; + break; - case 'T': - show_tabs = true; - break; + case 'T': + show_tabs = 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); - } + default: + usage (EXIT_FAILURE); + } } /* Get device, i-node number, and optimal blocksize of output. */ @@ -661,7 +661,7 @@ main (int argc, char **argv) { file_open_mode |= O_BINARY; if (O_BINARY && ! isatty (STDOUT_FILENO)) - xfreopen (NULL, "wb", stdout); + xfreopen (NULL, "wb", stdout); } /* Check if any of the input files are the same as the output file. */ @@ -674,104 +674,104 @@ main (int argc, char **argv) do { if (argind < argc) - infile = argv[argind]; + infile = argv[argind]; if (STREQ (infile, "-")) - { - have_read_stdin = true; - input_desc = STDIN_FILENO; - if ((file_open_mode & O_BINARY) && ! isatty (STDIN_FILENO)) - xfreopen (NULL, "rb", stdin); - } + { + have_read_stdin = true; + input_desc = STDIN_FILENO; + if ((file_open_mode & O_BINARY) && ! isatty (STDIN_FILENO)) + xfreopen (NULL, "rb", stdin); + } else - { - input_desc = open (infile, file_open_mode); - if (input_desc < 0) - { - error (0, errno, "%s", infile); - ok = false; - continue; - } - } + { + input_desc = open (infile, file_open_mode); + if (input_desc < 0) + { + error (0, errno, "%s", infile); + ok = false; + continue; + } + } if (fstat (input_desc, &stat_buf) < 0) - { - error (0, errno, "%s", infile); - ok = false; - goto contin; - } + { + error (0, errno, "%s", infile); + ok = false; + goto contin; + } insize = io_blksize (stat_buf); /* 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 - files cannot be redirected to themselves. */ + the corresponding values of the (output file associated with) + stdout, and skip this input file if they coincide. Input + files cannot be redirected to themselves. */ if (check_redirection - && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino - && (input_desc != STDIN_FILENO)) - { - error (0, 0, _("%s: input file is output file"), infile); - ok = false; - goto contin; - } + && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino + && (input_desc != STDIN_FILENO)) + { + error (0, 0, _("%s: input file is output file"), infile); + ok = false; + goto contin; + } /* Select which version of `cat' to use. If any format-oriented - options were given use `cat'; otherwise use `simple_cat'. */ + options were given use `cat'; otherwise use `simple_cat'. */ if (! (number | show_ends | show_nonprinting - | show_tabs | squeeze_blank)) - { - insize = MAX (insize, outsize); - inbuf = xmalloc (insize + page_size - 1); + | show_tabs | squeeze_blank)) + { + insize = MAX (insize, outsize); + inbuf = xmalloc (insize + page_size - 1); - ok &= simple_cat (ptr_align (inbuf, page_size), insize); - } + ok &= simple_cat (ptr_align (inbuf, page_size), insize); + } else - { - inbuf = xmalloc (insize + 1 + page_size - 1); + { + inbuf = xmalloc (insize + 1 + page_size - 1); - /* Why are - (OUTSIZE - 1 + INSIZE * 4 + LINE_COUNTER_BUF_LEN + PAGE_SIZE - 1) - bytes allocated for the output buffer? + /* Why are + (OUTSIZE - 1 + INSIZE * 4 + LINE_COUNTER_BUF_LEN + PAGE_SIZE - 1) + bytes allocated for the output buffer? - A test whether output needs to be written is done when the input - buffer empties or when a newline appears in the input. After - output is written, at most (OUTSIZE - 1) bytes will remain in the - buffer. Now INSIZE bytes of input is read. Each input character - may grow by a factor of 4 (by the prepending of M-^). If all - characters do, and no newlines appear in this block of input, we - will have at most (OUTSIZE - 1 + INSIZE * 4) bytes in the buffer. - If the last character in the preceding block of input was a - newline, a line number may be written (according to the given - options) as the first thing in the output buffer. (Done after the - new input is read, but before processing of the input begins.) - A line number requires seldom more than LINE_COUNTER_BUF_LEN - positions. + A test whether output needs to be written is done when the input + buffer empties or when a newline appears in the input. After + output is written, at most (OUTSIZE - 1) bytes will remain in the + buffer. Now INSIZE bytes of input is read. Each input character + may grow by a factor of 4 (by the prepending of M-^). If all + characters do, and no newlines appear in this block of input, we + will have at most (OUTSIZE - 1 + INSIZE * 4) bytes in the buffer. + If the last character in the preceding block of input was a + newline, a line number may be written (according to the given + options) as the first thing in the output buffer. (Done after the + new input is read, but before processing of the input begins.) + A line number requires seldom more than LINE_COUNTER_BUF_LEN + positions. - Align the output buffer to a page size boundary, for efficency on - some paging implementations, so add PAGE_SIZE - 1 bytes to the - request to make room for the alignment. */ + Align the output buffer to a page size boundary, for efficency on + some paging implementations, so add PAGE_SIZE - 1 bytes to the + request to make room for the alignment. */ - outbuf = xmalloc (outsize - 1 + insize * 4 + LINE_COUNTER_BUF_LEN - + page_size - 1); + outbuf = xmalloc (outsize - 1 + insize * 4 + LINE_COUNTER_BUF_LEN + + page_size - 1); - ok &= cat (ptr_align (inbuf, page_size), insize, - ptr_align (outbuf, page_size), outsize, show_nonprinting, - show_tabs, number, number_nonblank, show_ends, - squeeze_blank); + ok &= cat (ptr_align (inbuf, page_size), insize, + ptr_align (outbuf, page_size), outsize, show_nonprinting, + show_tabs, number, number_nonblank, show_ends, + squeeze_blank); - free (outbuf); - } + free (outbuf); + } free (inbuf); contin: if (!STREQ (infile, "-") && close (input_desc) < 0) - { - error (0, errno, "%s", infile); - ok = false; - } + { + error (0, errno, "%s", infile); + ok = false; + } } while (++argind < argc); diff --git a/src/bin/coreutils/src/chcon.c b/src/bin/coreutils/src/chcon.c index f5b5f22df7..7e8250d3da 100644 --- a/src/bin/coreutils/src/chcon.c +++ b/src/bin/coreutils/src/chcon.c @@ -22,6 +22,7 @@ #include "system.h" #include "dev-ino.h" #include "error.h" +#include "ignore-value.h" #include "quote.h" #include "quotearg.h" #include "root-dev-ino.h" @@ -97,7 +98,7 @@ compute_context_from_mask (security_context_t context, context_t *ret) if (!new_context) { error (0, errno, _("failed to create security context: %s"), - quotearg_colon (context)); + quotearg_colon (context)); return 1; } @@ -105,13 +106,13 @@ compute_context_from_mask (security_context_t context, context_t *ret) do \ { \ if (specified_ ## comp \ - && context_ ## comp ## _set ((C), specified_ ## comp)) \ + && context_ ## comp ## _set ((C), specified_ ## comp)) \ { \ - error (0, errno, \ - _("failed to set %s security context component to %s"), \ - #comp, quote (specified_ ## comp)); \ + error (0, errno, \ + _("failed to set %s security context component to %s"), \ + #comp, quote (specified_ ## comp)); \ ok = false; \ - } \ + } \ } \ while (0) @@ -147,35 +148,35 @@ change_file_context (int fd, char const *file) if (specified_context == NULL) { int status = (affect_symlink_referent - ? getfileconat (fd, file, &file_context) - : lgetfileconat (fd, file, &file_context)); + ? getfileconat (fd, file, &file_context) + : lgetfileconat (fd, file, &file_context)); if (status < 0 && errno != ENODATA) - { - error (0, errno, _("failed to get security context of %s"), - quote (file)); - return 1; - } + { + error (0, errno, _("failed to get security context of %s"), + quote (file)); + return 1; + } /* If the file doesn't have a context, and we're not setting all of - the context components, there isn't really an obvious default. - Thus, we just give up. */ + the context components, there isn't really an obvious default. + Thus, we just give up. */ if (file_context == NULL) - { - error (0, 0, _("can't apply partial context to unlabeled file %s"), - quote (file)); - return 1; - } + { + error (0, 0, _("can't apply partial context to unlabeled file %s"), + quote (file)); + return 1; + } if (compute_context_from_mask (file_context, &context)) - return 1; + return 1; } else { /* FIXME: this should be done exactly once, in main. */ context = context_new (specified_context); if (!context) - abort (); + abort (); } context_string = context_str (context); @@ -183,15 +184,15 @@ change_file_context (int fd, char const *file) if (file_context == NULL || ! STREQ (context_string, file_context)) { int fail = (affect_symlink_referent - ? setfileconat (fd, file, context_string) - : lsetfileconat (fd, file, context_string)); + ? setfileconat (fd, file, context_string) + : lsetfileconat (fd, file, context_string)); if (fail) - { - errors = 1; - error (0, errno, _("failed to change context of %s to %s"), - quote_n (0, file), quote_n (1, context_string)); - } + { + errors = 1; + error (0, errno, _("failed to change context of %s to %s"), + quote_n (0, file), quote_n (1, context_string)); + } } context_free (context); @@ -216,41 +217,41 @@ process_file (FTS *fts, FTSENT *ent) { case FTS_D: if (recurse) - { - if (ROOT_DEV_INO_CHECK (root_dev_ino, ent->fts_statp)) - { - /* This happens e.g., with "chcon -R --preserve-root ... /" - and with "chcon -RH --preserve-root ... symlink-to-root". */ - ROOT_DEV_INO_WARN (file_full_name); - /* Tell fts not to traverse into this hierarchy. */ - fts_set (fts, ent, FTS_SKIP); - /* Ensure that we do not process "/" on the second visit. */ - ent = fts_read (fts); - return false; - } - return true; - } + { + if (ROOT_DEV_INO_CHECK (root_dev_ino, ent->fts_statp)) + { + /* This happens e.g., with "chcon -R --preserve-root ... /" + and with "chcon -RH --preserve-root ... symlink-to-root". */ + ROOT_DEV_INO_WARN (file_full_name); + /* Tell fts not to traverse into this hierarchy. */ + fts_set (fts, ent, FTS_SKIP); + /* Ensure that we do not process "/" on the second visit. */ + ignore_ptr (fts_read (fts)); + return false; + } + return true; + } break; case FTS_DP: if (! recurse) - return true; + return true; break; case FTS_NS: /* For a top-level file or directory, this FTS_NS (stat failed) - indicator is determined at the time of the initial fts_open call. - With programs like chmod, chown, and chgrp, that modify - permissions, it is possible that the file in question is - accessible when control reaches this point. So, if this is - the first time we've seen the FTS_NS for this file, tell - fts_read to stat it "again". */ + indicator is determined at the time of the initial fts_open call. + With programs like chmod, chown, and chgrp, that modify + permissions, it is possible that the file in question is + accessible when control reaches this point. So, if this is + the first time we've seen the FTS_NS for this file, tell + fts_read to stat it "again". */ if (ent->fts_level == 0 && ent->fts_number == 0) - { - ent->fts_number = 1; - fts_set (fts, ent, FTS_AGAIN); - return true; - } + { + ent->fts_number = 1; + fts_set (fts, ent, FTS_AGAIN); + return true; + } error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name)); ok = false; break; @@ -262,7 +263,7 @@ process_file (FTS *fts, FTSENT *ent) case FTS_DNR: error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; break; @@ -280,11 +281,11 @@ process_file (FTS *fts, FTSENT *ent) if (ok) { if (verbose) - printf (_("changing security context of %s\n"), - quote (file_full_name)); + printf (_("changing security context of %s\n"), + quote (file_full_name)); if (change_file_context (fts->fts_cwd_fd, file) != 0) - ok = false; + ok = false; } if ( ! recurse) @@ -310,23 +311,24 @@ process_files (char **files, int bit_flags) ent = fts_read (fts); if (ent == NULL) - { - if (errno != 0) - { - /* FIXME: try to give a better message */ - error (0, errno, _("fts_read failed")); - ok = false; - } - break; - } + { + if (errno != 0) + { + /* FIXME: try to give a better message */ + error (0, errno, _("fts_read failed")); + ok = false; + } + break; + } ok &= process_file (fts, ent); } - /* Ignore failure, since the only way it can do so is in failing to - return to the original directory, and since we're about to exit, - that doesn't matter. */ - fts_close (fts); + if (fts_close (fts) != 0) + { + error (0, errno, _("fts_close failed")); + ok = false; + } return ok; } @@ -336,7 +338,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -344,7 +346,7 @@ Usage: %s [OPTION]... CONTEXT FILE...\n\ or: %s [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...\n\ or: %s [OPTION]... --reference=RFILE FILE...\n\ "), - program_name, program_name, program_name); + program_name, program_name, program_name); fputs (_("\ Change the security context of each FILE to CONTEXT.\n\ With --reference, change the security context of each FILE to that of RFILE.\n\ @@ -410,97 +412,97 @@ main (int argc, char **argv) atexit (close_stdout); while ((optc = getopt_long (argc, argv, "HLPRhvu:r:t:l:", long_options, NULL)) - != -1) + != -1) { switch (optc) - { - case 'H': /* Traverse command-line symlinks-to-directories. */ - bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL; - break; + { + case 'H': /* Traverse command-line symlinks-to-directories. */ + bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL; + break; - case 'L': /* Traverse all symlinks-to-directories. */ - bit_flags = FTS_LOGICAL; - break; + case 'L': /* Traverse all symlinks-to-directories. */ + bit_flags = FTS_LOGICAL; + break; - case 'P': /* Traverse no symlinks-to-directories. */ - bit_flags = FTS_PHYSICAL; - break; + case 'P': /* Traverse no symlinks-to-directories. */ + bit_flags = FTS_PHYSICAL; + break; - case 'h': /* --no-dereference: affect symlinks */ - dereference = 0; - break; + case 'h': /* --no-dereference: affect symlinks */ + dereference = 0; + break; - case DEREFERENCE_OPTION: /* --dereference: affect the referent - of each symlink */ - dereference = 1; - break; + case DEREFERENCE_OPTION: /* --dereference: affect the referent + of each symlink */ + dereference = 1; + break; - case NO_PRESERVE_ROOT: - preserve_root = false; - break; + case NO_PRESERVE_ROOT: + preserve_root = false; + break; - case PRESERVE_ROOT: - preserve_root = true; - break; + case PRESERVE_ROOT: + preserve_root = true; + break; - case REFERENCE_FILE_OPTION: - reference_file = optarg; - break; + case REFERENCE_FILE_OPTION: + reference_file = optarg; + break; - case 'R': - recurse = true; - break; + case 'R': + recurse = true; + break; - case 'f': - /* ignore */ - break; + case 'f': + /* ignore */ + break; - case 'v': - verbose = true; - break; + case 'v': + verbose = true; + break; - case 'u': - specified_user = optarg; - component_specified = true; - break; + case 'u': + specified_user = optarg; + component_specified = true; + break; - case 'r': - specified_role = optarg; - component_specified = true; - break; + case 'r': + specified_role = optarg; + component_specified = true; + break; - case 't': - specified_type = optarg; - component_specified = true; - break; + case 't': + specified_type = optarg; + component_specified = true; + break; - case 'l': - specified_range = optarg; - component_specified = true; - break; + case 'l': + specified_range = optarg; + component_specified = true; + break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (recurse) { if (bit_flags == FTS_PHYSICAL) - { - if (dereference == 1) - error (EXIT_FAILURE, 0, - _("-R --dereference requires either -H or -L")); - affect_symlink_referent = false; - } + { + if (dereference == 1) + error (EXIT_FAILURE, 0, + _("-R --dereference requires either -H or -L")); + affect_symlink_referent = false; + } else - { - if (dereference == 0) - error (EXIT_FAILURE, 0, _("-R -h requires -P")); - affect_symlink_referent = true; - } + { + if (dereference == 0) + error (EXIT_FAILURE, 0, _("-R -h requires -P")); + affect_symlink_referent = true; + } } else { @@ -511,17 +513,17 @@ main (int argc, char **argv) if (argc - optind < (reference_file || component_specified ? 1 : 2)) { if (argc <= optind) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); + error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); usage (EXIT_FAILURE); } if (reference_file) { if (getfilecon (reference_file, &ref_context) < 0) - error (EXIT_FAILURE, errno, _("failed to get security context of %s"), - quote (reference_file)); + error (EXIT_FAILURE, errno, _("failed to get security context of %s"), + quote (reference_file)); specified_context = ref_context; } @@ -536,8 +538,8 @@ main (int argc, char **argv) specified_context = argv[optind++]; context = context_new (specified_context); if (!context) - error (EXIT_FAILURE, 0, _("invalid context: %s"), - quotearg_colon (specified_context)); + error (EXIT_FAILURE, 0, _("invalid context: %s"), + quotearg_colon (specified_context)); context_free (context); } @@ -552,8 +554,8 @@ main (int argc, char **argv) static struct dev_ino dev_ino_buf; root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (root_dev_ino == NULL) - error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), + quote ("/")); } else { diff --git a/src/bin/coreutils/src/chgrp.c b/src/bin/coreutils/src/chgrp.c index 0653a9033d..0102ef0981 100644 --- a/src/bin/coreutils/src/chgrp.c +++ b/src/bin/coreutils/src/chgrp.c @@ -84,15 +84,15 @@ parse_group (const char *name) { struct group *grp = getgrnam (name); if (grp) - gid = grp->gr_gid; + gid = grp->gr_gid; else - { - unsigned long int tmp; - if (! (xstrtoul (name, NULL, 10, &tmp, "") == LONGINT_OK - && tmp <= GID_T_MAX)) - error (EXIT_FAILURE, 0, _("invalid group: %s"), quote (name)); - gid = tmp; - } + { + unsigned long int tmp; + if (! (xstrtoul (name, NULL, 10, &tmp, "") == LONGINT_OK + && tmp <= GID_T_MAX)) + error (EXIT_FAILURE, 0, _("invalid group: %s"), quote (name)); + gid = tmp; + } endgrent (); /* Save a file descriptor. */ } @@ -104,14 +104,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... GROUP FILE...\n\ or: %s [OPTION]... --reference=RFILE FILE...\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Change the group of each FILE to GROUP.\n\ With --reference, change the group of each FILE to that of RFILE.\n\ @@ -157,7 +157,7 @@ Examples:\n\ %s staff /u Change the group of /u to \"staff\".\n\ %s -hR staff /u Change the group of /u and subfiles to \"staff\".\n\ "), - program_name, program_name); + program_name, program_name); emit_bug_reporting_address (); } exit (status); @@ -191,75 +191,75 @@ main (int argc, char **argv) chopt_init (&chopt); while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, NULL)) - != -1) + != -1) { switch (optc) - { - case 'H': /* Traverse command-line symlinks-to-directories. */ - bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL; - break; + { + case 'H': /* Traverse command-line symlinks-to-directories. */ + bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL; + break; - case 'L': /* Traverse all symlinks-to-directories. */ - bit_flags = FTS_LOGICAL; - break; + case 'L': /* Traverse all symlinks-to-directories. */ + bit_flags = FTS_LOGICAL; + break; - case 'P': /* Traverse no symlinks-to-directories. */ - bit_flags = FTS_PHYSICAL; - break; + case 'P': /* Traverse no symlinks-to-directories. */ + bit_flags = FTS_PHYSICAL; + break; - case 'h': /* --no-dereference: affect symlinks */ - dereference = 0; - break; + case 'h': /* --no-dereference: affect symlinks */ + dereference = 0; + break; - case DEREFERENCE_OPTION: /* --dereference: affect the referent - of each symlink */ - dereference = 1; - break; + case DEREFERENCE_OPTION: /* --dereference: affect the referent + of each symlink */ + dereference = 1; + break; - case NO_PRESERVE_ROOT: - preserve_root = false; - break; + case NO_PRESERVE_ROOT: + preserve_root = false; + break; - case PRESERVE_ROOT: - preserve_root = true; - break; + case PRESERVE_ROOT: + preserve_root = true; + break; - case REFERENCE_FILE_OPTION: - reference_file = optarg; - break; + case REFERENCE_FILE_OPTION: + reference_file = optarg; + break; - case 'R': - chopt.recurse = true; - break; + case 'R': + chopt.recurse = true; + break; - case 'c': - chopt.verbosity = V_changes_only; - break; + case 'c': + chopt.verbosity = V_changes_only; + break; - case 'f': - chopt.force_silent = true; - break; + case 'f': + chopt.force_silent = true; + break; - case 'v': - chopt.verbosity = V_high; - break; + case 'v': + chopt.verbosity = V_high; + break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (chopt.recurse) { if (bit_flags == FTS_PHYSICAL) - { - if (dereference == 1) - error (EXIT_FAILURE, 0, - _("-R --dereference requires either -H or -L")); - dereference = 0; - } + { + if (dereference == 1) + error (EXIT_FAILURE, 0, + _("-R --dereference requires either -H or -L")); + dereference = 0; + } } else { @@ -270,9 +270,9 @@ main (int argc, char **argv) if (argc - optind < (reference_file ? 1 : 2)) { if (argc <= optind) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); + error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); usage (EXIT_FAILURE); } @@ -280,8 +280,8 @@ main (int argc, char **argv) { struct stat ref_stats; if (stat (reference_file, &ref_stats)) - error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote (reference_file)); + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), + quote (reference_file)); gid = ref_stats.st_gid; chopt.group_name = gid_to_name (ref_stats.st_gid); @@ -298,14 +298,14 @@ main (int argc, char **argv) static struct dev_ino dev_ino_buf; chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (chopt.root_dev_ino == NULL) - error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), + quote ("/")); } bit_flags |= FTS_DEFER_STAT; ok = chown_files (argv + optind, bit_flags, - (uid_t) -1, gid, - (uid_t) -1, (gid_t) -1, &chopt); + (uid_t) -1, gid, + (uid_t) -1, (gid_t) -1, &chopt); chopt_free (&chopt); diff --git a/src/bin/coreutils/src/chmod.c b/src/bin/coreutils/src/chmod.c index 91dfbc3aa5..282eadaffb 100644 --- a/src/bin/coreutils/src/chmod.c +++ b/src/bin/coreutils/src/chmod.c @@ -25,6 +25,7 @@ #include "dev-ino.h" #include "error.h" #include "filemode.h" +#include "ignore-value.h" #include "modechange.h" #include "quote.h" #include "quotearg.h" @@ -115,16 +116,16 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode) if (new_mode & (S_ISUID | S_ISGID | S_ISVTX)) { /* The new mode contains unusual bits that the call to chmod may - have silently cleared. Check whether they actually changed. */ + have silently cleared. Check whether they actually changed. */ struct stat new_stats; if (stat (file, &new_stats) != 0) - { - if (! force_silent) - error (0, errno, _("getting new attributes of %s"), quote (file)); - return false; - } + { + if (! force_silent) + error (0, errno, _("getting new attributes of %s"), quote (file)); + return false; + } new_mode = new_stats.st_mode; } @@ -137,7 +138,7 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode) static void describe_change (const char *file, mode_t mode, - enum Change_status changed) + enum Change_status changed) { char perms[12]; /* "-rwxrwxrwx" ls-style modes. */ const char *fmt; @@ -145,7 +146,7 @@ describe_change (const char *file, mode_t mode, if (changed == CH_NOT_APPLIED) { printf (_("neither symbolic link %s nor referent has been changed\n"), - quote (file)); + quote (file)); return; } @@ -166,7 +167,7 @@ describe_change (const char *file, mode_t mode, abort (); } printf (fmt, quote (file), - (unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]); + (unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]); } /* Change the mode of FILE. @@ -191,21 +192,21 @@ process_file (FTS *fts, FTSENT *ent) case FTS_NS: /* For a top-level file or directory, this FTS_NS (stat failed) - indicator is determined at the time of the initial fts_open call. - With programs like chmod, chown, and chgrp, that modify - permissions, it is possible that the file in question is - accessible when control reaches this point. So, if this is - the first time we've seen the FTS_NS for this file, tell - fts_read to stat it "again". */ + indicator is determined at the time of the initial fts_open call. + With programs like chmod, chown, and chgrp, that modify + permissions, it is possible that the file in question is + accessible when control reaches this point. So, if this is + the first time we've seen the FTS_NS for this file, tell + fts_read to stat it "again". */ if (ent->fts_level == 0 && ent->fts_number == 0) - { - ent->fts_number = 1; - fts_set (fts, ent, FTS_AGAIN); - return true; - } + { + ent->fts_number = 1; + fts_set (fts, ent, FTS_AGAIN); + return true; + } if (! force_silent) error (0, ent->fts_errno, _("cannot access %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; break; @@ -218,14 +219,14 @@ process_file (FTS *fts, FTSENT *ent) case FTS_DNR: if (! force_silent) error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; break; case FTS_SLNONE: if (! force_silent) error (0, 0, _("cannot operate on dangling symlink %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; default: @@ -238,63 +239,63 @@ process_file (FTS *fts, FTSENT *ent) /* Tell fts not to traverse into this hierarchy. */ fts_set (fts, ent, FTS_SKIP); /* Ensure that we do not process "/" on the second visit. */ - ent = fts_read (fts); - ok = false; + ignore_ptr (fts_read (fts)); + return false; } if (ok) { old_mode = file_stats->st_mode; new_mode = mode_adjust (old_mode, S_ISDIR (old_mode) != 0, umask_value, - change, NULL); + change, NULL); if (! S_ISLNK (old_mode)) - { - if (chmodat (fts->fts_cwd_fd, file, new_mode) == 0) - chmod_succeeded = true; - else - { - if (! force_silent) - error (0, errno, _("changing permissions of %s"), - quote (file_full_name)); - ok = false; - } - } + { + if (chmodat (fts->fts_cwd_fd, file, new_mode) == 0) + chmod_succeeded = true; + else + { + if (! force_silent) + error (0, errno, _("changing permissions of %s"), + quote (file_full_name)); + ok = false; + } + } } if (verbosity != V_off) { bool changed = (chmod_succeeded - && mode_changed (file, old_mode, new_mode)); + && mode_changed (file, old_mode, new_mode)); if (changed || verbosity == V_high) - { - enum Change_status ch_status = - (!ok ? CH_FAILED - : !chmod_succeeded ? CH_NOT_APPLIED - : !changed ? CH_NO_CHANGE_REQUESTED - : CH_SUCCEEDED); - describe_change (file_full_name, new_mode, ch_status); - } + { + enum Change_status ch_status = + (!ok ? CH_FAILED + : !chmod_succeeded ? CH_NOT_APPLIED + : !changed ? CH_NO_CHANGE_REQUESTED + : CH_SUCCEEDED); + describe_change (file_full_name, new_mode, ch_status); + } } if (chmod_succeeded & diagnose_surprises) { mode_t naively_expected_mode = - mode_adjust (old_mode, S_ISDIR (old_mode) != 0, 0, change, NULL); + mode_adjust (old_mode, S_ISDIR (old_mode) != 0, 0, change, NULL); if (new_mode & ~naively_expected_mode) - { - char new_perms[12]; - char naively_expected_perms[12]; - strmode (new_mode, new_perms); - strmode (naively_expected_mode, naively_expected_perms); - new_perms[10] = naively_expected_perms[10] = '\0'; - error (0, 0, - _("%s: new permissions are %s, not %s"), - quotearg_colon (file_full_name), - new_perms + 1, naively_expected_perms + 1); - ok = false; - } + { + char new_perms[12]; + char naively_expected_perms[12]; + strmode (new_mode, new_perms); + strmode (naively_expected_mode, naively_expected_perms); + new_perms[10] = naively_expected_perms[10] = '\0'; + error (0, 0, + _("%s: new permissions are %s, not %s"), + quotearg_colon (file_full_name), + new_perms + 1, naively_expected_perms + 1); + ok = false; + } } if ( ! recurse) @@ -320,24 +321,25 @@ process_files (char **files, int bit_flags) ent = fts_read (fts); if (ent == NULL) - { - if (errno != 0) - { - /* FIXME: try to give a better message */ - if (! force_silent) - error (0, errno, _("fts_read failed")); - ok = false; - } - break; - } + { + if (errno != 0) + { + /* FIXME: try to give a better message */ + if (! force_silent) + error (0, errno, _("fts_read failed")); + ok = false; + } + break; + } ok &= process_file (fts, ent); } - /* Ignore failure, since the only way it can do so is in failing to - return to the original directory, and since we're about to exit, - that doesn't matter. */ - fts_close (fts); + if (fts_close (fts) != 0) + { + error (0, errno, _("fts_close failed")); + ok = false; + } return ok; } @@ -347,7 +349,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -355,7 +357,7 @@ Usage: %s [OPTION]... MODE[,MODE]... FILE...\n\ or: %s [OPTION]... OCTAL-MODE FILE...\n\ or: %s [OPTION]... --reference=RFILE FILE...\n\ "), - program_name, program_name, program_name); + program_name, program_name, program_name); fputs (_("\ Change the mode of each FILE to MODE.\n\ \n\ @@ -407,99 +409,99 @@ main (int argc, char **argv) recurse = force_silent = diagnose_surprises = false; while ((c = getopt_long (argc, argv, - "Rcfvr::w::x::X::s::t::u::g::o::a::,::+::=::", - long_options, NULL)) - != -1) + "Rcfvr::w::x::X::s::t::u::g::o::a::,::+::=::", + long_options, NULL)) + != -1) { switch (c) - { - case 'r': - case 'w': - case 'x': - case 'X': - case 's': - case 't': - case 'u': - case 'g': - case 'o': - case 'a': - case ',': - case '+': - case '=': - /* Support nonportable uses like "chmod -w", but diagnose - surprises due to umask confusion. Even though "--", "--r", - etc., are valid modes, there is no "case '-'" here since - getopt_long reserves leading "--" for long options. */ - { - /* Allocate a mode string (e.g., "-rwx") by concatenating - the argument containing this option. If a previous mode - string was given, concatenate the previous string, a - comma, and the new string (e.g., "-s,-rwx"). */ + { + case 'r': + case 'w': + case 'x': + case 'X': + case 's': + case 't': + case 'u': + case 'g': + case 'o': + case 'a': + case ',': + case '+': + case '=': + /* Support nonportable uses like "chmod -w", but diagnose + surprises due to umask confusion. Even though "--", "--r", + etc., are valid modes, there is no "case '-'" here since + getopt_long reserves leading "--" for long options. */ + { + /* Allocate a mode string (e.g., "-rwx") by concatenating + the argument containing this option. If a previous mode + string was given, concatenate the previous string, a + comma, and the new string (e.g., "-s,-rwx"). */ - char const *arg = argv[optind - 1]; - size_t arg_len = strlen (arg); - size_t mode_comma_len = mode_len + !!mode_len; - size_t new_mode_len = mode_comma_len + arg_len; - if (mode_alloc <= new_mode_len) - { - mode_alloc = new_mode_len + 1; - mode = X2REALLOC (mode, &mode_alloc); - } - mode[mode_len] = ','; - strcpy (mode + mode_comma_len, arg); - mode_len = new_mode_len; + char const *arg = argv[optind - 1]; + size_t arg_len = strlen (arg); + size_t mode_comma_len = mode_len + !!mode_len; + size_t new_mode_len = mode_comma_len + arg_len; + if (mode_alloc <= new_mode_len) + { + mode_alloc = new_mode_len + 1; + mode = X2REALLOC (mode, &mode_alloc); + } + mode[mode_len] = ','; + strcpy (mode + mode_comma_len, arg); + mode_len = new_mode_len; - diagnose_surprises = true; - } - break; - case NO_PRESERVE_ROOT: - preserve_root = false; - break; - case PRESERVE_ROOT: - preserve_root = true; - break; - case REFERENCE_FILE_OPTION: - reference_file = optarg; - break; - case 'R': - recurse = true; - break; - case 'c': - verbosity = V_changes_only; - break; - case 'f': - force_silent = true; - break; - case 'v': - verbosity = V_high; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + diagnose_surprises = true; + } + break; + case NO_PRESERVE_ROOT: + preserve_root = false; + break; + case PRESERVE_ROOT: + preserve_root = true; + break; + case REFERENCE_FILE_OPTION: + reference_file = optarg; + break; + case 'R': + recurse = true; + break; + case 'c': + verbosity = V_changes_only; + break; + case 'f': + force_silent = true; + break; + case 'v': + verbosity = V_high; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (reference_file) { if (mode) - { - error (0, 0, _("cannot combine mode and --reference options")); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("cannot combine mode and --reference options")); + usage (EXIT_FAILURE); + } } else { if (!mode) - mode = argv[optind++]; + mode = argv[optind++]; } if (optind >= argc) { if (!mode || mode != argv[optind - 1]) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); + error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); usage (EXIT_FAILURE); } @@ -507,17 +509,17 @@ main (int argc, char **argv) { change = mode_create_from_ref (reference_file); if (!change) - error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote (reference_file)); + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), + quote (reference_file)); } else { change = mode_compile (mode); if (!change) - { - error (0, 0, _("invalid mode: %s"), quote (mode)); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("invalid mode: %s"), quote (mode)); + usage (EXIT_FAILURE); + } umask_value = umask (0); } @@ -526,8 +528,8 @@ main (int argc, char **argv) static struct dev_ino dev_ino_buf; root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (root_dev_ino == NULL) - error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), + quote ("/")); } else { @@ -535,7 +537,7 @@ main (int argc, char **argv) } ok = process_files (argv + optind, - FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT); + FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT); exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/bin/coreutils/src/chown-core.c b/src/bin/coreutils/src/chown-core.c index 3d6bb0e620..705a29bd38 100644 --- a/src/bin/coreutils/src/chown-core.c +++ b/src/bin/coreutils/src/chown-core.c @@ -25,6 +25,7 @@ #include "system.h" #include "chown-core.h" #include "error.h" +#include "ignore-value.h" #include "quote.h" #include "root-dev-ino.h" #include "xfts.h" @@ -83,8 +84,8 @@ gid_to_name (gid_t gid) char buf[INT_BUFSIZE_BOUND (intmax_t)]; struct group *grp = getgrgid (gid); return xstrdup (grp ? grp->gr_name - : TYPE_SIGNED (gid_t) ? imaxtostr (gid, buf) - : umaxtostr (gid, buf)); + : TYPE_SIGNED (gid_t) ? imaxtostr (gid, buf) + : umaxtostr (gid, buf)); } /* Convert the numeric user-id, UID, to a string stored in xmalloc'd memory, @@ -97,8 +98,8 @@ uid_to_name (uid_t uid) char buf[INT_BUFSIZE_BOUND (intmax_t)]; struct passwd *pwd = getpwuid (uid); return xstrdup (pwd ? pwd->pw_name - : TYPE_SIGNED (uid_t) ? imaxtostr (uid, buf) - : umaxtostr (uid, buf)); + : TYPE_SIGNED (uid_t) ? imaxtostr (uid, buf) + : umaxtostr (uid, buf)); } /* Tell the user how/if the user and group of FILE have been changed. @@ -107,7 +108,7 @@ uid_to_name (uid_t uid) static void describe_change (const char *file, enum Change_status changed, - char const *user, char const *group) + char const *user, char const *group) { const char *fmt; char const *spec; @@ -116,22 +117,22 @@ describe_change (const char *file, enum Change_status changed, if (changed == CH_NOT_APPLIED) { printf (_("neither symbolic link %s nor referent has been changed\n"), - quote (file)); + quote (file)); return; } if (user) { if (group) - { - spec_allocated = xmalloc (strlen (user) + 1 + strlen (group) + 1); - stpcpy (stpcpy (stpcpy (spec_allocated, user), ":"), group); - spec = spec_allocated; - } + { + spec_allocated = xmalloc (strlen (user) + 1 + strlen (group) + 1); + stpcpy (stpcpy (stpcpy (spec_allocated, user), ":"), group); + spec = spec_allocated; + } else - { - spec = user; - } + { + spec = user; + } } else { @@ -142,18 +143,18 @@ describe_change (const char *file, enum Change_status changed, { case CH_SUCCEEDED: fmt = (user ? _("changed ownership of %s to %s\n") - : group ? _("changed group of %s to %s\n") - : _("no change to ownership of %s\n")); + : group ? _("changed group of %s to %s\n") + : _("no change to ownership of %s\n")); break; case CH_FAILED: fmt = (user ? _("failed to change ownership of %s to %s\n") - : group ? _("failed to change group of %s to %s\n") - : _("failed to change ownership of %s\n")); + : group ? _("failed to change group of %s to %s\n") + : _("failed to change ownership of %s\n")); break; case CH_NO_CHANGE_REQUESTED: fmt = (user ? _("ownership of %s retained as %s\n") - : group ? _("group of %s retained as %s\n") - : _("ownership of %s retained\n")); + : group ? _("group of %s retained as %s\n") + : _("ownership of %s retained\n")); break; default: abort (); @@ -184,9 +185,9 @@ describe_change (const char *file, enum Change_status changed, static enum RCH_status restricted_chown (int cwd_fd, char const *file, - struct stat const *orig_st, - uid_t uid, gid_t gid, - uid_t required_uid, gid_t required_gid) + struct stat const *orig_st, + uid_t uid, gid_t gid, + uid_t required_uid, gid_t required_gid) { enum RCH_status status = RC_ok; struct stat st; @@ -199,15 +200,15 @@ restricted_chown (int cwd_fd, char const *file, if (! S_ISREG (orig_st->st_mode)) { if (S_ISDIR (orig_st->st_mode)) - open_flags |= O_DIRECTORY; + open_flags |= O_DIRECTORY; else - return RC_do_ordinary_chown; + return RC_do_ordinary_chown; } fd = openat (cwd_fd, file, O_RDONLY | open_flags); if (! (0 <= fd - || (errno == EACCES && S_ISREG (orig_st->st_mode) - && 0 <= (fd = openat (cwd_fd, file, O_WRONLY | open_flags))))) + || (errno == EACCES && S_ISREG (orig_st->st_mode) + && 0 <= (fd = openat (cwd_fd, file, O_WRONLY | open_flags))))) return (errno == EACCES ? RC_do_ordinary_chown : RC_error); if (fstat (fd, &st) != 0) @@ -215,18 +216,18 @@ restricted_chown (int cwd_fd, char const *file, else if (! SAME_INODE (*orig_st, st)) status = RC_inode_changed; else if ((required_uid == (uid_t) -1 || required_uid == st.st_uid) - && (required_gid == (gid_t) -1 || required_gid == st.st_gid)) + && (required_gid == (gid_t) -1 || required_gid == st.st_gid)) { if (fchown (fd, uid, gid) == 0) - { - status = (close (fd) == 0 - ? RC_ok : RC_error); - return status; - } + { + status = (close (fd) == 0 + ? RC_ok : RC_error); + return status; + } else - { - status = RC_error; - } + { + status = RC_error; + } } { /* FIXME: remove these curly braces when we assume C99. */ @@ -245,9 +246,9 @@ restricted_chown (int cwd_fd, char const *file, Return true if successful. */ static bool change_file_owner (FTS *fts, FTSENT *ent, - uid_t uid, gid_t gid, - uid_t required_uid, gid_t required_gid, - struct Chown_option const *chopt) + uid_t uid, gid_t gid, + uid_t required_uid, gid_t required_gid, + struct Chown_option const *chopt) { char const *file_full_name = ent->fts_path; char const *file = ent->fts_accpath; @@ -261,44 +262,44 @@ change_file_owner (FTS *fts, FTSENT *ent, { case FTS_D: if (chopt->recurse) - { - if (ROOT_DEV_INO_CHECK (chopt->root_dev_ino, ent->fts_statp)) - { - /* This happens e.g., with "chown -R --preserve-root 0 /" - and with "chown -RH --preserve-root 0 symlink-to-root". */ - ROOT_DEV_INO_WARN (file_full_name); - /* Tell fts not to traverse into this hierarchy. */ - fts_set (fts, ent, FTS_SKIP); - /* Ensure that we do not process "/" on the second visit. */ - ent = fts_read (fts); - return false; - } - return true; - } + { + if (ROOT_DEV_INO_CHECK (chopt->root_dev_ino, ent->fts_statp)) + { + /* This happens e.g., with "chown -R --preserve-root 0 /" + and with "chown -RH --preserve-root 0 symlink-to-root". */ + ROOT_DEV_INO_WARN (file_full_name); + /* Tell fts not to traverse into this hierarchy. */ + fts_set (fts, ent, FTS_SKIP); + /* Ensure that we do not process "/" on the second visit. */ + ignore_ptr (fts_read (fts)); + return false; + } + return true; + } break; case FTS_DP: if (! chopt->recurse) - return true; + return true; break; case FTS_NS: /* For a top-level file or directory, this FTS_NS (stat failed) - indicator is determined at the time of the initial fts_open call. - With programs like chmod, chown, and chgrp, that modify - permissions, it is possible that the file in question is - accessible when control reaches this point. So, if this is - the first time we've seen the FTS_NS for this file, tell - fts_read to stat it "again". */ + indicator is determined at the time of the initial fts_open call. + With programs like chmod, chown, and chgrp, that modify + permissions, it is possible that the file in question is + accessible when control reaches this point. So, if this is + the first time we've seen the FTS_NS for this file, tell + fts_read to stat it "again". */ if (ent->fts_level == 0 && ent->fts_number == 0) - { - ent->fts_number = 1; - fts_set (fts, ent, FTS_AGAIN); - return true; - } + { + ent->fts_number = 1; + fts_set (fts, ent, FTS_AGAIN); + return true; + } if (! chopt->force_silent) error (0, ent->fts_errno, _("cannot access %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; break; @@ -311,7 +312,7 @@ change_file_owner (FTS *fts, FTSENT *ent, case FTS_DNR: if (! chopt->force_silent) error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; break; @@ -325,9 +326,9 @@ change_file_owner (FTS *fts, FTSENT *ent, file_stats = NULL; } else if (required_uid == (uid_t) -1 && required_gid == (gid_t) -1 - && chopt->verbosity == V_off - && ! chopt->root_dev_ino - && ! chopt->affect_symlink_referent) + && chopt->verbosity == V_off + && ! chopt->root_dev_ino + && ! chopt->affect_symlink_referent) { do_chown = true; file_stats = ent->fts_statp; @@ -337,25 +338,25 @@ change_file_owner (FTS *fts, FTSENT *ent, file_stats = ent->fts_statp; /* If this is a symlink and we're dereferencing them, - stat it to get info on the referent. */ + stat it to get info on the referent. */ if (chopt->affect_symlink_referent && S_ISLNK (file_stats->st_mode)) - { - if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0) - { - if (! chopt->force_silent) - error (0, errno, _("cannot dereference %s"), - quote (file_full_name)); - ok = false; - } + { + if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0) + { + if (! chopt->force_silent) + error (0, errno, _("cannot dereference %s"), + quote (file_full_name)); + ok = false; + } - file_stats = &stat_buf; - } + file_stats = &stat_buf; + } do_chown = (ok - && (required_uid == (uid_t) -1 - || required_uid == file_stats->st_uid) - && (required_gid == (gid_t) -1 - || required_gid == file_stats->st_gid)); + && (required_uid == (uid_t) -1 + || required_uid == file_stats->st_uid) + && (required_gid == (gid_t) -1 + || required_gid == file_stats->st_gid)); } /* This happens when chown -LR --preserve-root encounters a symlink-to-/. */ @@ -370,89 +371,89 @@ change_file_owner (FTS *fts, FTSENT *ent, if (do_chown) { if ( ! chopt->affect_symlink_referent) - { - ok = (lchownat (fts->fts_cwd_fd, file, uid, gid) == 0); + { + ok = (lchownat (fts->fts_cwd_fd, file, uid, gid) == 0); - /* Ignore any error due to lack of support; POSIX requires - this behavior for top-level symbolic links with -h, and - implies that it's required for all symbolic links. */ - if (!ok && errno == EOPNOTSUPP) - { - ok = true; - symlink_changed = false; - } - } + /* Ignore any error due to lack of support; POSIX requires + this behavior for top-level symbolic links with -h, and + implies that it's required for all symbolic links. */ + if (!ok && errno == EOPNOTSUPP) + { + ok = true; + symlink_changed = false; + } + } else - { - /* If possible, avoid a race condition with --from=O:G and without the - (-h) --no-dereference option. If fts's stat call determined - that the uid/gid of FILE matched the --from=O:G-selected - owner and group IDs, blindly using chown(2) here could lead - chown(1) or chgrp(1) mistakenly to dereference a *symlink* - to an arbitrary file that an attacker had moved into the - place of FILE during the window between the stat and - chown(2) calls. If FILE is a regular file or a directory - that can be opened, this race condition can be avoided safely. */ + { + /* If possible, avoid a race condition with --from=O:G and without the + (-h) --no-dereference option. If fts's stat call determined + that the uid/gid of FILE matched the --from=O:G-selected + owner and group IDs, blindly using chown(2) here could lead + chown(1) or chgrp(1) mistakenly to dereference a *symlink* + to an arbitrary file that an attacker had moved into the + place of FILE during the window between the stat and + chown(2) calls. If FILE is a regular file or a directory + that can be opened, this race condition can be avoided safely. */ - enum RCH_status err - = restricted_chown (fts->fts_cwd_fd, file, file_stats, uid, gid, - required_uid, required_gid); - switch (err) - { - case RC_ok: - break; + enum RCH_status err + = restricted_chown (fts->fts_cwd_fd, file, file_stats, uid, gid, + required_uid, required_gid); + switch (err) + { + case RC_ok: + break; - case RC_do_ordinary_chown: - ok = (chownat (fts->fts_cwd_fd, file, uid, gid) == 0); - break; + case RC_do_ordinary_chown: + ok = (chownat (fts->fts_cwd_fd, file, uid, gid) == 0); + break; - case RC_error: - ok = false; - break; + case RC_error: + ok = false; + break; - case RC_inode_changed: - /* FIXME: give a diagnostic in this case? */ - case RC_excluded: - do_chown = false; - ok = false; - break; + case RC_inode_changed: + /* FIXME: give a diagnostic in this case? */ + case RC_excluded: + do_chown = false; + ok = false; + break; - default: - abort (); - } - } + default: + abort (); + } + } /* On some systems (e.g., GNU/Linux 2.4.x), - the chown function resets the `special' permission bits. - Do *not* restore those bits; doing so would open a window in - which a malicious user, M, could subvert a chown command run - by some other user and operating on files in a directory - where M has write access. */ + the chown function resets the `special' permission bits. + Do *not* restore those bits; doing so would open a window in + which a malicious user, M, could subvert a chown command run + by some other user and operating on files in a directory + where M has write access. */ if (do_chown && !ok && ! chopt->force_silent) - error (0, errno, (uid != (uid_t) -1 - ? _("changing ownership of %s") - : _("changing group of %s")), - quote (file_full_name)); + error (0, errno, (uid != (uid_t) -1 + ? _("changing ownership of %s") + : _("changing group of %s")), + quote (file_full_name)); } if (chopt->verbosity != V_off) { bool changed = - ((do_chown & ok & symlink_changed) - && ! ((uid == (uid_t) -1 || uid == file_stats->st_uid) - && (gid == (gid_t) -1 || gid == file_stats->st_gid))); + ((do_chown & ok & symlink_changed) + && ! ((uid == (uid_t) -1 || uid == file_stats->st_uid) + && (gid == (gid_t) -1 || gid == file_stats->st_gid))); if (changed || chopt->verbosity == V_high) - { - enum Change_status ch_status = - (!ok ? CH_FAILED - : !symlink_changed ? CH_NOT_APPLIED - : !changed ? CH_NO_CHANGE_REQUESTED - : CH_SUCCEEDED); - describe_change (file_full_name, ch_status, - chopt->user_name, chopt->group_name); - } + { + enum Change_status ch_status = + (!ok ? CH_FAILED + : !symlink_changed ? CH_NOT_APPLIED + : !changed ? CH_NO_CHANGE_REQUESTED + : CH_SUCCEEDED); + describe_change (file_full_name, ch_status, + chopt->user_name, chopt->group_name); + } } if ( ! chopt->recurse) @@ -472,18 +473,18 @@ change_file_owner (FTS *fts, FTSENT *ent, Return true if successful. */ extern bool chown_files (char **files, int bit_flags, - uid_t uid, gid_t gid, - uid_t required_uid, gid_t required_gid, - struct Chown_option const *chopt) + uid_t uid, gid_t gid, + uid_t required_uid, gid_t required_gid, + struct Chown_option const *chopt) { bool ok = true; /* Use lstat and stat only if they're needed. */ int stat_flags = ((required_uid != (uid_t) -1 || required_gid != (gid_t) -1 - || chopt->affect_symlink_referent - || chopt->verbosity != V_off) - ? 0 - : FTS_NOSTAT); + || chopt->affect_symlink_referent + || chopt->verbosity != V_off) + ? 0 + : FTS_NOSTAT); FTS *fts = xfts_open (files, bit_flags | stat_flags, NULL); @@ -493,25 +494,26 @@ chown_files (char **files, int bit_flags, ent = fts_read (fts); if (ent == NULL) - { - if (errno != 0) - { - /* FIXME: try to give a better message */ - if (! chopt->force_silent) - error (0, errno, _("fts_read failed")); - ok = false; - } - break; - } + { + if (errno != 0) + { + /* FIXME: try to give a better message */ + if (! chopt->force_silent) + error (0, errno, _("fts_read failed")); + ok = false; + } + break; + } ok &= change_file_owner (fts, ent, uid, gid, - required_uid, required_gid, chopt); + required_uid, required_gid, chopt); } - /* Ignore failure, since the only way it can do so is in failing to - return to the original directory, and since we're about to exit, - that doesn't matter. */ - fts_close (fts); + if (fts_close (fts) != 0) + { + error (0, errno, _("fts_close failed")); + ok = false; + } return ok; } diff --git a/src/bin/coreutils/src/chown-core.h b/src/bin/coreutils/src/chown-core.h index 2c6998e352..4947cad290 100644 --- a/src/bin/coreutils/src/chown-core.h +++ b/src/bin/coreutils/src/chown-core.h @@ -79,8 +79,8 @@ uid_to_name (uid_t); bool chown_files (char **files, int bit_flags, - uid_t uid, gid_t gid, - uid_t required_uid, gid_t required_gid, - struct Chown_option const *chopt); + uid_t uid, gid_t gid, + uid_t required_uid, gid_t required_gid, + struct Chown_option const *chopt); #endif /* CHOWN_CORE_H */ diff --git a/src/bin/coreutils/src/chown.c b/src/bin/coreutils/src/chown.c index 00cdb242b3..35488d90e8 100644 --- a/src/bin/coreutils/src/chown.c +++ b/src/bin/coreutils/src/chown.c @@ -85,14 +85,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [OWNER][:[GROUP]] FILE...\n\ or: %s [OPTION]... --reference=RFILE FILE...\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Change the owner and/or group of each FILE to OWNER and/or GROUP.\n\ With --reference, change the owner and group of each FILE to those of RFILE.\n\ @@ -152,7 +152,7 @@ Examples:\n\ %s root:staff /u Likewise, but also change its group to \"staff\".\n\ %s -hR root /u Change the owner of /u and subfiles to \"root\".\n\ "), - program_name, program_name, program_name); + program_name, program_name, program_name); emit_bug_reporting_address (); } exit (status); @@ -193,86 +193,86 @@ main (int argc, char **argv) chopt_init (&chopt); while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, NULL)) - != -1) + != -1) { switch (optc) - { - case 'H': /* Traverse command-line symlinks-to-directories. */ - bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL; - break; + { + case 'H': /* Traverse command-line symlinks-to-directories. */ + bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL; + break; - case 'L': /* Traverse all symlinks-to-directories. */ - bit_flags = FTS_LOGICAL; - break; + case 'L': /* Traverse all symlinks-to-directories. */ + bit_flags = FTS_LOGICAL; + break; - case 'P': /* Traverse no symlinks-to-directories. */ - bit_flags = FTS_PHYSICAL; - break; + case 'P': /* Traverse no symlinks-to-directories. */ + bit_flags = FTS_PHYSICAL; + break; - case 'h': /* --no-dereference: affect symlinks */ - dereference = 0; - break; + case 'h': /* --no-dereference: affect symlinks */ + dereference = 0; + break; - case DEREFERENCE_OPTION: /* --dereference: affect the referent - of each symlink */ - dereference = 1; - break; + case DEREFERENCE_OPTION: /* --dereference: affect the referent + of each symlink */ + dereference = 1; + break; - case NO_PRESERVE_ROOT: - preserve_root = false; - break; + case NO_PRESERVE_ROOT: + preserve_root = false; + break; - case PRESERVE_ROOT: - preserve_root = true; - break; + case PRESERVE_ROOT: + preserve_root = true; + break; - case REFERENCE_FILE_OPTION: - reference_file = optarg; - break; + case REFERENCE_FILE_OPTION: + reference_file = optarg; + break; - case FROM_OPTION: - { - char *u_dummy, *g_dummy; - const char *e = parse_user_spec (optarg, - &required_uid, &required_gid, - &u_dummy, &g_dummy); - if (e) - error (EXIT_FAILURE, 0, "%s: %s", e, quote (optarg)); - break; - } + case FROM_OPTION: + { + char *u_dummy, *g_dummy; + const char *e = parse_user_spec (optarg, + &required_uid, &required_gid, + &u_dummy, &g_dummy); + if (e) + error (EXIT_FAILURE, 0, "%s: %s", e, quote (optarg)); + break; + } - case 'R': - chopt.recurse = true; - break; + case 'R': + chopt.recurse = true; + break; - case 'c': - chopt.verbosity = V_changes_only; - break; + case 'c': + chopt.verbosity = V_changes_only; + break; - case 'f': - chopt.force_silent = true; - break; + case 'f': + chopt.force_silent = true; + break; - case 'v': - chopt.verbosity = V_high; - break; + case 'v': + chopt.verbosity = V_high; + break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (chopt.recurse) { if (bit_flags == FTS_PHYSICAL) - { - if (dereference == 1) - error (EXIT_FAILURE, 0, - _("-R --dereference requires either -H or -L")); - dereference = 0; - } + { + if (dereference == 1) + error (EXIT_FAILURE, 0, + _("-R --dereference requires either -H or -L")); + dereference = 0; + } } else { @@ -283,9 +283,9 @@ main (int argc, char **argv) if (argc - optind < (reference_file ? 1 : 2)) { if (argc <= optind) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); + error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); usage (EXIT_FAILURE); } @@ -293,8 +293,8 @@ main (int argc, char **argv) { struct stat ref_stats; if (stat (reference_file, &ref_stats)) - error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote (reference_file)); + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), + quote (reference_file)); uid = ref_stats.st_uid; gid = ref_stats.st_gid; @@ -304,13 +304,13 @@ main (int argc, char **argv) else { const char *e = parse_user_spec (argv[optind], &uid, &gid, - &chopt.user_name, &chopt.group_name); + &chopt.user_name, &chopt.group_name); if (e) error (EXIT_FAILURE, 0, "%s: %s", e, quote (argv[optind])); /* If a group is specified but no user, set the user name to the - empty string so that diagnostics say "ownership :GROUP" - rather than "group GROUP". */ + empty string so that diagnostics say "ownership :GROUP" + rather than "group GROUP". */ if (!chopt.user_name && chopt.group_name) chopt.user_name = bad_cast (""); @@ -322,14 +322,14 @@ main (int argc, char **argv) static struct dev_ino dev_ino_buf; chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (chopt.root_dev_ino == NULL) - error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), + quote ("/")); } bit_flags |= FTS_DEFER_STAT; ok = chown_files (argv + optind, bit_flags, - uid, gid, - required_uid, required_gid, &chopt); + uid, gid, + required_uid, required_gid, &chopt); chopt_free (&chopt); diff --git a/src/bin/coreutils/src/chroot.c b/src/bin/coreutils/src/chroot.c index ead2669207..5329a9d68c 100644 --- a/src/bin/coreutils/src/chroot.c +++ b/src/bin/coreutils/src/chroot.c @@ -118,7 +118,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -164,7 +164,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); while ((c = getopt_long (argc, argv, "+", long_opts, NULL)) != -1) { @@ -189,7 +189,7 @@ main (int argc, char **argv) if (chroot (argv[optind]) != 0) error (EXIT_FAILURE, errno, _("cannot change root directory to %s"), - argv[optind]); + argv[optind]); if (chdir ("/")) error (EXIT_FAILURE, errno, _("cannot chdir to root directory")); @@ -199,7 +199,7 @@ main (int argc, char **argv) /* No command. Run an interactive shell. */ char *shell = getenv ("SHELL"); if (shell == NULL) - shell = bad_cast ("/bin/sh"); + shell = bad_cast ("/bin/sh"); argv[0] = shell; argv[1] = bad_cast ("-i"); argv[2] = NULL; diff --git a/src/bin/coreutils/src/cksum.c b/src/bin/coreutils/src/cksum.c index da1faedf88..25cdb4789b 100644 --- a/src/bin/coreutils/src/cksum.c +++ b/src/bin/coreutils/src/cksum.c @@ -58,8 +58,8 @@ The i bit in GEN is set if X^i is a summand of G(X) except X^32. */ # define GEN (BIT (26) | BIT (23) | BIT (22) | BIT (16) | BIT (12) \ - | BIT (11) | BIT (10) | BIT (8) | BIT (7) | BIT (5) \ - | BIT (4) | BIT (2) | BIT (1) | BIT (0)) + | BIT (11) | BIT (10) | BIT (8) | BIT (7) | BIT (5) \ + | BIT (4) | BIT (2) | BIT (1) | BIT (0)) static uint_fast32_t r[8]; @@ -96,9 +96,9 @@ main (void) for (i = 0; i < 51; i++) { printf (",\n 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x", - crc_remainder (i * 5 + 1), crc_remainder (i * 5 + 2), - crc_remainder (i * 5 + 3), crc_remainder (i * 5 + 4), - crc_remainder (i * 5 + 5)); + crc_remainder (i * 5 + 1), crc_remainder (i * 5 + 2), + crc_remainder (i * 5 + 3), crc_remainder (i * 5 + 4), + crc_remainder (i * 5 + 5)); } printf ("\n};\n"); exit (EXIT_SUCCESS); @@ -193,16 +193,16 @@ cksum (const char *file, bool print_name) fp = stdin; have_read_stdin = true; if (O_BINARY && ! isatty (STDIN_FILENO)) - xfreopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { fp = fopen (file, (O_BINARY ? "rb" : "r")); if (fp == NULL) - { - error (0, errno, "%s", file); - return false; - } + { + error (0, errno, "%s", file); + return false; + } } while ((bytes_read = fread (buf, 1, BUFLEN, fp)) > 0) @@ -210,19 +210,19 @@ cksum (const char *file, bool print_name) unsigned char *cp = buf; if (length + bytes_read < length) - error (EXIT_FAILURE, 0, _("%s: file too long"), file); + error (EXIT_FAILURE, 0, _("%s: file too long"), file); length += bytes_read; while (bytes_read--) - crc = (crc << 8) ^ crctab[((crc >> 24) ^ *cp++) & 0xFF]; + crc = (crc << 8) ^ crctab[((crc >> 24) ^ *cp++) & 0xFF]; if (feof (fp)) - break; + break; } if (ferror (fp)) { error (0, errno, "%s", file); if (!STREQ (file, "-")) - fclose (fp); + fclose (fp); return false; } @@ -255,14 +255,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [FILE]...\n\ or: %s [OPTION]\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Print CRC checksum and byte counts of each FILE.\n\ \n\ @@ -289,7 +289,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); @@ -301,7 +301,7 @@ main (int argc, char **argv) { ok = true; for (i = optind; i < argc; i++) - ok &= cksum (argv[i], true); + ok &= cksum (argv[i], true); } if (have_read_stdin && fclose (stdin) == EOF) diff --git a/src/bin/coreutils/src/comm.c b/src/bin/coreutils/src/comm.c index e37cf88757..63b6b0c269 100644 --- a/src/bin/coreutils/src/comm.c +++ b/src/bin/coreutils/src/comm.c @@ -96,13 +96,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... FILE1 FILE2\n\ "), - program_name); + program_name); fputs (_("\ Compare sorted files FILE1 and FILE2 line by line.\n\ "), stdout); @@ -139,7 +139,7 @@ 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\ "), - program_name, program_name); + program_name, program_name); emit_bug_reporting_address (); } exit (status); @@ -157,26 +157,26 @@ writeline (struct linebuffer const *line, FILE *stream, int class) { case 1: if (!only_file_1) - return; + return; break; case 2: if (!only_file_2) - return; + return; /* Print a delimiter if we are printing lines from file 1. */ if (only_file_1) - fputs (delimiter, stream); + fputs (delimiter, stream); break; case 3: if (!both) - return; + return; /* Print a delimiter if we are printing lines from file 1. */ if (only_file_1) - fputs (delimiter, stream); + fputs (delimiter, stream); /* Print a delimiter if we are printing lines from file 2. */ if (only_file_2) - fputs (delimiter, stream); + fputs (delimiter, stream); break; } @@ -196,35 +196,35 @@ writeline (struct linebuffer const *line, FILE *stream, int class) static void check_order (struct linebuffer const *prev, - struct linebuffer const *current, - int whatfile) + struct linebuffer const *current, + int whatfile) { if (check_input_order != CHECK_ORDER_DISABLED && ((check_input_order == CHECK_ORDER_ENABLED) || seen_unpairable)) { if (!issued_disorder_warning[whatfile - 1]) - { - int order; + { + int order; - if (hard_LC_COLLATE) - order = xmemcoll (prev->buffer, prev->length - 1, - current->buffer, current->length - 1); - else - order = memcmp2 (prev->buffer, prev->length - 1, - current->buffer, current->length - 1); + if (hard_LC_COLLATE) + order = xmemcoll (prev->buffer, prev->length - 1, + current->buffer, current->length - 1); + else + order = memcmp2 (prev->buffer, prev->length - 1, + current->buffer, current->length - 1); - if (0 < order) - { - error ((check_input_order == CHECK_ORDER_ENABLED - ? EXIT_FAILURE : 0), - 0, _("file %d is not in sorted order"), whatfile); + if (0 < order) + { + error ((check_input_order == CHECK_ORDER_ENABLED + ? EXIT_FAILURE : 0), + 0, _("file %d is not in sorted order"), whatfile); - /* If we get to here, the message was just a warning, but we - want only to issue it once. */ - issued_disorder_warning[whatfile - 1] = true; - } - } + /* If we get to here, the message was just a warning, but we + want only to issue it once. */ + issued_disorder_warning[whatfile - 1] = true; + } + } } } @@ -260,20 +260,20 @@ compare_files (char **infiles) for (i = 0; i < 2; i++) { for (j = 0; j < 4; j++) - { - initbuffer (&lba[i][j]); - all_line[i][j] = &lba[i][j]; - } + { + initbuffer (&lba[i][j]); + all_line[i][j] = &lba[i][j]; + } alt[i][0] = 0; alt[i][1] = 0; alt[i][2] = 0; streams[i] = (STREQ (infiles[i], "-") ? stdin : fopen (infiles[i], "r")); if (!streams[i]) - error (EXIT_FAILURE, errno, "%s", infiles[i]); + error (EXIT_FAILURE, errno, "%s", infiles[i]); thisline[i] = readlinebuffer (all_line[i][alt[i][0]], streams[i]); if (ferror (streams[i])) - error (EXIT_FAILURE, errno, "%s", infiles[i]); + error (EXIT_FAILURE, errno, "%s", infiles[i]); } while (thisline[0] || thisline[1]) @@ -284,69 +284,69 @@ compare_files (char **infiles) /* Compare the next available lines of the two files. */ if (!thisline[0]) - order = 1; + order = 1; else if (!thisline[1]) - order = -1; + order = -1; else - { - if (hard_LC_COLLATE) - order = xmemcoll (thisline[0]->buffer, thisline[0]->length - 1, - thisline[1]->buffer, thisline[1]->length - 1); - else - { - size_t len = min (thisline[0]->length, thisline[1]->length) - 1; - order = memcmp (thisline[0]->buffer, thisline[1]->buffer, len); - if (order == 0) - order = (thisline[0]->length < thisline[1]->length - ? -1 - : thisline[0]->length != thisline[1]->length); - } - } + { + if (hard_LC_COLLATE) + order = xmemcoll (thisline[0]->buffer, thisline[0]->length - 1, + thisline[1]->buffer, thisline[1]->length - 1); + else + { + size_t len = min (thisline[0]->length, thisline[1]->length) - 1; + order = memcmp (thisline[0]->buffer, thisline[1]->buffer, len); + if (order == 0) + order = (thisline[0]->length < thisline[1]->length + ? -1 + : thisline[0]->length != thisline[1]->length); + } + } /* Output the line that is lesser. */ if (order == 0) - writeline (thisline[1], stdout, 3); + writeline (thisline[1], stdout, 3); else - { - seen_unpairable = true; - if (order <= 0) - writeline (thisline[0], stdout, 1); - else - writeline (thisline[1], stdout, 2); - } + { + seen_unpairable = true; + if (order <= 0) + writeline (thisline[0], stdout, 1); + else + writeline (thisline[1], stdout, 2); + } /* Step the file the line came from. - If the files match, step both files. */ + If the files match, step both files. */ if (0 <= order) - fill_up[1] = true; + fill_up[1] = true; if (order <= 0) - fill_up[0] = true; + fill_up[0] = true; for (i = 0; i < 2; i++) - if (fill_up[i]) - { - /* Rotate the buffers for this file. */ - alt[i][2] = alt[i][1]; - alt[i][1] = alt[i][0]; - alt[i][0] = (alt[i][0] + 1) & 0x03; + if (fill_up[i]) + { + /* Rotate the buffers for this file. */ + alt[i][2] = alt[i][1]; + alt[i][1] = alt[i][0]; + alt[i][0] = (alt[i][0] + 1) & 0x03; - thisline[i] = readlinebuffer (all_line[i][alt[i][0]], streams[i]); + thisline[i] = readlinebuffer (all_line[i][alt[i][0]], streams[i]); - if (thisline[i]) - check_order (all_line[i][alt[i][1]], thisline[i], i + 1); + if (thisline[i]) + check_order (all_line[i][alt[i][1]], thisline[i], i + 1); - /* If this is the end of the file we may need to re-check - the order of the previous two lines, since we might have - discovered an unpairable match since we checked before. */ - else if (all_line[i][alt[i][2]]->buffer) - check_order (all_line[i][alt[i][2]], - all_line[i][alt[i][1]], i + 1); + /* If this is the end of the file we may need to re-check + the order of the previous two lines, since we might have + discovered an unpairable match since we checked before. */ + else if (all_line[i][alt[i][2]]->buffer) + check_order (all_line[i][alt[i][2]], + all_line[i][alt[i][1]], i + 1); - if (ferror (streams[i])) - error (EXIT_FAILURE, errno, "%s", infiles[i]); + if (ferror (streams[i])) + error (EXIT_FAILURE, errno, "%s", infiles[i]); - fill_up[i] = false; - } + fill_up[i] = false; + } } for (i = 0; i < 2; i++) @@ -380,50 +380,50 @@ main (int argc, char **argv) switch (c) { case '1': - only_file_1 = false; - break; + only_file_1 = false; + break; case '2': - only_file_2 = false; - break; + only_file_2 = false; + break; case '3': - both = false; - break; + both = false; + break; case NOCHECK_ORDER_OPTION: - check_input_order = CHECK_ORDER_DISABLED; - break; + check_input_order = CHECK_ORDER_DISABLED; + break; case CHECK_ORDER_OPTION: - check_input_order = CHECK_ORDER_ENABLED; - break; + check_input_order = CHECK_ORDER_ENABLED; + break; case OUTPUT_DELIMITER_OPTION: - if (delimiter && !STREQ (delimiter, optarg)) - error (EXIT_FAILURE, 0, _("multiple delimiters specified")); - delimiter = optarg; - if (!*delimiter) - { - error (EXIT_FAILURE, 0, _("empty %s not allowed"), - quote ("--output-delimiter")); - } - break; + if (delimiter && !STREQ (delimiter, optarg)) + error (EXIT_FAILURE, 0, _("multiple delimiters specified")); + delimiter = optarg; + if (!*delimiter) + { + error (EXIT_FAILURE, 0, _("empty %s not allowed"), + quote ("--output-delimiter")); + } + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: - usage (EXIT_FAILURE); + usage (EXIT_FAILURE); } if (argc - optind < 2) { if (argc <= optind) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); + error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); usage (EXIT_FAILURE); } diff --git a/src/bin/coreutils/src/copy.c b/src/bin/coreutils/src/copy.c index 45cbdd3b18..8a1a6481d6 100644 --- a/src/bin/coreutils/src/copy.c +++ b/src/bin/coreutils/src/copy.c @@ -109,13 +109,13 @@ struct dir_list #define DEST_INFO_INITIAL_CAPACITY 61 static bool copy_internal (char const *src_name, char const *dst_name, - bool new_dst, dev_t device, - struct dir_list *ancestors, - const struct cp_options *x, - bool command_line_arg, - bool *first_dir_created_per_command_line_arg, - bool *copy_into_self, - bool *rename_succeeded); + bool new_dst, dev_t device, + struct dir_list *ancestors, + const struct cp_options *x, + bool command_line_arg, + bool *first_dir_created_per_command_line_arg, + bool *copy_into_self, + bool *rename_succeeded); static bool owner_failure_ok (struct cp_options const *x); /* Pointers to the file names: they're used in the diagnostic that is issued @@ -128,13 +128,18 @@ static char const *top_level_dst_name; static inline int utimens_symlink (char const *file, struct timespec const *timespec) { + int err = 0; + #if HAVE_UTIMENSAT - return utimensat (AT_FDCWD, file, timespec, AT_SYMLINK_NOFOLLOW); -#else - /* Don't set errno=ENOTSUP here as we don't want - to output an error message for this case. */ - return 0; + err = utimensat (AT_FDCWD, file, timespec, AT_SYMLINK_NOFOLLOW); + /* When configuring on a system with new headers and libraries, and + running on one with a kernel that is old enough to lack the syscall, + utimensat fails with ENOSYS. Ignore that. */ + if (err && errno == ENOSYS) + err = 0; #endif + + return err; } /* Perform the O(1) btrfs clone operation, if possible. @@ -149,6 +154,8 @@ clone_file (int dest_fd, int src_fd) # define BTRFS_IOC_CLONE _IOW (BTRFS_IOCTL_MAGIC, 9, int) return ioctl (dest_fd, BTRFS_IOC_CLONE, src_fd); #else + (void) dest_fd; + (void) src_fd; errno = ENOTSUP; return -1; #endif @@ -165,7 +172,7 @@ is_ancestor (const struct stat *sb, const struct dir_list *ancestors) while (ancestors != 0) { if (ancestors->ino == sb->st_ino && ancestors->dev == sb->st_dev) - return true; + return true; ancestors = ancestors->parent; } return false; @@ -265,7 +272,7 @@ errno_unsupported (int err) #if USE_XATTR static void copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED, - char const *fmt, ...) + char const *fmt, ...) { int err = errno; va_list ap; @@ -281,7 +288,7 @@ copy_attr_error (struct error_context *ctx ATTRIBUTE_UNUSED, static void copy_attr_allerror (struct error_context *ctx ATTRIBUTE_UNUSED, - char const *fmt, ...) + char const *fmt, ...) { int err = errno; va_list ap; @@ -300,7 +307,7 @@ copy_attr_quote (struct error_context *ctx ATTRIBUTE_UNUSED, char const *str) static void copy_attr_free (struct error_context *ctx ATTRIBUTE_UNUSED, - char const *str ATTRIBUTE_UNUSED) + char const *str ATTRIBUTE_UNUSED) { } @@ -336,15 +343,19 @@ copy_attr_by_name (char const *src_path, char const *dst_path, #else /* USE_XATTR */ 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) +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, char const *dst_path, - const struct cp_options *x) +copy_attr_by_name (char const *src_path ATTRIBUTE_UNUSED, + char const *dst_path ATTRIBUTE_UNUSED, + const struct cp_options *x ATTRIBUTE_UNUSED) { return true; } @@ -361,10 +372,10 @@ copy_attr_by_name (char const *src_path, char const *dst_path, static bool copy_dir (char const *src_name_in, char const *dst_name_in, bool new_dst, - const struct stat *src_sb, struct dir_list *ancestors, - const struct cp_options *x, - bool *first_dir_created_per_command_line_arg, - bool *copy_into_self) + const struct stat *src_sb, struct dir_list *ancestors, + const struct cp_options *x, + bool *first_dir_created_per_command_line_arg, + bool *copy_into_self) { char *name_space; char *namep; @@ -397,19 +408,19 @@ copy_dir (char const *src_name_in, char const *dst_name_in, bool new_dst, char *dst_name = file_name_concat (dst_name_in, namep, NULL); ok &= copy_internal (src_name, dst_name, new_dst, src_sb->st_dev, - ancestors, &non_command_line_options, false, - first_dir_created_per_command_line_arg, - &local_copy_into_self, NULL); + ancestors, &non_command_line_options, false, + first_dir_created_per_command_line_arg, + &local_copy_into_self, NULL); *copy_into_self |= local_copy_into_self; free (dst_name); free (src_name); /* If we're copying into self, there's no point in continuing, - and in fact, that would even infloop, now that we record only - the first created directory per command line argument. */ + and in fact, that would even infloop, now that we record only + the first created directory per command line argument. */ if (local_copy_into_self) - break; + break; namep += strlen (namep) + 1; } @@ -431,8 +442,8 @@ copy_dir (char const *src_name_in, char const *dst_name_in, bool new_dst, static int set_owner (const struct cp_options *x, char const *dst_name, int dest_desc, - struct stat const *src_sb, bool new_dst, - struct stat const *dst_sb) + struct stat const *src_sb, bool new_dst, + struct stat const *dst_sb) { uid_t uid = src_sb->st_uid; gid_t gid = src_sb->st_gid; @@ -447,28 +458,28 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc, { mode_t old_mode = dst_sb->st_mode; mode_t new_mode = - (x->preserve_mode | x->move_mode ? src_sb->st_mode : x->mode); + (x->preserve_mode | x->move_mode ? src_sb->st_mode : x->mode); mode_t restrictive_temp_mode = old_mode & new_mode & S_IRWXU; if ((USE_ACL - || (old_mode & CHMOD_MODE_BITS - & (~new_mode | S_ISUID | S_ISGID | S_ISVTX))) - && qset_acl (dst_name, dest_desc, restrictive_temp_mode) != 0) - { - if (! owner_failure_ok (x)) - error (0, errno, _("clearing permissions for %s"), quote (dst_name)); - return -x->require_preserve; - } + || (old_mode & CHMOD_MODE_BITS + & (~new_mode | S_ISUID | S_ISGID | S_ISVTX))) + && qset_acl (dst_name, dest_desc, restrictive_temp_mode) != 0) + { + if (! owner_failure_ok (x)) + error (0, errno, _("clearing permissions for %s"), quote (dst_name)); + return -x->require_preserve; + } } if (HAVE_FCHOWN && dest_desc != -1) { if (fchown (dest_desc, uid, gid) == 0) - return 1; + return 1; if (errno == EPERM || errno == EINVAL) { - /* We've failed to set *both*. Now, try to set just the group - ID, but ignore any failure here, and don't change errno. */ + /* We've failed to set *both*. Now, try to set just the group + ID, but ignore any failure here, and don't change errno. */ int saved_errno = errno; ignore_value (fchown (dest_desc, -1, gid)); errno = saved_errno; @@ -477,11 +488,11 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc, else { if (lchown (dst_name, uid, gid) == 0) - return 1; + return 1; if (errno == EPERM || errno == EINVAL) { - /* We've failed to set *both*. Now, try to set just the group - ID, but ignore any failure here, and don't change errno. */ + /* We've failed to set *both*. Now, try to set just the group + ID, but ignore any failure here, and don't change errno. */ int saved_errno = errno; ignore_value (lchown (dst_name, -1, gid)); errno = saved_errno; @@ -491,9 +502,9 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc, if (! chown_failure_ok (x)) { error (0, errno, _("failed to preserve ownership for %s"), - quote (dst_name)); + quote (dst_name)); if (x->require_preserve) - return -1; + return -1; } return 0; @@ -513,16 +524,16 @@ set_author (const char *dst_name, int dest_desc, const struct stat *src_sb) /* Preserve the st_author field. */ file_t file = (dest_desc < 0 - ? file_name_lookup (dst_name, 0, 0) - : getdport (dest_desc)); + ? file_name_lookup (dst_name, 0, 0) + : getdport (dest_desc)); if (file == MACH_PORT_NULL) error (0, errno, _("failed to lookup file %s"), quote (dst_name)); else { error_t err = file_chauthor (file, src_sb->st_author); if (err) - error (0, err, _("failed to preserve authorship for %s"), - quote (dst_name)); + error (0, err, _("failed to preserve authorship for %s"), + quote (dst_name)); mach_port_deallocate (mach_task_self (), file); } #else @@ -559,9 +570,9 @@ fchmod_or_lchmod (int desc, char const *name, mode_t mode) static bool copy_reg (char const *src_name, char const *dst_name, - const struct cp_options *x, - mode_t dst_mode, mode_t omitted_permissions, bool *new_dst, - struct stat const *src_sb) + const struct cp_options *x, + mode_t dst_mode, mode_t omitted_permissions, bool *new_dst, + struct stat const *src_sb) { char *buf; char *buf_alloc = NULL; @@ -573,10 +584,11 @@ 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; source_desc = open (src_name, - (O_RDONLY | O_BINARY - | (x->dereference == DEREF_NEVER ? O_NOFOLLOW : 0))); + (O_RDONLY | O_BINARY + | (x->dereference == DEREF_NEVER ? O_NOFOLLOW : 0))); if (source_desc < 0) { error (0, errno, _("cannot open %s for reading"), quote (src_name)); @@ -595,8 +607,8 @@ copy_reg (char const *src_name, char const *dst_name, if (! SAME_INODE (*src_sb, src_open_sb)) { error (0, 0, - _("skipping file %s, as it was replaced while being copied"), - quote (src_name)); + _("skipping file %s, as it was replaced while being copied"), + quote (src_name)); return_val = false; goto close_src_desc; } @@ -609,96 +621,96 @@ copy_reg (char const *src_name, char const *dst_name, dest_errno = errno; /* When using cp --preserve=context to copy to an existing destination, - use the default context rather than that of the source. Why? - 1) the src context may prohibit writing, and - 2) because it's more consistent to use the same context - that is used when the destination file doesn't already exist. */ + use the default context rather than that of the source. Why? + 1) the src context may prohibit writing, and + 2) because it's more consistent to use the same context + that is used when the destination file doesn't already exist. */ if (x->preserve_security_context && 0 <= dest_desc) - { - security_context_t con = NULL; - if (getfscreatecon (&con) < 0) - { - if (!x->reduce_diagnostics || x->require_preserve_context) - error (0, errno, _("failed to get file system create context")); - if (x->require_preserve_context) - { - return_val = false; - goto close_src_and_dst_desc; - } - } + { + security_context_t con = NULL; + if (getfscreatecon (&con) < 0) + { + if (!x->reduce_diagnostics || x->require_preserve_context) + error (0, errno, _("failed to get file system create context")); + if (x->require_preserve_context) + { + return_val = false; + goto close_src_and_dst_desc; + } + } - if (con) - { - if (fsetfilecon (dest_desc, con) < 0) - { - if (!x->reduce_diagnostics || x->require_preserve_context) - error (0, errno, - _("failed to set the security context of %s to %s"), - quote_n (0, dst_name), quote_n (1, con)); - if (x->require_preserve_context) - { - return_val = false; - freecon (con); - goto close_src_and_dst_desc; - } - } - freecon (con); - } - } + if (con) + { + if (fsetfilecon (dest_desc, con) < 0) + { + if (!x->reduce_diagnostics || x->require_preserve_context) + error (0, errno, + _("failed to set the security context of %s to %s"), + quote_n (0, dst_name), quote_n (1, con)); + if (x->require_preserve_context) + { + return_val = false; + freecon (con); + goto close_src_and_dst_desc; + } + } + freecon (con); + } + } if (dest_desc < 0 && x->unlink_dest_after_failed_open) - { - if (unlink (dst_name) != 0) - { - error (0, errno, _("cannot remove %s"), quote (dst_name)); - return_val = false; - goto close_src_desc; - } - if (x->verbose) - printf (_("removed %s\n"), quote (dst_name)); + { + if (unlink (dst_name) != 0) + { + error (0, errno, _("cannot remove %s"), quote (dst_name)); + return_val = false; + goto close_src_desc; + } + if (x->verbose) + printf (_("removed %s\n"), quote (dst_name)); - /* Tell caller that the destination file was unlinked. */ - *new_dst = true; - } + /* Tell caller that the destination file was unlinked. */ + *new_dst = true; + } } if (*new_dst) { int open_flags = O_WRONLY | O_CREAT | O_BINARY; dest_desc = open (dst_name, open_flags | O_EXCL, - dst_mode & ~omitted_permissions); + dst_mode & ~omitted_permissions); dest_errno = errno; /* When trying to copy through a dangling destination symlink, - the above open fails with EEXIST. If that happens, and - 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. */ + the above open fails with EEXIST. If that happens, and + 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. */ if (dest_desc < 0 && dest_errno == EEXIST && ! x->move_mode) - { - struct stat dangling_link_sb; - if (lstat (dst_name, &dangling_link_sb) == 0 - && S_ISLNK (dangling_link_sb.st_mode)) - { - if (x->open_dangling_dest_symlink) - { - dest_desc = open (dst_name, open_flags, - dst_mode & ~omitted_permissions); - dest_errno = errno; - } - else - { - error (0, 0, _("not writing through dangling symlink %s"), - quote (dst_name)); - return_val = false; - goto close_src_desc; - } - } - } + { + struct stat dangling_link_sb; + if (lstat (dst_name, &dangling_link_sb) == 0 + && S_ISLNK (dangling_link_sb.st_mode)) + { + if (x->open_dangling_dest_symlink) + { + dest_desc = open (dst_name, open_flags, + dst_mode & ~omitted_permissions); + dest_errno = errno; + } + else + { + error (0, 0, _("not writing through dangling symlink %s"), + quote (dst_name)); + return_val = false; + goto close_src_desc; + } + } + } } else omitted_permissions = 0; @@ -706,7 +718,7 @@ copy_reg (char const *src_name, char const *dst_name, if (dest_desc < 0) { error (0, dest_errno, _("cannot create regular file %s"), - quote (dst_name)); + quote (dst_name)); return_val = false; goto close_src_desc; } @@ -718,180 +730,186 @@ copy_reg (char const *src_name, char const *dst_name, goto close_src_and_dst_desc; } - if (x->reflink) + if (x->reflink_mode) { - if (clone_file (dest_desc, source_desc)) + bool clone_ok = clone_file (dest_desc, source_desc) == 0; + if (clone_ok || x->reflink_mode == REFLINK_ALWAYS) { - error (0, errno, _("failed to clone %s"), quote (dst_name)); - return_val = false; + if (!clone_ok) + { + error (0, errno, _("failed to clone %s"), quote (dst_name)); + return_val = false; + goto close_src_and_dst_desc; + } + data_copy_required = false; } - goto close_src_and_dst_desc; } - { - typedef uintptr_t word; - off_t n_read_total = 0; + if (data_copy_required) + { + typedef uintptr_t word; + off_t n_read_total = 0; - /* Choose a suitable buffer size; it may be adjusted later. */ - size_t buf_alignment = lcm (getpagesize (), sizeof (word)); - size_t buf_alignment_slop = sizeof (word) + buf_alignment - 1; - size_t buf_size = io_blksize (sb); + /* Choose a suitable buffer size; it may be adjusted later. */ + size_t buf_alignment = lcm (getpagesize (), sizeof (word)); + size_t buf_alignment_slop = sizeof (word) + buf_alignment - 1; + size_t buf_size = io_blksize (sb); - /* Deal with sparse files. */ - bool last_write_made_hole = false; - bool make_holes = false; + /* Deal with sparse files. */ + bool last_write_made_hole = false; + bool make_holes = false; - if (S_ISREG (sb.st_mode)) - { - /* Even with --sparse=always, try to create holes only - if the destination is a regular file. */ - if (x->sparse_mode == SPARSE_ALWAYS) - make_holes = true; + if (S_ISREG (sb.st_mode)) + { + /* Even with --sparse=always, try to create holes only + if the destination is a regular file. */ + if (x->sparse_mode == SPARSE_ALWAYS) + make_holes = true; #if HAVE_STRUCT_STAT_ST_BLOCKS - /* Use a heuristic to determine whether SRC_NAME contains any sparse - blocks. If the file has fewer blocks than would normally be - needed for a file of its size, then at least one of the blocks in - the file is a hole. */ - if (x->sparse_mode == SPARSE_AUTO && S_ISREG (src_open_sb.st_mode) - && ST_NBLOCKS (src_open_sb) < src_open_sb.st_size / ST_NBLOCKSIZE) - make_holes = true; + /* Use a heuristic to determine whether SRC_NAME contains any sparse + blocks. If the file has fewer blocks than would normally be + needed for a file of its size, then at least one of the blocks in + the file is a hole. */ + if (x->sparse_mode == SPARSE_AUTO && S_ISREG (src_open_sb.st_mode) + && ST_NBLOCKS (src_open_sb) < src_open_sb.st_size / ST_NBLOCKSIZE) + make_holes = true; #endif - } + } - /* If not making a sparse file, try to use a more-efficient - buffer size. */ - if (! make_holes) - { - /* Compute the least common multiple of the input and output - buffer sizes, adjusting for outlandish values. */ - size_t blcm_max = MIN (SIZE_MAX, SSIZE_MAX) - buf_alignment_slop; - size_t blcm = buffer_lcm (io_blksize (src_open_sb), buf_size, - blcm_max); + /* If not making a sparse file, try to use a more-efficient + buffer size. */ + if (! make_holes) + { + /* Compute the least common multiple of the input and output + buffer sizes, adjusting for outlandish values. */ + size_t blcm_max = MIN (SIZE_MAX, SSIZE_MAX) - buf_alignment_slop; + size_t blcm = buffer_lcm (io_blksize (src_open_sb), buf_size, + blcm_max); - /* Do not bother with a buffer larger than the input file, plus one - byte to make sure the file has not grown while reading it. */ - if (S_ISREG (src_open_sb.st_mode) && src_open_sb.st_size < buf_size) - buf_size = src_open_sb.st_size + 1; + /* Do not bother with a buffer larger than the input file, plus one + byte to make sure the file has not grown while reading it. */ + if (S_ISREG (src_open_sb.st_mode) && src_open_sb.st_size < buf_size) + buf_size = src_open_sb.st_size + 1; - /* However, stick with a block size that is a positive multiple of - blcm, overriding the above adjustments. Watch out for - overflow. */ - buf_size += blcm - 1; - buf_size -= buf_size % blcm; - if (buf_size == 0 || blcm_max < buf_size) - buf_size = blcm; - } + /* However, stick with a block size that is a positive multiple of + blcm, overriding the above adjustments. Watch out for + overflow. */ + buf_size += blcm - 1; + buf_size -= buf_size % blcm; + if (buf_size == 0 || blcm_max < buf_size) + buf_size = blcm; + } - /* Make a buffer with space for a sentinel at the end. */ - buf_alloc = xmalloc (buf_size + buf_alignment_slop); - buf = ptr_align (buf_alloc, buf_alignment); + /* Make a buffer with space for a sentinel at the end. */ + buf_alloc = xmalloc (buf_size + buf_alignment_slop); + buf = ptr_align (buf_alloc, buf_alignment); - for (;;) - { - word *wp = NULL; + for (;;) + { + word *wp = NULL; - ssize_t n_read = read (source_desc, buf, buf_size); - if (n_read < 0) - { + ssize_t n_read = read (source_desc, buf, buf_size); + if (n_read < 0) + { #ifdef EINTR - if (errno == EINTR) - continue; + if (errno == EINTR) + continue; #endif - error (0, errno, _("reading %s"), quote (src_name)); - return_val = false; - goto close_src_and_dst_desc; - } - if (n_read == 0) - break; + error (0, errno, _("reading %s"), quote (src_name)); + return_val = false; + goto close_src_and_dst_desc; + } + if (n_read == 0) + break; - n_read_total += n_read; + n_read_total += n_read; - if (make_holes) - { - char *cp; + if (make_holes) + { + char *cp; - /* Sentinel to stop loop. */ - buf[n_read] = '\1'; + /* Sentinel to stop loop. */ + buf[n_read] = '\1'; #ifdef lint - /* Usually, buf[n_read] is not the byte just before a "word" - (aka uintptr_t) boundary. In that case, the word-oriented - test below (*wp++ == 0) would read some uninitialized bytes - after the sentinel. To avoid false-positive reports about - this condition (e.g., from a tool like valgrind), set the - remaining bytes -- to any value. */ - memset (buf + n_read + 1, 0, sizeof (word) - 1); + /* Usually, buf[n_read] is not the byte just before a "word" + (aka uintptr_t) boundary. In that case, the word-oriented + test below (*wp++ == 0) would read some uninitialized bytes + after the sentinel. To avoid false-positive reports about + this condition (e.g., from a tool like valgrind), set the + remaining bytes -- to any value. */ + memset (buf + n_read + 1, 0, sizeof (word) - 1); #endif - /* Find first nonzero *word*, or the word with the sentinel. */ + /* Find first nonzero *word*, or the word with the sentinel. */ - wp = (word *) buf; - while (*wp++ == 0) - continue; + wp = (word *) buf; + while (*wp++ == 0) + continue; - /* Find the first nonzero *byte*, or the sentinel. */ + /* Find the first nonzero *byte*, or the sentinel. */ - cp = (char *) (wp - 1); - while (*cp++ == 0) - continue; + cp = (char *) (wp - 1); + while (*cp++ == 0) + continue; - if (cp <= buf + n_read) - /* Clear to indicate that a normal write is needed. */ - wp = NULL; - else - { - /* We found the sentinel, so the whole input block was zero. - Make a hole. */ - if (lseek (dest_desc, n_read, SEEK_CUR) < 0) - { - error (0, errno, _("cannot lseek %s"), quote (dst_name)); - return_val = false; - goto close_src_and_dst_desc; - } - last_write_made_hole = true; - } - } + if (cp <= buf + n_read) + /* Clear to indicate that a normal write is needed. */ + wp = NULL; + else + { + /* We found the sentinel, so the whole input block was zero. + Make a hole. */ + if (lseek (dest_desc, n_read, SEEK_CUR) < 0) + { + error (0, errno, _("cannot lseek %s"), quote (dst_name)); + return_val = false; + goto close_src_and_dst_desc; + } + last_write_made_hole = true; + } + } - if (!wp) - { - size_t n = n_read; - if (full_write (dest_desc, buf, n) != n) - { - error (0, errno, _("writing %s"), quote (dst_name)); - return_val = false; - goto close_src_and_dst_desc; - } - last_write_made_hole = false; + if (!wp) + { + size_t n = n_read; + if (full_write (dest_desc, buf, n) != n) + { + error (0, errno, _("writing %s"), quote (dst_name)); + return_val = false; + goto close_src_and_dst_desc; + } + last_write_made_hole = false; - /* It is tempting to return early here upon a short read from a - regular file. That would save the final read syscall for each - file. Unfortunately that doesn't work for certain files in - /proc with linux kernels from at least 2.6.9 .. 2.6.29. */ - } - } + /* It is tempting to return early here upon a short read from a + regular file. That would save the final read syscall for each + file. Unfortunately that doesn't work for certain files in + /proc with linux kernels from at least 2.6.9 .. 2.6.29. */ + } + } - /* If the file ends with a `hole', we need to do something to record - the length of the file. On modern systems, calling ftruncate does - the job. On systems without native ftruncate support, we have to - write a byte at the ending position. Otherwise the kernel would - truncate the file at the end of the last write operation. */ + /* If the file ends with a `hole', we need to do something to record + the length of the file. On modern systems, calling ftruncate does + the job. On systems without native ftruncate support, we have to + write a byte at the ending position. Otherwise the kernel would + truncate the file at the end of the last write operation. */ - 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)) - { - error (0, errno, _("writing %s"), quote (dst_name)); - return_val = false; - goto close_src_and_dst_desc; - } - } - } + 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)) + { + error (0, errno, _("writing %s"), quote (dst_name)); + return_val = false; + goto close_src_and_dst_desc; + } + } + } if (x->preserve_timestamps) { @@ -900,59 +918,59 @@ copy_reg (char const *src_name, char const *dst_name, timespec[1] = get_stat_mtime (src_sb); if (gl_futimens (dest_desc, dst_name, timespec) != 0) - { - error (0, errno, _("preserving times for %s"), quote (dst_name)); - if (x->require_preserve) - { - return_val = false; - goto close_src_and_dst_desc; - } - } + { + error (0, errno, _("preserving times for %s"), quote (dst_name)); + if (x->require_preserve) + { + return_val = false; + goto close_src_and_dst_desc; + } + } } if (x->preserve_ownership && ! SAME_OWNER_AND_GROUP (*src_sb, sb)) { switch (set_owner (x, dst_name, dest_desc, src_sb, *new_dst, &sb)) - { - case -1: - return_val = false; - goto close_src_and_dst_desc; + { + case -1: + return_val = false; + goto close_src_and_dst_desc; - case 0: - src_mode &= ~ (S_ISUID | S_ISGID | S_ISVTX); - break; - } + case 0: + src_mode &= ~ (S_ISUID | S_ISGID | S_ISVTX); + break; + } } set_author (dst_name, dest_desc, src_sb); if (x->preserve_xattr && ! copy_attr_by_fd (src_name, source_desc, - dst_name, dest_desc, x) + dst_name, dest_desc, x) && x->require_preserve_xattr) - return false; + return_val = false; if (x->preserve_mode || x->move_mode) { if (copy_acl (src_name, source_desc, dst_name, dest_desc, src_mode) != 0 - && x->require_preserve) - return_val = false; + && x->require_preserve) + return_val = false; } else if (x->set_mode) { if (set_acl (dst_name, dest_desc, x->mode) != 0) - return_val = false; + return_val = false; } else if (omitted_permissions) { omitted_permissions &= ~ cached_umask (); if (omitted_permissions - && fchmod_or_lchmod (dest_desc, dst_name, dst_mode) != 0) - { - error (0, errno, _("preserving permissions for %s"), - quote (dst_name)); - if (x->require_preserve) - return_val = false; - } + && fchmod_or_lchmod (dest_desc, dst_name, dst_mode) != 0) + { + error (0, errno, _("preserving permissions for %s"), + quote (dst_name)); + if (x->require_preserve) + return_val = false; + } } if (x->ignore_attributes == 0 @@ -997,8 +1015,8 @@ close_src_desc: static bool same_file_ok (char const *src_name, struct stat const *src_sb, - char const *dst_name, struct stat const *dst_sb, - const struct cp_options *x, bool *return_now, bool *unlink_src) + char const *dst_name, struct stat const *dst_sb, + const struct cp_options *x, bool *return_now, bool *unlink_src) { const struct stat *src_sb_link; const struct stat *dst_sb_link; @@ -1027,10 +1045,10 @@ same_file_ok (char const *src_name, struct stat const *src_sb, same_link = same; /* If both the source and destination files are symlinks (and we'll - know this here IFF preserving symlinks), then it's ok -- as long - as they are distinct. */ + know this here IFF preserving symlinks), then it's ok -- as long + as they are distinct. */ if (S_ISLNK (src_sb->st_mode) && S_ISLNK (dst_sb->st_mode)) - return ! same_name (src_name, dst_name); + return ! same_name (src_name, dst_name); src_sb_link = src_sb; dst_sb_link = dst_sb; @@ -1038,11 +1056,11 @@ same_file_ok (char const *src_name, struct stat const *src_sb, else { if (!same) - return true; + return true; if (lstat (dst_name, &tmp_dst_sb) != 0 - || lstat (src_name, &tmp_src_sb) != 0) - return true; + || lstat (src_name, &tmp_src_sb) != 0) + return true; src_sb_link = &tmp_src_sb; dst_sb_link = &tmp_dst_sb; @@ -1050,13 +1068,13 @@ same_file_ok (char const *src_name, struct stat const *src_sb, same_link = SAME_INODE (*src_sb_link, *dst_sb_link); /* If both are symlinks, then it's ok, but only if the destination - will be unlinked before being opened. This is like the test - above, but with the addition of the unlink_dest_before_opening - conjunct because otherwise, with two symlinks to the same target, - we'd end up truncating the source file. */ + will be unlinked before being opened. This is like the test + above, but with the addition of the unlink_dest_before_opening + conjunct because otherwise, with two symlinks to the same target, + we'd end up truncating the source file. */ if (S_ISLNK (src_sb_link->st_mode) && S_ISLNK (dst_sb_link->st_mode) - && x->unlink_dest_before_opening) - return true; + && x->unlink_dest_before_opening) + return true; } /* The backup code ensures there's a copy, so it's usually ok to @@ -1067,31 +1085,31 @@ same_file_ok (char const *src_name, struct stat const *src_sb, if (x->backup_type != no_backups) { if (!same_link) - { - /* In copy mode when dereferencing symlinks, if the source is a - symlink and the dest is not, then backing up the destination - (moving it aside) would make it a dangling symlink, and the - subsequent attempt to open it in copy_reg would fail with - a misleading diagnostic. Avoid that by returning zero in - that case so the caller can make cp (or mv when it has to - resort to reading the source file) fail now. */ + { + /* In copy mode when dereferencing symlinks, if the source is a + symlink and the dest is not, then backing up the destination + (moving it aside) would make it a dangling symlink, and the + subsequent attempt to open it in copy_reg would fail with + a misleading diagnostic. Avoid that by returning zero in + that case so the caller can make cp (or mv when it has to + resort to reading the source file) fail now. */ - /* FIXME-note: even with the following kludge, we can still provoke - the offending diagnostic. It's just a little harder to do :-) - $ rm -f a b c; touch c; ln -s c b; ln -s b a; cp -b a b - cp: cannot open `a' for reading: No such file or directory - That's misleading, since a subsequent `ls' shows that `a' - is still there. - One solution would be to open the source file *before* moving - aside the destination, but that'd involve a big rewrite. */ - if ( ! x->move_mode - && x->dereference != DEREF_NEVER - && S_ISLNK (src_sb_link->st_mode) - && ! S_ISLNK (dst_sb_link->st_mode)) - return false; + /* FIXME-note: even with the following kludge, we can still provoke + the offending diagnostic. It's just a little harder to do :-) + $ rm -f a b c; touch c; ln -s c b; ln -s b a; cp -b a b + cp: cannot open `a' for reading: No such file or directory + That's misleading, since a subsequent `ls' shows that `a' + is still there. + One solution would be to open the source file *before* moving + aside the destination, but that'd involve a big rewrite. */ + if ( ! x->move_mode + && x->dereference != DEREF_NEVER + && S_ISLNK (src_sb_link->st_mode) + && ! S_ISLNK (dst_sb_link->st_mode)) + return false; - return true; - } + return true; + } return ! same_name (src_name, dst_name); } @@ -1121,19 +1139,19 @@ same_file_ok (char const *src_name, struct stat const *src_sb, if (x->move_mode || x->unlink_dest_before_opening) { if (S_ISLNK (dst_sb_link->st_mode)) - return true; + return true; if (same_link - && 1 < dst_sb_link->st_nlink - && ! same_name (src_name, dst_name)) - { - if (x->move_mode) - { - *unlink_src = true; - *return_now = true; - } - return true; - } + && 1 < dst_sb_link->st_nlink + && ! same_name (src_name, dst_name)) + { + if (x->move_mode) + { + *unlink_src = true; + *return_now = true; + } + return true; + } } /* If neither is a symlink, then it's ok as long as they aren't @@ -1141,14 +1159,14 @@ same_file_ok (char const *src_name, struct stat const *src_sb, if (!S_ISLNK (src_sb_link->st_mode) && !S_ISLNK (dst_sb_link->st_mode)) { if (!SAME_INODE (*src_sb_link, *dst_sb_link)) - return true; + return true; /* If they are the same file, it's ok if we're making hard links. */ if (x->hard_link) - { - *return_now = true; - return true; - } + { + *return_now = true; + return true; + } } /* It's ok to remove a destination symlink. But that works only when we @@ -1161,24 +1179,24 @@ same_file_ok (char const *src_name, struct stat const *src_sb, if (x->dereference == DEREF_NEVER) { if ( ! S_ISLNK (src_sb_link->st_mode)) - tmp_src_sb = *src_sb_link; + tmp_src_sb = *src_sb_link; else if (stat (src_name, &tmp_src_sb) != 0) - return true; + return true; if ( ! S_ISLNK (dst_sb_link->st_mode)) - tmp_dst_sb = *dst_sb_link; + tmp_dst_sb = *dst_sb_link; else if (stat (dst_name, &tmp_dst_sb) != 0) - return true; + return true; if ( ! SAME_INODE (tmp_src_sb, tmp_dst_sb)) - return true; + return true; /* FIXME: shouldn't this be testing whether we're making symlinks? */ if (x->hard_link) - { - *return_now = true; - return true; - } + { + *return_now = true; + return true; + } } return false; @@ -1190,8 +1208,8 @@ static bool writable_destination (char const *file, mode_t mode) { return (S_ISLNK (mode) - || can_write_any_file () - || euidaccess (file, W_OK) == 0); + || can_write_any_file () + || euidaccess (file, W_OK) == 0); } static void @@ -1203,15 +1221,15 @@ overwrite_prompt (char const *dst_name, struct stat const *dst_sb) strmode (dst_sb->st_mode, perms); perms[10] = '\0'; fprintf (stderr, - _("%s: try to overwrite %s, overriding mode %04lo (%s)? "), - program_name, quote (dst_name), - (unsigned long int) (dst_sb->st_mode & CHMOD_MODE_BITS), - &perms[1]); + _("%s: try to overwrite %s, overriding mode %04lo (%s)? "), + program_name, quote (dst_name), + (unsigned long int) (dst_sb->st_mode & CHMOD_MODE_BITS), + &perms[1]); } else { fprintf (stderr, _("%s: overwrite %s? "), - program_name, quote (dst_name)); + program_name, quote (dst_name)); } } @@ -1222,10 +1240,10 @@ dest_info_init (struct cp_options *x) { x->dest_info = hash_initialize (DEST_INFO_INITIAL_CAPACITY, - NULL, - triple_hash, - triple_compare, - triple_free); + NULL, + triple_hash, + triple_compare, + triple_free); } /* Initialize the hash table implementing a set of F_triple entries @@ -1244,10 +1262,10 @@ src_info_init (struct cp_options *x) */ x->src_info = hash_initialize (DEST_INFO_INITIAL_CAPACITY, - NULL, - triple_hash_no_name, - triple_compare, - triple_free); + NULL, + triple_hash_no_name, + triple_compare, + triple_free); } /* When effecting a move (e.g., for mv(1)), and given the name DST_NAME @@ -1289,7 +1307,7 @@ restore_default_fscreatecon_or_die (void) { if (setfscreatecon (NULL) != 0) error (EXIT_FAILURE, errno, - _("failed to restore the default file creation context")); + _("failed to restore the default file creation context")); } /* Copy the file SRC_NAME to the file DST_NAME. The files may be of @@ -1306,14 +1324,14 @@ restore_default_fscreatecon_or_die (void) Return true if successful. */ static bool copy_internal (char const *src_name, char const *dst_name, - bool new_dst, - dev_t device, - struct dir_list *ancestors, - const struct cp_options *x, - bool command_line_arg, - bool *first_dir_created_per_command_line_arg, - bool *copy_into_self, - bool *rename_succeeded) + bool new_dst, + dev_t device, + struct dir_list *ancestors, + const struct cp_options *x, + bool command_line_arg, + bool *first_dir_created_per_command_line_arg, + bool *copy_into_self, + bool *rename_succeeded) { struct stat src_sb; struct stat dst_sb; @@ -1356,13 +1374,13 @@ copy_internal (char const *src_name, char const *dst_name, if (command_line_arg) { if ( ! S_ISDIR (src_sb.st_mode) - && x->backup_type == no_backups - && seen_file (x->src_info, src_name, &src_sb)) - { - error (0, 0, _("warning: source file %s specified more than once"), - quote (src_name)); - return true; - } + && x->backup_type == no_backups + && seen_file (x->src_info, src_name, &src_sb)) + { + error (0, 0, _("warning: source file %s specified more than once"), + quote (src_name)); + return true; + } record_file (x->src_info, src_name, &src_sb); } @@ -1370,256 +1388,256 @@ copy_internal (char const *src_name, char const *dst_name, if (!new_dst) { /* Regular files can be created by writing through symbolic - links, but other files cannot. So use stat on the - destination when copying a regular file, and lstat otherwise. - However, if we intend to unlink or remove the destination - first, use lstat, since a copy won't actually be made to the - destination in that case. */ + links, but other files cannot. So use stat on the + destination when copying a regular file, and lstat otherwise. + However, if we intend to unlink or remove the destination + first, use lstat, since a copy won't actually be made to the + destination in that case. */ bool use_stat = - ((S_ISREG (src_mode) - || (x->copy_as_regular - && ! (S_ISDIR (src_mode) || S_ISLNK (src_mode)))) - && ! (x->move_mode || x->symbolic_link || x->hard_link - || x->backup_type != no_backups - || x->unlink_dest_before_opening)); + ((S_ISREG (src_mode) + || (x->copy_as_regular + && ! (S_ISDIR (src_mode) || S_ISLNK (src_mode)))) + && ! (x->move_mode || x->symbolic_link || x->hard_link + || x->backup_type != no_backups + || x->unlink_dest_before_opening)); if ((use_stat - ? stat (dst_name, &dst_sb) - : lstat (dst_name, &dst_sb)) - != 0) - { - if (errno != ENOENT) - { - error (0, errno, _("cannot stat %s"), quote (dst_name)); - return false; - } - else - { - new_dst = true; - } - } + ? stat (dst_name, &dst_sb) + : lstat (dst_name, &dst_sb)) + != 0) + { + if (errno != ENOENT) + { + error (0, errno, _("cannot stat %s"), quote (dst_name)); + return false; + } + else + { + new_dst = true; + } + } else - { /* Here, we know that dst_name exists, at least to the point - that it is stat'able or lstat'able. */ - bool return_now; - bool unlink_src; + { /* Here, we know that dst_name exists, at least to the point + that it is stat'able or lstat'able. */ + bool return_now; + bool unlink_src; - have_dst_lstat = !use_stat; - if (! same_file_ok (src_name, &src_sb, dst_name, &dst_sb, - x, &return_now, &unlink_src)) - { - error (0, 0, _("%s and %s are the same file"), - quote_n (0, src_name), quote_n (1, dst_name)); - return false; - } + have_dst_lstat = !use_stat; + if (! same_file_ok (src_name, &src_sb, dst_name, &dst_sb, + x, &return_now, &unlink_src)) + { + error (0, 0, _("%s and %s are the same file"), + quote_n (0, src_name), quote_n (1, dst_name)); + return false; + } - if (!S_ISDIR (src_mode) && x->update) - { - /* When preserving time stamps (but not moving within a file - system), don't worry if the destination time stamp is - less than the source merely because of time stamp - truncation. */ - int options = ((x->preserve_timestamps - && ! (x->move_mode - && dst_sb.st_dev == src_sb.st_dev)) - ? UTIMECMP_TRUNCATE_SOURCE - : 0); + if (!S_ISDIR (src_mode) && x->update) + { + /* When preserving time stamps (but not moving within a file + system), don't worry if the destination time stamp is + less than the source merely because of time stamp + truncation. */ + int options = ((x->preserve_timestamps + && ! (x->move_mode + && dst_sb.st_dev == src_sb.st_dev)) + ? UTIMECMP_TRUNCATE_SOURCE + : 0); - if (0 <= utimecmp (dst_name, &dst_sb, &src_sb, options)) - { - /* We're using --update and the destination is not older - than the source, so do not copy or move. Pretend the - rename succeeded, so the caller (if it's mv) doesn't - end up removing the source file. */ - if (rename_succeeded) - *rename_succeeded = true; - return true; - } - } + if (0 <= utimecmp (dst_name, &dst_sb, &src_sb, options)) + { + /* We're using --update and the destination is not older + than the source, so do not copy or move. Pretend the + rename succeeded, so the caller (if it's mv) doesn't + end up removing the source file. */ + if (rename_succeeded) + *rename_succeeded = true; + return true; + } + } - /* When there is an existing destination file, we may end up - returning early, and hence not copying/moving the file. - This may be due to an interactive `negative' reply to the - prompt about the existing file. It may also be due to the - use of the --reply=no option. + /* When there is an existing destination file, we may end up + returning early, and hence not copying/moving the file. + This may be due to an interactive `negative' reply to the + prompt about the existing file. It may also be due to the + use of the --reply=no option. - cp and mv treat -i and -f differently. */ - if (x->move_mode) - { - if (abandon_move (x, dst_name, &dst_sb) - || (unlink_src && unlink (src_name) == 0)) - { - /* Pretend the rename succeeded, so the caller (mv) - doesn't end up removing the source file. */ - if (rename_succeeded) - *rename_succeeded = true; - if (unlink_src && x->verbose) - printf (_("removed %s\n"), quote (src_name)); - return true; - } - if (unlink_src) - { - error (0, errno, _("cannot remove %s"), quote (src_name)); - return false; - } - } - else - { - if (! S_ISDIR (src_mode) - && (x->interactive == I_ALWAYS_NO - || (x->interactive == I_ASK_USER - && (overwrite_prompt (dst_name, &dst_sb), 1) - && ! yesno ()))) - return true; - } + cp and mv treat -i and -f differently. */ + if (x->move_mode) + { + if (abandon_move (x, dst_name, &dst_sb) + || (unlink_src && unlink (src_name) == 0)) + { + /* Pretend the rename succeeded, so the caller (mv) + doesn't end up removing the source file. */ + if (rename_succeeded) + *rename_succeeded = true; + if (unlink_src && x->verbose) + printf (_("removed %s\n"), quote (src_name)); + return true; + } + if (unlink_src) + { + error (0, errno, _("cannot remove %s"), quote (src_name)); + return false; + } + } + else + { + if (! S_ISDIR (src_mode) + && (x->interactive == I_ALWAYS_NO + || (x->interactive == I_ASK_USER + && (overwrite_prompt (dst_name, &dst_sb), 1) + && ! yesno ()))) + return true; + } - if (return_now) - return true; + if (return_now) + return true; - if (!S_ISDIR (dst_sb.st_mode)) - { - if (S_ISDIR (src_mode)) - { - if (x->move_mode && x->backup_type != no_backups) - { - /* Moving a directory onto an existing - non-directory is ok only with --backup. */ - } - else - { - error (0, 0, - _("cannot overwrite non-directory %s with directory %s"), - quote_n (0, dst_name), quote_n (1, src_name)); - return false; - } - } + if (!S_ISDIR (dst_sb.st_mode)) + { + if (S_ISDIR (src_mode)) + { + if (x->move_mode && x->backup_type != no_backups) + { + /* Moving a directory onto an existing + non-directory is ok only with --backup. */ + } + else + { + error (0, 0, + _("cannot overwrite non-directory %s with directory %s"), + quote_n (0, dst_name), quote_n (1, src_name)); + return false; + } + } - /* Don't let the user destroy their data, even if they try hard: - This mv command must fail (likewise for cp): - rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c - Otherwise, the contents of b/f would be lost. - In the case of `cp', b/f would be lost if the user simulated - a move using cp and rm. - Note that it works fine if you use --backup=numbered. */ - if (command_line_arg - && x->backup_type != numbered_backups - && seen_file (x->dest_info, dst_name, &dst_sb)) - { - error (0, 0, - _("will not overwrite just-created %s with %s"), - quote_n (0, dst_name), quote_n (1, src_name)); - return false; - } - } + /* Don't let the user destroy their data, even if they try hard: + This mv command must fail (likewise for cp): + rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c + Otherwise, the contents of b/f would be lost. + In the case of `cp', b/f would be lost if the user simulated + a move using cp and rm. + Note that it works fine if you use --backup=numbered. */ + if (command_line_arg + && x->backup_type != numbered_backups + && seen_file (x->dest_info, dst_name, &dst_sb)) + { + error (0, 0, + _("will not overwrite just-created %s with %s"), + quote_n (0, dst_name), quote_n (1, src_name)); + return false; + } + } - if (!S_ISDIR (src_mode)) - { - if (S_ISDIR (dst_sb.st_mode)) - { - if (x->move_mode && x->backup_type != no_backups) - { - /* Moving a non-directory onto an existing - directory is ok only with --backup. */ - } - else - { - error (0, 0, - _("cannot overwrite directory %s with non-directory"), - quote (dst_name)); - return false; - } - } - } + if (!S_ISDIR (src_mode)) + { + if (S_ISDIR (dst_sb.st_mode)) + { + if (x->move_mode && x->backup_type != no_backups) + { + /* Moving a non-directory onto an existing + directory is ok only with --backup. */ + } + else + { + error (0, 0, + _("cannot overwrite directory %s with non-directory"), + quote (dst_name)); + return false; + } + } + } - if (x->move_mode) - { - /* Don't allow user to move a directory onto a non-directory. */ - if (S_ISDIR (src_sb.st_mode) && !S_ISDIR (dst_sb.st_mode) - && x->backup_type == no_backups) - { - error (0, 0, - _("cannot move directory onto non-directory: %s -> %s"), - quote_n (0, src_name), quote_n (0, dst_name)); - return false; - } - } + if (x->move_mode) + { + /* Don't allow user to move a directory onto a non-directory. */ + if (S_ISDIR (src_sb.st_mode) && !S_ISDIR (dst_sb.st_mode) + && x->backup_type == no_backups) + { + error (0, 0, + _("cannot move directory onto non-directory: %s -> %s"), + quote_n (0, src_name), quote_n (0, dst_name)); + return false; + } + } - if (x->backup_type != no_backups - /* Don't try to back up a destination if the last - component of src_name is "." or "..". */ - && ! dot_or_dotdot (last_component (src_name)) - /* Create a backup of each destination directory in move mode, - but not in copy mode. FIXME: it might make sense to add an - option to suppress backup creation also for move mode. - That would let one use mv to merge new content into an - existing hierarchy. */ - && (x->move_mode || ! S_ISDIR (dst_sb.st_mode))) - { - char *tmp_backup = find_backup_file_name (dst_name, - x->backup_type); + if (x->backup_type != no_backups + /* Don't try to back up a destination if the last + component of src_name is "." or "..". */ + && ! dot_or_dotdot (last_component (src_name)) + /* Create a backup of each destination directory in move mode, + but not in copy mode. FIXME: it might make sense to add an + option to suppress backup creation also for move mode. + That would let one use mv to merge new content into an + existing hierarchy. */ + && (x->move_mode || ! S_ISDIR (dst_sb.st_mode))) + { + char *tmp_backup = find_backup_file_name (dst_name, + x->backup_type); - /* Detect (and fail) when creating the backup file would - destroy the source file. Before, running the commands - cd /tmp; rm -f a a~; : > a; echo A > a~; cp --b=simple a~ a - would leave two zero-length files: a and a~. */ - /* FIXME: but simply change e.g., the final a~ to `./a~' - and the source will still be destroyed. */ - if (STREQ (tmp_backup, src_name)) - { - const char *fmt; - fmt = (x->move_mode - ? _("backing up %s would destroy source; %s not moved") - : _("backing up %s would destroy source; %s not copied")); - error (0, 0, fmt, - quote_n (0, dst_name), - quote_n (1, src_name)); - free (tmp_backup); - return false; - } + /* Detect (and fail) when creating the backup file would + destroy the source file. Before, running the commands + cd /tmp; rm -f a a~; : > a; echo A > a~; cp --b=simple a~ a + would leave two zero-length files: a and a~. */ + /* FIXME: but simply change e.g., the final a~ to `./a~' + and the source will still be destroyed. */ + if (STREQ (tmp_backup, src_name)) + { + const char *fmt; + fmt = (x->move_mode + ? _("backing up %s would destroy source; %s not moved") + : _("backing up %s would destroy source; %s not copied")); + error (0, 0, fmt, + quote_n (0, dst_name), + quote_n (1, src_name)); + free (tmp_backup); + return false; + } - /* FIXME: use fts: - Using alloca for a file name that may be arbitrarily - long is not recommended. In fact, even forming such a name - should be discouraged. Eventually, this code will be rewritten - to use fts, so using alloca here will be less of a problem. */ - ASSIGN_STRDUPA (dst_backup, tmp_backup); - free (tmp_backup); - if (rename (dst_name, dst_backup) != 0) - { - if (errno != ENOENT) - { - error (0, errno, _("cannot backup %s"), quote (dst_name)); - return false; - } - else - { - dst_backup = NULL; - } - } - else - { - backup_succeeded = true; - } - new_dst = true; - } - else if (! S_ISDIR (dst_sb.st_mode) - /* Never unlink dst_name when in move mode. */ - && ! x->move_mode - && (x->unlink_dest_before_opening - || (x->preserve_links && 1 < dst_sb.st_nlink) - || (x->dereference == DEREF_NEVER - && ! S_ISREG (src_sb.st_mode)) - )) - { - if (unlink (dst_name) != 0 && errno != ENOENT) - { - error (0, errno, _("cannot remove %s"), quote (dst_name)); - return false; - } - new_dst = true; - if (x->verbose) - printf (_("removed %s\n"), quote (dst_name)); - } - } + /* FIXME: use fts: + Using alloca for a file name that may be arbitrarily + long is not recommended. In fact, even forming such a name + should be discouraged. Eventually, this code will be rewritten + to use fts, so using alloca here will be less of a problem. */ + ASSIGN_STRDUPA (dst_backup, tmp_backup); + free (tmp_backup); + if (rename (dst_name, dst_backup) != 0) + { + if (errno != ENOENT) + { + error (0, errno, _("cannot backup %s"), quote (dst_name)); + return false; + } + else + { + dst_backup = NULL; + } + } + else + { + backup_succeeded = true; + } + new_dst = true; + } + else if (! S_ISDIR (dst_sb.st_mode) + /* Never unlink dst_name when in move mode. */ + && ! x->move_mode + && (x->unlink_dest_before_opening + || (x->preserve_links && 1 < dst_sb.st_nlink) + || (x->dereference == DEREF_NEVER + && ! S_ISREG (src_sb.st_mode)) + )) + { + if (unlink (dst_name) != 0 && errno != ENOENT) + { + error (0, errno, _("cannot remove %s"), quote (dst_name)); + return false; + } + new_dst = true; + if (x->verbose) + printf (_("removed %s\n"), quote (dst_name)); + } + } } /* Ensure we don't try to copy through a symlink that was @@ -1634,27 +1652,27 @@ copy_internal (char const *src_name, char const *dst_name, struct stat *dst_lstat_sb; /* If we called lstat above, good: use that data. - Otherwise, call lstat here, in case dst_name is a symlink. */ + Otherwise, call lstat here, in case dst_name is a symlink. */ if (have_dst_lstat) - dst_lstat_sb = &dst_sb; + dst_lstat_sb = &dst_sb; else - { - if (lstat (dst_name, &tmp_buf) == 0) - dst_lstat_sb = &tmp_buf; - else - lstat_ok = false; - } + { + if (lstat (dst_name, &tmp_buf) == 0) + dst_lstat_sb = &tmp_buf; + else + lstat_ok = false; + } /* Never copy through a symlink we've just created. */ if (lstat_ok - && S_ISLNK (dst_lstat_sb->st_mode) - && seen_file (x->dest_info, dst_name, dst_lstat_sb)) - { - error (0, 0, - _("will not copy %s through just-created symlink %s"), - quote_n (0, src_name), quote_n (1, dst_name)); - return false; - } + && S_ISLNK (dst_lstat_sb->st_mode) + && seen_file (x->dest_info, dst_name, dst_lstat_sb)) + { + error (0, 0, + _("will not copy %s through just-created symlink %s"), + quote_n (0, src_name), quote_n (1, dst_name)); + return false; + } } /* If the source is a directory, we don't always create the destination @@ -1675,20 +1693,20 @@ copy_internal (char const *src_name, char const *dst_name, Sometimes, when preserving links, we have to record dev/ino even though st_nlink == 1: - when in move_mode, since we may be moving a group of N hard-linked - files (via two or more command line arguments) to a different - partition; the links may be distributed among the command line - arguments (possibly hierarchies) so that the link count of - the final, once-linked source file is reduced to 1 when it is - considered below. But in this case (for mv) we don't need to - incur the expense of recording the dev/ino => name mapping; all we - really need is a lookup, to see if the dev/ino pair has already - been copied. + files (via two or more command line arguments) to a different + partition; the links may be distributed among the command line + arguments (possibly hierarchies) so that the link count of + the final, once-linked source file is reduced to 1 when it is + considered below. But in this case (for mv) we don't need to + incur the expense of recording the dev/ino => name mapping; all we + really need is a lookup, to see if the dev/ino pair has already + been copied. - when using -H and processing a command line argument; - that command line argument could be a symlink pointing to another - command line argument. With `cp -H --preserve=link', we hard-link - those two destination files. + that command line argument could be a symlink pointing to another + command line argument. With `cp -H --preserve=link', we hard-link + those two destination files. - likewise for -L except that it applies to all files, not just - command line arguments. + command line arguments. Also, with --recursive, record dev/ino of each command-line directory. We'll use that info to detect this problem: cp -R dir dir. */ @@ -1698,20 +1716,20 @@ copy_internal (char const *src_name, char const *dst_name, earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev); } else if (x->preserve_links - && !x->hard_link - && (1 < src_sb.st_nlink - || (command_line_arg - && x->dereference == DEREF_COMMAND_LINE_ARGUMENTS) - || x->dereference == DEREF_ALWAYS)) + && !x->hard_link + && (1 < src_sb.st_nlink + || (command_line_arg + && x->dereference == DEREF_COMMAND_LINE_ARGUMENTS) + || x->dereference == DEREF_ALWAYS)) { earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev); } else if (x->recursive && S_ISDIR (src_mode)) { if (command_line_arg) - earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev); + earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev); else - earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev); + earlier_file = src_to_dest_lookup (src_sb.st_ino, src_sb.st_dev); } /* Did we copy this inode somewhere else (in this command line argument) @@ -1720,60 +1738,60 @@ copy_internal (char const *src_name, char const *dst_name, if (earlier_file) { /* Avoid damaging the destination file system by refusing to preserve - hard-linked directories (which are found at least in Netapp snapshot - directories). */ + hard-linked directories (which are found at least in Netapp snapshot + directories). */ if (S_ISDIR (src_mode)) - { - /* If src_name and earlier_file refer to the same directory entry, - then warn about copying a directory into itself. */ - if (same_name (src_name, earlier_file)) - { - error (0, 0, _("cannot copy a directory, %s, into itself, %s"), - quote_n (0, top_level_src_name), - quote_n (1, top_level_dst_name)); - *copy_into_self = true; - goto un_backup; - } - else if (x->dereference == DEREF_ALWAYS) - { - /* This happens when e.g., encountering a directory for the - second or subsequent time via symlinks when cp is invoked - with -R and -L. E.g., - rm -rf a b c d; mkdir a b c d; ln -s ../c a; ln -s ../c b; - cp -RL a b d - */ - } - else - { - error (0, 0, _("will not create hard link %s to directory %s"), - quote_n (0, dst_name), quote_n (1, earlier_file)); - goto un_backup; - } - } + { + /* If src_name and earlier_file refer to the same directory entry, + then warn about copying a directory into itself. */ + if (same_name (src_name, earlier_file)) + { + error (0, 0, _("cannot copy a directory, %s, into itself, %s"), + quote_n (0, top_level_src_name), + quote_n (1, top_level_dst_name)); + *copy_into_self = true; + goto un_backup; + } + else if (x->dereference == DEREF_ALWAYS) + { + /* This happens when e.g., encountering a directory for the + second or subsequent time via symlinks when cp is invoked + with -R and -L. E.g., + rm -rf a b c d; mkdir a b c d; ln -s ../c a; ln -s ../c b; + cp -RL a b d + */ + } + else + { + error (0, 0, _("will not create hard link %s to directory %s"), + quote_n (0, dst_name), quote_n (1, earlier_file)); + goto un_backup; + } + } else - { - bool link_failed = (link (earlier_file, dst_name) != 0); + { + bool link_failed = (link (earlier_file, dst_name) != 0); - /* If the link failed because of an existing destination, - remove that file and then call link again. */ - if (link_failed && errno == EEXIST) - { - if (unlink (dst_name) != 0) - { - error (0, errno, _("cannot remove %s"), quote (dst_name)); - goto un_backup; - } - if (x->verbose) - printf (_("removed %s\n"), quote (dst_name)); - link_failed = (link (earlier_file, dst_name) != 0); - } + /* If the link failed because of an existing destination, + remove that file and then call link again. */ + if (link_failed && errno == EEXIST) + { + if (unlink (dst_name) != 0) + { + error (0, errno, _("cannot remove %s"), quote (dst_name)); + goto un_backup; + } + if (x->verbose) + printf (_("removed %s\n"), quote (dst_name)); + link_failed = (link (earlier_file, dst_name) != 0); + } - if (link_failed) - { - error (0, errno, _("cannot create hard link %s to %s"), - quote_n (0, dst_name), quote_n (1, earlier_file)); - goto un_backup; - } + if (link_failed) + { + error (0, errno, _("cannot create hard link %s to %s"), + quote_n (0, dst_name), quote_n (1, earlier_file)); + goto un_backup; + } else { if (x->ignore_attributes == 0 @@ -1783,106 +1801,106 @@ copy_internal (char const *src_name, char const *dst_name, earlier_file); } - return true; - } + return true; + } } if (x->move_mode) { if (rename (src_name, dst_name) == 0) - { - if (x->verbose && S_ISDIR (src_mode)) - emit_verbose (src_name, dst_name, - backup_succeeded ? dst_backup : NULL); + { + if (x->verbose && S_ISDIR (src_mode)) + emit_verbose (src_name, dst_name, + backup_succeeded ? dst_backup : NULL); - if (rename_succeeded) - *rename_succeeded = true; + if (rename_succeeded) + *rename_succeeded = true; - if (command_line_arg) - { - /* Record destination dev/ino/name, so that if we are asked - to overwrite that file again, we can detect it and fail. */ - /* It's fine to use the _source_ stat buffer (src_sb) to get the - _destination_ dev/ino, since the rename above can't have - changed those, and `mv' always uses lstat. - We could limit it further by operating - only on non-directories. */ - record_file (x->dest_info, dst_name, &src_sb); - } + if (command_line_arg) + { + /* Record destination dev/ino/name, so that if we are asked + to overwrite that file again, we can detect it and fail. */ + /* It's fine to use the _source_ stat buffer (src_sb) to get the + _destination_ dev/ino, since the rename above can't have + changed those, and `mv' always uses lstat. + We could limit it further by operating + only on non-directories. */ + record_file (x->dest_info, dst_name, &src_sb); + } - return true; - } + return true; + } /* FIXME: someday, consider what to do when moving a directory into - itself but when source and destination are on different devices. */ + itself but when source and destination are on different devices. */ /* This happens when attempting to rename a directory to a - subdirectory of itself. */ + subdirectory of itself. */ if (errno == EINVAL) - { - /* FIXME: this is a little fragile in that it relies on rename(2) - failing with a specific errno value. Expect problems on - non-POSIX systems. */ - error (0, 0, _("cannot move %s to a subdirectory of itself, %s"), - quote_n (0, top_level_src_name), - quote_n (1, top_level_dst_name)); + { + /* FIXME: this is a little fragile in that it relies on rename(2) + failing with a specific errno value. Expect problems on + non-POSIX systems. */ + error (0, 0, _("cannot move %s to a subdirectory of itself, %s"), + quote_n (0, top_level_src_name), + quote_n (1, top_level_dst_name)); - /* Note that there is no need to call forget_created here, - (compare with the other calls in this file) since the - destination directory didn't exist before. */ + /* Note that there is no need to call forget_created here, + (compare with the other calls in this file) since the + destination directory didn't exist before. */ - *copy_into_self = true; - /* FIXME-cleanup: Don't return true here; adjust mv.c accordingly. - The only caller that uses this code (mv.c) ends up setting its - exit status to nonzero when copy_into_self is nonzero. */ - return true; - } + *copy_into_self = true; + /* FIXME-cleanup: Don't return true here; adjust mv.c accordingly. + The only caller that uses this code (mv.c) ends up setting its + exit status to nonzero when copy_into_self is nonzero. */ + return true; + } /* WARNING: there probably exist systems for which an inter-device - rename fails with a value of errno not handled here. - If/as those are reported, add them to the condition below. - If this happens to you, please do the following and send the output - to the bug-reporting address (e.g., in the output of cp --help): - touch k; perl -e 'rename "k","/tmp/k" or print "$!(",$!+0,")\n"' - where your current directory is on one partion and /tmp is the other. - Also, please try to find the E* errno macro name corresponding to - the diagnostic and parenthesized integer, and include that in your - e-mail. One way to do that is to run a command like this - find /usr/include/. -type f \ - | xargs grep 'define.*\.*\<18\>' /dev/null - where you'd replace `18' with the integer in parentheses that - was output from the perl one-liner above. - If necessary, of course, change `/tmp' to some other directory. */ + rename fails with a value of errno not handled here. + If/as those are reported, add them to the condition below. + If this happens to you, please do the following and send the output + to the bug-reporting address (e.g., in the output of cp --help): + touch k; perl -e 'rename "k","/tmp/k" or print "$!(",$!+0,")\n"' + where your current directory is on one partion and /tmp is the other. + Also, please try to find the E* errno macro name corresponding to + the diagnostic and parenthesized integer, and include that in your + e-mail. One way to do that is to run a command like this + find /usr/include/. -type f \ + | xargs grep 'define.*\.*\<18\>' /dev/null + where you'd replace `18' with the integer in parentheses that + was output from the perl one-liner above. + If necessary, of course, change `/tmp' to some other directory. */ if (errno != EXDEV) - { - /* There are many ways this can happen due to a race condition. - When something happens between the initial XSTAT and the - subsequent rename, we can get many different types of errors. - For example, if the destination is initially a non-directory - or non-existent, but it is created as a directory, the rename - fails. If two `mv' commands try to rename the same file at - about the same time, one will succeed and the other will fail. - If the permissions on the directory containing the source or - destination file are made too restrictive, the rename will - fail. Etc. */ - error (0, errno, - _("cannot move %s to %s"), - quote_n (0, src_name), quote_n (1, dst_name)); - forget_created (src_sb.st_ino, src_sb.st_dev); - return false; - } + { + /* There are many ways this can happen due to a race condition. + When something happens between the initial XSTAT and the + subsequent rename, we can get many different types of errors. + For example, if the destination is initially a non-directory + or non-existent, but it is created as a directory, the rename + fails. If two `mv' commands try to rename the same file at + about the same time, one will succeed and the other will fail. + If the permissions on the directory containing the source or + destination file are made too restrictive, the rename will + fail. Etc. */ + error (0, errno, + _("cannot move %s to %s"), + quote_n (0, src_name), quote_n (1, dst_name)); + forget_created (src_sb.st_ino, src_sb.st_dev); + return false; + } /* The rename attempt has failed. Remove any existing destination - file so that a cross-device `mv' acts as if it were really using - the rename syscall. */ + file so that a cross-device `mv' acts as if it were really using + the rename syscall. */ if (unlink (dst_name) != 0 && errno != ENOENT) - { - error (0, errno, - _("inter-device move failed: %s to %s; unable to remove target"), - quote_n (0, src_name), quote_n (1, dst_name)); - forget_created (src_sb.st_ino, src_sb.st_dev); - return false; - } + { + error (0, errno, + _("inter-device move failed: %s to %s; unable to remove target"), + quote_n (0, src_name), quote_n (1, dst_name)); + forget_created (src_sb.st_ino, src_sb.st_dev); + return false; + } new_dst = true; } @@ -1895,8 +1913,8 @@ copy_internal (char const *src_name, char const *dst_name, omitted_permissions = (dst_mode_bits & (x->preserve_ownership ? S_IRWXG | S_IRWXO - : S_ISDIR (src_mode) ? S_IWGRP | S_IWOTH - : 0)); + : S_ISDIR (src_mode) ? S_IWGRP | S_IWOTH + : 0)); delayed_ok = true; @@ -1905,33 +1923,33 @@ copy_internal (char const *src_name, char const *dst_name, security_context_t con; if (0 <= lgetfilecon (src_name, &con)) - { - if (setfscreatecon (con) < 0) - { - if (!x->reduce_diagnostics || x->require_preserve_context) - error (0, errno, - _("failed to set default file creation context to %s"), - quote (con)); - if (x->require_preserve_context) - { - freecon (con); - return false; - } - } - freecon (con); - } + { + if (setfscreatecon (con) < 0) + { + if (!x->reduce_diagnostics || x->require_preserve_context) + error (0, errno, + _("failed to set default file creation context to %s"), + quote (con)); + if (x->require_preserve_context) + { + freecon (con); + return false; + } + } + freecon (con); + } else - { + { if (!errno_unsupported (errno) || x->require_preserve_context) - { - 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; - } - } + { + 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; + } + } } if (S_ISDIR (src_mode)) @@ -1944,11 +1962,11 @@ copy_internal (char const *src_name, char const *dst_name, continue to copy this, unless we've got an infinite disk. */ if (is_ancestor (&src_sb, ancestors)) - { - error (0, 0, _("cannot copy cyclic symbolic link %s"), - quote (src_name)); - goto un_backup; - } + { + error (0, 0, _("cannot copy cyclic symbolic link %s"), + quote (src_name)); + goto un_backup; + } /* Insert the current directory in the list of parents. */ @@ -1958,230 +1976,232 @@ copy_internal (char const *src_name, char const *dst_name, dir->dev = src_sb.st_dev; if (new_dst || !S_ISDIR (dst_sb.st_mode)) - { - /* POSIX says mkdir's behavior is implementation-defined when - (src_mode & ~S_IRWXUGO) != 0. However, common practice is - to ask mkdir to copy all the CHMOD_MODE_BITS, letting mkdir - decide what to do with S_ISUID | S_ISGID | S_ISVTX. */ - if (mkdir (dst_name, dst_mode_bits & ~omitted_permissions) != 0) - { - error (0, errno, _("cannot create directory %s"), - quote (dst_name)); - goto un_backup; - } + { + /* POSIX says mkdir's behavior is implementation-defined when + (src_mode & ~S_IRWXUGO) != 0. However, common practice is + to ask mkdir to copy all the CHMOD_MODE_BITS, letting mkdir + decide what to do with S_ISUID | S_ISGID | S_ISVTX. */ + if (mkdir (dst_name, dst_mode_bits & ~omitted_permissions) != 0) + { + error (0, errno, _("cannot create directory %s"), + quote (dst_name)); + goto un_backup; + } - /* We need search and write permissions to the new directory - for writing the directory's contents. Check if these - permissions are there. */ + /* We need search and write permissions to the new directory + for writing the directory's contents. Check if these + permissions are there. */ - if (lstat (dst_name, &dst_sb) != 0) - { - error (0, errno, _("cannot stat %s"), quote (dst_name)); - goto un_backup; - } - else if ((dst_sb.st_mode & S_IRWXU) != S_IRWXU) - { - /* Make the new directory searchable and writable. */ + if (lstat (dst_name, &dst_sb) != 0) + { + error (0, errno, _("cannot stat %s"), quote (dst_name)); + goto un_backup; + } + else if ((dst_sb.st_mode & S_IRWXU) != S_IRWXU) + { + /* Make the new directory searchable and writable. */ - dst_mode = dst_sb.st_mode; - restore_dst_mode = true; + dst_mode = dst_sb.st_mode; + restore_dst_mode = true; - if (lchmod (dst_name, dst_mode | S_IRWXU) != 0) - { - error (0, errno, _("setting permissions for %s"), - quote (dst_name)); - goto un_backup; - } - } + if (lchmod (dst_name, dst_mode | S_IRWXU) != 0) + { + error (0, errno, _("setting permissions for %s"), + quote (dst_name)); + goto un_backup; + } + } - /* Record the created directory's inode and device numbers into - the search structure, so that we can avoid copying it again. - Do this only for the first directory that is created for each - source command line argument. */ - if (!*first_dir_created_per_command_line_arg) - { - remember_copied (dst_name, dst_sb.st_ino, dst_sb.st_dev); - *first_dir_created_per_command_line_arg = true; - } + /* Record the created directory's inode and device numbers into + the search structure, so that we can avoid copying it again. + Do this only for the first directory that is created for each + source command line argument. */ + if (!*first_dir_created_per_command_line_arg) + { + remember_copied (dst_name, dst_sb.st_ino, dst_sb.st_dev); + *first_dir_created_per_command_line_arg = true; + } - if (x->verbose) - emit_verbose (src_name, dst_name, NULL); - } + if (x->verbose) + emit_verbose (src_name, dst_name, NULL); + } /* Decide whether to copy the contents of the directory. */ if (x->one_file_system && device != 0 && device != src_sb.st_dev) - { - /* Here, we are crossing a file system boundary and cp's -x option - is in effect: so don't copy the contents of this directory. */ - } + { + /* Here, we are crossing a file system boundary and cp's -x option + is in effect: so don't copy the contents of this directory. */ + } else - { - /* Copy the contents of the directory. Don't just return if - this fails -- otherwise, the failure to read a single file - in a source directory would cause the containing destination - directory not to have owner/perms set properly. */ - delayed_ok = copy_dir (src_name, dst_name, new_dst, &src_sb, dir, x, - first_dir_created_per_command_line_arg, - copy_into_self); - } + { + /* Copy the contents of the directory. Don't just return if + this fails -- otherwise, the failure to read a single file + in a source directory would cause the containing destination + directory not to have owner/perms set properly. */ + delayed_ok = copy_dir (src_name, dst_name, new_dst, &src_sb, dir, x, + first_dir_created_per_command_line_arg, + copy_into_self); + } } else if (x->symbolic_link) { dest_is_symlink = true; if (*src_name != '/') - { - /* Check that DST_NAME denotes a file in the current directory. */ - struct stat dot_sb; - struct stat dst_parent_sb; - char *dst_parent; - bool in_current_dir; + { + /* Check that DST_NAME denotes a file in the current directory. */ + struct stat dot_sb; + struct stat dst_parent_sb; + char *dst_parent; + bool in_current_dir; - dst_parent = dir_name (dst_name); + dst_parent = dir_name (dst_name); - in_current_dir = (STREQ (".", dst_parent) - /* If either stat call fails, it's ok not to report - the failure and say dst_name is in the current - directory. Other things will fail later. */ - || stat (".", &dot_sb) != 0 - || stat (dst_parent, &dst_parent_sb) != 0 - || SAME_INODE (dot_sb, dst_parent_sb)); - free (dst_parent); + in_current_dir = (STREQ (".", dst_parent) + /* If either stat call fails, it's ok not to report + the failure and say dst_name is in the current + directory. Other things will fail later. */ + || stat (".", &dot_sb) != 0 + || stat (dst_parent, &dst_parent_sb) != 0 + || SAME_INODE (dot_sb, dst_parent_sb)); + free (dst_parent); - if (! in_current_dir) - { - error (0, 0, - _("%s: can make relative symbolic links only in current directory"), - quote (dst_name)); - goto un_backup; - } - } + if (! in_current_dir) + { + error (0, 0, + _("%s: can make relative symbolic links only in current directory"), + quote (dst_name)); + goto un_backup; + } + } if (symlink (src_name, dst_name) != 0) - { - error (0, errno, _("cannot create symbolic link %s to %s"), - quote_n (0, dst_name), quote_n (1, src_name)); - goto un_backup; - } + { + error (0, errno, _("cannot create symbolic link %s to %s"), + quote_n (0, dst_name), quote_n (1, src_name)); + goto un_backup; + } } + /* POSIX 2008 states that it is implementation-defined whether + link() on a symlink creates a hard-link to the symlink, or only + to the referent (effectively dereferencing the symlink) (POSIX + 2001 required the latter behavior, although many systems provided + the former). Yet cp, invoked with `--link --no-dereference', + should not follow the link. We can approximate the desired + behavior by skipping this hard-link creating block and instead + copying the symlink, via the `S_ISLNK'- copying code below. + LINK_FOLLOWS_SYMLINKS is tri-state; if it is -1, we don't know + how link() behaves, so we use the fallback case for safety. + + FIXME - use a gnulib linkat emulation for more fine-tuned + emulation, particularly when LINK_FOLLOWS_SYMLINKS is -1. */ else if (x->hard_link -#ifdef LINK_FOLLOWS_SYMLINKS - /* A POSIX-conforming link syscall dereferences a symlink, yet cp, - invoked with `--link --no-dereference', should not. Thus, with - a POSIX-conforming link system call, we can't use link() here, - since that would create a hard link to the referent (effectively - dereferencing the symlink), rather than to the symlink itself. - We can approximate the desired behavior by skipping this hard-link - creating block and instead copying the symlink, via the `S_ISLNK'- - copying code below. - When link operates on the symlinks themselves, we use this block - and just call link(). */ - && !(S_ISLNK (src_mode) && x->dereference == DEREF_NEVER) -#endif - ) + && (!LINK_FOLLOWS_SYMLINKS + || !S_ISLNK (src_mode) + || x->dereference != DEREF_NEVER)) { if (link (src_name, dst_name)) - { - error (0, errno, _("cannot create link %s"), quote (dst_name)); - goto un_backup; - } + { + error (0, errno, _("cannot create link %s"), quote (dst_name)); + goto un_backup; + } } else if (S_ISREG (src_mode) - || (x->copy_as_regular && !S_ISLNK (src_mode))) + || (x->copy_as_regular && !S_ISLNK (src_mode))) { copied_as_regular = true; /* POSIX says the permission bits of the source file must be - used as the 3rd argument in the open call. Historical - practice passed all the source mode bits to 'open', but the extra - bits were ignored, so it should be the same either way. */ + used as the 3rd argument in the open call. Historical + practice passed all the source mode bits to 'open', but the extra + bits were ignored, so it should be the same either way. */ if (! copy_reg (src_name, dst_name, x, src_mode & S_IRWXUGO, - omitted_permissions, &new_dst, &src_sb)) - goto un_backup; + omitted_permissions, &new_dst, &src_sb)) + goto un_backup; } else if (S_ISFIFO (src_mode)) { /* Use mknod, rather than mkfifo, because the former preserves - the special mode bits of a fifo on Solaris 10, while mkfifo - does not. But fall back on mkfifo, because on some BSD systems, - mknod always fails when asked to create a FIFO. */ + the special mode bits of a fifo on Solaris 10, while mkfifo + does not. But fall back on mkfifo, because on some BSD systems, + mknod always fails when asked to create a FIFO. */ if (mknod (dst_name, src_mode & ~omitted_permissions, 0) != 0) - if (mkfifo (dst_name, src_mode & ~S_IFIFO & ~omitted_permissions) != 0) - { - error (0, errno, _("cannot create fifo %s"), quote (dst_name)); - goto un_backup; - } + if (mkfifo (dst_name, src_mode & ~S_IFIFO & ~omitted_permissions) != 0) + { + error (0, errno, _("cannot create fifo %s"), quote (dst_name)); + goto un_backup; + } } else if (S_ISBLK (src_mode) || S_ISCHR (src_mode) || S_ISSOCK (src_mode)) { if (mknod (dst_name, src_mode & ~omitted_permissions, src_sb.st_rdev) - != 0) - { - error (0, errno, _("cannot create special file %s"), - quote (dst_name)); - goto un_backup; - } + != 0) + { + error (0, errno, _("cannot create special file %s"), + quote (dst_name)); + goto un_backup; + } } else if (S_ISLNK (src_mode)) { char *src_link_val = areadlink_with_size (src_name, src_sb.st_size); dest_is_symlink = true; if (src_link_val == NULL) - { - error (0, errno, _("cannot read symbolic link %s"), quote (src_name)); - goto un_backup; - } + { + error (0, errno, _("cannot read symbolic link %s"), quote (src_name)); + goto un_backup; + } if (symlink (src_link_val, dst_name) == 0) - free (src_link_val); + free (src_link_val); else - { - int saved_errno = errno; - bool same_link = false; - if (x->update && !new_dst && S_ISLNK (dst_sb.st_mode) - && dst_sb.st_size == strlen (src_link_val)) - { - /* See if the destination is already the desired symlink. - FIXME: This behavior isn't documented, and seems wrong - in some cases, e.g., if the destination symlink has the - wrong ownership, permissions, or time stamps. */ - char *dest_link_val = - areadlink_with_size (dst_name, dst_sb.st_size); - if (dest_link_val && STREQ (dest_link_val, src_link_val)) - same_link = true; - free (dest_link_val); - } - free (src_link_val); + { + int saved_errno = errno; + bool same_link = false; + if (x->update && !new_dst && S_ISLNK (dst_sb.st_mode) + && dst_sb.st_size == strlen (src_link_val)) + { + /* See if the destination is already the desired symlink. + FIXME: This behavior isn't documented, and seems wrong + in some cases, e.g., if the destination symlink has the + wrong ownership, permissions, or time stamps. */ + char *dest_link_val = + areadlink_with_size (dst_name, dst_sb.st_size); + if (dest_link_val && STREQ (dest_link_val, src_link_val)) + same_link = true; + free (dest_link_val); + } + free (src_link_val); - if (! same_link) - { - error (0, saved_errno, _("cannot create symbolic link %s"), - quote (dst_name)); - goto un_backup; - } - } + if (! same_link) + { + error (0, saved_errno, _("cannot create symbolic link %s"), + quote (dst_name)); + goto un_backup; + } + } if (x->preserve_security_context) - restore_default_fscreatecon_or_die (); + restore_default_fscreatecon_or_die (); if (x->preserve_ownership) - { - /* Preserve the owner and group of the just-`copied' - symbolic link, if possible. */ - if (HAVE_LCHOWN - && lchown (dst_name, src_sb.st_uid, src_sb.st_gid) != 0 - && ! chown_failure_ok (x)) - { - error (0, errno, _("failed to preserve ownership for %s"), - dst_name); - goto un_backup; - } - else - { - /* Can't preserve ownership of symlinks. - FIXME: maybe give a warning or even error for symlinks - in directories with the sticky bit set -- there, not - preserving owner/group is a potential security problem. */ - } - } + { + /* Preserve the owner and group of the just-`copied' + symbolic link, if possible. */ + if (HAVE_LCHOWN + && lchown (dst_name, src_sb.st_uid, src_sb.st_gid) != 0 + && ! chown_failure_ok (x)) + { + error (0, errno, _("failed to preserve ownership for %s"), + dst_name); + goto un_backup; + } + else + { + /* Can't preserve ownership of symlinks. + FIXME: maybe give a warning or even error for symlinks + in directories with the sticky bit set -- there, not + preserving owner/group is a potential security problem. */ + } + } if (x->ignore_attributes == 0 && copy_attributes_by_name(src_name, dst_name, false) != 0) @@ -2197,10 +2217,10 @@ copy_internal (char const *src_name, char const *dst_name, if (command_line_arg && x->dest_info) { /* Now that the destination file is very likely to exist, - add its info to the set. */ + add its info to the set. */ struct stat sb; if (lstat (dst_name, &sb) == 0) - record_file (x->dest_info, dst_name, &sb); + record_file (x->dest_info, dst_name, &sb); } /* If we've just created a hard-link due to cp's --link option, @@ -2230,14 +2250,14 @@ copy_internal (char const *src_name, char const *dst_name, timespec[1] = get_stat_mtime (&src_sb); if ((dest_is_symlink - ? utimens_symlink (dst_name, timespec) - : utimens (dst_name, timespec)) - != 0) - { - error (0, errno, _("preserving times for %s"), quote (dst_name)); - if (x->require_preserve) - return false; - } + ? utimens_symlink (dst_name, timespec) + : utimens (dst_name, timespec)) + != 0) + { + error (0, errno, _("preserving times for %s"), quote (dst_name)); + if (x->require_preserve) + return false; + } } /* The operations beyond this point may dereference a symlink. */ @@ -2249,14 +2269,14 @@ copy_internal (char const *src_name, char const *dst_name, && (new_dst || !SAME_OWNER_AND_GROUP (src_sb, dst_sb))) { switch (set_owner (x, dst_name, -1, &src_sb, new_dst, &dst_sb)) - { - case -1: - return false; + { + case -1: + return false; - case 0: - src_mode &= ~ (S_ISUID | S_ISGID | S_ISVTX); - break; - } + case 0: + src_mode &= ~ (S_ISUID | S_ISGID | S_ISVTX); + break; + } } set_author (dst_name, -1, &src_sb); @@ -2268,49 +2288,49 @@ copy_internal (char const *src_name, char const *dst_name, if (x->preserve_mode || x->move_mode) { if (copy_acl (src_name, -1, dst_name, -1, src_mode) != 0 - && x->require_preserve) - return false; + && x->require_preserve) + return false; } else if (x->set_mode) { if (set_acl (dst_name, -1, x->mode) != 0) - return false; + return false; } else { if (omitted_permissions) - { - omitted_permissions &= ~ cached_umask (); + { + omitted_permissions &= ~ cached_umask (); - if (omitted_permissions && !restore_dst_mode) - { - /* Permissions were deliberately omitted when the file - was created due to security concerns. See whether - they need to be re-added now. It'd be faster to omit - the lstat, but deducing the current destination mode - is tricky in the presence of implementation-defined - rules for special mode bits. */ - if (new_dst && lstat (dst_name, &dst_sb) != 0) - { - error (0, errno, _("cannot stat %s"), quote (dst_name)); - return false; - } - dst_mode = dst_sb.st_mode; - if (omitted_permissions & ~dst_mode) - restore_dst_mode = true; - } - } + if (omitted_permissions && !restore_dst_mode) + { + /* Permissions were deliberately omitted when the file + was created due to security concerns. See whether + they need to be re-added now. It'd be faster to omit + the lstat, but deducing the current destination mode + is tricky in the presence of implementation-defined + rules for special mode bits. */ + if (new_dst && lstat (dst_name, &dst_sb) != 0) + { + error (0, errno, _("cannot stat %s"), quote (dst_name)); + return false; + } + dst_mode = dst_sb.st_mode; + if (omitted_permissions & ~dst_mode) + restore_dst_mode = true; + } + } if (restore_dst_mode) - { - if (lchmod (dst_name, dst_mode | omitted_permissions) != 0) - { - error (0, errno, _("preserving permissions for %s"), - quote (dst_name)); - if (x->require_preserve) - return false; - } - } + { + if (lchmod (dst_name, dst_mode | omitted_permissions) != 0) + { + error (0, errno, _("preserving permissions for %s"), + quote (dst_name)); + if (x->require_preserve) + return false; + } + } } return delayed_ok; @@ -2332,13 +2352,13 @@ un_backup: if (dst_backup) { if (rename (dst_backup, dst_name) != 0) - error (0, errno, _("cannot un-backup %s"), quote (dst_name)); + error (0, errno, _("cannot un-backup %s"), quote (dst_name)); else - { - if (x->verbose) - printf (_("%s -> %s (unbackup)\n"), - quote_n (0, dst_backup), quote_n (1, dst_name)); - } + { + if (x->verbose) + printf (_("%s -> %s (unbackup)\n"), + quote_n (0, dst_backup), quote_n (1, dst_name)); + } } return false; } @@ -2349,8 +2369,11 @@ valid_options (const struct cp_options *co) assert (co != NULL); assert (VALID_BACKUP_TYPE (co->backup_type)); assert (VALID_SPARSE_MODE (co->sparse_mode)); + assert (VALID_REFLINK_MODE (co->reflink_mode)); assert (!(co->hard_link && co->symbolic_link)); - assert (!(co->reflink && co->sparse_mode != SPARSE_AUTO)); + assert (! + (co->reflink_mode == REFLINK_ALWAYS + && co->sparse_mode != SPARSE_AUTO)); return true; } @@ -2383,9 +2406,9 @@ copy (char const *src_name, char const *dst_name, { bool first_dir_created_per_command_line_arg = false; return copy_internal (src_name, dst_name, nonexistent_dst, 0, NULL, - options, true, - &first_dir_created_per_command_line_arg, - copy_into_self, rename_succeeded); + options, true, + &first_dir_created_per_command_line_arg, + copy_into_self, rename_succeeded); } } @@ -2402,8 +2425,8 @@ cp_options_default (struct cp_options *x) xalloc_die (); if (getppriv (PRIV_EFFECTIVE, pset) == 0) { - x->chown_privileges = priv_ismember (pset, PRIV_FILE_CHOWN); - x->owner_privileges = priv_ismember (pset, PRIV_FILE_OWNER); + x->chown_privileges = priv_ismember (pset, PRIV_FILE_CHOWN); + x->owner_privileges = priv_ismember (pset, PRIV_FILE_OWNER); } priv_freeset (pset); } diff --git a/src/bin/coreutils/src/copy.h b/src/bin/coreutils/src/copy.h index 2487277b13..fd5b20e42a 100644 --- a/src/bin/coreutils/src/copy.h +++ b/src/bin/coreutils/src/copy.h @@ -43,6 +43,19 @@ enum Sparse_type SPARSE_ALWAYS }; +/* Control creation of COW files. */ +enum Reflink_type +{ + /* Default to a standard copy. */ + REFLINK_NEVER, + + /* Try a COW copy and fall back to a standard copy. */ + REFLINK_AUTO, + + /* Require a COW copy and fail if not available. */ + REFLINK_ALWAYS +}; + /* This type is used to help mv (via copy.c) distinguish these cases. */ enum Interactive { @@ -73,6 +86,11 @@ enum Dereference_symlink || (Mode) == SPARSE_AUTO \ || (Mode) == SPARSE_ALWAYS) +# define VALID_REFLINK_MODE(Mode) \ + ((Mode) == REFLINK_NEVER \ + || (Mode) == REFLINK_AUTO \ + || (Mode) == REFLINK_ALWAYS) + /* These options control how files are copied by at least the following programs: mv (when rename doesn't work), cp, install. So, if you add a new member, be sure to initialize it in @@ -222,8 +240,8 @@ struct cp_options such a symlink) and returns false. */ bool open_dangling_dest_symlink; - /* If true, attempt to clone the file instead of copying it. */ - bool reflink; + /* Control creation of COW files. */ + enum Reflink_type reflink_mode; /* This is a set of destination name/inode/dev triples. Each such triple represents a file we have created corresponding to a source file name @@ -255,8 +273,8 @@ int rpl_rename (const char *, const char *); # endif bool copy (char const *src_name, char const *dst_name, - bool nonexistent_dst, const struct cp_options *options, - bool *copy_into_self, bool *rename_succeeded); + bool nonexistent_dst, const struct cp_options *options, + bool *copy_into_self, bool *rename_succeeded); void dest_info_init (struct cp_options *); void src_info_init (struct cp_options *); diff --git a/src/bin/coreutils/src/coreutils.rdef b/src/bin/coreutils/src/coreutils.rdef index f2405e6eb5..9cf1de96af 100644 --- a/src/bin/coreutils/src/coreutils.rdef +++ b/src/bin/coreutils/src/coreutils.rdef @@ -1,6 +1,6 @@ resource app_version { major = 7, - middle = 4, + middle = 6, minor = 0, variety = B_APPV_FINAL, internal = 0, diff --git a/src/bin/coreutils/src/cp-hash.c b/src/bin/coreutils/src/cp-hash.c index 858be07fa2..b929d9ab90 100644 --- a/src/bin/coreutils/src/cp-hash.c +++ b/src/bin/coreutils/src/cp-hash.c @@ -148,9 +148,9 @@ extern void hash_init (void) { src_to_dest = hash_initialize (INITIAL_TABLE_SIZE, NULL, - src_to_dest_hash, - src_to_dest_compare, - src_to_dest_free); + src_to_dest_hash, + src_to_dest_compare, + src_to_dest_free); if (src_to_dest == NULL) xalloc_die (); } diff --git a/src/bin/coreutils/src/cp.c b/src/bin/coreutils/src/cp.c index 79527adc98..01387abfca 100644 --- a/src/bin/coreutils/src/cp.c +++ b/src/bin/coreutils/src/cp.c @@ -103,6 +103,16 @@ static enum Sparse_type const sparse_type[] = }; ARGMATCH_VERIFY (sparse_type_string, sparse_type); +static char const *const reflink_type_string[] = +{ + "auto", "always", NULL +}; +static enum Reflink_type const reflink_type[] = +{ + REFLINK_AUTO, REFLINK_ALWAYS +}; +ARGMATCH_VERIFY (reflink_type_string, reflink_type); + static struct option const long_opts[] = { {"archive", no_argument, NULL, 'a'}, @@ -124,7 +134,7 @@ static struct option const long_opts[] = {"recursive", no_argument, NULL, 'R'}, {"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING}, {"sparse", required_argument, NULL, SPARSE_OPTION}, - {"reflink", no_argument, NULL, REFLINK_OPTION}, + {"reflink", optional_argument, NULL, REFLINK_OPTION}, {"strip-trailing-slashes", no_argument, NULL, STRIP_TRAILING_SLASHES_OPTION}, {"suffix", required_argument, NULL, 'S'}, {"symbolic-link", no_argument, NULL, 's'}, @@ -141,7 +151,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -149,7 +159,7 @@ Usage: %s [OPTION]... [-T] SOURCE DEST\n\ or: %s [OPTION]... SOURCE... DIRECTORY\n\ or: %s [OPTION]... -t DIRECTORY SOURCE...\n\ "), - program_name, program_name, program_name); + program_name, program_name, program_name); fputs (_("\ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\ \n\ @@ -195,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 perform a lightweight (CoW/clone) copy\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\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); @@ -226,6 +236,10 @@ corresponding DEST file is made sparse as well. That is the behavior\n\ selected by --sparse=auto. Specify --sparse=always to create a sparse DEST\n\ file whenever the SOURCE file contains a long enough sequence of zero bytes.\n\ Use --sparse=never to inhibit creation of sparse files.\n\ +\n\ +When --reflink[=always] is specified, perform a lightweight copy, where the\n\ +data blocks are copied only when modified. If this is not possible the copy\n\ +fails, or if --reflink=auto is specified, fall back to a standard copy.\n\ "), stdout); fputs (_("\ \n\ @@ -273,7 +287,7 @@ regular file.\n\ static bool re_protect (char const *const_dst_name, size_t src_offset, - struct dir_attr *attr_list, const struct cp_options *x) + struct dir_attr *attr_list, const struct cp_options *x) { struct dir_attr *p; char *dst_name; /* A copy of CONST_DST_NAME we can change. */ @@ -287,26 +301,26 @@ re_protect (char const *const_dst_name, size_t src_offset, dst_name[p->slash_offset] = '\0'; /* Adjust the times (and if possible, ownership) for the copy. - chown turns off set[ug]id bits for non-root, - so do the chmod last. */ + chown turns off set[ug]id bits for non-root, + so do the chmod last. */ if (x->preserve_timestamps) - { - struct timespec timespec[2]; + { + struct timespec timespec[2]; - timespec[0] = get_stat_atime (&p->st); - timespec[1] = get_stat_mtime (&p->st); + timespec[0] = get_stat_atime (&p->st); + timespec[1] = get_stat_mtime (&p->st); - if (utimens (dst_name, timespec)) - { - error (0, errno, _("failed to preserve times for %s"), - quote (dst_name)); - return false; - } - } + if (utimens (dst_name, timespec)) + { + error (0, errno, _("failed to preserve times for %s"), + quote (dst_name)); + return false; + } + } if (x->preserve_ownership) - { + { if (lchown (dst_name, p->st.st_uid, p->st.st_gid) != 0) { if (! chown_failure_ok (x)) @@ -319,22 +333,22 @@ re_protect (char const *const_dst_name, size_t src_offset, the group, but ignore the possible error. */ ignore_value (lchown (dst_name, -1, p->st.st_gid)); } - } + } if (x->preserve_mode) - { - if (copy_acl (src_name, -1, dst_name, -1, p->st.st_mode) != 0) - return false; - } + { + if (copy_acl (src_name, -1, dst_name, -1, p->st.st_mode) != 0) + return false; + } else if (p->restore_mode) - { - if (lchmod (dst_name, p->st.st_mode) != 0) - { - error (0, errno, _("failed to preserve permissions for %s"), - quote (dst_name)); - return false; - } - } + { + if (lchmod (dst_name, p->st.st_mode) != 0) + { + error (0, errno, _("failed to preserve permissions for %s"), + quote (dst_name)); + return false; + } + } dst_name[p->slash_offset] = '/'; } @@ -362,9 +376,9 @@ re_protect (char const *const_dst_name, size_t src_offset, static bool make_dir_parents_private (char const *const_dir, size_t src_offset, - char const *verbose_fmt_string, - struct dir_attr **attr_list, bool *new_dst, - const struct cp_options *x) + char const *verbose_fmt_string, + struct dir_attr **attr_list, bool *new_dst, + const struct cp_options *x) { struct stat stats; char *dir; /* A copy of CONST_DIR we can change. */ @@ -386,139 +400,139 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, if (stat (dst_dir, &stats) != 0) { /* A parent of CONST_DIR does not exist. - Make all missing intermediate directories. */ + Make all missing intermediate directories. */ char *slash; slash = src; while (*slash == '/') - slash++; + slash++; while ((slash = strchr (slash, '/'))) - { - struct dir_attr *new IF_LINT (= NULL); - bool missing_dir; + { + struct dir_attr *new IF_LINT (= NULL); + bool missing_dir; - *slash = '\0'; - missing_dir = (stat (dir, &stats) != 0); + *slash = '\0'; + missing_dir = (stat (dir, &stats) != 0); - if (missing_dir | x->preserve_ownership | x->preserve_mode - | x->preserve_timestamps) - { - /* Add this directory to the list of directories whose - modes might need fixing later. */ - struct stat src_st; - int src_errno = (stat (src, &src_st) != 0 - ? errno - : S_ISDIR (src_st.st_mode) - ? 0 - : ENOTDIR); - if (src_errno) - { - error (0, src_errno, _("failed to get attributes of %s"), - quote (src)); - return false; - } + if (missing_dir | x->preserve_ownership | x->preserve_mode + | x->preserve_timestamps) + { + /* Add this directory to the list of directories whose + modes might need fixing later. */ + struct stat src_st; + int src_errno = (stat (src, &src_st) != 0 + ? errno + : S_ISDIR (src_st.st_mode) + ? 0 + : ENOTDIR); + if (src_errno) + { + error (0, src_errno, _("failed to get attributes of %s"), + quote (src)); + return false; + } - new = xmalloc (sizeof *new); - new->st = src_st; - new->slash_offset = slash - dir; - new->restore_mode = false; - new->next = *attr_list; - *attr_list = new; - } + new = xmalloc (sizeof *new); + new->st = src_st; + new->slash_offset = slash - dir; + new->restore_mode = false; + new->next = *attr_list; + *attr_list = new; + } - if (missing_dir) - { - mode_t src_mode; - mode_t omitted_permissions; - mode_t mkdir_mode; + if (missing_dir) + { + mode_t src_mode; + mode_t omitted_permissions; + mode_t mkdir_mode; - /* This component does not exist. We must set - *new_dst and new->st.st_mode inside this loop because, - for example, in the command `cp --parents ../a/../b/c e_dir', - make_dir_parents_private creates only e_dir/../a if - ./b already exists. */ - *new_dst = true; - src_mode = new->st.st_mode; + /* This component does not exist. We must set + *new_dst and new->st.st_mode inside this loop because, + for example, in the command `cp --parents ../a/../b/c e_dir', + make_dir_parents_private creates only e_dir/../a if + ./b already exists. */ + *new_dst = true; + src_mode = new->st.st_mode; - /* If the ownership or special mode bits might change, - omit some permissions at first, so unauthorized users - cannot nip in before the file is ready. */ - omitted_permissions = (src_mode - & (x->preserve_ownership - ? S_IRWXG | S_IRWXO - : x->preserve_mode - ? S_IWGRP | S_IWOTH - : 0)); + /* If the ownership or special mode bits might change, + omit some permissions at first, so unauthorized users + cannot nip in before the file is ready. */ + omitted_permissions = (src_mode + & (x->preserve_ownership + ? S_IRWXG | S_IRWXO + : x->preserve_mode + ? S_IWGRP | S_IWOTH + : 0)); - /* POSIX says mkdir's behavior is implementation-defined when - (src_mode & ~S_IRWXUGO) != 0. However, common practice is - to ask mkdir to copy all the CHMOD_MODE_BITS, letting mkdir - decide what to do with S_ISUID | S_ISGID | S_ISVTX. */ - mkdir_mode = src_mode & CHMOD_MODE_BITS & ~omitted_permissions; - if (mkdir (dir, mkdir_mode) != 0) - { - error (0, errno, _("cannot make directory %s"), - quote (dir)); - return false; - } - else - { - if (verbose_fmt_string != NULL) - printf (verbose_fmt_string, src, dir); - } + /* POSIX says mkdir's behavior is implementation-defined when + (src_mode & ~S_IRWXUGO) != 0. However, common practice is + to ask mkdir to copy all the CHMOD_MODE_BITS, letting mkdir + decide what to do with S_ISUID | S_ISGID | S_ISVTX. */ + mkdir_mode = src_mode & CHMOD_MODE_BITS & ~omitted_permissions; + if (mkdir (dir, mkdir_mode) != 0) + { + error (0, errno, _("cannot make directory %s"), + quote (dir)); + return false; + } + else + { + if (verbose_fmt_string != NULL) + printf (verbose_fmt_string, src, dir); + } - /* We need search and write permissions to the new directory - for writing the directory's contents. Check if these - permissions are there. */ + /* We need search and write permissions to the new directory + for writing the directory's contents. Check if these + permissions are there. */ - if (lstat (dir, &stats)) - { - error (0, errno, _("failed to get attributes of %s"), - quote (dir)); - return false; - } + if (lstat (dir, &stats)) + { + error (0, errno, _("failed to get attributes of %s"), + quote (dir)); + return false; + } - if (! x->preserve_mode) - { - if (omitted_permissions & ~stats.st_mode) - omitted_permissions &= ~ cached_umask (); - if (omitted_permissions & ~stats.st_mode - || (stats.st_mode & S_IRWXU) != S_IRWXU) - { - new->st.st_mode = stats.st_mode | omitted_permissions; - new->restore_mode = true; - } - } + if (! x->preserve_mode) + { + if (omitted_permissions & ~stats.st_mode) + omitted_permissions &= ~ cached_umask (); + if (omitted_permissions & ~stats.st_mode + || (stats.st_mode & S_IRWXU) != S_IRWXU) + { + new->st.st_mode = stats.st_mode | omitted_permissions; + new->restore_mode = true; + } + } - if ((stats.st_mode & S_IRWXU) != S_IRWXU) - { - /* Make the new directory searchable and writable. - The original permissions will be restored later. */ + if ((stats.st_mode & S_IRWXU) != S_IRWXU) + { + /* Make the new directory searchable and writable. + The original permissions will be restored later. */ - if (lchmod (dir, stats.st_mode | S_IRWXU) != 0) - { - error (0, errno, _("setting permissions for %s"), - quote (dir)); - return false; - } - } - } - else if (!S_ISDIR (stats.st_mode)) - { - error (0, 0, _("%s exists but is not a directory"), - quote (dir)); - return false; - } - else - *new_dst = false; - *slash++ = '/'; + if (lchmod (dir, stats.st_mode | S_IRWXU) != 0) + { + error (0, errno, _("setting permissions for %s"), + quote (dir)); + return false; + } + } + } + else if (!S_ISDIR (stats.st_mode)) + { + error (0, 0, _("%s exists but is not a directory"), + quote (dir)); + return false; + } + else + *new_dst = false; + *slash++ = '/'; - /* Avoid unnecessary calls to `stat' when given - file names containing multiple adjacent slashes. */ - while (*slash == '/') - slash++; - } + /* Avoid unnecessary calls to `stat' when given + file names containing multiple adjacent slashes. */ + while (*slash == '/') + slash++; + } } /* We get here if the parent of DIR already exists. */ @@ -552,7 +566,7 @@ target_directory_operand (char const *file, struct stat *st, bool *new_dst) if (err) { if (err != ENOENT) - error (EXIT_FAILURE, err, _("accessing %s"), quote (file)); + error (EXIT_FAILURE, err, _("accessing %s"), quote (file)); *new_dst = true; } return is_a_dir; @@ -563,7 +577,7 @@ target_directory_operand (char const *file, struct stat *st, bool *new_dst) static bool do_copy (int n_files, char **file, const char *target_directory, - bool no_target_directory, struct cp_options *x) + bool no_target_directory, struct cp_options *x) { struct stat sb; bool new_dst = false; @@ -572,131 +586,131 @@ do_copy (int n_files, char **file, const char *target_directory, if (n_files <= !target_directory) { if (n_files <= 0) - error (0, 0, _("missing file operand")); + error (0, 0, _("missing file operand")); else - error (0, 0, _("missing destination file operand after %s"), - quote (file[0])); + error (0, 0, _("missing destination file operand after %s"), + quote (file[0])); usage (EXIT_FAILURE); } if (no_target_directory) { if (target_directory) - error (EXIT_FAILURE, 0, - _("cannot combine --target-directory (-t) " - "and --no-target-directory (-T)")); + error (EXIT_FAILURE, 0, + _("cannot combine --target-directory (-t) " + "and --no-target-directory (-T)")); if (2 < n_files) - { - error (0, 0, _("extra operand %s"), quote (file[2])); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("extra operand %s"), quote (file[2])); + usage (EXIT_FAILURE); + } } else if (!target_directory) { if (2 <= n_files - && target_directory_operand (file[n_files - 1], &sb, &new_dst)) - target_directory = file[--n_files]; + && target_directory_operand (file[n_files - 1], &sb, &new_dst)) + target_directory = file[--n_files]; else if (2 < n_files) - error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (file[n_files - 1])); + error (EXIT_FAILURE, 0, _("target %s is not a directory"), + quote (file[n_files - 1])); } if (target_directory) { /* cp file1...filen edir - Copy the files `file1' through `filen' - to the existing directory `edir'. */ + Copy the files `file1' through `filen' + to the existing directory `edir'. */ int i; /* Initialize these hash tables only if we'll need them. - The problems they're used to detect can arise only if - there are two or more files to copy. */ + The problems they're used to detect can arise only if + there are two or more files to copy. */ if (2 <= n_files) - { - dest_info_init (x); - src_info_init (x); - } + { + dest_info_init (x); + src_info_init (x); + } for (i = 0; i < n_files; i++) - { - char *dst_name; - bool parent_exists = true; /* True if dir_name (dst_name) exists. */ - struct dir_attr *attr_list; - char *arg_in_concat = NULL; - char *arg = file[i]; + { + char *dst_name; + bool parent_exists = true; /* True if dir_name (dst_name) exists. */ + struct dir_attr *attr_list; + char *arg_in_concat = NULL; + char *arg = file[i]; - /* Trailing slashes are meaningful (i.e., maybe worth preserving) - only in the source file names. */ - if (remove_trailing_slashes) - strip_trailing_slashes (arg); + /* Trailing slashes are meaningful (i.e., maybe worth preserving) + only in the source file names. */ + if (remove_trailing_slashes) + strip_trailing_slashes (arg); - if (parents_option) - { - char *arg_no_trailing_slash; + if (parents_option) + { + char *arg_no_trailing_slash; - /* Use `arg' without trailing slashes in constructing destination - file names. Otherwise, we can end up trying to create a - directory via `mkdir ("dst/foo/"...', which is not portable. - It fails, due to the trailing slash, on at least - NetBSD 1.[34] systems. */ - ASSIGN_STRDUPA (arg_no_trailing_slash, arg); - strip_trailing_slashes (arg_no_trailing_slash); + /* Use `arg' without trailing slashes in constructing destination + file names. Otherwise, we can end up trying to create a + directory via `mkdir ("dst/foo/"...', which is not portable. + It fails, due to the trailing slash, on at least + NetBSD 1.[34] systems. */ + ASSIGN_STRDUPA (arg_no_trailing_slash, arg); + strip_trailing_slashes (arg_no_trailing_slash); - /* Append all of `arg' (minus any trailing slash) to `dest'. */ - dst_name = file_name_concat (target_directory, - arg_no_trailing_slash, - &arg_in_concat); + /* Append all of `arg' (minus any trailing slash) to `dest'. */ + dst_name = file_name_concat (target_directory, + arg_no_trailing_slash, + &arg_in_concat); - /* For --parents, we have to make sure that the directory - dir_name (dst_name) exists. We may have to create a few - leading directories. */ - parent_exists = - (make_dir_parents_private - (dst_name, arg_in_concat - dst_name, - (x->verbose ? "%s -> %s\n" : NULL), - &attr_list, &new_dst, x)); - } - else - { - char *arg_base; - /* Append the last component of `arg' to `target_directory'. */ + /* For --parents, we have to make sure that the directory + dir_name (dst_name) exists. We may have to create a few + leading directories. */ + parent_exists = + (make_dir_parents_private + (dst_name, arg_in_concat - dst_name, + (x->verbose ? "%s -> %s\n" : NULL), + &attr_list, &new_dst, x)); + } + else + { + char *arg_base; + /* Append the last component of `arg' to `target_directory'. */ - ASSIGN_BASENAME_STRDUPA (arg_base, arg); - /* For `cp -R source/.. dest', don't copy into `dest/..'. */ - dst_name = (STREQ (arg_base, "..") - ? xstrdup (target_directory) - : file_name_concat (target_directory, arg_base, - NULL)); - } + ASSIGN_BASENAME_STRDUPA (arg_base, arg); + /* For `cp -R source/.. dest', don't copy into `dest/..'. */ + dst_name = (STREQ (arg_base, "..") + ? xstrdup (target_directory) + : file_name_concat (target_directory, arg_base, + NULL)); + } - if (!parent_exists) - { - /* make_dir_parents_private failed, so don't even - attempt the copy. */ - ok = false; - } - else - { - bool copy_into_self; - ok &= copy (arg, dst_name, new_dst, x, ©_into_self, NULL); + if (!parent_exists) + { + /* make_dir_parents_private failed, so don't even + attempt the copy. */ + ok = false; + } + else + { + bool copy_into_self; + ok &= copy (arg, dst_name, new_dst, x, ©_into_self, NULL); - if (parents_option) - ok &= re_protect (dst_name, arg_in_concat - dst_name, - attr_list, x); - } + if (parents_option) + ok &= re_protect (dst_name, arg_in_concat - dst_name, + attr_list, x); + } - if (parents_option) - { - while (attr_list) - { - struct dir_attr *p = attr_list; - attr_list = attr_list->next; - free (p); - } - } + if (parents_option) + { + while (attr_list) + { + struct dir_attr *p = attr_list; + attr_list = attr_list->next; + free (p); + } + } - free (dst_name); - } + free (dst_name); + } } else /* !target_directory */ { @@ -706,39 +720,39 @@ do_copy (int n_files, char **file, const char *target_directory, bool unused; if (parents_option) - { - error (0, 0, - _("with --parents, the destination must be a directory")); - usage (EXIT_FAILURE); - } + { + error (0, 0, + _("with --parents, the destination must be a directory")); + usage (EXIT_FAILURE); + } /* When the force and backup options have been specified and - the source and destination are the same name for an existing - regular file, convert the user's command, e.g., - `cp --force --backup foo foo' to `cp --force foo fooSUFFIX' - where SUFFIX is determined by any version control options used. */ + the source and destination are the same name for an existing + regular file, convert the user's command, e.g., + `cp --force --backup foo foo' to `cp --force foo fooSUFFIX' + where SUFFIX is determined by any version control options used. */ if (x->unlink_dest_after_failed_open - && x->backup_type != no_backups - && STREQ (source, dest) - && !new_dst && S_ISREG (sb.st_mode)) - { - static struct cp_options x_tmp; + && x->backup_type != no_backups + && STREQ (source, dest) + && !new_dst && S_ISREG (sb.st_mode)) + { + static struct cp_options x_tmp; - new_dest = find_backup_file_name (dest, x->backup_type); - /* Set x->backup_type to `no_backups' so that the normal backup - mechanism is not used when performing the actual copy. - backup_type must be set to `no_backups' only *after* the above - call to find_backup_file_name -- that function uses - backup_type to determine the suffix it applies. */ - x_tmp = *x; - x_tmp.backup_type = no_backups; - x = &x_tmp; - } + new_dest = find_backup_file_name (dest, x->backup_type); + /* Set x->backup_type to `no_backups' so that the normal backup + mechanism is not used when performing the actual copy. + backup_type must be set to `no_backups' only *after* the above + call to find_backup_file_name -- that function uses + backup_type to determine the suffix it applies. */ + x_tmp = *x; + x_tmp.backup_type = no_backups; + x = &x_tmp; + } else - { - new_dest = dest; - } + { + new_dest = dest; + } ok = copy (source, new_dest, 0, x, &unused, NULL); } @@ -758,7 +772,7 @@ cp_option_init (struct cp_options *x) x->interactive = I_UNSPECIFIED; x->move_mode = false; x->one_file_system = false; - x->reflink = false; + x->reflink_mode = REFLINK_NEVER; x->preserve_ownership = false; x->preserve_links = false; @@ -833,51 +847,51 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off) /* If we found a comma, put a NUL in its place and advance. */ if (comma) - *comma++ = 0; + *comma++ = 0; /* process S. */ val = XARGMATCH ("--preserve", s, preserve_args, preserve_vals); switch (val) - { - case PRESERVE_MODE: - x->preserve_mode = on_off; - break; + { + case PRESERVE_MODE: + x->preserve_mode = on_off; + break; - case PRESERVE_TIMESTAMPS: - x->preserve_timestamps = on_off; - break; + case PRESERVE_TIMESTAMPS: + x->preserve_timestamps = on_off; + break; - case PRESERVE_OWNERSHIP: - x->preserve_ownership = on_off; - break; + case PRESERVE_OWNERSHIP: + x->preserve_ownership = on_off; + break; - case PRESERVE_LINK: - x->preserve_links = on_off; - break; + case PRESERVE_LINK: + x->preserve_links = on_off; + break; - case PRESERVE_CONTEXT: - x->preserve_security_context = on_off; - x->require_preserve_context = on_off; - break; + case PRESERVE_CONTEXT: + x->preserve_security_context = on_off; + x->require_preserve_context = on_off; + break; - case PRESERVE_XATTR: - x->preserve_xattr = on_off; - x->require_preserve_xattr = on_off; - break; + case PRESERVE_XATTR: + x->preserve_xattr = on_off; + x->require_preserve_xattr = on_off; + break; - case PRESERVE_ALL: - x->preserve_mode = on_off; - x->preserve_timestamps = on_off; - x->preserve_ownership = on_off; - x->preserve_links = on_off; - if (selinux_enabled) - x->preserve_security_context = on_off; - x->preserve_xattr = on_off; - break; + case PRESERVE_ALL: + x->preserve_mode = on_off; + x->preserve_timestamps = on_off; + x->preserve_ownership = on_off; + x->preserve_links = on_off; + if (selinux_enabled) + x->preserve_security_context = on_off; + x->preserve_xattr = on_off; + break; - default: - abort (); - } + default: + abort (); + } s = comma; } while (s); @@ -914,169 +928,173 @@ main (int argc, char **argv) backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX"); while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:T", - long_opts, NULL)) - != -1) + long_opts, NULL)) + != -1) { switch (c) - { - case SPARSE_OPTION: - x.sparse_mode = XARGMATCH ("--sparse", optarg, - sparse_type_string, sparse_type); - break; + { + case SPARSE_OPTION: + x.sparse_mode = XARGMATCH ("--sparse", optarg, + sparse_type_string, sparse_type); + break; - case REFLINK_OPTION: - x.reflink = true; - break; + case REFLINK_OPTION: + if (optarg == NULL) + x.reflink_mode = REFLINK_ALWAYS; + else + x.reflink_mode = XARGMATCH ("--reflink", optarg, + reflink_type_string, reflink_type); + break; - case 'a': /* Like -dR --preserve=all with reduced failure diagnostics. */ - x.dereference = DEREF_NEVER; - x.preserve_links = true; - x.preserve_ownership = true; - x.preserve_mode = true; - x.preserve_timestamps = true; - x.require_preserve = true; - if (selinux_enabled) - x.preserve_security_context = true; - x.preserve_xattr = true; - x.reduce_diagnostics = true; - x.recursive = true; - break; + case 'a': /* Like -dR --preserve=all with reduced failure diagnostics. */ + x.dereference = DEREF_NEVER; + x.preserve_links = true; + x.preserve_ownership = true; + x.preserve_mode = true; + x.preserve_timestamps = true; + x.require_preserve = true; + if (selinux_enabled) + x.preserve_security_context = true; + x.preserve_xattr = true; + x.reduce_diagnostics = true; + x.recursive = true; + break; - case 'b': - make_backups = true; - if (optarg) - version_control_string = optarg; - break; + case 'b': + make_backups = true; + if (optarg) + version_control_string = optarg; + break; - case COPY_CONTENTS_OPTION: - copy_contents = true; - break; + case COPY_CONTENTS_OPTION: + copy_contents = true; + break; - case 'd': - x.preserve_links = true; - x.dereference = DEREF_NEVER; - break; + case 'd': + x.preserve_links = true; + x.dereference = DEREF_NEVER; + break; - case 'f': - x.unlink_dest_after_failed_open = true; - break; + case 'f': + x.unlink_dest_after_failed_open = true; + break; - case 'H': - x.dereference = DEREF_COMMAND_LINE_ARGUMENTS; - break; + case 'H': + x.dereference = DEREF_COMMAND_LINE_ARGUMENTS; + break; - case IGNORE_ATTRIBUTES: - x.ignore_attributes = true; - break; + case IGNORE_ATTRIBUTES: + x.ignore_attributes = true; + break; - case 'i': - x.interactive = I_ASK_USER; - break; + case 'i': + x.interactive = I_ASK_USER; + break; - case 'l': - x.hard_link = true; - break; + case 'l': + x.hard_link = true; + break; - case 'L': - x.dereference = DEREF_ALWAYS; - break; + case 'L': + x.dereference = DEREF_ALWAYS; + break; - case 'n': - x.interactive = I_ALWAYS_NO; - break; + case 'n': + x.interactive = I_ALWAYS_NO; + break; - case 'P': - x.dereference = DEREF_NEVER; - break; + case 'P': + x.dereference = DEREF_NEVER; + break; - case NO_PRESERVE_ATTRIBUTES_OPTION: - decode_preserve_arg (optarg, &x, false); - break; + case NO_PRESERVE_ATTRIBUTES_OPTION: + decode_preserve_arg (optarg, &x, false); + break; - case PRESERVE_ATTRIBUTES_OPTION: - if (optarg == NULL) - { - /* Fall through to the case for `p' below. */ - } - else - { - decode_preserve_arg (optarg, &x, true); - x.require_preserve = true; - break; - } + case PRESERVE_ATTRIBUTES_OPTION: + if (optarg == NULL) + { + /* Fall through to the case for `p' below. */ + } + else + { + decode_preserve_arg (optarg, &x, true); + x.require_preserve = true; + break; + } - case 'p': - x.preserve_ownership = true; - x.preserve_mode = true; - x.preserve_timestamps = true; - x.require_preserve = true; - break; + case 'p': + x.preserve_ownership = true; + x.preserve_mode = true; + x.preserve_timestamps = true; + x.require_preserve = true; + break; - case PARENTS_OPTION: - parents_option = true; - break; + case PARENTS_OPTION: + parents_option = true; + break; - case 'r': - case 'R': - x.recursive = true; - break; + case 'r': + case 'R': + x.recursive = true; + break; - case UNLINK_DEST_BEFORE_OPENING: - x.unlink_dest_before_opening = true; - break; + case UNLINK_DEST_BEFORE_OPENING: + x.unlink_dest_before_opening = true; + break; - case STRIP_TRAILING_SLASHES_OPTION: - remove_trailing_slashes = true; - break; + case STRIP_TRAILING_SLASHES_OPTION: + remove_trailing_slashes = true; + break; - case 's': - x.symbolic_link = true; - break; + case 's': + x.symbolic_link = true; + break; - case 't': - if (target_directory) - error (EXIT_FAILURE, 0, - _("multiple target directories specified")); - else - { - struct stat st; - if (stat (optarg, &st) != 0) - error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg)); - if (! S_ISDIR (st.st_mode)) - error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (optarg)); - } - target_directory = optarg; - break; + case 't': + if (target_directory) + error (EXIT_FAILURE, 0, + _("multiple target directories specified")); + else + { + struct stat st; + if (stat (optarg, &st) != 0) + error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg)); + if (! S_ISDIR (st.st_mode)) + error (EXIT_FAILURE, 0, _("target %s is not a directory"), + quote (optarg)); + } + target_directory = optarg; + break; - case 'T': - no_target_directory = true; - break; + case 'T': + no_target_directory = true; + break; - case 'u': - x.update = true; - break; + case 'u': + x.update = true; + break; - case 'v': - x.verbose = true; - break; + case 'v': + x.verbose = true; + break; - case 'x': - x.one_file_system = true; - break; + case 'x': + x.one_file_system = true; + break; - case 'S': - make_backups = true; - backup_suffix_string = optarg; - break; + case 'S': + make_backups = true; + backup_suffix_string = optarg; + 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); - } + default: + usage (EXIT_FAILURE); + } } if (x.hard_link & x.symbolic_link) @@ -1088,11 +1106,11 @@ main (int argc, char **argv) if (make_backups && x.interactive == I_ALWAYS_NO) { error (0, 0, - _("options --backup and --no-clobber are mutually exclusive")); + _("options --backup and --no-clobber are mutually exclusive")); usage (EXIT_FAILURE); } - if (x.reflink && x.sparse_mode != SPARSE_AUTO) + if (x.reflink_mode == REFLINK_ALWAYS && x.sparse_mode != SPARSE_AUTO) { error (0, 0, _("--reflink can be used only with --sparse=auto")); usage (EXIT_FAILURE); @@ -1102,17 +1120,17 @@ main (int argc, char **argv) simple_backup_suffix = xstrdup (backup_suffix_string); x.backup_type = (make_backups - ? xget_version (_("backup type"), - version_control_string) - : no_backups); + ? xget_version (_("backup type"), + version_control_string) + : no_backups); if (x.dereference == DEREF_UNDEFINED) { if (x.recursive) - /* This is compatible with FreeBSD. */ - x.dereference = DEREF_NEVER; + /* This is compatible with FreeBSD. */ + x.dereference = DEREF_NEVER; else - x.dereference = DEREF_ALWAYS; + x.dereference = DEREF_ALWAYS; } if (x.recursive) @@ -1126,15 +1144,15 @@ main (int argc, char **argv) if (x.preserve_security_context) { if (!selinux_enabled) - error (EXIT_FAILURE, 0, - _("cannot preserve security context " - "without an SELinux-enabled kernel")); + error (EXIT_FAILURE, 0, + _("cannot preserve security context " + "without an SELinux-enabled kernel")); } #if !USE_XATTR if (x.require_preserve_xattr) error (EXIT_FAILURE, 0, _("cannot preserve extended attributes, cp is " - "built without xattr support")); + "built without xattr support")); #endif /* Allocate space for remembering copied and created files. */ @@ -1142,7 +1160,7 @@ main (int argc, char **argv) hash_init (); ok = do_copy (argc - optind, argv + optind, - target_directory, no_target_directory, &x); + target_directory, no_target_directory, &x); forget_all (); diff --git a/src/bin/coreutils/src/csplit.c b/src/bin/coreutils/src/csplit.c index b2892c917a..ba93d2b593 100644 --- a/src/bin/coreutils/src/csplit.c +++ b/src/bin/coreutils/src/csplit.c @@ -346,7 +346,7 @@ record_line_starts (struct buffer_record *b) { line_end = memchr (line_start, '\n', bytes_left); if (line_end == NULL) - break; + break; line_length = line_end - line_start + 1; keep_new_line (b, line_start, line_length); bytes_left -= line_length; @@ -358,12 +358,12 @@ record_line_starts (struct buffer_record *b) if (bytes_left) { if (have_read_eof) - { - keep_new_line (b, line_start, bytes_left); - lines++; - } + { + keep_new_line (b, line_start, bytes_left); + lines++; + } else - save_to_hold_area (xmemdup (line_start, bytes_left), bytes_left); + save_to_hold_area (xmemdup (line_start, bytes_left), bytes_left); } b->num_lines = lines; @@ -438,7 +438,7 @@ save_buffer (struct buffer_record *buf) else { for (p = head; p->next; p = p->next) - /* Do nothing. */ ; + /* Do nothing. */ ; p->next = buf; } } @@ -481,25 +481,25 @@ load_buffer (void) /* First check the `holding' area for a partial line. */ if (hold_count) - { - memcpy (p, hold_area, hold_count); - p += hold_count; - b->bytes_used += hold_count; - bytes_avail -= hold_count; - hold_count = 0; - } + { + memcpy (p, hold_area, hold_count); + p += hold_count; + b->bytes_used += hold_count; + bytes_avail -= hold_count; + hold_count = 0; + } b->bytes_used += read_input (p, bytes_avail); lines_found = record_line_starts (b); if (!lines_found) - free_buffer (b); + free_buffer (b); if (lines_found || have_read_eof) - break; + break; if (xalloc_oversized (2, b->bytes_alloc)) - xalloc_die (); + xalloc_die (); bytes_wanted = 2 * b->bytes_alloc; free_buffer (b); free (b); @@ -563,13 +563,13 @@ remove_line (void) /* Go on to the next line record. */ head->curr_line = l->next; if (head->curr_line == NULL || head->curr_line->used == 0) - { - /* Go on to the next data block. - but first record the current one so we can free it - once the line we're returning has been processed. */ - prev_buf = head; - head = head->next; - } + { + /* Go on to the next data block. + but first record the current one so we can free it + once the line we're returning has been processed. */ + prev_buf = head; + head = head->next; + } } return line; @@ -592,23 +592,23 @@ find_line (uintmax_t linenum) for (b = head;;) { if (linenum < b->start_line + b->num_lines) - { - /* The line is in this buffer. */ - struct line *l; - size_t offset; /* How far into the buffer the line is. */ + { + /* The line is in this buffer. */ + struct line *l; + size_t offset; /* How far into the buffer the line is. */ - l = b->line_start; - offset = linenum - b->start_line; - /* Find the control record. */ - while (offset >= CTRL_SIZE) - { - l = l->next; - offset -= CTRL_SIZE; - } - return &l->starts[offset]; - } + l = b->line_start; + offset = linenum - b->start_line; + /* Find the control record. */ + while (offset >= CTRL_SIZE) + { + l = l->next; + offset -= CTRL_SIZE; + } + return &l->starts[offset]; + } if (b->next == NULL && !load_buffer ()) - return NULL; + return NULL; b = b->next; /* Try the next data block. */ } } @@ -657,12 +657,12 @@ write_to_file (uintmax_t last_line, bool ignore, int argnum) { line = remove_line (); if (line == NULL) - { - error (0, 0, _("%s: line number out of range"), global_argv[argnum]); - cleanup_fatal (); - } + { + error (0, 0, _("%s: line number out of range"), global_argv[argnum]); + cleanup_fatal (); + } if (!ignore) - save_line_to_file (line); + save_line_to_file (line); } } @@ -688,7 +688,7 @@ handle_line_error (const struct control *p, uintmax_t repetition) char buf[INT_BUFSIZE_BOUND (uintmax_t)]; fprintf (stderr, _("%s: %s: line number out of range"), - program_name, quote (umaxtostr (p->lines_required, buf))); + program_name, quote (umaxtostr (p->lines_required, buf))); if (repetition) fprintf (stderr, _(" on repetition %s\n"), umaxtostr (repetition, buf)); else @@ -717,7 +717,7 @@ process_line_count (const struct control *p, uintmax_t repetition) { line = remove_line (); if (line == NULL) - handle_line_error (p, repetition); + handle_line_error (p, repetition); save_line_to_file (line); } @@ -734,7 +734,7 @@ static void regexp_error (struct control *p, uintmax_t repetition, bool ignore) { fprintf (stderr, _("%s: %s: match not found"), - program_name, quote (global_argv[p->argnum])); + program_name, quote (global_argv[p->argnum])); if (repetition) { @@ -774,75 +774,75 @@ process_regexp (struct control *p, uintmax_t repetition) if (p->offset >= 0) { for (;;) - { - line = find_line (++current_line); - if (line == NULL) - { - if (p->repeat_forever) - { - if (!ignore) - { - dump_rest_of_file (); - close_output_file (); - } - exit (EXIT_SUCCESS); - } - else - regexp_error (p, repetition, ignore); - } - line_len = line->len; - if (line->str[line_len - 1] == '\n') - line_len--; - ret = re_search (&p->re_compiled, line->str, line_len, - 0, line_len, NULL); - if (ret == -2) - { - error (0, 0, _("error in regular expression search")); - cleanup_fatal (); - } - if (ret == -1) - { - line = remove_line (); - if (!ignore) - save_line_to_file (line); - } - else - break; - } + { + line = find_line (++current_line); + if (line == NULL) + { + if (p->repeat_forever) + { + if (!ignore) + { + dump_rest_of_file (); + close_output_file (); + } + exit (EXIT_SUCCESS); + } + else + regexp_error (p, repetition, ignore); + } + line_len = line->len; + if (line->str[line_len - 1] == '\n') + line_len--; + ret = re_search (&p->re_compiled, line->str, line_len, + 0, line_len, NULL); + if (ret == -2) + { + error (0, 0, _("error in regular expression search")); + cleanup_fatal (); + } + if (ret == -1) + { + line = remove_line (); + if (!ignore) + save_line_to_file (line); + } + else + break; + } } else { /* Buffer the lines. */ for (;;) - { - line = find_line (++current_line); - if (line == NULL) - { - if (p->repeat_forever) - { - if (!ignore) - { - dump_rest_of_file (); - close_output_file (); - } - exit (EXIT_SUCCESS); - } - else - regexp_error (p, repetition, ignore); - } - line_len = line->len; - if (line->str[line_len - 1] == '\n') - line_len--; - ret = re_search (&p->re_compiled, line->str, line_len, - 0, line_len, NULL); - if (ret == -2) - { - error (0, 0, _("error in regular expression search")); - cleanup_fatal (); - } - if (ret != -1) - break; - } + { + line = find_line (++current_line); + if (line == NULL) + { + if (p->repeat_forever) + { + if (!ignore) + { + dump_rest_of_file (); + close_output_file (); + } + exit (EXIT_SUCCESS); + } + else + regexp_error (p, repetition, ignore); + } + line_len = line->len; + if (line->str[line_len - 1] == '\n') + line_len--; + ret = re_search (&p->re_compiled, line->str, line_len, + 0, line_len, NULL); + if (ret == -2) + { + error (0, 0, _("error in regular expression search")); + cleanup_fatal (); + } + if (ret != -1) + break; + } } /* Account for any offset from this regexp. */ @@ -868,17 +868,17 @@ split_file (void) { uintmax_t j; if (controls[i].regexpr) - { - for (j = 0; (controls[i].repeat_forever - || j <= controls[i].repeat); j++) - process_regexp (&controls[i], j); - } + { + for (j = 0; (controls[i].repeat_forever + || j <= controls[i].repeat); j++) + process_regexp (&controls[i], j); + } else - { - for (j = 0; (controls[i].repeat_forever - || j <= controls[i].repeat); j++) - process_line_count (&controls[i], j); - } + { + for (j = 0; (controls[i].repeat_forever + || j <= controls[i].repeat); j++) + process_line_count (&controls[i], j); + } } create_output_file (); @@ -946,7 +946,7 @@ delete_all_files (bool in_signal_handler) { const char *name = make_filename (i); if (unlink (name) != 0 && !in_signal_handler) - error (0, errno, "%s", name); + error (0, errno, "%s", name); } files_created = 0; @@ -961,41 +961,41 @@ close_output_file (void) if (output_stream) { if (ferror (output_stream)) - { - error (0, 0, _("write error for %s"), quote (output_filename)); - output_stream = NULL; - cleanup_fatal (); - } + { + error (0, 0, _("write error for %s"), quote (output_filename)); + output_stream = NULL; + cleanup_fatal (); + } if (fclose (output_stream) != 0) - { - error (0, errno, "%s", output_filename); - output_stream = NULL; - cleanup_fatal (); - } + { + error (0, errno, "%s", output_filename); + output_stream = NULL; + cleanup_fatal (); + } if (bytes_written == 0 && elide_empty_files) - { - sigset_t oldset; - bool unlink_ok; - int unlink_errno; + { + sigset_t oldset; + bool unlink_ok; + int unlink_errno; - /* Remove the output file in a critical section, to avoid races. */ - sigprocmask (SIG_BLOCK, &caught_signals, &oldset); - unlink_ok = (unlink (output_filename) == 0); - unlink_errno = errno; - files_created -= unlink_ok; - sigprocmask (SIG_SETMASK, &oldset, NULL); + /* Remove the output file in a critical section, to avoid races. */ + sigprocmask (SIG_BLOCK, &caught_signals, &oldset); + unlink_ok = (unlink (output_filename) == 0); + unlink_errno = errno; + files_created -= unlink_ok; + sigprocmask (SIG_SETMASK, &oldset, NULL); - if (! unlink_ok) - error (0, unlink_errno, "%s", output_filename); - } + if (! unlink_ok) + error (0, unlink_errno, "%s", output_filename); + } else - { - if (!suppress_count) - { - char buf[INT_BUFSIZE_BOUND (uintmax_t)]; - fprintf (stdout, "%s\n", umaxtostr (bytes_written, buf)); - } - } + { + if (!suppress_count) + { + char buf[INT_BUFSIZE_BOUND (uintmax_t)]; + fprintf (stdout, "%s\n", umaxtostr (bytes_written, buf)); + } + } output_stream = NULL; } } @@ -1062,11 +1062,11 @@ parse_repeat_count (int argnum, struct control *p, char *str) else { if (xstrtoumax (str + 1, NULL, 10, &val, "") != LONGINT_OK) - { - error (EXIT_FAILURE, 0, - _("%s}: integer required between `{' and `}'"), - global_argv[argnum]); - } + { + error (EXIT_FAILURE, 0, + _("%s}: integer required between `{' and `}'"), + global_argv[argnum]); + } p->repeat = val; } @@ -1091,7 +1091,7 @@ extract_regexp (int argnum, bool ignore, char const *str) closing_delim = strrchr (str + 1, delim); if (closing_delim == NULL) error (EXIT_FAILURE, 0, - _("%s: closing delimiter `%c' missing"), str, delim); + _("%s: closing delimiter `%c' missing"), str, delim); len = closing_delim - str - 1; p = new_control_record (); @@ -1132,44 +1132,44 @@ parse_patterns (int argc, int start, char **argv) for (i = start; i < argc; i++) { if (*argv[i] == '/' || *argv[i] == '%') - { - p = extract_regexp (i, *argv[i] == '%', argv[i]); - } + { + p = extract_regexp (i, *argv[i] == '%', argv[i]); + } else - { - p = new_control_record (); - p->argnum = i; + { + p = new_control_record (); + p->argnum = i; - if (xstrtoumax (argv[i], NULL, 10, &val, "") != LONGINT_OK) - error (EXIT_FAILURE, 0, _("%s: invalid pattern"), argv[i]); - if (val == 0) - error (EXIT_FAILURE, 0, - _("%s: line number must be greater than zero"), - argv[i]); - if (val < last_val) - { - char buf[INT_BUFSIZE_BOUND (uintmax_t)]; - error (EXIT_FAILURE, 0, - _("line number %s is smaller than preceding line number, %s"), - quote (argv[i]), umaxtostr (last_val, buf)); - } + if (xstrtoumax (argv[i], NULL, 10, &val, "") != LONGINT_OK) + error (EXIT_FAILURE, 0, _("%s: invalid pattern"), argv[i]); + if (val == 0) + error (EXIT_FAILURE, 0, + _("%s: line number must be greater than zero"), + argv[i]); + if (val < last_val) + { + char buf[INT_BUFSIZE_BOUND (uintmax_t)]; + error (EXIT_FAILURE, 0, + _("line number %s is smaller than preceding line number, %s"), + quote (argv[i]), umaxtostr (last_val, buf)); + } - if (val == last_val) - error (0, 0, - _("warning: line number %s is the same as preceding line number"), - quote (argv[i])); + if (val == last_val) + error (0, 0, + _("warning: line number %s is the same as preceding line number"), + quote (argv[i])); - last_val = val; + last_val = val; - p->lines_required = val; - } + p->lines_required = val; + } if (i + 1 < argc && *argv[i + 1] == '{') - { - /* We have a repeat count. */ - i++; - parse_repeat_count (i, p, argv[i]); - } + { + /* We have a repeat count. */ + i++; + parse_repeat_count (i, p, argv[i]); + } } } @@ -1181,22 +1181,22 @@ get_format_flags (char **format_ptr) for (; **format_ptr; (*format_ptr)++) { switch (**format_ptr) - { - case '-': - break; + { + case '-': + break; - case '+': - case ' ': - count |= 1; - break; + case '+': + case ' ': + count |= 1; + break; - case '#': - count |= 2; /* Allow for 0x prefix preceding an `x' conversion. */ - break; + case '#': + count |= 2; /* Allow for 0x prefix preceding an `x' conversion. */ + break; - default: - return count; - } + default: + return count; + } } return count; } @@ -1208,7 +1208,7 @@ get_format_width (char **format_ptr) if (ISDIGIT (**format_ptr) && (xstrtoul (*format_ptr, format_ptr, 10, &val, NULL) != LONGINT_OK - || SIZE_MAX < val)) + || SIZE_MAX < val)) error (EXIT_FAILURE, 0, _("invalid format width")); /* Allow for enough octal digits to represent the value of UINT_MAX, @@ -1229,8 +1229,8 @@ get_format_prec (char **format_ptr) { unsigned long int val; if (xstrtoul (*format_ptr, format_ptr, 10, &val, NULL) != LONGINT_OK - || SIZE_MAX < val) - error (EXIT_FAILURE, 0, _("invalid format precision")); + || SIZE_MAX < val) + error (EXIT_FAILURE, 0, _("invalid format precision")); return val; } } @@ -1257,10 +1257,10 @@ get_format_conv_type (char **format_ptr) default: if (isprint (ch)) error (EXIT_FAILURE, 0, - _("invalid conversion specifier in suffix: %c"), ch); + _("invalid conversion specifier in suffix: %c"), ch); else - error (EXIT_FAILURE, 0, - _("invalid conversion specifier in suffix: \\%.3o"), ch); + error (EXIT_FAILURE, 0, + _("invalid conversion specifier in suffix: \\%.3o"), ch); } } @@ -1275,30 +1275,30 @@ max_out (char *format) if (*format++ != '%') out_count++; else if (*format == '%') - { - format++; - out_count++; - } + { + format++; + out_count++; + } else - { - if (percent) - error (EXIT_FAILURE, 0, - _("too many %% conversion specifications in suffix")); - percent = true; - out_count += get_format_flags (&format); - { - size_t width = get_format_width (&format); - size_t prec = get_format_prec (&format); + { + if (percent) + error (EXIT_FAILURE, 0, + _("too many %% conversion specifications in suffix")); + percent = true; + out_count += get_format_flags (&format); + { + size_t width = get_format_width (&format); + size_t prec = get_format_prec (&format); - out_count += MAX (width, prec); - } - get_format_conv_type (&format); - } + out_count += MAX (width, prec); + } + get_format_conv_type (&format); + } } if (! percent) error (EXIT_FAILURE, 0, - _("missing %% conversion specification in suffix")); + _("missing %% conversion specification in suffix")); return out_count; } @@ -1328,47 +1328,47 @@ main (int argc, char **argv) switch (optc) { case 'f': - prefix = optarg; - break; + prefix = optarg; + break; case 'b': - suffix = optarg; - break; + suffix = optarg; + break; case 'k': - remove_files = false; - break; + remove_files = false; + break; case 'n': - if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK - || val > INT_MAX) - error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg); - digits = val; - break; + if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK + || val > INT_MAX) + error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg); + digits = val; + break; case 's': case 'q': - suppress_count = true; - break; + suppress_count = true; + break; case 'z': - elide_empty_files = true; - break; + elide_empty_files = true; + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: - usage (EXIT_FAILURE); + usage (EXIT_FAILURE); } if (argc - optind < 2) { if (argc <= optind) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); + error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); usage (EXIT_FAILURE); } @@ -1385,22 +1385,22 @@ main (int argc, char **argv) int i; static int const sig[] = { - /* The usual suspects. */ - SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, + /* The usual suspects. */ + SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, #ifdef SIGPOLL - SIGPOLL, + SIGPOLL, #endif #ifdef SIGPROF - SIGPROF, + SIGPROF, #endif #ifdef SIGVTALRM - SIGVTALRM, + SIGVTALRM, #endif #ifdef SIGXCPU - SIGXCPU, + SIGXCPU, #endif #ifdef SIGXFSZ - SIGXFSZ, + SIGXFSZ, #endif }; enum { nsigs = ARRAY_CARDINALITY (sig) }; @@ -1410,9 +1410,9 @@ main (int argc, char **argv) sigemptyset (&caught_signals); for (i = 0; i < nsigs; i++) { - sigaction (sig[i], NULL, &act); - if (act.sa_handler != SIG_IGN) - sigaddset (&caught_signals, sig[i]); + sigaction (sig[i], NULL, &act); + if (act.sa_handler != SIG_IGN) + sigaddset (&caught_signals, sig[i]); } act.sa_handler = interrupt_handler; @@ -1421,7 +1421,7 @@ main (int argc, char **argv) for (i = 0; i < nsigs; i++) if (sigismember (&caught_signals, sig[i])) - sigaction (sig[i], &act, NULL); + sigaction (sig[i], &act, NULL); } split_file (); @@ -1440,13 +1440,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... FILE PATTERN...\n\ "), - program_name); + program_name); fputs (_("\ Output pieces of FILE separated by PATTERN(s) to files `xx00', `xx01', ...,\n\ and output byte counts of each piece to standard output.\n\ diff --git a/src/bin/coreutils/src/cut.c b/src/bin/coreutils/src/cut.c index 23390bdabd..448e7ed7a0 100644 --- a/src/bin/coreutils/src/cut.c +++ b/src/bin/coreutils/src/cut.c @@ -60,11 +60,11 @@ do \ { \ if (low == 0 || high == 0) \ - FATAL_ERROR (_("fields and positions are numbered from 1")); \ + FATAL_ERROR (_("fields and positions are numbered from 1")); \ if (n_rp >= n_rp_allocated) \ - { \ - (rp) = X2NREALLOC (rp, &n_rp_allocated); \ - } \ + { \ + (rp) = X2NREALLOC (rp, &n_rp_allocated); \ + } \ rp[n_rp].lo = (low); \ rp[n_rp].hi = (high); \ ++n_rp; \ @@ -183,13 +183,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s OPTION... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Print selected parts of lines from each FILE to standard output.\n\ \n\ @@ -347,7 +347,7 @@ set_fields (const char *fieldstr) bool rhs_specified = false; bool dash_found = false; /* True if a '-' is found in this field. */ bool field_found = false; /* True if at least one field spec - has been processed. */ + has been processed. */ struct range_pair *rp = NULL; size_t n_rp = 0; @@ -361,139 +361,139 @@ set_fields (const char *fieldstr) for (;;) { if (*fieldstr == '-') - { - in_digits = false; - /* Starting a range. */ - if (dash_found) - FATAL_ERROR (_("invalid byte or field list")); - dash_found = true; - fieldstr++; + { + in_digits = false; + /* Starting a range. */ + if (dash_found) + FATAL_ERROR (_("invalid byte or field list")); + dash_found = true; + fieldstr++; - initial = (lhs_specified ? value : 1); - value = 0; - } + initial = (lhs_specified ? value : 1); + value = 0; + } else if (*fieldstr == ',' || - isblank (to_uchar (*fieldstr)) || *fieldstr == '\0') - { - in_digits = false; - /* Ending the string, or this field/byte sublist. */ - if (dash_found) - { - dash_found = false; + isblank (to_uchar (*fieldstr)) || *fieldstr == '\0') + { + in_digits = false; + /* Ending the string, or this field/byte sublist. */ + if (dash_found) + { + dash_found = false; - if (!lhs_specified && !rhs_specified) - FATAL_ERROR (_("invalid range with no endpoint: -")); + if (!lhs_specified && !rhs_specified) + FATAL_ERROR (_("invalid range with no endpoint: -")); - /* A range. Possibilities: -n, m-n, n-. - In any case, `initial' contains the start of the range. */ - if (!rhs_specified) - { - /* `n-'. From `initial' to end of line. */ - eol_range_start = initial; - field_found = true; - } - else - { - /* `m-n' or `-n' (1-n). */ - if (value < initial) - FATAL_ERROR (_("invalid decreasing range")); + /* A range. Possibilities: -n, m-n, n-. + In any case, `initial' contains the start of the range. */ + if (!rhs_specified) + { + /* `n-'. From `initial' to end of line. */ + eol_range_start = initial; + field_found = true; + } + else + { + /* `m-n' or `-n' (1-n). */ + if (value < initial) + FATAL_ERROR (_("invalid decreasing range")); - /* Is there already a range going to end of line? */ - if (eol_range_start != 0) - { - /* Yes. Is the new sequence already contained - in the old one? If so, no processing is - necessary. */ - if (initial < eol_range_start) - { - /* No, the new sequence starts before the - old. Does the old range going to end of line - extend into the new range? */ - if (eol_range_start <= value) - { - /* Yes. Simply move the end of line marker. */ - eol_range_start = initial; - } - else - { - /* No. A simple range, before and disjoint from - the range going to end of line. Fill it. */ - ADD_RANGE_PAIR (rp, initial, value); - } + /* Is there already a range going to end of line? */ + if (eol_range_start != 0) + { + /* Yes. Is the new sequence already contained + in the old one? If so, no processing is + necessary. */ + if (initial < eol_range_start) + { + /* No, the new sequence starts before the + old. Does the old range going to end of line + extend into the new range? */ + if (eol_range_start <= value) + { + /* Yes. Simply move the end of line marker. */ + eol_range_start = initial; + } + else + { + /* No. A simple range, before and disjoint from + the range going to end of line. Fill it. */ + ADD_RANGE_PAIR (rp, initial, value); + } - /* In any case, some fields were selected. */ - field_found = true; - } - } - else - { - /* There is no range going to end of line. */ - ADD_RANGE_PAIR (rp, initial, value); - field_found = true; - } - value = 0; - } - } - else - { - /* A simple field number, not a range. */ - ADD_RANGE_PAIR (rp, value, value); - value = 0; - field_found = true; - } + /* In any case, some fields were selected. */ + field_found = true; + } + } + else + { + /* There is no range going to end of line. */ + ADD_RANGE_PAIR (rp, initial, value); + field_found = true; + } + value = 0; + } + } + else + { + /* A simple field number, not a range. */ + ADD_RANGE_PAIR (rp, value, value); + value = 0; + field_found = true; + } - if (*fieldstr == '\0') - { - break; - } + if (*fieldstr == '\0') + { + break; + } - fieldstr++; - lhs_specified = false; - rhs_specified = false; - } + fieldstr++; + lhs_specified = false; + rhs_specified = false; + } else if (ISDIGIT (*fieldstr)) - { - /* Record beginning of digit string, in case we have to - complain about it. */ - static char const *num_start; - if (!in_digits || !num_start) - num_start = fieldstr; - in_digits = true; + { + /* Record beginning of digit string, in case we have to + complain about it. */ + static char const *num_start; + if (!in_digits || !num_start) + num_start = fieldstr; + in_digits = true; - if (dash_found) - rhs_specified = 1; - else - lhs_specified = 1; + if (dash_found) + rhs_specified = 1; + else + lhs_specified = 1; - /* Detect overflow. */ - if (!DECIMAL_DIGIT_ACCUMULATE (value, *fieldstr - '0', size_t)) - { - /* In case the user specified -c$(echo 2^64|bc),22, - complain only about the first number. */ - /* Determine the length of the offending number. */ - size_t len = strspn (num_start, "0123456789"); - char *bad_num = xstrndup (num_start, len); - if (operating_mode == byte_mode) - error (0, 0, - _("byte offset %s is too large"), quote (bad_num)); - else - error (0, 0, - _("field number %s is too large"), quote (bad_num)); - free (bad_num); - exit (EXIT_FAILURE); - } + /* Detect overflow. */ + if (!DECIMAL_DIGIT_ACCUMULATE (value, *fieldstr - '0', size_t)) + { + /* In case the user specified -c$(echo 2^64|bc),22, + complain only about the first number. */ + /* Determine the length of the offending number. */ + size_t len = strspn (num_start, "0123456789"); + char *bad_num = xstrndup (num_start, len); + if (operating_mode == byte_mode) + error (0, 0, + _("byte offset %s is too large"), quote (bad_num)); + else + error (0, 0, + _("field number %s is too large"), quote (bad_num)); + free (bad_num); + exit (EXIT_FAILURE); + } - fieldstr++; - } + fieldstr++; + } else - FATAL_ERROR (_("invalid byte or field list")); + FATAL_ERROR (_("invalid byte or field list")); } max_range_endpoint = 0; for (i = 0; i < n_rp; i++) { if (rp[i].hi > max_range_endpoint) - max_range_endpoint = rp[i].hi; + max_range_endpoint = rp[i].hi; } /* Allocate an array large enough so that it may be indexed by @@ -511,14 +511,14 @@ set_fields (const char *fieldstr) size_t rsi_candidate; /* Record the range-start indices, i.e., record each start - index that is not part of any other (lo..hi] range. */ + index that is not part of any other (lo..hi] range. */ rsi_candidate = complement ? rp[i].hi + 1 : rp[i].lo; if (output_delimiter_specified - && !is_printable_field (rsi_candidate)) - mark_range_start (rsi_candidate); + && !is_printable_field (rsi_candidate)) + mark_range_start (rsi_candidate); for (j = rp[i].lo; j <= rp[i].hi; j++) - mark_printable_field (j); + mark_printable_field (j); } if (output_delimiter_specified @@ -550,32 +550,32 @@ cut_bytes (FILE *stream) c = getc (stream); if (c == '\n') - { - putchar ('\n'); - byte_idx = 0; - print_delimiter = false; - } + { + putchar ('\n'); + byte_idx = 0; + print_delimiter = false; + } else if (c == EOF) - { - if (byte_idx > 0) - putchar ('\n'); - break; - } + { + if (byte_idx > 0) + putchar ('\n'); + break; + } else - { - bool range_start; - bool *rs = output_delimiter_specified ? &range_start : NULL; - if (print_kth (++byte_idx, rs)) - { - if (rs && *rs && print_delimiter) - { - fwrite (output_delimiter_string, sizeof (char), - output_delimiter_length, stdout); - } - print_delimiter = true; - putchar (c); - } - } + { + bool range_start; + bool *rs = output_delimiter_specified ? &range_start : NULL; + if (print_kth (++byte_idx, rs)) + { + if (rs && *rs && print_delimiter) + { + fwrite (output_delimiter_string, sizeof (char), + output_delimiter_length, stdout); + } + print_delimiter = true; + putchar (c); + } + } } } @@ -606,98 +606,98 @@ cut_fields (FILE *stream) while (1) { if (field_idx == 1 && buffer_first_field) - { - ssize_t len; - size_t n_bytes; + { + ssize_t len; + size_t n_bytes; - len = getndelim2 (&field_1_buffer, &field_1_bufsize, 0, - GETNLINE_NO_LIMIT, delim, '\n', stream); - if (len < 0) - { - free (field_1_buffer); - field_1_buffer = NULL; - if (ferror (stream) || feof (stream)) - break; - xalloc_die (); - } + len = getndelim2 (&field_1_buffer, &field_1_bufsize, 0, + GETNLINE_NO_LIMIT, delim, '\n', stream); + if (len < 0) + { + free (field_1_buffer); + field_1_buffer = NULL; + if (ferror (stream) || feof (stream)) + break; + xalloc_die (); + } - n_bytes = len; - assert (n_bytes != 0); + n_bytes = len; + assert (n_bytes != 0); - /* If the first field extends to the end of line (it is not - delimited) and we are printing all non-delimited lines, - print this one. */ - if (to_uchar (field_1_buffer[n_bytes - 1]) != delim) - { - if (suppress_non_delimited) - { - /* Empty. */ - } - else - { - fwrite (field_1_buffer, sizeof (char), n_bytes, stdout); - /* Make sure the output line is newline terminated. */ - if (field_1_buffer[n_bytes - 1] != '\n') - putchar ('\n'); - } - continue; - } - if (print_kth (1, NULL)) - { - /* Print the field, but not the trailing delimiter. */ - fwrite (field_1_buffer, sizeof (char), n_bytes - 1, stdout); - found_any_selected_field = true; - } - ++field_idx; - } + /* If the first field extends to the end of line (it is not + delimited) and we are printing all non-delimited lines, + print this one. */ + if (to_uchar (field_1_buffer[n_bytes - 1]) != delim) + { + if (suppress_non_delimited) + { + /* Empty. */ + } + else + { + fwrite (field_1_buffer, sizeof (char), n_bytes, stdout); + /* Make sure the output line is newline terminated. */ + if (field_1_buffer[n_bytes - 1] != '\n') + putchar ('\n'); + } + continue; + } + if (print_kth (1, NULL)) + { + /* Print the field, but not the trailing delimiter. */ + fwrite (field_1_buffer, sizeof (char), n_bytes - 1, stdout); + found_any_selected_field = true; + } + ++field_idx; + } if (c != EOF) - { - if (print_kth (field_idx, NULL)) - { - if (found_any_selected_field) - { - fwrite (output_delimiter_string, sizeof (char), - output_delimiter_length, stdout); - } - found_any_selected_field = true; + { + if (print_kth (field_idx, NULL)) + { + if (found_any_selected_field) + { + fwrite (output_delimiter_string, sizeof (char), + output_delimiter_length, stdout); + } + found_any_selected_field = true; - while ((c = getc (stream)) != delim && c != '\n' && c != EOF) - { - putchar (c); - } - } - else - { - while ((c = getc (stream)) != delim && c != '\n' && c != EOF) - { - /* Empty. */ - } - } - } + while ((c = getc (stream)) != delim && c != '\n' && c != EOF) + { + putchar (c); + } + } + else + { + while ((c = getc (stream)) != delim && c != '\n' && c != EOF) + { + /* Empty. */ + } + } + } if (c == '\n') - { - c = getc (stream); - if (c != EOF) - { - ungetc (c, stream); - c = '\n'; - } - } + { + c = getc (stream); + if (c != EOF) + { + ungetc (c, stream); + c = '\n'; + } + } if (c == delim) - ++field_idx; + ++field_idx; else if (c == '\n' || c == EOF) - { - if (found_any_selected_field - || !(suppress_non_delimited && field_idx == 1)) - putchar ('\n'); - if (c == EOF) - break; - field_idx = 1; - found_any_selected_field = false; - } + { + if (found_any_selected_field + || !(suppress_non_delimited && field_idx == 1)) + putchar ('\n'); + if (c == EOF) + break; + field_idx = 1; + found_any_selected_field = false; + } } } @@ -727,10 +727,10 @@ cut_file (char const *file) { stream = fopen (file, "r"); if (stream == NULL) - { - error (0, errno, "%s", file); - return false; - } + { + error (0, errno, "%s", file); + return false; + } } cut_stream (stream); @@ -777,60 +777,60 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "b:c:d:f:ns", longopts, NULL)) != -1) { switch (optc) - { - case 'b': - case 'c': - /* Build the byte list. */ - if (operating_mode != undefined_mode) - FATAL_ERROR (_("only one type of list may be specified")); - operating_mode = byte_mode; - spec_list_string = optarg; - break; + { + case 'b': + case 'c': + /* Build the byte list. */ + if (operating_mode != undefined_mode) + FATAL_ERROR (_("only one type of list may be specified")); + operating_mode = byte_mode; + spec_list_string = optarg; + break; - case 'f': - /* Build the field list. */ - if (operating_mode != undefined_mode) - FATAL_ERROR (_("only one type of list may be specified")); - operating_mode = field_mode; - spec_list_string = optarg; - break; + case 'f': + /* Build the field list. */ + if (operating_mode != undefined_mode) + FATAL_ERROR (_("only one type of list may be specified")); + operating_mode = field_mode; + spec_list_string = optarg; + break; - case 'd': - /* New delimiter. */ - /* Interpret -d '' to mean `use the NUL byte as the delimiter.' */ - if (optarg[0] != '\0' && optarg[1] != '\0') - FATAL_ERROR (_("the delimiter must be a single character")); - delim = optarg[0]; - delim_specified = true; - break; + case 'd': + /* New delimiter. */ + /* Interpret -d '' to mean `use the NUL byte as the delimiter.' */ + if (optarg[0] != '\0' && optarg[1] != '\0') + FATAL_ERROR (_("the delimiter must be a single character")); + delim = optarg[0]; + delim_specified = true; + break; - case OUTPUT_DELIMITER_OPTION: - output_delimiter_specified = true; - /* Interpret --output-delimiter='' to mean - `use the NUL byte as the delimiter.' */ - output_delimiter_length = (optarg[0] == '\0' - ? 1 : strlen (optarg)); - output_delimiter_string = xstrdup (optarg); - break; + case OUTPUT_DELIMITER_OPTION: + output_delimiter_specified = true; + /* Interpret --output-delimiter='' to mean + `use the NUL byte as the delimiter.' */ + output_delimiter_length = (optarg[0] == '\0' + ? 1 : strlen (optarg)); + output_delimiter_string = xstrdup (optarg); + break; - case 'n': - break; + case 'n': + break; - case 's': - suppress_non_delimited = true; - break; + case 's': + suppress_non_delimited = true; + break; - case COMPLEMENT_OPTION: - complement = true; - break; + case COMPLEMENT_OPTION: + complement = 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); - } + default: + usage (EXIT_FAILURE); + } } if (operating_mode == undefined_mode) @@ -847,19 +847,19 @@ main (int argc, char **argv) if (output_delimiter_specified) { range_start_ht = hash_initialize (HT_RANGE_START_INDEX_INITIAL_CAPACITY, - NULL, hash_int, - hash_compare_ints, NULL); + NULL, hash_int, + hash_compare_ints, NULL); if (range_start_ht == NULL) - xalloc_die (); + xalloc_die (); } if (! set_fields (spec_list_string)) { if (operating_mode == field_mode) - FATAL_ERROR (_("missing list of fields")); + FATAL_ERROR (_("missing list of fields")); else - FATAL_ERROR (_("missing list of positions")); + FATAL_ERROR (_("missing list of positions")); } if (!delim_specified) diff --git a/src/bin/coreutils/src/date.c b/src/bin/coreutils/src/date.c index 022107d40e..cbc53e6a51 100644 --- a/src/bin/coreutils/src/date.c +++ b/src/bin/coreutils/src/date.c @@ -118,14 +118,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [+FORMAT]\n\ or: %s [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Display the current time in the given FORMAT, or set the system date.\n\ \n\ @@ -264,9 +264,9 @@ batch_convert (const char *input_filename, const char *format) { in_stream = fopen (input_filename, "r"); if (in_stream == NULL) - { - error (EXIT_FAILURE, errno, "%s", quote (input_filename)); - } + { + error (EXIT_FAILURE, errno, "%s", quote (input_filename)); + } } line = NULL; @@ -276,22 +276,22 @@ batch_convert (const char *input_filename, const char *format) { ssize_t line_length = getline (&line, &buflen, in_stream); if (line_length < 0) - { - /* FIXME: detect/handle error here. */ - break; - } + { + /* FIXME: detect/handle error here. */ + break; + } if (! get_date (&when, line, NULL)) - { - if (line[line_length - 1] == '\n') - line[line_length - 1] = '\0'; - error (0, 0, _("invalid date %s"), quote (line)); - ok = false; - } + { + if (line[line_length - 1] == '\n') + line[line_length - 1] = '\0'; + error (0, 0, _("invalid date %s"), quote (line)); + ok = false; + } else - { - ok &= show_date (format, when); - } + { + ok &= show_date (format, when); + } } if (fclose (in_stream) == EOF) @@ -326,138 +326,138 @@ main (int argc, char **argv) atexit (close_stdout); while ((optc = getopt_long (argc, argv, short_options, long_options, NULL)) - != -1) + != -1) { char const *new_format = NULL; switch (optc) - { - case 'd': - datestr = optarg; - break; - case 'f': - batch_file = optarg; - break; - case RFC_3339_OPTION: - { - static char const rfc_3339_format[][32] = - { - "%Y-%m-%d", - "%Y-%m-%d %H:%M:%S%:z", - "%Y-%m-%d %H:%M:%S.%N%:z" - }; - enum Time_spec i = - XARGMATCH ("--rfc-3339", optarg, - time_spec_string + 2, time_spec + 2); - new_format = rfc_3339_format[i]; - break; - } - case 'I': - { - static char const iso_8601_format[][32] = - { - "%Y-%m-%d", - "%Y-%m-%dT%H:%M:%S%z", - "%Y-%m-%dT%H:%M:%S,%N%z", - "%Y-%m-%dT%H%z", - "%Y-%m-%dT%H:%M%z" - }; - enum Time_spec i = - (optarg - ? XARGMATCH ("--iso-8601", optarg, time_spec_string, time_spec) - : TIME_SPEC_DATE); - new_format = iso_8601_format[i]; - break; - } - case 'r': - reference = optarg; - break; - case 'R': - new_format = rfc_2822_format; - break; - case 's': - set_datestr = optarg; - set_date = true; - break; - case 'u': - /* POSIX says that `date -u' is equivalent to setting the TZ - environment variable, so this option should do nothing other - than setting TZ. */ - if (putenv (bad_cast ("TZ=UTC0")) != 0) - xalloc_die (); - TZSET; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + { + case 'd': + datestr = optarg; + break; + case 'f': + batch_file = optarg; + break; + case RFC_3339_OPTION: + { + static char const rfc_3339_format[][32] = + { + "%Y-%m-%d", + "%Y-%m-%d %H:%M:%S%:z", + "%Y-%m-%d %H:%M:%S.%N%:z" + }; + enum Time_spec i = + XARGMATCH ("--rfc-3339", optarg, + time_spec_string + 2, time_spec + 2); + new_format = rfc_3339_format[i]; + break; + } + case 'I': + { + static char const iso_8601_format[][32] = + { + "%Y-%m-%d", + "%Y-%m-%dT%H:%M:%S%z", + "%Y-%m-%dT%H:%M:%S,%N%z", + "%Y-%m-%dT%H%z", + "%Y-%m-%dT%H:%M%z" + }; + enum Time_spec i = + (optarg + ? XARGMATCH ("--iso-8601", optarg, time_spec_string, time_spec) + : TIME_SPEC_DATE); + new_format = iso_8601_format[i]; + break; + } + case 'r': + reference = optarg; + break; + case 'R': + new_format = rfc_2822_format; + break; + case 's': + set_datestr = optarg; + set_date = true; + break; + case 'u': + /* POSIX says that `date -u' is equivalent to setting the TZ + environment variable, so this option should do nothing other + than setting TZ. */ + if (putenv (bad_cast ("TZ=UTC0")) != 0) + xalloc_die (); + TZSET; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } if (new_format) - { - if (format) - error (EXIT_FAILURE, 0, _("multiple output formats specified")); - format = new_format; - } + { + if (format) + error (EXIT_FAILURE, 0, _("multiple output formats specified")); + format = new_format; + } } option_specified_date = ((datestr ? 1 : 0) - + (batch_file ? 1 : 0) - + (reference ? 1 : 0)); + + (batch_file ? 1 : 0) + + (reference ? 1 : 0)); if (option_specified_date > 1) { error (0, 0, - _("the options to specify dates for printing are mutually exclusive")); + _("the options to specify dates for printing are mutually exclusive")); usage (EXIT_FAILURE); } if (set_date && option_specified_date) { error (0, 0, - _("the options to print and set the time may not be used together")); + _("the options to print and set the time may not be used together")); usage (EXIT_FAILURE); } if (optind < argc) { if (optind + 1 < argc) - { - error (0, 0, _("extra operand %s"), quote (argv[optind + 1])); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("extra operand %s"), quote (argv[optind + 1])); + usage (EXIT_FAILURE); + } if (argv[optind][0] == '+') - { - if (format) - error (EXIT_FAILURE, 0, _("multiple output formats specified")); - format = argv[optind++] + 1; - } + { + if (format) + error (EXIT_FAILURE, 0, _("multiple output formats specified")); + format = argv[optind++] + 1; + } else if (set_date || option_specified_date) - { - error (0, 0, - _("the argument %s lacks a leading `+';\n" - "when using an option to specify date(s), any non-option\n" - "argument must be a format string beginning with `+'"), - quote (argv[optind])); - usage (EXIT_FAILURE); - } + { + error (0, 0, + _("the argument %s lacks a leading `+';\n" + "when using an option to specify date(s), any non-option\n" + "argument must be a format string beginning with `+'"), + quote (argv[optind])); + usage (EXIT_FAILURE); + } } if (!format) { format = DATE_FMT_LANGINFO (); if (! *format) - { - /* Do not wrap the following literal format string with _(...). - 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 - using the POSIX locale; but adding _() would cause "date" - to use a Korean translation of the format. */ - format = "%a %b %e %H:%M:%S %Z %Y"; - } + { + /* Do not wrap the following literal format string with _(...). + 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 + using the POSIX locale; but adding _() would cause "date" + to use a Korean translation of the format. */ + format = "%a %b %e %H:%M:%S %Z %Y"; + } } if (batch_file != NULL) @@ -468,55 +468,55 @@ main (int argc, char **argv) ok = true; if (!option_specified_date && !set_date) - { - if (optind < argc) - { - /* Prepare to set system clock to the specified date/time - given in the POSIX-format. */ - set_date = true; - datestr = argv[optind]; - valid_date = posixtime (&when.tv_sec, - datestr, - (PDS_TRAILING_YEAR - | PDS_CENTURY | PDS_SECONDS)); - when.tv_nsec = 0; /* FIXME: posixtime should set this. */ - } - else - { - /* Prepare to print the current date/time. */ - gettime (&when); - } - } + { + if (optind < argc) + { + /* Prepare to set system clock to the specified date/time + given in the POSIX-format. */ + set_date = true; + datestr = argv[optind]; + valid_date = posixtime (&when.tv_sec, + datestr, + (PDS_TRAILING_YEAR + | PDS_CENTURY | PDS_SECONDS)); + when.tv_nsec = 0; /* FIXME: posixtime should set this. */ + } + else + { + /* Prepare to print the current date/time. */ + gettime (&when); + } + } else - { - /* (option_specified_date || set_date) */ - if (reference != NULL) - { - if (stat (reference, &refstats) != 0) - error (EXIT_FAILURE, errno, "%s", reference); - when = get_stat_mtime (&refstats); - } - else - { - if (set_datestr) - datestr = set_datestr; - valid_date = get_date (&when, datestr, NULL); - } - } + { + /* (option_specified_date || set_date) */ + if (reference != NULL) + { + if (stat (reference, &refstats) != 0) + error (EXIT_FAILURE, errno, "%s", reference); + when = get_stat_mtime (&refstats); + } + else + { + if (set_datestr) + datestr = set_datestr; + valid_date = get_date (&when, datestr, NULL); + } + } if (! valid_date) - error (EXIT_FAILURE, 0, _("invalid date %s"), quote (datestr)); + error (EXIT_FAILURE, 0, _("invalid date %s"), quote (datestr)); if (set_date) - { - /* Set the system clock to the specified date, then regardless of - the success of that operation, format and print that date. */ - if (settime (&when) != 0) - { - error (0, errno, _("cannot set date")); - ok = false; - } - } + { + /* Set the system clock to the specified date, then regardless of + the success of that operation, format and print that date. */ + if (settime (&when) != 0) + { + error (0, errno, _("cannot set date")); + ok = false; + } + } ok &= show_date (format, when); } diff --git a/src/bin/coreutils/src/dd.c b/src/bin/coreutils/src/dd.c index 30bd8085c7..76a31e9816 100644 --- a/src/bin/coreutils/src/dd.c +++ b/src/bin/coreutils/src/dd.c @@ -25,6 +25,7 @@ #include #include "system.h" +#include "close-stream.h" #include "error.h" #include "fd-reopen.h" #include "gethrxtime.h" @@ -82,7 +83,7 @@ static void process_signals (void); { \ obuf[oc++] = (c); \ if (oc >= output_blocksize) \ - write_output (); \ + write_output (); \ } \ while (0) @@ -444,12 +445,16 @@ static bool close_stdout_required = true; close_stdout function call "fclose (stdout)" would result in a harmless failure of the close syscall (with errno EBADF). This function serves solely to avoid the unnecessary close_stdout - call, once parse_long_options has succeeded. */ + call, once parse_long_options has succeeded. + Meanwhile, we guarantee that the standard error stream is flushed, + by inlining the last half of close_stdout as needed. */ static void maybe_close_stdout (void) { if (close_stdout_required) close_stdout (); + else if (close_stream (stderr) != 0) + _exit (EXIT_FAILURE); } void @@ -457,14 +462,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPERAND]...\n\ or: %s OPTION\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Copy a file, converting and formatting according to the operands.\n\ \n\ @@ -522,36 +527,36 @@ Each FLAG symbol may be:\n\ append append mode (makes sense only for output; conv=notrunc suggested)\n\ "), stdout); if (O_CIO) - fputs (_(" cio use concurrent I/O for data\n"), stdout); + fputs (_(" cio use concurrent I/O for data\n"), stdout); if (O_DIRECT) - fputs (_(" direct use direct I/O for data\n"), stdout); + fputs (_(" direct use direct I/O for data\n"), stdout); if (O_DIRECTORY) - fputs (_(" directory fail unless a directory\n"), stdout); + fputs (_(" directory fail unless a directory\n"), stdout); if (O_DSYNC) - fputs (_(" dsync use synchronized I/O for data\n"), stdout); + fputs (_(" dsync use synchronized I/O for data\n"), stdout); if (O_SYNC) - fputs (_(" sync likewise, but also for metadata\n"), stdout); + fputs (_(" sync likewise, but also for metadata\n"), stdout); fputs (_(" fullblock accumulate full blocks of input (iflag only)\n"), - stdout); + stdout); if (O_NONBLOCK) - fputs (_(" nonblock use non-blocking I/O\n"), stdout); + fputs (_(" nonblock use non-blocking I/O\n"), stdout); if (O_NOATIME) - fputs (_(" noatime do not update access time\n"), stdout); + fputs (_(" noatime do not update access time\n"), stdout); if (O_NOCTTY) - fputs (_(" noctty do not assign controlling terminal from file\n"), - stdout); + fputs (_(" noctty do not assign controlling terminal from file\n"), + stdout); if (HAVE_WORKING_O_NOFOLLOW) - fputs (_(" nofollow do not follow symlinks\n"), stdout); + fputs (_(" nofollow do not follow symlinks\n"), stdout); if (O_NOLINKS) - fputs (_(" nolinks fail if multiply-linked\n"), stdout); + fputs (_(" nolinks fail if multiply-linked\n"), stdout); if (O_BINARY) - fputs (_(" binary use binary I/O for data\n"), stdout); + fputs (_(" binary use binary I/O for data\n"), stdout); if (O_TEXT) - fputs (_(" text use text I/O for data\n"), stdout); + fputs (_(" text use text I/O for data\n"), stdout); { - char const *siginfo_name = (SIGINFO == SIGUSR1 ? "USR1" : "INFO"); - printf (_("\ + char const *siginfo_name = (SIGINFO == SIGUSR1 ? "USR1" : "INFO"); + printf (_("\ \n\ Sending a %s signal to a running `dd' process makes it\n\ print I/O statistics to standard error and then resume copying.\n\ @@ -565,7 +570,7 @@ print I/O statistics to standard error and then resume copying.\n\ Options are:\n\ \n\ "), - siginfo_name, siginfo_name); + siginfo_name, siginfo_name); } fputs (HELP_OPTION_DESCRIPTION, stdout); @@ -607,16 +612,16 @@ print_stats (void) char const *bytes_per_second; fprintf (stderr, - _("%"PRIuMAX"+%"PRIuMAX" records in\n" - "%"PRIuMAX"+%"PRIuMAX" records out\n"), - r_full, r_partial, w_full, w_partial); + _("%"PRIuMAX"+%"PRIuMAX" records in\n" + "%"PRIuMAX"+%"PRIuMAX" records out\n"), + r_full, r_partial, w_full, w_partial); if (r_truncate != 0) fprintf (stderr, - ngettext ("%"PRIuMAX" truncated record\n", - "%"PRIuMAX" truncated records\n", - select_plural (r_truncate)), - r_truncate); + ngettext ("%"PRIuMAX" truncated record\n", + "%"PRIuMAX" truncated records\n", + select_plural (r_truncate)), + r_truncate); if (status_flags & STATUS_NOXFER) return; @@ -625,11 +630,11 @@ print_stats (void) since that makes it easy to use SI abbreviations. */ fprintf (stderr, - ngettext ("%"PRIuMAX" byte (%s) copied", - "%"PRIuMAX" bytes (%s) copied", - select_plural (w_bytes)), - w_bytes, - human_readable (w_bytes, hbuf, human_opts, 1, 1)); + ngettext ("%"PRIuMAX" byte (%s) copied", + "%"PRIuMAX" bytes (%s) copied", + select_plural (w_bytes)), + w_bytes, + human_readable (w_bytes, hbuf, human_opts, 1, 1)); if (start_time < now) { @@ -638,7 +643,7 @@ print_stats (void) delta_xtime -= start_time; delta_s = delta_xtime / XTIME_PRECISIONe0; bytes_per_second = human_readable (w_bytes, hbuf, human_opts, - XTIME_PRECISION, delta_xtime); + XTIME_PRECISION, delta_xtime); } else { @@ -664,14 +669,14 @@ cleanup (void) { if (close (STDIN_FILENO) < 0) error (EXIT_FAILURE, errno, - _("closing input file %s"), quote (input_file)); + _("closing input file %s"), quote (input_file)); /* Don't remove this call to close, even though close_stdout closes standard output. This close is necessary when cleanup is called as part of a signal handler. */ if (close (STDOUT_FILENO) < 0) error (EXIT_FAILURE, errno, - _("closing output file %s"), quote (output_file)); + _("closing output file %s"), quote (output_file)); } static void ATTRIBUTE_NORETURN @@ -718,7 +723,7 @@ install_signal_handlers (void) { sigaction (SIGINFO, NULL, &act); if (act.sa_handler != SIG_IGN) - sigaddset (&caught_signals, SIGINFO); + sigaddset (&caught_signals, SIGINFO); } sigaction (SIGINT, NULL, &act); if (act.sa_handler != SIG_IGN) @@ -735,8 +740,8 @@ install_signal_handlers (void) if (sigismember (&caught_signals, SIGINT)) { /* POSIX 1003.1-2001 says SA_RESETHAND implies SA_NODEFER, - but this is not true on Solaris 8 at least. It doesn't - hurt to use SA_NODEFER here, so leave it in. */ + but this is not true on Solaris 8 at least. It doesn't + hurt to use SA_NODEFER here, so leave it in. */ act.sa_handler = interrupt_handler; act.sa_flags = SA_NODEFER | SA_RESETHAND; sigaction (SIGINT, &act, NULL); @@ -773,20 +778,20 @@ process_signals (void) sigprocmask (SIG_BLOCK, &caught_signals, &oldset); /* Reload interrupt_signal and info_signal_count, in case a new - signal was handled before sigprocmask took effect. */ + signal was handled before sigprocmask took effect. */ interrupt = interrupt_signal; infos = info_signal_count; if (infos) - info_signal_count = infos - 1; + info_signal_count = infos - 1; sigprocmask (SIG_SETMASK, &oldset, NULL); if (interrupt) - cleanup (); + cleanup (); print_stats (); if (interrupt) - raise (interrupt); + raise (interrupt); } } @@ -803,7 +808,7 @@ iread (int fd, char *buf, size_t size) process_signals (); nread = read (fd, buf, size); if (! (nread < 0 && errno == EINTR)) - return nread; + return nread; } } @@ -817,9 +822,9 @@ iread_fullblock (int fd, char *buf, size_t size) { ssize_t ncurr = iread (fd, buf, size); if (ncurr < 0) - return ncurr; + return ncurr; if (ncurr == 0) - break; + break; nread += ncurr; buf += ncurr; size -= ncurr; @@ -868,20 +873,20 @@ iwrite (int fd, char const *buf, size_t size) process_signals (); nwritten = write (fd, buf + total_written, size - total_written); if (nwritten < 0) - { - if (errno != EINTR) - break; - } + { + if (errno != EINTR) + break; + } else if (nwritten == 0) - { - /* Some buggy drivers return 0 when one tries to write beyond - a device's end. (Example: Linux kernel 1.2.13 on /dev/fd0.) - Set errno to ENOSPC so they get a sensible diagnostic. */ - errno = ENOSPC; - break; - } + { + /* Some buggy drivers return 0 when one tries to write beyond + a device's end. (Example: Linux kernel 1.2.13 on /dev/fd0.) + Set errno to ENOSPC so they get a sensible diagnostic. */ + errno = ENOSPC; + break; + } else - total_written += nwritten; + total_written += nwritten; } return total_written; @@ -898,7 +903,7 @@ write_output (void) { error (0, errno, _("writing to %s"), quote (output_file)); if (nwritten != 0) - w_partial++; + w_partial++; quit (EXIT_FAILURE); } else @@ -923,7 +928,7 @@ operand_matches (char const *str, char const *pattern, char delim) static int parse_symbols (char const *str, struct symbol_value const *table, - char const *error_msgid) + char const *error_msgid) { int value = 0; @@ -933,21 +938,21 @@ parse_symbols (char const *str, struct symbol_value const *table, struct symbol_value const *entry; for (entry = table; - ! (operand_matches (str, entry->symbol, ',') && entry->value); - entry++) - { - if (! entry->symbol[0]) - { - size_t slen = strcomma ? strcomma - str : strlen (str); - error (0, 0, "%s: %s", _(error_msgid), - quotearg_n_style_mem (0, locale_quoting_style, str, slen)); - usage (EXIT_FAILURE); - } - } + ! (operand_matches (str, entry->symbol, ',') && entry->value); + entry++) + { + if (! entry->symbol[0]) + { + size_t slen = strcomma ? strcomma - str : strlen (str); + error (0, 0, "%s: %s", _(error_msgid), + quotearg_n_style_mem (0, locale_quoting_style, str, slen)); + usage (EXIT_FAILURE); + } + } value |= entry->value; if (!strcomma) - break; + break; str = strcomma + 1; } @@ -970,10 +975,10 @@ parse_integer (const char *str, bool *invalid) uintmax_t multiplier = parse_integer (suffix + 1, invalid); if (multiplier != 0 && n * multiplier / multiplier != n) - { - *invalid = true; - return 0; - } + { + *invalid = true; + return 0; + } n *= multiplier; } @@ -1006,68 +1011,68 @@ scanargs (int argc, char *const *argv) char const *val = strchr (name, '='); if (val == NULL) - { - error (0, 0, _("unrecognized operand %s"), quote (name)); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("unrecognized operand %s"), quote (name)); + usage (EXIT_FAILURE); + } val++; if (operand_is (name, "if")) - input_file = val; + input_file = val; else if (operand_is (name, "of")) - output_file = val; + output_file = val; else if (operand_is (name, "conv")) - conversions_mask |= parse_symbols (val, conversions, - N_("invalid conversion")); + conversions_mask |= parse_symbols (val, conversions, + N_("invalid conversion")); else if (operand_is (name, "iflag")) - input_flags |= parse_symbols (val, flags, - N_("invalid input flag")); + input_flags |= parse_symbols (val, flags, + N_("invalid input flag")); else if (operand_is (name, "oflag")) - output_flags |= parse_symbols (val, flags, - N_("invalid output flag")); + output_flags |= parse_symbols (val, flags, + N_("invalid output flag")); else if (operand_is (name, "status")) - status_flags |= parse_symbols (val, statuses, - N_("invalid status flag")); + status_flags |= parse_symbols (val, statuses, + N_("invalid status flag")); else - { - bool invalid = false; - uintmax_t n = parse_integer (val, &invalid); + { + bool invalid = false; + uintmax_t n = parse_integer (val, &invalid); - if (operand_is (name, "ibs")) - { - invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP)); - input_blocksize = n; - } - else if (operand_is (name, "obs")) - { - invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (OUTPUT_BLOCK_SLOP)); - output_blocksize = n; - } - else if (operand_is (name, "bs")) - { - invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP)); - blocksize = n; - } - else if (operand_is (name, "cbs")) - { - invalid |= ! (0 < n && n <= SIZE_MAX); - conversion_blocksize = n; - } - else if (operand_is (name, "skip")) - skip_records = n; - else if (operand_is (name, "seek")) - seek_records = n; - else if (operand_is (name, "count")) - max_records = n; - else - { - error (0, 0, _("unrecognized operand %s"), quote (name)); - usage (EXIT_FAILURE); - } + if (operand_is (name, "ibs")) + { + invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP)); + input_blocksize = n; + } + else if (operand_is (name, "obs")) + { + invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (OUTPUT_BLOCK_SLOP)); + output_blocksize = n; + } + else if (operand_is (name, "bs")) + { + invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP)); + blocksize = n; + } + else if (operand_is (name, "cbs")) + { + invalid |= ! (0 < n && n <= SIZE_MAX); + conversion_blocksize = n; + } + else if (operand_is (name, "skip")) + skip_records = n; + else if (operand_is (name, "seek")) + seek_records = n; + else if (operand_is (name, "count")) + max_records = n; + else + { + error (0, 0, _("unrecognized operand %s"), quote (name)); + usage (EXIT_FAILURE); + } - if (invalid) - error (EXIT_FAILURE, 0, _("invalid number %s"), quote (val)); - } + if (invalid) + error (EXIT_FAILURE, 0, _("invalid number %s"), quote (val)); + } } if (blocksize) @@ -1075,7 +1080,7 @@ scanargs (int argc, char *const *argv) else { /* POSIX says dd aggregates short reads into - output_blocksize if bs= is not specified. */ + output_blocksize if bs= is not specified. */ conversions_mask |= C_TWOBUFS; } @@ -1095,8 +1100,8 @@ scanargs (int argc, char *const *argv) usage (EXIT_FAILURE); } iread_fnc = ((input_flags & O_FULLBLOCK) - ? iread_fullblock - : iread); + ? iread_fullblock + : iread); input_flags &= ~O_FULLBLOCK; if (multiple_bits_set (conversions_mask & (C_ASCII | C_EBCDIC | C_IBM))) @@ -1122,13 +1127,13 @@ apply_translations (void) if (conversions_mask & C_UCASE) { for (i = 0; i < 256; i++) - trans_table[i] = toupper (trans_table[i]); + trans_table[i] = toupper (trans_table[i]); translation_needed = true; } else if (conversions_mask & C_LCASE) { for (i = 0; i < 256; i++) - trans_table[i] = tolower (trans_table[i]); + trans_table[i] = tolower (trans_table[i]); translation_needed = true; } @@ -1254,7 +1259,7 @@ skip_via_lseek (char const *filename, int fdesc, off_t offset, int whence) { error (0, 0, _("warning: working around lseek kernel bug for file (%s)\n\ of mt_type=0x%0lx -- see for the list of types"), - filename, s2.mt_type); + filename, s2.mt_type); errno = 0; new_position = -1; } @@ -1288,20 +1293,20 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize, { if (fdesc == STDIN_FILENO) { - struct stat st; - if (fstat (STDIN_FILENO, &st) != 0) - error (EXIT_FAILURE, errno, _("cannot fstat %s"), quote (file)); - if (S_ISREG (st.st_mode) && st.st_size < (input_offset + offset)) - { - /* When skipping past EOF, return the number of _full_ blocks - * that are not skipped, and set offset to EOF, so the caller - * can determine the requested skip was not satisfied. */ - records = ( offset - st.st_size ) / blocksize; - offset = st.st_size - input_offset; - } - else - records = 0; - advance_input_offset (offset); + struct stat st; + if (fstat (STDIN_FILENO, &st) != 0) + error (EXIT_FAILURE, errno, _("cannot fstat %s"), quote (file)); + if (S_ISREG (st.st_mode) && st.st_size < (input_offset + offset)) + { + /* When skipping past EOF, return the number of _full_ blocks + * that are not skipped, and set offset to EOF, so the caller + * can determine the requested skip was not satisfied. */ + records = ( offset - st.st_size ) / blocksize; + offset = st.st_size - input_offset; + } + else + records = 0; + advance_input_offset (offset); } else records = 0; @@ -1310,64 +1315,63 @@ skip (int fdesc, char const *file, uintmax_t records, size_t blocksize, else { int lseek_errno = errno; - off_t soffset; /* The seek request may have failed above if it was too big (> device size, > max file size, etc.) Or it may not have been done at all (> OFF_T_MAX). Therefore try to seek to the end of the file, to avoid redundant reading. */ - if ((soffset = skip_via_lseek (file, fdesc, 0, SEEK_END)) >= 0) - { - /* File is seekable, and we're at the end of it, and - size <= OFF_T_MAX. So there's no point using read to advance. */ + if ((skip_via_lseek (file, fdesc, 0, SEEK_END)) >= 0) + { + /* File is seekable, and we're at the end of it, and + size <= OFF_T_MAX. So there's no point using read to advance. */ - if (!lseek_errno) - { - /* The original seek was not attempted as offset > OFF_T_MAX. - We should error for write as can't get to the desired - location, even if OFF_T_MAX < max file size. - For read we're not going to read any data anyway, - so we should error for consistency. - It would be nice to not error for /dev/{zero,null} - for any offset, but that's not a significant issue. */ - lseek_errno = EOVERFLOW; - } + if (!lseek_errno) + { + /* The original seek was not attempted as offset > OFF_T_MAX. + We should error for write as can't get to the desired + location, even if OFF_T_MAX < max file size. + For read we're not going to read any data anyway, + so we should error for consistency. + It would be nice to not error for /dev/{zero,null} + for any offset, but that's not a significant issue. */ + lseek_errno = EOVERFLOW; + } - if (fdesc == STDIN_FILENO) - error (0, lseek_errno, _("%s: cannot skip"), quote (file)); - else - error (0, lseek_errno, _("%s: cannot seek"), quote (file)); - /* If the file has a specific size and we've asked - to skip/seek beyond the max allowable, then quit. */ - quit (EXIT_FAILURE); - } + if (fdesc == STDIN_FILENO) + error (0, lseek_errno, _("%s: cannot skip"), quote (file)); + else + error (0, lseek_errno, _("%s: cannot seek"), quote (file)); + /* If the file has a specific size and we've asked + to skip/seek beyond the max allowable, then quit. */ + quit (EXIT_FAILURE); + } /* else file_size && offset > OFF_T_MAX or file ! seekable */ do - { - ssize_t nread = iread_fnc (fdesc, buf, blocksize); - if (nread < 0) - { - if (fdesc == STDIN_FILENO) - { - error (0, errno, _("reading %s"), quote (file)); - if (conversions_mask & C_NOERROR) - { - print_stats (); - continue; - } - } - else - error (0, lseek_errno, _("%s: cannot seek"), quote (file)); - quit (EXIT_FAILURE); - } + { + ssize_t nread = iread_fnc (fdesc, buf, blocksize); + if (nread < 0) + { + if (fdesc == STDIN_FILENO) + { + error (0, errno, _("reading %s"), quote (file)); + if (conversions_mask & C_NOERROR) + { + print_stats (); + continue; + } + } + else + error (0, lseek_errno, _("%s: cannot seek"), quote (file)); + quit (EXIT_FAILURE); + } - if (nread == 0) - break; - if (fdesc == STDIN_FILENO) - advance_input_offset (nread); - } + if (nread == 0) + break; + if (fdesc == STDIN_FILENO) + advance_input_offset (nread); + } while (--records != 0); return records; @@ -1386,7 +1390,7 @@ advance_input_after_read_error (size_t nbytes) if (! input_seekable) { if (input_seek_errno == ESPIPE) - return true; + return true; errno = input_seek_errno; } else @@ -1395,25 +1399,25 @@ advance_input_after_read_error (size_t nbytes) advance_input_offset (nbytes); input_offset_overflow |= (OFF_T_MAX < input_offset); if (input_offset_overflow) - { - error (0, 0, _("offset overflow while reading file %s"), - quote (input_file)); - return false; - } + { + error (0, 0, _("offset overflow while reading file %s"), + quote (input_file)); + return false; + } offset = lseek (STDIN_FILENO, 0, SEEK_CUR); if (0 <= offset) - { - off_t diff; - if (offset == input_offset) - return true; - diff = input_offset - offset; - if (! (0 <= diff && diff <= nbytes)) - error (0, 0, _("warning: invalid file offset after failed read")); - if (0 <= skip_via_lseek (input_file, STDIN_FILENO, diff, SEEK_CUR)) - return true; - if (errno == 0) - error (0, 0, _("cannot work around kernel bug after all")); - } + { + off_t diff; + if (offset == input_offset) + return true; + diff = input_offset - offset; + if (! (0 <= diff && diff <= nbytes)) + error (0, 0, _("warning: invalid file offset after failed read")); + if (0 <= skip_via_lseek (input_file, STDIN_FILENO, diff, SEEK_CUR)) + return true; + if (errno == 0) + error (0, 0, _("cannot work around kernel bug after all")); + } } error (0, errno, _("%s: cannot seek"), quote (input_file)); @@ -1437,7 +1441,7 @@ copy_simple (char const *buf, size_t nread) start += nfree; oc += nfree; if (oc >= output_blocksize) - write_output (); + write_output (); } while (nread != 0); } @@ -1454,23 +1458,23 @@ copy_with_block (char const *buf, size_t nread) for (i = nread; i; i--, buf++) { if (*buf == newline_character) - { - if (col < conversion_blocksize) - { - size_t j; - for (j = col; j < conversion_blocksize; j++) - output_char (space_character); - } - col = 0; - } + { + if (col < conversion_blocksize) + { + size_t j; + for (j = col; j < conversion_blocksize; j++) + output_char (space_character); + } + col = 0; + } else - { - if (col == conversion_blocksize) - r_truncate++; - else if (col < conversion_blocksize) - output_char (*buf); - col++; - } + { + if (col == conversion_blocksize) + r_truncate++; + else if (col < conversion_blocksize) + output_char (*buf); + col++; + } } } @@ -1490,24 +1494,24 @@ copy_with_unblock (char const *buf, size_t nread) c = buf[i]; if (col++ >= conversion_blocksize) - { - col = pending_spaces = 0; /* Wipe out any pending spaces. */ - i--; /* Push the char back; get it later. */ - output_char (newline_character); - } + { + col = pending_spaces = 0; /* Wipe out any pending spaces. */ + i--; /* Push the char back; get it later. */ + output_char (newline_character); + } else if (c == space_character) - pending_spaces++; + pending_spaces++; else - { - /* `c' is the character after a run of spaces that were not - at the end of the conversion buffer. Output them. */ - while (pending_spaces) - { - output_char (space_character); - --pending_spaces; - } - output_char (c); - } + { + /* `c' is the character after a run of spaces that were not + at the end of the conversion buffer. Output them. */ + while (pending_spaces) + { + output_char (space_character); + --pending_spaces; + } + output_char (c); + } } } @@ -1526,36 +1530,36 @@ set_fd_flags (int fd, int add_flags, char const *name) int new_flags = old_flags | add_flags; bool ok = true; if (old_flags < 0) - ok = false; + ok = false; else if (old_flags != new_flags) - { - if (new_flags & (O_DIRECTORY | O_NOLINKS)) - { - /* NEW_FLAGS contains at least one file creation flag that - requires some checking of the open file descriptor. */ - struct stat st; - if (fstat (fd, &st) != 0) - ok = false; - else if ((new_flags & O_DIRECTORY) && ! S_ISDIR (st.st_mode)) - { - errno = ENOTDIR; - ok = false; - } - else if ((new_flags & O_NOLINKS) && 1 < st.st_nlink) - { - errno = EMLINK; - ok = false; - } - new_flags &= ~ (O_DIRECTORY | O_NOLINKS); - } + { + if (new_flags & (O_DIRECTORY | O_NOLINKS)) + { + /* NEW_FLAGS contains at least one file creation flag that + requires some checking of the open file descriptor. */ + struct stat st; + if (fstat (fd, &st) != 0) + ok = false; + else if ((new_flags & O_DIRECTORY) && ! S_ISDIR (st.st_mode)) + { + errno = ENOTDIR; + ok = false; + } + else if ((new_flags & O_NOLINKS) && 1 < st.st_nlink) + { + errno = EMLINK; + ok = false; + } + new_flags &= ~ (O_DIRECTORY | O_NOLINKS); + } - if (ok && old_flags != new_flags - && fcntl (fd, F_SETFL, new_flags) == -1) - ok = false; - } + if (ok && old_flags != new_flags + && fcntl (fd, F_SETFL, new_flags) == -1) + ok = false; + } if (!ok) - error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name)); + error (EXIT_FAILURE, errno, _("setting flags for %s"), quote (name)); } } @@ -1617,40 +1621,40 @@ dd_copy (void) { uintmax_t us_bytes = input_offset + (skip_records * input_blocksize); uintmax_t us_blocks = skip (STDIN_FILENO, input_file, - skip_records, input_blocksize, ibuf); + skip_records, input_blocksize, ibuf); us_bytes -= input_offset; /* POSIX doesn't say what to do when dd detects it has been - asked to skip past EOF, so I assume it's non-fatal. - There are 3 reasons why there might be unskipped blocks/bytes: - 1. file is too small - 2. pipe has not enough data - 3. short reads */ + asked to skip past EOF, so I assume it's non-fatal. + There are 3 reasons why there might be unskipped blocks/bytes: + 1. file is too small + 2. pipe has not enough data + 3. short reads */ if (us_blocks || (!input_offset_overflow && us_bytes)) - { - error (0, 0, - _("%s: cannot skip to specified offset"), quote (input_file)); - } + { + error (0, 0, + _("%s: cannot skip to specified offset"), quote (input_file)); + } } if (seek_records != 0) { uintmax_t write_records = skip (STDOUT_FILENO, output_file, - seek_records, output_blocksize, obuf); + seek_records, output_blocksize, obuf); if (write_records != 0) - { - memset (obuf, 0, output_blocksize); + { + memset (obuf, 0, output_blocksize); - do - if (iwrite (STDOUT_FILENO, obuf, output_blocksize) - != output_blocksize) - { - error (0, errno, _("writing to %s"), quote (output_file)); - quit (EXIT_FAILURE); - } - while (--write_records != 0); - } + do + if (iwrite (STDOUT_FILENO, obuf, output_blocksize) + != output_blocksize) + { + error (0, errno, _("writing to %s"), quote (output_file)); + quit (EXIT_FAILURE); + } + while (--write_records != 0); + } } if (max_records == 0) @@ -1659,106 +1663,106 @@ dd_copy (void) while (1) { if (r_partial + r_full >= max_records) - break; + break; /* Zero the buffer before reading, so that if we get a read error, - whatever data we are able to read is followed by zeros. - This minimizes data loss. */ + whatever data we are able to read is followed by zeros. + This minimizes data loss. */ if ((conversions_mask & C_SYNC) && (conversions_mask & C_NOERROR)) - memset (ibuf, - (conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0', - input_blocksize); + memset (ibuf, + (conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0', + input_blocksize); nread = iread_fnc (STDIN_FILENO, ibuf, input_blocksize); if (nread == 0) - break; /* EOF. */ + break; /* EOF. */ if (nread < 0) - { - error (0, errno, _("reading %s"), quote (input_file)); - if (conversions_mask & C_NOERROR) - { - print_stats (); - /* Seek past the bad block if possible. */ - if (!advance_input_after_read_error (input_blocksize - partread)) - { - exit_status = EXIT_FAILURE; + { + error (0, errno, _("reading %s"), quote (input_file)); + if (conversions_mask & C_NOERROR) + { + print_stats (); + /* Seek past the bad block if possible. */ + if (!advance_input_after_read_error (input_blocksize - partread)) + { + exit_status = EXIT_FAILURE; - /* Suppress duplicate diagnostics. */ - input_seekable = false; - input_seek_errno = ESPIPE; - } - if ((conversions_mask & C_SYNC) && !partread) - /* Replace the missing input with null bytes and - proceed normally. */ - nread = 0; - else - continue; - } - else - { - /* Write any partial block. */ - exit_status = EXIT_FAILURE; - break; - } - } + /* Suppress duplicate diagnostics. */ + input_seekable = false; + input_seek_errno = ESPIPE; + } + if ((conversions_mask & C_SYNC) && !partread) + /* Replace the missing input with null bytes and + proceed normally. */ + nread = 0; + else + continue; + } + else + { + /* Write any partial block. */ + exit_status = EXIT_FAILURE; + break; + } + } n_bytes_read = nread; advance_input_offset (nread); if (n_bytes_read < input_blocksize) - { - r_partial++; - partread = n_bytes_read; - if (conversions_mask & C_SYNC) - { - if (!(conversions_mask & C_NOERROR)) - /* If C_NOERROR, we zeroed the block before reading. */ - memset (ibuf + n_bytes_read, - (conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0', - input_blocksize - n_bytes_read); - n_bytes_read = input_blocksize; - } - } + { + r_partial++; + partread = n_bytes_read; + if (conversions_mask & C_SYNC) + { + if (!(conversions_mask & C_NOERROR)) + /* If C_NOERROR, we zeroed the block before reading. */ + memset (ibuf + n_bytes_read, + (conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0', + input_blocksize - n_bytes_read); + n_bytes_read = input_blocksize; + } + } else - { - r_full++; - partread = 0; - } + { + r_full++; + partread = 0; + } if (ibuf == obuf) /* If not C_TWOBUFS. */ - { - size_t nwritten = iwrite (STDOUT_FILENO, obuf, n_bytes_read); - w_bytes += nwritten; - if (nwritten != n_bytes_read) - { - error (0, errno, _("writing %s"), quote (output_file)); - return EXIT_FAILURE; - } - else if (n_bytes_read == input_blocksize) - w_full++; - else - w_partial++; - continue; - } + { + size_t nwritten = iwrite (STDOUT_FILENO, obuf, n_bytes_read); + w_bytes += nwritten; + if (nwritten != n_bytes_read) + { + error (0, errno, _("writing %s"), quote (output_file)); + return EXIT_FAILURE; + } + else if (n_bytes_read == input_blocksize) + w_full++; + else + w_partial++; + continue; + } /* Do any translations on the whole buffer at once. */ if (translation_needed) - translate_buffer (ibuf, n_bytes_read); + translate_buffer (ibuf, n_bytes_read); if (conversions_mask & C_SWAB) - bufstart = swab_buffer (ibuf, &n_bytes_read); + bufstart = swab_buffer (ibuf, &n_bytes_read); else - bufstart = ibuf; + bufstart = ibuf; if (conversions_mask & C_BLOCK) copy_with_block (bufstart, n_bytes_read); else if (conversions_mask & C_UNBLOCK) - copy_with_unblock (bufstart, n_bytes_read); + copy_with_unblock (bufstart, n_bytes_read); else - copy_simple (bufstart, n_bytes_read); + copy_simple (bufstart, n_bytes_read); } /* If we have a char left as a result of conv=swab, output it. */ @@ -1767,24 +1771,25 @@ dd_copy (void) if (conversions_mask & C_BLOCK) copy_with_block (&saved_char, 1); else if (conversions_mask & C_UNBLOCK) - copy_with_unblock (&saved_char, 1); + copy_with_unblock (&saved_char, 1); else - output_char (saved_char); + output_char (saved_char); } if ((conversions_mask & C_BLOCK) && col > 0) { /* If the final input line didn't end with a '\n', pad - the output block to `conversion_blocksize' chars. */ + the output block to `conversion_blocksize' chars. */ size_t i; for (i = col; i < conversion_blocksize; i++) - output_char (space_character); + output_char (space_character); } - if ((conversions_mask & C_UNBLOCK) && col == conversion_blocksize) - /* Add a final '\n' if there are exactly `conversion_blocksize' - characters in the final record. */ - output_char (newline_character); + if (col && (conversions_mask & C_UNBLOCK)) + { + /* If there was any output, add a final '\n'. */ + output_char (newline_character); + } /* Write out the last block. */ if (oc != 0) @@ -1792,31 +1797,31 @@ dd_copy (void) size_t nwritten = iwrite (STDOUT_FILENO, obuf, oc); w_bytes += nwritten; if (nwritten != 0) - w_partial++; + w_partial++; if (nwritten != oc) - { - error (0, errno, _("writing %s"), quote (output_file)); - return EXIT_FAILURE; - } + { + error (0, errno, _("writing %s"), quote (output_file)); + return EXIT_FAILURE; + } } if ((conversions_mask & C_FDATASYNC) && fdatasync (STDOUT_FILENO) != 0) { if (errno != ENOSYS && errno != EINVAL) - { - error (0, errno, _("fdatasync failed for %s"), quote (output_file)); - exit_status = EXIT_FAILURE; - } + { + error (0, errno, _("fdatasync failed for %s"), quote (output_file)); + exit_status = EXIT_FAILURE; + } conversions_mask |= C_FSYNC; } if (conversions_mask & C_FSYNC) while (fsync (STDOUT_FILENO) != 0) if (errno != EINTR) - { - error (0, errno, _("fsync failed for %s"), quote (output_file)); - return EXIT_FAILURE; - } + { + error (0, errno, _("fsync failed for %s"), quote (output_file)); + return EXIT_FAILURE; + } return exit_status; } @@ -1842,7 +1847,7 @@ main (int argc, char **argv) page_size = getpagesize (); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); close_stdout_required = false; if (getopt_long (argc, argv, "", NULL, NULL) != -1) @@ -1865,7 +1870,7 @@ main (int argc, char **argv) else { if (fd_reopen (STDIN_FILENO, input_file, O_RDONLY | input_flags, 0) < 0) - error (EXIT_FAILURE, errno, _("opening %s"), quote (input_file)); + error (EXIT_FAILURE, errno, _("opening %s"), quote (input_file)); } offset = lseek (STDIN_FILENO, 0, SEEK_CUR); @@ -1882,52 +1887,52 @@ main (int argc, char **argv) { mode_t perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; int opts - = (output_flags - | (conversions_mask & C_NOCREAT ? 0 : O_CREAT) - | (conversions_mask & C_EXCL ? O_EXCL : 0) - | (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC)); + = (output_flags + | (conversions_mask & C_NOCREAT ? 0 : O_CREAT) + | (conversions_mask & C_EXCL ? O_EXCL : 0) + | (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC)); /* Open the output file with *read* access only if we might - need to read to satisfy a `seek=' request. If we can't read - the file, go ahead with write-only access; it might work. */ + need to read to satisfy a `seek=' request. If we can't read + the file, go ahead with write-only access; it might work. */ if ((! seek_records - || fd_reopen (STDOUT_FILENO, output_file, O_RDWR | opts, perms) < 0) - && (fd_reopen (STDOUT_FILENO, output_file, O_WRONLY | opts, perms) - < 0)) - error (EXIT_FAILURE, errno, _("opening %s"), quote (output_file)); + || fd_reopen (STDOUT_FILENO, output_file, O_RDWR | opts, perms) < 0) + && (fd_reopen (STDOUT_FILENO, output_file, O_WRONLY | opts, perms) + < 0)) + error (EXIT_FAILURE, errno, _("opening %s"), quote (output_file)); if (seek_records != 0 && !(conversions_mask & C_NOTRUNC)) - { - uintmax_t size = seek_records * output_blocksize; - unsigned long int obs = output_blocksize; + { + uintmax_t size = seek_records * output_blocksize; + unsigned long int obs = output_blocksize; - if (OFF_T_MAX / output_blocksize < seek_records) - error (EXIT_FAILURE, 0, - _("offset too large: " - "cannot truncate to a length of seek=%"PRIuMAX"" - " (%lu-byte) blocks"), - seek_records, obs); + if (OFF_T_MAX / output_blocksize < seek_records) + error (EXIT_FAILURE, 0, + _("offset too large: " + "cannot truncate to a length of seek=%"PRIuMAX"" + " (%lu-byte) blocks"), + seek_records, obs); - if (ftruncate (STDOUT_FILENO, size) != 0) - { - /* Complain only when ftruncate fails on a regular file, a - directory, or a shared memory object, as POSIX 1003.1-2004 - specifies ftruncate's behavior only for these file types. - For example, do not complain when Linux kernel 2.4 ftruncate - fails on /dev/fd0. */ - int ftruncate_errno = errno; - struct stat stdout_stat; - if (fstat (STDOUT_FILENO, &stdout_stat) != 0) - error (EXIT_FAILURE, errno, _("cannot fstat %s"), - quote (output_file)); - if (S_ISREG (stdout_stat.st_mode) - || S_ISDIR (stdout_stat.st_mode) - || S_TYPEISSHM (&stdout_stat)) - error (EXIT_FAILURE, ftruncate_errno, + if (ftruncate (STDOUT_FILENO, size) != 0) + { + /* Complain only when ftruncate fails on a regular file, a + directory, or a shared memory object, as POSIX 1003.1-2004 + specifies ftruncate's behavior only for these file types. + For example, do not complain when Linux kernel 2.4 ftruncate + fails on /dev/fd0. */ + int ftruncate_errno = errno; + struct stat stdout_stat; + if (fstat (STDOUT_FILENO, &stdout_stat) != 0) + error (EXIT_FAILURE, errno, _("cannot fstat %s"), + quote (output_file)); + if (S_ISREG (stdout_stat.st_mode) + || S_ISDIR (stdout_stat.st_mode) + || S_TYPEISSHM (&stdout_stat)) + error (EXIT_FAILURE, ftruncate_errno, _("failed to truncate to %"PRIuMAX" bytes in output file %s"), - size, quote (output_file)); - } - } + size, quote (output_file)); + } + } } start_time = gethrxtime (); diff --git a/src/bin/coreutils/src/df.c b/src/bin/coreutils/src/df.c index 070980e252..6cda35e75c 100644 --- a/src/bin/coreutils/src/df.c +++ b/src/bin/coreutils/src/df.c @@ -158,22 +158,22 @@ print_header (void) else if (human_output_opts & human_autoscale) { if (human_output_opts & human_base_1024) - printf (_(" Size Used Avail Use%%")); + printf (_(" Size Used Avail Use%%")); else - printf (_(" Size Used Avail Use%%")); + printf (_(" Size Used Avail Use%%")); } else if (posix_format) printf (_(" %s-blocks Used Available Capacity"), - umaxtostr (output_block_size, buf)); + umaxtostr (output_block_size, buf)); else { int opts = (human_suppress_point_zero - | human_autoscale | human_SI - | (human_output_opts - & (human_group_digits | human_base_1024 | human_B))); + | human_autoscale | human_SI + | (human_output_opts + & (human_group_digits | human_base_1024 | human_B))); /* Prefer the base that makes the human-readable value more exact, - if there is a difference. */ + if there is a difference. */ uintmax_t q1000 = output_block_size; uintmax_t q1024 = output_block_size; @@ -181,21 +181,21 @@ print_header (void) bool divisible_by_1024; do - { - divisible_by_1000 = q1000 % 1000 == 0; q1000 /= 1000; - divisible_by_1024 = q1024 % 1024 == 0; q1024 /= 1024; - } + { + divisible_by_1000 = q1000 % 1000 == 0; q1000 /= 1000; + divisible_by_1024 = q1024 % 1024 == 0; q1024 /= 1024; + } while (divisible_by_1000 & divisible_by_1024); if (divisible_by_1000 < divisible_by_1024) - opts |= human_base_1024; + opts |= human_base_1024; if (divisible_by_1024 < divisible_by_1000) - opts &= ~human_base_1024; + opts &= ~human_base_1024; if (! (opts & human_base_1024)) - opts |= human_B; + opts |= human_B; printf (_(" %4s-blocks Used Available Use%%"), - human_readable (output_block_size, buf, opts, 1, 1)); + human_readable (output_block_size, buf, opts, 1, 1)); } printf (_(" Mounted on\n")); @@ -250,16 +250,16 @@ known_value (uintmax_t n) static char const * df_readable (bool negative, uintmax_t n, char *buf, - uintmax_t input_units, uintmax_t output_units) + uintmax_t input_units, uintmax_t output_units) { if (! known_value (n) && !negative) return "-"; else { char *p = human_readable (negative ? -n : n, buf + negative, - human_output_opts, input_units, output_units); + human_output_opts, input_units, output_units); if (negative) - *--p = '-'; + *--p = '-'; return p; } } @@ -273,7 +273,7 @@ df_readable (bool negative, uintmax_t n, char *buf, how the negation flag is used. */ static void add_uint_with_neg_flag (uintmax_t *dest, bool *dest_neg, - uintmax_t src, bool src_neg) + uintmax_t src, bool src_neg) { if (LOG_EQ (*dest_neg, src_neg)) { @@ -314,9 +314,9 @@ add_uint_with_neg_flag (uintmax_t *dest, bool *dest_neg, static void show_dev (char const *disk, char const *mount_point, - char const *stat_file, char const *fstype, - bool me_dummy, bool me_remote, - const struct fs_usage *force_fsu) + char const *stat_file, char const *fstype, + bool me_dummy, bool me_remote, + const struct fs_usage *force_fsu) { struct fs_usage fsu; char buf[3][LONGEST_HUMAN_READABLE + 2]; @@ -379,18 +379,18 @@ show_dev (char const *disk, char const *mount_point, size_t disk_name_len = strlen (disk); size_t fstype_len = strlen (fstype); if (disk_name_len + fstype_len < 18) - printf ("%s%*s ", disk, 18 - (int) disk_name_len, fstype); + printf ("%s%*s ", disk, 18 - (int) disk_name_len, fstype); else if (!posix_format) - printf ("%s\n%18s ", disk, fstype); + printf ("%s\n%18s ", disk, fstype); else - printf ("%s %s", disk, fstype); + printf ("%s %s", disk, fstype); } else { if (strlen (disk) > 20 && !posix_format) - printf ("%s\n%20s", disk, ""); + printf ("%s\n%20s", disk, ""); else - printf ("%-20s", disk); + printf ("%-20s", disk); } if (inode_format) @@ -404,44 +404,44 @@ show_dev (char const *disk, char const *mount_point, available_to_root = available; if (known_value (total)) - grand_fsu.fsu_files += total; + grand_fsu.fsu_files += total; if (known_value (available)) - grand_fsu.fsu_ffree += available; + grand_fsu.fsu_ffree += available; } else { if (human_output_opts & human_autoscale) - width = 5 + ! (human_output_opts & human_base_1024); + width = 5 + ! (human_output_opts & human_base_1024); else - { - width = 9; - if (posix_format) - { - uintmax_t b; - col1_adjustment = -3; - for (b = output_block_size; 9 < b; b /= 10) - col1_adjustment++; - } - } + { + width = 9; + if (posix_format) + { + uintmax_t b; + col1_adjustment = -3; + for (b = output_block_size; 9 < b; b /= 10) + col1_adjustment++; + } + } use_width = ((posix_format - && ! (human_output_opts & human_autoscale)) - ? 8 : 4); + && ! (human_output_opts & human_autoscale)) + ? 8 : 4); input_units = fsu.fsu_blocksize; output_units = output_block_size; total = fsu.fsu_blocks; available = fsu.fsu_bavail; negate_available = (fsu.fsu_bavail_top_bit_set - & known_value (available)); + & known_value (available)); available_to_root = fsu.fsu_bfree; if (known_value (total)) - grand_fsu.fsu_blocks += input_units * total; + grand_fsu.fsu_blocks += input_units * total; if (known_value (available_to_root)) - grand_fsu.fsu_bfree += input_units * available_to_root; + grand_fsu.fsu_bfree += input_units * available_to_root; if (known_value (available)) - add_uint_with_neg_flag (&grand_fsu.fsu_bavail, - &grand_fsu.fsu_bavail_top_bit_set, - input_units * available, negate_available); + add_uint_with_neg_flag (&grand_fsu.fsu_bavail, + &grand_fsu.fsu_bavail_top_bit_set, + input_units * available, negate_available); } used = UINTMAX_MAX; @@ -453,20 +453,20 @@ show_dev (char const *disk, char const *mount_point, } printf (" %*s %*s %*s ", - width + col1_adjustment, - df_readable (false, total, - buf[0], input_units, output_units), - width, df_readable (negate_used, used, - buf[1], input_units, output_units), - width, df_readable (negate_available, available, - buf[2], input_units, output_units)); + width + col1_adjustment, + df_readable (false, total, + buf[0], input_units, output_units), + width, df_readable (negate_used, used, + buf[1], input_units, output_units), + width, df_readable (negate_available, available, + buf[2], input_units, output_units)); if (! known_value (used) || ! known_value (available)) ; else if (!negate_used - && used <= TYPE_MAXIMUM (uintmax_t) / 100 - && used + available != 0 - && (used + available < used) == negate_available) + && used <= TYPE_MAXIMUM (uintmax_t) / 100 + && used + available != 0 + && (used + available < used) == negate_available) { uintmax_t u100 = used * 100; uintmax_t nonroot_total = used + available; @@ -475,23 +475,23 @@ show_dev (char const *disk, char const *mount_point, else { /* The calculation cannot be done easily with integer - arithmetic. Fall back on floating point. This can suffer - from minor rounding errors, but doing it exactly requires - multiple precision arithmetic, and it's not worth the - aggravation. */ + arithmetic. Fall back on floating point. This can suffer + from minor rounding errors, but doing it exactly requires + multiple precision arithmetic, and it's not worth the + aggravation. */ double u = negate_used ? - (double) - used : used; double a = negate_available ? - (double) - available : available; double nonroot_total = u + a; if (nonroot_total) - { - long int lipct = pct = u * 100 / nonroot_total; - double ipct = lipct; + { + long int lipct = pct = u * 100 / nonroot_total; + double ipct = lipct; - /* Like `pct = ceil (dpct);', but avoid ceil so that - the math library needn't be linked. */ - if (ipct - 1 < pct && pct <= ipct + 1) - pct = ipct + (ipct < pct); - } + /* Like `pct = ceil (dpct);', but avoid ceil so that + the math library needn't be linked. */ + if (ipct - 1 < pct && pct <= ipct + 1) + pct = ipct + (ipct < pct); + } } if (0 <= pct) @@ -503,12 +503,12 @@ show_dev (char const *disk, char const *mount_point, { #ifdef HIDE_AUTOMOUNT_PREFIX /* Don't print the first directory name in MOUNT_POINT if it's an - artifact of an automounter. This is a bit too aggressive to be - the default. */ + artifact of an automounter. This is a bit too aggressive to be + the default. */ if (strncmp ("/auto/", mount_point, 6) == 0) - mount_point += 5; + mount_point += 5; else if (strncmp ("/tmp_mnt/", mount_point, 9) == 0) - mount_point += 8; + mount_point += 8; #endif printf (" %s", mount_point); } @@ -537,10 +537,10 @@ find_mount_point (const char *file, const struct stat *file_stat) { last_stat = *file_stat; if (chdir (file) < 0) - { - error (0, errno, _("cannot change to directory %s"), quote (file)); - return NULL; - } + { + error (0, errno, _("cannot change to directory %s"), quote (file)); + return NULL; + } } else /* FILE is some other kind of file; use its directory. */ @@ -551,17 +551,17 @@ find_mount_point (const char *file, const struct stat *file_stat) free (xdir); if (chdir (dir) < 0) - { - error (0, errno, _("cannot change to directory %s"), quote (dir)); - return NULL; - } + { + 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; - } + { + 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 /, @@ -571,18 +571,18 @@ find_mount_point (const char *file, const struct stat *file_stat) { struct stat st; if (stat ("..", &st) < 0) - { - error (0, errno, _("cannot stat %s"), quote ("..")); - goto done; - } + { + 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; + /* cwd is the mount point. */ + break; if (chdir ("..") < 0) - { - error (0, errno, _("cannot change to directory %s"), quote ("..")); - goto done; - } + { + error (0, errno, _("cannot change to directory %s"), quote ("..")); + goto done; + } last_stat = st; } @@ -595,7 +595,7 @@ done: int save_errno = errno; if (restore_cwd (&cwd) != 0) error (EXIT_FAILURE, errno, - _("failed to return to initial working directory")); + _("failed to return to initial working directory")); free_cwd (&cwd); errno = save_errno; } @@ -618,8 +618,8 @@ show_disk (char const *disk) if (best_match) { show_dev (best_match->me_devname, best_match->me_mountdir, NULL, - best_match->me_type, best_match->me_dummy, - best_match->me_remote, NULL); + best_match->me_type, best_match->me_dummy, + best_match->me_remote, NULL); return true; } @@ -641,12 +641,12 @@ show_point (const char *point, const struct stat *statp) if (*point == '/') { /* Find the best match: prefer non-dummies, and then prefer the - last match if there are ties. */ + 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; + 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 @@ -657,87 +657,87 @@ show_point (const char *point, const struct stat *statp) char *resolved = canonicalize_file_name (point); if (resolved && resolved[0] == '/') - { - size_t resolved_len = strlen (resolved); - size_t best_match_len = 0; + { + 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; - } - } - } + 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; + } + } + } free (resolved); if (best_match - && (stat (best_match->me_mountdir, &disk_stats) != 0 - || disk_stats.st_dev != statp->st_dev)) - best_match = NULL; + && (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) { - if (me->me_dev == (dev_t) -1) - { - if (stat (me->me_mountdir, &disk_stats) == 0) - me->me_dev = disk_stats.st_dev; - else - { - /* Report only I/O errors. Other errors might be - caused by shadowed mount points, which means POINT - can't possibly be on this file system. */ - if (errno == EIO) - { - error (0, errno, "%s", quote (me->me_mountdir)); - exit_status = EXIT_FAILURE; - } + if (me->me_dev == (dev_t) -1) + { + if (stat (me->me_mountdir, &disk_stats) == 0) + me->me_dev = disk_stats.st_dev; + else + { + /* Report only I/O errors. Other errors might be + caused by shadowed mount points, which means POINT + can't possibly be on this file system. */ + if (errno == EIO) + { + error (0, errno, "%s", quote (me->me_mountdir)); + exit_status = EXIT_FAILURE; + } - /* So we won't try and fail repeatedly. */ - me->me_dev = (dev_t) -2; - } - } + /* So we won't try and fail repeatedly. */ + me->me_dev = (dev_t) -2; + } + } - if (statp->st_dev == me->me_dev - && !STREQ (me->me_type, "lofs") - && (!best_match || best_match->me_dummy || !me->me_dummy)) - { - /* Skip bogus mtab entries. */ - if (stat (me->me_mountdir, &disk_stats) != 0 - || disk_stats.st_dev != me->me_dev) - me->me_dev = (dev_t) -2; - else - best_match = me; - } + if (statp->st_dev == me->me_dev + && !STREQ (me->me_type, "lofs") + && (!best_match || best_match->me_dummy || !me->me_dummy)) + { + /* Skip bogus mtab entries. */ + if (stat (me->me_mountdir, &disk_stats) != 0 + || disk_stats.st_dev != me->me_dev) + me->me_dev = (dev_t) -2; + else + best_match = me; + } } if (best_match) show_dev (best_match->me_devname, best_match->me_mountdir, point, - best_match->me_type, best_match->me_dummy, best_match->me_remote, - NULL); + best_match->me_type, best_match->me_dummy, best_match->me_remote, + NULL); else { /* We couldn't find the mount entry corresponding to POINT. Go ahead and - print as much info as we can; methods that require the device to be - present will fail at a later point. */ + print as much info as we can; methods that require the device to be + present will fail at a later point. */ /* Find the actual mount point. */ char *mp = find_mount_point (point, statp); if (mp) - { - show_dev (NULL, mp, NULL, NULL, false, false, NULL); - free (mp); - } + { + show_dev (NULL, mp, NULL, NULL, false, false, NULL); + free (mp); + } } } @@ -764,7 +764,7 @@ show_all_entries (void) for (me = mount_list; me; me = me->me_next) show_dev (me->me_devname, me->me_mountdir, NULL, me->me_type, - me->me_dummy, me->me_remote, NULL); + me->me_dummy, me->me_remote, NULL); } /* Add FSTYPE to the list of file system types to display. */ @@ -798,7 +798,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name); @@ -833,10 +833,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - fputs (_("\n\ -SIZE may be (or may be an integer optionally followed by) one of following:\n\ -kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\ -"), stdout); + emit_blocksize_note ("DF"); + emit_size_note (); emit_bug_reporting_address (); } exit (status); @@ -872,93 +870,93 @@ main (int argc, char **argv) { int oi = -1; int c = getopt_long (argc, argv, "aB:iF:hHklmPTt:vx:", long_options, - &oi); + &oi); if (c == -1) - break; + break; switch (c) - { - case 'a': - show_all_fs = true; - break; - case 'B': - { - enum strtol_error e = human_options (optarg, &human_output_opts, - &output_block_size); - if (e != LONGINT_OK) - xstrtol_fatal (e, oi, c, long_options, optarg); - } - break; - case 'i': - inode_format = true; - break; - case 'h': - human_output_opts = human_autoscale | human_SI | human_base_1024; - output_block_size = 1; - break; - case 'H': - human_output_opts = human_autoscale | human_SI; - output_block_size = 1; - break; - case 'k': - human_output_opts = 0; - output_block_size = 1024; - break; - case 'l': - show_local_fs = true; - break; - case 'm': /* obsolescent */ - human_output_opts = 0; - output_block_size = 1024 * 1024; - break; - case 'T': - print_type = true; - break; - case 'P': - posix_format = true; - break; - case SYNC_OPTION: - require_sync = true; - break; - case NO_SYNC_OPTION: - require_sync = false; - break; + { + case 'a': + show_all_fs = true; + break; + case 'B': + { + enum strtol_error e = human_options (optarg, &human_output_opts, + &output_block_size); + if (e != LONGINT_OK) + xstrtol_fatal (e, oi, c, long_options, optarg); + } + break; + case 'i': + inode_format = true; + break; + case 'h': + human_output_opts = human_autoscale | human_SI | human_base_1024; + output_block_size = 1; + break; + case 'H': + human_output_opts = human_autoscale | human_SI; + output_block_size = 1; + break; + case 'k': + human_output_opts = 0; + output_block_size = 1024; + break; + case 'l': + show_local_fs = true; + break; + case 'm': /* obsolescent */ + human_output_opts = 0; + output_block_size = 1024 * 1024; + break; + case 'T': + print_type = true; + break; + case 'P': + posix_format = true; + break; + case SYNC_OPTION: + require_sync = true; + break; + case NO_SYNC_OPTION: + require_sync = false; + break; - case 'F': - /* Accept -F as a synonym for -t for compatibility with Solaris. */ - case 't': - add_fs_type (optarg); - break; + case 'F': + /* Accept -F as a synonym for -t for compatibility with Solaris. */ + case 't': + add_fs_type (optarg); + break; - case 'v': /* For SysV compatibility. */ - /* ignore */ - break; - case 'x': - add_excluded_fs_type (optarg); - break; + case 'v': /* For SysV compatibility. */ + /* ignore */ + break; + case 'x': + add_excluded_fs_type (optarg); + break; - case 'c': - print_grand_total = true; - break; + case 'c': + print_grand_total = true; + break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + default: + usage (EXIT_FAILURE); + } } if (human_output_opts == -1) { if (posix_format) - { - human_output_opts = 0; - output_block_size = (getenv ("POSIXLY_CORRECT") ? 512 : 1024); - } + { + human_output_opts = 0; + output_block_size = (getenv ("POSIXLY_CORRECT") ? 512 : 1024); + } else - human_options (getenv ("DF_BLOCK_SIZE"), - &human_output_opts, &output_block_size); + human_options (getenv ("DF_BLOCK_SIZE"), + &human_output_opts, &output_block_size); } /* Fail if the same file system type was both selected and excluded. */ @@ -967,18 +965,18 @@ main (int argc, char **argv) struct fs_type_list *fs_incl; for (fs_incl = fs_select_list; fs_incl; fs_incl = fs_incl->fs_next) { - struct fs_type_list *fs_excl; - for (fs_excl = fs_exclude_list; fs_excl; fs_excl = fs_excl->fs_next) - { - if (STREQ (fs_incl->fs_name, fs_excl->fs_name)) - { - error (0, 0, - _("file system type %s both selected and excluded"), - quote (fs_incl->fs_name)); - match = true; - break; - } - } + struct fs_type_list *fs_excl; + for (fs_excl = fs_exclude_list; fs_excl; fs_excl = fs_excl->fs_next) + { + if (STREQ (fs_incl->fs_name, fs_excl->fs_name)) + { + error (0, 0, + _("file system type %s both selected and excluded"), + quote (fs_incl->fs_name)); + match = true; + break; + } + } } if (match) exit (EXIT_FAILURE); @@ -989,38 +987,41 @@ main (int argc, char **argv) int i; /* Open each of the given entries to make sure any corresponding - partition is automounted. This must be done before reading the - file system table. */ + partition is automounted. This must be done before reading the + file system table. */ stats = xnmalloc (argc - optind, sizeof *stats); for (i = optind; i < argc; ++i) - { - int fd = open (argv[i], O_RDONLY | O_NOCTTY); - if (fd < 0 || fstat (fd, &stats[i - optind])) - { - error (0, errno, "%s", quote (argv[i])); - exit_status = EXIT_FAILURE; - argv[i] = NULL; - } - if (0 <= fd) - close (fd); - } + { + /* Prefer to open with O_NOCTTY and use fstat, but fall back + on using "stat", in case the file is unreadable. */ + int fd = open (argv[i], O_RDONLY | O_NOCTTY); + if ((fd < 0 || fstat (fd, &stats[i - optind])) + && stat (argv[i], &stats[i - optind])) + { + error (0, errno, "%s", quote (argv[i])); + exit_status = EXIT_FAILURE; + argv[i] = NULL; + } + if (0 <= fd) + close (fd); + } } mount_list = read_file_system_list ((fs_select_list != NULL - || fs_exclude_list != NULL - || print_type - || show_local_fs)); + || fs_exclude_list != NULL + || print_type + || show_local_fs)); if (mount_list == NULL) { /* Couldn't read the table of mounted file systems. - Fail if df was invoked with no file name arguments; - Otherwise, merely give a warning and proceed. */ + Fail if df was invoked with no file name arguments; + Otherwise, merely give a warning and proceed. */ int status = (optind < argc ? 0 : EXIT_FAILURE); const char *warning = (optind < argc ? _("Warning: ") : ""); error (status, errno, "%s%s", warning, - _("cannot read table of mounted file systems")); + _("cannot read table of mounted file systems")); } if (require_sync) @@ -1034,8 +1035,8 @@ main (int argc, char **argv) show_listed_fs = true; for (i = optind; i < argc; ++i) - if (argv[i]) - show_entry (argv[i], &stats[i - optind]); + if (argv[i]) + show_entry (argv[i], &stats[i - optind]); } else show_all_entries (); @@ -1043,7 +1044,7 @@ main (int argc, char **argv) if (print_grand_total) { if (inode_format) - grand_fsu.fsu_blocks = 1; + grand_fsu.fsu_blocks = 1; show_dev ("total", NULL, NULL, NULL, false, false, &grand_fsu); } diff --git a/src/bin/coreutils/src/dircolors.c b/src/bin/coreutils/src/dircolors.c index 39c8e64b74..b724155921 100644 --- a/src/bin/coreutils/src/dircolors.c +++ b/src/bin/coreutils/src/dircolors.c @@ -198,29 +198,29 @@ append_quoted (const char *str) while (*str != '\0') { switch (*str) - { - case '\'': - APPEND_CHAR ('\''); - APPEND_CHAR ('\\'); - APPEND_CHAR ('\''); - need_backslash = true; - break; + { + case '\'': + APPEND_CHAR ('\''); + APPEND_CHAR ('\\'); + APPEND_CHAR ('\''); + need_backslash = true; + break; - case '\\': - case '^': - need_backslash = !need_backslash; - break; + case '\\': + case '^': + need_backslash = !need_backslash; + break; - case ':': - case '=': - if (need_backslash) - APPEND_CHAR ('\\'); - /* Fall through */ + case ':': + case '=': + if (need_backslash) + APPEND_CHAR ('\\'); + /* Fall through */ - default: - need_backslash = true; - break; - } + default: + need_backslash = true; + break; + } APPEND_CHAR (*str); ++str; @@ -261,106 +261,106 @@ dc_parse_stream (FILE *fp, const char *filename) ++line_number; if (fp) - { - if (getline (&input_line, &input_line_size, fp) <= 0) - { - free (input_line); - break; - } - line = input_line; - } + { + if (getline (&input_line, &input_line_size, fp) <= 0) + { + free (input_line); + break; + } + line = input_line; + } else - { - if (next_G_line == G_line + sizeof G_line) - break; - line = next_G_line; - next_G_line += strlen (next_G_line) + 1; - } + { + if (next_G_line == G_line + sizeof G_line) + break; + line = next_G_line; + next_G_line += strlen (next_G_line) + 1; + } parse_line (line, &keywd, &arg); if (keywd == NULL) - continue; + continue; if (arg == NULL) - { - error (0, 0, _("%s:%lu: invalid line; missing second token"), - filename, (unsigned long int) line_number); - ok = false; - free (keywd); - continue; - } + { + error (0, 0, _("%s:%lu: invalid line; missing second token"), + filename, (unsigned long int) line_number); + ok = false; + free (keywd); + continue; + } unrecognized = false; if (c_strcasecmp (keywd, "TERM") == 0) - { - if (STREQ (arg, term)) - state = ST_TERMSURE; - else if (state != ST_TERMSURE) - state = ST_TERMNO; - } + { + if (STREQ (arg, term)) + state = ST_TERMSURE; + else if (state != ST_TERMSURE) + state = ST_TERMNO; + } else - { - if (state == ST_TERMSURE) - state = ST_TERMYES; /* Another TERM can cancel */ + { + if (state == ST_TERMSURE) + state = ST_TERMYES; /* Another TERM can cancel */ - if (state != ST_TERMNO) - { - if (keywd[0] == '.') - { - APPEND_CHAR ('*'); - append_quoted (keywd); - APPEND_CHAR ('='); - append_quoted (arg); - APPEND_CHAR (':'); - } - else if (keywd[0] == '*') - { - append_quoted (keywd); - APPEND_CHAR ('='); - append_quoted (arg); - APPEND_CHAR (':'); - } - else if (c_strcasecmp (keywd, "OPTIONS") == 0 - || c_strcasecmp (keywd, "COLOR") == 0 - || c_strcasecmp (keywd, "EIGHTBIT") == 0) - { - /* Ignore. */ - } - else - { - int i; + if (state != ST_TERMNO) + { + if (keywd[0] == '.') + { + APPEND_CHAR ('*'); + append_quoted (keywd); + APPEND_CHAR ('='); + append_quoted (arg); + APPEND_CHAR (':'); + } + else if (keywd[0] == '*') + { + append_quoted (keywd); + APPEND_CHAR ('='); + append_quoted (arg); + APPEND_CHAR (':'); + } + else if (c_strcasecmp (keywd, "OPTIONS") == 0 + || c_strcasecmp (keywd, "COLOR") == 0 + || c_strcasecmp (keywd, "EIGHTBIT") == 0) + { + /* Ignore. */ + } + else + { + int i; - for (i = 0; slack_codes[i] != NULL; ++i) - if (c_strcasecmp (keywd, slack_codes[i]) == 0) - break; + for (i = 0; slack_codes[i] != NULL; ++i) + if (c_strcasecmp (keywd, slack_codes[i]) == 0) + break; - if (slack_codes[i] != NULL) - { - APPEND_TWO_CHAR_STRING (ls_codes[i]); - APPEND_CHAR ('='); - append_quoted (arg); - APPEND_CHAR (':'); - } - else - { - unrecognized = true; - } - } - } - else - { - unrecognized = true; - } - } + if (slack_codes[i] != NULL) + { + APPEND_TWO_CHAR_STRING (ls_codes[i]); + APPEND_CHAR ('='); + append_quoted (arg); + APPEND_CHAR (':'); + } + else + { + unrecognized = true; + } + } + } + else + { + unrecognized = true; + } + } if (unrecognized && (state == ST_TERMSURE || state == ST_TERMYES)) - { - error (0, 0, _("%s:%lu: unrecognized keyword %s"), - (filename ? quote (filename) : _("")), - (unsigned long int) line_number, keywd); - ok = false; - } + { + error (0, 0, _("%s:%lu: unrecognized keyword %s"), + (filename ? quote (filename) : _("")), + (unsigned long int) line_number, keywd); + ok = false; + } free (keywd); free (arg); @@ -411,23 +411,23 @@ main (int argc, char **argv) switch (optc) { case 'b': /* Bourne shell syntax. */ - syntax = SHELL_SYNTAX_BOURNE; - break; + syntax = SHELL_SYNTAX_BOURNE; + break; case 'c': /* C shell syntax. */ - syntax = SHELL_SYNTAX_C; - break; + syntax = SHELL_SYNTAX_C; + break; case 'p': - print_database = true; - break; + print_database = true; + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: - usage (EXIT_FAILURE); + usage (EXIT_FAILURE); } argc -= optind; @@ -438,7 +438,7 @@ main (int argc, char **argv) if (print_database && syntax != SHELL_SYNTAX_UNKNOWN) { error (0, 0, - _("the options to output dircolors' internal database and\n\ + _("the options to output dircolors' internal database and\n\ to select a shell syntax are mutually exclusive")); usage (EXIT_FAILURE); } @@ -447,9 +447,9 @@ to select a shell syntax are mutually exclusive")); { error (0, 0, _("extra operand %s"), quote (argv[!print_database])); if (print_database) - fprintf (stderr, "%s\n", - _("file operands cannot be combined with " - "--print-database (-p)")); + fprintf (stderr, "%s\n", + _("file operands cannot be combined with " + "--print-database (-p)")); usage (EXIT_FAILURE); } @@ -457,51 +457,51 @@ to select a shell syntax are mutually exclusive")); { char const *p = G_line; while (p < G_line + sizeof G_line) - { - puts (p); - p += strlen (p) + 1; - } + { + puts (p); + p += strlen (p) + 1; + } } else { /* If shell syntax was not explicitly specified, try to guess it. */ if (syntax == SHELL_SYNTAX_UNKNOWN) - { - syntax = guess_shell_syntax (); - if (syntax == SHELL_SYNTAX_UNKNOWN) - { - error (EXIT_FAILURE, 0, - _("no SHELL environment variable, and no shell type option given")); - } - } + { + syntax = guess_shell_syntax (); + if (syntax == SHELL_SYNTAX_UNKNOWN) + { + error (EXIT_FAILURE, 0, + _("no SHELL environment variable, and no shell type option given")); + } + } obstack_init (&lsc_obstack); if (argc == 0) - ok = dc_parse_stream (NULL, NULL); + ok = dc_parse_stream (NULL, NULL); else - ok = dc_parse_file (argv[0]); + ok = dc_parse_file (argv[0]); if (ok) - { - size_t len = obstack_object_size (&lsc_obstack); - char *s = obstack_finish (&lsc_obstack); - const char *prefix; - const char *suffix; + { + size_t len = obstack_object_size (&lsc_obstack); + char *s = obstack_finish (&lsc_obstack); + const char *prefix; + const char *suffix; - if (syntax == SHELL_SYNTAX_BOURNE) - { - prefix = "LS_COLORS='"; - suffix = "';\nexport LS_COLORS\n"; - } - else - { - prefix = "setenv LS_COLORS '"; - suffix = "'\n"; - } - fputs (prefix, stdout); - fwrite (s, 1, len, stdout); - fputs (suffix, stdout); - } + if (syntax == SHELL_SYNTAX_BOURNE) + { + prefix = "LS_COLORS='"; + suffix = "';\nexport LS_COLORS\n"; + } + else + { + prefix = "setenv LS_COLORS '"; + suffix = "'\n"; + } + fputs (prefix, stdout); + fwrite (s, 1, len, stdout); + fputs (suffix, stdout); + } } exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); diff --git a/src/bin/coreutils/src/dircolors.hin b/src/bin/coreutils/src/dircolors.hin index 30fd878560..91ddcb65a7 100644 --- a/src/bin/coreutils/src/dircolors.hin +++ b/src/bin/coreutils/src/dircolors.hin @@ -69,7 +69,7 @@ TERM xterm-debian RESET 0 # reset to "normal" color DIR 01;34 # directory LINK 01;36 # symbolic link. (If you set this to 'target' instead of a - # numerical value, the color is as for the file pointed to.) + # numerical value, the color is as for the file pointed to.) MULTIHARDLINK 00 # regular file with more than one link FIFO 40;33 # pipe SOCK 01;35 # socket diff --git a/src/bin/coreutils/src/dirname.c b/src/bin/coreutils/src/dirname.c index c0fc017177..53d0bdc7d9 100644 --- a/src/bin/coreutils/src/dirname.c +++ b/src/bin/coreutils/src/dirname.c @@ -39,14 +39,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s NAME\n\ or: %s OPTION\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Print NAME with its trailing /component removed; if NAME contains no /'s,\n\ output `.' (meaning the current directory).\n\ @@ -60,7 +60,7 @@ Examples:\n\ %s /usr/bin/sort Output \"/usr/bin\".\n\ %s stdio.h Output \".\".\n\ "), - program_name, program_name); + program_name, program_name); emit_bug_reporting_address (); } exit (status); @@ -82,7 +82,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "+", NULL, NULL) != -1) usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/du.c b/src/bin/coreutils/src/du.c index fd580311a6..0ffd147511 100644 --- a/src/bin/coreutils/src/du.c +++ b/src/bin/coreutils/src/du.c @@ -262,7 +262,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -330,10 +330,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - fputs (_("\n\ -SIZE may be (or may be an integer optionally followed by) one of following:\n\ -kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\ -"), stdout); + emit_blocksize_note ("DU"); + emit_size_note (); emit_bug_reporting_address (); } exit (status); @@ -396,7 +394,7 @@ static void hash_init (void) { htab = hash_initialize (INITIAL_TABLE_SIZE, NULL, - entry_hash, entry_compare, free); + entry_hash, entry_compare, free); if (htab == NULL) xalloc_die (); } @@ -427,7 +425,7 @@ print_only_size (uintmax_t n_bytes) { char buf[LONGEST_HUMAN_READABLE + 1]; fputs (human_readable (n_bytes, buf, human_output_opts, - 1, output_block_size), stdout); + 1, output_block_size), stdout); } /* Print size (and optionally time) indicated by *PDUI, followed by STRING. */ @@ -492,7 +490,7 @@ process_file (FTS *fts, FTSENT *ent) 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. */ + we were able to stat it, so we do have a size. */ error (0, ent->fts_errno, _("cannot read directory %s"), quote (file)); ok = false; break; @@ -512,25 +510,25 @@ process_file (FTS *fts, FTSENT *ent) 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))) + && ! 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. */ + 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))); + (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; @@ -544,44 +542,44 @@ process_file (FTS *fts, FTSENT *ent) else { if (level == prev_level) - { - /* This is usually the most common case. Do nothing. */ - } + { + /* This is usually the most common case. Do nothing. */ + } else if (level > prev_level) - { - /* Descending the hierarchy. - Clear the accumulators for *all* levels between prev_level - and the current one. The depth may change dramatically, - e.g., from 1 to 10. */ - size_t i; + { + /* Descending the hierarchy. + Clear the accumulators for *all* levels between prev_level + and the current one. The depth may change dramatically, + e.g., from 1 to 10. */ + size_t i; - if (n_alloc <= level) - { - dulvl = xnrealloc (dulvl, level, 2 * sizeof *dulvl); - n_alloc = level * 2; - } + if (n_alloc <= level) + { + dulvl = xnrealloc (dulvl, level, 2 * sizeof *dulvl); + n_alloc = level * 2; + } - for (i = prev_level + 1; i <= level; i++) - { - duinfo_init (&dulvl[i].ent); - duinfo_init (&dulvl[i].subdir); - } - } + for (i = prev_level + 1; i <= level; i++) + { + duinfo_init (&dulvl[i].ent); + duinfo_init (&dulvl[i].subdir); + } + } else /* level < prev_level */ - { - /* Ascending the hierarchy. - Process a directory only after all entries in that - directory have been processed. When the depth decreases, - propagate sums from the children (prev_level) to the parent. - Here, the current level is always one smaller than the - previous one. */ - assert (level == prev_level - 1); - duinfo_add (&dui_to_print, &dulvl[prev_level].ent); - if (!opt_separate_dirs) - duinfo_add (&dui_to_print, &dulvl[prev_level].subdir); - duinfo_add (&dulvl[level].subdir, &dulvl[prev_level].ent); - duinfo_add (&dulvl[level].subdir, &dulvl[prev_level].subdir); - } + { + /* Ascending the hierarchy. + Process a directory only after all entries in that + directory have been processed. When the depth decreases, + propagate sums from the children (prev_level) to the parent. + Here, the current level is always one smaller than the + previous one. */ + assert (level == prev_level - 1); + duinfo_add (&dui_to_print, &dulvl[prev_level].ent); + if (!opt_separate_dirs) + duinfo_add (&dui_to_print, &dulvl[prev_level].subdir); + duinfo_add (&dulvl[level].subdir, &dulvl[prev_level].ent); + duinfo_add (&dulvl[level].subdir, &dulvl[prev_level].subdir); + } } prev_level = level; @@ -623,29 +621,30 @@ du_files (char **files, int bit_flags) FTS *fts = xfts_open (files, bit_flags, NULL); while (1) - { - FTSENT *ent; + { + FTSENT *ent; - ent = fts_read (fts); - if (ent == NULL) - { - if (errno != 0) - { - /* FIXME: try to give a better message */ - error (0, errno, _("fts_read failed")); - ok = false; - } - break; - } - FTS_CROSS_CHECK (fts); + ent = fts_read (fts); + if (ent == NULL) + { + if (errno != 0) + { + /* FIXME: try to give a better message */ + error (0, errno, _("fts_read failed")); + ok = false; + } + break; + } + FTS_CROSS_CHECK (fts); - ok &= process_file (fts, ent); - } + ok &= process_file (fts, ent); + } - /* Ignore failure, since the only way it can do so is in failing to - return to the original directory, and since we're about to exit, - that doesn't matter. */ - fts_close (fts); + if (fts_close (fts) != 0) + { + error (0, errno, _("fts_close failed")); + ok = false; + } } return ok; @@ -685,162 +684,162 @@ main (int argc, char **argv) exclude = new_exclude (); human_options (getenv ("DU_BLOCK_SIZE"), - &human_output_opts, &output_block_size); + &human_output_opts, &output_block_size); for (;;) { int oi = -1; int c = getopt_long (argc, argv, DEBUG_OPT "0abchHklmsxB:DLPSX:", - long_options, &oi); + long_options, &oi); if (c == -1) - break; + break; switch (c) - { + { #if DU_DEBUG - case 'd': - fts_debug = true; - break; + case 'd': + fts_debug = true; + break; #endif - case '0': - opt_nul_terminate_output = true; - break; + case '0': + opt_nul_terminate_output = true; + break; - case 'a': - opt_all = true; - break; + case 'a': + opt_all = true; + break; - case APPARENT_SIZE_OPTION: - apparent_size = true; - break; + case APPARENT_SIZE_OPTION: + apparent_size = true; + break; - case 'b': - apparent_size = true; - human_output_opts = 0; - output_block_size = 1; - break; + case 'b': + apparent_size = true; + human_output_opts = 0; + output_block_size = 1; + break; - case 'c': - print_grand_total = true; - break; + case 'c': + print_grand_total = true; + break; - case 'h': - human_output_opts = human_autoscale | human_SI | human_base_1024; - output_block_size = 1; - break; + case 'h': + human_output_opts = human_autoscale | human_SI | human_base_1024; + output_block_size = 1; + break; - case HUMAN_SI_OPTION: - human_output_opts = human_autoscale | human_SI; - output_block_size = 1; - break; + case HUMAN_SI_OPTION: + human_output_opts = human_autoscale | human_SI; + output_block_size = 1; + break; - case 'k': - human_output_opts = 0; - output_block_size = 1024; - break; + case 'k': + human_output_opts = 0; + output_block_size = 1024; + break; - case MAX_DEPTH_OPTION: /* --max-depth=N */ - { - unsigned long int tmp_ulong; - if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK - && tmp_ulong <= SIZE_MAX) - { - max_depth_specified = true; - max_depth = tmp_ulong; - } - else - { - error (0, 0, _("invalid maximum depth %s"), - quote (optarg)); - ok = false; - } - } - break; + case MAX_DEPTH_OPTION: /* --max-depth=N */ + { + unsigned long int tmp_ulong; + if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK + && tmp_ulong <= SIZE_MAX) + { + max_depth_specified = true; + max_depth = tmp_ulong; + } + else + { + error (0, 0, _("invalid maximum depth %s"), + quote (optarg)); + ok = false; + } + } + break; - case MEGABYTES_LONG_OPTION: /* FIXME: remove in 2009 */ - error (0, 0, - _("the --megabytes option is deprecated; use -m instead")); - /* fall through */ - case 'm': - human_output_opts = 0; - output_block_size = 1024 * 1024; - break; + case MEGABYTES_LONG_OPTION: /* FIXME: remove in 2009 */ + error (0, 0, + _("the --megabytes option is deprecated; use -m instead")); + /* fall through */ + case 'm': + human_output_opts = 0; + output_block_size = 1024 * 1024; + break; - case 'l': - opt_count_all = true; - break; + case 'l': + opt_count_all = true; + break; - case 's': - opt_summarize_only = true; - break; + case 's': + opt_summarize_only = true; + break; - case 'x': - bit_flags |= FTS_XDEV; - break; + case 'x': + bit_flags |= FTS_XDEV; + break; - case 'B': - { - enum strtol_error e = human_options (optarg, &human_output_opts, - &output_block_size); - if (e != LONGINT_OK) - xstrtol_fatal (e, oi, c, long_options, optarg); - } - break; + case 'B': + { + enum strtol_error e = human_options (optarg, &human_output_opts, + &output_block_size); + if (e != LONGINT_OK) + xstrtol_fatal (e, oi, c, long_options, optarg); + } + break; - case 'H': /* NOTE: before 2008-12, -H was equivalent to --si. */ - case 'D': - symlink_deref_bits = FTS_COMFOLLOW | FTS_PHYSICAL; - break; + case 'H': /* NOTE: before 2008-12, -H was equivalent to --si. */ + case 'D': + symlink_deref_bits = FTS_COMFOLLOW | FTS_PHYSICAL; + break; - case 'L': /* --dereference */ - symlink_deref_bits = FTS_LOGICAL; - break; + case 'L': /* --dereference */ + symlink_deref_bits = FTS_LOGICAL; + break; - case 'P': /* --no-dereference */ - symlink_deref_bits = FTS_PHYSICAL; - break; + case 'P': /* --no-dereference */ + symlink_deref_bits = FTS_PHYSICAL; + break; - case 'S': - opt_separate_dirs = true; - break; + case 'S': + opt_separate_dirs = true; + break; - case 'X': - if (add_exclude_file (add_exclude, exclude, optarg, - EXCLUDE_WILDCARDS, '\n')) - { - error (0, errno, "%s", quotearg_colon (optarg)); - ok = false; - } - break; + case 'X': + if (add_exclude_file (add_exclude, exclude, optarg, + EXCLUDE_WILDCARDS, '\n')) + { + error (0, errno, "%s", quotearg_colon (optarg)); + ok = false; + } + break; - case FILES0_FROM_OPTION: - files_from = optarg; - break; + case FILES0_FROM_OPTION: + files_from = optarg; + break; - case EXCLUDE_OPTION: - add_exclude (exclude, optarg, EXCLUDE_WILDCARDS); - break; + case EXCLUDE_OPTION: + add_exclude (exclude, optarg, EXCLUDE_WILDCARDS); + break; - case TIME_OPTION: - opt_time = true; - time_type = - (optarg - ? XARGMATCH ("--time", optarg, time_args, time_types) - : time_mtime); - break; + case TIME_OPTION: + opt_time = true; + time_type = + (optarg + ? XARGMATCH ("--time", optarg, time_args, time_types) + : time_mtime); + break; - case TIME_STYLE_OPTION: - time_style = optarg; - break; + case TIME_STYLE_OPTION: + time_style = optarg; + break; - case_GETOPT_HELP_CHAR; + case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - ok = false; - } + default: + ok = false; + } } if (!ok) @@ -855,7 +854,7 @@ main (int argc, char **argv) if (opt_summarize_only && max_depth_specified && max_depth == 0) { error (0, 0, - _("warning: summarizing is the same as using --max-depth=0")); + _("warning: summarizing is the same as using --max-depth=0")); } if (opt_summarize_only && max_depth_specified && max_depth != 0) @@ -872,48 +871,48 @@ main (int argc, char **argv) if (opt_time) { if (! time_style) - { - time_style = getenv ("TIME_STYLE"); + { + time_style = getenv ("TIME_STYLE"); - /* Ignore TIMESTYLE="locale", for compatibility with ls. */ - if (! time_style || STREQ (time_style, "locale")) - time_style = "long-iso"; - else if (*time_style == '+') - { - /* Ignore anything after a newline, for compatibility - with ls. */ - char *p = strchr (time_style, '\n'); - if (p) - *p = '\0'; - } - else - { - /* Ignore "posix-" prefix, for compatibility with ls. */ - static char const posix_prefix[] = "posix-"; - while (strncmp (time_style, posix_prefix, sizeof posix_prefix - 1) - == 0) - time_style += sizeof posix_prefix - 1; - } - } + /* Ignore TIMESTYLE="locale", for compatibility with ls. */ + if (! time_style || STREQ (time_style, "locale")) + time_style = "long-iso"; + else if (*time_style == '+') + { + /* Ignore anything after a newline, for compatibility + with ls. */ + char *p = strchr (time_style, '\n'); + if (p) + *p = '\0'; + } + else + { + /* Ignore "posix-" prefix, for compatibility with ls. */ + static char const posix_prefix[] = "posix-"; + while (strncmp (time_style, posix_prefix, sizeof posix_prefix - 1) + == 0) + time_style += sizeof posix_prefix - 1; + } + } if (*time_style == '+') - time_format = time_style + 1; + time_format = time_style + 1; else { switch (XARGMATCH ("time style", time_style, time_style_args, time_style_types)) { - case full_iso_time_style: - time_format = "%Y-%m-%d %H:%M:%S.%N %z"; - break; + case full_iso_time_style: + time_format = "%Y-%m-%d %H:%M:%S.%N %z"; + break; - case long_iso_time_style: - time_format = "%Y-%m-%d %H:%M"; - break; + case long_iso_time_style: + time_format = "%Y-%m-%d %H:%M"; + break; - case iso_time_style: - time_format = "%Y-%m-%d"; - break; + case iso_time_style: + time_format = "%Y-%m-%d"; + break; } } } @@ -921,18 +920,18 @@ main (int argc, char **argv) if (files_from) { /* When using --files0-from=F, you may not specify any files - on the command-line. */ + on the command-line. */ if (optind < argc) - { - error (0, 0, _("extra operand %s"), quote (argv[optind])); - fprintf (stderr, "%s\n", - _("file operands cannot be combined with --files0-from")); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("extra operand %s"), quote (argv[optind])); + fprintf (stderr, "%s\n", + _("file operands cannot be combined with --files0-from")); + usage (EXIT_FAILURE); + } if (! (STREQ (files_from, "-") || freopen (files_from, "r", stdin))) - error (EXIT_FAILURE, errno, _("cannot open %s for reading"), - quote (files_from)); + error (EXIT_FAILURE, errno, _("cannot open %s for reading"), + quote (files_from)); ai = argv_iter_init_stream (stdin); } @@ -957,64 +956,63 @@ main (int argc, char **argv) enum argv_iter_err ai_err; char *file_name = argv_iter (ai, &ai_err); if (ai_err == AI_ERR_EOF) - break; + break; if (!file_name) - { - switch (ai_err) - { - case AI_ERR_READ: - error (0, errno, _("%s: read error"), quote (files_from)); - skip_file = true; - continue; + { + switch (ai_err) + { + case AI_ERR_READ: + error (0, errno, _("%s: read error"), quote (files_from)); + continue; - case AI_ERR_MEM: - xalloc_die (); + case AI_ERR_MEM: + xalloc_die (); - default: - assert (!"unexpected error code from argv_iter"); - } - } + default: + assert (!"unexpected error code from argv_iter"); + } + } if (files_from && STREQ (files_from, "-") && STREQ (file_name, "-")) - { - /* Give a better diagnostic in an unusual case: - printf - | du --files0-from=- */ - error (0, 0, _("when reading file names from stdin, " - "no file name of %s allowed"), - quote (file_name)); - skip_file = true; - } + { + /* Give a better diagnostic in an unusual case: + printf - | du --files0-from=- */ + error (0, 0, _("when reading file names from stdin, " + "no file name of %s allowed"), + quote (file_name)); + skip_file = true; + } /* Report and skip any empty file names before invoking fts. - This works around a glitch in fts, which fails immediately - (without looking at the other file names) when given an empty - file name. */ + This works around a glitch in fts, which fails immediately + (without looking at the other file names) when given an empty + file name. */ if (!file_name[0]) - { - /* Diagnose a zero-length file name. When it's one - among many, knowing the record number may help. - FIXME: currently print the record number only with - --files0-from=FILE. Maybe do it for argv, too? */ - if (files_from == NULL) - error (0, 0, "%s", _("invalid zero-length file name")); - else - { - /* Using the standard `filename:line-number:' prefix here is - not totally appropriate, since NUL is the separator, not NL, - but it might be better than nothing. */ - unsigned long int file_number = argv_iter_n_args (ai); - error (0, 0, "%s:%lu: %s", quotearg_colon (files_from), - file_number, _("invalid zero-length file name")); - } - skip_file = true; - } + { + /* Diagnose a zero-length file name. When it's one + among many, knowing the record number may help. + FIXME: currently print the record number only with + --files0-from=FILE. Maybe do it for argv, too? */ + if (files_from == NULL) + error (0, 0, "%s", _("invalid zero-length file name")); + else + { + /* Using the standard `filename:line-number:' prefix here is + not totally appropriate, since NUL is the separator, not NL, + but it might be better than nothing. */ + unsigned long int file_number = argv_iter_n_args (ai); + error (0, 0, "%s:%lu: %s", quotearg_colon (files_from), + file_number, _("invalid zero-length file name")); + } + skip_file = true; + } if (skip_file) - ok = false; + ok = false; else - { - temp_argv[0] = file_name; - ok &= du_files (temp_argv, bit_flags); - } + { + temp_argv[0] = file_name; + ok &= du_files (temp_argv, bit_flags); + } } argv_iter_free (ai); diff --git a/src/bin/coreutils/src/echo.c b/src/bin/coreutils/src/echo.c index 7b069e0e52..210352ca77 100644 --- a/src/bin/coreutils/src/echo.c +++ b/src/bin/coreutils/src/echo.c @@ -37,7 +37,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -50,13 +50,13 @@ Echo the STRING(s) to standard output.\n\ -n do not output the trailing newline\n\ "), stdout); fputs (_(DEFAULT_ECHO_TO_XPG - ? N_("\ + ? N_("\ -e enable interpretation of backslash escapes (default)\n\ -E disable interpretation of backslash escapes\n") - : N_("\ + : N_("\ -e enable interpretation of backslash escapes\n\ -E disable interpretation of backslash escapes (default)\n")), - stdout); + stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); fputs (_("\ @@ -128,14 +128,14 @@ main (int argc, char **argv) if (allow_options && argc == 2) { if (STREQ (argv[1], "--help")) - usage (EXIT_SUCCESS); + usage (EXIT_SUCCESS); if (STREQ (argv[1], "--version")) - { - version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, - (char *) NULL); - exit (EXIT_SUCCESS); - } + { + version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, + (char *) NULL); + exit (EXIT_SUCCESS); + } } --argc; @@ -144,45 +144,45 @@ main (int argc, char **argv) if (allow_options) while (argc > 0 && *argv[0] == '-') { - char const *temp = argv[0] + 1; - size_t i; + char const *temp = argv[0] + 1; + size_t i; - /* If it appears that we are handling options, then make sure that - all of the options specified are actually valid. Otherwise, the - string should just be echoed. */ + /* If it appears that we are handling options, then make sure that + all of the options specified are actually valid. Otherwise, the + string should just be echoed. */ - for (i = 0; temp[i]; i++) - switch (temp[i]) - { - case 'e': case 'E': case 'n': - break; - default: - goto just_echo; - } + for (i = 0; temp[i]; i++) + switch (temp[i]) + { + case 'e': case 'E': case 'n': + break; + default: + goto just_echo; + } - if (i == 0) - goto just_echo; + if (i == 0) + goto just_echo; - /* All of the options in TEMP are valid options to ECHO. - Handle them. */ - while (*temp) - switch (*temp++) - { - case 'e': - do_v9 = true; - break; + /* All of the options in TEMP are valid options to ECHO. + Handle them. */ + while (*temp) + switch (*temp++) + { + case 'e': + do_v9 = true; + break; - case 'E': - do_v9 = false; - break; + case 'E': + do_v9 = false; + break; - case 'n': - display_return = false; - break; - } + case 'n': + display_return = false; + break; + } - argc--; - argv++; + argc--; + argv++; } just_echo: @@ -190,77 +190,77 @@ just_echo: if (do_v9) { while (argc > 0) - { - char const *s = argv[0]; - unsigned char c; + { + char const *s = argv[0]; + unsigned char c; - while ((c = *s++)) - { - if (c == '\\' && *s) - { - switch (c = *s++) - { - case 'a': c = '\a'; break; - case 'b': c = '\b'; break; - case 'c': exit (EXIT_SUCCESS); - case 'f': c = '\f'; break; - case 'n': c = '\n'; break; - case 'r': c = '\r'; break; - case 't': c = '\t'; break; - case 'v': c = '\v'; break; - case 'x': - { - unsigned char ch = *s; - if (! isxdigit (ch)) - goto not_an_escape; - s++; - c = hextobin (ch); - ch = *s; - if (isxdigit (ch)) - { - s++; - c = c * 16 + hextobin (ch); - } - } - break; - case '0': - c = 0; - if (! ('0' <= *s && *s <= '7')) - break; - c = *s++; - /* Fall through. */ - case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - c -= '0'; - if ('0' <= *s && *s <= '7') - c = c * 8 + (*s++ - '0'); - if ('0' <= *s && *s <= '7') - c = c * 8 + (*s++ - '0'); - break; - case '\\': break; + while ((c = *s++)) + { + if (c == '\\' && *s) + { + switch (c = *s++) + { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'c': exit (EXIT_SUCCESS); + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case 'x': + { + unsigned char ch = *s; + if (! isxdigit (ch)) + goto not_an_escape; + s++; + c = hextobin (ch); + ch = *s; + if (isxdigit (ch)) + { + s++; + c = c * 16 + hextobin (ch); + } + } + break; + case '0': + c = 0; + if (! ('0' <= *s && *s <= '7')) + break; + c = *s++; + /* Fall through. */ + case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + c -= '0'; + if ('0' <= *s && *s <= '7') + c = c * 8 + (*s++ - '0'); + if ('0' <= *s && *s <= '7') + c = c * 8 + (*s++ - '0'); + break; + case '\\': break; - not_an_escape: - default: putchar ('\\'); break; - } - } - putchar (c); - } - argc--; - argv++; - if (argc > 0) - putchar (' '); - } + not_an_escape: + default: putchar ('\\'); break; + } + } + putchar (c); + } + argc--; + argv++; + if (argc > 0) + putchar (' '); + } } else { while (argc > 0) - { - fputs (argv[0], stdout); - argc--; - argv++; - if (argc > 0) - putchar (' '); - } + { + fputs (argv[0], stdout); + argc--; + argv++; + if (argc > 0) + putchar (' '); + } } if (display_return) diff --git a/src/bin/coreutils/src/env.c b/src/bin/coreutils/src/env.c index 89d1ea0a75..c22981ba3f 100644 --- a/src/bin/coreutils/src/env.c +++ b/src/bin/coreutils/src/env.c @@ -20,24 +20,24 @@ - -i --ignore-environment - Construct a new environment from scratch; normally the - environment is inherited from the parent process, except as - modified by other options. + Construct a new environment from scratch; normally the + environment is inherited from the parent process, except as + modified by other options. -u variable --unset=variable - Unset variable VARIABLE (remove it from the environment). - If VARIABLE was not set, does nothing. + Unset variable VARIABLE (remove it from the environment). + If VARIABLE was not set, does nothing. variable=value (an arg containing a "=" character) - Set the environment variable VARIABLE to value VALUE. VALUE - may be of zero length ("variable="). Setting a variable to a - zero-length value is different from unsetting it. + Set the environment variable VARIABLE to value VALUE. VALUE + may be of zero length ("variable="). Setting a variable to a + zero-length value is different from unsetting it. -- - Indicate that the following argument is the program - to invoke. This is necessary when the program's name - begins with "-" or contains a "=". + Indicate that the following argument is the program + to invoke. This is necessary when the program's name + begins with "-" or contains a "=". The first remaining argument specifies a program to invoke; it is searched for according to the specification of the PATH @@ -51,29 +51,29 @@ Examples: If the environment passed to "env" is - { LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks } + { LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks } env - foo - runs "foo" in a null environment. + runs "foo" in a null environment. env foo - runs "foo" in the environment - { LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks } + runs "foo" in the environment + { LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks } env DISPLAY=gnu:0 nemacs - runs "nemacs" in the environment - { LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks DISPLAY=gnu:0 } + runs "nemacs" in the environment + { LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks DISPLAY=gnu:0 } env - LOGNAME=foo /hacks/hack bar baz - runs the "hack" program on arguments "bar" and "baz" in an - environment in which the only variable is "LOGNAME". Note that - the "-" option clears out the PATH variable, so one should be - careful to specify in which directory to find the program to - call. + runs the "hack" program on arguments "bar" and "baz" in an + environment in which the only variable is "LOGNAME". Note that + the "-" option clears out the PATH variable, so one should be + careful to specify in which directory to find the program to + call. env -u EDITOR LOGNAME=foo PATH=/energy -- e=mc2 bar baz - runs the program "/energy/e=mc2" with environment - { LOGNAME=foo PATH=/energy } + runs the program "/energy/e=mc2" with environment + { LOGNAME=foo PATH=/energy } */ #include @@ -107,12 +107,12 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n"), - program_name); + program_name); fputs (_("\ Set each NAME to VALUE in the environment and run COMMAND.\n\ \n\ @@ -148,17 +148,17 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1) { switch (optc) - { - case 'i': - ignore_environment = true; - break; - case 'u': - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + { + case 'i': + ignore_environment = true; + break; + case 'u': + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (optind < argc && STREQ (argv[optind], "-")) @@ -186,7 +186,7 @@ main (int argc, char **argv) { char *const *e = environ; while (*e) - puts (*e++); + puts (*e++); exit (EXIT_SUCCESS); } diff --git a/src/bin/coreutils/src/expand.c b/src/bin/coreutils/src/expand.c index 10f36430d0..c8648335a3 100644 --- a/src/bin/coreutils/src/expand.c +++ b/src/bin/coreutils/src/expand.c @@ -23,10 +23,10 @@ --tabs=tab1[,tab2[,...]] -t tab1[,tab2[,...]] -tab1[,tab2[,...]] If only one tab stop is given, set the tabs tab1 - columns apart instead of the default 8. Otherwise, - set the tabs at columns tab1, tab2, etc. (numbered from - 0); replace any tabs beyond the tab stops given with - single spaces. + columns apart instead of the default 8. Otherwise, + set the tabs at columns tab1, tab2, etc. (numbered from + 0); replace any tabs beyond the tab stops given with + single spaces. --initial -i Only convert initial tabs on each line to spaces. @@ -97,13 +97,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Convert tabs in each FILE to spaces, writing to standard output.\n\ With no FILE, or when FILE is -, read standard input.\n\ @@ -150,38 +150,38 @@ parse_tab_stops (char const *stops) for (; *stops; stops++) { if (*stops == ',' || isblank (to_uchar (*stops))) - { - if (have_tabval) - add_tab_stop (tabval); - have_tabval = false; - } + { + if (have_tabval) + add_tab_stop (tabval); + have_tabval = false; + } else if (ISDIGIT (*stops)) - { - if (!have_tabval) - { - tabval = 0; - have_tabval = true; - num_start = stops; - } + { + if (!have_tabval) + { + tabval = 0; + have_tabval = true; + num_start = stops; + } - /* Detect overflow. */ - if (!DECIMAL_DIGIT_ACCUMULATE (tabval, *stops - '0', uintmax_t)) - { - size_t len = strspn (num_start, "0123456789"); - char *bad_num = xstrndup (num_start, len); - error (0, 0, _("tab stop is too large %s"), quote (bad_num)); - free (bad_num); - ok = false; - stops = num_start + len - 1; - } - } + /* Detect overflow. */ + if (!DECIMAL_DIGIT_ACCUMULATE (tabval, *stops - '0', uintmax_t)) + { + size_t len = strspn (num_start, "0123456789"); + char *bad_num = xstrndup (num_start, len); + error (0, 0, _("tab stop is too large %s"), quote (bad_num)); + free (bad_num); + ok = false; + stops = num_start + len - 1; + } + } else - { - error (0, 0, _("tab size contains invalid character(s): %s"), - quote (stops)); - ok = false; - break; - } + { + error (0, 0, _("tab size contains invalid character(s): %s"), + quote (stops)); + ok = false; + break; + } } if (!ok) @@ -203,9 +203,9 @@ validate_tab_stops (uintmax_t const *tabs, size_t entries) for (i = 0; i < entries; i++) { if (tabs[i] == 0) - error (EXIT_FAILURE, 0, _("tab size cannot be 0")); + error (EXIT_FAILURE, 0, _("tab size cannot be 0")); if (tabs[i] <= prev_tab) - error (EXIT_FAILURE, 0, _("tab sizes must be ascending")); + error (EXIT_FAILURE, 0, _("tab sizes must be ascending")); prev_tab = tabs[i]; } } @@ -224,33 +224,33 @@ next_file (FILE *fp) if (fp) { if (ferror (fp)) - { - error (0, errno, "%s", prev_file); - exit_status = EXIT_FAILURE; - } + { + error (0, errno, "%s", prev_file); + exit_status = EXIT_FAILURE; + } if (STREQ (prev_file, "-")) - clearerr (fp); /* Also clear EOF. */ + clearerr (fp); /* Also clear EOF. */ else if (fclose (fp) != 0) - { - error (0, errno, "%s", prev_file); - exit_status = EXIT_FAILURE; - } + { + error (0, errno, "%s", prev_file); + exit_status = EXIT_FAILURE; + } } while ((file = *file_list++) != NULL) { if (STREQ (file, "-")) - { - have_read_stdin = true; - prev_file = file; - return stdin; - } + { + have_read_stdin = true; + prev_file = file; + return stdin; + } fp = fopen (file, "r"); if (fp) - { - prev_file = file; - return fp; - } + { + prev_file = file; + return fp; + } error (0, errno, "%s", file); exit_status = EXIT_FAILURE; } @@ -279,7 +279,7 @@ expand (void) /* The following variables have valid values only when CONVERT - is true: */ + is true: */ /* Column of next input character. */ uintmax_t column = 0; @@ -291,68 +291,68 @@ expand (void) /* Convert a line of text. */ do - { - while ((c = getc (fp)) < 0 && (fp = next_file (fp))) - continue; + { + while ((c = getc (fp)) < 0 && (fp = next_file (fp))) + continue; - if (convert) - { - if (c == '\t') - { - /* Column the next input tab stop is on. */ - uintmax_t next_tab_column; + if (convert) + { + if (c == '\t') + { + /* Column the next input tab stop is on. */ + uintmax_t next_tab_column; - if (tab_size) - next_tab_column = column + (tab_size - column % tab_size); - else - for (;;) - if (tab_index == first_free_tab) - { - next_tab_column = column + 1; - break; - } - else - { - uintmax_t tab = tab_list[tab_index++]; - if (column < tab) - { - next_tab_column = tab; - break; - } - } + if (tab_size) + next_tab_column = column + (tab_size - column % tab_size); + else + for (;;) + if (tab_index == first_free_tab) + { + next_tab_column = column + 1; + break; + } + else + { + uintmax_t tab = tab_list[tab_index++]; + if (column < tab) + { + next_tab_column = tab; + break; + } + } - if (next_tab_column < column) - error (EXIT_FAILURE, 0, _("input line is too long")); + if (next_tab_column < column) + error (EXIT_FAILURE, 0, _("input line is too long")); - while (++column < next_tab_column) - if (putchar (' ') < 0) - error (EXIT_FAILURE, errno, _("write error")); + while (++column < next_tab_column) + if (putchar (' ') < 0) + error (EXIT_FAILURE, errno, _("write error")); - c = ' '; - } - else if (c == '\b') - { - /* Go back one column, and force recalculation of the - next tab stop. */ - column -= !!column; - tab_index -= !!tab_index; - } - else - { - column++; - if (!column) - error (EXIT_FAILURE, 0, _("input line is too long")); - } + c = ' '; + } + else if (c == '\b') + { + /* Go back one column, and force recalculation of the + next tab stop. */ + column -= !!column; + tab_index -= !!tab_index; + } + else + { + column++; + if (!column) + error (EXIT_FAILURE, 0, _("input line is too long")); + } - convert &= convert_entire_line | !! isblank (c); - } + convert &= convert_entire_line | !! isblank (c); + } - if (c < 0) - return; + if (c < 0) + return; - if (putchar (c) < 0) - error (EXIT_FAILURE, errno, _("write error")); - } + if (putchar (c) < 0) + error (EXIT_FAILURE, errno, _("write error")); + } while (c != '\n'); } } @@ -379,35 +379,35 @@ main (int argc, char **argv) while ((c = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1) { switch (c) - { - case 'i': - convert_entire_line = false; - break; + { + case 'i': + convert_entire_line = false; + break; - case 't': - parse_tab_stops (optarg); - break; + case 't': + parse_tab_stops (optarg); + break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (optarg) - parse_tab_stops (optarg - 1); - else - { - char tab_stop[2]; - tab_stop[0] = c; - tab_stop[1] = '\0'; - parse_tab_stops (tab_stop); - } - break; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (optarg) + parse_tab_stops (optarg - 1); + else + { + char tab_stop[2]; + tab_stop[0] = c; + tab_stop[1] = '\0'; + parse_tab_stops (tab_stop); + } + 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); - } + default: + usage (EXIT_FAILURE); + } } validate_tab_stops (tab_list, first_free_tab); diff --git a/src/bin/coreutils/src/expr.c b/src/bin/coreutils/src/expr.c index ac3f4c3f27..11bf7ed477 100644 --- a/src/bin/coreutils/src/expr.c +++ b/src/bin/coreutils/src/expr.c @@ -89,7 +89,7 @@ mpz_mul (mpz_t r, mpz_t a0, mpz_t b0) intmax_t b = b0[0]; intmax_t val = a * b; if (! (a == 0 || b == 0 - || ((val < 0) == ((a < 0) ^ (b < 0)) && val / a == b))) + || ((val < 0) == ((a < 0) ^ (b < 0)) && val / a == b))) integer_overflow ('*'); r[0] = val; } @@ -196,14 +196,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s EXPRESSION\n\ or: %s OPTION\n\ "), - program_name, program_name); + program_name, program_name); putchar ('\n'); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -231,7 +231,7 @@ separates increasing precedence groups. EXPRESSION may be:\n\ ARG1 - ARG2 arithmetic difference of ARG1 and ARG2\n\ "), stdout); /* Tell xgettext that the "% A" below is not a printf-style - format string: xgettext:no-c-format */ + format string: xgettext:no-c-format */ fputs (_("\ \n\ ARG1 * ARG2 arithmetic product of ARG1 and ARG2\n\ @@ -309,7 +309,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); /* The above handles --help and --version. Since there is no other invocation of getopt, handle `--' here. */ if (argc > 1 && STREQ (argv[1], "--")) @@ -398,20 +398,20 @@ null (VALUE *v) return mpz_sgn (v->u.i) == 0; case string: { - char const *cp = v->u.s; - if (*cp == '\0') - return true; + char const *cp = v->u.s; + if (*cp == '\0') + return true; - cp += (*cp == '-'); + cp += (*cp == '-'); - do - { - if (*cp != '0') - return false; - } - while (*++cp); + do + { + if (*cp != '0') + return false; + } + while (*++cp); - return true; + return true; } default: abort (); @@ -442,10 +442,10 @@ tostring (VALUE *v) { case integer: { - char *s = mpz_get_str (NULL, 10, v->u.i); - mpz_clear (v->u.i); - v->u.s = s; - v->type = string; + char *s = mpz_get_str (NULL, 10, v->u.i); + mpz_clear (v->u.i); + v->u.s = s; + v->type = string; } break; case string: @@ -466,15 +466,15 @@ toarith (VALUE *v) return true; case string: { - char *s = v->u.s; + char *s = v->u.s; - if (! looks_like_integer (s)) - return false; - if (mpz_init_set_str (v->u.i, s, 10) != 0 && !HAVE_GMP) - error (EXPR_FAILURE, ERANGE, "%s", s); - free (s); - v->type = integer; - return true; + if (! looks_like_integer (s)) + return false; + if (mpz_init_set_str (v->u.i, s, 10) != 0 && !HAVE_GMP) + error (EXPR_FAILURE, ERANGE, "%s", s); + free (s); + v->type = integer; + return true; } default: abort (); @@ -493,7 +493,7 @@ getsize (mpz_t i) { unsigned long int ul = mpz_get_ui (i); if (ul < SIZE_MAX) - return ul; + return ul; } return SIZE_MAX - 1; } @@ -575,25 +575,25 @@ docolon (VALUE *sv, VALUE *pv) { /* Were \(...\) used? */ if (re_buffer.re_nsub > 0) - { - sv->u.s[re_regs.end[1]] = '\0'; - v = str_value (sv->u.s + re_regs.start[1]); - } + { + sv->u.s[re_regs.end[1]] = '\0'; + v = str_value (sv->u.s + re_regs.start[1]); + } else - v = int_value (matchlen); + v = int_value (matchlen); } else if (matchlen == -1) { /* Match failed -- return the right kind of null. */ if (re_buffer.re_nsub > 0) - v = str_value (""); + v = str_value (""); else - v = int_value (0); + v = int_value (0); } else error (EXPR_FAILURE, - (matchlen == -2 ? errno : EOVERFLOW), - _("error in regular expression matcher")); + (matchlen == -2 ? errno : EOVERFLOW), + _("error in regular expression matcher")); if (0 < re_regs.num_regs) { @@ -622,7 +622,7 @@ eval7 (bool evaluate) { v = eval (evaluate); if (!nextarg (")")) - syntax_error (); + syntax_error (); return v; } @@ -649,7 +649,7 @@ eval6 (bool evaluate) if (nextarg ("+")) { if (nomoreargs ()) - syntax_error (); + syntax_error (); return str_value (*args++); } else if (nextarg ("length")) @@ -665,12 +665,12 @@ eval6 (bool evaluate) l = eval6 (evaluate); r = eval6 (evaluate); if (evaluate) - { - v = docolon (l, r); - freev (l); - } + { + v = docolon (l, r); + freev (l); + } else - v = l; + v = l; freev (r); return v; } @@ -698,25 +698,25 @@ eval6 (bool evaluate) llen = strlen (l->u.s); if (!toarith (i1) || !toarith (i2)) - v = str_value (""); + v = str_value (""); else - { - size_t pos = getsize (i1->u.i); - size_t len = getsize (i2->u.i); + { + size_t pos = getsize (i1->u.i); + size_t len = getsize (i2->u.i); - if (llen < pos || pos == 0 || len == 0 || len == SIZE_MAX) - v = str_value (""); - else - { - size_t vlen = MIN (len, llen - pos + 1); - char *vlim; - v = xmalloc (sizeof *v); - v->type = string; - v->u.s = xmalloc (vlen + 1); - vlim = mempcpy (v->u.s, l->u.s + pos - 1, vlen); - *vlim = '\0'; - } - } + if (llen < pos || pos == 0 || len == 0 || len == SIZE_MAX) + v = str_value (""); + else + { + size_t vlen = MIN (len, llen - pos + 1); + char *vlim; + v = xmalloc (sizeof *v); + v->type = string; + v->u.s = xmalloc (vlen + 1); + vlim = mempcpy (v->u.s, l->u.s + pos - 1, vlen); + *vlim = '\0'; + } + } freev (l); freev (i1); freev (i2); @@ -743,18 +743,18 @@ eval5 (bool evaluate) while (1) { if (nextarg (":")) - { - r = eval6 (evaluate); - if (evaluate) - { - v = docolon (l, r); - freev (l); - l = v; - } - freev (r); - } + { + r = eval6 (evaluate); + if (evaluate) + { + v = docolon (l, r); + freev (l); + l = v; + } + freev (r); + } else - return l; + return l; } } @@ -774,25 +774,25 @@ eval4 (bool evaluate) while (1) { if (nextarg ("*")) - fxn = multiply; + fxn = multiply; else if (nextarg ("/")) - fxn = divide; + fxn = divide; else if (nextarg ("%")) - fxn = mod; + fxn = mod; else - return l; + return l; r = eval5 (evaluate); if (evaluate) - { - if (!toarith (l) || !toarith (r)) - error (EXPR_INVALID, 0, _("non-numeric argument")); - if (fxn != multiply && mpz_sgn (r->u.i) == 0) - error (EXPR_INVALID, 0, _("division by zero")); - ((fxn == multiply ? mpz_mul - : fxn == divide ? mpz_tdiv_q - : mpz_tdiv_r) - (l->u.i, l->u.i, r->u.i)); - } + { + if (!toarith (l) || !toarith (r)) + error (EXPR_INVALID, 0, _("non-numeric argument")); + if (fxn != multiply && mpz_sgn (r->u.i) == 0) + error (EXPR_INVALID, 0, _("division by zero")); + ((fxn == multiply ? mpz_mul + : fxn == divide ? mpz_tdiv_q + : mpz_tdiv_r) + (l->u.i, l->u.i, r->u.i)); + } freev (r); } } @@ -813,18 +813,18 @@ eval3 (bool evaluate) while (1) { if (nextarg ("+")) - fxn = plus; + fxn = plus; else if (nextarg ("-")) - fxn = minus; + fxn = minus; else - return l; + return l; r = eval4 (evaluate); if (evaluate) - { - if (!toarith (l) || !toarith (r)) - error (EXPR_INVALID, 0, _("non-numeric argument")); - (fxn == plus ? mpz_add : mpz_sub) (l->u.i, l->u.i, r->u.i); - } + { + if (!toarith (l) || !toarith (r)) + error (EXPR_INVALID, 0, _("non-numeric argument")); + (fxn == plus ? mpz_add : mpz_sub) (l->u.i, l->u.i, r->u.i); + } freev (r); } } @@ -844,62 +844,62 @@ eval2 (bool evaluate) { VALUE *r; enum - { - less_than, less_equal, equal, not_equal, greater_equal, greater_than - } fxn; + { + less_than, less_equal, equal, not_equal, greater_equal, greater_than + } fxn; bool val = false; if (nextarg ("<")) - fxn = less_than; + fxn = less_than; else if (nextarg ("<=")) - fxn = less_equal; + fxn = less_equal; else if (nextarg ("=") || nextarg ("==")) - fxn = equal; + fxn = equal; else if (nextarg ("!=")) - fxn = not_equal; + fxn = not_equal; else if (nextarg (">=")) - fxn = greater_equal; + fxn = greater_equal; else if (nextarg (">")) - fxn = greater_than; + fxn = greater_than; else - return l; + return l; r = eval3 (evaluate); if (evaluate) - { - int cmp; - tostring (l); - tostring (r); + { + int cmp; + tostring (l); + tostring (r); - if (looks_like_integer (l->u.s) && looks_like_integer (r->u.s)) - cmp = strintcmp (l->u.s, r->u.s); - else - { - errno = 0; - cmp = strcoll (l->u.s, r->u.s); + if (looks_like_integer (l->u.s) && looks_like_integer (r->u.s)) + cmp = strintcmp (l->u.s, r->u.s); + else + { + errno = 0; + cmp = strcoll (l->u.s, r->u.s); - if (errno) - { - error (0, errno, _("string comparison failed")); - error (0, 0, _("set LC_ALL='C' to work around the problem")); - error (EXPR_INVALID, 0, - _("the strings compared were %s and %s"), - quotearg_n_style (0, locale_quoting_style, l->u.s), - quotearg_n_style (1, locale_quoting_style, r->u.s)); - } - } + if (errno) + { + error (0, errno, _("string comparison failed")); + error (0, 0, _("set LC_ALL='C' to work around the problem")); + error (EXPR_INVALID, 0, + _("the strings compared were %s and %s"), + quotearg_n_style (0, locale_quoting_style, l->u.s), + quotearg_n_style (1, locale_quoting_style, r->u.s)); + } + } - switch (fxn) - { - case less_than: val = (cmp < 0); break; - case less_equal: val = (cmp <= 0); break; - case equal: val = (cmp == 0); break; - case not_equal: val = (cmp != 0); break; - case greater_equal: val = (cmp >= 0); break; - case greater_than: val = (cmp > 0); break; - default: abort (); - } - } + switch (fxn) + { + case less_than: val = (cmp < 0); break; + case less_equal: val = (cmp <= 0); break; + case equal: val = (cmp == 0); break; + case not_equal: val = (cmp != 0); break; + case greater_equal: val = (cmp >= 0); break; + case greater_than: val = (cmp > 0); break; + default: abort (); + } + } freev (l); freev (r); @@ -922,19 +922,19 @@ eval1 (bool evaluate) while (1) { if (nextarg ("&")) - { - r = eval2 (evaluate & ~ null (l)); - if (null (l) || null (r)) - { - freev (l); - freev (r); - l = int_value (0); - } - else - freev (r); - } + { + r = eval2 (evaluate & ~ null (l)); + if (null (l) || null (r)) + { + freev (l); + freev (r); + l = int_value (0); + } + else + freev (r); + } else - return l; + return l; } } @@ -953,22 +953,22 @@ eval (bool evaluate) while (1) { if (nextarg ("|")) - { - r = eval1 (evaluate & null (l)); - if (null (l)) - { - freev (l); - l = r; - if (null (l)) - { - freev (l); - l = int_value (0); - } - } - else - freev (r); - } + { + r = eval1 (evaluate & null (l)); + if (null (l)) + { + freev (l); + l = r; + if (null (l)) + { + freev (l); + l = int_value (0); + } + } + else + freev (r); + } else - return l; + return l; } } diff --git a/src/bin/coreutils/src/extract-magic b/src/bin/coreutils/src/extract-magic index 8daf59d22a..dfea3d5fdd 100644 --- a/src/bin/coreutils/src/extract-magic +++ b/src/bin/coreutils/src/extract-magic @@ -114,10 +114,10 @@ EOF while (defined (my $line = )) { $line =~ /^[ \t]+case S_MAGIC_/ - or next; + or next; $line =~ m!^[ \t]+case (S_MAGIC_\w+): /\* (0x[0-9A-Fa-f]+) \*/$! - or (warn "$ME:$file:$.: malformed case S_MAGIC_... line"), - $fail = 1, next; + or (warn "$ME:$file:$.: malformed case S_MAGIC_... line"), + $fail = 1, next; my $name = $1; my $value = $2; print "# define $name $value\n"; diff --git a/src/bin/coreutils/src/factor.c b/src/bin/coreutils/src/factor.c index 9ac703ce89..59fe1f45fd 100644 --- a/src/bin/coreutils/src/factor.c +++ b/src/bin/coreutils/src/factor.c @@ -110,7 +110,7 @@ factor_using_division (mpz_t t, unsigned int limit) { mpz_tdiv_qr_ui (q, r, t, 3); if (mpz_cmp_ui (r, 0) != 0) - break; + break; mpz_set (t, q); emit_ul_factor (3); } @@ -119,7 +119,7 @@ factor_using_division (mpz_t t, unsigned int limit) { mpz_tdiv_qr_ui (q, r, t, 5); if (mpz_cmp_ui (r, 0) != 0) - break; + break; mpz_set (t, q); emit_ul_factor (5); } @@ -131,21 +131,21 @@ factor_using_division (mpz_t t, unsigned int limit) { mpz_tdiv_qr_ui (q, r, t, f); if (mpz_cmp_ui (r, 0) != 0) - { - f += addv[ai]; - if (mpz_cmp_ui (q, f) < 0) - break; - ai = (ai + 1) & 7; - failures++; - if (failures > limit) - break; - } + { + f += addv[ai]; + if (mpz_cmp_ui (q, f) < 0) + break; + ai = (ai + 1) & 7; + failures++; + if (failures > limit) + break; + } else - { - mpz_swap (t, q); - emit_ul_factor (f); - failures = 0; - } + { + mpz_swap (t, q); + emit_ul_factor (f); + failures = 0; + } } mpz_clear (q); @@ -184,67 +184,67 @@ S2: mpz_sub (t1, x1, x); mpz_mul (t2, P, t1); mpz_mod (P, t2, n); c++; if (c == 20) - { - c = 0; - mpz_gcd (g, P, n); - if (mpz_cmp_ui (g, 1) != 0) - goto S4; - mpz_set (y, x); - } + { + c = 0; + mpz_gcd (g, P, n); + if (mpz_cmp_ui (g, 1) != 0) + goto S4; + mpz_set (y, x); + } k--; if (k > 0) - goto S2; + goto S2; mpz_gcd (g, P, n); if (mpz_cmp_ui (g, 1) != 0) - goto S4; + goto S4; mpz_set (x1, x); k = l; l = 2 * l; for (i = 0; i < k; i++) - { - mpz_mul (x, x, x); mpz_add (x, x, a); mpz_mod (x, x, n); - } + { + mpz_mul (x, x, x); mpz_add (x, x, a); mpz_mod (x, x, n); + } mpz_set (y, x); c = 0; goto S2; S4: do - { - mpz_mul (y, y, y); mpz_add (y, y, a); mpz_mod (y, y, n); - mpz_sub (t1, x1, y); mpz_gcd (g, t1, n); - } + { + mpz_mul (y, y, y); mpz_add (y, y, a); mpz_mod (y, y, n); + mpz_sub (t1, x1, y); mpz_gcd (g, t1, n); + } while (mpz_cmp_ui (g, 1) == 0); mpz_div (n, n, g); /* divide by g, before g is overwritten */ if (!mpz_probab_prime_p (g, 3)) - { - do - { - mp_limb_t a_limb; - mpn_random (&a_limb, (mp_size_t) 1); - a_int = (int) a_limb; - } - while (a_int == -2 || a_int == 0); + { + do + { + mp_limb_t a_limb; + mpn_random (&a_limb, (mp_size_t) 1); + a_int = (int) a_limb; + } + while (a_int == -2 || a_int == 0); - debug ("[composite factor--restarting pollard-rho] "); - factor_using_pollard_rho (g, a_int); - } + debug ("[composite factor--restarting pollard-rho] "); + factor_using_pollard_rho (g, a_int); + } else - { - emit_factor (g); - } + { + emit_factor (g); + } mpz_mod (x, x, n); mpz_mod (x1, x1, n); mpz_mod (y, y, n); if (mpz_probab_prime_p (n, 3)) - { - emit_factor (n); - break; - } + { + emit_factor (n); + break; + } } mpz_clear (g); @@ -309,15 +309,15 @@ factor_wheel (uintmax_t n0, size_t max_n_factors, uintmax_t *factors) { q = n / d; while (n == q * d) - { - assert (n_factors < max_n_factors); - factors[n_factors++] = d; - n = q; - q = n / d; - } + { + assert (n_factors < max_n_factors); + factors[n_factors++] = d; + n = q; + q = n / d; + } d += *(w++); if (w == WHEEL_END) - w = WHEEL_START; + w = WHEEL_START; } while (d <= q); @@ -407,13 +407,13 @@ print_factors_multi (mpz_t t) factor_using_division (t, division_limit); if (mpz_cmp_ui (t, 1) != 0) - { - debug ("[is number prime?] "); - if (mpz_probab_prime_p (t, 3)) - emit_factor (t); - else - factor_using_pollard_rho (t, 1); - } + { + debug ("[is number prime?] "); + if (mpz_probab_prime_p (t, 3)) + emit_factor (t); + else + factor_using_pollard_rho (t, 1); + } } mpz_clear (t); @@ -443,11 +443,11 @@ print_factors (char const *s) mpz_t t; mpz_init (t); if (gmp_sscanf (s, "%Zd", t) == 1) - { - debug ("[%s]", _("using arbitrary-precision arithmetic")); - print_factors_multi (t); - return true; - } + { + debug ("[%s]", _("using arbitrary-precision arithmetic")); + print_factors_multi (t); + return true; + } err = LONGINT_INVALID; } #endif @@ -487,14 +487,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [NUMBER]...\n\ or: %s OPTION\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Print the prime factors of each specified integer NUMBER. If none\n\ are specified on the command line, read them from standard input.\n\ @@ -518,9 +518,9 @@ do_stdin (void) for (;;) { size_t token_length = readtoken (stdin, DELIM, sizeof (DELIM) - 1, - &tokenbuffer); + &tokenbuffer); if (token_length == (size_t) -1) - break; + break; ok &= print_factors (tokenbuffer.buffer); } free (tokenbuffer.buffer); @@ -545,18 +545,18 @@ main (int argc, char **argv) while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1) { switch (c) - { - case VERBOSE_OPTION: - verbose = true; - break; + { + case VERBOSE_OPTION: + verbose = 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); - } + default: + usage (EXIT_FAILURE); + } } if (argc <= optind) @@ -566,8 +566,8 @@ main (int argc, char **argv) int i; ok = true; for (i = optind; i < argc; i++) - if (! print_factors (argv[i])) - ok = false; + if (! print_factors (argv[i])) + ok = false; } #if HAVE_GMP free (factor); diff --git a/src/bin/coreutils/src/fmt.c b/src/bin/coreutils/src/fmt.c index b8577bb7a8..c12072c58e 100644 --- a/src/bin/coreutils/src/fmt.c +++ b/src/bin/coreutils/src/fmt.c @@ -263,7 +263,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [-WIDTH] [OPTION]... [FILE]...\n"), program_name); @@ -281,7 +281,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ reattaching the prefix to reformatted lines\n\ -s, --split-only split long lines, but do not refill\n\ "), - stdout); + stdout); fputs (_("\ -t, --tagged-paragraph indentation of first line different from second\n\ -u, --uniform-spacing one space between words, two after sentences\n\ @@ -292,7 +292,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fputs (_("\ \n\ With no FILE, or when FILE is -, read standard input.\n"), - stdout); + stdout); emit_bug_reporting_address (); } exit (status); @@ -345,40 +345,40 @@ main (int argc, char **argv) } while ((optchar = getopt_long (argc, argv, "0123456789cstuw:p:", - long_options, NULL)) - != -1) + long_options, NULL)) + != -1) switch (optchar) { default: - if (ISDIGIT (optchar)) - error (0, 0, _("invalid option -- %c; -WIDTH is recognized\ + if (ISDIGIT (optchar)) + error (0, 0, _("invalid option -- %c; -WIDTH is recognized\ only when it is the first\noption; use -w N instead"), - optchar); - usage (EXIT_FAILURE); + optchar); + usage (EXIT_FAILURE); case 'c': - crown = true; - break; + crown = true; + break; case 's': - split = true; - break; + split = true; + break; case 't': - tagged = true; - break; + tagged = true; + break; case 'u': - uniform = true; - break; + uniform = true; + break; case 'w': - max_width_option = optarg; - break; + max_width_option = optarg; + break; case 'p': - set_prefix (optarg); - break; + set_prefix (optarg); + break; case_GETOPT_HELP_CHAR; @@ -389,12 +389,12 @@ main (int argc, char **argv) if (max_width_option) { /* Limit max_width to MAXCHARS / 2; otherwise, the resulting - output can be quite ugly. */ + output can be quite ugly. */ unsigned long int tmp; if (! (xstrtoul (max_width_option, NULL, 10, &tmp, "") == LONGINT_OK - && tmp <= MAXCHARS / 2)) - error (EXIT_FAILURE, 0, _("invalid width: %s"), - quote (max_width_option)); + && tmp <= MAXCHARS / 2)) + error (EXIT_FAILURE, 0, _("invalid width: %s"), + quote (max_width_option)); max_width = tmp; } @@ -405,31 +405,31 @@ main (int argc, char **argv) else { for (; optind < argc; optind++) - { - char *file = argv[optind]; - if (STREQ (file, "-")) - fmt (stdin); - else - { - FILE *in_stream; - in_stream = fopen (file, "r"); - if (in_stream != NULL) - { - fmt (in_stream); - if (fclose (in_stream) == EOF) - { - error (0, errno, "%s", file); - ok = false; - } - } - else - { - error (0, errno, _("cannot open %s for reading"), - quote (file)); - ok = false; - } - } - } + { + char *file = argv[optind]; + if (STREQ (file, "-")) + fmt (stdin); + else + { + FILE *in_stream; + in_stream = fopen (file, "r"); + if (in_stream != NULL) + { + fmt (in_stream); + if (fclose (in_stream) == EOF) + { + error (0, errno, "%s", file); + ok = false; + } + } + else + { + error (0, errno, _("cannot open %s for reading"), + quote (file)); + ok = false; + } + } + } } exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); @@ -488,9 +488,9 @@ set_other_indent (bool same_paragraph) else if (tagged) { if (same_paragraph && in_column != first_indent) - { - other_indent = in_column; - } + { + other_indent = in_column; + } /* Only one line: use the secondary indent from last time if it splits, or 0 if there have been no multi-line paragraphs in the @@ -498,7 +498,7 @@ set_other_indent (bool same_paragraph) pick a new secondary indent. */ else if (other_indent == first_indent) - other_indent = first_indent == 0 ? DEF_INDENT : 0; + other_indent = first_indent == 0 ? DEF_INDENT : 0; } else { @@ -532,15 +532,15 @@ get_paragraph (FILE *f) /* Scan (and copy) blank lines, and lines not introduced by the prefix. */ while (c == '\n' || c == EOF - || next_prefix_indent < prefix_lead_space - || in_column < next_prefix_indent + prefix_full_length) + || next_prefix_indent < prefix_lead_space + || in_column < next_prefix_indent + prefix_full_length) { c = copy_rest (f, c); if (c == EOF) - { - next_char = EOF; - return false; - } + { + next_char = EOF; + return false; + } putchar ('\n'); c = get_prefix (f); } @@ -563,29 +563,29 @@ get_paragraph (FILE *f) else if (crown) { if (same_para (c)) - { - do - { /* for each line till the end of the para */ - c = get_line (f, c); - } - while (same_para (c) && in_column == other_indent); - } + { + do + { /* for each line till the end of the para */ + c = get_line (f, c); + } + while (same_para (c) && in_column == other_indent); + } } else if (tagged) { if (same_para (c) && in_column != first_indent) - { - do - { /* for each line till the end of the para */ - c = get_line (f, c); - } - while (same_para (c) && in_column == other_indent); - } + { + do + { /* for each line till the end of the para */ + c = get_line (f, c); + } + while (same_para (c) && in_column == other_indent); + } } else { while (same_para (c) && in_column == other_indent) - c = get_line (f, c); + c = get_line (f, c); } (word_limit - 1)->period = (word_limit - 1)->final = true; next_char = c; @@ -607,11 +607,11 @@ copy_rest (FILE *f, int c) { put_space (next_prefix_indent); for (s = prefix; out_column != in_column && *s; out_column++) - putchar (*s++); + putchar (*s++); if (c != EOF && c != '\n') - put_space (in_column - out_column); + put_space (in_column - out_column); if (c == EOF && in_column >= next_prefix_indent + prefix_length) - putchar ('\n'); + putchar ('\n'); } while (c != '\n' && c != EOF) { @@ -629,8 +629,8 @@ static bool same_para (int c) { return (next_prefix_indent == prefix_indent - && in_column >= next_prefix_indent + prefix_full_length - && c != '\n' && c != EOF); + && in_column >= next_prefix_indent + prefix_full_length + && c != '\n' && c != EOF); } /* Read a line from input file F, given first non-blank character C @@ -658,15 +658,15 @@ get_line (FILE *f, int c) word_limit->text = wptr; do - { - if (wptr == end_of_parabuf) - { - set_other_indent (true); - flush_paragraph (); - } - *wptr++ = c; - c = getc (f); - } + { + if (wptr == end_of_parabuf) + { + set_other_indent (true); + flush_paragraph (); + } + *wptr++ = c; + c = getc (f); + } while (c != EOF && !isspace (c)); in_column += word_limit->length = wptr - word_limit->text; check_punctuation (word_limit); @@ -677,15 +677,15 @@ get_line (FILE *f, int c) c = get_space (f, c); word_limit->space = in_column - start; word_limit->final = (c == EOF - || (word_limit->period - && (c == '\n' || word_limit->space > 1))); + || (word_limit->period + && (c == '\n' || word_limit->space > 1))); if (c == '\n' || c == EOF || uniform) - word_limit->space = word_limit->final ? 2 : 1; + word_limit->space = word_limit->final ? 2 : 1; if (word_limit == end_of_word) - { - set_other_indent (true); - flush_paragraph (); - } + { + set_other_indent (true); + flush_paragraph (); + } word_limit++; } while (c != '\n' && c != EOF); @@ -710,13 +710,13 @@ get_prefix (FILE *f) const char *p; next_prefix_indent = in_column; for (p = prefix; *p != '\0'; p++) - { - unsigned char pc = *p; - if (c != pc) - return c; - in_column++; - c = getc (f); - } + { + unsigned char pc = *p; + if (c != pc) + return c; + in_column++; + c = getc (f); + } c = get_space (f, c); } return c; @@ -731,14 +731,14 @@ get_space (FILE *f, int c) for (;;) { if (c == ' ') - in_column++; + in_column++; else if (c == '\t') - { - tabs = true; - in_column = (in_column / TABWIDTH + 1) * TABWIDTH; - } + { + tabs = true; + in_column = (in_column / TABWIDTH + 1) * TABWIDTH; + } else - return c; + return c; c = getc (f); } } @@ -794,12 +794,12 @@ flush_paragraph (void) for (w = word->next_break; w != word_limit; w = w->next_break) { if (w->best_cost - w->next_break->best_cost < best_break) - { - split_point = w; - best_break = w->best_cost - w->next_break->best_cost; - } + { + split_point = w; + best_break = w->best_cost - w->next_break->best_cost; + } if (best_break <= MAXCOST - LINE_CREDIT) - best_break += LINE_CREDIT; + best_break += LINE_CREDIT; } put_paragraph (split_point); @@ -848,30 +848,30 @@ fmt_paragraph (void) w = start; len += w->length; do - { - w++; + { + w++; - /* Consider breaking before w. */ + /* Consider breaking before w. */ - wcost = line_cost (w, len) + w->best_cost; - if (start == word && last_line_length > 0) - wcost += RAGGED_COST (len - last_line_length); - if (wcost < best) - { - best = wcost; - start->next_break = w; - start->line_length = len; - } + wcost = line_cost (w, len) + w->best_cost; + if (start == word && last_line_length > 0) + wcost += RAGGED_COST (len - last_line_length); + if (wcost < best) + { + best = wcost; + start->next_break = w; + start->line_length = len; + } - /* This is a kludge to keep us from computing `len' as the - sum of the sentinel length and some non-zero number. - Since the sentinel w->length may be INT_MAX, adding - to that would give a negative result. */ - if (w == word_limit) - break; + /* This is a kludge to keep us from computing `len' as the + sum of the sentinel length and some non-zero number. + Since the sentinel w->length may be INT_MAX, adding + to that would give a negative result. */ + if (w == word_limit) + break; - len += (w - 1)->space + w->length; /* w > start >= word */ - } + len += (w - 1)->space + w->length; /* w > start >= word */ + } while (len < max_width); start->best_cost = best + base_cost (start); } @@ -892,16 +892,16 @@ base_cost (WORD *this) if (this > word) { if ((this - 1)->period) - { - if ((this - 1)->final) - cost -= SENTENCE_BONUS; - else - cost += NOBREAK_COST; - } + { + if ((this - 1)->final) + cost -= SENTENCE_BONUS; + else + cost += NOBREAK_COST; + } else if ((this - 1)->punct) - cost -= PUNCT_BONUS; + cost -= PUNCT_BONUS; else if (this > word + 1 && (this - 2)->final) - cost += WIDOW_COST ((this - 1)->length); + cost += WIDOW_COST ((this - 1)->length); } if (this->paren) @@ -997,11 +997,11 @@ put_space (int space) { tab_target = space_target / TABWIDTH * TABWIDTH; if (out_column + 1 < tab_target) - while (out_column < tab_target) - { - putchar ('\t'); - out_column = (out_column / TABWIDTH + 1) * TABWIDTH; - } + while (out_column < tab_target) + { + putchar ('\t'); + out_column = (out_column / TABWIDTH + 1) * TABWIDTH; + } } while (out_column < space_target) { diff --git a/src/bin/coreutils/src/fold.c b/src/bin/coreutils/src/fold.c index b9c909f8d3..52322657ad 100644 --- a/src/bin/coreutils/src/fold.c +++ b/src/bin/coreutils/src/fold.c @@ -60,13 +60,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Wrap input lines in each FILE (standard input by default), writing to\n\ standard output.\n\ @@ -97,16 +97,16 @@ adjust_column (size_t column, char c) if (!count_bytes) { if (c == '\b') - { - if (column > 0) - column--; - } + { + if (column > 0) + column--; + } else if (c == '\r') - column = 0; + column = 0; else if (c == '\t') - column += TAB_WIDTH - column % TAB_WIDTH; + column += TAB_WIDTH - column % TAB_WIDTH; else /* if (isprint (c)) */ - column++; + column++; } else column++; @@ -145,71 +145,71 @@ fold_file (char const *filename, size_t width) while ((c = getc (istream)) != EOF) { if (offset_out + 1 >= allocated_out) - line_out = X2REALLOC (line_out, &allocated_out); + line_out = X2REALLOC (line_out, &allocated_out); if (c == '\n') - { - line_out[offset_out++] = c; - fwrite (line_out, sizeof (char), offset_out, stdout); - column = offset_out = 0; - continue; - } + { + line_out[offset_out++] = c; + fwrite (line_out, sizeof (char), offset_out, stdout); + column = offset_out = 0; + continue; + } rescan: column = adjust_column (column, c); if (column > width) - { - /* This character would make the line too long. - Print the line plus a newline, and make this character - start the next line. */ - if (break_spaces) - { - bool found_blank = false; - size_t logical_end = offset_out; + { + /* This character would make the line too long. + Print the line plus a newline, and make this character + start the next line. */ + if (break_spaces) + { + bool found_blank = false; + size_t logical_end = offset_out; - /* Look for the last blank. */ - while (logical_end) - { - --logical_end; - if (isblank (to_uchar (line_out[logical_end]))) - { - found_blank = true; - break; - } - } + /* Look for the last blank. */ + while (logical_end) + { + --logical_end; + if (isblank (to_uchar (line_out[logical_end]))) + { + found_blank = true; + break; + } + } - if (found_blank) - { - size_t i; + if (found_blank) + { + size_t i; - /* Found a blank. Don't output the part after it. */ - logical_end++; - fwrite (line_out, sizeof (char), (size_t) logical_end, - stdout); - putchar ('\n'); - /* Move the remainder to the beginning of the next line. - The areas being copied here might overlap. */ - memmove (line_out, line_out + logical_end, - offset_out - logical_end); - offset_out -= logical_end; - for (column = i = 0; i < offset_out; i++) - column = adjust_column (column, line_out[i]); - goto rescan; - } - } + /* Found a blank. Don't output the part after it. */ + logical_end++; + fwrite (line_out, sizeof (char), (size_t) logical_end, + stdout); + putchar ('\n'); + /* Move the remainder to the beginning of the next line. + The areas being copied here might overlap. */ + memmove (line_out, line_out + logical_end, + offset_out - logical_end); + offset_out -= logical_end; + for (column = i = 0; i < offset_out; i++) + column = adjust_column (column, line_out[i]); + goto rescan; + } + } - if (offset_out == 0) - { - line_out[offset_out++] = c; - continue; - } + if (offset_out == 0) + { + line_out[offset_out++] = c; + continue; + } - line_out[offset_out++] = '\n'; - fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); - column = offset_out = 0; - goto rescan; - } + line_out[offset_out++] = '\n'; + fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); + column = offset_out = 0; + goto rescan; + } line_out[offset_out++] = c; } @@ -223,7 +223,7 @@ fold_file (char const *filename, size_t width) { error (0, saved_errno, "%s", filename); if (!STREQ (filename, "-")) - fclose (istream); + fclose (istream); return false; } if (!STREQ (filename, "-") && fclose (istream) == EOF) @@ -258,44 +258,44 @@ main (int argc, char **argv) char optargbuf[2]; switch (optc) - { - case 'b': /* Count bytes rather than columns. */ - count_bytes = true; - break; + { + case 'b': /* Count bytes rather than columns. */ + count_bytes = true; + break; - case 's': /* Break at word boundaries. */ - break_spaces = true; - break; + case 's': /* Break at word boundaries. */ + break_spaces = true; + break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (optarg) - optarg--; - else - { - optargbuf[0] = optc; - optargbuf[1] = '\0'; - optarg = optargbuf; - } - /* Fall through. */ - case 'w': /* Line width. */ - { - unsigned long int tmp_ulong; - if (! (xstrtoul (optarg, NULL, 10, &tmp_ulong, "") == LONGINT_OK - && 0 < tmp_ulong && tmp_ulong < SIZE_MAX - TAB_WIDTH)) - error (EXIT_FAILURE, 0, - _("invalid number of columns: %s"), quote (optarg)); - width = tmp_ulong; - } - break; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (optarg) + optarg--; + else + { + optargbuf[0] = optc; + optargbuf[1] = '\0'; + optarg = optargbuf; + } + /* Fall through. */ + case 'w': /* Line width. */ + { + unsigned long int tmp_ulong; + if (! (xstrtoul (optarg, NULL, 10, &tmp_ulong, "") == LONGINT_OK + && 0 < tmp_ulong && tmp_ulong < SIZE_MAX - TAB_WIDTH)) + error (EXIT_FAILURE, 0, + _("invalid number of columns: %s"), quote (optarg)); + width = tmp_ulong; + } + 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); - } + default: + usage (EXIT_FAILURE); + } } if (argc == optind) @@ -304,7 +304,7 @@ main (int argc, char **argv) { ok = true; for (i = optind; i < argc; i++) - ok &= fold_file (argv[i], width); + ok &= fold_file (argv[i], width); } if (have_read_stdin && fclose (stdin) == EOF) diff --git a/src/bin/coreutils/src/getlimits.c b/src/bin/coreutils/src/getlimits.c index da0c6f4844..82cd34531e 100644 --- a/src/bin/coreutils/src/getlimits.c +++ b/src/bin/coreutils/src/getlimits.c @@ -172,9 +172,3 @@ main (int argc, char **argv) print_int (INTMAX); print_int (UINTMAX); } - -/* - * Local variables: - * indent-tabs-mode: nil - * End: - */ diff --git a/src/bin/coreutils/src/group-list.c b/src/bin/coreutils/src/group-list.c index 46895b4745..4c5391ddb9 100644 --- a/src/bin/coreutils/src/group-list.c +++ b/src/bin/coreutils/src/group-list.c @@ -113,9 +113,3 @@ print_group (gid_t gid, bool use_name) printf ("%s", grp->gr_name); return ok; } - -/* - * Local variables: - * indent-tabs-mode: nil - * End: - */ diff --git a/src/bin/coreutils/src/groups.c b/src/bin/coreutils/src/groups.c index c89e0dcc4e..27e8724066 100644 --- a/src/bin/coreutils/src/groups.c +++ b/src/bin/coreutils/src/groups.c @@ -124,9 +124,3 @@ main (int argc, char **argv) exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); } - -/* - * Local variables: - * indent-tabs-mode: nil - * End: - */ diff --git a/src/bin/coreutils/src/head.c b/src/bin/coreutils/src/head.c index c96f91009d..f014388097 100644 --- a/src/bin/coreutils/src/head.c +++ b/src/bin/coreutils/src/head.c @@ -102,13 +102,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Print the first 10 lines of each FILE to standard output.\n\ With more than one FILE, precede each with a header giving the file name.\n\ @@ -186,15 +186,15 @@ copy_fd (int src_fd, FILE *o_stream, uintmax_t n_bytes) size_t n_to_read = MIN (buf_size, n_bytes); size_t n_read = safe_read (src_fd, buf, n_to_read); if (n_read == SAFE_READ_ERROR) - return COPY_FD_READ_ERROR; + return COPY_FD_READ_ERROR; n_bytes -= n_read; if (n_read == 0 && n_bytes != 0) - return COPY_FD_UNEXPECTED_EOF; + return COPY_FD_UNEXPECTED_EOF; if (fwrite (buf, 1, n_read, o_stream) < n_read) - return COPY_FD_WRITE_ERROR; + return COPY_FD_WRITE_ERROR; } return COPY_FD_OK; @@ -229,7 +229,7 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0) { char umax_buf[INT_BUFSIZE_BOUND (uintmax_t)]; error (EXIT_FAILURE, 0, _("%s: number of bytes is too large"), - umaxtostr (n_elide_0, umax_buf)); + umaxtostr (n_elide_0, umax_buf)); } /* Two cases to consider... @@ -255,54 +255,54 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0) b[1] = b[0] + n_to_read; for (i = false; ! eof ; i = !i) - { - size_t n_read = full_read (fd, b[i], n_to_read); - size_t delta = 0; - if (n_read < n_to_read) - { - if (errno != 0) - { - error (0, errno, _("error reading %s"), quote (filename)); - ok = false; - break; - } + { + size_t n_read = full_read (fd, b[i], n_to_read); + size_t delta = 0; + if (n_read < n_to_read) + { + if (errno != 0) + { + error (0, errno, _("error reading %s"), quote (filename)); + ok = false; + break; + } - /* reached EOF */ - if (n_read <= n_elide) - { - if (first) - { - /* The input is no larger than the number of bytes - to elide. So there's nothing to output, and - we're done. */ - } - else - { - delta = n_elide - n_read; - } - } - eof = true; - } + /* reached EOF */ + if (n_read <= n_elide) + { + if (first) + { + /* The input is no larger than the number of bytes + to elide. So there's nothing to output, and + we're done. */ + } + else + { + delta = n_elide - n_read; + } + } + eof = true; + } - /* Output any (but maybe just part of the) elided data from - the previous round. */ - if ( ! first) - { - /* Don't bother checking for errors here. - If there's a failure, the test of the following - fwrite or in close_stdout will catch it. */ - fwrite (b[!i] + READ_BUFSIZE, 1, n_elide - delta, stdout); - } - first = false; + /* Output any (but maybe just part of the) elided data from + the previous round. */ + if ( ! first) + { + /* Don't bother checking for errors here. + If there's a failure, the test of the following + fwrite or in close_stdout will catch it. */ + fwrite (b[!i] + READ_BUFSIZE, 1, n_elide - delta, stdout); + } + first = false; - if (n_elide < n_read - && fwrite (b[i], 1, n_read - n_elide, stdout) < n_read - n_elide) - { - error (0, errno, _("write error")); - ok = false; - break; - } - } + if (n_elide < n_read + && fwrite (b[i], 1, n_read - n_elide, stdout) < n_read - n_elide) + { + error (0, errno, _("write error")); + ok = false; + break; + } + } free (b[0]); return ok; @@ -310,7 +310,7 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0) else { /* Read blocks of size READ_BUFSIZE, until we've read at least n_elide - bytes. Then, for each new buffer we read, also write an old one. */ + bytes. Then, for each new buffer we read, also write an old one. */ bool ok = true; bool eof = false; @@ -326,74 +326,74 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0) buffered_enough = false; for (i = 0, i_next = 1; !eof; i = i_next, i_next = (i_next + 1) % n_bufs) - { - if (b[i] == NULL) - b[i] = xmalloc (READ_BUFSIZE); - n_read = full_read (fd, b[i], READ_BUFSIZE); - if (n_read < READ_BUFSIZE) - { - if (errno != 0) - { - error (0, errno, _("error reading %s"), quote (filename)); - ok = false; - goto free_mem; - } - eof = true; - } + { + if (b[i] == NULL) + b[i] = xmalloc (READ_BUFSIZE); + n_read = full_read (fd, b[i], READ_BUFSIZE); + if (n_read < READ_BUFSIZE) + { + if (errno != 0) + { + error (0, errno, _("error reading %s"), quote (filename)); + ok = false; + goto free_mem; + } + eof = true; + } - if (i + 1 == n_bufs) - buffered_enough = true; + if (i + 1 == n_bufs) + buffered_enough = true; - if (buffered_enough) - { - if (fwrite (b[i_next], 1, n_read, stdout) < n_read) - { - error (0, errno, _("write error")); - ok = false; - goto free_mem; - } - } - } + if (buffered_enough) + { + if (fwrite (b[i_next], 1, n_read, stdout) < n_read) + { + error (0, errno, _("write error")); + ok = false; + goto free_mem; + } + } + } /* Output any remainder: rem bytes from b[i] + n_read. */ if (rem) - { - if (buffered_enough) - { - size_t n_bytes_left_in_b_i = READ_BUFSIZE - n_read; - if (rem < n_bytes_left_in_b_i) - { - fwrite (b[i] + n_read, 1, rem, stdout); - } - else - { - fwrite (b[i] + n_read, 1, n_bytes_left_in_b_i, stdout); - fwrite (b[i_next], 1, rem - n_bytes_left_in_b_i, stdout); - } - } - else if (i + 1 == n_bufs) - { - /* This happens when n_elide < file_size < n_elide_round. + { + if (buffered_enough) + { + size_t n_bytes_left_in_b_i = READ_BUFSIZE - n_read; + if (rem < n_bytes_left_in_b_i) + { + fwrite (b[i] + n_read, 1, rem, stdout); + } + else + { + fwrite (b[i] + n_read, 1, n_bytes_left_in_b_i, stdout); + fwrite (b[i_next], 1, rem - n_bytes_left_in_b_i, stdout); + } + } + else if (i + 1 == n_bufs) + { + /* This happens when n_elide < file_size < n_elide_round. - |READ_BUF.| - | | rem | - |---------!---------!---------!---------| - |---- n_elide ---------| - | | x | - | |y | - |---- file size -----------| - | |n_read| - |---- n_elide_round ----------| - */ - size_t y = READ_BUFSIZE - rem; - size_t x = n_read - y; - fwrite (b[i_next], 1, x, stdout); - } - } + |READ_BUF.| + | | rem | + |---------!---------!---------!---------| + |---- n_elide ---------| + | | x | + | |y | + |---- file size -----------| + | |n_read| + |---- n_elide_round ----------| + */ + size_t y = READ_BUFSIZE - rem; + size_t x = n_read - y; + fwrite (b[i_next], 1, x, stdout); + } + } free_mem:; for (i = 0; i < n_bufs; i++) - free (b[i]); + free (b[i]); free (b); return ok; @@ -424,31 +424,31 @@ elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide) enum Copy_fd_status err; if ((current_pos = lseek (fd, (off_t) 0, SEEK_CUR)) == -1 - || (end_pos = lseek (fd, (off_t) 0, SEEK_END)) == -1) - { - error (0, errno, _("cannot lseek %s"), quote (filename)); - return false; - } + || (end_pos = lseek (fd, (off_t) 0, SEEK_END)) == -1) + { + error (0, errno, _("cannot lseek %s"), quote (filename)); + return false; + } /* Be careful here. The current position may actually be - beyond the end of the file. */ + beyond the end of the file. */ bytes_remaining = (diff = end_pos - current_pos) < 0 ? 0 : diff; if (bytes_remaining <= n_elide) - return true; + return true; /* Seek back to `current' position, then copy the required - number of bytes from fd. */ + number of bytes from fd. */ if (lseek (fd, (off_t) 0, current_pos) == -1) - { - error (0, errno, _("%s: cannot lseek back to original position"), - quote (filename)); - return false; - } + { + error (0, errno, _("%s: cannot lseek back to original position"), + quote (filename)); + return false; + } err = copy_fd (fd, stdout, bytes_remaining - n_elide); if (err == COPY_FD_OK) - return true; + return true; diagnose_copy_fd_failure (err, filename); return false; @@ -488,20 +488,20 @@ elide_tail_lines_pipe (const char *filename, int fd, uintmax_t n_elide) { n_read = safe_read (fd, tmp->buffer, BUFSIZ); if (n_read == 0 || n_read == SAFE_READ_ERROR) - break; + break; tmp->nbytes = n_read; tmp->nlines = 0; tmp->next = NULL; /* Count the number of newlines just read. */ { - char const *buffer_end = tmp->buffer + n_read; - char const *p = tmp->buffer; - while ((p = memchr (p, '\n', buffer_end - p))) - { - ++p; - ++tmp->nlines; - } + char const *buffer_end = tmp->buffer + n_read; + char const *p = tmp->buffer; + while ((p = memchr (p, '\n', buffer_end - p))) + { + ++p; + ++tmp->nlines; + } } total_lines += tmp->nlines; @@ -509,29 +509,29 @@ elide_tail_lines_pipe (const char *filename, int fd, uintmax_t n_elide) one to it. This is because when reading from a pipe, `n_read' can often be very small. */ if (tmp->nbytes + last->nbytes < BUFSIZ) - { - memcpy (&last->buffer[last->nbytes], tmp->buffer, tmp->nbytes); - last->nbytes += tmp->nbytes; - last->nlines += tmp->nlines; - } + { + memcpy (&last->buffer[last->nbytes], tmp->buffer, tmp->nbytes); + last->nbytes += tmp->nbytes; + last->nlines += tmp->nlines; + } else - { - /* If there's not enough room, link the new buffer onto the end of - the list, then either free up the oldest buffer for the next - read if that would leave enough lines, or else malloc a new one. - Some compaction mechanism is possible but probably not - worthwhile. */ - last = last->next = tmp; - if (n_elide < total_lines - first->nlines) - { - fwrite (first->buffer, 1, first->nbytes, stdout); - tmp = first; - total_lines -= first->nlines; - first = first->next; - } - else - tmp = xmalloc (sizeof (LBUFFER)); - } + { + /* If there's not enough room, link the new buffer onto the end of + the list, then either free up the oldest buffer for the next + read if that would leave enough lines, or else malloc a new one. + Some compaction mechanism is possible but probably not + worthwhile. */ + last = last->next = tmp; + if (n_elide < total_lines - first->nlines) + { + fwrite (first->buffer, 1, first->nbytes, stdout); + tmp = first; + total_lines -= first->nlines; + first = first->next; + } + else + tmp = xmalloc (sizeof (LBUFFER)); + } } free (tmp); @@ -564,11 +564,11 @@ elide_tail_lines_pipe (const char *filename, int fd, uintmax_t n_elide) char const *buffer_end = tmp->buffer + tmp->nbytes; char const *p = tmp->buffer; while (n && (p = memchr (p, '\n', buffer_end - p))) - { - ++p; - ++tmp->nlines; - --n; - } + { + ++p; + ++tmp->nlines; + --n; + } fwrite (tmp->buffer, 1, p - tmp->buffer, stdout); } @@ -595,8 +595,8 @@ free_lbuffers: in a less efficient implementation or a messy interface. */ static bool elide_tail_lines_seekable (const char *pretty_filename, int fd, - uintmax_t n_lines, - off_t start_pos, off_t end_pos) + uintmax_t n_lines, + off_t start_pos, off_t end_pos) { char buffer[BUFSIZ]; size_t bytes_read; @@ -614,7 +614,7 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd, { char offset_buf[INT_BUFSIZE_BOUND (off_t)]; error (0, errno, _("%s: cannot seek to offset %s"), - pretty_filename, offtostr (pos, offset_buf)); + pretty_filename, offtostr (pos, offset_buf)); return false; } bytes_read = safe_read (fd, buffer, bytes_read); @@ -634,72 +634,72 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd, size_t n = bytes_read; while (n) - { - char const *nl; - nl = memrchr (buffer, '\n', n); - if (nl == NULL) - break; - n = nl - buffer; - if (n_lines-- == 0) - { - /* Found it. */ - /* If necessary, restore the file pointer and copy - input to output up to position, POS. */ - if (start_pos < pos) - { - enum Copy_fd_status err; - if (lseek (fd, start_pos, SEEK_SET) < 0) - { - /* Failed to reposition file pointer. */ - error (0, errno, - "%s: unable to restore file pointer to initial offset", - quote (pretty_filename)); - return false; - } + { + char const *nl; + nl = memrchr (buffer, '\n', n); + if (nl == NULL) + break; + n = nl - buffer; + if (n_lines-- == 0) + { + /* Found it. */ + /* If necessary, restore the file pointer and copy + input to output up to position, POS. */ + if (start_pos < pos) + { + enum Copy_fd_status err; + if (lseek (fd, start_pos, SEEK_SET) < 0) + { + /* Failed to reposition file pointer. */ + error (0, errno, + "%s: unable to restore file pointer to initial offset", + quote (pretty_filename)); + return false; + } - err = copy_fd (fd, stdout, pos - start_pos); - if (err != COPY_FD_OK) - { - diagnose_copy_fd_failure (err, pretty_filename); - return false; - } - } + err = copy_fd (fd, stdout, pos - start_pos); + if (err != COPY_FD_OK) + { + diagnose_copy_fd_failure (err, pretty_filename); + return false; + } + } - /* Output the initial portion of the buffer - in which we found the desired newline byte. - Don't bother testing for failure for such a small amount. - Any failure will be detected upon close. */ - fwrite (buffer, 1, n + 1, stdout); - return true; - } - } + /* Output the initial portion of the buffer + in which we found the desired newline byte. + Don't bother testing for failure for such a small amount. + Any failure will be detected upon close. */ + fwrite (buffer, 1, n + 1, stdout); + return true; + } + } /* Not enough newlines in that bufferfull. */ if (pos == start_pos) - { - /* Not enough lines in the file. */ - return true; - } + { + /* Not enough lines in the file. */ + return true; + } pos -= BUFSIZ; if (lseek (fd, pos, SEEK_SET) < 0) - { - char offset_buf[INT_BUFSIZE_BOUND (off_t)]; - error (0, errno, _("%s: cannot seek to offset %s"), - pretty_filename, offtostr (pos, offset_buf)); - return false; - } + { + char offset_buf[INT_BUFSIZE_BOUND (off_t)]; + error (0, errno, _("%s: cannot seek to offset %s"), + pretty_filename, offtostr (pos, offset_buf)); + return false; + } bytes_read = safe_read (fd, buffer, BUFSIZ); if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, _("error reading %s"), quote (pretty_filename)); - return false; - } + { + error (0, errno, _("error reading %s"), quote (pretty_filename)); + return false; + } /* FIXME: is this dead code? - Consider the test, pos == start_pos, above. */ + Consider the test, pos == start_pos, above. */ if (bytes_read == 0) - return true; + return true; } } @@ -713,24 +713,24 @@ elide_tail_lines_file (const char *filename, int fd, uintmax_t n_elide) if (!presume_input_pipe) { /* Find the offset, OFF, of the Nth newline from the end, - but not counting the last byte of the file. - If found, write from current position to OFF, inclusive. - Otherwise, just return true. */ + but not counting the last byte of the file. + If found, write from current position to OFF, inclusive. + Otherwise, just return true. */ off_t start_pos = lseek (fd, (off_t) 0, SEEK_CUR); off_t end_pos = lseek (fd, (off_t) 0, SEEK_END); if (0 <= start_pos && start_pos < end_pos) - { - /* If the file is empty, we're done. */ - if (end_pos == 0) - return true; + { + /* If the file is empty, we're done. */ + if (end_pos == 0) + return true; - return elide_tail_lines_seekable (filename, fd, n_elide, - start_pos, end_pos); - } + return elide_tail_lines_seekable (filename, fd, n_elide, + start_pos, end_pos); + } /* lseek failed or the end offset precedes start. - Fall through. */ + Fall through. */ } return elide_tail_lines_pipe (filename, fd, n_elide); @@ -746,17 +746,17 @@ head_bytes (const char *filename, int fd, uintmax_t bytes_to_write) { size_t bytes_read; if (bytes_to_write < bytes_to_read) - bytes_to_read = bytes_to_write; + bytes_to_read = bytes_to_write; bytes_read = safe_read (fd, buffer, bytes_to_read); if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, _("error reading %s"), quote (filename)); - return false; - } + { + error (0, errno, _("error reading %s"), quote (filename)); + return false; + } if (bytes_read == 0) - break; + break; if (fwrite (buffer, 1, bytes_read, stdout) < bytes_read) - error (EXIT_FAILURE, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); bytes_to_write -= bytes_read; } return true; @@ -773,31 +773,31 @@ head_lines (const char *filename, int fd, uintmax_t lines_to_write) size_t bytes_to_write = 0; if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, _("error reading %s"), quote (filename)); - return false; - } + { + error (0, errno, _("error reading %s"), quote (filename)); + return false; + } if (bytes_read == 0) - break; + break; while (bytes_to_write < bytes_read) - if (buffer[bytes_to_write++] == '\n' && --lines_to_write == 0) - { - off_t n_bytes_past_EOL = bytes_read - bytes_to_write; - /* If we have read more data than that on the specified number - of lines, try to seek back to the position we would have - gotten to had we been reading one byte at a time. */ - if (lseek (fd, -n_bytes_past_EOL, SEEK_CUR) < 0) - { - int e = errno; - struct stat st; - if (fstat (fd, &st) != 0 || S_ISREG (st.st_mode)) - error (0, e, _("cannot reposition file pointer for %s"), - quote (filename)); - } - break; - } + if (buffer[bytes_to_write++] == '\n' && --lines_to_write == 0) + { + off_t n_bytes_past_EOL = bytes_read - bytes_to_write; + /* If we have read more data than that on the specified number + of lines, try to seek back to the position we would have + gotten to had we been reading one byte at a time. */ + if (lseek (fd, -n_bytes_past_EOL, SEEK_CUR) < 0) + { + int e = errno; + struct stat st; + if (fstat (fd, &st) != 0 || S_ISREG (st.st_mode)) + error (0, e, _("cannot reposition file pointer for %s"), + quote (filename)); + } + break; + } if (fwrite (buffer, 1, bytes_to_write, stdout) < bytes_to_write) - error (EXIT_FAILURE, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); } return true; } @@ -812,13 +812,13 @@ head (const char *filename, int fd, uintmax_t n_units, bool count_lines, if (elide_from_end) { if (count_lines) - { - return elide_tail_lines_file (filename, fd, n_units); - } + { + return elide_tail_lines_file (filename, fd, n_units); + } else - { - return elide_tail_bytes_file (filename, fd, n_units); - } + { + return elide_tail_bytes_file (filename, fd, n_units); + } } if (count_lines) return head_lines (filename, fd, n_units); @@ -828,7 +828,7 @@ head (const char *filename, int fd, uintmax_t n_units, bool count_lines, static bool head_file (const char *filename, uintmax_t n_units, bool count_lines, - bool elide_from_end) + bool elide_from_end) { int fd; bool ok; @@ -840,16 +840,16 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines, fd = STDIN_FILENO; filename = _("standard input"); if (O_BINARY && ! isatty (STDIN_FILENO)) - xfreopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { fd = open (filename, O_RDONLY | O_BINARY); if (fd < 0) - { - error (0, errno, _("cannot open %s for reading"), quote (filename)); - return false; - } + { + error (0, errno, _("cannot open %s for reading"), quote (filename)); + return false; + } } ok = head (filename, fd, n_units, count_lines, elide_from_end); @@ -878,16 +878,16 @@ string_to_integer (bool count_lines, const char *n_string) if (s_err == LONGINT_OVERFLOW) { error (EXIT_FAILURE, 0, - _("%s: %s is so large that it is not representable"), n_string, - count_lines ? _("number of lines") : _("number of bytes")); + _("%s: %s is so large that it is not representable"), n_string, + count_lines ? _("number of lines") : _("number of bytes")); } if (s_err != LONGINT_OK) { error (EXIT_FAILURE, 0, "%s: %s", n_string, - (count_lines - ? _("invalid number of lines") - : _("invalid number of bytes"))); + (count_lines + ? _("invalid number of lines") + : _("invalid number of bytes"))); } return n; @@ -937,7 +937,7 @@ main (int argc, char **argv) char multiplier_char = 0; /* Old option syntax; a dash, one or more digits, and one or - more option letters. Move past the number. */ + more option letters. Move past the number. */ do ++a; while (ISDIGIT (*a)); @@ -946,44 +946,44 @@ main (int argc, char **argv) /* Parse any appended option letters. */ for (; *a; a++) - { - switch (*a) - { - case 'c': - count_lines = false; - multiplier_char = 0; - break; + { + switch (*a) + { + case 'c': + count_lines = false; + multiplier_char = 0; + break; - case 'b': - case 'k': - case 'm': - count_lines = false; - multiplier_char = *a; - break; + case 'b': + case 'k': + case 'm': + count_lines = false; + multiplier_char = *a; + break; - case 'l': - count_lines = true; - break; + case 'l': + count_lines = true; + break; - case 'q': - header_mode = never; - break; + case 'q': + header_mode = never; + break; - case 'v': - header_mode = always; - break; + case 'v': + header_mode = always; + break; - default: - error (0, 0, _("invalid trailing option -- %c"), *a); - usage (EXIT_FAILURE); - } - } + default: + error (0, 0, _("invalid trailing option -- %c"), *a); + usage (EXIT_FAILURE); + } + } /* Append the multiplier character (if any) onto the end of - the digit string. Then add NUL byte if necessary. */ + the digit string. Then add NUL byte if necessary. */ *end_n_string = multiplier_char; if (multiplier_char) - *(++end_n_string) = 0; + *(++end_n_string) = 0; n_units = string_to_integer (count_lines, n_string); @@ -994,47 +994,47 @@ main (int argc, char **argv) } while ((c = getopt_long (argc, argv, "c:n:qv0123456789", long_options, NULL)) - != -1) + != -1) { switch (c) - { - case PRESUME_INPUT_PIPE_OPTION: - presume_input_pipe = true; - break; + { + case PRESUME_INPUT_PIPE_OPTION: + presume_input_pipe = true; + break; - case 'c': - count_lines = false; - elide_from_end = (*optarg == '-'); - if (elide_from_end) - ++optarg; - n_units = string_to_integer (count_lines, optarg); - break; + case 'c': + count_lines = false; + elide_from_end = (*optarg == '-'); + if (elide_from_end) + ++optarg; + n_units = string_to_integer (count_lines, optarg); + break; - case 'n': - count_lines = true; - elide_from_end = (*optarg == '-'); - if (elide_from_end) - ++optarg; - n_units = string_to_integer (count_lines, optarg); - break; + case 'n': + count_lines = true; + elide_from_end = (*optarg == '-'); + if (elide_from_end) + ++optarg; + n_units = string_to_integer (count_lines, optarg); + break; - case 'q': - header_mode = never; - break; + case 'q': + header_mode = never; + break; - case 'v': - header_mode = always; - break; + case 'v': + header_mode = always; + break; - case_GETOPT_HELP_CHAR; + case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - if (ISDIGIT (c)) - error (0, 0, _("invalid trailing option -- %c"), c); - usage (EXIT_FAILURE); - } + default: + if (ISDIGIT (c)) + error (0, 0, _("invalid trailing option -- %c"), c); + usage (EXIT_FAILURE); + } } if (header_mode == always @@ -1045,12 +1045,12 @@ main (int argc, char **argv) { char umax_buf[INT_BUFSIZE_BOUND (uintmax_t)]; error (EXIT_FAILURE, 0, _("%s: number of bytes is too large"), - umaxtostr (n_units, umax_buf)); + umaxtostr (n_units, umax_buf)); } file_list = (optind < argc - ? (char const *const *) &argv[optind] - : default_file_list); + ? (char const *const *) &argv[optind] + : default_file_list); if (O_BINARY && ! isatty (STDOUT_FILENO)) xfreopen (NULL, "wb", stdout); diff --git a/src/bin/coreutils/src/hostid.c b/src/bin/coreutils/src/hostid.c index 1da5a0c5ce..7c93f2e768 100644 --- a/src/bin/coreutils/src/hostid.c +++ b/src/bin/coreutils/src/hostid.c @@ -38,7 +38,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -67,7 +67,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/hostname.c b/src/bin/coreutils/src/hostname.c index 6572b320dd..110014b3fc 100644 --- a/src/bin/coreutils/src/hostname.c +++ b/src/bin/coreutils/src/hostname.c @@ -51,7 +51,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -82,7 +82,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); @@ -92,10 +92,10 @@ main (int argc, char **argv) /* Set hostname to operand. */ char const *name = argv[optind]; if (sethostname (name, strlen (name)) != 0) - error (EXIT_FAILURE, errno, _("cannot set name to %s"), quote (name)); + error (EXIT_FAILURE, errno, _("cannot set name to %s"), quote (name)); #else error (EXIT_FAILURE, 0, - _("cannot set hostname; this system lacks the functionality")); + _("cannot set hostname; this system lacks the functionality")); #endif } @@ -103,7 +103,7 @@ main (int argc, char **argv) { hostname = xgethostname (); if (hostname == NULL) - error (EXIT_FAILURE, errno, _("cannot determine hostname")); + error (EXIT_FAILURE, errno, _("cannot determine hostname")); printf ("%s\n", hostname); } diff --git a/src/bin/coreutils/src/id.c b/src/bin/coreutils/src/id.c index 78f78e058f..b28643b18a 100644 --- a/src/bin/coreutils/src/id.c +++ b/src/bin/coreutils/src/id.c @@ -76,7 +76,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... [USERNAME]\n"), program_name); @@ -129,39 +129,39 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "agnruGZ", longopts, NULL)) != -1) { switch (optc) - { - case 'a': - /* Ignore -a, for compatibility with SVR4. */ - break; + { + case 'a': + /* Ignore -a, for compatibility with SVR4. */ + break; case 'Z': - /* politely decline if we're not on a selinux-enabled kernel. */ - if (!selinux_enabled) - error (EXIT_FAILURE, 0, - _("--context (-Z) works only on an SELinux-enabled kernel")); + /* politely decline if we're not on a selinux-enabled kernel. */ + if (!selinux_enabled) + error (EXIT_FAILURE, 0, + _("--context (-Z) works only on an SELinux-enabled kernel")); just_context = 1; break; - case 'g': - just_group = true; - break; - case 'n': - use_name = true; - break; - case 'r': - use_real = true; - break; - case 'u': - just_user = true; - break; - case 'G': - just_group_list = true; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + case 'g': + just_group = true; + break; + case 'n': + use_name = true; + break; + case 'r': + use_real = true; + break; + case 'u': + just_user = true; + break; + case 'G': + just_group_list = true; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (1 < argc - optind) @@ -172,7 +172,7 @@ main (int argc, char **argv) if (argc - optind == 1 && just_context) error (EXIT_FAILURE, 0, - _("cannot print security context when user specified")); + _("cannot print security context when user specified")); /* If we are on a selinux-enabled kernel and no user is specified, get our context. Otherwise, leave the context variable alone - @@ -189,13 +189,13 @@ main (int argc, char **argv) if (just_user + just_group + just_group_list == 0 && (use_real | use_name)) error (EXIT_FAILURE, 0, - _("cannot print only names or real IDs in default format")); + _("cannot print only names or real IDs in default format")); if (argc - optind == 1) { struct passwd *pwd = getpwnam (argv[optind]); if (pwd == NULL) - error (EXIT_FAILURE, 0, _("%s: No such user"), argv[optind]); + error (EXIT_FAILURE, 0, _("%s: No such user"), argv[optind]); ruid = euid = pwd->pw_uid; rgid = egid = pwd->pw_gid; } @@ -214,12 +214,12 @@ main (int argc, char **argv) else if (just_group) { if (!print_group (use_real ? rgid : egid, use_name)) - ok = false; + ok = false; } else if (just_group_list) { if (!print_group_list (argv[optind], ruid, rgid, egid, use_name)) - ok = false; + ok = false; } else if (just_context) { @@ -245,11 +245,11 @@ print_user (uid_t uid) { pwd = getpwuid (uid); if (pwd == NULL) - { - error (0, 0, _("cannot find name for user ID %lu"), - (unsigned long int) uid); - ok = false; - } + { + error (0, 0, _("cannot find name for user ID %lu"), + (unsigned long int) uid); + ok = false; + } } if (pwd == NULL) @@ -281,7 +281,7 @@ print_full_info (const char *username) printf (_(" euid=%lu"), (unsigned long int) euid); pwd = getpwuid (euid); if (pwd) - printf ("(%s)", pwd->pw_name); + printf ("(%s)", pwd->pw_name); } if (egid != rgid) @@ -289,7 +289,7 @@ print_full_info (const char *username) printf (_(" egid=%lu"), (unsigned long int) egid); grp = getgrgid (egid); if (grp) - printf ("(%s)", grp->gr_name); + printf ("(%s)", grp->gr_name); } #if HAVE_GETGROUPS @@ -298,32 +298,32 @@ print_full_info (const char *username) int i; int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1), - &groups); + &groups); if (n_groups < 0) { - if (username) - { - error (0, errno, _("failed to get groups for user %s"), - quote (username)); - } - else - { - error (0, errno, _("failed to get groups for the current process")); - } - ok = false; - return; + if (username) + { + error (0, errno, _("failed to get groups for user %s"), + quote (username)); + } + else + { + error (0, errno, _("failed to get groups for the current process")); + } + ok = false; + return; } if (n_groups > 0) fputs (_(" groups="), stdout); for (i = 0; i < n_groups; i++) { - if (i > 0) - putchar (','); - printf ("%lu", (unsigned long int) groups[i]); - grp = getgrgid (groups[i]); - if (grp) - printf ("(%s)", grp->gr_name); + if (i > 0) + putchar (','); + printf ("%lu", (unsigned long int) groups[i]); + grp = getgrgid (groups[i]); + if (grp) + printf ("(%s)", grp->gr_name); } free (groups); } diff --git a/src/bin/coreutils/src/install.c b/src/bin/coreutils/src/install.c index 19efb1d1bc..fafa21a3cf 100644 --- a/src/bin/coreutils/src/install.c +++ b/src/bin/coreutils/src/install.c @@ -74,18 +74,18 @@ static bool use_default_selinux_context = true; static bool change_timestamps (struct stat const *from_sb, char const *to); static bool change_attributes (char const *name); static bool copy_file (const char *from, const char *to, - const struct cp_options *x); + const struct cp_options *x); static bool install_file_in_file_parents (char const *from, char *to, - struct cp_options *x); + struct cp_options *x); static bool install_file_in_dir (const char *from, const char *to_dir, - const struct cp_options *x); + const struct cp_options *x); static bool install_file_in_file (const char *from, const char *to, - const struct cp_options *x); + const struct cp_options *x); static void get_ids (void); static void strip (char const *name); static void announce_mkdir (char const *dir, void *options); static int make_ancestor (char const *dir, char const *component, - void *options); + void *options); void usage (int status); /* The user name that will own the files, or NULL to make the owner @@ -195,7 +195,7 @@ extra_mode (mode_t input) /* Return true if copy of file SRC_NAME to file DEST_NAME is necessary. */ static bool need_copy (const char *src_name, const char *dest_name, - const struct cp_options *x) + const struct cp_options *x) { struct stat src_sb, dest_sb; int src_fd, dest_fd; @@ -229,20 +229,20 @@ need_copy (const char *src_name, const char *dest_name, bool scontext_match; if (getfilecon (src_name, &file_scontext) == -1) - return true; + return true; if (getfilecon (dest_name, &to_scontext) == -1) - { - freecon (file_scontext); - return true; - } + { + freecon (file_scontext); + return true; + } scontext_match = STREQ (file_scontext, to_scontext); freecon (file_scontext); freecon (to_scontext); if (!scontext_match) - return true; + return true; } /* compare files content */ @@ -269,7 +269,7 @@ cp_option_init (struct cp_options *x) { cp_options_default (x); x->copy_as_regular = true; - x->reflink = false; + x->reflink_mode = REFLINK_NEVER; x->dereference = DEREF_ALWAYS; x->unlink_dest_before_opening = true; x->unlink_dest_after_failed_open = false; @@ -328,37 +328,37 @@ setdefaultfilecon (char const *file) if (first_call && IS_ABSOLUTE_FILE_NAME (file)) { /* Calling matchpathcon_init_prefix (NULL, "/first_component/") - is an optimization to minimize the expense of the following - matchpathcon call. Do it only once, just before the first - matchpathcon call. We *could* call matchpathcon_fini after - the final matchpathcon call, but that's not necessary, since - by then we're about to exit, and besides, the buffers it - would free are still reachable. */ + is an optimization to minimize the expense of the following + matchpathcon call. Do it only once, just before the first + matchpathcon call. We *could* call matchpathcon_fini after + the final matchpathcon call, but that's not necessary, since + by then we're about to exit, and besides, the buffers it + would free are still reachable. */ char const *p0; char const *p = file + 1; while (ISSLASH (*p)) - ++p; + ++p; /* Record final leading slash, for when FILE starts with two or more. */ p0 = p - 1; if (*p) - { - char *prefix; - do - { - ++p; - } - while (*p && !ISSLASH (*p)); + { + char *prefix; + do + { + ++p; + } + while (*p && !ISSLASH (*p)); - prefix = malloc (p - p0 + 2); - if (prefix) - { - stpcpy (stpncpy (prefix, p0, p - p0), "/"); - matchpathcon_init_prefix (NULL, prefix); - free (prefix); - } - } + prefix = malloc (p - p0 + 2); + if (prefix) + { + stpcpy (stpncpy (prefix, p0, p - p0), "/"); + matchpathcon_init_prefix (NULL, prefix); + free (prefix); + } + } } first_call = false; @@ -368,14 +368,14 @@ setdefaultfilecon (char const *file) STREQ (scontext, "<>")) { if (scontext != NULL) - freecon (scontext); + freecon (scontext); return; } if (lsetfilecon (file, scontext) < 0 && errno != ENOTSUP) error (0, errno, - _("warning: %s: failed to change context to %s"), - quotearg_colon (file), scontext); + _("warning: %s: failed to change context to %s"), + quotearg_colon (file), scontext); freecon (scontext); return; @@ -414,11 +414,11 @@ static int process_dir (char *dir, struct savewd *wd, void *options) { return (make_dir_parents (dir, wd, - make_ancestor, options, - dir_mode, announce_mkdir, - dir_mode_bits, owner_id, group_id, false) - ? EXIT_SUCCESS - : EXIT_FAILURE); + make_ancestor, options, + dir_mode, announce_mkdir, + dir_mode_bits, owner_id, group_id, false) + ? EXIT_SUCCESS + : EXIT_FAILURE); } int @@ -462,131 +462,131 @@ main (int argc, char **argv) backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX"); while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z:", long_options, - NULL)) != -1) + NULL)) != -1) { switch (optc) - { - case 'b': - make_backups = true; - if (optarg) - version_control_string = optarg; - break; - case 'c': - break; - case 'C': - copy_only_if_needed = true; - break; - case 's': - strip_files = true; + { + case 'b': + make_backups = true; + if (optarg) + version_control_string = optarg; + break; + case 'c': + break; + case 'C': + copy_only_if_needed = true; + break; + case 's': + strip_files = true; #ifdef SIGCHLD - /* System V fork+wait does not work if SIGCHLD is ignored. */ - signal (SIGCHLD, SIG_DFL); + /* System V fork+wait does not work if SIGCHLD is ignored. */ + signal (SIGCHLD, SIG_DFL); #endif - break; - case STRIP_PROGRAM_OPTION: - strip_program = xstrdup (optarg); - strip_program_specified = true; - break; - case 'd': - dir_arg = true; - break; - case 'D': - mkdir_and_install = true; - break; - case 'v': - x.verbose = true; - break; - case 'g': - group_name = optarg; - break; - case 'm': - specified_mode = optarg; - break; - case 'o': - owner_name = optarg; - break; - case 'p': - x.preserve_timestamps = true; - break; - case 'S': - make_backups = true; - backup_suffix_string = optarg; - break; - case 't': - if (target_directory) - error (EXIT_FAILURE, 0, - _("multiple target directories specified")); - else - { - struct stat st; - if (stat (optarg, &st) != 0) - error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg)); - if (! S_ISDIR (st.st_mode)) - error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (optarg)); - } - target_directory = optarg; - break; - case 'T': - no_target_directory = true; - break; + break; + case STRIP_PROGRAM_OPTION: + strip_program = xstrdup (optarg); + strip_program_specified = true; + break; + case 'd': + dir_arg = true; + break; + case 'D': + mkdir_and_install = true; + break; + case 'v': + x.verbose = true; + break; + case 'g': + group_name = optarg; + break; + case 'm': + specified_mode = optarg; + break; + case 'o': + owner_name = optarg; + break; + case 'p': + x.preserve_timestamps = true; + break; + case 'S': + make_backups = true; + backup_suffix_string = optarg; + break; + case 't': + if (target_directory) + error (EXIT_FAILURE, 0, + _("multiple target directories specified")); + else + { + struct stat st; + if (stat (optarg, &st) != 0) + error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg)); + if (! S_ISDIR (st.st_mode)) + error (EXIT_FAILURE, 0, _("target %s is not a directory"), + quote (optarg)); + } + target_directory = optarg; + break; + case 'T': + no_target_directory = true; + break; - case PRESERVE_CONTEXT_OPTION_DEPRECATED: - error (0, 0, _("WARNING: --preserve_context is deprecated; " - "use --preserve-context instead")); - /* fall through */ - case PRESERVE_CONTEXT_OPTION: - if ( ! selinux_enabled) - { - error (0, 0, _("WARNING: ignoring --preserve-context; " - "this kernel is not SELinux-enabled")); - break; - } - x.preserve_security_context = true; - use_default_selinux_context = false; - break; - case 'Z': - if ( ! selinux_enabled) - { - error (0, 0, _("WARNING: ignoring --context (-Z); " - "this kernel is not SELinux-enabled")); - break; - } - scontext = optarg; - use_default_selinux_context = false; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + case PRESERVE_CONTEXT_OPTION_DEPRECATED: + error (0, 0, _("WARNING: --preserve_context is deprecated; " + "use --preserve-context instead")); + /* fall through */ + case PRESERVE_CONTEXT_OPTION: + if ( ! selinux_enabled) + { + error (0, 0, _("WARNING: ignoring --preserve-context; " + "this kernel is not SELinux-enabled")); + break; + } + x.preserve_security_context = true; + use_default_selinux_context = false; + break; + case 'Z': + if ( ! selinux_enabled) + { + error (0, 0, _("WARNING: ignoring --context (-Z); " + "this kernel is not SELinux-enabled")); + break; + } + scontext = optarg; + use_default_selinux_context = false; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } /* Check for invalid combinations of arguments. */ if (dir_arg & strip_files) error (EXIT_FAILURE, 0, - _("the strip option may not be used when installing a directory")); + _("the strip option may not be used when installing a directory")); if (dir_arg && target_directory) error (EXIT_FAILURE, 0, - _("target directory not allowed when installing a directory")); + _("target directory not allowed when installing a directory")); if (x.preserve_security_context && scontext != NULL) error (EXIT_FAILURE, 0, - _("cannot force target context to %s and preserve it"), - quote (scontext)); + _("cannot force target context to %s and preserve it"), + quote (scontext)); if (backup_suffix_string) simple_backup_suffix = xstrdup (backup_suffix_string); x.backup_type = (make_backups - ? xget_version (_("backup type"), - version_control_string) - : no_backups); + ? xget_version (_("backup type"), + version_control_string) + : no_backups); if (scontext && setfscreatecon (scontext) < 0) error (EXIT_FAILURE, errno, - _("failed to set default file creation context to %s"), - quote (scontext)); + _("failed to set default file creation context to %s"), + quote (scontext)); n_files = argc - optind; file = argv + optind; @@ -594,39 +594,39 @@ main (int argc, char **argv) if (n_files <= ! (dir_arg || target_directory)) { if (n_files <= 0) - error (0, 0, _("missing file operand")); + error (0, 0, _("missing file operand")); else - error (0, 0, _("missing destination file operand after %s"), - quote (file[0])); + error (0, 0, _("missing destination file operand after %s"), + quote (file[0])); usage (EXIT_FAILURE); } if (no_target_directory) { if (target_directory) - error (EXIT_FAILURE, 0, - _("cannot combine --target-directory (-t) " - "and --no-target-directory (-T)")); + error (EXIT_FAILURE, 0, + _("cannot combine --target-directory (-t) " + "and --no-target-directory (-T)")); if (2 < n_files) - { - error (0, 0, _("extra operand %s"), quote (file[2])); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("extra operand %s"), quote (file[2])); + usage (EXIT_FAILURE); + } } else if (! (dir_arg || target_directory)) { if (2 <= n_files && target_directory_operand (file[n_files - 1])) - target_directory = file[--n_files]; + target_directory = file[--n_files]; else if (2 < n_files) - error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (file[n_files - 1])); + error (EXIT_FAILURE, 0, _("target %s is not a directory"), + quote (file[n_files - 1])); } if (specified_mode) { struct mode_change *change = mode_compile (specified_mode); if (!change) - error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode)); + error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode)); mode = mode_adjust (0, false, 0, change, NULL); dir_mode = mode_adjust (0, true, 0, change, &dir_mode_bits); free (change); @@ -634,25 +634,25 @@ main (int argc, char **argv) if (strip_program_specified && !strip_files) error (0, 0, _("WARNING: ignoring --strip-program option as -s option was " - "not specified")); + "not specified")); if (copy_only_if_needed && x.preserve_timestamps) { error (0, 0, _("options --compare (-C) and --preserve-timestamps are " - "mutually exclusive")); + "mutually exclusive")); usage (EXIT_FAILURE); } if (copy_only_if_needed && strip_files) { error (0, 0, _("options --compare (-C) and --strip are mutually " - "exclusive")); + "exclusive")); usage (EXIT_FAILURE); } if (copy_only_if_needed && extra_mode (mode)) error (0, 0, _("the --compare (-C) option is ignored when you" - " specify a mode with non-permission bits")); + " specify a mode with non-permission bits")); get_ids (); @@ -661,24 +661,24 @@ main (int argc, char **argv) else { /* FIXME: it's a little gross that this initialization is - required by copy.c::copy. */ + required by copy.c::copy. */ hash_init (); if (!target_directory) { if (! (mkdir_and_install - ? install_file_in_file_parents (file[0], file[1], &x) - : install_file_in_file (file[0], file[1], &x))) - exit_status = EXIT_FAILURE; - } + ? install_file_in_file_parents (file[0], file[1], &x) + : install_file_in_file (file[0], file[1], &x))) + exit_status = EXIT_FAILURE; + } else - { - int i; - dest_info_init (&x); - for (i = 0; i < n_files; i++) - if (! install_file_in_dir (file[i], target_directory, &x)) - exit_status = EXIT_FAILURE; - } + { + int i; + dest_info_init (&x); + for (i = 0; i < n_files; i++) + if (! install_file_in_dir (file[i], target_directory, &x)) + exit_status = EXIT_FAILURE; + } } exit (exit_status); @@ -689,7 +689,7 @@ main (int argc, char **argv) static bool install_file_in_file_parents (char const *from, char *to, - struct cp_options *x) + struct cp_options *x) { bool save_working_directory = ! (IS_ABSOLUTE_FILE_NAME (from) && IS_ABSOLUTE_FILE_NAME (to)); @@ -712,12 +712,12 @@ install_file_in_file_parents (char const *from, char *to, int restore_errno = errno; savewd_finish (&wd); if (EXIT_SUCCESS < restore_result) - return false; + return false; if (restore_result < 0 && status == EXIT_SUCCESS) - { - error (0, restore_errno, _("cannot create directory %s"), to); - return false; - } + { + error (0, restore_errno, _("cannot create directory %s"), to); + return false; + } } return (status == EXIT_SUCCESS && install_file_in_file (from, to, x)); @@ -729,7 +729,7 @@ install_file_in_file_parents (char const *from, char *to, static bool install_file_in_file (const char *from, const char *to, - const struct cp_options *x) + const struct cp_options *x) { struct stat from_sb; if (x->preserve_timestamps && stat (from, &from_sb) != 0) @@ -753,7 +753,7 @@ install_file_in_file (const char *from, const char *to, static bool install_file_in_dir (const char *from, const char *to_dir, - const struct cp_options *x) + const struct cp_options *x) { const char *from_base = last_component (from); char *to = file_name_concat (to_dir, from_base, NULL); @@ -856,9 +856,9 @@ strip (char const *name) break; default: /* Parent. */ if (waitpid (pid, &status, 0) < 0) - error (EXIT_FAILURE, errno, _("waiting for strip")); + error (EXIT_FAILURE, errno, _("waiting for strip")); else if (! WIFEXITED (status) || WEXITSTATUS (status)) - error (EXIT_FAILURE, 0, _("strip process terminated abnormally")); + error (EXIT_FAILURE, 0, _("strip process terminated abnormally")); break; } } @@ -875,15 +875,15 @@ get_ids (void) { pw = getpwnam (owner_name); if (pw == NULL) - { - unsigned long int tmp; - if (xstrtoul (owner_name, NULL, 0, &tmp, NULL) != LONGINT_OK - || UID_T_MAX < tmp) - error (EXIT_FAILURE, 0, _("invalid user %s"), quote (owner_name)); - owner_id = tmp; - } + { + unsigned long int tmp; + if (xstrtoul (owner_name, NULL, 0, &tmp, NULL) != LONGINT_OK + || UID_T_MAX < tmp) + error (EXIT_FAILURE, 0, _("invalid user %s"), quote (owner_name)); + owner_id = tmp; + } else - owner_id = pw->pw_uid; + owner_id = pw->pw_uid; endpwent (); } else @@ -893,15 +893,15 @@ get_ids (void) { gr = getgrnam (group_name); if (gr == NULL) - { - unsigned long int tmp; - if (xstrtoul (group_name, NULL, 0, &tmp, NULL) != LONGINT_OK - || GID_T_MAX < tmp) - error (EXIT_FAILURE, 0, _("invalid group %s"), quote (group_name)); - group_id = tmp; - } + { + unsigned long int tmp; + if (xstrtoul (group_name, NULL, 0, &tmp, NULL) != LONGINT_OK + || GID_T_MAX < tmp) + error (EXIT_FAILURE, 0, _("invalid group %s"), quote (group_name)); + group_id = tmp; + } else - group_id = gr->gr_gid; + group_id = gr->gr_gid; endgrent (); } else @@ -934,7 +934,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -943,7 +943,7 @@ Usage: %s [OPTION]... [-T] SOURCE DEST\n\ or: %s [OPTION]... -t DIRECTORY SOURCE...\n\ or: %s [OPTION]... -d DIRECTORY...\n\ "), - program_name, program_name, program_name, program_name); + program_name, program_name, program_name, program_name); fputs (_("\ \n\ This install program copies files (often just compiled) into destination\n\ diff --git a/src/bin/coreutils/src/join.c b/src/bin/coreutils/src/join.c index 756a7be6e7..73e1f37bb4 100644 --- a/src/bin/coreutils/src/join.c +++ b/src/bin/coreutils/src/join.c @@ -161,13 +161,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... FILE1 FILE2\n\ "), - program_name); + program_name); fputs (_("\ For each pair of input lines with identical join fields, write a line to\n\ standard output. The default join field is the first, delimited\n\ @@ -242,26 +242,26 @@ xfields (struct line *line) { char *sep; for (; (sep = memchr (ptr, tab, lim - ptr)) != NULL; ptr = sep + 1) - extract_field (line, ptr, sep - ptr); + extract_field (line, ptr, sep - ptr); } else { /* Skip leading blanks before the first field. */ while (isblank (to_uchar (*ptr))) - if (++ptr == lim) - return; + if (++ptr == lim) + return; do - { - char *sep; - for (sep = ptr + 1; sep != lim && ! isblank (to_uchar (*sep)); sep++) - continue; - extract_field (line, ptr, sep - ptr); - if (sep == lim) - return; - for (ptr = sep + 1; ptr != lim && isblank (to_uchar (*ptr)); ptr++) - continue; - } + { + char *sep; + for (sep = ptr + 1; sep != lim && ! isblank (to_uchar (*sep)); sep++) + continue; + extract_field (line, ptr, sep - ptr); + if (sep == lim) + return; + for (ptr = sep + 1; ptr != lim && isblank (to_uchar (*ptr)); ptr++) + continue; + } while (ptr != lim); } @@ -283,7 +283,7 @@ freeline (struct line *line) static int keycmp (struct line const *line1, struct line const *line2, - size_t jf_1, size_t jf_2) + size_t jf_1, size_t jf_2) { /* Start of field to compare in each file. */ char *beg1; @@ -329,7 +329,7 @@ keycmp (struct line const *line1, struct line const *line2, else { if (hard_LC_COLLATE) - return xmemcoll (beg1, len1, beg2, len2); + return xmemcoll (beg1, len1, beg2, len2); diff = memcmp (beg1, beg2, MIN (len1, len2)); } @@ -351,26 +351,26 @@ keycmp (struct line const *line1, struct line const *line2, static void check_order (const struct line *prev, - const struct line *current, - int whatfile) + const struct line *current, + int whatfile) { if (check_input_order != CHECK_ORDER_DISABLED && ((check_input_order == CHECK_ORDER_ENABLED) || seen_unpairable)) { if (!issued_disorder_warning[whatfile-1]) - { - size_t join_field = whatfile == 1 ? join_field_1 : join_field_2; - if (keycmp (prev, current, join_field, join_field) > 0) - { - error ((check_input_order == CHECK_ORDER_ENABLED - ? EXIT_FAILURE : 0), - 0, _("file %d is not in sorted order"), whatfile); + { + size_t join_field = whatfile == 1 ? join_field_1 : join_field_2; + if (keycmp (prev, current, join_field, join_field) > 0) + { + error ((check_input_order == CHECK_ORDER_ENABLED + ? EXIT_FAILURE : 0), + 0, _("file %d is not in sorted order"), whatfile); - /* If we get to here, the message was just a warning, but we - want only to issue it once. */ - issued_disorder_warning[whatfile-1] = true; - } - } + /* If we get to here, the message was just a warning, but we + want only to issue it once. */ + issued_disorder_warning[whatfile-1] = true; + } + } } } @@ -411,7 +411,7 @@ get_line (FILE *fp, struct line **linep, int which) if (! readlinebuffer (&line->buf, fp)) { if (ferror (fp)) - error (EXIT_FAILURE, errno, _("read error")); + error (EXIT_FAILURE, errno, _("read error")); freeline (line); return false; } @@ -433,10 +433,10 @@ free_spareline (void) for (i = 0; i < ARRAY_CARDINALITY (spareline); i++) { if (spareline[i]) - { - freeline (spareline[i]); - free (spareline[i]); - } + { + freeline (spareline[i]); + free (spareline[i]); + } } } @@ -458,7 +458,7 @@ getseq (FILE *fp, struct seq *seq, int whichfile) size_t i; seq->lines = X2NREALLOC (seq->lines, &seq->alloc); for (i = seq->count; i < seq->alloc; i++) - seq->lines[i] = NULL; + seq->lines[i] = NULL; } if (get_line (fp, &seq->lines[seq->count], whichfile)) @@ -487,9 +487,9 @@ delseq (struct seq *seq) for (i = 0; i < seq->alloc; i++) if (seq->lines[i]) { - if (seq->lines[i]->buf.buffer) - freeline (seq->lines[i]); - free (seq->lines[i]); + if (seq->lines[i]->buf.buffer) + freeline (seq->lines[i]); + free (seq->lines[i]); } free (seq->lines); } @@ -507,9 +507,9 @@ prfield (size_t n, struct line const *line) { len = line->fields[n].len; if (len) - fwrite (line->fields[n].beg, 1, len, stdout); + fwrite (line->fields[n].beg, 1, len, stdout); else if (empty_filler) - fputs (empty_filler, stdout); + fputs (empty_filler, stdout); } else if (empty_filler) fputs (empty_filler, stdout); @@ -530,34 +530,34 @@ prjoin (struct line const *line1, struct line const *line2) o = outlist; while (1) - { - size_t field; - struct line const *line; + { + size_t field; + struct line const *line; - if (o->file == 0) - { - if (line1 == &uni_blank) - { - line = line2; - field = join_field_2; - } - else - { - line = line1; - field = join_field_1; - } - } - else - { - line = (o->file == 1 ? line1 : line2); - field = o->field; - } - prfield (field, line); - o = o->next; - if (o == NULL) - break; - putchar (output_separator); - } + if (o->file == 0) + { + if (line1 == &uni_blank) + { + line = line2; + field = join_field_2; + } + else + { + line = line1; + field = join_field_1; + } + } + else + { + line = (o->file == 1 ? line1 : line2); + field = o->field; + } + prfield (field, line); + o = o->next; + if (o == NULL) + break; + putchar (output_separator); + } putchar ('\n'); } else @@ -565,34 +565,34 @@ prjoin (struct line const *line1, struct line const *line2) size_t i; if (line1 == &uni_blank) - { - struct line const *t; - t = line1; - line1 = line2; - line2 = t; - } + { + struct line const *t; + t = line1; + line1 = line2; + line2 = t; + } prfield (join_field_1, line1); for (i = 0; i < join_field_1 && i < line1->nfields; ++i) - { - putchar (output_separator); - prfield (i, line1); - } + { + putchar (output_separator); + prfield (i, line1); + } for (i = join_field_1 + 1; i < line1->nfields; ++i) - { - putchar (output_separator); - prfield (i, line1); - } + { + putchar (output_separator); + prfield (i, line1); + } for (i = 0; i < join_field_2 && i < line2->nfields; ++i) - { - putchar (output_separator); - prfield (i, line2); - } + { + putchar (output_separator); + prfield (i, line2); + } for (i = join_field_2 + 1; i < line2->nfields; ++i) - { - putchar (output_separator); - prfield (i, line2); - } + { + putchar (output_separator); + prfield (i, line2); + } putchar ('\n'); } } @@ -619,75 +619,75 @@ join (FILE *fp1, FILE *fp2) { size_t i; diff = keycmp (seq1.lines[0], seq2.lines[0], - join_field_1, join_field_2); + join_field_1, join_field_2); if (diff < 0) - { - if (print_unpairables_1) - prjoin (seq1.lines[0], &uni_blank); - advance_seq (fp1, &seq1, true, 1); - seen_unpairable = true; - continue; - } + { + if (print_unpairables_1) + prjoin (seq1.lines[0], &uni_blank); + advance_seq (fp1, &seq1, true, 1); + seen_unpairable = true; + continue; + } if (diff > 0) - { - if (print_unpairables_2) - prjoin (&uni_blank, seq2.lines[0]); - advance_seq (fp2, &seq2, true, 2); - seen_unpairable = true; - continue; - } + { + if (print_unpairables_2) + prjoin (&uni_blank, seq2.lines[0]); + advance_seq (fp2, &seq2, true, 2); + seen_unpairable = true; + continue; + } /* Keep reading lines from file1 as long as they continue to match the current line from file2. */ eof1 = false; do - if (!advance_seq (fp1, &seq1, false, 1)) - { - eof1 = true; - ++seq1.count; - break; - } + if (!advance_seq (fp1, &seq1, false, 1)) + { + eof1 = true; + ++seq1.count; + break; + } while (!keycmp (seq1.lines[seq1.count - 1], seq2.lines[0], - join_field_1, join_field_2)); + join_field_1, join_field_2)); /* Keep reading lines from file2 as long as they continue to match the current line from file1. */ eof2 = false; do - if (!advance_seq (fp2, &seq2, false, 2)) - { - eof2 = true; - ++seq2.count; - break; - } + if (!advance_seq (fp2, &seq2, false, 2)) + { + eof2 = true; + ++seq2.count; + break; + } while (!keycmp (seq1.lines[0], seq2.lines[seq2.count - 1], - join_field_1, join_field_2)); + join_field_1, join_field_2)); if (print_pairables) - { - for (i = 0; i < seq1.count - 1; ++i) - { - size_t j; - for (j = 0; j < seq2.count - 1; ++j) - prjoin (seq1.lines[i], seq2.lines[j]); - } - } + { + for (i = 0; i < seq1.count - 1; ++i) + { + size_t j; + for (j = 0; j < seq2.count - 1; ++j) + prjoin (seq1.lines[i], seq2.lines[j]); + } + } if (!eof1) - { - SWAPLINES (seq1.lines[0], seq1.lines[seq1.count - 1]); - seq1.count = 1; - } + { + SWAPLINES (seq1.lines[0], seq1.lines[seq1.count - 1]); + seq1.count = 1; + } else - seq1.count = 0; + seq1.count = 0; if (!eof2) - { - SWAPLINES (seq2.lines[0], seq2.lines[seq2.count - 1]); - seq2.count = 1; - } + { + SWAPLINES (seq2.lines[0], seq2.lines[seq2.count - 1]); + seq2.count = 1; + } else - seq2.count = 0; + seq2.count = 0; } /* If the user did not specify --check-order, and the we read the @@ -703,29 +703,29 @@ join (FILE *fp1, FILE *fp2) if ((print_unpairables_1 || checktail) && seq1.count) { if (print_unpairables_1) - prjoin (seq1.lines[0], &uni_blank); + prjoin (seq1.lines[0], &uni_blank); seen_unpairable = true; while (get_line (fp1, linep, 1)) - { - if (print_unpairables_1) - prjoin (*linep, &uni_blank); - if (issued_disorder_warning[0] && !print_unpairables_1) - break; - } + { + if (print_unpairables_1) + prjoin (*linep, &uni_blank); + if (issued_disorder_warning[0] && !print_unpairables_1) + break; + } } if ((print_unpairables_2 || checktail) && seq2.count) { if (print_unpairables_2) - prjoin (&uni_blank, seq2.lines[0]); + prjoin (&uni_blank, seq2.lines[0]); seen_unpairable = true; while (get_line (fp2, linep, 2)) - { - if (print_unpairables_2) - prjoin (&uni_blank, *linep); - if (issued_disorder_warning[1] && !print_unpairables_2) - break; - } + { + if (print_unpairables_2) + prjoin (&uni_blank, *linep); + if (issued_disorder_warning[1] && !print_unpairables_2) + break; + } } free (*linep); @@ -792,9 +792,9 @@ decode_field_spec (const char *s, int *file_index, size_t *field_index) case '0': if (s[1]) { - /* `0' must be all alone -- no `.FIELD'. */ - error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s)); - } + /* `0' must be all alone -- no `.FIELD'. */ + error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s)); + } *file_index = 0; *field_index = 0; break; @@ -802,18 +802,18 @@ decode_field_spec (const char *s, int *file_index, size_t *field_index) case '1': case '2': if (s[1] != '.') - error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s)); + error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s)); *file_index = s[0] - '0'; *field_index = string_to_join_field (s + 2); break; default: error (EXIT_FAILURE, 0, - _("invalid file number in field spec: %s"), quote (s)); + _("invalid file number in field spec: %s"), quote (s)); /* Tell gcc -W -Wall that we can't get beyond this point. - This avoids a warning (otherwise legit) that the caller's copies - of *file_index and *field_index might be used uninitialized. */ + This avoids a warning (otherwise legit) that the caller's copies + of *file_index and *field_index might be used uninitialized. */ abort (); break; @@ -853,7 +853,7 @@ set_join_field (size_t *var, size_t val) unsigned long int var1 = *var + 1; unsigned long int val1 = val + 1; error (EXIT_FAILURE, 0, _("incompatible join fields %lu, %lu"), - var1, val1); + var1, val1); } *var = val; } @@ -881,8 +881,8 @@ enum operand_status static void add_file_name (char *name, char *names[2], - int operand_status[2], int joption_count[2], int *nfiles, - int *prev_optc_status, int *optc_status) + int operand_status[2], int joption_count[2], int *nfiles, + int *prev_optc_status, int *optc_status) { int n = *nfiles; @@ -891,30 +891,30 @@ add_file_name (char *name, char *names[2], bool op0 = (operand_status[0] == MUST_BE_OPERAND); char *arg = names[op0]; switch (operand_status[op0]) - { - case MUST_BE_OPERAND: - error (0, 0, _("extra operand %s"), quote (name)); - usage (EXIT_FAILURE); + { + case MUST_BE_OPERAND: + error (0, 0, _("extra operand %s"), quote (name)); + usage (EXIT_FAILURE); - case MIGHT_BE_J1_ARG: - joption_count[0]--; - set_join_field (&join_field_1, string_to_join_field (arg)); - break; + case MIGHT_BE_J1_ARG: + joption_count[0]--; + set_join_field (&join_field_1, string_to_join_field (arg)); + break; - case MIGHT_BE_J2_ARG: - joption_count[1]--; - set_join_field (&join_field_2, string_to_join_field (arg)); - break; + case MIGHT_BE_J2_ARG: + joption_count[1]--; + set_join_field (&join_field_2, string_to_join_field (arg)); + break; - case MIGHT_BE_O_ARG: - add_field_list (arg); - break; - } + case MIGHT_BE_O_ARG: + add_field_list (arg); + break; + } if (!op0) - { - operand_status[0] = operand_status[1]; - names[0] = names[1]; - } + { + operand_status[0] = operand_status[1]; + names[0] = names[1]; + } n = 1; } @@ -954,110 +954,110 @@ main (int argc, char **argv) check_input_order = CHECK_ORDER_DEFAULT; while ((optc = getopt_long (argc, argv, "-a:e:i1:2:j:o:t:v:", - longopts, NULL)) - != -1) + longopts, NULL)) + != -1) { optc_status = MUST_BE_OPERAND; switch (optc) - { - case 'v': - print_pairables = false; - /* Fall through. */ + { + case 'v': + print_pairables = false; + /* Fall through. */ - case 'a': - { - unsigned long int val; - if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK - || (val != 1 && val != 2)) - error (EXIT_FAILURE, 0, - _("invalid field number: %s"), quote (optarg)); - if (val == 1) - print_unpairables_1 = true; - else - print_unpairables_2 = true; - } - break; + case 'a': + { + unsigned long int val; + if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK + || (val != 1 && val != 2)) + error (EXIT_FAILURE, 0, + _("invalid field number: %s"), quote (optarg)); + if (val == 1) + print_unpairables_1 = true; + else + print_unpairables_2 = true; + } + break; - case 'e': - if (empty_filler && ! STREQ (empty_filler, optarg)) - error (EXIT_FAILURE, 0, - _("conflicting empty-field replacement strings")); - empty_filler = optarg; - break; + case 'e': + if (empty_filler && ! STREQ (empty_filler, optarg)) + error (EXIT_FAILURE, 0, + _("conflicting empty-field replacement strings")); + empty_filler = optarg; + break; - case 'i': - ignore_case = true; - break; + case 'i': + ignore_case = true; + break; - case '1': - set_join_field (&join_field_1, string_to_join_field (optarg)); - break; + case '1': + set_join_field (&join_field_1, string_to_join_field (optarg)); + break; - case '2': - set_join_field (&join_field_2, string_to_join_field (optarg)); - break; + case '2': + set_join_field (&join_field_2, string_to_join_field (optarg)); + break; - case 'j': - if ((optarg[0] == '1' || optarg[0] == '2') && !optarg[1] - && optarg == argv[optind - 1] + 2) - { - /* The argument was either "-j1" or "-j2". */ - bool is_j2 = (optarg[0] == '2'); - joption_count[is_j2]++; - optc_status = MIGHT_BE_J1_ARG + is_j2; - } - else - { - set_join_field (&join_field_1, string_to_join_field (optarg)); - set_join_field (&join_field_2, join_field_1); - } - break; + case 'j': + if ((optarg[0] == '1' || optarg[0] == '2') && !optarg[1] + && optarg == argv[optind - 1] + 2) + { + /* The argument was either "-j1" or "-j2". */ + bool is_j2 = (optarg[0] == '2'); + joption_count[is_j2]++; + optc_status = MIGHT_BE_J1_ARG + is_j2; + } + else + { + set_join_field (&join_field_1, string_to_join_field (optarg)); + set_join_field (&join_field_2, join_field_1); + } + break; - case 'o': - add_field_list (optarg); - optc_status = MIGHT_BE_O_ARG; - break; + case 'o': + add_field_list (optarg); + optc_status = MIGHT_BE_O_ARG; + break; - case 't': - { - unsigned char newtab = optarg[0]; - if (! newtab) - error (EXIT_FAILURE, 0, _("empty tab")); - if (optarg[1]) - { - if (STREQ (optarg, "\\0")) - newtab = '\0'; - else - error (EXIT_FAILURE, 0, _("multi-character tab %s"), - quote (optarg)); - } - if (0 <= tab && tab != newtab) - error (EXIT_FAILURE, 0, _("incompatible tabs")); - tab = newtab; - } - break; + case 't': + { + unsigned char newtab = optarg[0]; + if (! newtab) + error (EXIT_FAILURE, 0, _("empty tab")); + if (optarg[1]) + { + if (STREQ (optarg, "\\0")) + newtab = '\0'; + else + error (EXIT_FAILURE, 0, _("multi-character tab %s"), + quote (optarg)); + } + if (0 <= tab && tab != newtab) + error (EXIT_FAILURE, 0, _("incompatible tabs")); + tab = newtab; + } + break; - case NOCHECK_ORDER_OPTION: - check_input_order = CHECK_ORDER_DISABLED; - break; + case NOCHECK_ORDER_OPTION: + check_input_order = CHECK_ORDER_DISABLED; + break; - case CHECK_ORDER_OPTION: - check_input_order = CHECK_ORDER_ENABLED; - break; + case CHECK_ORDER_OPTION: + check_input_order = CHECK_ORDER_ENABLED; + break; - case 1: /* Non-option argument. */ - add_file_name (optarg, names, operand_status, joption_count, - &nfiles, &prev_optc_status, &optc_status); - break; + case 1: /* Non-option argument. */ + add_file_name (optarg, names, operand_status, joption_count, + &nfiles, &prev_optc_status, &optc_status); + 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); - } + default: + usage (EXIT_FAILURE); + } prev_optc_status = optc_status; } @@ -1066,14 +1066,14 @@ main (int argc, char **argv) prev_optc_status = MUST_BE_OPERAND; while (optind < argc) add_file_name (argv[optind++], names, operand_status, joption_count, - &nfiles, &prev_optc_status, &optc_status); + &nfiles, &prev_optc_status, &optc_status); if (nfiles != 2) { if (nfiles == 0) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); + error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); usage (EXIT_FAILURE); } @@ -1082,8 +1082,8 @@ main (int argc, char **argv) for (i = 0; i < 2; i++) if (joption_count[i] != 0) { - set_join_field (&join_field_1, i); - set_join_field (&join_field_2, i); + set_join_field (&join_field_1, i); + set_join_field (&join_field_2, i); } if (join_field_1 == SIZE_MAX) diff --git a/src/bin/coreutils/src/kill.c b/src/bin/coreutils/src/kill.c index 29b6d81a37..3429cb19d0 100644 --- a/src/bin/coreutils/src/kill.c +++ b/src/bin/coreutils/src/kill.c @@ -52,8 +52,8 @@ # endif # if HAVE_DECL_SYS_SIGLIST || defined sys_siglist # define strsignal(signum) (0 <= (signum) && (signum) <= SIGNUM_BOUND \ - ? sys_siglist[signum] \ - : 0) + ? sys_siglist[signum] \ + : 0) # endif # ifndef strsignal # define strsignal(signum) 0 @@ -81,7 +81,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -89,7 +89,7 @@ Usage: %s [-s SIGNAL | -SIGNAL] PID...\n\ or: %s -l [SIGNAL]...\n\ or: %s -t [SIGNAL]...\n\ "), - program_name, program_name, program_name); + program_name, program_name, program_name); fputs (_("\ Send signals to processes, or list signals.\n\ \n\ @@ -122,11 +122,11 @@ PID is an integer; if negative it identifies a process group.\n\ static void print_table_row (unsigned int num_width, int signum, - unsigned int name_width, char const *signame) + unsigned int name_width, char const *signame) { char const *description = strsignal (signum); printf ("%*d %-*s %s\n", num_width, signum, name_width, signame, - description ? description : "?"); + description ? description : "?"); } /* Print a list of signal names. If TABLE, print a table. @@ -147,51 +147,51 @@ list_signals (bool table, char *const *argv) /* Compute the maximum width of a signal number. */ unsigned int num_width = 1; for (signum = 1; signum <= SIGNUM_BOUND / 10; signum *= 10) - num_width++; + num_width++; /* Compute the maximum width of a signal name. */ for (signum = 1; signum <= SIGNUM_BOUND; signum++) - if (sig2str (signum, signame) == 0) - { - size_t len = strlen (signame); - if (name_width < len) - name_width = len; - } + if (sig2str (signum, signame) == 0) + { + size_t len = strlen (signame); + if (name_width < len) + name_width = len; + } if (argv) - for (; *argv; argv++) - { - signum = operand2sig (*argv, signame); - if (signum < 0) - status = EXIT_FAILURE; - else - print_table_row (num_width, signum, name_width, signame); - } + for (; *argv; argv++) + { + signum = operand2sig (*argv, signame); + if (signum < 0) + status = EXIT_FAILURE; + else + print_table_row (num_width, signum, name_width, signame); + } else - for (signum = 1; signum <= SIGNUM_BOUND; signum++) - if (sig2str (signum, signame) == 0) - print_table_row (num_width, signum, name_width, signame); + for (signum = 1; signum <= SIGNUM_BOUND; signum++) + if (sig2str (signum, signame) == 0) + print_table_row (num_width, signum, name_width, signame); } else { if (argv) - for (; *argv; argv++) - { - signum = operand2sig (*argv, signame); - if (signum < 0) - status = EXIT_FAILURE; - else - { - if (ISDIGIT (**argv)) - puts (signame); - else - printf ("%d\n", signum); - } - } + for (; *argv; argv++) + { + signum = operand2sig (*argv, signame); + if (signum < 0) + status = EXIT_FAILURE; + else + { + if (ISDIGIT (**argv)) + puts (signame); + else + printf ("%d\n", signum); + } + } else - for (signum = 1; signum <= SIGNUM_BOUND; signum++) - if (sig2str (signum, signame) == 0) - puts (signame); + for (signum = 1; signum <= SIGNUM_BOUND; signum++) + if (sig2str (signum, signame) == 0) + puts (signame); } return status; @@ -213,15 +213,15 @@ send_signals (int signum, char *const *argv) pid_t pid = n; if (errno == ERANGE || pid != n || arg == endp || *endp) - { - error (0, 0, _("%s: invalid process id"), arg); - status = EXIT_FAILURE; - } + { + error (0, 0, _("%s: invalid process id"), arg); + status = EXIT_FAILURE; + } else if (kill (pid, signum) != 0) - { - error (0, errno, "%s", arg); - status = EXIT_FAILURE; - } + { + error (0, errno, "%s", arg); + status = EXIT_FAILURE; + } } while ((arg = *++argv)); @@ -246,61 +246,61 @@ main (int argc, char **argv) atexit (close_stdout); while ((optc = getopt_long (argc, argv, short_options, long_options, NULL)) - != -1) + != -1) switch (optc) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - if (optind != 2) - { - /* This option is actually a process-id. */ - optind--; - goto no_more_options; - } - /* Fall through. */ + if (optind != 2) + { + /* This option is actually a process-id. */ + optind--; + goto no_more_options; + } + /* Fall through. */ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': - if (! optarg) - optarg = argv[optind - 1] + strlen (argv[optind - 1]); - if (optarg != argv[optind - 1] + 2) - { - error (0, 0, _("invalid option -- %c"), optc); - usage (EXIT_FAILURE); - } - optarg--; - /* Fall through. */ + if (! optarg) + optarg = argv[optind - 1] + strlen (argv[optind - 1]); + if (optarg != argv[optind - 1] + 2) + { + error (0, 0, _("invalid option -- %c"), optc); + usage (EXIT_FAILURE); + } + optarg--; + /* Fall through. */ case 'n': /* -n is not documented, but is for Bash compatibility. */ case 's': - if (0 <= signum) - { - error (0, 0, _("%s: multiple signals specified"), optarg); - usage (EXIT_FAILURE); - } - signum = operand2sig (optarg, signame); - if (signum < 0) - usage (EXIT_FAILURE); - break; + if (0 <= signum) + { + error (0, 0, _("%s: multiple signals specified"), optarg); + usage (EXIT_FAILURE); + } + signum = operand2sig (optarg, signame); + if (signum < 0) + usage (EXIT_FAILURE); + break; case 't': - table = true; - /* Fall through. */ + table = true; + /* Fall through. */ case 'l': - if (list) - { - error (0, 0, _("multiple -l or -t options specified")); - usage (EXIT_FAILURE); - } - list = true; - break; + if (list) + { + error (0, 0, _("multiple -l or -t options specified")); + usage (EXIT_FAILURE); + } + list = true; + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: - usage (EXIT_FAILURE); + usage (EXIT_FAILURE); } no_more_options:; @@ -319,6 +319,6 @@ main (int argc, char **argv) } return (list - ? list_signals (table, optind < argc ? argv + optind : NULL) - : send_signals (signum, argv + optind)); + ? list_signals (table, optind < argc ? argv + optind : NULL) + : send_signals (signum, argv + optind)); } diff --git a/src/bin/coreutils/src/link.c b/src/bin/coreutils/src/link.c index 4376245f89..ead3ac2f57 100644 --- a/src/bin/coreutils/src/link.c +++ b/src/bin/coreutils/src/link.c @@ -40,7 +40,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -48,7 +48,7 @@ Usage: %s FILE1 FILE2\n\ or: %s OPTION\n"), program_name, program_name); fputs (_("Call the link function to create a link named FILE2\ to an existing FILE1.\n\n"), - stdout); + stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_bug_reporting_address (); @@ -68,16 +68,16 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); if (argc < optind + 2) { if (argc < optind + 1) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - error (0, 0, _("missing operand after %s"), quote (argv[optind])); + error (0, 0, _("missing operand after %s"), quote (argv[optind])); usage (EXIT_FAILURE); } @@ -89,7 +89,7 @@ main (int argc, char **argv) if (link (argv[optind], argv[optind + 1]) != 0) error (EXIT_FAILURE, errno, _("cannot create link %s to %s"), - quote_n (0, argv[optind + 1]), quote_n (1, argv[optind])); + quote_n (0, argv[optind + 1]), quote_n (1, argv[optind])); exit (EXIT_SUCCESS); } diff --git a/src/bin/coreutils/src/ln.c b/src/bin/coreutils/src/ln.c index d0f92669de..6a1dc32077 100644 --- a/src/bin/coreutils/src/ln.c +++ b/src/bin/coreutils/src/ln.c @@ -39,10 +39,6 @@ proper_name ("Mike Parker"), \ proper_name ("David MacKenzie") -#ifndef ENABLE_HARD_LINK_TO_SYMLINK_WARNING -# define ENABLE_HARD_LINK_TO_SYMLINK_WARNING 0 -#endif - /* In being careful not even to try to make hard links to directories, we have to know whether link(2) follows symlinks. If it does, then we have to *stat* the `source' to see if the resulting link would be @@ -150,43 +146,40 @@ do_link (const char *source, const char *dest) /* Use stat here instead of lstat. On SVR4, link does not follow symlinks, so this check disallows making hard links to symlinks that point to directories. Big deal. - On other systems, link follows symlinks, so this check is right. */ + On other systems, link follows symlinks, so this check is right. + + FIXME - POSIX 2008 added the AT_SYMLINK_FOLLOW flag to linkat so + that we can specify either behavior, via the new options -L + (hard-link to symlinks) and -P (hard-link to the referent). Once + gnulib has a decent implementation, we should use it here. */ if (!symbolic_link) { if (STAT_LIKE_LINK (source, &source_stats) != 0) - { - error (0, errno, _("accessing %s"), quote (source)); - return false; - } - - if (ENABLE_HARD_LINK_TO_SYMLINK_WARNING - && S_ISLNK (source_stats.st_mode)) - { - error (0, 0, _("%s: warning: making a hard link to a symbolic link\ - is not portable"), - quote (source)); - } + { + error (0, errno, _("accessing %s"), quote (source)); + return false; + } if (S_ISDIR (source_stats.st_mode)) - { - source_is_dir = true; - if (! hard_dir_link) - { - error (0, 0, _("%s: hard link not allowed for directory"), - quote (source)); - return false; - } - } + { + source_is_dir = true; + if (! hard_dir_link) + { + error (0, 0, _("%s: hard link not allowed for directory"), + quote (source)); + return false; + } + } } if (remove_existing_files || interactive || backup_type != no_backups) { dest_lstat_ok = (lstat (dest, &dest_stats) == 0); if (!dest_lstat_ok && errno != ENOENT) - { - error (0, errno, _("accessing %s"), quote (dest)); - return false; - } + { + error (0, errno, _("accessing %s"), quote (dest)); + return false; + } } /* If the current target was created as a hard link to another @@ -196,8 +189,8 @@ do_link (const char *source, const char *dest) && seen_file (dest_set, dest, &dest_stats)) { error (0, 0, - _("will not overwrite just-created %s with %s"), - quote_n (0, dest), quote_n (1, source)); + _("will not overwrite just-created %s with %s"), + quote_n (0, dest), quote_n (1, source)); return false; } @@ -208,77 +201,78 @@ do_link (const char *source, const char *dest) anything and fail right here. */ if ((remove_existing_files /* Ensure that "ln --backup f f" fails here, with the - "... same file" diagnostic, below. Otherwise, subsequent - code would give a misleading "file not found" diagnostic. - This case is different than the others handled here, since - the command in question doesn't use --force. */ + "... same file" diagnostic, below. Otherwise, subsequent + code would give a misleading "file not found" diagnostic. + This case is different than the others handled here, since + the command in question doesn't use --force. */ || (!symbolic_link && backup_type != no_backups)) && dest_lstat_ok /* Allow `ln -sf --backup k k' to succeed in creating the - self-referential symlink, but don't allow the hard-linking - equivalent: `ln -f k k' (with or without --backup) to get - beyond this point, because the error message you'd get is - misleading. */ + self-referential symlink, but don't allow the hard-linking + equivalent: `ln -f k k' (with or without --backup) to get + beyond this point, because the error message you'd get is + misleading. */ && (backup_type == no_backups || !symbolic_link) && (!symbolic_link || stat (source, &source_stats) == 0) && SAME_INODE (source_stats, dest_stats) /* The following detects whether removing DEST will also remove - SOURCE. If the file has only one link then both are surely - the same link. Otherwise check whether they point to the same - name in the same directory. */ + SOURCE. If the file has only one link then both are surely + the same link. Otherwise check whether they point to the same + name in the same directory. */ && (source_stats.st_nlink == 1 || same_name (source, dest))) { error (0, 0, _("%s and %s are the same file"), - quote_n (0, source), quote_n (1, dest)); + quote_n (0, source), quote_n (1, dest)); return false; } if (dest_lstat_ok) { if (S_ISDIR (dest_stats.st_mode)) - { - error (0, 0, _("%s: cannot overwrite directory"), quote (dest)); - return false; - } + { + error (0, 0, _("%s: cannot overwrite directory"), quote (dest)); + return false; + } if (interactive) - { - fprintf (stderr, _("%s: replace %s? "), program_name, quote (dest)); - if (!yesno ()) - return true; - remove_existing_files = true; - } + { + fprintf (stderr, _("%s: replace %s? "), program_name, quote (dest)); + if (!yesno ()) + return true; + remove_existing_files = true; + } if (backup_type != no_backups) - { - dest_backup = find_backup_file_name (dest, backup_type); - if (rename (dest, dest_backup) != 0) - { - int rename_errno = errno; - free (dest_backup); - dest_backup = NULL; - if (rename_errno != ENOENT) - { - error (0, rename_errno, _("cannot backup %s"), quote (dest)); - return false; - } - } - } + { + dest_backup = find_backup_file_name (dest, backup_type); + if (rename (dest, dest_backup) != 0) + { + int rename_errno = errno; + free (dest_backup); + dest_backup = NULL; + if (rename_errno != ENOENT) + { + error (0, rename_errno, _("cannot backup %s"), quote (dest)); + return false; + } + } + } } ok = ((symbolic_link ? symlink (source, dest) : link (source, dest)) - == 0); + == 0); /* If the attempt to create a link failed and we are removing or backing up destinations, unlink the destination and try again. - POSIX 1003.1-2004 requires that ln -f A B must unlink B even on - failure (e.g., when A does not exist). This is counterintuitive, - and we submitted a defect report - - (2004-06-24). If the committee does not fix the standard we'll - have to change the behavior of ln -f, at least if POSIXLY_CORRECT - is set. In the meantime ln -f A B will not unlink B unless the - attempt to link A to B failed because B already existed. + On the surface, POSIX describes an algorithm that states that + 'ln -f A B' will call unlink() on B before ever attempting + link() on A. But strictly following this has the counterintuitive + effect of losing the contents of B, if A does not exist. + Fortunately, POSIX 2008 clarified that an application is free + to fail early if it can prove that continuing onwards cannot + succeed, so we are justified in trying link() before blindly + removing B, thus sometimes calling link() a second time during + a successful 'ln -f A B'. Try to unlink DEST even if we may have backed it up successfully. In some unusual cases (when DEST and DEST_BACKUP are hard-links @@ -289,50 +283,50 @@ do_link (const char *source, const char *dest) if (!ok && errno == EEXIST && (remove_existing_files || dest_backup)) { if (unlink (dest) != 0) - { - error (0, errno, _("cannot remove %s"), quote (dest)); - free (dest_backup); - return false; - } + { + error (0, errno, _("cannot remove %s"), quote (dest)); + free (dest_backup); + return false; + } ok = ((symbolic_link ? symlink (source, dest) : link (source, dest)) - == 0); + == 0); } if (ok) { /* Right after creating a hard link, do this: (note dest name and - source_stats, which are also the just-linked-destinations stats) */ + source_stats, which are also the just-linked-destinations stats) */ record_file (dest_set, dest, &source_stats); if (verbose) - { - if (dest_backup) - printf ("%s ~ ", quote (dest_backup)); - printf ("%s %c> %s\n", quote_n (0, dest), (symbolic_link ? '-' : '='), - quote_n (1, source)); - } + { + if (dest_backup) + printf ("%s ~ ", quote (dest_backup)); + printf ("%s %c> %s\n", quote_n (0, dest), (symbolic_link ? '-' : '='), + quote_n (1, source)); + } } else { error (0, errno, - (symbolic_link - ? (errno != ENAMETOOLONG && *source - ? _("creating symbolic link %s") - : _("creating symbolic link %s -> %s")) - : (errno == EMLINK && !source_is_dir - ? _("creating hard link to %.0s%s") - : (errno == EDQUOT || errno == EEXIST || errno == ENOSPC - || errno == EROFS) - ? _("creating hard link %s") - : _("creating hard link %s => %s"))), - quote_n (0, dest), quote_n (1, source)); + (symbolic_link + ? (errno != ENAMETOOLONG && *source + ? _("creating symbolic link %s") + : _("creating symbolic link %s -> %s")) + : (errno == EMLINK && !source_is_dir + ? _("creating hard link to %.0s%s") + : (errno == EDQUOT || errno == EEXIST || errno == ENOSPC + || errno == EROFS) + ? _("creating hard link %s") + : _("creating hard link %s => %s"))), + quote_n (0, dest), quote_n (1, source)); if (dest_backup) - { - if (rename (dest_backup, dest) != 0) - error (0, errno, _("cannot un-backup %s"), quote (dest)); - } + { + if (rename (dest_backup, dest) != 0) + error (0, errno, _("cannot un-backup %s"), quote (dest)); + } } free (dest_backup); @@ -344,7 +338,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -353,7 +347,7 @@ Usage: %s [OPTION]... [-T] TARGET LINK_NAME (1st form)\n\ or: %s [OPTION]... TARGET... DIRECTORY (3rd form)\n\ or: %s [OPTION]... -t DIRECTORY TARGET... (4th form)\n\ "), - program_name, program_name, program_name, program_name); + program_name, program_name, program_name, program_name); fputs (_("\ In the 1st form, create a link to TARGET with the name LINK_NAME.\n\ In the 2nd form, create a link to TARGET in the current directory.\n\ @@ -437,63 +431,63 @@ main (int argc, char **argv) = hard_dir_link = false; while ((c = getopt_long (argc, argv, "bdfinst:vFS:T", long_options, NULL)) - != -1) + != -1) { switch (c) - { - case 'b': - make_backups = true; - if (optarg) - version_control_string = optarg; - break; - case 'd': - case 'F': - hard_dir_link = true; - break; - case 'f': - remove_existing_files = true; - interactive = false; - break; - case 'i': - remove_existing_files = false; - interactive = true; - break; - case 'n': - dereference_dest_dir_symlinks = false; - break; - case 's': - symbolic_link = true; - break; - case 't': - if (target_directory) - error (EXIT_FAILURE, 0, _("multiple target directories specified")); - else - { - struct stat st; - if (stat (optarg, &st) != 0) - error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg)); - if (! S_ISDIR (st.st_mode)) - error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (optarg)); - } - target_directory = optarg; - break; - case 'T': - no_target_directory = true; - break; - case 'v': - verbose = true; - break; - case 'S': - make_backups = true; - backup_suffix_string = optarg; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - break; - } + { + case 'b': + make_backups = true; + if (optarg) + version_control_string = optarg; + break; + case 'd': + case 'F': + hard_dir_link = true; + break; + case 'f': + remove_existing_files = true; + interactive = false; + break; + case 'i': + remove_existing_files = false; + interactive = true; + break; + case 'n': + dereference_dest_dir_symlinks = false; + break; + case 's': + symbolic_link = true; + break; + case 't': + if (target_directory) + error (EXIT_FAILURE, 0, _("multiple target directories specified")); + else + { + struct stat st; + if (stat (optarg, &st) != 0) + error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg)); + if (! S_ISDIR (st.st_mode)) + error (EXIT_FAILURE, 0, _("target %s is not a directory"), + quote (optarg)); + } + target_directory = optarg; + break; + case 'T': + no_target_directory = true; + break; + case 'v': + verbose = true; + break; + case 'S': + make_backups = true; + backup_suffix_string = optarg; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + break; + } } n_files = argc - optind; @@ -508,75 +502,75 @@ main (int argc, char **argv) if (no_target_directory) { if (target_directory) - error (EXIT_FAILURE, 0, - _("cannot combine --target-directory " - "and --no-target-directory")); + error (EXIT_FAILURE, 0, + _("cannot combine --target-directory " + "and --no-target-directory")); if (n_files != 2) - { - if (n_files < 2) - error (0, 0, - _("missing destination file operand after %s"), - quote (file[0])); - else - error (0, 0, _("extra operand %s"), quote (file[2])); - usage (EXIT_FAILURE); - } + { + if (n_files < 2) + error (0, 0, + _("missing destination file operand after %s"), + quote (file[0])); + else + error (0, 0, _("extra operand %s"), quote (file[2])); + usage (EXIT_FAILURE); + } } else if (!target_directory) { if (n_files < 2) - target_directory = "."; + target_directory = "."; else if (2 <= n_files && target_directory_operand (file[n_files - 1])) - target_directory = file[--n_files]; + target_directory = file[--n_files]; else if (2 < n_files) - error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (file[n_files - 1])); + error (EXIT_FAILURE, 0, _("target %s is not a directory"), + quote (file[n_files - 1])); } if (backup_suffix_string) simple_backup_suffix = xstrdup (backup_suffix_string); backup_type = (make_backups - ? xget_version (_("backup type"), version_control_string) - : no_backups); + ? xget_version (_("backup type"), version_control_string) + : no_backups); if (target_directory) { int i; /* Create the data structure we'll use to record which hard links we - create. Used to ensure that ln detects an obscure corner case that - might result in user data loss. Create it only if needed. */ + create. Used to ensure that ln detects an obscure corner case that + might result in user data loss. Create it only if needed. */ if (2 <= n_files - && remove_existing_files - /* Don't bother trying to protect symlinks, since ln clobbering - a just-created symlink won't ever lead to real data loss. */ - && ! symbolic_link - /* No destination hard link can be clobbered when making - numbered backups. */ - && backup_type != numbered_backups) + && remove_existing_files + /* Don't bother trying to protect symlinks, since ln clobbering + a just-created symlink won't ever lead to real data loss. */ + && ! symbolic_link + /* No destination hard link can be clobbered when making + numbered backups. */ + && backup_type != numbered_backups) - { - dest_set = hash_initialize (DEST_INFO_INITIAL_CAPACITY, - NULL, - triple_hash, - triple_compare, - triple_free); - if (dest_set == NULL) - xalloc_die (); - } + { + dest_set = hash_initialize (DEST_INFO_INITIAL_CAPACITY, + NULL, + triple_hash, + triple_compare, + triple_free); + if (dest_set == NULL) + xalloc_die (); + } ok = true; for (i = 0; i < n_files; ++i) - { - char *dest_base; - char *dest = file_name_concat (target_directory, - last_component (file[i]), - &dest_base); - strip_trailing_slashes (dest_base); - ok &= do_link (file[i], dest); - free (dest); - } + { + char *dest_base; + char *dest = file_name_concat (target_directory, + last_component (file[i]), + &dest_base); + strip_trailing_slashes (dest_base); + ok &= do_link (file[i], dest); + free (dest); + } } else ok = do_link (file[0], file[1]); diff --git a/src/bin/coreutils/src/logname.c b/src/bin/coreutils/src/logname.c index 25350af43e..8abb535f0d 100644 --- a/src/bin/coreutils/src/logname.c +++ b/src/bin/coreutils/src/logname.c @@ -34,7 +34,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]\n"), program_name); @@ -63,7 +63,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/ls.c b/src/bin/coreutils/src/ls.c index d46516ab0d..6d75b35f1d 100644 --- a/src/bin/coreutils/src/ls.c +++ b/src/bin/coreutils/src/ls.c @@ -112,8 +112,8 @@ #include "mbsalign.h" #define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \ - : (ls_mode == LS_MULTI_COL \ - ? "dir" : "vdir")) + : (ls_mode == LS_MULTI_COL \ + ? "dir" : "vdir")) #define AUTHORS \ proper_name ("Richard M. Stallman"), \ @@ -126,6 +126,26 @@ Subtracting doesn't always work, due to overflow. */ #define longdiff(a, b) ((a) < (b) ? -1 : (a) > (b)) +/* Unix-based readdir implementations have historically returned a dirent.d_ino + value that is sometimes not equal to the stat-obtained st_ino value for + that same entry. This error occurs for a readdir entry that refers + to a mount point. readdir's error is to return the inode number of + the underlying directory -- one that typically cannot be stat'ed, as + long as a file system is mounted on that directory. RELIABLE_D_INO + encapsulates whether we can use the more efficient approach of relying + on readdir-supplied d_ino values, or whether we must incur the cost of + calling stat or lstat to obtain each guaranteed-valid inode number. */ + +#ifndef READDIR_LIES_ABOUT_MOUNTPOINT_D_INO +# define READDIR_LIES_ABOUT_MOUNTPOINT_D_INO 1 +#endif + +#if READDIR_LIES_ABOUT_MOUNTPOINT_D_INO +# define RELIABLE_D_INO(dp) NOT_AN_INODE_NUMBER +#else +# define RELIABLE_D_INO(dp) D_INO (dp) +#endif + #if ! HAVE_STRUCT_STAT_ST_AUTHOR # define st_author st_uid #endif @@ -212,49 +232,49 @@ struct bin_str #endif static size_t quote_name (FILE *out, const char *name, - struct quoting_options const *options, - size_t *width); + struct quoting_options const *options, + size_t *width); static char *make_link_name (char const *name, char const *linkname); static int decode_switches (int argc, char **argv); static bool file_ignored (char const *name); static uintmax_t gobble_file (char const *name, enum filetype type, - ino_t inode, bool command_line_arg, - char const *dirname); + ino_t inode, bool command_line_arg, + char const *dirname); static bool print_color_indicator (const char *name, mode_t mode, int linkok, - bool stat_ok, enum filetype type, - nlink_t nlink); + bool stat_ok, enum filetype type, + nlink_t nlink); static void put_indicator (const struct bin_str *ind); static void add_ignore_pattern (const char *pattern); static void attach (char *dest, const char *dirname, const char *name); static void clear_files (void); static void extract_dirs_from_files (char const *dirname, - bool command_line_arg); + bool command_line_arg); static void get_link_name (char const *filename, struct fileinfo *f, - bool command_line_arg); + bool command_line_arg); static void indent (size_t from, size_t to); static size_t calculate_columns (bool by_columns); static void print_current_files (void); static void print_dir (char const *name, char const *realname, - bool command_line_arg); + bool command_line_arg); static size_t print_file_name_and_frills (const struct fileinfo *f, - size_t start_col); + size_t start_col); static void print_horizontal (void); static int format_user_width (uid_t u); static int format_group_width (gid_t g); static void print_long_format (const struct fileinfo *f); static void print_many_per_line (void); static size_t print_name_with_quoting (const char *p, mode_t mode, - int linkok, bool stat_ok, - enum filetype type, - struct obstack *stack, - nlink_t nlink, - size_t start_col); + int linkok, bool stat_ok, + enum filetype type, + struct obstack *stack, + nlink_t nlink, + size_t start_col); static void prep_non_filename_text (void); static bool print_type_indicator (bool stat_ok, mode_t mode, - enum filetype type); + enum filetype type); static void print_with_commas (void); static void queue_directory (char const *name, char const *realname, - bool command_line_arg); + bool command_line_arg); static void sort_files (void); static void parse_ls_color (void); void usage (int status); @@ -912,8 +932,8 @@ static size_t dired_pos; #define DIRED_INDENT() \ do \ { \ - if (dired) \ - DIRED_FPUTS_LITERAL (" ", stdout); \ + if (dired) \ + DIRED_FPUTS_LITERAL (" ", stdout); \ } \ while (0) @@ -932,7 +952,7 @@ static struct obstack subdired_obstack; do \ { \ if (dired) \ - obstack_grow (obs, &dired_pos, sizeof (dired_pos)); \ + obstack_grow (obs, &dired_pos, sizeof (dired_pos)); \ } \ while (0) @@ -993,7 +1013,7 @@ dired_dump_obstack (const char *prefix, struct obstack *os) pos = (size_t *) obstack_finish (os); fputs (prefix, stdout); for (i = 0; i < n_pos; i++) - printf (" %lu", (unsigned long int) pos[i]); + printf (" %lu", (unsigned long int) pos[i]); putchar ('\n'); } } @@ -1026,21 +1046,21 @@ abmon_init (void) curr_max_width = required_mon_width; required_mon_width = 0; for (int i = 0; i < 12; i++) - { - size_t width = curr_max_width; + { + size_t width = curr_max_width; - size_t req = mbsalign (nl_langinfo (ABMON_1 + i), - abmon[i], sizeof (abmon[i]), - &width, MBS_ALIGN_LEFT, 0); + size_t req = mbsalign (nl_langinfo (ABMON_1 + i), + abmon[i], sizeof (abmon[i]), + &width, MBS_ALIGN_LEFT, 0); - if (req == (size_t) -1 || req >= sizeof (abmon[i])) - { - required_mon_width = 0; /* ignore precomputed strings. */ - return required_mon_width; - } + if (req == (size_t) -1 || req >= sizeof (abmon[i])) + { + required_mon_width = 0; /* ignore precomputed strings. */ + return required_mon_width; + } - required_mon_width = MAX (required_mon_width, width); - } + required_mon_width = MAX (required_mon_width, width); + } } while (curr_max_width > required_mon_width); @@ -1118,8 +1138,8 @@ is_colored (enum indicator_no type) size_t len = color_indicator[type].len; char const *s = color_indicator[type].string; return ! (len == 0 - || (len == 1 && strncmp (s, "0", 1) == 0) - || (len == 2 && strncmp (s, "00", 2) == 0)); + || (len == 1 && strncmp (s, "0", 1) == 0) + || (len == 2 && strncmp (s, "00", 2) == 0)); } static void @@ -1167,33 +1187,33 @@ process_signals (void) sigset_t oldset; if (used_color) - restore_default_color (); + restore_default_color (); fflush (stdout); sigprocmask (SIG_BLOCK, &caught_signals, &oldset); /* Reload interrupt_signal and stop_signal_count, in case a new - signal was handled before sigprocmask took effect. */ + signal was handled before sigprocmask took effect. */ sig = interrupt_signal; stops = stop_signal_count; /* SIGTSTP is special, since the application can receive that signal - more than once. In this case, don't set the signal handler to the - default. Instead, just raise the uncatchable SIGSTOP. */ + more than once. In this case, don't set the signal handler to the + default. Instead, just raise the uncatchable SIGSTOP. */ if (stops) - { - stop_signal_count = stops - 1; - sig = SIGSTOP; - } + { + stop_signal_count = stops - 1; + sig = SIGSTOP; + } else - signal (sig, SIG_DFL); + signal (sig, SIG_DFL); /* Exit or suspend the program. */ raise (sig); sigprocmask (SIG_SETMASK, &oldset, NULL); /* If execution reaches here, then the program has been - continued (after being suspended). */ + continued (after being suspended). */ } } @@ -1264,68 +1284,68 @@ main (int argc, char **argv) { /* Avoid following symbolic links when possible. */ if (is_colored (C_ORPHAN) - || (is_colored (C_EXEC) && color_symlink_as_referent) - || (is_colored (C_MISSING) && format == long_format)) - check_symlink_color = true; + || (is_colored (C_EXEC) && color_symlink_as_referent) + || (is_colored (C_MISSING) && format == long_format)) + check_symlink_color = true; /* If the standard output is a controlling terminal, watch out for signals, so that the colors can be restored to the default state if "ls" is suspended or interrupted. */ if (0 <= tcgetpgrp (STDOUT_FILENO)) - { - int j; + { + int j; #if SA_NOCLDSTOP - struct sigaction act; + struct sigaction act; - sigemptyset (&caught_signals); - for (j = 0; j < nsigs; j++) - { - sigaction (sig[j], NULL, &act); - if (act.sa_handler != SIG_IGN) - sigaddset (&caught_signals, sig[j]); - } + sigemptyset (&caught_signals); + for (j = 0; j < nsigs; j++) + { + sigaction (sig[j], NULL, &act); + if (act.sa_handler != SIG_IGN) + sigaddset (&caught_signals, sig[j]); + } - act.sa_mask = caught_signals; - act.sa_flags = SA_RESTART; + act.sa_mask = caught_signals; + act.sa_flags = SA_RESTART; - for (j = 0; j < nsigs; j++) - if (sigismember (&caught_signals, sig[j])) - { - act.sa_handler = sig[j] == SIGTSTP ? stophandler : sighandler; - sigaction (sig[j], &act, NULL); - } + for (j = 0; j < nsigs; j++) + if (sigismember (&caught_signals, sig[j])) + { + act.sa_handler = sig[j] == SIGTSTP ? stophandler : sighandler; + sigaction (sig[j], &act, NULL); + } #else - for (j = 0; j < nsigs; j++) - { - caught_sig[j] = (signal (sig[j], SIG_IGN) != SIG_IGN); - if (caught_sig[j]) - { - signal (sig[j], sig[j] == SIGTSTP ? stophandler : sighandler); - siginterrupt (sig[j], 0); - } - } + for (j = 0; j < nsigs; j++) + { + caught_sig[j] = (signal (sig[j], SIG_IGN) != SIG_IGN); + if (caught_sig[j]) + { + signal (sig[j], sig[j] == SIGTSTP ? stophandler : sighandler); + siginterrupt (sig[j], 0); + } + } #endif - } + } } if (dereference == DEREF_UNDEFINED) dereference = ((immediate_dirs - || indicator_style == classify - || format == long_format) - ? DEREF_NEVER - : DEREF_COMMAND_LINE_SYMLINK_TO_DIR); + || indicator_style == classify + || format == long_format) + ? DEREF_NEVER + : DEREF_COMMAND_LINE_SYMLINK_TO_DIR); /* When using -R, initialize a data structure we'll use to detect any directory cycles. */ if (recursive) { active_dir_set = hash_initialize (INITIAL_TABLE_SIZE, NULL, - dev_ino_hash, - dev_ino_compare, - dev_ino_free); + dev_ino_hash, + dev_ino_compare, + dev_ino_free); if (active_dir_set == NULL) - xalloc_die (); + xalloc_die (); obstack_init (&dev_ino_obstack); } @@ -1335,10 +1355,10 @@ main (int argc, char **argv) || print_scontext || print_block_size; format_needs_type = (! format_needs_stat - && (recursive - || print_with_color - || indicator_style != none - || directories_first)); + && (recursive + || print_with_color + || indicator_style != none + || directories_first)); if (dired) { @@ -1357,9 +1377,9 @@ main (int argc, char **argv) if (n_files <= 0) { if (immediate_dirs) - gobble_file (".", directory, NOT_AN_INODE_NUMBER, true, ""); + gobble_file (".", directory, NOT_AN_INODE_NUMBER, true, ""); else - queue_directory (".", NULL, true); + queue_directory (".", NULL, true); } else do @@ -1370,7 +1390,7 @@ main (int argc, char **argv) { sort_files (); if (!immediate_dirs) - extract_dirs_from_files (NULL, true); + extract_dirs_from_files (NULL, true); /* `cwd_n_used' might be zero now. */ } @@ -1382,7 +1402,7 @@ main (int argc, char **argv) { print_current_files (); if (pending_dirs) - DIRED_PUTCHAR ('\n'); + DIRED_PUTCHAR ('\n'); } else if (n_files <= 1 && pending_dirs && pending_dirs->next == 0) print_dir_name = false; @@ -1393,25 +1413,25 @@ main (int argc, char **argv) pending_dirs = pending_dirs->next; if (LOOP_DETECT) - { - if (thispend->name == NULL) - { - /* thispend->name == NULL means this is a marker entry - indicating we've finished processing the directory. - Use its dev/ino numbers to remove the corresponding - entry from the active_dir_set hash table. */ - struct dev_ino di = dev_ino_pop (); - struct dev_ino *found = hash_delete (active_dir_set, &di); - /* ASSERT_MATCHING_DEV_INO (thispend->realname, di); */ - assert (found); - dev_ino_free (found); - free_pending_ent (thispend); - continue; - } - } + { + if (thispend->name == NULL) + { + /* thispend->name == NULL means this is a marker entry + indicating we've finished processing the directory. + Use its dev/ino numbers to remove the corresponding + entry from the active_dir_set hash table. */ + struct dev_ino di = dev_ino_pop (); + struct dev_ino *found = hash_delete (active_dir_set, &di); + /* ASSERT_MATCHING_DEV_INO (thispend->realname, di); */ + assert (found); + dev_ino_free (found); + free_pending_ent (thispend); + continue; + } + } print_dir (thispend->name, thispend->realname, - thispend->command_line_arg); + thispend->command_line_arg); free_pending_ent (thispend); print_dir_name = true; @@ -1422,29 +1442,29 @@ main (int argc, char **argv) int j; if (used_color) - restore_default_color (); + restore_default_color (); fflush (stdout); /* Restore the default signal handling. */ #if SA_NOCLDSTOP for (j = 0; j < nsigs; j++) - if (sigismember (&caught_signals, sig[j])) - signal (sig[j], SIG_DFL); + if (sigismember (&caught_signals, sig[j])) + signal (sig[j], SIG_DFL); #else for (j = 0; j < nsigs; j++) - if (caught_sig[j]) - signal (sig[j], SIG_DFL); + if (caught_sig[j]) + signal (sig[j], SIG_DFL); #endif /* Act on any signals that arrived before the default was restored. - This can process signals out of order, but there doesn't seem to - be an easy way to do them in order, and the order isn't that - important anyway. */ + This can process signals out of order, but there doesn't seem to + be an easy way to do them in order, and the order isn't that + important anyway. */ for (j = stop_signal_count; j; j--) - raise (SIGSTOP); + raise (SIGSTOP); j = interrupt_signal; if (j) - raise (j); + raise (j); } if (dired) @@ -1453,7 +1473,7 @@ main (int argc, char **argv) dired_dump_obstack ("//DIRED//", &dired_obstack); dired_dump_obstack ("//SUBDIRED//", &subdired_obstack); printf ("//DIRED-OPTIONS// --quoting-style=%s\n", - quoting_style_args[get_quoting_style (filename_quoting_options)]); + quoting_style_args[get_quoting_style (filename_quoting_options)]); } if (LOOP_DETECT) @@ -1497,16 +1517,16 @@ decode_switches (int argc, char **argv) case LS_LS: /* This is for the `ls' program. */ if (isatty (STDOUT_FILENO)) - { - format = many_per_line; - /* See description of qmark_funny_chars, above. */ - qmark_funny_chars = true; - } + { + format = many_per_line; + /* See description of qmark_funny_chars, above. */ + qmark_funny_chars = true; + } else - { - format = one_per_line; - qmark_funny_chars = false; - } + { + format = one_per_line; + qmark_funny_chars = false; + } break; default: @@ -1533,20 +1553,20 @@ decode_switches (int argc, char **argv) char const *q_style = getenv ("QUOTING_STYLE"); if (q_style) { - int i = ARGMATCH (q_style, quoting_style_args, quoting_style_vals); - if (0 <= i) - set_quoting_style (NULL, quoting_style_vals[i]); - else - error (0, 0, - _("ignoring invalid value of environment variable QUOTING_STYLE: %s"), - quotearg (q_style)); + int i = ARGMATCH (q_style, quoting_style_args, quoting_style_vals); + if (0 <= i) + set_quoting_style (NULL, quoting_style_vals[i]); + else + error (0, 0, + _("ignoring invalid value of environment variable QUOTING_STYLE: %s"), + quotearg (q_style)); } } { char const *ls_block_size = getenv ("LS_BLOCK_SIZE"); human_options (ls_block_size, - &human_output_opts, &output_block_size); + &human_output_opts, &output_block_size); if (ls_block_size || getenv ("BLOCK_SIZE")) file_output_block_size = output_block_size; } @@ -1556,18 +1576,18 @@ decode_switches (int argc, char **argv) char const *p = getenv ("COLUMNS"); if (p && *p) { - unsigned long int tmp_ulong; - if (xstrtoul (p, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK - && 0 < tmp_ulong && tmp_ulong <= SIZE_MAX) - { - line_length = tmp_ulong; - } - else - { - error (0, 0, - _("ignoring invalid width in environment variable COLUMNS: %s"), - quotearg (p)); - } + unsigned long int tmp_ulong; + if (xstrtoul (p, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK + && 0 < tmp_ulong && tmp_ulong <= SIZE_MAX) + { + line_length = tmp_ulong; + } + else + { + error (0, 0, + _("ignoring invalid width in environment variable COLUMNS: %s"), + quotearg (p)); + } } } @@ -1576,7 +1596,7 @@ decode_switches (int argc, char **argv) struct winsize ws; if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &ws) != -1 - && 0 < ws.ws_col && ws.ws_col == (size_t) ws.ws_col) + && 0 < ws.ws_col && ws.ws_col == (size_t) ws.ws_col) line_length = ws.ws_col; } #endif @@ -1586,18 +1606,18 @@ decode_switches (int argc, char **argv) tabsize = 8; if (p) { - unsigned long int tmp_ulong; - if (xstrtoul (p, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK - && tmp_ulong <= SIZE_MAX) - { - tabsize = tmp_ulong; - } - else - { - error (0, 0, - _("ignoring invalid tab size in environment variable TABSIZE: %s"), - quotearg (p)); - } + unsigned long int tmp_ulong; + if (xstrtoul (p, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK + && tmp_ulong <= SIZE_MAX) + { + tabsize = tmp_ulong; + } + else + { + error (0, 0, + _("ignoring invalid tab size in environment variable TABSIZE: %s"), + quotearg (p)); + } } } @@ -1605,319 +1625,319 @@ decode_switches (int argc, char **argv) { int oi = -1; int c = getopt_long (argc, argv, - "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UXZ1", - long_options, &oi); + "abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UXZ1", + long_options, &oi); if (c == -1) - break; + break; switch (c) - { - case 'a': - ignore_mode = IGNORE_MINIMAL; - break; + { + case 'a': + ignore_mode = IGNORE_MINIMAL; + break; - case 'b': - set_quoting_style (NULL, escape_quoting_style); - break; + case 'b': + set_quoting_style (NULL, escape_quoting_style); + break; - case 'c': - time_type = time_ctime; - break; + case 'c': + time_type = time_ctime; + break; - case 'd': - immediate_dirs = true; - break; + case 'd': + immediate_dirs = true; + break; - case 'f': - /* Same as enabling -a -U and disabling -l -s. */ - ignore_mode = IGNORE_MINIMAL; - sort_type = sort_none; - sort_type_specified = true; - /* disable -l */ - if (format == long_format) - format = (isatty (STDOUT_FILENO) ? many_per_line : one_per_line); - print_block_size = false; /* disable -s */ - print_with_color = false; /* disable --color */ - break; + case 'f': + /* Same as enabling -a -U and disabling -l -s. */ + ignore_mode = IGNORE_MINIMAL; + sort_type = sort_none; + sort_type_specified = true; + /* disable -l */ + if (format == long_format) + format = (isatty (STDOUT_FILENO) ? many_per_line : one_per_line); + print_block_size = false; /* disable -s */ + print_with_color = false; /* disable --color */ + break; - case FILE_TYPE_INDICATOR_OPTION: /* --file-type */ - indicator_style = file_type; - break; + case FILE_TYPE_INDICATOR_OPTION: /* --file-type */ + indicator_style = file_type; + break; - case 'g': - format = long_format; - print_owner = false; - break; + case 'g': + format = long_format; + print_owner = false; + break; - case 'h': - human_output_opts = human_autoscale | human_SI | human_base_1024; - file_output_block_size = output_block_size = 1; - break; + case 'h': + human_output_opts = human_autoscale | human_SI | human_base_1024; + file_output_block_size = output_block_size = 1; + break; - case 'i': - print_inode = true; - break; + case 'i': + print_inode = true; + break; - case 'k': - human_output_opts = 0; - file_output_block_size = output_block_size = 1024; - break; + case 'k': + human_output_opts = 0; + file_output_block_size = output_block_size = 1024; + break; - case 'l': - format = long_format; - break; + case 'l': + format = long_format; + break; - case 'm': - format = with_commas; - break; + case 'm': + format = with_commas; + break; - case 'n': - numeric_ids = true; - format = long_format; - break; + case 'n': + numeric_ids = true; + format = long_format; + break; - case 'o': /* Just like -l, but don't display group info. */ - format = long_format; - print_group = false; - break; + case 'o': /* Just like -l, but don't display group info. */ + format = long_format; + print_group = false; + break; - case 'p': - indicator_style = slash; - break; + case 'p': + indicator_style = slash; + break; - case 'q': - qmark_funny_chars = true; - break; + case 'q': + qmark_funny_chars = true; + break; - case 'r': - sort_reverse = true; - break; + case 'r': + sort_reverse = true; + break; - case 's': - print_block_size = true; - break; + case 's': + print_block_size = true; + break; - case 't': - sort_type = sort_time; - sort_type_specified = true; - break; + case 't': + sort_type = sort_time; + sort_type_specified = true; + break; - case 'u': - time_type = time_atime; - break; + case 'u': + time_type = time_atime; + break; - case 'v': - sort_type = sort_version; - sort_type_specified = true; - break; + case 'v': + sort_type = sort_version; + sort_type_specified = true; + break; - case 'w': - { - unsigned long int tmp_ulong; - if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK - || ! (0 < tmp_ulong && tmp_ulong <= SIZE_MAX)) - error (LS_FAILURE, 0, _("invalid line width: %s"), - quotearg (optarg)); - line_length = tmp_ulong; - break; - } + case 'w': + { + unsigned long int tmp_ulong; + if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK + || ! (0 < tmp_ulong && tmp_ulong <= SIZE_MAX)) + error (LS_FAILURE, 0, _("invalid line width: %s"), + quotearg (optarg)); + line_length = tmp_ulong; + break; + } - case 'x': - format = horizontal; - break; + case 'x': + format = horizontal; + break; - case 'A': - if (ignore_mode == IGNORE_DEFAULT) - ignore_mode = IGNORE_DOT_AND_DOTDOT; - break; + case 'A': + if (ignore_mode == IGNORE_DEFAULT) + ignore_mode = IGNORE_DOT_AND_DOTDOT; + break; - case 'B': - add_ignore_pattern ("*~"); - add_ignore_pattern (".*~"); - break; + case 'B': + add_ignore_pattern ("*~"); + add_ignore_pattern (".*~"); + break; - case 'C': - format = many_per_line; - break; + case 'C': + format = many_per_line; + break; - case 'D': - dired = true; - break; + case 'D': + dired = true; + break; - case 'F': - indicator_style = classify; - break; + case 'F': + indicator_style = classify; + break; - case 'G': /* inhibit display of group info */ - print_group = false; - break; + case 'G': /* inhibit display of group info */ + print_group = false; + break; - case 'H': - dereference = DEREF_COMMAND_LINE_ARGUMENTS; - break; + case 'H': + dereference = DEREF_COMMAND_LINE_ARGUMENTS; + break; - case DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_OPTION: - dereference = DEREF_COMMAND_LINE_SYMLINK_TO_DIR; - break; + case DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_OPTION: + dereference = DEREF_COMMAND_LINE_SYMLINK_TO_DIR; + break; - case 'I': - add_ignore_pattern (optarg); - break; + case 'I': + add_ignore_pattern (optarg); + break; - case 'L': - dereference = DEREF_ALWAYS; - break; + case 'L': + dereference = DEREF_ALWAYS; + break; - case 'N': - set_quoting_style (NULL, literal_quoting_style); - break; + case 'N': + set_quoting_style (NULL, literal_quoting_style); + break; - case 'Q': - set_quoting_style (NULL, c_quoting_style); - break; + case 'Q': + set_quoting_style (NULL, c_quoting_style); + break; - case 'R': - recursive = true; - break; + case 'R': + recursive = true; + break; - case 'S': - sort_type = sort_size; - sort_type_specified = true; - break; + case 'S': + sort_type = sort_size; + sort_type_specified = true; + break; - case 'T': - { - unsigned long int tmp_ulong; - if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK - || SIZE_MAX < tmp_ulong) - error (LS_FAILURE, 0, _("invalid tab size: %s"), - quotearg (optarg)); - tabsize = tmp_ulong; - break; - } + case 'T': + { + unsigned long int tmp_ulong; + if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK + || SIZE_MAX < tmp_ulong) + error (LS_FAILURE, 0, _("invalid tab size: %s"), + quotearg (optarg)); + tabsize = tmp_ulong; + break; + } - case 'U': - sort_type = sort_none; - sort_type_specified = true; - break; + case 'U': + sort_type = sort_none; + sort_type_specified = true; + break; - case 'X': - sort_type = sort_extension; - sort_type_specified = true; - break; + case 'X': + sort_type = sort_extension; + sort_type_specified = true; + break; - case '1': - /* -1 has no effect after -l. */ - if (format != long_format) - format = one_per_line; - break; + case '1': + /* -1 has no effect after -l. */ + if (format != long_format) + format = one_per_line; + break; case AUTHOR_OPTION: print_author = true; break; - case HIDE_OPTION: - { - struct ignore_pattern *hide = xmalloc (sizeof *hide); - hide->pattern = optarg; - hide->next = hide_patterns; - hide_patterns = hide; - } - break; + case HIDE_OPTION: + { + struct ignore_pattern *hide = xmalloc (sizeof *hide); + hide->pattern = optarg; + hide->next = hide_patterns; + hide_patterns = hide; + } + break; - case SORT_OPTION: - sort_type = XARGMATCH ("--sort", optarg, sort_args, sort_types); - sort_type_specified = true; - break; + case SORT_OPTION: + sort_type = XARGMATCH ("--sort", optarg, sort_args, sort_types); + sort_type_specified = true; + break; - case GROUP_DIRECTORIES_FIRST_OPTION: - directories_first = true; - break; + case GROUP_DIRECTORIES_FIRST_OPTION: + directories_first = true; + break; - case TIME_OPTION: - time_type = XARGMATCH ("--time", optarg, time_args, time_types); - break; + case TIME_OPTION: + time_type = XARGMATCH ("--time", optarg, time_args, time_types); + break; - case FORMAT_OPTION: - format = XARGMATCH ("--format", optarg, format_args, format_types); - break; + case FORMAT_OPTION: + format = XARGMATCH ("--format", optarg, format_args, format_types); + break; - case FULL_TIME_OPTION: - format = long_format; - time_style_option = bad_cast ("full-iso"); - break; + case FULL_TIME_OPTION: + format = long_format; + time_style_option = bad_cast ("full-iso"); + break; - case COLOR_OPTION: - { - int i; - if (optarg) - i = XARGMATCH ("--color", optarg, color_args, color_types); - else - /* Using --color with no argument is equivalent to using - --color=always. */ - i = color_always; + case COLOR_OPTION: + { + int i; + if (optarg) + i = XARGMATCH ("--color", optarg, color_args, color_types); + else + /* Using --color with no argument is equivalent to using + --color=always. */ + i = color_always; - print_with_color = (i == color_always - || (i == color_if_tty - && isatty (STDOUT_FILENO))); + print_with_color = (i == color_always + || (i == color_if_tty + && isatty (STDOUT_FILENO))); - if (print_with_color) - { - /* Don't use TAB characters in output. Some terminal - emulators can't handle the combination of tabs and - color codes on the same line. */ - tabsize = 0; - } - break; - } + if (print_with_color) + { + /* Don't use TAB characters in output. Some terminal + emulators can't handle the combination of tabs and + color codes on the same line. */ + tabsize = 0; + } + break; + } - case INDICATOR_STYLE_OPTION: - indicator_style = XARGMATCH ("--indicator-style", optarg, - indicator_style_args, - indicator_style_types); - break; + case INDICATOR_STYLE_OPTION: + indicator_style = XARGMATCH ("--indicator-style", optarg, + indicator_style_args, + indicator_style_types); + break; - case QUOTING_STYLE_OPTION: - set_quoting_style (NULL, - XARGMATCH ("--quoting-style", optarg, - quoting_style_args, - quoting_style_vals)); - break; + case QUOTING_STYLE_OPTION: + set_quoting_style (NULL, + XARGMATCH ("--quoting-style", optarg, + quoting_style_args, + quoting_style_vals)); + break; - case TIME_STYLE_OPTION: - time_style_option = optarg; - break; + case TIME_STYLE_OPTION: + time_style_option = optarg; + break; - case SHOW_CONTROL_CHARS_OPTION: - qmark_funny_chars = false; - break; + case SHOW_CONTROL_CHARS_OPTION: + qmark_funny_chars = false; + break; - case BLOCK_SIZE_OPTION: - { - enum strtol_error e = human_options (optarg, &human_output_opts, - &output_block_size); - if (e != LONGINT_OK) - xstrtol_fatal (e, oi, 0, long_options, optarg); - file_output_block_size = output_block_size; - } - break; + case BLOCK_SIZE_OPTION: + { + enum strtol_error e = human_options (optarg, &human_output_opts, + &output_block_size); + if (e != LONGINT_OK) + xstrtol_fatal (e, oi, 0, long_options, optarg); + file_output_block_size = output_block_size; + } + break; - case SI_OPTION: - human_output_opts = human_autoscale | human_SI; - file_output_block_size = output_block_size = 1; - break; + case SI_OPTION: + human_output_opts = human_autoscale | human_SI; + file_output_block_size = output_block_size = 1; + break; - case 'Z': - print_scontext = true; - break; + case 'Z': + print_scontext = 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 (LS_FAILURE); - } + default: + usage (LS_FAILURE); + } } max_idx = MAX (1, line_length / MIN_COLUMN_WIDTH); @@ -1929,7 +1949,7 @@ decode_switches (int argc, char **argv) { char const *p; for (p = "*=>@|" + indicator_style - file_type; *p; p++) - set_char_quoting (filename_quoting_options, *p, 1); + set_char_quoting (filename_quoting_options, *p, 1); } dirname_quoting_options = clone_quoting_options (NULL); @@ -1961,73 +1981,73 @@ decode_switches (int argc, char **argv) static char const posix_prefix[] = "posix-"; if (! style) - if (! (style = getenv ("TIME_STYLE"))) - style = bad_cast ("locale"); + if (! (style = getenv ("TIME_STYLE"))) + style = bad_cast ("locale"); while (strncmp (style, posix_prefix, sizeof posix_prefix - 1) == 0) - { - if (! hard_locale (LC_TIME)) - return optind; - style += sizeof posix_prefix - 1; - } + { + if (! hard_locale (LC_TIME)) + return optind; + style += sizeof posix_prefix - 1; + } if (*style == '+') - { - char *p0 = style + 1; - char *p1 = strchr (p0, '\n'); - if (! p1) - p1 = p0; - else - { - if (strchr (p1 + 1, '\n')) - error (LS_FAILURE, 0, _("invalid time style format %s"), - quote (p0)); - *p1++ = '\0'; - } - long_time_format[0] = p0; - long_time_format[1] = p1; - } + { + char *p0 = style + 1; + char *p1 = strchr (p0, '\n'); + if (! p1) + p1 = p0; + else + { + if (strchr (p1 + 1, '\n')) + error (LS_FAILURE, 0, _("invalid time style format %s"), + quote (p0)); + *p1++ = '\0'; + } + long_time_format[0] = p0; + long_time_format[1] = p1; + } else - switch (XARGMATCH ("time style", style, - time_style_args, - time_style_types)) - { - case full_iso_time_style: - long_time_format[0] = long_time_format[1] = - "%Y-%m-%d %H:%M:%S.%N %z"; - break; + switch (XARGMATCH ("time style", style, + time_style_args, + time_style_types)) + { + case full_iso_time_style: + long_time_format[0] = long_time_format[1] = + "%Y-%m-%d %H:%M:%S.%N %z"; + break; - case long_iso_time_style: - case_long_iso_time_style: - long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M"; - break; + case long_iso_time_style: + case_long_iso_time_style: + long_time_format[0] = long_time_format[1] = "%Y-%m-%d %H:%M"; + break; - case iso_time_style: - long_time_format[0] = "%Y-%m-%d "; - long_time_format[1] = "%m-%d %H:%M"; - break; + case iso_time_style: + long_time_format[0] = "%Y-%m-%d "; + long_time_format[1] = "%m-%d %H:%M"; + break; - case locale_time_style: - if (hard_locale (LC_TIME)) - { - /* Ensure that the locale has translations for both - formats. If not, fall back on long-iso format. */ - int i; - for (i = 0; i < 2; i++) - { - char const *locale_format = - dcgettext (NULL, long_time_format[i], LC_TIME); - if (locale_format == long_time_format[i]) - goto case_long_iso_time_style; - long_time_format[i] = locale_format; - } - } - } + case locale_time_style: + if (hard_locale (LC_TIME)) + { + /* Ensure that the locale has translations for both + formats. If not, fall back on long-iso format. */ + int i; + for (i = 0; i < 2; i++) + { + char const *locale_format = + dcgettext (NULL, long_time_format[i], LC_TIME); + if (locale_format == long_time_format[i]) + goto case_long_iso_time_style; + long_time_format[i] = locale_format; + } + } + } #ifdef HAVE_NL_LANGINFO /* Note we leave %5b etc. alone so user widths/flags are honored. */ if (strstr (long_time_format[0],"%b") || strstr (long_time_format[1],"%b")) - if (!abmon_init ()) - error (0, 0, _("error initializing month strings")); + if (!abmon_init ()) + error (0, 0, _("error initializing month strings")); #endif } @@ -2049,7 +2069,7 @@ decode_switches (int argc, char **argv) static bool get_funky_string (char **dest, const char **src, bool equals_end, - size_t *output_count) + size_t *output_count) { char num; /* For numerical codes */ size_t count; /* Something to count with */ @@ -2069,170 +2089,170 @@ get_funky_string (char **dest, const char **src, bool equals_end, while (state < ST_END) { switch (state) - { - case ST_GND: /* Ground state (no escapes) */ - switch (*p) - { - case ':': - case '\0': - state = ST_END; /* End of string */ - break; - case '\\': - state = ST_BACKSLASH; /* Backslash scape sequence */ - ++p; - break; - case '^': - state = ST_CARET; /* Caret escape */ - ++p; - break; - case '=': - if (equals_end) - { - state = ST_END; /* End */ - break; - } - /* else fall through */ - default: - *(q++) = *(p++); - ++count; - break; - } - break; + { + case ST_GND: /* Ground state (no escapes) */ + switch (*p) + { + case ':': + case '\0': + state = ST_END; /* End of string */ + break; + case '\\': + state = ST_BACKSLASH; /* Backslash scape sequence */ + ++p; + break; + case '^': + state = ST_CARET; /* Caret escape */ + ++p; + break; + case '=': + if (equals_end) + { + state = ST_END; /* End */ + break; + } + /* else fall through */ + default: + *(q++) = *(p++); + ++count; + break; + } + break; - case ST_BACKSLASH: /* Backslash escaped character */ - switch (*p) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - state = ST_OCTAL; /* Octal sequence */ - num = *p - '0'; - break; - case 'x': - case 'X': - state = ST_HEX; /* Hex sequence */ - num = 0; - break; - case 'a': /* Bell */ - num = '\a'; - break; - case 'b': /* Backspace */ - num = '\b'; - break; - case 'e': /* Escape */ - num = 27; - break; - case 'f': /* Form feed */ - num = '\f'; - break; - case 'n': /* Newline */ - num = '\n'; - break; - case 'r': /* Carriage return */ - num = '\r'; - break; - case 't': /* Tab */ - num = '\t'; - break; - case 'v': /* Vtab */ - num = '\v'; - break; - case '?': /* Delete */ + case ST_BACKSLASH: /* Backslash escaped character */ + switch (*p) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + state = ST_OCTAL; /* Octal sequence */ + num = *p - '0'; + break; + case 'x': + case 'X': + state = ST_HEX; /* Hex sequence */ + num = 0; + break; + case 'a': /* Bell */ + num = '\a'; + break; + case 'b': /* Backspace */ + num = '\b'; + break; + case 'e': /* Escape */ + num = 27; + break; + case 'f': /* Form feed */ + num = '\f'; + break; + case 'n': /* Newline */ + num = '\n'; + break; + case 'r': /* Carriage return */ + num = '\r'; + break; + case 't': /* Tab */ + num = '\t'; + break; + case 'v': /* Vtab */ + num = '\v'; + break; + case '?': /* Delete */ num = 127; - break; - case '_': /* Space */ - num = ' '; - break; - case '\0': /* End of string */ - state = ST_ERROR; /* Error! */ - break; - default: /* Escaped character like \ ^ : = */ - num = *p; - break; - } - if (state == ST_BACKSLASH) - { - *(q++) = num; - ++count; - state = ST_GND; - } - ++p; - break; + break; + case '_': /* Space */ + num = ' '; + break; + case '\0': /* End of string */ + state = ST_ERROR; /* Error! */ + break; + default: /* Escaped character like \ ^ : = */ + num = *p; + break; + } + if (state == ST_BACKSLASH) + { + *(q++) = num; + ++count; + state = ST_GND; + } + ++p; + break; - case ST_OCTAL: /* Octal sequence */ - if (*p < '0' || *p > '7') - { - *(q++) = num; - ++count; - state = ST_GND; - } - else - num = (num << 3) + (*(p++) - '0'); - break; + case ST_OCTAL: /* Octal sequence */ + if (*p < '0' || *p > '7') + { + *(q++) = num; + ++count; + state = ST_GND; + } + else + num = (num << 3) + (*(p++) - '0'); + break; - case ST_HEX: /* Hex sequence */ - switch (*p) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - num = (num << 4) + (*(p++) - '0'); - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - num = (num << 4) + (*(p++) - 'a') + 10; - break; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - num = (num << 4) + (*(p++) - 'A') + 10; - break; - default: - *(q++) = num; - ++count; - state = ST_GND; - break; - } - break; + case ST_HEX: /* Hex sequence */ + switch (*p) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + num = (num << 4) + (*(p++) - '0'); + break; + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + num = (num << 4) + (*(p++) - 'a') + 10; + break; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + num = (num << 4) + (*(p++) - 'A') + 10; + break; + default: + *(q++) = num; + ++count; + state = ST_GND; + break; + } + break; - case ST_CARET: /* Caret escape */ - state = ST_GND; /* Should be the next state... */ - if (*p >= '@' && *p <= '~') - { - *(q++) = *(p++) & 037; - ++count; - } - else if (*p == '?') - { - *(q++) = 127; - ++count; - } - else - state = ST_ERROR; - break; + case ST_CARET: /* Caret escape */ + state = ST_GND; /* Should be the next state... */ + if (*p >= '@' && *p <= '~') + { + *(q++) = *(p++) & 037; + ++count; + } + else if (*p == '?') + { + *(q++) = 127; + ++count; + } + else + state = ST_ERROR; + break; - default: - abort (); - } + default: + abort (); + } } *dest = q; @@ -2268,83 +2288,83 @@ parse_ls_color (void) while (state > 0) { switch (state) - { - case 1: /* First label character */ - switch (*p) - { - case ':': - ++p; - break; + { + case 1: /* First label character */ + switch (*p) + { + case ':': + ++p; + break; - case '*': - /* Allocate new extension block and add to head of - linked list (this way a later definition will - override an earlier one, which can be useful for - having terminal-specific defs override global). */ + case '*': + /* Allocate new extension block and add to head of + linked list (this way a later definition will + override an earlier one, which can be useful for + having terminal-specific defs override global). */ - ext = xmalloc (sizeof *ext); - ext->next = color_ext_list; - color_ext_list = ext; + ext = xmalloc (sizeof *ext); + ext->next = color_ext_list; + color_ext_list = ext; - ++p; - ext->ext.string = buf; + ++p; + ext->ext.string = buf; - state = (get_funky_string (&buf, &p, true, &ext->ext.len) - ? 4 : -1); - break; + state = (get_funky_string (&buf, &p, true, &ext->ext.len) + ? 4 : -1); + break; - case '\0': - state = 0; /* Done! */ - break; + case '\0': + state = 0; /* Done! */ + break; - default: /* Assume it is file type label */ - label[0] = *(p++); - state = 2; - break; - } - break; + default: /* Assume it is file type label */ + label[0] = *(p++); + state = 2; + break; + } + break; - case 2: /* Second label character */ - if (*p) - { - label[1] = *(p++); - state = 3; - } - else - state = -1; /* Error */ - break; + case 2: /* Second label character */ + if (*p) + { + label[1] = *(p++); + state = 3; + } + else + state = -1; /* Error */ + break; - case 3: /* Equal sign after indicator label */ - state = -1; /* Assume failure... */ - if (*(p++) == '=')/* It *should* be... */ - { - for (ind_no = 0; indicator_name[ind_no] != NULL; ++ind_no) - { - if (STREQ (label, indicator_name[ind_no])) - { - color_indicator[ind_no].string = buf; - state = (get_funky_string (&buf, &p, false, - &color_indicator[ind_no].len) - ? 1 : -1); - break; - } - } - if (state == -1) - error (0, 0, _("unrecognized prefix: %s"), quotearg (label)); - } - break; + case 3: /* Equal sign after indicator label */ + state = -1; /* Assume failure... */ + if (*(p++) == '=')/* It *should* be... */ + { + for (ind_no = 0; indicator_name[ind_no] != NULL; ++ind_no) + { + if (STREQ (label, indicator_name[ind_no])) + { + color_indicator[ind_no].string = buf; + state = (get_funky_string (&buf, &p, false, + &color_indicator[ind_no].len) + ? 1 : -1); + break; + } + } + if (state == -1) + error (0, 0, _("unrecognized prefix: %s"), quotearg (label)); + } + break; - case 4: /* Equal sign after *.ext */ - if (*(p++) == '=') - { - ext->seq.string = buf; - state = (get_funky_string (&buf, &p, false, &ext->seq.len) - ? 1 : -1); - } - else - state = -1; - break; - } + case 4: /* Equal sign after *.ext */ + if (*(p++) == '=') + { + ext->seq.string = buf; + state = (get_funky_string (&buf, &p, false, &ext->seq.len) + ? 1 : -1); + } + else + state = -1; + break; + } } if (state < 0) @@ -2353,14 +2373,14 @@ parse_ls_color (void) struct color_ext_type *e2; error (0, 0, - _("unparsable value for LS_COLORS environment variable")); + _("unparsable value for LS_COLORS environment variable")); free (color_buf); for (e = color_ext_list; e != NULL; /* empty */) - { - e2 = e; - e = e->next; - free (e2); - } + { + e2 = e; + e = e->next; + free (e2); + } print_with_color = false; } @@ -2441,24 +2461,24 @@ print_dir (char const *name, char const *realname, bool command_line_arg) /* If dirfd failed, endure the overhead of using stat. */ if ((0 <= fd - ? fstat (fd, &dir_stat) - : stat (name, &dir_stat)) < 0) - { - file_failure (command_line_arg, - _("cannot determine device and inode of %s"), name); - closedir (dirp); - return; - } + ? fstat (fd, &dir_stat) + : stat (name, &dir_stat)) < 0) + { + file_failure (command_line_arg, + _("cannot determine device and inode of %s"), name); + closedir (dirp); + return; + } /* If we've already visited this dev/inode pair, warn that - we've found a loop, and do not process this directory. */ + we've found a loop, and do not process this directory. */ if (visit_dir (dir_stat.st_dev, dir_stat.st_ino)) - { - error (0, 0, _("%s: not listing already-listed directory"), - quotearg_colon (name)); - closedir (dirp); - return; - } + { + error (0, 0, _("%s: not listing already-listed directory"), + quotearg_colon (name)); + closedir (dirp); + return; + } DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino); } @@ -2466,12 +2486,12 @@ print_dir (char const *name, char const *realname, bool command_line_arg) if (recursive | print_dir_name) { if (!first) - DIRED_PUTCHAR ('\n'); + DIRED_PUTCHAR ('\n'); first = false; DIRED_INDENT (); PUSH_CURRENT_DIRED_POS (&subdired_obstack); dired_pos += quote_name (stdout, realname ? realname : name, - dirname_quoting_options, NULL); + dirname_quoting_options, NULL); PUSH_CURRENT_DIRED_POS (&subdired_obstack); DIRED_FPUTS_LITERAL (":\n", stdout); } @@ -2484,57 +2504,58 @@ print_dir (char const *name, char const *realname, bool command_line_arg) while (1) { /* Set errno to zero so we can distinguish between a readdir failure - and when readdir simply finds that there are no more entries. */ + and when readdir simply finds that there are no more entries. */ errno = 0; next = readdir (dirp); if (next) - { - if (! file_ignored (next->d_name)) - { - enum filetype type = unknown; + { + if (! file_ignored (next->d_name)) + { + enum filetype type = unknown; #if HAVE_STRUCT_DIRENT_D_TYPE - switch (next->d_type) - { - case DT_BLK: type = blockdev; break; - case DT_CHR: type = chardev; break; - case DT_DIR: type = directory; break; - case DT_FIFO: type = fifo; break; - case DT_LNK: type = symbolic_link; break; - case DT_REG: type = normal; break; - case DT_SOCK: type = sock; break; + switch (next->d_type) + { + case DT_BLK: type = blockdev; break; + case DT_CHR: type = chardev; break; + case DT_DIR: type = directory; break; + case DT_FIFO: type = fifo; break; + case DT_LNK: type = symbolic_link; break; + case DT_REG: type = normal; break; + case DT_SOCK: type = sock; break; # ifdef DT_WHT - case DT_WHT: type = whiteout; break; + case DT_WHT: type = whiteout; break; # endif - } + } #endif - total_blocks += gobble_file (next->d_name, type, D_INO (next), - false, name); + total_blocks += gobble_file (next->d_name, type, + RELIABLE_D_INO (next), + false, name); - /* In this narrow case, print out each name right away, so - ls uses constant memory while processing the entries of - this directory. Useful when there are many (millions) - of entries in a directory. */ - if (format == one_per_line && sort_type == sort_none - && !print_block_size && !recursive) - { - /* We must call sort_files in spite of - "sort_type == sort_none" for its initialization - of the sorted_file vector. */ - sort_files (); - print_current_files (); - clear_files (); - } - } - } + /* In this narrow case, print out each name right away, so + ls uses constant memory while processing the entries of + this directory. Useful when there are many (millions) + of entries in a directory. */ + if (format == one_per_line && sort_type == sort_none + && !print_block_size && !recursive) + { + /* We must call sort_files in spite of + "sort_type == sort_none" for its initialization + of the sorted_file vector. */ + sort_files (); + print_current_files (); + clear_files (); + } + } + } else if (errno != 0) - { - file_failure (command_line_arg, _("reading directory %s"), name); - if (errno != EOVERFLOW) - break; - } + { + file_failure (command_line_arg, _("reading directory %s"), name); + if (errno != EOVERFLOW) + break; + } else - break; + break; } if (closedir (dirp) != 0) @@ -2562,7 +2583,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg) DIRED_FPUTS (p, stdout, strlen (p)); DIRED_PUTCHAR (' '); p = human_readable (total_blocks, buf, human_output_opts, - ST_NBLOCKSIZE, output_block_size); + ST_NBLOCKSIZE, output_block_size); DIRED_FPUTS (p, stdout, strlen (p)); DIRED_PUTCHAR ('\n'); } @@ -2604,11 +2625,11 @@ static bool file_ignored (char const *name) { return ((ignore_mode != IGNORE_MINIMAL - && name[0] == '.' - && (ignore_mode == IGNORE_DEFAULT || ! name[1 + (name[1] == '.')])) - || (ignore_mode == IGNORE_DEFAULT - && patterns_match (hide_patterns, name)) - || patterns_match (ignore_patterns, name)); + && name[0] == '.' + && (ignore_mode == IGNORE_DEFAULT || ! name[1 + (name[1] == '.')])) + || (ignore_mode == IGNORE_DEFAULT + && patterns_match (hide_patterns, name)) + || patterns_match (ignore_patterns, name)); } /* POSIX requires that a file size be printed without a sign, even @@ -2636,7 +2657,7 @@ clear_files (void) free (f->name); free (f->linkname); if (f->scontext != UNKNOWN_SECURITY_CONTEXT) - freecon (f->scontext); + freecon (f->scontext); } cwd_n_used = 0; @@ -2659,7 +2680,7 @@ clear_files (void) static uintmax_t gobble_file (char const *name, enum filetype type, ino_t inode, - bool command_line_arg, char const *dirname) + bool command_line_arg, char const *dirname) { uintmax_t blocks = 0; struct fileinfo *f; @@ -2682,32 +2703,32 @@ gobble_file (char const *name, enum filetype type, ino_t inode, if (command_line_arg || format_needs_stat /* When coloring a directory (we may know the type from - direct.d_type), we have to stat it in order to indicate - sticky and/or other-writable attributes. */ + direct.d_type), we have to stat it in order to indicate + sticky and/or other-writable attributes. */ || (type == directory && print_with_color) /* When dereferencing symlinks, the inode and type must come from - stat, but readdir provides the inode and type of lstat. */ + stat, but readdir provides the inode and type of lstat. */ || ((print_inode || format_needs_type) - && (type == symbolic_link || type == unknown) - && (dereference == DEREF_ALWAYS - || (command_line_arg && dereference != DEREF_NEVER) - || color_symlink_as_referent || check_symlink_color)) + && (type == symbolic_link || type == unknown) + && (dereference == DEREF_ALWAYS + || (command_line_arg && dereference != DEREF_NEVER) + || color_symlink_as_referent || check_symlink_color)) /* Command line dereferences are already taken care of by the above - assertion that the inode number is not yet known. */ + assertion that the inode number is not yet known. */ || (print_inode && inode == NOT_AN_INODE_NUMBER) || (format_needs_type - && (type == unknown || command_line_arg - /* --indicator-style=classify (aka -F) - requires that we stat each regular file - to see if it's executable. */ - || (type == normal && (indicator_style == classify - /* This is so that --color ends up - highlighting files with the executable - bit set even when options like -F are - not specified. */ - || (print_with_color - && is_colored (C_EXEC)) - ))))) + && (type == unknown || command_line_arg + /* --indicator-style=classify (aka -F) + requires that we stat each regular file + to see if it's executable. */ + || (type == normal && (indicator_style == classify + /* This is so that --color ends up + highlighting files with the executable + bit set even when options like -F are + not specified. */ + || (print_with_color + && is_colored (C_EXEC)) + ))))) { /* Absolute name of this file. */ @@ -2716,241 +2737,241 @@ gobble_file (char const *name, enum filetype type, ino_t inode, int err; if (name[0] == '/' || dirname[0] == 0) - absolute_name = (char *) name; + absolute_name = (char *) name; else - { - absolute_name = alloca (strlen (name) + strlen (dirname) + 2); - attach (absolute_name, dirname, name); - } + { + absolute_name = alloca (strlen (name) + strlen (dirname) + 2); + attach (absolute_name, dirname, name); + } switch (dereference) - { - case DEREF_ALWAYS: - err = stat (absolute_name, &f->stat); - do_deref = true; - break; + { + case DEREF_ALWAYS: + err = stat (absolute_name, &f->stat); + do_deref = true; + break; - case DEREF_COMMAND_LINE_ARGUMENTS: - case DEREF_COMMAND_LINE_SYMLINK_TO_DIR: - if (command_line_arg) - { - bool need_lstat; - err = stat (absolute_name, &f->stat); - do_deref = true; + case DEREF_COMMAND_LINE_ARGUMENTS: + case DEREF_COMMAND_LINE_SYMLINK_TO_DIR: + if (command_line_arg) + { + bool need_lstat; + err = stat (absolute_name, &f->stat); + do_deref = true; - if (dereference == DEREF_COMMAND_LINE_ARGUMENTS) - break; + if (dereference == DEREF_COMMAND_LINE_ARGUMENTS) + break; - need_lstat = (err < 0 - ? errno == ENOENT - : ! S_ISDIR (f->stat.st_mode)); - if (!need_lstat) - break; + need_lstat = (err < 0 + ? errno == ENOENT + : ! S_ISDIR (f->stat.st_mode)); + if (!need_lstat) + break; - /* stat failed because of ENOENT, maybe indicating a dangling - symlink. Or stat succeeded, ABSOLUTE_NAME does not refer to a - directory, and --dereference-command-line-symlink-to-dir is - in effect. Fall through so that we call lstat instead. */ - } + /* stat failed because of ENOENT, maybe indicating a dangling + symlink. Or stat succeeded, ABSOLUTE_NAME does not refer to a + directory, and --dereference-command-line-symlink-to-dir is + in effect. Fall through so that we call lstat instead. */ + } - default: /* DEREF_NEVER */ - err = lstat (absolute_name, &f->stat); - do_deref = false; - break; - } + default: /* DEREF_NEVER */ + err = lstat (absolute_name, &f->stat); + do_deref = false; + break; + } if (err != 0) - { - /* Failure to stat a command line argument leads to - an exit status of 2. For other files, stat failure - provokes an exit status of 1. */ - file_failure (command_line_arg, - _("cannot access %s"), absolute_name); - if (command_line_arg) - return 0; + { + /* Failure to stat a command line argument leads to + an exit status of 2. For other files, stat failure + provokes an exit status of 1. */ + file_failure (command_line_arg, + _("cannot access %s"), absolute_name); + if (command_line_arg) + return 0; - f->name = xstrdup (name); - cwd_n_used++; + f->name = xstrdup (name); + cwd_n_used++; - return 0; - } + return 0; + } f->stat_ok = true; if (format == long_format || print_scontext) - { - bool have_selinux = false; - bool have_acl = false; - int attr_len = (do_deref - ? getfilecon (absolute_name, &f->scontext) - : lgetfilecon (absolute_name, &f->scontext)); - err = (attr_len < 0); + { + bool have_selinux = false; + bool have_acl = false; + int attr_len = (do_deref + ? getfilecon (absolute_name, &f->scontext) + : lgetfilecon (absolute_name, &f->scontext)); + err = (attr_len < 0); - /* Contrary to its documented API, getfilecon may return 0, - yet set f->scontext to NULL (on at least Debian's libselinux1 - 2.0.15-2+b1), so work around that bug. - FIXME: remove this work-around in 2011, or whenever affected - versions of libselinux are long gone. */ - if (attr_len == 0) - { - err = 0; - f->scontext = xstrdup ("unlabeled"); - } + /* Contrary to its documented API, getfilecon may return 0, + yet set f->scontext to NULL (on at least Debian's libselinux1 + 2.0.15-2+b1), so work around that bug. + FIXME: remove this work-around in 2011, or whenever affected + versions of libselinux are long gone. */ + if (attr_len == 0) + { + err = 0; + f->scontext = xstrdup ("unlabeled"); + } - if (err == 0) - have_selinux = ! STREQ ("unlabeled", f->scontext); - else - { - f->scontext = UNKNOWN_SECURITY_CONTEXT; + if (err == 0) + have_selinux = ! STREQ ("unlabeled", f->scontext); + else + { + f->scontext = UNKNOWN_SECURITY_CONTEXT; - /* When requesting security context information, don't make - ls fail just because the file (even a command line argument) - isn't on the right type of file system. I.e., a getfilecon - failure isn't in the same class as a stat failure. */ - if (errno == ENOTSUP || errno == EOPNOTSUPP || errno == ENODATA) - err = 0; - } + /* When requesting security context information, don't make + ls fail just because the file (even a command line argument) + isn't on the right type of file system. I.e., a getfilecon + failure isn't in the same class as a stat failure. */ + if (errno == ENOTSUP || errno == EOPNOTSUPP || errno == ENODATA) + err = 0; + } - if (err == 0 && format == long_format) - { - int n = file_has_acl (absolute_name, &f->stat); - err = (n < 0); - have_acl = (0 < n); - } + if (err == 0 && format == long_format) + { + int n = file_has_acl (absolute_name, &f->stat); + err = (n < 0); + have_acl = (0 < n); + } - f->acl_type = (!have_selinux && !have_acl - ? ACL_T_NONE - : (have_selinux && !have_acl - ? ACL_T_SELINUX_ONLY - : ACL_T_YES)); - any_has_acl |= f->acl_type != ACL_T_NONE; + f->acl_type = (!have_selinux && !have_acl + ? ACL_T_NONE + : (have_selinux && !have_acl + ? ACL_T_SELINUX_ONLY + : ACL_T_YES)); + any_has_acl |= f->acl_type != ACL_T_NONE; - if (err) - error (0, errno, "%s", quotearg_colon (absolute_name)); - } + if (err) + error (0, errno, "%s", quotearg_colon (absolute_name)); + } if (S_ISLNK (f->stat.st_mode) - && (format == long_format || check_symlink_color)) - { - char *linkname; - struct stat linkstats; + && (format == long_format || check_symlink_color)) + { + char *linkname; + struct stat linkstats; - get_link_name (absolute_name, f, command_line_arg); - linkname = make_link_name (absolute_name, f->linkname); + get_link_name (absolute_name, f, command_line_arg); + linkname = make_link_name (absolute_name, f->linkname); - /* Avoid following symbolic links when possible, ie, when - they won't be traced and when no indicator is needed. */ - if (linkname - && (file_type <= indicator_style || check_symlink_color) - && stat (linkname, &linkstats) == 0) - { - f->linkok = true; + /* Avoid following symbolic links when possible, ie, when + they won't be traced and when no indicator is needed. */ + if (linkname + && (file_type <= indicator_style || check_symlink_color) + && stat (linkname, &linkstats) == 0) + { + f->linkok = true; - /* Symbolic links to directories that are mentioned on the - command line are automatically traced if not being - listed as files. */ - if (!command_line_arg || format == long_format - || !S_ISDIR (linkstats.st_mode)) - { - /* Get the linked-to file's mode for the filetype indicator - in long listings. */ - f->linkmode = linkstats.st_mode; - } - } - free (linkname); - } + /* Symbolic links to directories that are mentioned on the + command line are automatically traced if not being + listed as files. */ + if (!command_line_arg || format == long_format + || !S_ISDIR (linkstats.st_mode)) + { + /* Get the linked-to file's mode for the filetype indicator + in long listings. */ + f->linkmode = linkstats.st_mode; + } + } + free (linkname); + } /* When not distinguishing types of symlinks, pretend we know that - it is stat'able, so that it will be colored as a regular symlink, - and not as an orphan. */ + it is stat'able, so that it will be colored as a regular symlink, + and not as an orphan. */ if (S_ISLNK (f->stat.st_mode) && !check_symlink_color) - f->linkok = true; + f->linkok = true; if (S_ISLNK (f->stat.st_mode)) - f->filetype = symbolic_link; + f->filetype = symbolic_link; else if (S_ISDIR (f->stat.st_mode)) - { - if (command_line_arg & !immediate_dirs) - f->filetype = arg_directory; - else - f->filetype = directory; - } + { + if (command_line_arg & !immediate_dirs) + f->filetype = arg_directory; + else + f->filetype = directory; + } else - f->filetype = normal; + f->filetype = normal; blocks = ST_NBLOCKS (f->stat); if (format == long_format || print_block_size) - { - char buf[LONGEST_HUMAN_READABLE + 1]; - int len = mbswidth (human_readable (blocks, buf, human_output_opts, - ST_NBLOCKSIZE, output_block_size), - 0); - if (block_size_width < len) - block_size_width = len; - } + { + char buf[LONGEST_HUMAN_READABLE + 1]; + int len = mbswidth (human_readable (blocks, buf, human_output_opts, + ST_NBLOCKSIZE, output_block_size), + 0); + if (block_size_width < len) + block_size_width = len; + } if (format == long_format) - { - if (print_owner) - { - int len = format_user_width (f->stat.st_uid); - if (owner_width < len) - owner_width = len; - } + { + if (print_owner) + { + int len = format_user_width (f->stat.st_uid); + if (owner_width < len) + owner_width = len; + } - if (print_group) - { - int len = format_group_width (f->stat.st_gid); - if (group_width < len) - group_width = len; - } + if (print_group) + { + int len = format_group_width (f->stat.st_gid); + if (group_width < len) + group_width = len; + } - if (print_author) - { - int len = format_user_width (f->stat.st_author); - if (author_width < len) - author_width = len; - } - } + if (print_author) + { + int len = format_user_width (f->stat.st_author); + if (author_width < len) + author_width = len; + } + } if (print_scontext) - { - int len = strlen (f->scontext); - if (scontext_width < len) - scontext_width = len; - } + { + int len = strlen (f->scontext); + if (scontext_width < len) + scontext_width = len; + } if (format == long_format) - { - char b[INT_BUFSIZE_BOUND (uintmax_t)]; - int b_len = strlen (umaxtostr (f->stat.st_nlink, b)); - if (nlink_width < b_len) - nlink_width = b_len; + { + char b[INT_BUFSIZE_BOUND (uintmax_t)]; + int b_len = strlen (umaxtostr (f->stat.st_nlink, b)); + if (nlink_width < b_len) + nlink_width = b_len; - if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode)) - { - char buf[INT_BUFSIZE_BOUND (uintmax_t)]; - int len = strlen (umaxtostr (major (f->stat.st_rdev), buf)); - if (major_device_number_width < len) - major_device_number_width = len; - len = strlen (umaxtostr (minor (f->stat.st_rdev), buf)); - if (minor_device_number_width < len) - minor_device_number_width = len; - len = major_device_number_width + 2 + minor_device_number_width; - if (file_size_width < len) - file_size_width = len; - } - else - { - char buf[LONGEST_HUMAN_READABLE + 1]; - uintmax_t size = unsigned_file_size (f->stat.st_size); - int len = mbswidth (human_readable (size, buf, human_output_opts, - 1, file_output_block_size), - 0); - if (file_size_width < len) - file_size_width = len; - } - } + if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode)) + { + char buf[INT_BUFSIZE_BOUND (uintmax_t)]; + int len = strlen (umaxtostr (major (f->stat.st_rdev), buf)); + if (major_device_number_width < len) + major_device_number_width = len; + len = strlen (umaxtostr (minor (f->stat.st_rdev), buf)); + if (minor_device_number_width < len) + minor_device_number_width = len; + len = major_device_number_width + 2 + minor_device_number_width; + if (file_size_width < len) + file_size_width = len; + } + else + { + char buf[LONGEST_HUMAN_READABLE + 1]; + uintmax_t size = unsigned_file_size (f->stat.st_size); + int len = mbswidth (human_readable (size, buf, human_output_opts, + 1, file_output_block_size), + 0); + if (file_size_width < len) + file_size_width = len; + } + } } if (print_inode) @@ -2958,7 +2979,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode, char buf[INT_BUFSIZE_BOUND (uintmax_t)]; int len = strlen (umaxtostr (f->stat.st_ino, buf)); if (inode_number_width < len) - inode_number_width = len; + inode_number_width = len; } f->name = xstrdup (name); @@ -2984,7 +3005,7 @@ get_link_name (char const *filename, struct fileinfo *f, bool command_line_arg) f->linkname = areadlink_with_size (filename, f->stat.st_size); if (f->linkname == NULL) file_failure (command_line_arg, _("cannot read symbolic link %s"), - filename); + filename); } /* If `linkname' is a relative name and `name' contains one or more @@ -3045,8 +3066,8 @@ extract_dirs_from_files (char const *dirname, bool command_line_arg) if (dirname && LOOP_DETECT) { /* Insert a marker entry first. When we dequeue this marker entry, - we'll know that DIRNAME has been processed and may be removed - from the set of active directories. */ + we'll know that DIRNAME has been processed and may be removed + from the set of active directories. */ queue_directory (NULL, dirname, false); } @@ -3057,20 +3078,20 @@ extract_dirs_from_files (char const *dirname, bool command_line_arg) struct fileinfo *f = sorted_file[i]; if (is_directory (f) - && (! ignore_dot_and_dot_dot - || ! basename_is_dot_or_dotdot (f->name))) - { - if (!dirname || f->name[0] == '/') - queue_directory (f->name, f->linkname, command_line_arg); - else - { - char *name = file_name_concat (dirname, f->name, NULL); - queue_directory (name, f->linkname, command_line_arg); - free (name); - } - if (f->filetype == arg_directory) - free (f->name); - } + && (! ignore_dot_and_dot_dot + || ! basename_is_dot_or_dotdot (f->name))) + { + if (!dirname || f->name[0] == '/') + queue_directory (f->name, f->linkname, command_line_arg); + else + { + char *name = file_name_concat (dirname, f->name, NULL); + queue_directory (name, f->linkname, command_line_arg); + free (name); + } + if (f->filetype == arg_directory) + free (f->name); + } } /* Now delete the directories from the table, compacting all the remaining @@ -3099,7 +3120,7 @@ xstrcoll (char const *a, char const *b) if (errno) { error (0, errno, _("cannot compare file names %s and %s"), - quote_n (0, a), quote_n (1, b)); + quote_n (0, a), quote_n (1, b)); set_exit_status (false); longjmp (failed_strcoll, 1); } @@ -3120,9 +3141,9 @@ typedef int (*qsortFunc)(V a, V b); bool a_is_dir = is_directory ((struct fileinfo const *) a); \ bool b_is_dir = is_directory ((struct fileinfo const *) b); \ if (a_is_dir && !b_is_dir) \ - return -1; /* a goes before b */ \ + return -1; /* a goes before b */ \ if (!a_is_dir && b_is_dir) \ - return 1; /* b goes before a */ \ + return 1; /* b goes before a */ \ } \ while (0) @@ -3137,19 +3158,19 @@ typedef int (*qsortFunc)(V a, V b); { return key_cmp_func (a, b, xstrcoll); } \ static int strcmp_##key_name (V a, V b) \ { return key_cmp_func (a, b, strcmp); } \ - \ + \ /* reverse, non-dirfirst versions */ \ static int rev_xstrcoll_##key_name (V a, V b) \ { return key_cmp_func (b, a, xstrcoll); } \ static int rev_strcmp_##key_name (V a, V b) \ { return key_cmp_func (b, a, strcmp); } \ - \ + \ /* direct, dirfirst versions */ \ static int xstrcoll_df_##key_name (V a, V b) \ { DIRFIRST_CHECK (a, b); return key_cmp_func (a, b, xstrcoll); } \ static int strcmp_df_##key_name (V a, V b) \ { DIRFIRST_CHECK (a, b); return key_cmp_func (a, b, strcmp); } \ - \ + \ /* reverse, dirfirst versions */ \ static int rev_xstrcoll_df_##key_name (V a, V b) \ { DIRFIRST_CHECK (a, b); return key_cmp_func (b, a, xstrcoll); } \ @@ -3158,34 +3179,34 @@ typedef int (*qsortFunc)(V a, V b); static inline int cmp_ctime (struct fileinfo const *a, struct fileinfo const *b, - int (*cmp) (char const *, char const *)) + int (*cmp) (char const *, char const *)) { int diff = timespec_cmp (get_stat_ctime (&b->stat), - get_stat_ctime (&a->stat)); + get_stat_ctime (&a->stat)); return diff ? diff : cmp (a->name, b->name); } static inline int cmp_mtime (struct fileinfo const *a, struct fileinfo const *b, - int (*cmp) (char const *, char const *)) + int (*cmp) (char const *, char const *)) { int diff = timespec_cmp (get_stat_mtime (&b->stat), - get_stat_mtime (&a->stat)); + get_stat_mtime (&a->stat)); return diff ? diff : cmp (a->name, b->name); } static inline int cmp_atime (struct fileinfo const *a, struct fileinfo const *b, - int (*cmp) (char const *, char const *)) + int (*cmp) (char const *, char const *)) { int diff = timespec_cmp (get_stat_atime (&b->stat), - get_stat_atime (&a->stat)); + get_stat_atime (&a->stat)); return diff ? diff : cmp (a->name, b->name); } static inline int cmp_size (struct fileinfo const *a, struct fileinfo const *b, - int (*cmp) (char const *, char const *)) + int (*cmp) (char const *, char const *)) { int diff = longdiff (b->stat.st_size, a->stat.st_size); return diff ? diff : cmp (a->name, b->name); @@ -3193,7 +3214,7 @@ cmp_size (struct fileinfo const *a, struct fileinfo const *b, static inline int cmp_name (struct fileinfo const *a, struct fileinfo const *b, - int (*cmp) (char const *, char const *)) + int (*cmp) (char const *, char const *)) { return cmp (a->name, b->name); } @@ -3203,7 +3224,7 @@ cmp_name (struct fileinfo const *a, struct fileinfo const *b, static inline int cmp_extension (struct fileinfo const *a, struct fileinfo const *b, - int (*cmp) (char const *, char const *)) + int (*cmp) (char const *, char const *)) { char const *base1 = strrchr (a->name, '.'); char const *base2 = strrchr (b->name, '.'); @@ -3303,7 +3324,7 @@ static qsortFunc const sort_functions[][2][2][2] = This line verifies at compile-time that the array of sort functions has been initialized for all possible sortkeys. */ verify (ARRAY_CARDINALITY (sort_functions) - == sort_numtypes + time_numtypes - 1 ); + == sort_numtypes + time_numtypes - 1 ); /* Set up SORTED_FILE to point to the in-use entries in CWD_FILE, in order. */ @@ -3350,9 +3371,9 @@ sort_files (void) /* When sort_type == sort_time, use time_type as subindex. */ mpsort ((void const **) sorted_file, cwd_n_used, - sort_functions[sort_type + (sort_type == sort_time ? time_type : 0)] - [use_strcmp][sort_reverse] - [directories_first]); + sort_functions[sort_type + (sort_type == sort_time ? time_type : 0)] + [use_strcmp][sort_reverse] + [directories_first]); } /* List all the files now in the table. */ @@ -3366,10 +3387,10 @@ print_current_files (void) { case one_per_line: for (i = 0; i < cwd_n_used; i++) - { - print_file_name_and_frills (sorted_file[i], 0); - putchar ('\n'); - } + { + print_file_name_and_frills (sorted_file[i], 0); + putchar ('\n'); + } break; case many_per_line: @@ -3386,10 +3407,10 @@ print_current_files (void) case long_format: for (i = 0; i < cwd_n_used; i++) - { - print_long_format (sorted_file[i]); - DIRED_PUTCHAR ('\n'); - } + { + print_long_format (sorted_file[i]); + DIRED_PUTCHAR ('\n'); + } break; } } @@ -3400,7 +3421,7 @@ print_current_files (void) static size_t align_nstrftime (char *buf, size_t size, char const *fmt, struct tm const *tm, - int __utc, int __ns) + int __utc, int __ns) { const char *nfmt = fmt; /* In the unlikely event that rpl_fmt below is not large enough, @@ -3410,14 +3431,14 @@ align_nstrftime (char *buf, size_t size, char const *fmt, struct tm const *tm, if (required_mon_width && (pb = strstr (fmt, "%b"))) { if (strlen (fmt) < (sizeof (rpl_fmt) - sizeof (abmon[0]) + 2)) - { - char *pfmt = rpl_fmt; - nfmt = rpl_fmt; + { + char *pfmt = rpl_fmt; + nfmt = rpl_fmt; - pfmt = mempcpy (pfmt, fmt, pb - fmt); - pfmt = stpcpy (pfmt, abmon[tm->tm_mon]); - strcpy (pfmt, pb + 2); - } + pfmt = mempcpy (pfmt, fmt, pb - fmt); + pfmt = stpcpy (pfmt, abmon[tm->tm_mon]); + strcpy (pfmt, pb + 2); + } } return nstrftime (buf, size, nfmt, tm, __utc, __ns); } @@ -3437,22 +3458,22 @@ long_time_expected_width (void) char buf[TIME_STAMP_LEN_MAXIMUM + 1]; /* In case you're wondering if localtime can fail with an input time_t - value of 0, let's just say it's very unlikely, but not inconceivable. - The TZ environment variable would have to specify a time zone that - is 2**31-1900 years or more ahead of UTC. This could happen only on - a 64-bit system that blindly accepts e.g., TZ=UTC+20000000000000. - However, this is not possible with Solaris 10 or glibc-2.3.5, since - their implementations limit the offset to 167:59 and 24:00, resp. */ + value of 0, let's just say it's very unlikely, but not inconceivable. + The TZ environment variable would have to specify a time zone that + is 2**31-1900 years or more ahead of UTC. This could happen only on + a 64-bit system that blindly accepts e.g., TZ=UTC+20000000000000. + However, this is not possible with Solaris 10 or glibc-2.3.5, since + their implementations limit the offset to 167:59 and 24:00, resp. */ if (tm) - { - size_t len = - align_nstrftime (buf, sizeof buf, long_time_format[0], tm, 0, 0); - if (len != 0) - width = mbsnwidth (buf, len, 0); - } + { + size_t len = + align_nstrftime (buf, sizeof buf, long_time_format[0], tm, 0, 0); + if (len != 0) + width = mbsnwidth (buf, len, 0); + } if (width < 0) - width = 0; + width = 0; } return width; @@ -3474,7 +3495,7 @@ format_user_or_group (char const *name, unsigned long int id, int width) len = strlen (name) + pad; do - putchar (' '); + putchar (' '); while (pad--); } else @@ -3493,7 +3514,7 @@ static void format_user (uid_t u, int width, bool stat_ok) { format_user_or_group (! stat_ok ? "?" : - (numeric_ids ? NULL : getuser (u)), u, width); + (numeric_ids ? NULL : getuser (u)), u, width); } /* Likewise, for groups. */ @@ -3502,7 +3523,7 @@ static void format_group (gid_t g, int width, bool stat_ok) { format_user_or_group (! stat_ok ? "?" : - (numeric_ids ? NULL : getgroup (g)), g, width); + (numeric_ids ? NULL : getgroup (g)), g, width); } /* Return the number of columns that format_user_or_group will print. */ @@ -3598,11 +3619,11 @@ print_long_format (const struct fileinfo *f) { char hbuf[INT_BUFSIZE_BOUND (uintmax_t)]; sprintf (p, "%*s ", inode_number_width, - (f->stat.st_ino == NOT_AN_INODE_NUMBER - ? "?" - : umaxtostr (f->stat.st_ino, hbuf))); + (f->stat.st_ino == NOT_AN_INODE_NUMBER + ? "?" + : umaxtostr (f->stat.st_ino, hbuf))); /* Increment by strlen (p) here, rather than by inode_number_width + 1. - The latter is wrong when inode_number_width is zero. */ + The latter is wrong when inode_number_width is zero. */ p += strlen (p); } @@ -3610,15 +3631,15 @@ print_long_format (const struct fileinfo *f) { char hbuf[LONGEST_HUMAN_READABLE + 1]; char const *blocks = - (! f->stat_ok - ? "?" - : human_readable (ST_NBLOCKS (f->stat), hbuf, human_output_opts, - ST_NBLOCKSIZE, output_block_size)); + (! f->stat_ok + ? "?" + : human_readable (ST_NBLOCKS (f->stat), hbuf, human_output_opts, + ST_NBLOCKSIZE, output_block_size)); int pad; for (pad = block_size_width - mbswidth (blocks, 0); 0 < pad; pad--) - *p++ = ' '; + *p++ = ' '; while ((*p++ = *blocks++)) - continue; + continue; p[-1] = ' '; } @@ -3627,7 +3648,7 @@ print_long_format (const struct fileinfo *f) { char hbuf[INT_BUFSIZE_BOUND (uintmax_t)]; sprintf (p, "%s %*s ", modebuf, nlink_width, - ! f->stat_ok ? "?" : umaxtostr (f->stat.st_nlink, hbuf)); + ! f->stat_ok ? "?" : umaxtostr (f->stat.st_nlink, hbuf)); } /* Increment by strlen (p) here, rather than by, e.g., sizeof modebuf - 2 + any_has_acl + 1 + nlink_width + 1. @@ -3641,16 +3662,16 @@ print_long_format (const struct fileinfo *f) DIRED_FPUTS (buf, stdout, p - buf); if (print_owner) - format_user (f->stat.st_uid, owner_width, f->stat_ok); + format_user (f->stat.st_uid, owner_width, f->stat_ok); if (print_group) - format_group (f->stat.st_gid, group_width, f->stat_ok); + format_group (f->stat.st_gid, group_width, f->stat_ok); if (print_author) - format_user (f->stat.st_author, author_width, f->stat_ok); + format_user (f->stat.st_author, author_width, f->stat_ok); if (print_scontext) - format_user_or_group (f->scontext, 0, scontext_width); + format_user_or_group (f->scontext, 0, scontext_width); p = buf; } @@ -3662,13 +3683,13 @@ print_long_format (const struct fileinfo *f) char majorbuf[INT_BUFSIZE_BOUND (uintmax_t)]; char minorbuf[INT_BUFSIZE_BOUND (uintmax_t)]; int blanks_width = (file_size_width - - (major_device_number_width + 2 - + minor_device_number_width)); + - (major_device_number_width + 2 + + minor_device_number_width)); sprintf (p, "%*s, %*s ", - major_device_number_width + MAX (0, blanks_width), - umaxtostr (major (f->stat.st_rdev), majorbuf), - minor_device_number_width, - umaxtostr (minor (f->stat.st_rdev), minorbuf)); + major_device_number_width + MAX (0, blanks_width), + umaxtostr (major (f->stat.st_rdev), majorbuf), + minor_device_number_width, + umaxtostr (minor (f->stat.st_rdev), minorbuf)); p += file_size_width + 1; } else @@ -3676,15 +3697,15 @@ print_long_format (const struct fileinfo *f) { char hbuf[LONGEST_HUMAN_READABLE + 1]; char const *size = - (! f->stat_ok - ? "?" - : human_readable (unsigned_file_size (f->stat.st_size), - hbuf, human_output_opts, 1, file_output_block_size)); + (! f->stat_ok + ? "?" + : human_readable (unsigned_file_size (f->stat.st_size), + hbuf, human_output_opts, 1, file_output_block_size)); int pad; for (pad = file_size_width - mbswidth (size, 0); 0 < pad; pad--) - *p++ = ' '; + *p++ = ' '; while ((*p++ = *size++)) - continue; + continue; p[-1] = ' '; } @@ -3699,32 +3720,32 @@ print_long_format (const struct fileinfo *f) char const *fmt; /* If the file appears to be in the future, update the current - time, in case the file happens to have been modified since - the last time we checked the clock. */ + time, in case the file happens to have been modified since + the last time we checked the clock. */ if (timespec_cmp (current_time, when_timespec) < 0) - { - /* Note that gettime may call gettimeofday which, on some non- - compliant systems, clobbers the buffer used for localtime's result. - But it's ok here, because we use a gettimeofday wrapper that - saves and restores the buffer around the gettimeofday call. */ - gettime (¤t_time); - } + { + /* Note that gettime may call gettimeofday which, on some non- + compliant systems, clobbers the buffer used for localtime's result. + But it's ok here, because we use a gettimeofday wrapper that + saves and restores the buffer around the gettimeofday call. */ + gettime (¤t_time); + } /* Consider a time to be recent if it is within the past six - months. A Gregorian year has 365.2425 * 24 * 60 * 60 == - 31556952 seconds on the average. Write this value as an - integer constant to avoid floating point hassles. */ + months. A Gregorian year has 365.2425 * 24 * 60 * 60 == + 31556952 seconds on the average. Write this value as an + integer constant to avoid floating point hassles. */ six_months_ago.tv_sec = current_time.tv_sec - 31556952 / 2; six_months_ago.tv_nsec = current_time.tv_nsec; recent = (timespec_cmp (six_months_ago, when_timespec) < 0 - && (timespec_cmp (when_timespec, current_time) < 0)); + && (timespec_cmp (when_timespec, current_time) < 0)); fmt = long_time_format[recent]; /* We assume here that all time zones are offset from UTC by a - whole number of seconds. */ + whole number of seconds. */ s = align_nstrftime (p, TIME_STAMP_LEN_MAXIMUM + 1, fmt, - when_local, 0, when_timespec.tv_nsec); + when_local, 0, when_timespec.tv_nsec); } if (s || !*p) @@ -3738,12 +3759,12 @@ print_long_format (const struct fileinfo *f) else { /* The time cannot be converted using the desired format, so - print it as a huge integer number of seconds. */ + print it as a huge integer number of seconds. */ char hbuf[INT_BUFSIZE_BOUND (intmax_t)]; sprintf (p, "%*s ", long_time_expected_width (), - (! f->stat_ok - ? "?" - : timetostr (when_timespec.tv_sec, hbuf))); + (! f->stat_ok + ? "?" + : timetostr (when_timespec.tv_sec, hbuf))); /* FIXME: (maybe) We discarded when_timespec.tv_nsec. */ p += strlen (p); } @@ -3751,20 +3772,20 @@ print_long_format (const struct fileinfo *f) DIRED_FPUTS (buf, stdout, p - buf); { size_t w = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), f->linkok, - f->stat_ok, f->filetype, &dired_obstack, - f->stat.st_nlink, p - buf); + f->stat_ok, f->filetype, &dired_obstack, + f->stat.st_nlink, p - buf); if (f->filetype == symbolic_link) { if (f->linkname) - { - DIRED_FPUTS_LITERAL (" -> ", stdout); - print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1, - f->stat_ok, f->filetype, NULL, - f->stat.st_nlink, (p - buf) + w + 4); - if (indicator_style != none) - print_type_indicator (true, f->linkmode, unknown); - } + { + DIRED_FPUTS_LITERAL (" -> ", stdout); + print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1, + f->stat_ok, f->filetype, NULL, + f->stat.st_nlink, (p - buf) + w + 4); + if (indicator_style != none) + print_type_indicator (true, f->linkmode, unknown); + } } else if (indicator_style != none) print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype); @@ -3779,7 +3800,7 @@ print_long_format (const struct fileinfo *f) static size_t quote_name (FILE *out, const char *name, struct quoting_options const *options, - size_t *width) + size_t *width) { char smallbuf[BUFSIZ]; size_t len = quotearg_buffer (smallbuf, sizeof smallbuf, name, -1, options); @@ -3797,137 +3818,137 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options, if (qmark_funny_chars) { if (MB_CUR_MAX > 1) - { - char const *p = buf; - char const *plimit = buf + len; - char *q = buf; - displayed_width = 0; + { + char const *p = buf; + char const *plimit = buf + len; + char *q = buf; + displayed_width = 0; - while (p < plimit) - switch (*p) - { - case ' ': case '!': case '"': case '#': case '%': - case '&': case '\'': case '(': case ')': case '*': - case '+': case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': - case '?': - case 'A': case 'B': case 'C': case 'D': case 'E': - case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'L': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': case 'Y': - case 'Z': - case '[': case '\\': case ']': case '^': case '_': - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': - case 'z': case '{': case '|': case '}': case '~': - /* These characters are printable ASCII characters. */ - *q++ = *p++; - displayed_width += 1; - break; - default: - /* If we have a multibyte sequence, copy it until we - reach its end, replacing each non-printable multibyte - character with a single question mark. */ - { - DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate); - do - { - wchar_t wc; - size_t bytes; - int w; + while (p < plimit) + switch (*p) + { + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* These characters are printable ASCII characters. */ + *q++ = *p++; + displayed_width += 1; + break; + default: + /* If we have a multibyte sequence, copy it until we + reach its end, replacing each non-printable multibyte + character with a single question mark. */ + { + DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate); + do + { + wchar_t wc; + size_t bytes; + int w; - bytes = mbrtowc (&wc, p, plimit - p, &mbstate); + bytes = mbrtowc (&wc, p, plimit - p, &mbstate); - if (bytes == (size_t) -1) - { - /* An invalid multibyte sequence was - encountered. Skip one input byte, and - put a question mark. */ - p++; - *q++ = '?'; - displayed_width += 1; - break; - } + if (bytes == (size_t) -1) + { + /* An invalid multibyte sequence was + encountered. Skip one input byte, and + put a question mark. */ + p++; + *q++ = '?'; + displayed_width += 1; + break; + } - if (bytes == (size_t) -2) - { - /* An incomplete multibyte character - at the end. Replace it entirely with - a question mark. */ - p = plimit; - *q++ = '?'; - displayed_width += 1; - break; - } + if (bytes == (size_t) -2) + { + /* An incomplete multibyte character + at the end. Replace it entirely with + a question mark. */ + p = plimit; + *q++ = '?'; + displayed_width += 1; + break; + } - if (bytes == 0) - /* A null wide character was encountered. */ - bytes = 1; + if (bytes == 0) + /* A null wide character was encountered. */ + bytes = 1; - w = wcwidth (wc); - if (w >= 0) - { - /* A printable multibyte character. - Keep it. */ - for (; bytes > 0; --bytes) - *q++ = *p++; - displayed_width += w; - } - else - { - /* An unprintable multibyte character. - Replace it entirely with a question - mark. */ - p += bytes; - *q++ = '?'; - displayed_width += 1; - } - } - while (! mbsinit (&mbstate)); - } - break; - } + w = wcwidth (wc); + if (w >= 0) + { + /* A printable multibyte character. + Keep it. */ + for (; bytes > 0; --bytes) + *q++ = *p++; + displayed_width += w; + } + else + { + /* An unprintable multibyte character. + Replace it entirely with a question + mark. */ + p += bytes; + *q++ = '?'; + displayed_width += 1; + } + } + while (! mbsinit (&mbstate)); + } + break; + } - /* The buffer may have shrunk. */ - len = q - buf; - } + /* The buffer may have shrunk. */ + len = q - buf; + } else - { - char *p = buf; - char const *plimit = buf + len; + { + char *p = buf; + char const *plimit = buf + len; - while (p < plimit) - { - if (! isprint (to_uchar (*p))) - *p = '?'; - p++; - } - displayed_width = len; - } + while (p < plimit) + { + if (! isprint (to_uchar (*p))) + *p = '?'; + p++; + } + displayed_width = len; + } } else if (width != NULL) { if (MB_CUR_MAX > 1) - displayed_width = mbsnwidth (buf, len, 0); + displayed_width = mbsnwidth (buf, len, 0); else - { - char const *p = buf; - char const *plimit = buf + len; + { + char const *p = buf; + char const *plimit = buf + len; - displayed_width = 0; - while (p < plimit) - { - if (isprint (to_uchar (*p))) - displayed_width++; - p++; - } - } + displayed_width = 0; + while (p < plimit) + { + if (isprint (to_uchar (*p))) + displayed_width++; + p++; + } + } } if (out != NULL) @@ -3939,9 +3960,9 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options, static size_t print_name_with_quoting (const char *p, mode_t mode, int linkok, - bool stat_ok, enum filetype type, - struct obstack *stack, nlink_t nlink, - size_t start_col) + bool stat_ok, enum filetype type, + struct obstack *stack, nlink_t nlink, + size_t start_col) { size_t width; bool used_color_this_time @@ -3962,7 +3983,7 @@ print_name_with_quoting (const char *p, mode_t mode, int linkok, process_signals (); prep_non_filename_text (); if (start_col / line_length != (start_col + width - 1) / line_length) - put_indicator (&color_indicator[C_CLR_TO_EOL]); + put_indicator (&color_indicator[C_CLR_TO_EOL]); } return width; @@ -3992,19 +4013,19 @@ print_file_name_and_frills (const struct fileinfo *f, size_t start_col) if (print_inode) printf ("%*s ", format == with_commas ? 0 : inode_number_width, - umaxtostr (f->stat.st_ino, buf)); + umaxtostr (f->stat.st_ino, buf)); if (print_block_size) printf ("%*s ", format == with_commas ? 0 : block_size_width, - human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts, - ST_NBLOCKSIZE, output_block_size)); + human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts, + ST_NBLOCKSIZE, output_block_size)); if (print_scontext) printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext); { size_t width = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), - f->linkok, f->stat_ok, f->filetype, - NULL, f->stat.st_nlink, start_col); + f->linkok, f->stat_ok, f->filetype, + NULL, f->stat.st_nlink, start_col); if (indicator_style != none) width += print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype); @@ -4023,26 +4044,26 @@ get_type_indicator (bool stat_ok, mode_t mode, enum filetype type) if (stat_ok ? S_ISREG (mode) : type == normal) { if (stat_ok && indicator_style == classify && (mode & S_IXUGO)) - c = '*'; + c = '*'; else - c = 0; + c = 0; } else { if (stat_ok ? S_ISDIR (mode) : type == directory || type == arg_directory) - c = '/'; + c = '/'; else if (indicator_style == slash) - c = 0; + c = 0; else if (stat_ok ? S_ISLNK (mode) : type == symbolic_link) - c = '@'; + c = '@'; else if (stat_ok ? S_ISFIFO (mode) : type == fifo) - c = '|'; + c = '|'; else if (stat_ok ? S_ISSOCK (mode) : type == sock) - c = '='; + c = '='; else if (stat_ok && S_ISDOOR (mode)) - c = '>'; + c = '>'; else - c = 0; + c = 0; } return c; } @@ -4090,8 +4111,8 @@ has_capability (char const *name ATTRIBUTE_UNUSED) /* Returns whether any color sequence was printed. */ static bool print_color_indicator (const char *name, mode_t mode, int linkok, - bool stat_ok, enum filetype filetype, - nlink_t nlink) + bool stat_ok, enum filetype filetype, + nlink_t nlink) { int type; struct color_ext_type *ext; /* Color extension */ @@ -4109,48 +4130,48 @@ print_color_indicator (const char *name, mode_t mode, int linkok, else { if (S_ISREG (mode)) - { - type = C_FILE; - if ((mode & S_ISUID) != 0) - type = C_SETUID; - else if ((mode & S_ISGID) != 0) - type = C_SETGID; - else if (is_colored (C_CAP) && has_capability (name)) - type = C_CAP; - else if ((mode & S_IXUGO) != 0) - type = C_EXEC; - else if (is_colored (C_MULTIHARDLINK) && (1 < nlink)) - type = C_MULTIHARDLINK; - } + { + type = C_FILE; + if ((mode & S_ISUID) != 0) + type = C_SETUID; + else if ((mode & S_ISGID) != 0) + type = C_SETGID; + else if (is_colored (C_CAP) && has_capability (name)) + type = C_CAP; + else if ((mode & S_IXUGO) != 0) + type = C_EXEC; + else if (is_colored (C_MULTIHARDLINK) && (1 < nlink)) + type = C_MULTIHARDLINK; + } else if (S_ISDIR (mode)) - { - if ((mode & S_ISVTX) && (mode & S_IWOTH)) - type = C_STICKY_OTHER_WRITABLE; - else if ((mode & S_IWOTH) != 0) - type = C_OTHER_WRITABLE; - else if ((mode & S_ISVTX) != 0) - type = C_STICKY; - else - type = C_DIR; - } + { + if ((mode & S_ISVTX) && (mode & S_IWOTH)) + type = C_STICKY_OTHER_WRITABLE; + else if ((mode & S_IWOTH) != 0) + type = C_OTHER_WRITABLE; + else if ((mode & S_ISVTX) != 0) + type = C_STICKY; + else + type = C_DIR; + } else if (S_ISLNK (mode)) - type = ((!linkok && color_indicator[C_ORPHAN].string) - ? C_ORPHAN : C_LINK); + type = ((!linkok && color_indicator[C_ORPHAN].string) + ? C_ORPHAN : C_LINK); else if (S_ISFIFO (mode)) - type = C_FIFO; + type = C_FIFO; else if (S_ISSOCK (mode)) - type = C_SOCK; + type = C_SOCK; else if (S_ISBLK (mode)) - type = C_BLK; + type = C_BLK; else if (S_ISCHR (mode)) - type = C_CHR; + type = C_CHR; else if (S_ISDOOR (mode)) - type = C_DOOR; + type = C_DOOR; else - { - /* Classify a file of some other type as C_ORPHAN. */ - type = C_ORPHAN; - } + { + /* Classify a file of some other type as C_ORPHAN. */ + type = C_ORPHAN; + } } /* Check the file's suffix only if still classified as C_FILE. */ @@ -4162,12 +4183,12 @@ print_color_indicator (const char *name, mode_t mode, int linkok, len = strlen (name); name += len; /* Pointer to final \0. */ for (ext = color_ext_list; ext != NULL; ext = ext->next) - { - if (ext->ext.len <= len - && strncmp (name - ext->ext.len, ext->ext.string, - ext->ext.len) == 0) - break; - } + { + if (ext->ext.len <= len + && strncmp (name - ext->ext.len, ext->ext.string, + ext->ext.len) == 0) + break; + } } { @@ -4175,10 +4196,10 @@ print_color_indicator (const char *name, mode_t mode, int linkok, = ext ? &(ext->seq) : &color_indicator[type]; if (s->string != NULL) { - put_indicator (&color_indicator[C_LEFT]); - put_indicator (s); - put_indicator (&color_indicator[C_RIGHT]); - return true; + put_indicator (&color_indicator[C_LEFT]); + put_indicator (s); + put_indicator (&color_indicator[C_RIGHT]); + return true; } else return false; @@ -4207,15 +4228,15 @@ length_of_file_name_and_frills (const struct fileinfo *f) if (print_inode) len += 1 + (format == with_commas - ? strlen (umaxtostr (f->stat.st_ino, buf)) - : inode_number_width); + ? strlen (umaxtostr (f->stat.st_ino, buf)) + : inode_number_width); if (print_block_size) len += 1 + (format == with_commas - ? strlen (human_readable (ST_NBLOCKS (f->stat), buf, - human_output_opts, ST_NBLOCKSIZE, - output_block_size)) - : block_size_width); + ? strlen (human_readable (ST_NBLOCKS (f->stat), buf, + human_output_opts, ST_NBLOCKSIZE, + output_block_size)) + : block_size_width); if (print_scontext) len += 1 + (format == with_commas ? strlen (f->scontext) : scontext_width); @@ -4251,19 +4272,19 @@ print_many_per_line (void) /* Print the next row. */ while (1) - { - struct fileinfo const *f = sorted_file[filesno]; - size_t name_length = length_of_file_name_and_frills (f); - size_t max_name_length = line_fmt->col_arr[col++]; - print_file_name_and_frills (f, pos); + { + struct fileinfo const *f = sorted_file[filesno]; + size_t name_length = length_of_file_name_and_frills (f); + size_t max_name_length = line_fmt->col_arr[col++]; + print_file_name_and_frills (f, pos); - filesno += rows; - if (filesno >= cwd_n_used) - break; + filesno += rows; + if (filesno >= cwd_n_used) + break; - indent (pos + name_length, pos + max_name_length); - pos += max_name_length; - } + indent (pos + name_length, pos + max_name_length); + pos += max_name_length; + } putchar ('\n'); } } @@ -4288,15 +4309,15 @@ print_horizontal (void) size_t col = filesno % cols; if (col == 0) - { - putchar ('\n'); - pos = 0; - } + { + putchar ('\n'); + pos = 0; + } else - { - indent (pos + name_length, pos + max_name_length); - pos += max_name_length; - } + { + indent (pos + name_length, pos + max_name_length); + pos += max_name_length; + } f = sorted_file[filesno]; print_file_name_and_frills (f, pos); @@ -4319,23 +4340,23 @@ print_with_commas (void) size_t len = length_of_file_name_and_frills (f); if (filesno != 0) - { - char separator; + { + char separator; - if (pos + len + 2 < line_length) - { - pos += 2; - separator = ' '; - } - else - { - pos = 0; - separator = '\n'; - } + if (pos + len + 2 < line_length) + { + pos += 2; + separator = ' '; + } + else + { + pos = 0; + separator = '\n'; + } - putchar (','); - putchar (separator); - } + putchar (','); + putchar (separator); + } print_file_name_and_frills (f, pos); pos += len; @@ -4352,15 +4373,15 @@ indent (size_t from, size_t to) while (from < to) { if (tabsize != 0 && to / tabsize > (from + 1) / tabsize) - { - putchar ('\t'); - from += tabsize - from % tabsize; - } + { + putchar ('\t'); + from += tabsize - from % tabsize; + } else - { - putchar (' '); - from++; - } + { + putchar (' '); + from++; + } } } @@ -4377,10 +4398,10 @@ attach (char *dest, const char *dirname, const char *name) if (dirname[0] != '.' || dirname[1] != 0) { while (*dirnamep) - *dest++ = *dirnamep++; + *dest++ = *dirnamep++; /* Add '/' if `dirname' doesn't already end with it. */ if (dirnamep > dirname && dirnamep[-1] != '/') - *dest++ = '/'; + *dest++ = '/'; } while (*name) *dest++ = *name++; @@ -4406,41 +4427,41 @@ init_column_info (void) size_t *p; if (max_cols < max_idx / 2) - { - /* The number of columns is far less than the display width - allows. Grow the allocation, but only so that it's - double the current requirements. If the display is - extremely wide, this avoids allocating a lot of memory - that is never needed. */ - column_info = xnrealloc (column_info, max_cols, - 2 * sizeof *column_info); - new_column_info_alloc = 2 * max_cols; - } + { + /* The number of columns is far less than the display width + allows. Grow the allocation, but only so that it's + double the current requirements. If the display is + extremely wide, this avoids allocating a lot of memory + that is never needed. */ + column_info = xnrealloc (column_info, max_cols, + 2 * sizeof *column_info); + new_column_info_alloc = 2 * max_cols; + } else - { - column_info = xnrealloc (column_info, max_idx, sizeof *column_info); - new_column_info_alloc = max_idx; - } + { + column_info = xnrealloc (column_info, max_idx, sizeof *column_info); + new_column_info_alloc = max_idx; + } /* Allocate the new size_t objects by computing the triangle - formula n * (n + 1) / 2, except that we don't need to - allocate the part of the triangle that we've already - allocated. Check for address arithmetic overflow. */ + formula n * (n + 1) / 2, except that we don't need to + allocate the part of the triangle that we've already + allocated. Check for address arithmetic overflow. */ { - size_t column_info_growth = new_column_info_alloc - column_info_alloc; - size_t s = column_info_alloc + 1 + new_column_info_alloc; - size_t t = s * column_info_growth; - if (s < new_column_info_alloc || t / column_info_growth != s) - xalloc_die (); - p = xnmalloc (t / 2, sizeof *p); + size_t column_info_growth = new_column_info_alloc - column_info_alloc; + size_t s = column_info_alloc + 1 + new_column_info_alloc; + size_t t = s * column_info_growth; + if (s < new_column_info_alloc || t / column_info_growth != s) + xalloc_die (); + p = xnmalloc (t / 2, sizeof *p); } /* Grow the triangle by parceling out the cells just allocated. */ for (i = column_info_alloc; i < new_column_info_alloc; i++) - { - column_info[i].col_arr = p; - p += i + 1; - } + { + column_info[i].col_arr = p; + p += i + 1; + } column_info_alloc = new_column_info_alloc; } @@ -4452,7 +4473,7 @@ init_column_info (void) column_info[i].valid_len = true; column_info[i].line_len = (i + 1) * MIN_COLUMN_WIDTH; for (j = 0; j <= i; ++j) - column_info[i].col_arr[j] = MIN_COLUMN_WIDTH; + column_info[i].col_arr[j] = MIN_COLUMN_WIDTH; } } @@ -4480,31 +4501,31 @@ calculate_columns (bool by_columns) size_t i; for (i = 0; i < max_cols; ++i) - { - if (column_info[i].valid_len) - { - size_t idx = (by_columns - ? filesno / ((cwd_n_used + i) / (i + 1)) - : filesno % (i + 1)); - size_t real_length = name_length + (idx == i ? 0 : 2); + { + if (column_info[i].valid_len) + { + size_t idx = (by_columns + ? filesno / ((cwd_n_used + i) / (i + 1)) + : filesno % (i + 1)); + size_t real_length = name_length + (idx == i ? 0 : 2); - if (column_info[i].col_arr[idx] < real_length) - { - column_info[i].line_len += (real_length - - column_info[i].col_arr[idx]); - column_info[i].col_arr[idx] = real_length; - column_info[i].valid_len = (column_info[i].line_len - < line_length); - } - } - } + if (column_info[i].col_arr[idx] < real_length) + { + column_info[i].line_len += (real_length + - column_info[i].col_arr[idx]); + column_info[i].col_arr[idx] = real_length; + column_info[i].valid_len = (column_info[i].line_len + < line_length); + } + } + } } /* Find maximum allowed columns. */ for (cols = max_cols; 1 < cols; --cols) { if (column_info[cols - 1].valid_len) - break; + break; } return cols; @@ -4515,7 +4536,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name); @@ -4534,7 +4555,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -b, --escape print octal escapes for nongraphic characters\n\ "), stdout); fputs (_("\ - --block-size=SIZE use SIZE-byte blocks\n\ + --block-size=SIZE use SIZE-byte blocks. See SIZE format below\n\ -B, --ignore-backups do not list implied entries ending with ~\n\ -c with -lt: sort by, and show, ctime (time of last\n\ modification of file status information)\n\ @@ -4655,10 +4676,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - fputs (_("\n\ -SIZE may be (or may be an integer optionally followed by) one of following:\n\ -kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\ -"), stdout); + emit_size_note (); fputs (_("\ \n\ By default, color is not used to distinguish types of files. That is\n\ diff --git a/src/bin/coreutils/src/md5sum.c b/src/bin/coreutils/src/md5sum.c index 1b1ae6aa0d..c8e01efb84 100644 --- a/src/bin/coreutils/src/md5sum.c +++ b/src/bin/coreutils/src/md5sum.c @@ -147,7 +147,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -156,26 +156,26 @@ Print or check %s (%d-bit) checksums.\n\ With no FILE, or when FILE is -, read standard input.\n\ \n\ "), - program_name, - DIGEST_TYPE_STRING, - DIGEST_BITS); + program_name, + DIGEST_TYPE_STRING, + DIGEST_BITS); if (O_BINARY) - fputs (_("\ + fputs (_("\ -b, --binary read in binary mode (default unless reading tty stdin)\n\ "), stdout); else - fputs (_("\ + fputs (_("\ -b, --binary read in binary mode\n\ "), stdout); printf (_("\ -c, --check read %s sums from the FILEs and check them\n"), - DIGEST_TYPE_STRING); + DIGEST_TYPE_STRING); if (O_BINARY) - fputs (_("\ + fputs (_("\ -t, --text read in text mode (default if reading tty stdin)\n\ "), stdout); else - fputs (_("\ + fputs (_("\ -t, --text read in text mode (default)\n\ "), stdout); fputs (_("\ @@ -194,7 +194,7 @@ The sums are computed as described in %s. When checking, the input\n\ should be a former output of this program. The default mode is to print\n\ a line with checksum, a character indicating type (`*' for binary, ` ' for\n\ text), and name for each FILE.\n"), - DIGEST_REFERENCE); + DIGEST_REFERENCE); emit_bug_reporting_address (); } @@ -249,7 +249,7 @@ bsd_split_3 (char *s, size_t s_len, unsigned char **hex_digest, char **file_name static bool split_3 (char *s, size_t s_len, - unsigned char **hex_digest, int *binary, char **file_name) + unsigned char **hex_digest, int *binary, char **file_name) { size_t i; bool escaped_filename = false; @@ -264,12 +264,12 @@ split_3 (char *s, size_t s_len, if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0) { if (strncmp (s + i + algo_name_len, " (", 2) == 0) - { - *binary = 0; - return bsd_split_3 (s + i + algo_name_len + 2, - s_len - (i + algo_name_len + 2), - hex_digest, file_name); - } + { + *binary = 0; + return bsd_split_3 (s + i + algo_name_len + 2, + s_len - (i + algo_name_len + 2), + hex_digest, file_name); + } } /* Ignore this line if it is too short. @@ -306,45 +306,45 @@ split_3 (char *s, size_t s_len, if (escaped_filename) { /* Translate each `\n' string in the file name to a NEWLINE, - and each `\\' string to a backslash. */ + and each `\\' string to a backslash. */ char *dst = &s[i]; while (i < s_len) - { - switch (s[i]) - { - case '\\': - if (i == s_len - 1) - { - /* A valid line does not end with a backslash. */ - return false; - } - ++i; - switch (s[i++]) - { - case 'n': - *dst++ = '\n'; - break; - case '\\': - *dst++ = '\\'; - break; - default: - /* Only `\' or `n' may follow a backslash. */ - return false; - } - break; + { + switch (s[i]) + { + case '\\': + if (i == s_len - 1) + { + /* A valid line does not end with a backslash. */ + return false; + } + ++i; + switch (s[i++]) + { + case 'n': + *dst++ = '\n'; + break; + case '\\': + *dst++ = '\\'; + break; + default: + /* Only `\' or `n' may follow a backslash. */ + return false; + } + break; - case '\0': - /* The file name may not contain a NUL. */ - return false; - break; + case '\0': + /* The file name may not contain a NUL. */ + return false; + break; - default: - *dst++ = s[i++]; - break; - } - } + default: + *dst++ = s[i++]; + break; + } + } *dst = '\0'; } return true; @@ -388,21 +388,21 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result) have_read_stdin = true; fp = stdin; if (O_BINARY && *binary) - { - if (*binary < 0) - *binary = ! isatty (STDIN_FILENO); - if (*binary) - xfreopen (NULL, "rb", stdin); - } + { + if (*binary < 0) + *binary = ! isatty (STDIN_FILENO); + if (*binary) + xfreopen (NULL, "rb", stdin); + } } else { fp = fopen (filename, (O_BINARY && *binary ? "rb" : "r")); if (fp == NULL) - { - error (0, errno, "%s", filename); - return false; - } + { + error (0, errno, "%s", filename); + return false; + } } err = DIGEST_STREAM (fp, bin_result); @@ -410,7 +410,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result) { error (0, errno, "%s", filename); if (fp != stdin) - fclose (fp); + fclose (fp); return false; } @@ -448,10 +448,10 @@ digest_check (const char *checkfile_name) { checkfile_stream = fopen (checkfile_name, "r"); if (checkfile_stream == NULL) - { - error (0, errno, "%s", checkfile_name); - return false; - } + { + error (0, errno, "%s", checkfile_name); + return false; + } } line_number = 0; @@ -466,82 +466,82 @@ digest_check (const char *checkfile_name) ++line_number; if (line_number == 0) - error (EXIT_FAILURE, 0, _("%s: too many checksum lines"), - checkfile_name); + error (EXIT_FAILURE, 0, _("%s: too many checksum lines"), + checkfile_name); line_length = getline (&line, &line_chars_allocated, checkfile_stream); if (line_length <= 0) - break; + break; /* Ignore comment lines, which begin with a '#' character. */ if (line[0] == '#') - continue; + continue; /* Remove any trailing newline. */ if (line[line_length - 1] == '\n') - line[--line_length] = '\0'; + line[--line_length] = '\0'; if (! (split_3 (line, line_length, &hex_digest, &binary, &filename) - && ! (is_stdin && STREQ (filename, "-")) - && hex_digits (hex_digest))) - { - if (warn) - { - error (0, 0, - _("%s: %" PRIuMAX - ": improperly formatted %s checksum line"), - checkfile_name, line_number, - DIGEST_TYPE_STRING); - } - } + && ! (is_stdin && STREQ (filename, "-")) + && hex_digits (hex_digest))) + { + if (warn) + { + error (0, 0, + _("%s: %" PRIuMAX + ": improperly formatted %s checksum line"), + checkfile_name, line_number, + DIGEST_TYPE_STRING); + } + } else - { - static const char bin2hex[] = { '0', '1', '2', '3', - '4', '5', '6', '7', - '8', '9', 'a', 'b', - 'c', 'd', 'e', 'f' }; - bool ok; + { + static const char bin2hex[] = { '0', '1', '2', '3', + '4', '5', '6', '7', + '8', '9', 'a', 'b', + 'c', 'd', 'e', 'f' }; + bool ok; - ++n_properly_formatted_lines; + ++n_properly_formatted_lines; - ok = digest_file (filename, &binary, bin_buffer); + ok = digest_file (filename, &binary, bin_buffer); - if (!ok) - { - ++n_open_or_read_failures; - if (!status_only) - { - printf (_("%s: FAILED open or read\n"), filename); - fflush (stdout); - } - } - else - { - size_t digest_bin_bytes = digest_hex_bytes / 2; - size_t cnt; - /* Compare generated binary number with text representation - in check file. Ignore case of hex digits. */ - for (cnt = 0; cnt < digest_bin_bytes; ++cnt) - { - if (tolower (hex_digest[2 * cnt]) - != bin2hex[bin_buffer[cnt] >> 4] - || (tolower (hex_digest[2 * cnt + 1]) - != (bin2hex[bin_buffer[cnt] & 0xf]))) - break; - } - if (cnt != digest_bin_bytes) - ++n_mismatched_checksums; + if (!ok) + { + ++n_open_or_read_failures; + if (!status_only) + { + printf (_("%s: FAILED open or read\n"), filename); + fflush (stdout); + } + } + else + { + size_t digest_bin_bytes = digest_hex_bytes / 2; + size_t cnt; + /* Compare generated binary number with text representation + in check file. Ignore case of hex digits. */ + for (cnt = 0; cnt < digest_bin_bytes; ++cnt) + { + if (tolower (hex_digest[2 * cnt]) + != bin2hex[bin_buffer[cnt] >> 4] + || (tolower (hex_digest[2 * cnt + 1]) + != (bin2hex[bin_buffer[cnt] & 0xf]))) + break; + } + if (cnt != digest_bin_bytes) + ++n_mismatched_checksums; - if (!status_only) - { - if (cnt != digest_bin_bytes) - printf ("%s: %s\n", filename, _("FAILED")); - else if (!quiet) - printf ("%s: %s\n", filename, _("OK")); - fflush (stdout); - } - } - } + if (!status_only) + { + if (cnt != digest_bin_bytes) + printf ("%s: %s\n", filename, _("FAILED")); + else if (!quiet) + printf ("%s: %s\n", filename, _("OK")); + fflush (stdout); + } + } + } } while (!feof (checkfile_stream) && !ferror (checkfile_stream)); @@ -563,39 +563,39 @@ digest_check (const char *checkfile_name) { /* Warn if no tests are found. */ error (0, 0, _("%s: no properly formatted %s checksum lines found"), - checkfile_name, DIGEST_TYPE_STRING); + checkfile_name, DIGEST_TYPE_STRING); } else { if (!status_only) - { - if (n_open_or_read_failures != 0) - error (0, 0, - ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX - " listed file could not be read", - "WARNING: %" PRIuMAX " of %" PRIuMAX - " listed files could not be read", - select_plural (n_properly_formatted_lines)), - n_open_or_read_failures, n_properly_formatted_lines); + { + if (n_open_or_read_failures != 0) + error (0, 0, + ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX + " listed file could not be read", + "WARNING: %" PRIuMAX " of %" PRIuMAX + " listed files could not be read", + select_plural (n_properly_formatted_lines)), + n_open_or_read_failures, n_properly_formatted_lines); - if (n_mismatched_checksums != 0) - { - uintmax_t n_computed_checksums = - (n_properly_formatted_lines - n_open_or_read_failures); - error (0, 0, - ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX - " computed checksum did NOT match", - "WARNING: %" PRIuMAX " of %" PRIuMAX - " computed checksums did NOT match", - select_plural (n_computed_checksums)), - n_mismatched_checksums, n_computed_checksums); - } - } + if (n_mismatched_checksums != 0) + { + uintmax_t n_computed_checksums = + (n_properly_formatted_lines - n_open_or_read_failures); + error (0, 0, + ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX + " computed checksum did NOT match", + "WARNING: %" PRIuMAX " of %" PRIuMAX + " computed checksums did NOT match", + select_plural (n_computed_checksums)), + n_mismatched_checksums, n_computed_checksums); + } + } } return (n_properly_formatted_lines != 0 - && n_mismatched_checksums == 0 - && n_open_or_read_failures == 0); + && n_mismatched_checksums == 0 + && n_open_or_read_failures == 0); } int @@ -622,33 +622,33 @@ main (int argc, char **argv) switch (opt) { case 'b': - binary = 1; - break; + binary = 1; + break; case 'c': - do_check = true; - break; + do_check = true; + break; case STATUS_OPTION: - status_only = true; - warn = false; - quiet = false; - break; + status_only = true; + warn = false; + quiet = false; + break; case 't': - binary = 0; - break; + binary = 0; + break; case 'w': - status_only = false; - warn = true; - quiet = false; - break; + status_only = false; + warn = true; + quiet = false; + break; case QUIET_OPTION: - status_only = false; - warn = false; - quiet = true; - break; + status_only = false; + warn = false; + quiet = true; + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: - usage (EXIT_FAILURE); + usage (EXIT_FAILURE); } min_digest_line_length = MIN_DIGEST_LINE_LENGTH; @@ -657,7 +657,7 @@ main (int argc, char **argv) if (0 <= binary && do_check) { error (0, 0, _("the --binary and --text options are meaningless when " - "verifying checksums")); + "verifying checksums")); usage (EXIT_FAILURE); } @@ -693,53 +693,53 @@ main (int argc, char **argv) char *file = argv[optind]; if (do_check) - ok &= digest_check (file); + ok &= digest_check (file); else - { - int file_is_binary = binary; + { + int file_is_binary = binary; - if (! digest_file (file, &file_is_binary, bin_buffer)) - ok = false; - else - { - size_t i; + if (! digest_file (file, &file_is_binary, bin_buffer)) + ok = false; + else + { + size_t i; - /* Output a leading backslash if the file name contains - a newline or backslash. */ - if (strchr (file, '\n') || strchr (file, '\\')) - putchar ('\\'); + /* Output a leading backslash if the file name contains + a newline or backslash. */ + if (strchr (file, '\n') || strchr (file, '\\')) + putchar ('\\'); - for (i = 0; i < (digest_hex_bytes / 2); ++i) - printf ("%02x", bin_buffer[i]); + for (i = 0; i < (digest_hex_bytes / 2); ++i) + printf ("%02x", bin_buffer[i]); - putchar (' '); - if (file_is_binary) - putchar ('*'); - else - putchar (' '); + putchar (' '); + if (file_is_binary) + putchar ('*'); + else + putchar (' '); - /* Translate each NEWLINE byte to the string, "\\n", - and each backslash to "\\\\". */ - for (i = 0; i < strlen (file); ++i) - { - switch (file[i]) - { - case '\n': - fputs ("\\n", stdout); - break; + /* Translate each NEWLINE byte to the string, "\\n", + and each backslash to "\\\\". */ + for (i = 0; i < strlen (file); ++i) + { + switch (file[i]) + { + case '\n': + fputs ("\\n", stdout); + break; - case '\\': - fputs ("\\\\", stdout); - break; + case '\\': + fputs ("\\\\", stdout); + break; - default: - putchar (file[i]); - break; - } - } - putchar ('\n'); - } - } + default: + putchar (file[i]); + break; + } + } + putchar ('\n'); + } + } } if (have_read_stdin && fclose (stdin) == EOF) diff --git a/src/bin/coreutils/src/mkdir.c b/src/bin/coreutils/src/mkdir.c index 17e1df5b84..4ae4875935 100644 --- a/src/bin/coreutils/src/mkdir.c +++ b/src/bin/coreutils/src/mkdir.c @@ -51,7 +51,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... DIRECTORY...\n"), program_name); @@ -129,10 +129,10 @@ process_dir (char *dir, struct savewd *wd, void *options) { struct mkdir_options const *o = options; return (make_dir_parents (dir, wd, o->make_ancestor_function, options, - o->mode, announce_mkdir, - o->mode_bits, (uid_t) -1, (gid_t) -1, true) - ? EXIT_SUCCESS - : EXIT_FAILURE); + o->mode, announce_mkdir, + o->mode_bits, (uid_t) -1, (gid_t) -1, true) + ? EXIT_SUCCESS + : EXIT_FAILURE); } int @@ -159,24 +159,24 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "pm:vZ:", longopts, NULL)) != -1) { switch (optc) - { - case 'p': - options.make_ancestor_function = make_ancestor; - break; - case 'm': - specified_mode = optarg; - break; - case 'v': /* --verbose */ - options.created_directory_format = _("created directory %s"); - break; - case 'Z': - scontext = optarg; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + { + case 'p': + options.make_ancestor_function = make_ancestor; + break; + case 'm': + specified_mode = optarg; + break; + case 'v': /* --verbose */ + options.created_directory_format = _("created directory %s"); + break; + case 'Z': + scontext = optarg; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (optind == argc) @@ -187,8 +187,8 @@ main (int argc, char **argv) if (scontext && setfscreatecon (scontext) < 0) error (EXIT_FAILURE, errno, - _("failed to set default file creation context to %s"), - quote (scontext)); + _("failed to set default file creation context to %s"), + quote (scontext)); if (options.make_ancestor_function || specified_mode) { @@ -197,19 +197,19 @@ main (int argc, char **argv) options.ancestor_mode = (S_IRWXUGO & ~umask_value) | (S_IWUSR | S_IXUSR); if (specified_mode) - { - struct mode_change *change = mode_compile (specified_mode); - if (!change) - error (EXIT_FAILURE, 0, _("invalid mode %s"), - quote (specified_mode)); - options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change, - &options.mode_bits); - free (change); - } + { + struct mode_change *change = mode_compile (specified_mode); + if (!change) + error (EXIT_FAILURE, 0, _("invalid mode %s"), + quote (specified_mode)); + options.mode = mode_adjust (S_IRWXUGO, true, umask_value, change, + &options.mode_bits); + free (change); + } else - options.mode = S_IRWXUGO & ~umask_value; + options.mode = S_IRWXUGO & ~umask_value; } exit (savewd_process_files (argc - optind, argv + optind, - process_dir, &options)); + process_dir, &options)); } diff --git a/src/bin/coreutils/src/mkfifo.c b/src/bin/coreutils/src/mkfifo.c index 74210d435f..5ea3e3b829 100644 --- a/src/bin/coreutils/src/mkfifo.c +++ b/src/bin/coreutils/src/mkfifo.c @@ -46,7 +46,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... NAME...\n"), program_name); @@ -90,18 +90,18 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "m:Z:", longopts, NULL)) != -1) { switch (optc) - { - case 'm': - specified_mode = optarg; - break; - case 'Z': - scontext = optarg; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + { + case 'm': + specified_mode = optarg; + break; + case 'Z': + scontext = optarg; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (optind == argc) @@ -112,27 +112,27 @@ main (int argc, char **argv) if (scontext && setfscreatecon (scontext) < 0) error (EXIT_FAILURE, errno, - _("failed to set default file creation context to %s"), - quote (scontext)); + _("failed to set default file creation context to %s"), + quote (scontext)); newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (specified_mode) { struct mode_change *change = mode_compile (specified_mode); if (!change) - error (EXIT_FAILURE, 0, _("invalid mode")); + error (EXIT_FAILURE, 0, _("invalid mode")); newmode = mode_adjust (newmode, false, umask (0), change, NULL); free (change); if (newmode & ~S_IRWXUGO) - error (EXIT_FAILURE, 0, - _("mode must specify only file permission bits")); + error (EXIT_FAILURE, 0, + _("mode must specify only file permission bits")); } for (; optind < argc; ++optind) if (mkfifo (argv[optind], newmode) != 0) { - error (0, errno, _("cannot create fifo %s"), quote (argv[optind])); - exit_status = EXIT_FAILURE; + error (0, errno, _("cannot create fifo %s"), quote (argv[optind])); + exit_status = EXIT_FAILURE; } exit (exit_status); diff --git a/src/bin/coreutils/src/mknod.c b/src/bin/coreutils/src/mknod.c index 9422bdbd89..94e4471ef2 100644 --- a/src/bin/coreutils/src/mknod.c +++ b/src/bin/coreutils/src/mknod.c @@ -47,11 +47,11 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... NAME TYPE [MAJOR MINOR]\n"), - program_name); + program_name); fputs (_("\ Create the special file NAME of the given TYPE.\n\ \n\ @@ -107,18 +107,18 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "m:Z:", longopts, NULL)) != -1) { switch (optc) - { - case 'm': - specified_mode = optarg; - break; - case 'Z': - scontext = optarg; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + { + case 'm': + specified_mode = optarg; + break; + case 'Z': + scontext = optarg; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); @@ -126,47 +126,47 @@ main (int argc, char **argv) { struct mode_change *change = mode_compile (specified_mode); if (!change) - error (EXIT_FAILURE, 0, _("invalid mode")); + error (EXIT_FAILURE, 0, _("invalid mode")); newmode = mode_adjust (newmode, false, umask (0), change, NULL); free (change); if (newmode & ~S_IRWXUGO) - error (EXIT_FAILURE, 0, - _("mode must specify only file permission bits")); + error (EXIT_FAILURE, 0, + _("mode must specify only file permission bits")); } /* If the number of arguments is 0 or 1, or (if it's 2 or more and the second one starts with `p'), then there must be exactly two operands. Otherwise, there must be four. */ expected_operands = (argc <= optind - || (optind + 1 < argc && argv[optind + 1][0] == 'p') - ? 2 : 4); + || (optind + 1 < argc && argv[optind + 1][0] == 'p') + ? 2 : 4); if (argc - optind < expected_operands) { if (argc <= optind) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); + error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); if (expected_operands == 4 && argc - optind == 2) - fprintf (stderr, "%s\n", - _("Special files require major and minor device numbers.")); + fprintf (stderr, "%s\n", + _("Special files require major and minor device numbers.")); usage (EXIT_FAILURE); } if (expected_operands < argc - optind) { error (0, 0, _("extra operand %s"), - quote (argv[optind + expected_operands])); + quote (argv[optind + expected_operands])); if (expected_operands == 2 && argc - optind == 4) - fprintf (stderr, "%s\n", - _("Fifos do not have major and minor device numbers.")); + fprintf (stderr, "%s\n", + _("Fifos do not have major and minor device numbers.")); usage (EXIT_FAILURE); } if (scontext && setfscreatecon (scontext) < 0) error (EXIT_FAILURE, errno, - _("failed to set default file creation context to %s"), - quote (scontext)); + _("failed to set default file creation context to %s"), + quote (scontext)); /* Only check the first character, to allow mnemonic usage like `mknod /dev/rst0 character 18 0'. */ @@ -192,35 +192,35 @@ main (int argc, char **argv) block_or_character: { - char const *s_major = argv[optind + 2]; - char const *s_minor = argv[optind + 3]; - uintmax_t i_major, i_minor; - dev_t device; + char const *s_major = argv[optind + 2]; + char const *s_minor = argv[optind + 3]; + uintmax_t i_major, i_minor; + dev_t device; - if (xstrtoumax (s_major, NULL, 0, &i_major, NULL) != LONGINT_OK - || i_major != (major_t) i_major) - error (EXIT_FAILURE, 0, - _("invalid major device number %s"), quote (s_major)); + if (xstrtoumax (s_major, NULL, 0, &i_major, NULL) != LONGINT_OK + || i_major != (major_t) i_major) + error (EXIT_FAILURE, 0, + _("invalid major device number %s"), quote (s_major)); - if (xstrtoumax (s_minor, NULL, 0, &i_minor, NULL) != LONGINT_OK - || i_minor != (minor_t) i_minor) - error (EXIT_FAILURE, 0, - _("invalid minor device number %s"), quote (s_minor)); + if (xstrtoumax (s_minor, NULL, 0, &i_minor, NULL) != LONGINT_OK + || i_minor != (minor_t) i_minor) + error (EXIT_FAILURE, 0, + _("invalid minor device number %s"), quote (s_minor)); - device = makedev (i_major, i_minor); + device = makedev (i_major, i_minor); #ifdef NODEV - if (device == NODEV) - error (EXIT_FAILURE, 0, _("invalid device %s %s"), s_major, s_minor); + if (device == NODEV) + error (EXIT_FAILURE, 0, _("invalid device %s %s"), s_major, s_minor); #endif - if (mknod (argv[optind], newmode | node_type, device) != 0) - error (EXIT_FAILURE, errno, "%s", quote (argv[optind])); + if (mknod (argv[optind], newmode | node_type, device) != 0) + error (EXIT_FAILURE, errno, "%s", quote (argv[optind])); } break; case 'p': /* `pipe' */ if (mkfifo (argv[optind], newmode) != 0) - error (EXIT_FAILURE, errno, "%s", quote (argv[optind])); + error (EXIT_FAILURE, errno, "%s", quote (argv[optind])); break; default: diff --git a/src/bin/coreutils/src/mktemp.c b/src/bin/coreutils/src/mktemp.c index 43ea416e64..a9a8708ca3 100644 --- a/src/bin/coreutils/src/mktemp.c +++ b/src/bin/coreutils/src/mktemp.c @@ -286,9 +286,3 @@ main (int argc, char **argv) exit (status); } - -/* - * Local variables: - * indent-tabs-mode: nil - * End: - */ diff --git a/src/bin/coreutils/src/mv.c b/src/bin/coreutils/src/mv.c index a13d1c5b35..413855b7df 100644 --- a/src/bin/coreutils/src/mv.c +++ b/src/bin/coreutils/src/mv.c @@ -94,7 +94,7 @@ rm_option_init (struct rm_options *x) x->root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (x->root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quote ("/")); } } @@ -105,7 +105,7 @@ cp_option_init (struct cp_options *x) cp_options_default (x); x->copy_as_regular = false; /* FIXME: maybe make this an option */ - x->reflink = false; + x->reflink_mode = REFLINK_NEVER; x->dereference = DEREF_NEVER; x->unlink_dest_before_opening = false; x->unlink_dest_after_failed_open = false; @@ -168,67 +168,67 @@ do_move (const char *source, const char *dest, const struct cp_options *x) { char const *dir_to_remove; if (copy_into_self) - { - /* In general, when copy returns with copy_into_self set, SOURCE is - the same as, or a parent of DEST. In this case we know it's a - parent. It doesn't make sense to move a directory into itself, and - besides in some situations doing so would give highly nonintuitive - results. Run this `mkdir b; touch a c; mv * b' in an empty - directory. Here's the result of running echo `find b -print`: - b b/a b/b b/b/a b/c. Notice that only file `a' was copied - into b/b. Handle this by giving a diagnostic, removing the - copied-into-self directory, DEST (`b/b' in the example), - and failing. */ + { + /* In general, when copy returns with copy_into_self set, SOURCE is + the same as, or a parent of DEST. In this case we know it's a + parent. It doesn't make sense to move a directory into itself, and + besides in some situations doing so would give highly nonintuitive + results. Run this `mkdir b; touch a c; mv * b' in an empty + directory. Here's the result of running echo `find b -print`: + b b/a b/b b/b/a b/c. Notice that only file `a' was copied + into b/b. Handle this by giving a diagnostic, removing the + copied-into-self directory, DEST (`b/b' in the example), + and failing. */ - dir_to_remove = NULL; - ok = false; - } + dir_to_remove = NULL; + ok = false; + } else if (rename_succeeded) - { - /* No need to remove anything. SOURCE was successfully - renamed to DEST. Or the user declined to rename a file. */ - dir_to_remove = NULL; - } + { + /* No need to remove anything. SOURCE was successfully + renamed to DEST. Or the user declined to rename a file. */ + dir_to_remove = NULL; + } else - { - /* This may mean SOURCE and DEST referred to different devices. - It may also conceivably mean that even though they referred - to the same device, rename wasn't implemented for that device. + { + /* This may mean SOURCE and DEST referred to different devices. + It may also conceivably mean that even though they referred + to the same device, rename wasn't implemented for that device. - E.g., (from Joel N. Weber), - [...] there might someday be cases where you can't rename - but you can copy where the device name is the same, especially - on Hurd. Consider an ftpfs with a primitive ftp server that - supports uploading, downloading and deleting, but not renaming. + E.g., (from Joel N. Weber), + [...] there might someday be cases where you can't rename + but you can copy where the device name is the same, especially + on Hurd. Consider an ftpfs with a primitive ftp server that + supports uploading, downloading and deleting, but not renaming. - Also, note that comparing device numbers is not a reliable - check for `can-rename'. Some systems can be set up so that - files from many different physical devices all have the same - st_dev field. This is a feature of some NFS mounting - configurations. + Also, note that comparing device numbers is not a reliable + check for `can-rename'. Some systems can be set up so that + files from many different physical devices all have the same + st_dev field. This is a feature of some NFS mounting + configurations. - We reach this point if SOURCE has been successfully copied - to DEST. Now we have to remove SOURCE. + We reach this point if SOURCE has been successfully copied + to DEST. Now we have to remove SOURCE. - This function used to resort to copying only when rename - failed and set errno to EXDEV. */ + This function used to resort to copying only when rename + failed and set errno to EXDEV. */ - dir_to_remove = source; - } + dir_to_remove = source; + } if (dir_to_remove != NULL) - { - struct rm_options rm_options; - enum RM_status status; + { + struct rm_options rm_options; + enum RM_status status; - rm_option_init (&rm_options); - rm_options.verbose = x->verbose; + rm_option_init (&rm_options); + rm_options.verbose = x->verbose; - status = rm (1, &dir_to_remove, &rm_options); - assert (VALID_STATUS (status)); - if (status == RM_ERROR) - ok = false; - } + status = rm (1, &dir_to_remove, &rm_options); + assert (VALID_STATUS (status)); + if (status == RM_ERROR) + ok = false; + } } return ok; @@ -240,7 +240,7 @@ do_move (const char *source, const char *dest, const struct cp_options *x) static bool movefile (char *source, char *dest, bool dest_is_dir, - const struct cp_options *x) + const struct cp_options *x) { bool ok; @@ -276,7 +276,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -284,7 +284,7 @@ Usage: %s [OPTION]... [-T] SOURCE DEST\n\ or: %s [OPTION]... SOURCE... DIRECTORY\n\ or: %s [OPTION]... -t DIRECTORY SOURCE...\n\ "), - program_name, program_name, program_name); + program_name, program_name, program_name); fputs (_("\ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n\ \n\ @@ -365,59 +365,59 @@ main (int argc, char **argv) backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX"); while ((c = getopt_long (argc, argv, "bfint:uvS:T", long_options, NULL)) - != -1) + != -1) { switch (c) - { - case 'b': - make_backups = true; - if (optarg) - version_control_string = optarg; - break; - case 'f': - x.interactive = I_ALWAYS_YES; - break; - case 'i': - x.interactive = I_ASK_USER; - break; - case 'n': - x.interactive = I_ALWAYS_NO; - break; - case STRIP_TRAILING_SLASHES_OPTION: - remove_trailing_slashes = true; - break; - case 't': - if (target_directory) - error (EXIT_FAILURE, 0, _("multiple target directories specified")); - else - { - struct stat st; - if (stat (optarg, &st) != 0) - error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg)); - if (! S_ISDIR (st.st_mode)) - error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (optarg)); - } - target_directory = optarg; - break; - case 'T': - no_target_directory = true; - break; - case 'u': - x.update = true; - break; - case 'v': - x.verbose = true; - break; - case 'S': - make_backups = true; - backup_suffix_string = optarg; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + { + case 'b': + make_backups = true; + if (optarg) + version_control_string = optarg; + break; + case 'f': + x.interactive = I_ALWAYS_YES; + break; + case 'i': + x.interactive = I_ASK_USER; + break; + case 'n': + x.interactive = I_ALWAYS_NO; + break; + case STRIP_TRAILING_SLASHES_OPTION: + remove_trailing_slashes = true; + break; + case 't': + if (target_directory) + error (EXIT_FAILURE, 0, _("multiple target directories specified")); + else + { + struct stat st; + if (stat (optarg, &st) != 0) + error (EXIT_FAILURE, errno, _("accessing %s"), quote (optarg)); + if (! S_ISDIR (st.st_mode)) + error (EXIT_FAILURE, 0, _("target %s is not a directory"), + quote (optarg)); + } + target_directory = optarg; + break; + case 'T': + no_target_directory = true; + break; + case 'u': + x.update = true; + break; + case 'v': + x.verbose = true; + break; + case 'S': + make_backups = true; + backup_suffix_string = optarg; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } n_files = argc - optind; @@ -426,39 +426,39 @@ main (int argc, char **argv) if (n_files <= !target_directory) { if (n_files <= 0) - error (0, 0, _("missing file operand")); + error (0, 0, _("missing file operand")); else - error (0, 0, _("missing destination file operand after %s"), - quote (file[0])); + error (0, 0, _("missing destination file operand after %s"), + quote (file[0])); usage (EXIT_FAILURE); } if (no_target_directory) { if (target_directory) - error (EXIT_FAILURE, 0, - _("cannot combine --target-directory (-t) " - "and --no-target-directory (-T)")); + error (EXIT_FAILURE, 0, + _("cannot combine --target-directory (-t) " + "and --no-target-directory (-T)")); if (2 < n_files) - { - error (0, 0, _("extra operand %s"), quote (file[2])); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("extra operand %s"), quote (file[2])); + usage (EXIT_FAILURE); + } } else if (!target_directory) { assert (2 <= n_files); if (target_directory_operand (file[n_files - 1])) - target_directory = file[--n_files]; + target_directory = file[--n_files]; else if (2 < n_files) - error (EXIT_FAILURE, 0, _("target %s is not a directory"), - quote (file[n_files - 1])); + error (EXIT_FAILURE, 0, _("target %s is not a directory"), + quote (file[n_files - 1])); } if (make_backups && x.interactive == I_ALWAYS_NO) { error (0, 0, - _("options --backup and --no-clobber are mutually exclusive")); + _("options --backup and --no-clobber are mutually exclusive")); usage (EXIT_FAILURE); } @@ -466,9 +466,9 @@ main (int argc, char **argv) simple_backup_suffix = xstrdup (backup_suffix_string); x.backup_type = (make_backups - ? xget_version (_("backup type"), - version_control_string) - : no_backups); + ? xget_version (_("backup type"), + version_control_string) + : no_backups); hash_init (); @@ -477,14 +477,14 @@ main (int argc, char **argv) int i; /* Initialize the hash table only if we'll need it. - The problem it is used to detect can arise only if there are - two or more files to move. */ + The problem it is used to detect can arise only if there are + two or more files to move. */ if (2 <= n_files) - dest_info_init (&x); + dest_info_init (&x); ok = true; for (i = 0; i < n_files; ++i) - ok &= movefile (file[i], target_directory, true, &x); + ok &= movefile (file[i], target_directory, true, &x); } else ok = movefile (file[0], file[1], false, &x); diff --git a/src/bin/coreutils/src/nice.c b/src/bin/coreutils/src/nice.c index d4432a37a4..4a3c092122 100644 --- a/src/bin/coreutils/src/nice.c +++ b/src/bin/coreutils/src/nice.c @@ -66,7 +66,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION] [COMMAND [ARG]...]\n"), program_name); @@ -77,7 +77,7 @@ With no COMMAND, print the current niceness. Nicenesses range from\n\ \n\ -n, --adjustment=N add integer N to the niceness (default 10)\n\ "), - - NZERO, NZERO - 1); + - NZERO, NZERO - 1); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); @@ -105,66 +105,66 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); for (i = 1; i < argc; /* empty */) { char const *s = argv[i]; if (s[0] == '-' && ISDIGIT (s[1 + (s[1] == '-' || s[1] == '+')])) - { - adjustment_given = s + 1; - ++i; - } + { + adjustment_given = s + 1; + ++i; + } else - { - int optc; - int fake_argc = argc - (i - 1); - char **fake_argv = argv + (i - 1); + { + int optc; + int fake_argc = argc - (i - 1); + char **fake_argv = argv + (i - 1); - /* Ensure that any getopt diagnostics use the right name. */ - fake_argv[0] = argv[0]; + /* Ensure that any getopt diagnostics use the right name. */ + fake_argv[0] = argv[0]; - /* Initialize getopt_long's internal state. */ - optind = 0; + /* Initialize getopt_long's internal state. */ + optind = 0; - optc = getopt_long (fake_argc, fake_argv, "+n:", longopts, NULL); - i += optind - 1; + optc = getopt_long (fake_argc, fake_argv, "+n:", longopts, NULL); + i += optind - 1; - if (optc == '?') - usage (EXIT_FAILURE); - else if (optc == 'n') - adjustment_given = optarg; - else /* optc == -1 */ - break; - } + if (optc == '?') + usage (EXIT_FAILURE); + else if (optc == 'n') + adjustment_given = optarg; + else /* optc == -1 */ + break; + } } if (adjustment_given) { /* If the requested adjustment is outside the valid range, - silently bring it to just within range; this mimics what - "setpriority" and "nice" do. */ + silently bring it to just within range; this mimics what + "setpriority" and "nice" do. */ enum { MIN_ADJUSTMENT = 1 - 2 * NZERO, MAX_ADJUSTMENT = 2 * NZERO - 1 }; long int tmp; if (LONGINT_OVERFLOW < xstrtol (adjustment_given, NULL, 10, &tmp, "")) - error (EXIT_FAILURE, 0, _("invalid adjustment %s"), - quote (adjustment_given)); + error (EXIT_FAILURE, 0, _("invalid adjustment %s"), + quote (adjustment_given)); adjustment = MAX (MIN_ADJUSTMENT, MIN (tmp, MAX_ADJUSTMENT)); } if (i == argc) { if (adjustment_given) - { - error (0, 0, _("a command must be given with an adjustment")); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("a command must be given with an adjustment")); + usage (EXIT_FAILURE); + } /* No command given; print the niceness. */ errno = 0; current_niceness = GET_NICENESS (); if (current_niceness == -1 && errno != 0) - error (EXIT_FAILURE, errno, _("cannot get niceness")); + error (EXIT_FAILURE, errno, _("cannot get niceness")); printf ("%d\n", current_niceness); exit (EXIT_SUCCESS); } diff --git a/src/bin/coreutils/src/nl.c b/src/bin/coreutils/src/nl.c index d63773a98c..773740fa59 100644 --- a/src/bin/coreutils/src/nl.c +++ b/src/bin/coreutils/src/nl.c @@ -176,13 +176,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Write each FILE to standard output, with line numbers added.\n\ With no FILE, or when FILE is -, read standard input.\n\ @@ -241,7 +241,7 @@ FORMAT is one of:\n\ static bool build_type_arg (char const **typep, - struct re_pattern_buffer *regexp, char *fastmap) + struct re_pattern_buffer *regexp, char *fastmap) { char const *errmsg; bool rval = true; @@ -260,10 +260,10 @@ build_type_arg (char const **typep, regexp->fastmap = fastmap; regexp->translate = NULL; re_syntax_options = - RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES; + RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES; errmsg = re_compile_pattern (optarg, strlen (optarg), regexp); if (errmsg) - error (EXIT_FAILURE, 0, "%s", errmsg); + error (EXIT_FAILURE, 0, "%s", errmsg); break; default: rval = false; @@ -330,42 +330,42 @@ proc_text (void) { case 'a': if (blank_join > 1) - { - if (1 < line_buf.length || ++blank_lines == blank_join) - { - print_lineno (); - blank_lines = 0; - } - else - fputs (print_no_line_fmt, stdout); - } + { + if (1 < line_buf.length || ++blank_lines == blank_join) + { + print_lineno (); + blank_lines = 0; + } + else + fputs (print_no_line_fmt, stdout); + } else - print_lineno (); + print_lineno (); break; case 't': if (1 < line_buf.length) - print_lineno (); + print_lineno (); else - fputs (print_no_line_fmt, stdout); + fputs (print_no_line_fmt, stdout); break; case 'n': fputs (print_no_line_fmt, stdout); break; case 'p': switch (re_search (current_regex, line_buf.buffer, line_buf.length - 1, - 0, line_buf.length - 1, NULL)) - { - case -2: - error (EXIT_FAILURE, errno, _("error in regular expression search")); + 0, line_buf.length - 1, NULL)) + { + case -2: + error (EXIT_FAILURE, errno, _("error in regular expression search")); - case -1: - fputs (print_no_line_fmt, stdout); - break; + case -1: + fputs (print_no_line_fmt, stdout); + break; - default: - print_lineno (); - break; - } + default: + print_lineno (); + break; + } } fwrite (line_buf.buffer, sizeof (char), line_buf.length, stdout); } @@ -399,20 +399,20 @@ process_file (FILE *fp) while (readlinebuffer (&line_buf, fp)) { switch (check_section ()) - { - case Header: - proc_header (); - break; - case Body: - proc_body (); - break; - case Footer: - proc_footer (); - break; - case Text: - proc_text (); - break; - } + { + case Header: + proc_header (); + break; + case Body: + proc_body (); + break; + case Footer: + proc_footer (); + break; + case Text: + proc_text (); + break; + } } } @@ -433,10 +433,10 @@ nl_file (char const *file) { stream = fopen (file, "r"); if (stream == NULL) - { - error (0, errno, "%s", file); - return false; - } + { + error (0, errno, "%s", file); + return false; + } } process_file (stream); @@ -474,110 +474,110 @@ main (int argc, char **argv) have_read_stdin = false; while ((c = getopt_long (argc, argv, "h:b:f:v:i:pl:s:w:n:d:", longopts, - NULL)) != -1) + NULL)) != -1) { switch (c) - { - case 'h': - if (! build_type_arg (&header_type, &header_regex, header_fastmap)) - { - error (0, 0, _("invalid header numbering style: %s"), - quote (optarg)); - ok = false; - } - break; - case 'b': - if (! build_type_arg (&body_type, &body_regex, body_fastmap)) - { - error (0, 0, _("invalid body numbering style: %s"), - quote (optarg)); - ok = false; - } - break; - case 'f': - if (! build_type_arg (&footer_type, &footer_regex, footer_fastmap)) - { - error (0, 0, _("invalid footer numbering style: %s"), - quote (optarg)); - ok = false; - } - break; - case 'v': - if (xstrtoimax (optarg, NULL, 10, &starting_line_number, "") - != LONGINT_OK) - { - error (0, 0, _("invalid starting line number: %s"), - quote (optarg)); - ok = false; - } - break; + { + case 'h': + if (! build_type_arg (&header_type, &header_regex, header_fastmap)) + { + error (0, 0, _("invalid header numbering style: %s"), + quote (optarg)); + ok = false; + } + break; + case 'b': + if (! build_type_arg (&body_type, &body_regex, body_fastmap)) + { + error (0, 0, _("invalid body numbering style: %s"), + quote (optarg)); + ok = false; + } + break; + case 'f': + if (! build_type_arg (&footer_type, &footer_regex, footer_fastmap)) + { + error (0, 0, _("invalid footer numbering style: %s"), + quote (optarg)); + ok = false; + } + break; + case 'v': + if (xstrtoimax (optarg, NULL, 10, &starting_line_number, "") + != LONGINT_OK) + { + error (0, 0, _("invalid starting line number: %s"), + quote (optarg)); + ok = false; + } + break; case PAGE_INCREMENT_OPTION_DEPRECATED: error (0, 0, _("WARNING: --page-increment is deprecated; " "use --line-increment instead")); /* fall through */ - case 'i': - if (! (xstrtoimax (optarg, NULL, 10, &page_incr, "") == LONGINT_OK - && 0 < page_incr)) - { - error (0, 0, _("invalid line number increment: %s"), - quote (optarg)); - ok = false; - } - break; - case 'p': - reset_numbers = false; - break; - case 'l': - if (! (xstrtoimax (optarg, NULL, 10, &blank_join, "") == LONGINT_OK - && 0 < blank_join)) - { - error (0, 0, _("invalid number of blank lines: %s"), - quote (optarg)); - ok = false; - } - break; - case 's': - separator_str = optarg; - break; - case 'w': - { - long int tmp_long; - if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK - || tmp_long <= 0 || tmp_long > INT_MAX) - { - error (0, 0, _("invalid line number field width: %s"), - quote (optarg)); - ok = false; - } - else - { - lineno_width = tmp_long; - } - } - break; - case 'n': - if (STREQ (optarg, "ln")) - lineno_format = FORMAT_LEFT; - else if (STREQ (optarg, "rn")) - lineno_format = FORMAT_RIGHT_NOLZ; - else if (STREQ (optarg, "rz")) - lineno_format = FORMAT_RIGHT_LZ; - else - { - error (0, 0, _("invalid line numbering format: %s"), - quote (optarg)); - ok = false; - } - break; - case 'd': - section_del = optarg; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - ok = false; - break; - } + case 'i': + if (! (xstrtoimax (optarg, NULL, 10, &page_incr, "") == LONGINT_OK + && 0 < page_incr)) + { + error (0, 0, _("invalid line number increment: %s"), + quote (optarg)); + ok = false; + } + break; + case 'p': + reset_numbers = false; + break; + case 'l': + if (! (xstrtoimax (optarg, NULL, 10, &blank_join, "") == LONGINT_OK + && 0 < blank_join)) + { + error (0, 0, _("invalid number of blank lines: %s"), + quote (optarg)); + ok = false; + } + break; + case 's': + separator_str = optarg; + break; + case 'w': + { + long int tmp_long; + if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK + || tmp_long <= 0 || tmp_long > INT_MAX) + { + error (0, 0, _("invalid line number field width: %s"), + quote (optarg)); + ok = false; + } + else + { + lineno_width = tmp_long; + } + } + break; + case 'n': + if (STREQ (optarg, "ln")) + lineno_format = FORMAT_LEFT; + else if (STREQ (optarg, "rn")) + lineno_format = FORMAT_RIGHT_NOLZ; + else if (STREQ (optarg, "rz")) + lineno_format = FORMAT_RIGHT_LZ; + else + { + error (0, 0, _("invalid line numbering format: %s"), + quote (optarg)); + ok = false; + } + break; + case 'd': + section_del = optarg; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + ok = false; + break; + } } if (!ok) diff --git a/src/bin/coreutils/src/nohup.c b/src/bin/coreutils/src/nohup.c index 5ae6d1adce..f4b1b23423 100644 --- a/src/bin/coreutils/src/nohup.c +++ b/src/bin/coreutils/src/nohup.c @@ -48,14 +48,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s COMMAND [ARG]...\n\ or: %s OPTION\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Run COMMAND, ignoring hangup signals.\n\ @@ -69,7 +69,7 @@ If standard output is a terminal, append output to `nohup.out' if possible,\n\ `$HOME/nohup.out' otherwise.\n\ If standard error is a terminal, redirect it to standard output.\n\ To save output to FILE, use `%s COMMAND > FILE'.\n"), - program_name); + program_name); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); emit_bug_reporting_address (); } @@ -96,7 +96,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "+", NULL, NULL) != -1) usage (NOHUP_FAILURE); @@ -118,7 +118,7 @@ main (int argc, char **argv) { fd_reopen (STDIN_FILENO, "/dev/null", O_WRONLY, 0); if (!redirecting_stdout && !redirecting_stderr) - error (0, 0, _("ignoring input")); + error (0, 0, _("ignoring input")); } /* If standard output is a tty, redirect it (appending) to a file. @@ -133,38 +133,38 @@ main (int argc, char **argv) mode_t mode = S_IRUSR | S_IWUSR; mode_t umask_value = umask (~mode); out_fd = (redirecting_stdout - ? fd_reopen (STDOUT_FILENO, file, flags, mode) - : open (file, flags, mode)); + ? fd_reopen (STDOUT_FILENO, file, flags, mode) + : open (file, flags, mode)); if (out_fd < 0) - { - int saved_errno = errno; - char const *home = getenv ("HOME"); - if (home) - { - in_home = file_name_concat (home, file, NULL); - out_fd = (redirecting_stdout - ? fd_reopen (STDOUT_FILENO, in_home, flags, mode) - : open (in_home, flags, mode)); - } - if (out_fd < 0) - { - int saved_errno2 = errno; - error (0, saved_errno, _("failed to open %s"), quote (file)); - if (in_home) - error (0, saved_errno2, _("failed to open %s"), - quote (in_home)); - exit (NOHUP_FAILURE); - } - file = in_home; - } + { + int saved_errno = errno; + char const *home = getenv ("HOME"); + if (home) + { + in_home = file_name_concat (home, file, NULL); + out_fd = (redirecting_stdout + ? fd_reopen (STDOUT_FILENO, in_home, flags, mode) + : open (in_home, flags, mode)); + } + if (out_fd < 0) + { + int saved_errno2 = errno; + error (0, saved_errno, _("failed to open %s"), quote (file)); + if (in_home) + error (0, saved_errno2, _("failed to open %s"), + quote (in_home)); + exit (NOHUP_FAILURE); + } + file = in_home; + } umask (umask_value); error (0, 0, - _(ignoring_input - ? N_("ignoring input and appending output to %s") - : N_("appending output to %s")), - quote (file)); + _(ignoring_input + ? N_("ignoring input and appending output to %s") + : N_("appending output to %s")), + quote (file)); free (in_home); } @@ -172,27 +172,27 @@ main (int argc, char **argv) if (redirecting_stderr) { /* Save a copy of stderr before redirecting, so we can use the original - if execve fails. It's no big deal if this dup fails. It might - not change anything, and at worst, it'll lead to suppression of - the post-failed-execve diagnostic. */ + if execve fails. It's no big deal if this dup fails. It might + not change anything, and at worst, it'll lead to suppression of + the post-failed-execve diagnostic. */ saved_stderr_fd = dup (STDERR_FILENO); if (0 <= saved_stderr_fd - && set_cloexec_flag (saved_stderr_fd, true) != 0) - error (NOHUP_FAILURE, errno, - _("failed to set the copy of stderr to close on exec")); + && set_cloexec_flag (saved_stderr_fd, true) != 0) + error (NOHUP_FAILURE, errno, + _("failed to set the copy of stderr to close on exec")); if (!redirecting_stdout) - error (0, 0, - _(ignoring_input - ? N_("ignoring input and redirecting stderr to stdout") - : N_("redirecting stderr to stdout"))); + error (0, 0, + _(ignoring_input + ? N_("ignoring input and redirecting stderr to stdout") + : N_("redirecting stderr to stdout"))); if (dup2 (out_fd, STDERR_FILENO) < 0) - error (NOHUP_FAILURE, errno, _("failed to redirect standard error")); + error (NOHUP_FAILURE, errno, _("failed to redirect standard error")); if (stdout_is_closed) - close (out_fd); + close (out_fd); } signal (SIGHUP, SIG_IGN); @@ -209,7 +209,7 @@ main (int argc, char **argv) /* The execve failed. Output a diagnostic to stderr only if: - stderr was initially redirected to a non-tty, or - stderr was initially directed to a tty, and we - can dup2 it to point back to that same tty. + can dup2 it to point back to that same tty. In other words, output the diagnostic if possible, but only if it will go to the original stderr. */ if (dup2 (saved_stderr_fd, STDERR_FILENO) == STDERR_FILENO) diff --git a/src/bin/coreutils/src/od.c b/src/bin/coreutils/src/od.c index 56585bd56f..085d6406cf 100644 --- a/src/bin/coreutils/src/od.c +++ b/src/bin/coreutils/src/od.c @@ -93,12 +93,12 @@ enum { FMT_BYTES_ALLOCATED = MAX ((sizeof "%*.99" - 1 - + MAX (sizeof "ld", - MAX (sizeof PRIdMAX, - MAX (sizeof PRIoMAX, - MAX (sizeof PRIuMAX, - sizeof PRIxMAX))))), - sizeof "%*.99Le") + + MAX (sizeof "ld", + MAX (sizeof PRIdMAX, + MAX (sizeof PRIoMAX, + MAX (sizeof PRIuMAX, + sizeof PRIxMAX))))), + sizeof "%*.99Le") }; /* Ensure that our choice for FMT_BYTES_ALLOCATED is reasonable. */ @@ -116,7 +116,7 @@ struct tspec leading space, and PAD is total pad to divide among FIELDS. PAD is at least as large as FIELDS. */ void (*print_function) (size_t fields, size_t blank, void const *data, - char const *fmt, int width, int pad); + char const *fmt, int width, int pad); char fmt_string[FMT_BYTES_ALLOCATED]; /* Of the style "%*d". */ bool hexl_mode_trailer; int field_width; /* Minimum width of a field, excluding leading space. */ @@ -302,7 +302,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -310,7 +310,7 @@ Usage: %s [OPTION]... [FILE]...\n\ or: %s [-abcdfilosx]... [FILE] [[+]OFFSET[.][b]]\n\ or: %s --traditional [OPTION]... [FILE] [[+]OFFSET[.][b] [+][LABEL][.][b]]\n\ "), - program_name, program_name, program_name); + program_name, program_name, program_name); fputs (_("\n\ Write an unambiguous representation, octal bytes by default,\n\ of FILE to standard output. With more than one FILE argument,\n\ @@ -446,8 +446,8 @@ dump_hexl_mode_trailer (size_t n_bytes, const char *block) static void print_named_ascii (size_t fields, size_t blank, void const *block, - const char *unused_fmt_string ATTRIBUTE_UNUSED, - int width, int pad) + const char *unused_fmt_string ATTRIBUTE_UNUSED, + int width, int pad) { unsigned char const *p = block; size_t i; @@ -460,15 +460,15 @@ print_named_ascii (size_t fields, size_t blank, void const *block, char buf[2]; if (masked_c == 127) - s = "del"; + s = "del"; else if (masked_c <= 040) - s = charname[masked_c]; + s = charname[masked_c]; else - { - buf[0] = masked_c; - buf[1] = 0; - s = buf; - } + { + buf[0] = masked_c; + buf[1] = 0; + s = buf; + } xprintf ("%*s", pad_remaining - next_pad + width, s); pad_remaining = next_pad; @@ -477,8 +477,8 @@ print_named_ascii (size_t fields, size_t blank, void const *block, static void print_ascii (size_t fields, size_t blank, void const *block, - const char *unused_fmt_string ATTRIBUTE_UNUSED, int width, - int pad) + const char *unused_fmt_string ATTRIBUTE_UNUSED, int width, + int pad) { unsigned char const *p = block; size_t i; @@ -491,43 +491,43 @@ print_ascii (size_t fields, size_t blank, void const *block, char buf[4]; switch (c) - { - case '\0': - s = "\\0"; - break; + { + case '\0': + s = "\\0"; + break; - case '\a': - s = "\\a"; - break; + case '\a': + s = "\\a"; + break; - case '\b': - s = "\\b"; - break; + case '\b': + s = "\\b"; + break; - case '\f': - s = "\\f"; - break; + case '\f': + s = "\\f"; + break; - case '\n': - s = "\\n"; - break; + case '\n': + s = "\\n"; + break; - case '\r': - s = "\\r"; - break; + case '\r': + s = "\\r"; + break; - case '\t': - s = "\\t"; - break; + case '\t': + s = "\\t"; + break; - case '\v': - s = "\\v"; - break; + case '\v': + s = "\\v"; + break; - default: - sprintf (buf, (isprint (c) ? "%c" : "%03o"), c); - s = buf; - } + default: + sprintf (buf, (isprint (c) ? "%c" : "%03o"), c); + s = buf; + } xprintf ("%*s", pad_remaining - next_pad + width, s); pad_remaining = next_pad; @@ -552,7 +552,7 @@ simple_strtoul (const char *s, const char **p, unsigned long int *val) { int c = *s++ - '0'; if (sum > (ULONG_MAX - c) / 10) - return false; + return false; sum = sum * 10 + c; } *p = s; @@ -581,14 +581,14 @@ simple_strtoul (const char *s, const char **p, unsigned long int *val) static bool decode_one_format (const char *s_orig, const char *s, const char **next, - struct tspec *tspec) + struct tspec *tspec) { enum size_spec size_spec; unsigned long int size; enum output_format fmt; const char *pre_fmt_string; void (*print_function) (size_t, size_t, void const *, char const *, - int, int); + int, int); const char *p; char c; int field_width; @@ -605,51 +605,51 @@ decode_one_format (const char *s_orig, const char *s, const char **next, c = *s; ++s; switch (*s) - { - case 'C': - ++s; - size = sizeof (char); - break; + { + case 'C': + ++s; + size = sizeof (char); + break; - case 'S': - ++s; - size = sizeof (short int); - break; + case 'S': + ++s; + size = sizeof (short int); + break; - case 'I': - ++s; - size = sizeof (int); - break; + case 'I': + ++s; + size = sizeof (int); + break; - case 'L': - ++s; - size = sizeof (long int); - break; + case 'L': + ++s; + size = sizeof (long int); + break; - default: - if (! simple_strtoul (s, &p, &size)) - { - /* The integer at P in S would overflow an unsigned long int. - A digit string that long is sufficiently odd looking - that the following diagnostic is sufficient. */ - error (0, 0, _("invalid type string %s"), quote (s_orig)); - return false; - } - if (p == s) - size = sizeof (int); - else - { - if (MAX_INTEGRAL_TYPE_SIZE < size - || integral_type_size[size] == NO_SIZE) - { - error (0, 0, _("invalid type string %s;\n\ + default: + if (! simple_strtoul (s, &p, &size)) + { + /* The integer at P in S would overflow an unsigned long int. + A digit string that long is sufficiently odd looking + that the following diagnostic is sufficient. */ + error (0, 0, _("invalid type string %s"), quote (s_orig)); + return false; + } + if (p == s) + size = sizeof (int); + else + { + if (MAX_INTEGRAL_TYPE_SIZE < size + || integral_type_size[size] == NO_SIZE) + { + error (0, 0, _("invalid type string %s;\n\ this system doesn't provide a %lu-byte integral type"), quote (s_orig), size); - return false; - } - s = p; - } - break; - } + return false; + } + s = p; + } + break; + } #define ISPEC_TO_FORMAT(Spec, Min_format, Long_format, Max_format) \ ((Spec) == LONG_LONG ? (Max_format) \ @@ -659,143 +659,143 @@ this system doesn't provide a %lu-byte integral type"), quote (s_orig), size); size_spec = integral_type_size[size]; switch (c) - { - case 'd': - fmt = SIGNED_DECIMAL; - field_width = bytes_to_signed_dec_digits[size]; - sprintf (tspec->fmt_string, "%%*%s", - ISPEC_TO_FORMAT (size_spec, "d", "ld", PRIdMAX)); - break; + { + case 'd': + fmt = SIGNED_DECIMAL; + field_width = bytes_to_signed_dec_digits[size]; + sprintf (tspec->fmt_string, "%%*%s", + ISPEC_TO_FORMAT (size_spec, "d", "ld", PRIdMAX)); + break; - case 'o': - fmt = OCTAL; - sprintf (tspec->fmt_string, "%%*.%d%s", - (field_width = bytes_to_oct_digits[size]), - ISPEC_TO_FORMAT (size_spec, "o", "lo", PRIoMAX)); - break; + case 'o': + fmt = OCTAL; + sprintf (tspec->fmt_string, "%%*.%d%s", + (field_width = bytes_to_oct_digits[size]), + ISPEC_TO_FORMAT (size_spec, "o", "lo", PRIoMAX)); + break; - case 'u': - fmt = UNSIGNED_DECIMAL; - field_width = bytes_to_unsigned_dec_digits[size]; - sprintf (tspec->fmt_string, "%%*%s", - ISPEC_TO_FORMAT (size_spec, "u", "lu", PRIuMAX)); - break; + case 'u': + fmt = UNSIGNED_DECIMAL; + field_width = bytes_to_unsigned_dec_digits[size]; + sprintf (tspec->fmt_string, "%%*%s", + ISPEC_TO_FORMAT (size_spec, "u", "lu", PRIuMAX)); + break; - case 'x': - fmt = HEXADECIMAL; - sprintf (tspec->fmt_string, "%%*.%d%s", - (field_width = bytes_to_hex_digits[size]), - ISPEC_TO_FORMAT (size_spec, "x", "lx", PRIxMAX)); - break; + case 'x': + fmt = HEXADECIMAL; + sprintf (tspec->fmt_string, "%%*.%d%s", + (field_width = bytes_to_hex_digits[size]), + ISPEC_TO_FORMAT (size_spec, "x", "lx", PRIxMAX)); + break; - default: - abort (); - } + default: + abort (); + } assert (strlen (tspec->fmt_string) < FMT_BYTES_ALLOCATED); switch (size_spec) - { - case CHAR: - print_function = (fmt == SIGNED_DECIMAL - ? print_s_char - : print_char); - break; + { + case CHAR: + print_function = (fmt == SIGNED_DECIMAL + ? print_s_char + : print_char); + break; - case SHORT: - print_function = (fmt == SIGNED_DECIMAL - ? print_s_short - : print_short); - break; + case SHORT: + print_function = (fmt == SIGNED_DECIMAL + ? print_s_short + : print_short); + break; - case INT: - print_function = print_int; - break; + case INT: + print_function = print_int; + break; - case LONG: - print_function = print_long; - break; + case LONG: + print_function = print_long; + break; - case LONG_LONG: - print_function = print_long_long; - break; + case LONG_LONG: + print_function = print_long_long; + break; - default: - abort (); - } + default: + abort (); + } break; case 'f': fmt = FLOATING_POINT; ++s; switch (*s) - { - case 'F': - ++s; - size = sizeof (float); - break; + { + case 'F': + ++s; + size = sizeof (float); + break; - case 'D': - ++s; - size = sizeof (double); - break; + case 'D': + ++s; + size = sizeof (double); + break; - case 'L': - ++s; - size = sizeof (long double); - break; + case 'L': + ++s; + size = sizeof (long double); + break; - default: - if (! simple_strtoul (s, &p, &size)) - { - /* The integer at P in S would overflow an unsigned long int. - A digit string that long is sufficiently odd looking - that the following diagnostic is sufficient. */ - error (0, 0, _("invalid type string %s"), quote (s_orig)); - return false; - } - if (p == s) - size = sizeof (double); - else - { - if (size > MAX_FP_TYPE_SIZE - || fp_type_size[size] == NO_SIZE) - { - error (0, 0, _("invalid type string %s;\n\ + default: + if (! simple_strtoul (s, &p, &size)) + { + /* The integer at P in S would overflow an unsigned long int. + A digit string that long is sufficiently odd looking + that the following diagnostic is sufficient. */ + error (0, 0, _("invalid type string %s"), quote (s_orig)); + return false; + } + if (p == s) + size = sizeof (double); + else + { + if (size > MAX_FP_TYPE_SIZE + || fp_type_size[size] == NO_SIZE) + { + error (0, 0, _("invalid type string %s;\n\ this system doesn't provide a %lu-byte floating point type"), - quote (s_orig), size); - return false; - } - s = p; - } - break; - } + quote (s_orig), size); + return false; + } + s = p; + } + break; + } size_spec = fp_type_size[size]; switch (size_spec) - { - case FLOAT_SINGLE: - print_function = print_float; - /* FIXME - should we use %g instead of %e? */ - pre_fmt_string = "%%*.%de"; - precision = FLT_DIG; - break; + { + case FLOAT_SINGLE: + print_function = print_float; + /* FIXME - should we use %g instead of %e? */ + pre_fmt_string = "%%*.%de"; + precision = FLT_DIG; + break; - case FLOAT_DOUBLE: - print_function = print_double; - pre_fmt_string = "%%*.%de"; - precision = DBL_DIG; - break; + case FLOAT_DOUBLE: + print_function = print_double; + pre_fmt_string = "%%*.%de"; + precision = DBL_DIG; + break; - case FLOAT_LONG_DOUBLE: - print_function = print_long_double; - pre_fmt_string = "%%*.%dLe"; - precision = LDBL_DIG; - break; + case FLOAT_LONG_DOUBLE: + print_function = print_long_double; + pre_fmt_string = "%%*.%dLe"; + precision = LDBL_DIG; + break; - default: - abort (); - } + default: + abort (); + } field_width = precision + 8; sprintf (tspec->fmt_string, pre_fmt_string, precision); @@ -820,7 +820,7 @@ this system doesn't provide a %lu-byte floating point type"), default: error (0, 0, _("invalid character `%c' in type string %s"), - *s, quote (s_orig)); + *s, quote (s_orig)); return false; } @@ -855,26 +855,26 @@ open_next_file (void) { input_filename = *file_list; if (input_filename == NULL) - return ok; + return ok; ++file_list; if (STREQ (input_filename, "-")) - { - input_filename = _("standard input"); - in_stream = stdin; - have_read_stdin = true; - if (O_BINARY && ! isatty (STDIN_FILENO)) - xfreopen (NULL, "rb", stdin); - } + { + input_filename = _("standard input"); + in_stream = stdin; + have_read_stdin = true; + if (O_BINARY && ! isatty (STDIN_FILENO)) + xfreopen (NULL, "rb", stdin); + } else - { - in_stream = fopen (input_filename, (O_BINARY ? "rb" : "r")); - if (in_stream == NULL) - { - error (0, errno, "%s", input_filename); - ok = false; - } - } + { + in_stream = fopen (input_filename, (O_BINARY ? "rb" : "r")); + if (in_stream == NULL) + { + error (0, errno, "%s", input_filename); + ok = false; + } + } } while (in_stream == NULL); @@ -899,17 +899,17 @@ check_and_close (int in_errno) if (in_stream != NULL) { if (ferror (in_stream)) - { - error (0, in_errno, _("%s: read error"), input_filename); - if (! STREQ (file_list[-1], "-")) - fclose (in_stream); - ok = false; - } + { + error (0, in_errno, _("%s: read error"), input_filename); + if (! STREQ (file_list[-1], "-")) + fclose (in_stream); + ok = false; + } else if (! STREQ (file_list[-1], "-") && fclose (in_stream) != 0) - { - error (0, errno, "%s", input_filename); - ok = false; - } + { + error (0, errno, "%s", input_filename); + ok = false; + } in_stream = NULL; } @@ -938,10 +938,10 @@ decode_format_string (const char *s) const char *next; if (n_specs_allocated <= n_specs) - spec = X2NREALLOC (spec, &n_specs_allocated); + spec = X2NREALLOC (spec, &n_specs_allocated); if (! decode_one_format (s_orig, s, &next, &spec[n_specs])) - return false; + return false; assert (s != next); s = next; @@ -972,72 +972,72 @@ skip (uintmax_t n_skip) struct stat file_stats; /* First try seeking. For large offsets, this extra work is - worthwhile. If the offset is below some threshold it may be - more efficient to move the pointer by reading. There are two - issues when trying to seek: - - the file must be seekable. - - before seeking to the specified position, make sure - that the new position is in the current file. - Try to do that by getting file's size using fstat. - But that will work only for regular files. */ + worthwhile. If the offset is below some threshold it may be + more efficient to move the pointer by reading. There are two + issues when trying to seek: + - the file must be seekable. + - before seeking to the specified position, make sure + that the new position is in the current file. + Try to do that by getting file's size using fstat. + But that will work only for regular files. */ if (fstat (fileno (in_stream), &file_stats) == 0) - { - /* The st_size field is valid only for regular files - (and for symbolic links, which cannot occur here). - If the number of bytes left to skip is larger than - the size of the current file, we can decrement n_skip - and go on to the next file. Skip this optimization also - when st_size is 0, because some kernels report that - nonempty files in /proc have st_size == 0. */ - if (S_ISREG (file_stats.st_mode) && 0 < file_stats.st_size) - { - if ((uintmax_t) file_stats.st_size < n_skip) - n_skip -= file_stats.st_size; - else - { - if (fseeko (in_stream, n_skip, SEEK_CUR) != 0) - { - in_errno = errno; - ok = false; - } - n_skip = 0; - } - } + { + /* The st_size field is valid only for regular files + (and for symbolic links, which cannot occur here). + If the number of bytes left to skip is larger than + the size of the current file, we can decrement n_skip + and go on to the next file. Skip this optimization also + when st_size is 0, because some kernels report that + nonempty files in /proc have st_size == 0. */ + if (S_ISREG (file_stats.st_mode) && 0 < file_stats.st_size) + { + if ((uintmax_t) file_stats.st_size < n_skip) + n_skip -= file_stats.st_size; + else + { + if (fseeko (in_stream, n_skip, SEEK_CUR) != 0) + { + in_errno = errno; + ok = false; + } + n_skip = 0; + } + } - /* If it's not a regular file with nonnegative size, - position the file pointer by reading. */ + /* If it's not a regular file with nonnegative size, + position the file pointer by reading. */ - else - { - char buf[BUFSIZ]; - size_t n_bytes_read, n_bytes_to_read = BUFSIZ; + else + { + char buf[BUFSIZ]; + size_t n_bytes_read, n_bytes_to_read = BUFSIZ; - while (0 < n_skip) - { - if (n_skip < n_bytes_to_read) - n_bytes_to_read = n_skip; - n_bytes_read = fread (buf, 1, n_bytes_to_read, in_stream); - n_skip -= n_bytes_read; - if (n_bytes_read != n_bytes_to_read) - { - in_errno = errno; - ok = false; - n_skip = 0; - break; - } - } - } + while (0 < n_skip) + { + if (n_skip < n_bytes_to_read) + n_bytes_to_read = n_skip; + n_bytes_read = fread (buf, 1, n_bytes_to_read, in_stream); + n_skip -= n_bytes_read; + if (n_bytes_read != n_bytes_to_read) + { + in_errno = errno; + ok = false; + n_skip = 0; + break; + } + } + } - if (n_skip == 0) - break; - } + if (n_skip == 0) + break; + } else /* cannot fstat() file */ - { - error (0, errno, "%s", input_filename); - ok = false; - } + { + error (0, errno, "%s", input_filename); + ok = false; + } ok &= check_and_close (in_errno); @@ -1072,19 +1072,19 @@ format_address_std (uintmax_t address, char c) { case 8: do - *--p = '0' + (address & 7); + *--p = '0' + (address & 7); while ((address >>= 3) != 0); break; case 10: do - *--p = '0' + (address % 10); + *--p = '0' + (address % 10); while ((address /= 10) != 0); break; case 16: do - *--p = "0123456789abcdef"[address & 15]; + *--p = "0123456789abcdef"[address & 15]; while ((address >>= 4) != 0); break; } @@ -1123,7 +1123,7 @@ format_address_label (uintmax_t address, char c) static void write_block (uintmax_t current_offset, size_t n_bytes, - const char *prev_block, const char *curr_block) + const char *prev_block, const char *curr_block) { static bool first = true; static bool prev_pair_equal = false; @@ -1135,15 +1135,15 @@ write_block (uintmax_t current_offset, size_t n_bytes, && EQUAL_BLOCKS (prev_block, curr_block)) { if (prev_pair_equal) - { - /* The two preceding blocks were equal, and the current - block is the same as the last one, so print nothing. */ - } + { + /* The two preceding blocks were equal, and the current + block is the same as the last one, so print nothing. */ + } else - { - printf ("*\n"); - prev_pair_equal = true; - } + { + printf ("*\n"); + prev_pair_equal = true; + } } else { @@ -1151,28 +1151,28 @@ write_block (uintmax_t current_offset, size_t n_bytes, prev_pair_equal = false; for (i = 0; i < n_specs; i++) - { - int datum_width = width_bytes[spec[i].size]; - int fields_per_block = bytes_per_block / datum_width; - int blank_fields = (bytes_per_block - n_bytes) / datum_width; - if (i == 0) - format_address (current_offset, '\0'); - else - printf ("%*s", address_pad_len, ""); - (*spec[i].print_function) (fields_per_block, blank_fields, - curr_block, spec[i].fmt_string, - spec[i].field_width, spec[i].pad_width); - if (spec[i].hexl_mode_trailer) - { - /* space-pad out to full line width, then dump the trailer */ - int field_width = spec[i].field_width; - int pad_width = (spec[i].pad_width * blank_fields - / fields_per_block); - printf ("%*s", blank_fields * field_width + pad_width, ""); - dump_hexl_mode_trailer (n_bytes, curr_block); - } - putchar ('\n'); - } + { + int datum_width = width_bytes[spec[i].size]; + int fields_per_block = bytes_per_block / datum_width; + int blank_fields = (bytes_per_block - n_bytes) / datum_width; + if (i == 0) + format_address (current_offset, '\0'); + else + printf ("%*s", address_pad_len, ""); + (*spec[i].print_function) (fields_per_block, blank_fields, + curr_block, spec[i].fmt_string, + spec[i].field_width, spec[i].pad_width); + if (spec[i].hexl_mode_trailer) + { + /* space-pad out to full line width, then dump the trailer */ + int field_width = spec[i].field_width; + int pad_width = (spec[i].pad_width * blank_fields + / fields_per_block); + printf ("%*s", blank_fields * field_width + pad_width, ""); + dump_hexl_mode_trailer (n_bytes, curr_block); + } + putchar ('\n'); + } } first = false; } @@ -1200,7 +1200,7 @@ read_char (int *c) *c = fgetc (in_stream); if (*c != EOF) - break; + break; ok &= check_and_close (errno); @@ -1247,7 +1247,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer) *n_bytes_in_buffer += n_read; if (n_read == n_needed) - break; + break; ok &= check_and_close (errno); @@ -1294,9 +1294,9 @@ parse_old_offset (const char *s, uintmax_t *offset) else { if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) - radix = 16; + radix = 16; else - radix = 8; + radix = 8; } return xstrtoumax (s, NULL, radix, offset, "Bb") == LONGINT_OK; @@ -1331,38 +1331,38 @@ dump (void) if (limit_bytes_to_format) { while (1) - { - size_t n_needed; - if (current_offset >= end_offset) - { - n_bytes_read = 0; - break; - } - n_needed = MIN (end_offset - current_offset, - (uintmax_t) bytes_per_block); - ok &= read_block (n_needed, block[idx], &n_bytes_read); - if (n_bytes_read < bytes_per_block) - break; - assert (n_bytes_read == bytes_per_block); - write_block (current_offset, n_bytes_read, - block[!idx], block[idx]); - current_offset += n_bytes_read; - idx = !idx; - } + { + size_t n_needed; + if (current_offset >= end_offset) + { + n_bytes_read = 0; + break; + } + n_needed = MIN (end_offset - current_offset, + (uintmax_t) bytes_per_block); + ok &= read_block (n_needed, block[idx], &n_bytes_read); + if (n_bytes_read < bytes_per_block) + break; + assert (n_bytes_read == bytes_per_block); + write_block (current_offset, n_bytes_read, + block[!idx], block[idx]); + current_offset += n_bytes_read; + idx = !idx; + } } else { while (1) - { - ok &= read_block (bytes_per_block, block[idx], &n_bytes_read); - if (n_bytes_read < bytes_per_block) - break; - assert (n_bytes_read == bytes_per_block); - write_block (current_offset, n_bytes_read, - block[!idx], block[idx]); - current_offset += n_bytes_read; - idx = !idx; - } + { + ok &= read_block (bytes_per_block, block[idx], &n_bytes_read); + if (n_bytes_read < bytes_per_block) + break; + assert (n_bytes_read == bytes_per_block); + write_block (current_offset, n_bytes_read, + block[!idx], block[idx]); + current_offset += n_bytes_read; + idx = !idx; + } } if (n_bytes_read > 0) @@ -1373,7 +1373,7 @@ dump (void) l_c_m = get_lcm (); /* Ensure zero-byte padding up to the smallest multiple of l_c_m that - is at least as large as n_bytes_read. */ + is at least as large as n_bytes_read. */ bytes_to_write = l_c_m * ((n_bytes_read + l_c_m - 1) / l_c_m); memset (block[idx] + n_bytes_read, 0, bytes_to_write - n_bytes_read); @@ -1414,87 +1414,87 @@ dump_strings (void) tryline: if (limit_bytes_to_format - && (end_offset < string_min || end_offset - string_min <= address)) - break; + && (end_offset < string_min || end_offset - string_min <= address)) + break; for (i = 0; i < string_min; i++) - { - ok &= read_char (&c); - address++; - if (c < 0) - { - free (buf); - return ok; - } - if (! isprint (c)) - /* Found a non-printing. Try again starting with next char. */ - goto tryline; - buf[i] = c; - } + { + ok &= read_char (&c); + address++; + if (c < 0) + { + free (buf); + return ok; + } + if (! isprint (c)) + /* Found a non-printing. Try again starting with next char. */ + goto tryline; + buf[i] = c; + } /* We found a run of `string_min' printable characters. - Now see if it is terminated with a null byte. */ + Now see if it is terminated with a null byte. */ while (!limit_bytes_to_format || address < end_offset) - { - if (i == bufsize) - { - buf = X2REALLOC (buf, &bufsize); - } - ok &= read_char (&c); - address++; - if (c < 0) - { - free (buf); - return ok; - } - if (c == '\0') - break; /* It is; print this string. */ - if (! isprint (c)) - goto tryline; /* It isn't; give up on this string. */ - buf[i++] = c; /* String continues; store it all. */ - } + { + if (i == bufsize) + { + buf = X2REALLOC (buf, &bufsize); + } + ok &= read_char (&c); + address++; + if (c < 0) + { + free (buf); + return ok; + } + if (c == '\0') + break; /* It is; print this string. */ + if (! isprint (c)) + goto tryline; /* It isn't; give up on this string. */ + buf[i++] = c; /* String continues; store it all. */ + } /* If we get here, the string is all printable and null-terminated, - so print it. It is all in `buf' and `i' is its length. */ + so print it. It is all in `buf' and `i' is its length. */ buf[i] = 0; format_address (address - i - 1, ' '); for (i = 0; (c = buf[i]); i++) - { - switch (c) - { - case '\a': - fputs ("\\a", stdout); - break; + { + switch (c) + { + case '\a': + fputs ("\\a", stdout); + break; - case '\b': - fputs ("\\b", stdout); - break; + case '\b': + fputs ("\\b", stdout); + break; - case '\f': - fputs ("\\f", stdout); - break; + case '\f': + fputs ("\\f", stdout); + break; - case '\n': - fputs ("\\n", stdout); - break; + case '\n': + fputs ("\\n", stdout); + break; - case '\r': - fputs ("\\r", stdout); - break; + case '\r': + fputs ("\\r", stdout); + break; - case '\t': - fputs ("\\t", stdout); - break; + case '\t': + fputs ("\\t", stdout); + break; - case '\v': - fputs ("\\v", stdout); - break; + case '\v': + fputs ("\\v", stdout); + break; - default: - putc (c, stdout); - } - } + default: + putc (c, stdout); + } + } putchar ('\n'); } @@ -1574,151 +1574,151 @@ main (int argc, char **argv) break; switch (c) - { - case 'A': - modern = true; - switch (optarg[0]) - { - case 'd': - format_address = format_address_std; - address_base = 10; - address_pad_len = 7; - break; - case 'o': - format_address = format_address_std; - address_base = 8; - address_pad_len = 7; - break; - case 'x': - format_address = format_address_std; - address_base = 16; - address_pad_len = 6; - break; - case 'n': - format_address = format_address_none; - address_pad_len = 0; - break; - default: - error (EXIT_FAILURE, 0, - _("invalid output address radix `%c'; \ + { + case 'A': + modern = true; + switch (optarg[0]) + { + case 'd': + format_address = format_address_std; + address_base = 10; + address_pad_len = 7; + break; + case 'o': + format_address = format_address_std; + address_base = 8; + address_pad_len = 7; + break; + case 'x': + format_address = format_address_std; + address_base = 16; + address_pad_len = 6; + break; + case 'n': + format_address = format_address_none; + address_pad_len = 0; + break; + default: + error (EXIT_FAILURE, 0, + _("invalid output address radix `%c'; \ it must be one character from [doxn]"), - optarg[0]); - break; - } - break; + optarg[0]); + break; + } + break; - case 'j': - modern = true; - s_err = xstrtoumax (optarg, NULL, 0, &n_bytes_to_skip, multipliers); - if (s_err != LONGINT_OK) - xstrtol_fatal (s_err, oi, c, long_options, optarg); - break; + case 'j': + modern = true; + s_err = xstrtoumax (optarg, NULL, 0, &n_bytes_to_skip, multipliers); + if (s_err != LONGINT_OK) + xstrtol_fatal (s_err, oi, c, long_options, optarg); + break; - case 'N': - modern = true; - limit_bytes_to_format = true; + case 'N': + modern = true; + limit_bytes_to_format = true; - s_err = xstrtoumax (optarg, NULL, 0, &max_bytes_to_format, - multipliers); - if (s_err != LONGINT_OK) - xstrtol_fatal (s_err, oi, c, long_options, optarg); - break; + s_err = xstrtoumax (optarg, NULL, 0, &max_bytes_to_format, + multipliers); + if (s_err != LONGINT_OK) + xstrtol_fatal (s_err, oi, c, long_options, optarg); + break; - case 'S': - modern = true; - if (optarg == NULL) - string_min = 3; - else - { - s_err = xstrtoumax (optarg, NULL, 0, &tmp, multipliers); - if (s_err != LONGINT_OK) - xstrtol_fatal (s_err, oi, c, long_options, optarg); + case 'S': + modern = true; + if (optarg == NULL) + string_min = 3; + else + { + s_err = xstrtoumax (optarg, NULL, 0, &tmp, multipliers); + if (s_err != LONGINT_OK) + xstrtol_fatal (s_err, oi, c, long_options, optarg); - /* The minimum string length may be no larger than SIZE_MAX, - since we may allocate a buffer of this size. */ - if (SIZE_MAX < tmp) - error (EXIT_FAILURE, 0, _("%s is too large"), optarg); + /* The minimum string length may be no larger than SIZE_MAX, + since we may allocate a buffer of this size. */ + if (SIZE_MAX < tmp) + error (EXIT_FAILURE, 0, _("%s is too large"), optarg); - string_min = tmp; - } - flag_dump_strings = true; - break; + string_min = tmp; + } + flag_dump_strings = true; + break; - case 't': - modern = true; - ok &= decode_format_string (optarg); - break; + case 't': + modern = true; + ok &= decode_format_string (optarg); + break; - case 'v': - modern = true; - abbreviate_duplicate_blocks = false; - break; + case 'v': + modern = true; + abbreviate_duplicate_blocks = false; + break; - case TRADITIONAL_OPTION: - traditional = true; - break; + case TRADITIONAL_OPTION: + traditional = true; + break; - /* The next several cases map the traditional format - specification options to the corresponding modern format - specs. GNU od accepts any combination of old- and - new-style options. Format specification options accumulate. - The obsolescent and undocumented formats are compatible - with FreeBSD 4.10 od. */ + /* The next several cases map the traditional format + specification options to the corresponding modern format + specs. GNU od accepts any combination of old- and + new-style options. Format specification options accumulate. + The obsolescent and undocumented formats are compatible + with FreeBSD 4.10 od. */ #define CASE_OLD_ARG(old_char,new_string) \ - case old_char: \ - ok &= decode_format_string (new_string); \ - break + case old_char: \ + ok &= decode_format_string (new_string); \ + break - CASE_OLD_ARG ('a', "a"); - CASE_OLD_ARG ('b', "o1"); - CASE_OLD_ARG ('c', "c"); - CASE_OLD_ARG ('D', "u4"); /* obsolescent and undocumented */ - CASE_OLD_ARG ('d', "u2"); - case 'F': /* obsolescent and undocumented alias */ - CASE_OLD_ARG ('e', "fD"); /* obsolescent and undocumented */ - CASE_OLD_ARG ('f', "fF"); - case 'X': /* obsolescent and undocumented alias */ - CASE_OLD_ARG ('H', "x4"); /* obsolescent and undocumented */ - CASE_OLD_ARG ('i', "dI"); - case 'I': case 'L': /* obsolescent and undocumented aliases */ - CASE_OLD_ARG ('l', "dL"); - CASE_OLD_ARG ('O', "o4"); /* obsolesent and undocumented */ - case 'B': /* obsolescent and undocumented alias */ - CASE_OLD_ARG ('o', "o2"); - CASE_OLD_ARG ('s', "d2"); - case 'h': /* obsolescent and undocumented alias */ - CASE_OLD_ARG ('x', "x2"); + CASE_OLD_ARG ('a', "a"); + CASE_OLD_ARG ('b', "o1"); + CASE_OLD_ARG ('c', "c"); + CASE_OLD_ARG ('D', "u4"); /* obsolescent and undocumented */ + CASE_OLD_ARG ('d', "u2"); + case 'F': /* obsolescent and undocumented alias */ + CASE_OLD_ARG ('e', "fD"); /* obsolescent and undocumented */ + CASE_OLD_ARG ('f', "fF"); + case 'X': /* obsolescent and undocumented alias */ + CASE_OLD_ARG ('H', "x4"); /* obsolescent and undocumented */ + CASE_OLD_ARG ('i', "dI"); + case 'I': case 'L': /* obsolescent and undocumented aliases */ + CASE_OLD_ARG ('l', "dL"); + CASE_OLD_ARG ('O', "o4"); /* obsolesent and undocumented */ + case 'B': /* obsolescent and undocumented alias */ + CASE_OLD_ARG ('o', "o2"); + CASE_OLD_ARG ('s', "d2"); + case 'h': /* obsolescent and undocumented alias */ + CASE_OLD_ARG ('x', "x2"); #undef CASE_OLD_ARG - case 'w': - modern = true; - width_specified = true; - if (optarg == NULL) - { - desired_width = 32; - } - else - { - uintmax_t w_tmp; - s_err = xstrtoumax (optarg, NULL, 10, &w_tmp, ""); - if (s_err != LONGINT_OK) - xstrtol_fatal (s_err, oi, c, long_options, optarg); - if (SIZE_MAX < w_tmp) - error (EXIT_FAILURE, 0, _("%s is too large"), optarg); - desired_width = w_tmp; - } - break; + case 'w': + modern = true; + width_specified = true; + if (optarg == NULL) + { + desired_width = 32; + } + else + { + uintmax_t w_tmp; + s_err = xstrtoumax (optarg, NULL, 10, &w_tmp, ""); + if (s_err != LONGINT_OK) + xstrtol_fatal (s_err, oi, c, long_options, optarg); + if (SIZE_MAX < w_tmp) + error (EXIT_FAILURE, 0, _("%s is too large"), optarg); + desired_width = w_tmp; + } + 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); - break; - } + default: + usage (EXIT_FAILURE); + break; + } } if (!ok) @@ -1726,20 +1726,20 @@ it must be one character from [doxn]"), if (flag_dump_strings && n_specs > 0) error (EXIT_FAILURE, 0, - _("no type may be specified when dumping strings")); + _("no type may be specified when dumping strings")); n_files = argc - optind; /* If the --traditional option is used, there may be from 0 to 3 remaining command line arguments; handle each case separately. - od [file] [[+]offset[.][b] [[+]label[.][b]]] + od [file] [[+]offset[.][b] [[+]label[.][b]]] The offset and label have the same syntax. If --traditional is not given, and if no modern options are given, and if the offset begins with + or (if there are two operands) a digit, accept only this form, as per POSIX: - od [file] [[+]offset[.][b]] + od [file] [[+]offset[.][b]] */ if (!modern | traditional) @@ -1748,81 +1748,81 @@ it must be one character from [doxn]"), uintmax_t o2; switch (n_files) - { - case 1: - if ((traditional || argv[optind][0] == '+') - && parse_old_offset (argv[optind], &o1)) - { - n_bytes_to_skip = o1; - --n_files; - ++argv; - } - break; + { + case 1: + if ((traditional || argv[optind][0] == '+') + && parse_old_offset (argv[optind], &o1)) + { + n_bytes_to_skip = o1; + --n_files; + ++argv; + } + break; - case 2: - if ((traditional || argv[optind + 1][0] == '+' - || ISDIGIT (argv[optind + 1][0])) - && parse_old_offset (argv[optind + 1], &o2)) - { - if (traditional && parse_old_offset (argv[optind], &o1)) - { - n_bytes_to_skip = o1; - flag_pseudo_start = true; - pseudo_start = o2; - argv += 2; - n_files -= 2; - } - else - { - n_bytes_to_skip = o2; - --n_files; - argv[optind + 1] = argv[optind]; - ++argv; - } - } - break; + case 2: + if ((traditional || argv[optind + 1][0] == '+' + || ISDIGIT (argv[optind + 1][0])) + && parse_old_offset (argv[optind + 1], &o2)) + { + if (traditional && parse_old_offset (argv[optind], &o1)) + { + n_bytes_to_skip = o1; + flag_pseudo_start = true; + pseudo_start = o2; + argv += 2; + n_files -= 2; + } + else + { + n_bytes_to_skip = o2; + --n_files; + argv[optind + 1] = argv[optind]; + ++argv; + } + } + break; - case 3: - if (traditional - && parse_old_offset (argv[optind + 1], &o1) - && parse_old_offset (argv[optind + 2], &o2)) - { - n_bytes_to_skip = o1; - flag_pseudo_start = true; - pseudo_start = o2; - argv[optind + 2] = argv[optind]; - argv += 2; - n_files -= 2; - } - break; - } + case 3: + if (traditional + && parse_old_offset (argv[optind + 1], &o1) + && parse_old_offset (argv[optind + 2], &o2)) + { + n_bytes_to_skip = o1; + flag_pseudo_start = true; + pseudo_start = o2; + argv[optind + 2] = argv[optind]; + argv += 2; + n_files -= 2; + } + break; + } if (traditional && 1 < n_files) - { - error (0, 0, _("extra operand %s"), quote (argv[optind + 1])); - error (0, 0, "%s\n", - _("compatibility mode supports at most one file")); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("extra operand %s"), quote (argv[optind + 1])); + error (0, 0, "%s\n", + _("compatibility mode supports at most one file")); + usage (EXIT_FAILURE); + } } if (flag_pseudo_start) { if (format_address == format_address_none) - { - address_base = 8; - address_pad_len = 7; - format_address = format_address_paren; - } + { + address_base = 8; + address_pad_len = 7; + format_address = format_address_paren; + } else - format_address = format_address_label; + format_address = format_address_label; } if (limit_bytes_to_format) { end_offset = n_bytes_to_skip + max_bytes_to_format; if (end_offset < n_bytes_to_skip) - error (EXIT_FAILURE, 0, _("skip-bytes + read-bytes is too large")); + error (EXIT_FAILURE, 0, _("skip-bytes + read-bytes is too large")); } if (n_specs == 0) @@ -1831,15 +1831,15 @@ it must be one character from [doxn]"), if (n_files > 0) { /* Set the global pointer FILE_LIST so that it - references the first file-argument on the command-line. */ + references the first file-argument on the command-line. */ file_list = (char const *const *) &argv[optind]; } else { /* No files were listed on the command line. - Set the global pointer FILE_LIST so that it - references the null-terminated list of one name: "-". */ + Set the global pointer FILE_LIST so that it + references the null-terminated list of one name: "-". */ file_list = default_file_list; } @@ -1862,20 +1862,20 @@ it must be one character from [doxn]"), if (width_specified) { if (desired_width != 0 && desired_width % l_c_m == 0) - bytes_per_block = desired_width; + bytes_per_block = desired_width; else - { - error (0, 0, _("warning: invalid width %lu; using %d instead"), - (unsigned long int) desired_width, l_c_m); - bytes_per_block = l_c_m; - } + { + error (0, 0, _("warning: invalid width %lu; using %d instead"), + (unsigned long int) desired_width, l_c_m); + bytes_per_block = l_c_m; + } } else { if (l_c_m < DEFAULT_BYTES_PER_BLOCK) - bytes_per_block = l_c_m * (DEFAULT_BYTES_PER_BLOCK / l_c_m); + bytes_per_block = l_c_m * (DEFAULT_BYTES_PER_BLOCK / l_c_m); else - bytes_per_block = l_c_m; + bytes_per_block = l_c_m; } /* Compute padding necessary to align output block. */ @@ -1884,7 +1884,7 @@ it must be one character from [doxn]"), int fields_per_block = bytes_per_block / width_bytes[spec[i].size]; int block_width = (spec[i].field_width + 1) * fields_per_block; if (width_per_block < block_width) - width_per_block = block_width; + width_per_block = block_width; } for (i = 0; i < n_specs; i++) { @@ -1901,8 +1901,8 @@ it must be one character from [doxn]"), assert (bytes_per_block % width_bytes[spec[i].size] == 0); assert (1 <= spec[i].pad_width / fields_per_block); printf ("%d: fmt=\"%s\" in_width=%d out_width=%d pad=%d\n", - i, spec[i].fmt_string, width_bytes[spec[i].size], - spec[i].field_width, spec[i].pad_width); + i, spec[i].fmt_string, width_bytes[spec[i].size], + spec[i].field_width, spec[i].pad_width); } #endif diff --git a/src/bin/coreutils/src/paste.c b/src/bin/coreutils/src/paste.c index 9494f42171..730a288732 100644 --- a/src/bin/coreutils/src/paste.c +++ b/src/bin/coreutils/src/paste.c @@ -26,12 +26,12 @@ Options: --serial -s Paste one file at a time rather than - one line from each file. + one line from each file. --delimiters=delim-list -d delim-list Consecutively use the characters in - DELIM-LIST instead of tab to separate - merged lines. When DELIM-LIST is exhausted, - start again at its beginning. + DELIM-LIST instead of tab to separate + merged lines. When DELIM-LIST is exhausted, + start again at its beginning. A FILE of `-' means standard input. If no FILEs are given, standard input is used. */ @@ -95,53 +95,53 @@ collapse_escapes (char const *strptr) while (*strptr) { if (*strptr != '\\') /* Is it an escape character? */ - *strout++ = *strptr++; /* No, just transfer it. */ + *strout++ = *strptr++; /* No, just transfer it. */ else - { - switch (*++strptr) - { - case '0': - *strout++ = EMPTY_DELIM; - break; + { + switch (*++strptr) + { + case '0': + *strout++ = EMPTY_DELIM; + break; - case 'b': - *strout++ = '\b'; - break; + case 'b': + *strout++ = '\b'; + break; - case 'f': - *strout++ = '\f'; - break; + case 'f': + *strout++ = '\f'; + break; - case 'n': - *strout++ = '\n'; - break; + case 'n': + *strout++ = '\n'; + break; - case 'r': - *strout++ = '\r'; - break; + case 'r': + *strout++ = '\r'; + break; - case 't': - *strout++ = '\t'; - break; + case 't': + *strout++ = '\t'; + break; - case 'v': - *strout++ = '\v'; - break; + case 'v': + *strout++ = '\v'; + break; - case '\\': - *strout++ = '\\'; - break; + case '\\': + *strout++ = '\\'; + break; - case '\0': - backslash_at_end = true; - goto done; + case '\0': + backslash_at_end = true; + goto done; - default: - *strout++ = *strptr; - break; - } - strptr++; - } + default: + *strout++ = *strptr; + break; + } + strptr++; + } } done:; @@ -200,18 +200,18 @@ paste_parallel (size_t nfiles, char **fnamptr) for (files_open = 0; files_open < nfiles; ++files_open) { if (STREQ (fnamptr[files_open], "-")) - { - have_read_stdin = true; - fileptr[files_open] = stdin; - } + { + have_read_stdin = true; + fileptr[files_open] = stdin; + } else - { - fileptr[files_open] = fopen (fnamptr[files_open], "r"); - if (fileptr[files_open] == NULL) - error (EXIT_FAILURE, errno, "%s", fnamptr[files_open]); - else if (fileno (fileptr[files_open]) == STDIN_FILENO) - opened_stdin = true; - } + { + fileptr[files_open] = fopen (fnamptr[files_open], "r"); + if (fileptr[files_open] == NULL) + error (EXIT_FAILURE, errno, "%s", fnamptr[files_open]); + else if (fileno (fileptr[files_open]) == STDIN_FILENO) + opened_stdin = true; + } } if (opened_stdin && have_read_stdin) @@ -230,107 +230,107 @@ paste_parallel (size_t nfiles, char **fnamptr) size_t i; for (i = 0; i < nfiles && files_open; i++) - { - int chr IF_LINT (= 0); /* Input character. */ - int err IF_LINT (= 0); /* Input errno value. */ - size_t line_length = 0; /* Number of chars in line. */ + { + int chr IF_LINT (= 0); /* Input character. */ + int err IF_LINT (= 0); /* Input errno value. */ + size_t line_length = 0; /* Number of chars in line. */ - if (fileptr[i]) - { - chr = getc (fileptr[i]); - err = errno; - if (chr != EOF && delims_saved) - { - if (fwrite (delbuf, 1, delims_saved, stdout) != delims_saved) - write_error (); - delims_saved = 0; - } + if (fileptr[i]) + { + chr = getc (fileptr[i]); + err = errno; + if (chr != EOF && delims_saved) + { + if (fwrite (delbuf, 1, delims_saved, stdout) != delims_saved) + write_error (); + delims_saved = 0; + } - while (chr != EOF) - { - line_length++; - if (chr == '\n') - break; - xputchar (chr); - chr = getc (fileptr[i]); - err = errno; - } - } + while (chr != EOF) + { + line_length++; + if (chr == '\n') + break; + xputchar (chr); + chr = getc (fileptr[i]); + err = errno; + } + } - if (line_length == 0) - { - /* EOF, read error, or closed file. - If an EOF or error, close the file. */ - if (fileptr[i]) - { - if (ferror (fileptr[i])) - { - error (0, err, "%s", fnamptr[i]); - ok = false; - } - if (fileptr[i] == stdin) - clearerr (fileptr[i]); /* Also clear EOF. */ - else if (fclose (fileptr[i]) == EOF) - { - error (0, errno, "%s", fnamptr[i]); - ok = false; - } + if (line_length == 0) + { + /* EOF, read error, or closed file. + If an EOF or error, close the file. */ + if (fileptr[i]) + { + if (ferror (fileptr[i])) + { + error (0, err, "%s", fnamptr[i]); + ok = false; + } + if (fileptr[i] == stdin) + clearerr (fileptr[i]); /* Also clear EOF. */ + else if (fclose (fileptr[i]) == EOF) + { + error (0, errno, "%s", fnamptr[i]); + ok = false; + } - fileptr[i] = NULL; - files_open--; - } + fileptr[i] = NULL; + files_open--; + } - if (i + 1 == nfiles) - { - /* End of this output line. - Is this the end of the whole thing? */ - if (somedone) - { - /* No. Some files were not closed for this line. */ - if (delims_saved) - { - if (fwrite (delbuf, 1, delims_saved, stdout) - != delims_saved) - write_error (); - delims_saved = 0; - } - xputchar ('\n'); - } - continue; /* Next read of files, or exit. */ - } - else - { - /* Closed file; add delimiter to `delbuf'. */ - if (*delimptr != EMPTY_DELIM) - delbuf[delims_saved++] = *delimptr; - if (++delimptr == delim_end) - delimptr = delims; - } - } - else - { - /* Some data read. */ - somedone = true; + if (i + 1 == nfiles) + { + /* End of this output line. + Is this the end of the whole thing? */ + if (somedone) + { + /* No. Some files were not closed for this line. */ + if (delims_saved) + { + if (fwrite (delbuf, 1, delims_saved, stdout) + != delims_saved) + write_error (); + delims_saved = 0; + } + xputchar ('\n'); + } + continue; /* Next read of files, or exit. */ + } + else + { + /* Closed file; add delimiter to `delbuf'. */ + if (*delimptr != EMPTY_DELIM) + delbuf[delims_saved++] = *delimptr; + if (++delimptr == delim_end) + delimptr = delims; + } + } + else + { + /* Some data read. */ + somedone = true; - /* Except for last file, replace last newline with delim. */ - if (i + 1 != nfiles) - { - if (chr != '\n' && chr != EOF) - xputchar (chr); - if (*delimptr != EMPTY_DELIM) - xputchar (*delimptr); - if (++delimptr == delim_end) - delimptr = delims; - } - else - { - /* If the last line of the last file lacks a newline, - print one anyhow. POSIX requires this. */ - char c = (chr == EOF ? '\n' : chr); - xputchar (c); - } - } - } + /* Except for last file, replace last newline with delim. */ + if (i + 1 != nfiles) + { + if (chr != '\n' && chr != EOF) + xputchar (chr); + if (*delimptr != EMPTY_DELIM) + xputchar (*delimptr); + if (++delimptr == delim_end) + delimptr = delims; + } + else + { + /* If the last line of the last file lacks a newline, + print one anyhow. POSIX requires this. */ + char c = (chr == EOF ? '\n' : chr); + xputchar (c); + } + } + } } free (fileptr); free (delbuf); @@ -354,70 +354,70 @@ paste_serial (size_t nfiles, char **fnamptr) int saved_errno; bool is_stdin = STREQ (*fnamptr, "-"); if (is_stdin) - { - have_read_stdin = true; - fileptr = stdin; - } + { + have_read_stdin = true; + fileptr = stdin; + } else - { - fileptr = fopen (*fnamptr, "r"); - if (fileptr == NULL) - { - error (0, errno, "%s", *fnamptr); - ok = false; - continue; - } - } + { + fileptr = fopen (*fnamptr, "r"); + if (fileptr == NULL) + { + error (0, errno, "%s", *fnamptr); + ok = false; + continue; + } + } delimptr = delims; /* Set up for delimiter string. */ charold = getc (fileptr); saved_errno = errno; if (charold != EOF) - { - /* `charold' is set up. Hit it! - Keep reading characters, stashing them in `charnew'; - output `charold', converting to the appropriate delimiter - character if needed. After the EOF, output `charold' - if it's a newline; otherwise, output it and then a newline. */ + { + /* `charold' is set up. Hit it! + Keep reading characters, stashing them in `charnew'; + output `charold', converting to the appropriate delimiter + character if needed. After the EOF, output `charold' + if it's a newline; otherwise, output it and then a newline. */ - while ((charnew = getc (fileptr)) != EOF) - { - /* Process the old character. */ - if (charold == '\n') - { - if (*delimptr != EMPTY_DELIM) - xputchar (*delimptr); + while ((charnew = getc (fileptr)) != EOF) + { + /* Process the old character. */ + if (charold == '\n') + { + if (*delimptr != EMPTY_DELIM) + xputchar (*delimptr); - if (++delimptr == delim_end) - delimptr = delims; - } - else - xputchar (charold); + if (++delimptr == delim_end) + delimptr = delims; + } + else + xputchar (charold); - charold = charnew; - } - saved_errno = errno; + charold = charnew; + } + saved_errno = errno; - /* Hit EOF. Process that last character. */ - xputchar (charold); - } + /* Hit EOF. Process that last character. */ + xputchar (charold); + } if (charold != '\n') - xputchar ('\n'); + xputchar ('\n'); if (ferror (fileptr)) - { - error (0, saved_errno, "%s", *fnamptr); - ok = false; - } + { + error (0, saved_errno, "%s", *fnamptr); + ok = false; + } if (is_stdin) - clearerr (fileptr); /* Also clear EOF. */ + clearerr (fileptr); /* Also clear EOF. */ else if (fclose (fileptr) == EOF) - { - error (0, errno, "%s", *fnamptr); - ok = false; - } + { + error (0, errno, "%s", *fnamptr); + ok = false; + } } return ok; } @@ -427,13 +427,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Write lines consisting of the sequentially corresponding lines from\n\ each FILE, separated by TABs, to standard output.\n\ @@ -476,23 +476,23 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "d:s", longopts, NULL)) != -1) { switch (optc) - { - case 'd': - /* Delimiter character(s). */ - delim_arg = (optarg[0] == '\0' ? "\\0" : optarg); - break; + { + case 'd': + /* Delimiter character(s). */ + delim_arg = (optarg[0] == '\0' ? "\\0" : optarg); + break; - case 's': - serial_merge = true; - break; + case 's': + serial_merge = 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); - } + default: + usage (EXIT_FAILURE); + } } if (optind == argc) @@ -501,11 +501,11 @@ main (int argc, char **argv) if (collapse_escapes (delim_arg)) { /* Don't use the default quoting style, because that would double the - number of displayed backslashes, making the diagnostic look bogus. */ + number of displayed backslashes, making the diagnostic look bogus. */ set_quoting_style (NULL, escape_quoting_style); error (EXIT_FAILURE, 0, - _("delimiter list ends with an unescaped backslash: %s"), - quotearg_colon (delim_arg)); + _("delimiter list ends with an unescaped backslash: %s"), + quotearg_colon (delim_arg)); } if (!serial_merge) diff --git a/src/bin/coreutils/src/pathchk.c b/src/bin/coreutils/src/pathchk.c index 526134507b..04b70a3898 100644 --- a/src/bin/coreutils/src/pathchk.c +++ b/src/bin/coreutils/src/pathchk.c @@ -91,7 +91,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... NAME...\n"), program_name); @@ -128,27 +128,27 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "+pP", longopts, NULL)) != -1) { switch (optc) - { - case PORTABILITY_OPTION: - check_basic_portability = true; - check_extra_portability = true; - break; + { + case PORTABILITY_OPTION: + check_basic_portability = true; + check_extra_portability = true; + break; - case 'p': - check_basic_portability = true; - break; + case 'p': + check_basic_portability = true; + break; - case 'P': - check_extra_portability = true; - break; + case 'P': + check_extra_portability = 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); - } + default: + usage (EXIT_FAILURE); + } } if (optind == argc) @@ -159,7 +159,7 @@ main (int argc, char **argv) for (; optind < argc; ++optind) ok &= validate_file_name (argv[optind], - check_basic_portability, check_extra_portability); + check_basic_portability, check_extra_portability); exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); } @@ -175,9 +175,9 @@ no_leading_hyphen (char const *file) for (p = file; (p = strchr (p, '-')); p++) if (p == file || p[-1] == '/') { - error (0, 0, _("leading `-' in a component of file name %s"), - quote (file)); - return false; + error (0, 0, _("leading `-' in a component of file name %s"), + quote (file)); + return false; } return true; @@ -190,10 +190,10 @@ static bool portable_chars_only (char const *file, size_t filelen) { size_t validlen = strspn (file, - ("/" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789._-")); + ("/" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789._-")); char const *invalid = file + validlen; if (*invalid) @@ -201,10 +201,10 @@ portable_chars_only (char const *file, size_t filelen) DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate); size_t charlen = mbrlen (invalid, filelen - validlen, &mbstate); error (0, 0, - _("nonportable character %s in file name %s"), - quotearg_n_style_mem (1, locale_quoting_style, invalid, - (charlen <= MB_LEN_MAX ? charlen : 1)), - quote_n (0, file)); + _("nonportable character %s in file name %s"), + quotearg_n_style_mem (1, locale_quoting_style, invalid, + (charlen <= MB_LEN_MAX ? charlen : 1)), + quote_n (0, file)); return false; } @@ -254,7 +254,7 @@ component_len (char const *f) static bool validate_file_name (char *file, bool check_basic_portability, - bool check_extra_portability) + bool check_extra_portability) { size_t filelen = strlen (file); @@ -274,9 +274,9 @@ validate_file_name (char *file, bool check_basic_portability, && filelen == 0) { /* Fail, since empty names are not portable. As of - 2005-01-06 POSIX does not address whether "pathchk -p ''" - should (or is allowed to) fail, so this is not a - conformance violation. */ + 2005-01-06 POSIX does not address whether "pathchk -p ''" + should (or is allowed to) fail, so this is not a + conformance violation. */ error (0, 0, _("empty file name")); return false; } @@ -284,23 +284,23 @@ validate_file_name (char *file, bool check_basic_portability, if (check_basic_portability) { if (! portable_chars_only (file, filelen)) - return false; + return false; } else { /* Check whether a file name component is in a directory that - is not searchable, or has some other serious problem. - POSIX does not allow "" as a file name, but some non-POSIX - hosts do (as an alias for "."), so allow "" if lstat does. */ + is not searchable, or has some other serious problem. + POSIX does not allow "" as a file name, but some non-POSIX + hosts do (as an alias for "."), so allow "" if lstat does. */ struct stat st; if (lstat (file, &st) == 0) - file_exists = true; + file_exists = true; else if (errno != ENOENT || filelen == 0) - { - error (0, errno, "%s", file); - return false; - } + { + error (0, errno, "%s", file); + return false; + } } if (check_basic_portability @@ -309,31 +309,31 @@ validate_file_name (char *file, bool check_basic_portability, size_t maxsize; if (check_basic_portability) - maxsize = _POSIX_PATH_MAX; + maxsize = _POSIX_PATH_MAX; else - { - long int size; - char const *dir = (*file == '/' ? "/" : "."); - errno = 0; - size = pathconf (dir, _PC_PATH_MAX); - if (size < 0 && errno != 0) - { - error (0, errno, - _("%s: unable to determine maximum file name length"), - dir); - return false; - } - maxsize = MIN (size, SSIZE_MAX); - } + { + long int size; + char const *dir = (*file == '/' ? "/" : "."); + errno = 0; + size = pathconf (dir, _PC_PATH_MAX); + if (size < 0 && errno != 0) + { + error (0, errno, + _("%s: unable to determine maximum file name length"), + dir); + return false; + } + maxsize = MIN (size, SSIZE_MAX); + } if (maxsize <= filelen) - { - unsigned long int len = filelen; - unsigned long int maxlen = maxsize - 1; - error (0, 0, _("limit %lu exceeded by length %lu of file name %s"), - maxlen, len, quote (file)); - return false; - } + { + unsigned long int len = filelen; + unsigned long int maxlen = maxsize - 1; + error (0, 0, _("limit %lu exceeded by length %lu of file name %s"), + maxlen, len, quote (file)); + return false; + } } /* Check whether pathconf (..., _PC_NAME_MAX) can be avoided, i.e., @@ -345,17 +345,17 @@ validate_file_name (char *file, bool check_basic_portability, if (! check_component_lengths && ! file_exists) { for (start = file; *(start = component_start (start)); ) - { - size_t length = component_len (start); + { + size_t length = component_len (start); - if (NAME_MAX_MINIMUM < length) - { - check_component_lengths = true; - break; - } + if (NAME_MAX_MINIMUM < length) + { + check_component_lengths = true; + break; + } - start += length; - } + start += length; + } } if (check_component_lengths) @@ -370,61 +370,61 @@ validate_file_name (char *file, bool check_basic_portability, size_t known_name_max = (check_basic_portability ? _POSIX_NAME_MAX : 0); for (start = file; *(start = component_start (start)); ) - { - size_t length; + { + size_t length; - if (known_name_max) - name_max = known_name_max; - else - { - long int len; - char const *dir = (start == file ? "." : file); - char c = *start; - errno = 0; - *start = '\0'; - len = pathconf (dir, _PC_NAME_MAX); - *start = c; - if (0 <= len) - name_max = MIN (len, SSIZE_MAX); - else - switch (errno) - { - case 0: - /* There is no limit. */ - name_max = SIZE_MAX; - break; + if (known_name_max) + name_max = known_name_max; + else + { + long int len; + char const *dir = (start == file ? "." : file); + char c = *start; + errno = 0; + *start = '\0'; + len = pathconf (dir, _PC_NAME_MAX); + *start = c; + if (0 <= len) + name_max = MIN (len, SSIZE_MAX); + else + switch (errno) + { + case 0: + /* There is no limit. */ + name_max = SIZE_MAX; + break; - case ENOENT: - /* DIR does not exist; use its parent's maximum. */ - known_name_max = name_max; - break; + case ENOENT: + /* DIR does not exist; use its parent's maximum. */ + known_name_max = name_max; + break; - default: - *start = '\0'; - error (0, errno, "%s", dir); - *start = c; - return false; - } - } + default: + *start = '\0'; + error (0, errno, "%s", dir); + *start = c; + return false; + } + } - length = component_len (start); + length = component_len (start); - if (name_max < length) - { - unsigned long int len = length; - unsigned long int maxlen = name_max; - char c = start[len]; - start[len] = '\0'; - error (0, 0, - _("limit %lu exceeded by length %lu " - "of file name component %s"), - maxlen, len, quote (start)); - start[len] = c; - return false; - } + if (name_max < length) + { + unsigned long int len = length; + unsigned long int maxlen = name_max; + char c = start[len]; + start[len] = '\0'; + error (0, 0, + _("limit %lu exceeded by length %lu " + "of file name component %s"), + maxlen, len, quote (start)); + start[len] = c; + return false; + } - start += length; - } + start += length; + } } return true; diff --git a/src/bin/coreutils/src/pinky.c b/src/bin/coreutils/src/pinky.c index 8ddd218fae..f75002e1f0 100644 --- a/src/bin/coreutils/src/pinky.c +++ b/src/bin/coreutils/src/pinky.c @@ -92,7 +92,7 @@ count_ampersands (const char *str) do { if (*str == '&') - count++; + count++; } while (*str++); return count; } @@ -117,7 +117,7 @@ create_fullname (const char *gecos_name, const char *user_name) size_t product = ampersands * ulen; rsize += product - ampersands; if (xalloc_oversized (ulen, ampersands) || rsize < product) - xalloc_die (); + xalloc_die (); } r = result = xmalloc (rsize); @@ -125,17 +125,17 @@ create_fullname (const char *gecos_name, const char *user_name) while (*gecos_name) { if (*gecos_name == '&') - { - const char *uname = user_name; - if (islower (to_uchar (*uname))) - *r++ = toupper (to_uchar (*uname++)); - while (*uname) - *r++ = *uname++; - } + { + const char *uname = user_name; + if (islower (to_uchar (*uname))) + *r++ = toupper (to_uchar (*uname++)); + while (*uname) + *r++ = *uname++; + } else - { - *r++ = *gecos_name; - } + { + *r++ = *gecos_name; + } gecos_name++; } @@ -249,32 +249,32 @@ print_entry (const STRUCT_UTMP *utmp_ent) name[UT_USER_SIZE] = '\0'; pw = getpwnam (name); if (pw == NULL) - /* TRANSLATORS: Real name is unknown; at most 19 characters. */ - printf (" %19s", _(" ???")); + /* TRANSLATORS: Real name is unknown; at most 19 characters. */ + printf (" %19s", _(" ???")); else - { - char *const comma = strchr (pw->pw_gecos, ','); - char *result; + { + char *const comma = strchr (pw->pw_gecos, ','); + char *result; - if (comma) - *comma = '\0'; + if (comma) + *comma = '\0'; - result = create_fullname (pw->pw_gecos, pw->pw_name); - printf (" %-19.19s", result); - free (result); - } + result = create_fullname (pw->pw_gecos, pw->pw_name); + printf (" %-19.19s", result); + free (result); + } } printf (" %c%-8.*s", - mesg, (int) sizeof (utmp_ent->ut_line), utmp_ent->ut_line); + mesg, (int) sizeof (utmp_ent->ut_line), utmp_ent->ut_line); if (include_idle) { if (last_change) - printf (" %-6s", idle_string (last_change)); + printf (" %-6s", idle_string (last_change)); else - /* TRANSLATORS: Idle time is unknown; at most 5 characters. */ - printf (" %-6s", _("?????")); + /* TRANSLATORS: Idle time is unknown; at most 5 characters. */ + printf (" %-6s", _("?????")); } printf (" %s", time_string (utmp_ent)); @@ -293,21 +293,21 @@ print_entry (const STRUCT_UTMP *utmp_ent) /* Look for an X display. */ display = strchr (ut_host, ':'); if (display) - *display++ = '\0'; + *display++ = '\0'; if (*ut_host) - /* See if we can canonicalize it. */ - host = canon_host (ut_host); + /* See if we can canonicalize it. */ + host = canon_host (ut_host); if ( ! host) - host = ut_host; + host = ut_host; if (display) - printf (" %s:%s", host, display); + printf (" %s:%s", host, display); else - printf (" %s", host); + printf (" %s", host); if (host != ut_host) - free (host); + free (host); } #endif @@ -339,7 +339,7 @@ print_long_entry (const char name[]) char *result; if (comma) - *comma = '\0'; + *comma = '\0'; result = create_fullname (pw->pw_gecos, pw->pw_name); printf (" %s", result); @@ -368,15 +368,15 @@ print_long_entry (const char name[]) stream = fopen (project, "r"); if (stream) - { - size_t bytes; + { + size_t bytes; - printf (_("Project: ")); + printf (_("Project: ")); - while ((bytes = fread (buf, 1, sizeof (buf), stream)) > 0) - fwrite (buf, 1, bytes, stdout); - fclose (stream); - } + while ((bytes = fread (buf, 1, sizeof (buf), stream)) > 0) + fwrite (buf, 1, bytes, stdout); + fclose (stream); + } free (project); } @@ -392,15 +392,15 @@ print_long_entry (const char name[]) stream = fopen (plan, "r"); if (stream) - { - size_t bytes; + { + size_t bytes; - printf (_("Plan:\n")); + printf (_("Plan:\n")); - while ((bytes = fread (buf, 1, sizeof (buf), stream)) > 0) - fwrite (buf, 1, bytes, stdout); - fclose (stream); - } + while ((bytes = fread (buf, 1, sizeof (buf), stream)) > 0) + fwrite (buf, 1, bytes, stdout); + fclose (stream); + } free (plan); } @@ -432,7 +432,7 @@ print_heading (void) static void scan_entries (size_t n, const STRUCT_UTMP *utmp_buf, - const int argc_names, char *const argv_names[]) + const int argc_names, char *const argv_names[]) { if (hard_locale (LC_TIME)) { @@ -451,22 +451,22 @@ scan_entries (size_t n, const STRUCT_UTMP *utmp_buf, while (n--) { if (IS_USER_PROCESS (utmp_buf)) - { - if (argc_names) - { - int i; + { + if (argc_names) + { + int i; - for (i = 0; i < argc_names; i++) - if (strncmp (UT_USER (utmp_buf), argv_names[i], UT_USER_SIZE) - == 0) - { - print_entry (utmp_buf); - break; - } - } - else - print_entry (utmp_buf); - } + for (i = 0; i < argc_names; i++) + if (strncmp (UT_USER (utmp_buf), argv_names[i], UT_USER_SIZE) + == 0) + { + print_entry (utmp_buf); + break; + } + } + else + print_entry (utmp_buf); + } utmp_buf++; } } @@ -475,7 +475,7 @@ scan_entries (size_t n, const STRUCT_UTMP *utmp_buf, static void short_pinky (const char *filename, - const int argc_names, char *const argv_names[]) + const int argc_names, char *const argv_names[]) { size_t n_users; STRUCT_UTMP *utmp_buf; @@ -500,7 +500,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... [USER]...\n"), program_name); @@ -548,57 +548,57 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, NULL)) != -1) { switch (optc) - { - case 's': - do_short_format = true; - break; + { + case 's': + do_short_format = true; + break; - case 'l': - do_short_format = false; - break; + case 'l': + do_short_format = false; + break; - case 'f': - include_heading = false; - break; + case 'f': + include_heading = false; + break; - case 'w': - include_fullname = false; - break; + case 'w': + include_fullname = false; + break; - case 'i': - include_fullname = false; + case 'i': + include_fullname = false; #ifdef HAVE_UT_HOST - include_where = false; + include_where = false; #endif - break; + break; - case 'q': - include_fullname = false; + case 'q': + include_fullname = false; #ifdef HAVE_UT_HOST - include_where = false; + include_where = false; #endif - include_idle = false; - break; + include_idle = false; + break; - case 'h': - include_project = false; - break; + case 'h': + include_project = false; + break; - case 'p': - include_plan = false; - break; + case 'p': + include_plan = false; + break; - case 'b': - include_home_and_shell = false; - break; + case 'b': + include_home_and_shell = false; + 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); - } + default: + usage (EXIT_FAILURE); + } } n_users = argc - optind; diff --git a/src/bin/coreutils/src/pr.c b/src/bin/coreutils/src/pr.c index f0910eb305..f584fdd30b 100644 --- a/src/bin/coreutils/src/pr.c +++ b/src/bin/coreutils/src/pr.c @@ -112,198 +112,198 @@ form feeds produce empty pages. +FIRST_PAGE[:LAST_PAGE], --pages=FIRST_PAGE[:LAST_PAGE] - begin [stop] printing with page FIRST_[LAST_]PAGE + begin [stop] printing with page FIRST_[LAST_]PAGE -COLUMN, --columns=COLUMN - Produce output that is COLUMN columns wide and - print columns down, unless -a is used. Balance number of - lines in the columns on each page. + Produce output that is COLUMN columns wide and + print columns down, unless -a is used. Balance number of + lines in the columns on each page. -a, --across Print columns across rather than down, used - together with -COLUMN. The input - one - two - three - four - will be printed with `-a -3' as - one two three - four + together with -COLUMN. The input + one + two + three + four + will be printed with `-a -3' as + one two three + four -b Balance columns on the last page. - -b is no longer an independent option. It's always used - together with -COLUMN (unless -a is used) to get a - consistent formulation with "FF set by hand" in input - files. Each formfeed found terminates the number of lines - to be read with the actual page. The situation for - printing columns down is equivalent to that on the last - page. So we need a balancing. + -b is no longer an independent option. It's always used + together with -COLUMN (unless -a is used) to get a + consistent formulation with "FF set by hand" in input + files. Each formfeed found terminates the number of lines + to be read with the actual page. The situation for + printing columns down is equivalent to that on the last + page. So we need a balancing. - Keeping -b as an underground option guarantees some - downward compatibility. Utilities using pr with -b - (a most frequently used form) still work as usual. + Keeping -b as an underground option guarantees some + downward compatibility. Utilities using pr with -b + (a most frequently used form) still work as usual. -c, --show-control-chars - Print unprintable characters as control prefixes. - Control-g is printed as ^G (use hat notation) and - octal backslash notation. + Print unprintable characters as control prefixes. + Control-g is printed as ^G (use hat notation) and + octal backslash notation. -d, --double-space Double space the output. -D FORMAT, --date-format=FORMAT Use FORMAT for the header date. -e[CHAR[WIDTH]], --expand-tabs[=CHAR[WIDTH]] - Expand tabs to spaces on input. Optional argument CHAR - is the input TAB character. (Default is TAB). Optional - argument WIDTH is the input TAB character's width. - (Default is 8.) + Expand tabs to spaces on input. Optional argument CHAR + is the input TAB character. (Default is TAB). Optional + argument WIDTH is the input TAB character's width. + (Default is 8.) -F, -f, --form-feed Use formfeeds instead of newlines to separate - pages. A three line HEADER is used, no TRAILER with -F, - without -F both HEADER and TRAILER are made of five lines. + pages. A three line HEADER is used, no TRAILER with -F, + without -F both HEADER and TRAILER are made of five lines. -h HEADER, --header=HEADER - Replace the filename in the header with the string HEADER. - A centered header is used. + Replace the filename in the header with the string HEADER. + A centered header is used. -i[CHAR[WIDTH]], --output-tabs[=CHAR[WIDTH]] - Replace spaces with tabs on output. Optional argument - CHAR is the output TAB character. (Default is TAB). - Optional argument WIDTH is the output TAB character's - width. (Default is 8) + Replace spaces with tabs on output. Optional argument + CHAR is the output TAB character. (Default is TAB). + Optional argument WIDTH is the output TAB character's + width. (Default is 8) -J, --join-lines Merge lines of full length, turns off -W/-w - line truncation, no column alignment, --sep-string[=STRING] - sets separators, works with all column options - (-COLUMN | -a -COLUMN | -m). - -J has been introduced (together with -W and --sep-string) to - disentangle the old (POSIX compliant) options -w, -s - along with the 3 column options. + line truncation, no column alignment, --sep-string[=STRING] + sets separators, works with all column options + (-COLUMN | -a -COLUMN | -m). + -J has been introduced (together with -W and --sep-string) to + disentangle the old (POSIX compliant) options -w, -s + along with the 3 column options. -l PAGE_LENGTH, --length=PAGE_LENGTH - Set the page length to PAGE_LENGTH lines. Default is 66, - including 5 lines of HEADER and 5 lines of TRAILER - without -F, but only 3 lines of HEADER and no TRAILER - with -F (i.e the number of text lines defaults to 56 or - 63 respectively). + Set the page length to PAGE_LENGTH lines. Default is 66, + including 5 lines of HEADER and 5 lines of TRAILER + without -F, but only 3 lines of HEADER and no TRAILER + with -F (i.e the number of text lines defaults to 56 or + 63 respectively). -m, --merge Print files in parallel; pad_across_to align - columns; truncate lines and print separator strings; - Do it also with empty columns to get a continuous line - numbering and column marking by separators throughout - the whole merged file. + columns; truncate lines and print separator strings; + Do it also with empty columns to get a continuous line + numbering and column marking by separators throughout + the whole merged file. - Empty pages in some input files produce empty columns - [marked by separators] in the merged pages. Completely - empty merged pages show no column separators at all. + Empty pages in some input files produce empty columns + [marked by separators] in the merged pages. Completely + empty merged pages show no column separators at all. - The layout of a merged page is ruled by the largest form - feed distance of the single pages at that page. Shorter - columns will be filled up with empty lines. + The layout of a merged page is ruled by the largest form + feed distance of the single pages at that page. Shorter + columns will be filled up with empty lines. - Together with -J option join lines of full length and - set separators when -S option is used. + Together with -J option join lines of full length and + set separators when -S option is used. -n[SEP[DIGITS]], --number-lines[=SEP[DIGITS]] - Provide DIGITS digit line numbering (default for DIGITS - is 5). With multicolumn output the number occupies the - first DIGITS column positions of each text column or only - each line of -m output. - With single column output the number precedes each line - just as -m output. - Optional argument SEP is the character appended to the - line number to separate it from the text followed. - The default separator is a TAB. In a strict sense a TAB - is always printed with single column output only. The - TAB-width varies with the TAB-position, e.g. with the - left margin specified by -o option. - With multicolumn output priority is given to `equal width - of output columns' (a POSIX specification). The TAB-width - is fixed to the value of the 1st column and does not - change with different values of left margin. That means a - fixed number of spaces is always printed in the place of - a TAB. The tabification depends upon the output - position. + Provide DIGITS digit line numbering (default for DIGITS + is 5). With multicolumn output the number occupies the + first DIGITS column positions of each text column or only + each line of -m output. + With single column output the number precedes each line + just as -m output. + Optional argument SEP is the character appended to the + line number to separate it from the text followed. + The default separator is a TAB. In a strict sense a TAB + is always printed with single column output only. The + TAB-width varies with the TAB-position, e.g. with the + left margin specified by -o option. + With multicolumn output priority is given to `equal width + of output columns' (a POSIX specification). The TAB-width + is fixed to the value of the 1st column and does not + change with different values of left margin. That means a + fixed number of spaces is always printed in the place of + a TAB. The tabification depends upon the output + position. - Default counting of the line numbers starts with 1st - line of the input file (not the 1st line printed, - compare the --page option and -N option). + Default counting of the line numbers starts with 1st + line of the input file (not the 1st line printed, + compare the --page option and -N option). -N NUMBER, --first-line-number=NUMBER - Start line counting with the number NUMBER at the 1st - line of first page printed (mostly not the 1st line of - the input file). + Start line counting with the number NUMBER at the 1st + line of first page printed (mostly not the 1st line of + the input file). -o MARGIN, --indent=MARGIN - Offset each line with a margin MARGIN spaces wide. - Total page width is the size of the margin plus the - PAGE_WIDTH set with -W/-w option. + Offset each line with a margin MARGIN spaces wide. + Total page width is the size of the margin plus the + PAGE_WIDTH set with -W/-w option. -r, --no-file-warnings - Omit warning when a file cannot be opened. + Omit warning when a file cannot be opened. -s[CHAR], --separator[=CHAR] - Separate columns by a single character CHAR, default for - CHAR is the TAB character without -w and 'no char' with -w. - Without `-s' default separator `space' is set. - -s[CHAR] turns off line truncation of all 3 column options - (-COLUMN|-a -COLUMN|-m) except -w is set. That is a POSIX - compliant formulation. The source code translates -s into - the new options -S and -J, also -W if required. + Separate columns by a single character CHAR, default for + CHAR is the TAB character without -w and 'no char' with -w. + Without `-s' default separator `space' is set. + -s[CHAR] turns off line truncation of all 3 column options + (-COLUMN|-a -COLUMN|-m) except -w is set. That is a POSIX + compliant formulation. The source code translates -s into + the new options -S and -J, also -W if required. -S STRING, --sep-string[=STRING] - Separate columns by any string STRING. The -S option - doesn't react upon the -W/-w option (unlike -s option - does). It defines a separator nothing else. - Without -S: Default separator TAB is used with -J and - `space' otherwise (same as -S" "). - With -S "": No separator is used. - Quotes should be used with blanks and some shell active - characters. - -S is problematic because in its obsolete form you - cannot use -S "STRING", but in its standard form you - must use -S "STRING" if STRING is empty. Use - --sep-string to avoid the ambiguity. + Separate columns by any string STRING. The -S option + doesn't react upon the -W/-w option (unlike -s option + does). It defines a separator nothing else. + Without -S: Default separator TAB is used with -J and + `space' otherwise (same as -S" "). + With -S "": No separator is used. + Quotes should be used with blanks and some shell active + characters. + -S is problematic because in its obsolete form you + cannot use -S "STRING", but in its standard form you + must use -S "STRING" if STRING is empty. Use + --sep-string to avoid the ambiguity. -t, --omit-header Do not print headers or footers but retain form - feeds set in the input files. + feeds set in the input files. -T, --omit-pagination - Do not print headers or footers, eliminate any pagination - by form feeds set in the input files. + Do not print headers or footers, eliminate any pagination + by form feeds set in the input files. -v, --show-nonprinting - Print unprintable characters as escape sequences. Use - octal backslash notation. Control-G becomes \007. + Print unprintable characters as escape sequences. Use + octal backslash notation. Control-G becomes \007. -w PAGE_WIDTH, --width=PAGE_WIDTH - Set page width to PAGE_WIDTH characters for multiple - text-column output only (default for PAGE_WIDTH is 72). - -s[CHAR] turns off the default page width and any line - truncation. Lines of full length will be merged, - regardless of the column options set. A POSIX compliant - formulation. + Set page width to PAGE_WIDTH characters for multiple + text-column output only (default for PAGE_WIDTH is 72). + -s[CHAR] turns off the default page width and any line + truncation. Lines of full length will be merged, + regardless of the column options set. A POSIX compliant + formulation. -W PAGE_WIDTH, --page-width=PAGE_WIDTH - Set the page width to PAGE_WIDTH characters. That's valid - with and without a column option. Text lines will be - truncated, unless -J is used. Together with one of the - column options (-COLUMN| -a -COLUMN| -m) column alignment - is always used. - Default is 72 characters. - Without -W PAGE_WIDTH - - but with one of the column options default truncation of - 72 characters is used (to keep downward compatibility - and to simplify most frequently met column tasks). - Column alignment and column separators are used. - - and without any of the column options NO line truncation - is used (to keep downward compatibility and to meet most - frequent tasks). That's equivalent to -W 72 -J . + Set the page width to PAGE_WIDTH characters. That's valid + with and without a column option. Text lines will be + truncated, unless -J is used. Together with one of the + column options (-COLUMN| -a -COLUMN| -m) column alignment + is always used. + Default is 72 characters. + Without -W PAGE_WIDTH + - but with one of the column options default truncation of + 72 characters is used (to keep downward compatibility + and to simplify most frequently met column tasks). + Column alignment and column separators are used. + - and without any of the column options NO line truncation + is used (to keep downward compatibility and to meet most + frequent tasks). That's equivalent to -W 72 -J . - With/without -W PAGE_WIDTH the header line is always - truncated to avoid line overflow. + With/without -W PAGE_WIDTH the header line is always + truncated to avoid line overflow. - (In pr versions newer than 1.14 -S option does no longer - affect -W option.) + (In pr versions newer than 1.14 -S option does no longer + affect -W option.) */ @@ -348,27 +348,27 @@ fit the same printing loop. print_func Function used to print lines in this column. - If we're storing this column it will be - print_stored(), Otherwise it will be read_line(). + If we're storing this column it will be + print_stored(), Otherwise it will be read_line(). char_func Function used to process characters in this column. - If we're storing this column it will be store_char(), - otherwise it will be print_char(). + If we're storing this column it will be store_char(), + otherwise it will be print_char(). current_line Index of the current entry in line_vector, which - contains the index of the first character of the - current line in buff[]. + contains the index of the first character of the + current line in buff[]. lines_stored Number of lines in this column which are stored in - buff. + buff. lines_to_print If we're storing this column, lines_to_print is - the number of stored_lines which remain to be - printed. Otherwise it is the number of lines - we can print without exceeding lines_per_body. + the number of stored_lines which remain to be + printed. Otherwise it is the number of lines + we can print without exceeding lines_per_body. start_position The horizontal position we want to be in before we - print the first character in this column. + print the first character in this column. numbered True means precede this column with a line number. */ @@ -384,11 +384,11 @@ struct COLUMN char const *name; /* File name. */ enum { - OPEN, - FF_FOUND, /* used with -b option, set with \f, changed - to ON_HOLD after print_header */ - ON_HOLD, /* Hit a form feed. */ - CLOSED + OPEN, + FF_FOUND, /* used with -b option, set with \f, changed + to ON_HOLD after print_header */ + ON_HOLD, /* Hit a form feed. */ + CLOSED } status; /* Status of the file pointer. */ @@ -423,7 +423,7 @@ static void print_header (void); static void pad_across_to (int position); static void add_line_number (COLUMN *p); static void getoptarg (char *arg, char switch_char, char *character, - int *number); + int *number); void usage (int status); static void print_files (int number_of_files, char **av); static void init_parameters (int number_of_files); @@ -781,8 +781,8 @@ cols_ready_to_print (void) n = 0; for (q = column_vector, i = 0; i < columns; ++q, ++i) if (q->status == OPEN || - q->status == FF_FOUND || /* With -b: To print a header only */ - (storing_columns && q->lines_stored > 0 && q->lines_to_print > 0)) + q->status == FF_FOUND || /* With -b: To print a header only */ + (storing_columns && q->lines_stored > 0 && q->lines_to_print > 0)) ++n; return n; } @@ -808,9 +808,9 @@ first_last_page (int oi, char c, char const *pages) char const *p1 = p + 1; err = xstrtoumax (p1, &p, 10, &last, ""); if (err != LONGINT_OK) - xstrtol_fatal (err, oi, c, long_options, pages); + xstrtol_fatal (err, oi, c, long_options, pages); if (p1 == p || last < first) - return false; + return false; } if (*p) @@ -832,7 +832,7 @@ parse_column_count (char const *s) if (xstrtol (s, NULL, 10, &tmp_long, "") != LONGINT_OK || !(1 <= tmp_long && tmp_long <= INT_MAX)) error (EXIT_FAILURE, 0, - _("invalid number of columns: %s"), quote (s)); + _("invalid number of columns: %s"), quote (s)); columns = tmp_long; explicit_columns = true; @@ -872,211 +872,211 @@ main (int argc, char **argv) n_files = 0; file_names = (argc > 1 - ? xmalloc ((argc - 1) * sizeof (char *)) - : NULL); + ? xmalloc ((argc - 1) * sizeof (char *)) + : NULL); for (;;) { int oi = -1; int c = getopt_long (argc, argv, short_options, long_options, &oi); if (c == -1) - break; + break; if (ISDIGIT (c)) - { - /* Accumulate column-count digits specified via old-style options. */ - if (n_digits + 1 >= n_alloc) - column_count_string - = X2REALLOC (column_count_string, &n_alloc); - column_count_string[n_digits++] = c; - column_count_string[n_digits] = '\0'; - continue; - } + { + /* Accumulate column-count digits specified via old-style options. */ + if (n_digits + 1 >= n_alloc) + column_count_string + = X2REALLOC (column_count_string, &n_alloc); + column_count_string[n_digits++] = c; + column_count_string[n_digits] = '\0'; + continue; + } n_digits = 0; switch (c) - { - case 1: /* Non-option argument. */ - /* long option --page dominates old `+FIRST_PAGE ...'. */ - if (! (first_page_number == 0 - && *optarg == '+' && first_last_page (-2, '+', optarg + 1))) - file_names[n_files++] = optarg; - break; + { + case 1: /* Non-option argument. */ + /* long option --page dominates old `+FIRST_PAGE ...'. */ + if (! (first_page_number == 0 + && *optarg == '+' && first_last_page (-2, '+', optarg + 1))) + file_names[n_files++] = optarg; + break; - case PAGES_OPTION: /* --pages=FIRST_PAGE[:LAST_PAGE] */ - { /* dominates old opt +... */ - if (! optarg) - error (EXIT_FAILURE, 0, - _("`--pages=FIRST_PAGE[:LAST_PAGE]' missing argument")); - else if (! first_last_page (oi, 0, optarg)) - error (EXIT_FAILURE, 0, _("invalid page range %s"), - quote (optarg)); - break; - } + case PAGES_OPTION: /* --pages=FIRST_PAGE[:LAST_PAGE] */ + { /* dominates old opt +... */ + if (! optarg) + error (EXIT_FAILURE, 0, + _("`--pages=FIRST_PAGE[:LAST_PAGE]' missing argument")); + else if (! first_last_page (oi, 0, optarg)) + error (EXIT_FAILURE, 0, _("invalid page range %s"), + quote (optarg)); + break; + } - case COLUMNS_OPTION: /* --columns=COLUMN */ - { - parse_column_count (optarg); + case COLUMNS_OPTION: /* --columns=COLUMN */ + { + parse_column_count (optarg); - /* If there was a prior column count specified via the - short-named option syntax, e.g., -9, ensure that this - long-name-specified value overrides it. */ - free (column_count_string); - column_count_string = NULL; - n_alloc = 0; - break; - } + /* If there was a prior column count specified via the + short-named option syntax, e.g., -9, ensure that this + long-name-specified value overrides it. */ + free (column_count_string); + column_count_string = NULL; + n_alloc = 0; + break; + } - case 'a': - print_across_flag = true; - storing_columns = false; - break; - case 'b': - balance_columns = true; - break; - case 'c': - use_cntrl_prefix = true; - break; - case 'd': - double_space = true; - break; - case 'D': - date_format = optarg; - break; - case 'e': - if (optarg) - getoptarg (optarg, 'e', &input_tab_char, - &chars_per_input_tab); - /* Could check tab width > 0. */ - untabify_input = true; - break; - case 'f': - case 'F': - use_form_feed = true; - break; - case 'h': - custom_header = optarg; - break; - case 'i': - if (optarg) - getoptarg (optarg, 'i', &output_tab_char, - &chars_per_output_tab); - /* Could check tab width > 0. */ - tabify_output = true; - break; - case 'J': - join_lines = true; - break; - case 'l': - { - long int tmp_long; - if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK - || tmp_long <= 0 || tmp_long > INT_MAX) - { - error (EXIT_FAILURE, 0, - _("`-l PAGE_LENGTH' invalid number of lines: %s"), - quote (optarg)); - } - lines_per_page = tmp_long; - break; - } - case 'm': - parallel_files = true; - storing_columns = false; - break; - case 'n': - numbered_lines = true; - if (optarg) - getoptarg (optarg, 'n', &number_separator, - &chars_per_number); - break; - case 'N': - skip_count = false; - { - long int tmp_long; - if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK - || tmp_long > INT_MAX) - { - error (EXIT_FAILURE, 0, - _("`-N NUMBER' invalid starting line number: %s"), - quote (optarg)); - } - start_line_num = tmp_long; - break; - } - case 'o': - { - long int tmp_long; - if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK - || tmp_long < 0 || tmp_long > INT_MAX) - error (EXIT_FAILURE, 0, - _("`-o MARGIN' invalid line offset: %s"), quote (optarg)); - chars_per_margin = tmp_long; - break; - } - case 'r': - ignore_failed_opens = true; - break; - case 's': - old_options = true; - old_s = true; - if (!use_col_separator && optarg) - separator_string (optarg); - break; - case 'S': - old_s = false; - /* Reset an additional input of -s, -S dominates -s */ - col_sep_string = bad_cast (""); - col_sep_length = 0; - use_col_separator = true; - if (optarg) - separator_string (optarg); - break; - case 't': - extremities = false; - keep_FF = true; - break; - case 'T': - extremities = false; - keep_FF = false; - break; - case 'v': - use_esc_sequence = true; - break; - case 'w': - old_options = true; - old_w = true; - { - long int tmp_long; - if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK - || tmp_long <= 0 || tmp_long > INT_MAX) - error (EXIT_FAILURE, 0, - _("`-w PAGE_WIDTH' invalid number of characters: %s"), - quote (optarg)); - if (!truncate_lines) - chars_per_line = tmp_long; - break; - } - case 'W': - old_w = false; /* dominates -w */ - truncate_lines = true; - { - long int tmp_long; - if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK - || tmp_long <= 0 || tmp_long > INT_MAX) - error (EXIT_FAILURE, 0, - _("`-W PAGE_WIDTH' invalid number of characters: %s"), - quote (optarg)); - chars_per_line = tmp_long; - break; - } - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - break; - } + case 'a': + print_across_flag = true; + storing_columns = false; + break; + case 'b': + balance_columns = true; + break; + case 'c': + use_cntrl_prefix = true; + break; + case 'd': + double_space = true; + break; + case 'D': + date_format = optarg; + break; + case 'e': + if (optarg) + getoptarg (optarg, 'e', &input_tab_char, + &chars_per_input_tab); + /* Could check tab width > 0. */ + untabify_input = true; + break; + case 'f': + case 'F': + use_form_feed = true; + break; + case 'h': + custom_header = optarg; + break; + case 'i': + if (optarg) + getoptarg (optarg, 'i', &output_tab_char, + &chars_per_output_tab); + /* Could check tab width > 0. */ + tabify_output = true; + break; + case 'J': + join_lines = true; + break; + case 'l': + { + long int tmp_long; + if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK + || tmp_long <= 0 || tmp_long > INT_MAX) + { + error (EXIT_FAILURE, 0, + _("`-l PAGE_LENGTH' invalid number of lines: %s"), + quote (optarg)); + } + lines_per_page = tmp_long; + break; + } + case 'm': + parallel_files = true; + storing_columns = false; + break; + case 'n': + numbered_lines = true; + if (optarg) + getoptarg (optarg, 'n', &number_separator, + &chars_per_number); + break; + case 'N': + skip_count = false; + { + long int tmp_long; + if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK + || tmp_long > INT_MAX) + { + error (EXIT_FAILURE, 0, + _("`-N NUMBER' invalid starting line number: %s"), + quote (optarg)); + } + start_line_num = tmp_long; + break; + } + case 'o': + { + long int tmp_long; + if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK + || tmp_long < 0 || tmp_long > INT_MAX) + error (EXIT_FAILURE, 0, + _("`-o MARGIN' invalid line offset: %s"), quote (optarg)); + chars_per_margin = tmp_long; + break; + } + case 'r': + ignore_failed_opens = true; + break; + case 's': + old_options = true; + old_s = true; + if (!use_col_separator && optarg) + separator_string (optarg); + break; + case 'S': + old_s = false; + /* Reset an additional input of -s, -S dominates -s */ + col_sep_string = bad_cast (""); + col_sep_length = 0; + use_col_separator = true; + if (optarg) + separator_string (optarg); + break; + case 't': + extremities = false; + keep_FF = true; + break; + case 'T': + extremities = false; + keep_FF = false; + break; + case 'v': + use_esc_sequence = true; + break; + case 'w': + old_options = true; + old_w = true; + { + long int tmp_long; + if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK + || tmp_long <= 0 || tmp_long > INT_MAX) + error (EXIT_FAILURE, 0, + _("`-w PAGE_WIDTH' invalid number of characters: %s"), + quote (optarg)); + if (!truncate_lines) + chars_per_line = tmp_long; + break; + } + case 'W': + old_w = false; /* dominates -w */ + truncate_lines = true; + { + long int tmp_long; + if (xstrtol (optarg, NULL, 10, &tmp_long, "") != LONGINT_OK + || tmp_long <= 0 || tmp_long > INT_MAX) + error (EXIT_FAILURE, 0, + _("`-W PAGE_WIDTH' invalid number of characters: %s"), + quote (optarg)); + chars_per_line = tmp_long; + break; + } + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + break; + } } if (column_count_string) @@ -1087,8 +1087,8 @@ main (int argc, char **argv) if (! date_format) date_format = (getenv ("POSIXLY_CORRECT") && !hard_locale (LC_TIME) - ? "%b %e %H:%M %Y" - : "%Y-%m-%d %H:%M"); + ? "%b %e %H:%M %Y" + : "%Y-%m-%d %H:%M"); /* Now we can set a reasonable initial value: */ if (first_page_number == 0) @@ -1096,7 +1096,7 @@ main (int argc, char **argv) if (parallel_files & explicit_columns) error (EXIT_FAILURE, 0, - _("cannot specify number of columns when printing in parallel")); + _("cannot specify number of columns when printing in parallel")); if (parallel_files & print_across_flag) error (EXIT_FAILURE, 0, @@ -1111,40 +1111,40 @@ main (int argc, char **argv) if (old_w) { if (parallel_files | explicit_columns) - { - /* activate -W */ - truncate_lines = true; - if (old_s) - /* adapt HP-UX and SunOS: -s = no separator; - activate -S */ - use_col_separator = true; - } - else - /* old -w sets width with columns only - activate -J */ - join_lines = true; - } + { + /* activate -W */ + truncate_lines = true; + if (old_s) + /* adapt HP-UX and SunOS: -s = no separator; + activate -S */ + use_col_separator = true; + } + else + /* old -w sets width with columns only + activate -J */ + join_lines = true; + } else if (!use_col_separator) { - /* No -S option read */ + /* No -S option read */ if (old_s & (parallel_files | explicit_columns)) - { - if (!truncate_lines) - { - /* old -s (without -w and -W) annuls column alignment, - uses fields, activate -J */ - join_lines = true; - if (col_sep_length > 0) - /* activate -S */ - use_col_separator = true; - } - else - /* with -W */ - /* adapt HP-UX and SunOS: -s = no separator; - activate -S */ - use_col_separator = true; - } - } + { + if (!truncate_lines) + { + /* old -s (without -w and -W) annuls column alignment, + uses fields, activate -J */ + join_lines = true; + if (col_sep_length > 0) + /* activate -S */ + use_col_separator = true; + } + else + /* with -W */ + /* adapt HP-UX and SunOS: -s = no separator; + activate -S */ + use_col_separator = true; + } + } } for (; optind < argc; optind++) @@ -1160,13 +1160,13 @@ main (int argc, char **argv) else { if (parallel_files) - print_files (n_files, file_names); + print_files (n_files, file_names); else - { - int i; - for (i = 0; i < n_files; i++) - print_files (1, &file_names[i]); - } + { + int i; + for (i = 0; i < n_files; i++) + print_files (1, &file_names[i]); + } } cleanup (); @@ -1193,13 +1193,13 @@ getoptarg (char *arg, char switch_char, char *character, int *number) { long int tmp_long; if (xstrtol (arg, NULL, 10, &tmp_long, "") != LONGINT_OK - || tmp_long <= 0 || tmp_long > INT_MAX) - { - error (0, 0, - _("`-%c' extra characters or invalid number in the argument: %s"), - switch_char, quote (arg)); - usage (EXIT_FAILURE); - } + || tmp_long <= 0 || tmp_long > INT_MAX) + { + error (0, 0, + _("`-%c' extra characters or invalid number in the argument: %s"), + switch_char, quote (arg)); + usage (EXIT_FAILURE); + } *number = tmp_long; } } @@ -1240,16 +1240,16 @@ init_parameters (int number_of_files) if (columns > 1) { if (!use_col_separator) - { - /* Use default separator */ - if (join_lines) - col_sep_string = line_separator; - else - col_sep_string = column_separator; + { + /* Use default separator */ + if (join_lines) + col_sep_string = line_separator; + else + col_sep_string = column_separator; - col_sep_length = 1; - use_col_separator = true; - } + col_sep_length = 1; + use_col_separator = true; + } /* It's rather pointless to define a TAB separator with column alignment */ else if (!join_lines && *col_sep_string == '\t') @@ -1273,21 +1273,21 @@ init_parameters (int number_of_files) line_count = start_line_num; /* To allow input tab-expansion (-e sensitive) use: - if (number_separator == input_tab_char) - number_width = chars_per_number + - TAB_WIDTH (chars_per_input_tab, chars_per_number); */ + if (number_separator == input_tab_char) + number_width = chars_per_number + + TAB_WIDTH (chars_per_input_tab, chars_per_number); */ /* Estimate chars_per_text without any margin and keep it constant. */ if (number_separator == '\t') - number_width = chars_per_number + - TAB_WIDTH (chars_per_default_tab, chars_per_number); + number_width = chars_per_number + + TAB_WIDTH (chars_per_default_tab, chars_per_number); else - number_width = chars_per_number + 1; + number_width = chars_per_number + 1; /* The number is part of the column width unless we are - printing files in parallel. */ + printing files in parallel. */ if (parallel_files) - chars_used_by_number = number_width; + chars_used_by_number = number_width; /* We use power_10 to cut off the higher-order digits of the line_number in function add_line_number */ @@ -1297,7 +1297,7 @@ init_parameters (int number_of_files) } chars_per_column = (chars_per_line - chars_used_by_number - - (columns - 1) * col_sep_length) / columns; + (columns - 1) * col_sep_length) / columns; if (chars_per_column < 1) error (EXIT_FAILURE, 0, _("page width too narrow")); @@ -1345,49 +1345,49 @@ init_fps (int number_of_files, char **av) { files_left = number_of_files; for (p = column_vector; files_left--; ++p, ++av) - { - if (! open_file (*av, p)) - { - --p; - --columns; - } - } + { + if (! open_file (*av, p)) + { + --p; + --columns; + } + } if (columns == 0) - return false; + return false; init_header ("", -1); } else { p = column_vector; if (number_of_files > 0) - { - if (! open_file (*av, p)) - return false; - init_header (*av, fileno (p->fp)); - p->lines_stored = 0; - } + { + if (! open_file (*av, p)) + return false; + init_header (*av, fileno (p->fp)); + p->lines_stored = 0; + } else - { - p->name = _("standard input"); - p->fp = stdin; - have_read_stdin = true; - p->status = OPEN; - p->full_page_printed = false; - ++total_files; - init_header ("", -1); - p->lines_stored = 0; - } + { + p->name = _("standard input"); + p->fp = stdin; + have_read_stdin = true; + p->status = OPEN; + p->full_page_printed = false; + ++total_files; + init_header ("", -1); + p->lines_stored = 0; + } firstname = p->name; firstfp = p->fp; for (i = columns - 1, ++p; i; --i, ++p) - { - p->name = firstname; - p->fp = firstfp; - p->status = OPEN; - p->full_page_printed = false; - p->lines_stored = 0; - } + { + p->name = firstname; + p->fp = firstfp; + p->status = OPEN; + p->full_page_printed = false; + p->lines_stored = 0; + } } files_ready_to_read = total_files; return true; @@ -1415,9 +1415,9 @@ init_funcs (void) first column to accomodate the number. Looks better than the Sys V approach. */ if (parallel_files & numbered_lines) - h_next = h + chars_per_column + number_width; + h_next = h + chars_per_column + number_width; else - h_next = h + chars_per_column; + h_next = h + chars_per_column; } /* Enlarge p->start_position of first column to use the same form of @@ -1429,16 +1429,16 @@ init_funcs (void) for (p = column_vector, i = 1; i < columns; ++p, ++i) { if (storing_columns) /* One file, multi columns down. */ - { - p->char_func = store_char; - p->print_func = print_stored; - } + { + p->char_func = store_char; + p->print_func = print_stored; + } else - /* One file, multi columns across; or parallel files. */ - { - p->char_func = print_char; - p->print_func = read_line; - } + /* One file, multi columns across; or parallel files. */ + { + p->char_func = print_char; + p->print_func = read_line; + } /* Number only the first column when printing files in parallel. */ @@ -1450,15 +1450,15 @@ init_funcs (void) using a margin. */ if (!truncate_lines) - { - h = ANYWHERE; - h_next = ANYWHERE; - } + { + h = ANYWHERE; + h_next = ANYWHERE; + } else - { - h = h_next + col_sep_length; - h_next = h + chars_per_column; - } + { + h = h_next + col_sep_length; + h_next = h + chars_per_column; + } } /* The rightmost column. @@ -1503,7 +1503,7 @@ open_file (char *name, COLUMN *p) { failed_opens = true; if (!ignore_failed_opens) - error (0, errno, "%s", name); + error (0, errno, "%s", name); return false; } p->status = OPEN; @@ -1533,13 +1533,13 @@ close_file (COLUMN *p) if (!parallel_files) { for (q = column_vector, i = columns; i; ++q, --i) - { - q->status = CLOSED; - if (q->lines_stored == 0) - { - q->lines_to_print = 0; - } - } + { + q->status = CLOSED; + if (q->lines_stored == 0) + { + q->lines_to_print = 0; + } + } } else { @@ -1565,10 +1565,10 @@ hold_file (COLUMN *p) if (!parallel_files) for (q = column_vector, i = columns; i; ++q, --i) { - if (storing_columns) - q->status = FF_FOUND; - else - q->status = ON_HOLD; + if (storing_columns) + q->status = FF_FOUND; + else + q->status = ON_HOLD; } else p->status = ON_HOLD; @@ -1589,8 +1589,8 @@ reset_status (void) for (p = column_vector; i; --i, ++p) if (p->status == ON_HOLD) { - p->status = OPEN; - files_ready_to_read++; + p->status = OPEN; + files_ready_to_read++; } if (storing_columns) @@ -1624,9 +1624,9 @@ print_files (int number_of_files, char **av) if (first_page_number > 1) { if (!skip_to_page (first_page_number)) - return; + return; else - page_number = first_page_number; + page_number = first_page_number; } else page_number = 1; @@ -1660,7 +1660,7 @@ init_header (char const *filename, int desc) { static struct timespec timespec; if (! timespec.tv_sec) - gettime (×pec); + gettime (×pec); t = timespec; } @@ -1669,7 +1669,7 @@ init_header (char const *filename, int desc) if (tm == NULL) { buf = xmalloc (INT_BUFSIZE_BOUND (long int) - + MAX (10, INT_BUFSIZE_BOUND (int))); + + MAX (10, INT_BUFSIZE_BOUND (int))); sprintf (buf, "%ld.%09d", (long int) t.tv_sec, ns); } else @@ -1683,8 +1683,8 @@ init_header (char const *filename, int desc) date_text = buf; file_text = custom_header ? custom_header : desc < 0 ? "" : filename; header_width_available = (chars_per_line - - mbswidth (date_text, 0) - - mbswidth (file_text, 0)); + - mbswidth (date_text, 0) + - mbswidth (file_text, 0)); } /* Set things up for printing a page @@ -1707,35 +1707,35 @@ init_page (void) { store_columns (); for (j = columns - 1, p = column_vector; j; --j, ++p) - { - p->lines_to_print = p->lines_stored; - } + { + p->lines_to_print = p->lines_stored; + } /* Last column. */ if (balance_columns) - { - p->lines_to_print = p->lines_stored; - } + { + p->lines_to_print = p->lines_stored; + } /* Since we're not balancing columns, we don't need to store the rightmost column. Read it straight from the file. */ else - { - if (p->status == OPEN) - { - p->lines_to_print = lines_per_body; - } - else - p->lines_to_print = 0; - } + { + if (p->status == OPEN) + { + p->lines_to_print = lines_per_body; + } + else + p->lines_to_print = 0; + } } else for (j = columns, p = column_vector; j; --j, ++p) if (p->status == OPEN) - { - p->lines_to_print = lines_per_body; - } + { + p->lines_to_print = lines_per_body; + } else - p->lines_to_print = 0; + p->lines_to_print = 0; } /* Align empty columns and print separators. @@ -1812,67 +1812,67 @@ print_page (void) empty_line = true; for (j = 1, p = column_vector; j <= columns; ++j, ++p) - { - input_position = 0; - if (p->lines_to_print > 0 || p->status == FF_FOUND) - { - FF_only = false; - padding_not_printed = p->start_position; - if (!(p->print_func) (p)) - read_rest_of_line (p); - pv |= pad_vertically; + { + input_position = 0; + if (p->lines_to_print > 0 || p->status == FF_FOUND) + { + FF_only = false; + padding_not_printed = p->start_position; + if (!(p->print_func) (p)) + read_rest_of_line (p); + pv |= pad_vertically; - --p->lines_to_print; - if (p->lines_to_print <= 0) - { - if (cols_ready_to_print () <= 0) - break; - } + --p->lines_to_print; + if (p->lines_to_print <= 0) + { + if (cols_ready_to_print () <= 0) + break; + } - /* File p changed its status to ON_HOLD or CLOSED */ - if (parallel_files && p->status != OPEN) - { - if (empty_line) - align_empty_cols = true; - else if (p->status == CLOSED || - (p->status == ON_HOLD && FF_only)) - align_column (p); - } - } - else if (parallel_files) - { - /* File status ON_HOLD or CLOSED */ - if (empty_line) - align_empty_cols = true; - else - align_column (p); - } + /* File p changed its status to ON_HOLD or CLOSED */ + if (parallel_files && p->status != OPEN) + { + if (empty_line) + align_empty_cols = true; + else if (p->status == CLOSED || + (p->status == ON_HOLD && FF_only)) + align_column (p); + } + } + else if (parallel_files) + { + /* File status ON_HOLD or CLOSED */ + if (empty_line) + align_empty_cols = true; + else + align_column (p); + } - /* We need it also with an empty column */ - if (use_col_separator) - ++separators_not_printed; - } + /* We need it also with an empty column */ + if (use_col_separator) + ++separators_not_printed; + } if (pad_vertically) - { - putchar ('\n'); - --lines_left_on_page; - } + { + putchar ('\n'); + --lines_left_on_page; + } if (cols_ready_to_print () <= 0 && !extremities) - break; + break; if (double_space & pv) - { - putchar ('\n'); - --lines_left_on_page; - } + { + putchar ('\n'); + --lines_left_on_page; + } } if (lines_left_on_page == 0) for (j = 1, p = column_vector; j <= columns; ++j, ++p) if (p->status == OPEN) - p->full_page_printed = true; + p->full_page_printed = true; pad_vertically = pv; @@ -1921,8 +1921,8 @@ init_store_cols (void) free (buff); buff_allocated = (use_col_separator - ? 2 * chars_if_truncate - : chars_if_truncate); /* Tune this. */ + ? 2 * chars_if_truncate + : chars_if_truncate); /* Tune this. */ buff = xmalloc (buff_allocated); } @@ -1964,22 +1964,22 @@ store_columns (void) p->current_line = line; for (j = lines_per_body; j && files_ready_to_read; --j) - if (p->status == OPEN) /* Redundant. Clean up. */ - { - input_position = 0; + if (p->status == OPEN) /* Redundant. Clean up. */ + { + input_position = 0; - if (!read_line (p)) - read_rest_of_line (p); + if (!read_line (p)) + read_rest_of_line (p); - if (p->status == OPEN - || buff_start != buff_current) - { - ++p->lines_stored; - line_vector[line] = buff_start; - end_vector[line++] = input_position; - buff_start = buff_current; - } - } + if (p->status == OPEN + || buff_start != buff_current) + { + ++p->lines_stored; + line_vector[line] = buff_start; + end_vector[line++] = input_position; + buff_start = buff_current; + } + } } /* Keep track of the location of the last char in buff. */ @@ -2000,7 +2000,7 @@ balance (int total_stored) { lines = total_stored / columns; if (i <= total_stored % columns) - ++lines; + ++lines; p->lines_stored = lines; p->current_line = first_line; @@ -2046,13 +2046,13 @@ add_line_number (COLUMN *p) if (columns > 1) { /* Tabification is assumed for multiple columns, also for n-separators, - but `default n-separator = TAB' hasn't been given priority over - equal column_width also specified by POSIX. */ + but `default n-separator = TAB' hasn't been given priority over + equal column_width also specified by POSIX. */ if (number_separator == '\t') { i = number_width - chars_per_number; while (i-- > 0) - (p->char_func) (' '); + (p->char_func) (' '); } else (p->char_func) (number_separator); @@ -2065,7 +2065,7 @@ add_line_number (COLUMN *p) (p->char_func) (number_separator); if (number_separator == '\t') output_position = POS_AFTER_TAB (chars_per_output_tab, - output_position); + output_position); } if (truncate_lines & !parallel_files) @@ -2085,7 +2085,7 @@ pad_across_to (int position) else { while (++h <= position) - putchar (' '); + putchar (' '); output_position = position; } } @@ -2122,19 +2122,19 @@ read_rest_of_line (COLUMN *p) while ((c = getc (f)) != '\n') { if (c == '\f') - { - if ((c = getc (f)) != '\n') - ungetc (c, f); - if (keep_FF) - print_a_FF = true; - hold_file (p); - break; - } + { + if ((c = getc (f)) != '\n') + ungetc (c, f); + if (keep_FF) + print_a_FF = true; + hold_file (p); + break; + } else if (c == EOF) - { - close_file (p); - break; - } + { + close_file (p); + break; + } } } @@ -2178,28 +2178,28 @@ skip_read (COLUMN *p, int column_number) while (c != '\n') { if (c == '\f') - { - /* No FF-coincidence possible, - no catching up of a FF-coincidence with next page */ - if (last_line) - { - if (!parallel_files) - for (q = column_vector, i = columns; i; ++q, --i) - q->full_page_printed = false; - else - p->full_page_printed = false; - } + { + /* No FF-coincidence possible, + no catching up of a FF-coincidence with next page */ + if (last_line) + { + if (!parallel_files) + for (q = column_vector, i = columns; i; ++q, --i) + q->full_page_printed = false; + else + p->full_page_printed = false; + } - if ((c = getc (f)) != '\n') - ungetc (c, f); - hold_file (p); - break; - } + if ((c = getc (f)) != '\n') + ungetc (c, f); + hold_file (p); + break; + } else if (c == EOF) - { - close_file (p); - break; - } + { + close_file (p); + break; + } c = getc (f); } @@ -2222,7 +2222,7 @@ print_white_space (void) int goal = h_old + spaces_not_printed; while (goal - h_old > 1 - && (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal) + && (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal) { putchar (output_tab_char); h_old = h_new; @@ -2251,35 +2251,35 @@ print_sep_string (void) { /* We'll be starting a line with chars_per_margin, anything else? */ if (spaces_not_printed > 0) - print_white_space (); + print_white_space (); } else { for (; separators_not_printed > 0; --separators_not_printed) - { - while (l-- > 0) - { - /* 3 types of sep_strings: spaces only, spaces and chars, - chars only */ - if (*s == ' ') - { - /* We're tabifying output; consecutive spaces in - sep_string may have to be converted to tabs */ - s++; - ++spaces_not_printed; - } - else - { - if (spaces_not_printed > 0) - print_white_space (); - putchar (*s++); - ++output_position; - } - } + { + while (l-- > 0) + { + /* 3 types of sep_strings: spaces only, spaces and chars, + chars only */ + if (*s == ' ') + { + /* We're tabifying output; consecutive spaces in + sep_string may have to be converted to tabs */ + s++; + ++spaces_not_printed; + } + else + { + if (spaces_not_printed > 0) + print_white_space (); + putchar (*s++); + ++output_position; + } + } /* sep_string ends with some spaces */ - if (spaces_not_printed > 0) - print_white_space (); - } + if (spaces_not_printed > 0) + print_white_space (); + } } } @@ -2308,21 +2308,21 @@ print_char (char c) if (tabify_output) { if (c == ' ') - { - ++spaces_not_printed; - return; - } + { + ++spaces_not_printed; + return; + } else if (spaces_not_printed > 0) - print_white_space (); + print_white_space (); /* Nonprintables are assumed to have width 0, except '\b'. */ if (! isprint (to_uchar (c))) - { - if (c == '\b') - --output_position; - } + { + if (c == '\b') + --output_position; + } else - ++output_position; + ++output_position; } putchar (c); } @@ -2341,34 +2341,34 @@ skip_to_page (uintmax_t page) for (n = 1; n < page; ++n) { for (i = 1; i < lines_per_body; ++i) - { - for (j = 1, p = column_vector; j <= columns; ++j, ++p) - if (p->status == OPEN) - skip_read (p, j); - } + { + for (j = 1, p = column_vector; j <= columns; ++j, ++p) + if (p->status == OPEN) + skip_read (p, j); + } last_line = true; for (j = 1, p = column_vector; j <= columns; ++j, ++p) - if (p->status == OPEN) - skip_read (p, j); + if (p->status == OPEN) + skip_read (p, j); if (storing_columns) /* change FF_FOUND to ON_HOLD */ - for (j = 1, p = column_vector; j <= columns; ++j, ++p) - if (p->status != CLOSED) - p->status = ON_HOLD; + for (j = 1, p = column_vector; j <= columns; ++j, ++p) + if (p->status != CLOSED) + p->status = ON_HOLD; reset_status (); last_line = false; if (files_ready_to_read < 1) { - /* It's very helpful, normally the total number of pages is - not known in advance. */ - error (0, 0, - _("starting page number %"PRIuMAX - " exceeds page count %"PRIuMAX), - page, n); + /* It's very helpful, normally the total number of pages is + not known in advance. */ + error (0, 0, + _("starting page number %"PRIuMAX + " exceeds page count %"PRIuMAX), + page, n); break; - } + } } return files_ready_to_read > 0; } @@ -2455,15 +2455,15 @@ read_line (COLUMN *p) { case '\f': if ((c = getc (p->fp)) != '\n') - ungetc (c, p->fp); + ungetc (c, p->fp); FF_only = true; if (print_a_header & !storing_columns) - { - pad_vertically = true; - print_header (); - } + { + pad_vertically = true; + print_header (); + } else if (keep_FF) - print_a_FF = true; + print_a_FF = true; hold_file (p); return true; case EOF: @@ -2486,34 +2486,34 @@ read_line (COLUMN *p) pad_vertically = true; if (print_a_header & !storing_columns) - print_header (); + print_header (); if (parallel_files & align_empty_cols) - { - /* We have to align empty columns at the beginning of a line. */ - k = separators_not_printed; - separators_not_printed = 0; - for (j = 1, q = column_vector; j <= k; ++j, ++q) - { - align_column (q); - separators_not_printed += 1; - } - padding_not_printed = p->start_position; - if (truncate_lines) - spaces_not_printed = chars_per_column; - else - spaces_not_printed = 0; - align_empty_cols = false; - } + { + /* We have to align empty columns at the beginning of a line. */ + k = separators_not_printed; + separators_not_printed = 0; + for (j = 1, q = column_vector; j <= k; ++j, ++q) + { + align_column (q); + separators_not_printed += 1; + } + padding_not_printed = p->start_position; + if (truncate_lines) + spaces_not_printed = chars_per_column; + else + spaces_not_printed = 0; + align_empty_cols = false; + } if (padding_not_printed - col_sep_length > 0) - { - pad_across_to (padding_not_printed - col_sep_length); - padding_not_printed = ANYWHERE; - } + { + pad_across_to (padding_not_printed - col_sep_length); + padding_not_printed = ANYWHERE; + } if (use_col_separator) - print_sep_string (); + print_sep_string (); } if (p->numbered) @@ -2530,28 +2530,28 @@ read_line (COLUMN *p) c = getc (p->fp); switch (c) - { - case '\n': - return true; - case '\f': - if ((c = getc (p->fp)) != '\n') - ungetc (c, p->fp); - if (keep_FF) - print_a_FF = true; - hold_file (p); - return true; - case EOF: - close_file (p); - return true; - } + { + case '\n': + return true; + case '\f': + if ((c = getc (p->fp)) != '\n') + ungetc (c, p->fp); + if (keep_FF) + print_a_FF = true; + hold_file (p); + return true; + case EOF: + close_file (p); + return true; + } last_input_position = input_position; chars = char_to_clump (c); if (truncate_lines && input_position > chars_per_column) - { - input_position = last_input_position; - return false; - } + { + input_position = last_input_position; + return false; + } print_clump (p, chars, clump_buff); } @@ -2600,13 +2600,13 @@ print_stored (COLUMN *p) if (p->status == FF_FOUND) { for (i = 1, q = column_vector; i <= columns; ++i, ++q) - q->status = ON_HOLD; + q->status = ON_HOLD; if (column_vector->lines_to_print <= 0) - { - if (!extremities) - pad_vertically = false; - return true; /* print a header only */ - } + { + if (!extremities) + pad_vertically = false; + return true; /* print a header only */ + } } if (padding_not_printed - col_sep_length > 0) @@ -2625,7 +2625,7 @@ print_stored (COLUMN *p) { output_position = p->start_position + end_vector[line]; if (p->start_position - col_sep_length == chars_per_margin) - output_position -= col_sep_length; + output_position -= col_sep_length; } return true; @@ -2662,60 +2662,60 @@ char_to_clump (char c) width = TAB_WIDTH (chars_per_c, input_position); if (untabify_input) - { - for (i = width; i; --i) - *s++ = ' '; - chars = width; - } + { + for (i = width; i; --i) + *s++ = ' '; + chars = width; + } else - { - *s = c; - chars = 1; - } + { + *s = c; + chars = 1; + } } else if (! isprint (uc)) { if (use_esc_sequence) - { - width = 4; - chars = 4; - *s++ = '\\'; - sprintf (esc_buff, "%03o", uc); - for (i = 0; i <= 2; ++i) - *s++ = esc_buff[i]; - } + { + width = 4; + chars = 4; + *s++ = '\\'; + sprintf (esc_buff, "%03o", uc); + for (i = 0; i <= 2; ++i) + *s++ = esc_buff[i]; + } else if (use_cntrl_prefix) - { - if (uc < 0200) - { - width = 2; - chars = 2; - *s++ = '^'; - *s++ = c ^ 0100; - } - else - { - width = 4; - chars = 4; - *s++ = '\\'; - sprintf (esc_buff, "%03o", uc); - for (i = 0; i <= 2; ++i) - *s++ = esc_buff[i]; - } - } + { + if (uc < 0200) + { + width = 2; + chars = 2; + *s++ = '^'; + *s++ = c ^ 0100; + } + else + { + width = 4; + chars = 4; + *s++ = '\\'; + sprintf (esc_buff, "%03o", uc); + for (i = 0; i <= 2; ++i) + *s++ = esc_buff[i]; + } + } else if (c == '\b') - { - width = -1; - chars = 1; - *s = c; - } + { + width = -1; + chars = 1; + *s = c; + } else - { - width = 0; - chars = 1; - *s = c; - } + { + width = 0; + chars = 1; + *s = c; + } } else { @@ -2761,13 +2761,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Paginate or columnate FILE(s) for printing.\n\ diff --git a/src/bin/coreutils/src/printenv.c b/src/bin/coreutils/src/printenv.c index 7c9b544419..69e2a6639b 100644 --- a/src/bin/coreutils/src/printenv.c +++ b/src/bin/coreutils/src/printenv.c @@ -52,7 +52,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -62,7 +62,7 @@ Print the values of the specified environment VARIABLE(s).\n\ If no VARIABLE is specified, print name and value pairs for them all.\n\ \n\ "), - program_name, program_name); + program_name, program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); @@ -89,14 +89,14 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "+", NULL, NULL) != -1) usage (PRINTENV_FAILURE); if (optind >= argc) { for (env = environ; *env != NULL; ++env) - puts (*env); + puts (*env); ok = true; } else @@ -104,26 +104,26 @@ main (int argc, char **argv) int matches = 0; for (i = optind; i < argc; ++i) - { - bool matched = false; + { + bool matched = false; - for (env = environ; *env; ++env) - { - ep = *env; - ap = argv[i]; - while (*ep != '\0' && *ap != '\0' && *ep++ == *ap++) - { - if (*ep == '=' && *ap == '\0') - { - puts (ep + 1); - matched = true; - break; - } - } - } + for (env = environ; *env; ++env) + { + ep = *env; + ap = argv[i]; + while (*ep != '\0' && *ap != '\0' && *ep++ == *ap++) + { + if (*ep == '=' && *ap == '\0') + { + puts (ep + 1); + matched = true; + break; + } + } + } - matches += matched; - } + matches += matched; + } ok = (matches == argc - optind); } diff --git a/src/bin/coreutils/src/printf.c b/src/bin/coreutils/src/printf.c index 89fa45628a..5fa25dee82 100644 --- a/src/bin/coreutils/src/printf.c +++ b/src/bin/coreutils/src/printf.c @@ -63,7 +63,7 @@ #define isodigit(c) ((c) >= '0' && (c) <= '7') #define hextobin(c) ((c) >= 'a' && (c) <= 'f' ? (c) - 'a' + 10 : \ - (c) >= 'A' && (c) <= 'F' ? (c) - 'A' + 10 : (c) - '0') + (c) >= 'A' && (c) <= 'F' ? (c) - 'A' + 10 : (c) - '0') #define octtobin(c) ((c) - '0') /* The value to return to the calling program. */ @@ -82,14 +82,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s FORMAT [ARGUMENT]...\n\ or: %s OPTION\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Print ARGUMENT(s) according to FORMAT, or execute according to OPTION:\n\ \n\ @@ -146,9 +146,9 @@ verify_numeric (const char *s, const char *end) else if (*end) { if (s == end) - error (0, 0, _("%s: expected a numeric value"), s); + error (0, 0, _("%s: expected a numeric value"), s); else - error (0, 0, _("%s: value not completely converted"), s); + error (0, 0, _("%s: value not completely converted"), s); exit_status = EXIT_FAILURE; } } @@ -159,17 +159,17 @@ FUNC_NAME (char const *s) \ { \ char *end; \ TYPE val; \ - \ + \ if (*s == '\"' || *s == '\'') \ { \ unsigned char ch = *++s; \ val = ch; \ /* If POSIXLY_CORRECT is not set, then give a warning that there \ - are characters following the character constant and that GNU \ - printf is ignoring those characters. If POSIXLY_CORRECT *is* \ - set, then don't give the warning. */ \ + are characters following the character constant and that GNU \ + printf is ignoring those characters. If POSIXLY_CORRECT *is* \ + set, then don't give the warning. */ \ if (*++s != 0 && !posixly_correct) \ - error (0, 0, _(cfcc_msg), s); \ + error (0, 0, _(cfcc_msg), s); \ } \ else \ { \ @@ -238,11 +238,11 @@ print_esc (const char *escstart, bool octal_0) { /* A hexadecimal \xhh escape sequence must have 1 or 2 hex. digits. */ for (esc_length = 0, ++p; - esc_length < 2 && isxdigit (to_uchar (*p)); - ++esc_length, ++p) - esc_value = esc_value * 16 + hextobin (*p); + esc_length < 2 && isxdigit (to_uchar (*p)); + ++esc_length, ++p) + esc_value = esc_value * 16 + hextobin (*p); if (esc_length == 0) - error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); + error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); putchar (esc_value); } else if (isodigit (*p)) @@ -251,9 +251,9 @@ print_esc (const char *escstart, bool octal_0) Allow \ooo if octal_0 && *p != '0'; this is an undocumented extension to POSIX that is compatible with Bash 2.05b. */ for (esc_length = 0, p += octal_0 && *p == '0'; - esc_length < 3 && isodigit (*p); - ++esc_length, ++p) - esc_value = esc_value * 8 + octtobin (*p); + esc_length < 3 && isodigit (*p); + ++esc_length, ++p) + esc_value = esc_value * 8 + octtobin (*p); putchar (esc_value); } else if (*p && strchr ("\"\\abcfnrtv", *p)) @@ -265,24 +265,24 @@ print_esc (const char *escstart, bool octal_0) uni_value = 0; for (esc_length = (esc_char == 'u' ? 4 : 8), ++p; - esc_length > 0; - --esc_length, ++p) - { - if (! isxdigit (to_uchar (*p))) - error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); - uni_value = uni_value * 16 + hextobin (*p); - } + esc_length > 0; + --esc_length, ++p) + { + if (! isxdigit (to_uchar (*p))) + error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); + uni_value = uni_value * 16 + hextobin (*p); + } /* A universal character name shall not specify a character short - identifier in the range 00000000 through 00000020, 0000007F through - 0000009F, or 0000D800 through 0000DFFF inclusive. A universal - character name shall not designate a character in the required - character set. */ + identifier in the range 00000000 through 00000020, 0000007F through + 0000009F, or 0000D800 through 0000DFFF inclusive. A universal + character name shall not designate a character in the required + character set. */ if ((uni_value <= 0x9f - && uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60) - || (uni_value >= 0xd800 && uni_value <= 0xdfff)) - error (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"), - esc_char, (esc_char == 'u' ? 4 : 8), uni_value); + && uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60) + || (uni_value >= 0xd800 && uni_value <= 0xdfff)) + error (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"), + esc_char, (esc_char == 'u' ? 4 : 8), uni_value); print_unicode_char (stdout, uni_value, 0); } @@ -290,10 +290,10 @@ print_esc (const char *escstart, bool octal_0) { putchar ('\\'); if (*p) - { - putchar (*p); - p++; - } + { + putchar (*p); + p++; + } } return p - escstart - 1; } @@ -320,9 +320,9 @@ print_esc_string (const char *str) static void print_direc (const char *start, size_t length, char conversion, - bool have_field_width, int field_width, - bool have_precision, int precision, - char const *argument) + bool have_field_width, int field_width, + bool have_precision, int precision, + char const *argument) { char *p; /* Null-terminated copy of % directive. */ @@ -337,20 +337,20 @@ print_direc (const char *start, size_t length, char conversion, switch (conversion) { case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': - length_modifier = PRIdMAX; - length_modifier_len = sizeof PRIdMAX - 2; - break; + length_modifier = PRIdMAX; + length_modifier_len = sizeof PRIdMAX - 2; + break; case 'a': case 'e': case 'f': case 'g': case 'A': case 'E': case 'F': case 'G': - length_modifier = "L"; - length_modifier_len = 1; - break; + length_modifier = "L"; + length_modifier_len = 1; + break; default: - length_modifier = start; /* Any valid pointer will do. */ - length_modifier_len = 0; - break; + length_modifier = start; /* Any valid pointer will do. */ + length_modifier_len = 0; + break; } p = xmalloc (length + length_modifier_len + 2); @@ -365,21 +365,21 @@ print_direc (const char *start, size_t length, char conversion, case 'd': case 'i': { - intmax_t arg = vstrtoimax (argument); - if (!have_field_width) - { - if (!have_precision) - xprintf (p, arg); - else - xprintf (p, precision, arg); - } - else - { - if (!have_precision) - xprintf (p, field_width, arg); - else - xprintf (p, field_width, precision, arg); - } + intmax_t arg = vstrtoimax (argument); + if (!have_field_width) + { + if (!have_precision) + xprintf (p, arg); + else + xprintf (p, precision, arg); + } + else + { + if (!have_precision) + xprintf (p, field_width, arg); + else + xprintf (p, field_width, precision, arg); + } } break; @@ -388,21 +388,21 @@ print_direc (const char *start, size_t length, char conversion, case 'x': case 'X': { - uintmax_t arg = vstrtoumax (argument); - if (!have_field_width) - { - if (!have_precision) - xprintf (p, arg); - else - xprintf (p, precision, arg); - } - else - { - if (!have_precision) - xprintf (p, field_width, arg); - else - xprintf (p, field_width, precision, arg); - } + uintmax_t arg = vstrtoumax (argument); + if (!have_field_width) + { + if (!have_precision) + xprintf (p, arg); + else + xprintf (p, precision, arg); + } + else + { + if (!have_precision) + xprintf (p, field_width, arg); + else + xprintf (p, field_width, precision, arg); + } } break; @@ -415,46 +415,46 @@ print_direc (const char *start, size_t length, char conversion, case 'g': case 'G': { - long double arg = vstrtold (argument); - if (!have_field_width) - { - if (!have_precision) - xprintf (p, arg); - else - xprintf (p, precision, arg); - } - else - { - if (!have_precision) - xprintf (p, field_width, arg); - else - xprintf (p, field_width, precision, arg); - } + long double arg = vstrtold (argument); + if (!have_field_width) + { + if (!have_precision) + xprintf (p, arg); + else + xprintf (p, precision, arg); + } + else + { + if (!have_precision) + xprintf (p, field_width, arg); + else + xprintf (p, field_width, precision, arg); + } } break; case 'c': if (!have_field_width) - xprintf (p, *argument); + xprintf (p, *argument); else - xprintf (p, field_width, *argument); + xprintf (p, field_width, *argument); break; case 's': if (!have_field_width) - { - if (!have_precision) - xprintf (p, argument); - else - xprintf (p, precision, argument); - } + { + if (!have_precision) + xprintf (p, argument); + else + xprintf (p, precision, argument); + } else - { - if (!have_precision) - xprintf (p, field_width, argument); - else - xprintf (p, field_width, precision, argument); - } + { + if (!have_precision) + xprintf (p, field_width, argument); + else + xprintf (p, field_width, precision, argument); + } break; } @@ -481,146 +481,146 @@ print_formatted (const char *format, int argc, char **argv) for (f = format; *f; ++f) { switch (*f) - { - case '%': - direc_start = f++; - direc_length = 1; - have_field_width = have_precision = false; - if (*f == '%') - { - putchar ('%'); - break; - } - if (*f == 'b') - { - /* FIXME: Field width and precision are not supported - for %b, even though POSIX requires it. */ - if (argc > 0) - { - print_esc_string (*argv); - ++argv; - --argc; - } - break; - } + { + case '%': + direc_start = f++; + direc_length = 1; + have_field_width = have_precision = false; + if (*f == '%') + { + putchar ('%'); + break; + } + if (*f == 'b') + { + /* FIXME: Field width and precision are not supported + for %b, even though POSIX requires it. */ + if (argc > 0) + { + print_esc_string (*argv); + ++argv; + --argc; + } + break; + } - memset (ok, 0, sizeof ok); - ok['a'] = ok['A'] = ok['c'] = ok['d'] = ok['e'] = ok['E'] = - ok['f'] = ok['F'] = ok['g'] = ok['G'] = ok['i'] = ok['o'] = - ok['s'] = ok['u'] = ok['x'] = ok['X'] = 1; + memset (ok, 0, sizeof ok); + ok['a'] = ok['A'] = ok['c'] = ok['d'] = ok['e'] = ok['E'] = + ok['f'] = ok['F'] = ok['g'] = ok['G'] = ok['i'] = ok['o'] = + ok['s'] = ok['u'] = ok['x'] = ok['X'] = 1; - for (;; f++, direc_length++) - switch (*f) - { + for (;; f++, direc_length++) + switch (*f) + { #if (__GLIBC__ == 2 && 2 <= __GLIBC_MINOR__) || 3 <= __GLIBC__ - case 'I': + case 'I': #endif - case '\'': - ok['a'] = ok['A'] = ok['c'] = ok['e'] = ok['E'] = - ok['o'] = ok['s'] = ok['x'] = ok['X'] = 0; - break; - case '-': case '+': case ' ': - break; - case '#': - ok['c'] = ok['d'] = ok['i'] = ok['s'] = ok['u'] = 0; - break; - case '0': - ok['c'] = ok['s'] = 0; - break; - default: - goto no_more_flag_characters; - } - no_more_flag_characters:; + case '\'': + ok['a'] = ok['A'] = ok['c'] = ok['e'] = ok['E'] = + ok['o'] = ok['s'] = ok['x'] = ok['X'] = 0; + break; + case '-': case '+': case ' ': + break; + case '#': + ok['c'] = ok['d'] = ok['i'] = ok['s'] = ok['u'] = 0; + break; + case '0': + ok['c'] = ok['s'] = 0; + break; + default: + goto no_more_flag_characters; + } + no_more_flag_characters:; - if (*f == '*') - { - ++f; - ++direc_length; - if (argc > 0) - { - intmax_t width = vstrtoimax (*argv); - if (INT_MIN <= width && width <= INT_MAX) - field_width = width; - else - error (EXIT_FAILURE, 0, _("invalid field width: %s"), - *argv); - ++argv; - --argc; - } - else - field_width = 0; - have_field_width = true; - } - else - while (ISDIGIT (*f)) - { - ++f; - ++direc_length; - } - if (*f == '.') - { - ++f; - ++direc_length; - ok['c'] = 0; - if (*f == '*') - { - ++f; - ++direc_length; - if (argc > 0) - { - intmax_t prec = vstrtoimax (*argv); - if (prec < 0) - { - /* A negative precision is taken as if the - precision were omitted, so -1 is safe - here even if prec < INT_MIN. */ - precision = -1; - } - else if (INT_MAX < prec) - error (EXIT_FAILURE, 0, _("invalid precision: %s"), - *argv); - else - precision = prec; - ++argv; - --argc; - } - else - precision = 0; - have_precision = true; - } - else - while (ISDIGIT (*f)) - { - ++f; - ++direc_length; - } - } + if (*f == '*') + { + ++f; + ++direc_length; + if (argc > 0) + { + intmax_t width = vstrtoimax (*argv); + if (INT_MIN <= width && width <= INT_MAX) + field_width = width; + else + error (EXIT_FAILURE, 0, _("invalid field width: %s"), + *argv); + ++argv; + --argc; + } + else + field_width = 0; + have_field_width = true; + } + else + while (ISDIGIT (*f)) + { + ++f; + ++direc_length; + } + if (*f == '.') + { + ++f; + ++direc_length; + ok['c'] = 0; + if (*f == '*') + { + ++f; + ++direc_length; + if (argc > 0) + { + intmax_t prec = vstrtoimax (*argv); + if (prec < 0) + { + /* A negative precision is taken as if the + precision were omitted, so -1 is safe + here even if prec < INT_MIN. */ + precision = -1; + } + else if (INT_MAX < prec) + error (EXIT_FAILURE, 0, _("invalid precision: %s"), + *argv); + else + precision = prec; + ++argv; + --argc; + } + else + precision = 0; + have_precision = true; + } + else + while (ISDIGIT (*f)) + { + ++f; + ++direc_length; + } + } - while (*f == 'l' || *f == 'L' || *f == 'h' - || *f == 'j' || *f == 't' || *f == 'z') - ++f; + while (*f == 'l' || *f == 'L' || *f == 'h' + || *f == 'j' || *f == 't' || *f == 'z') + ++f; - { - unsigned char conversion = *f; - if (! ok[conversion]) - error (EXIT_FAILURE, 0, - _("%.*s: invalid conversion specification"), - (int) (f + 1 - direc_start), direc_start); - } + { + unsigned char conversion = *f; + if (! ok[conversion]) + error (EXIT_FAILURE, 0, + _("%.*s: invalid conversion specification"), + (int) (f + 1 - direc_start), direc_start); + } - print_direc (direc_start, direc_length, *f, - have_field_width, field_width, - have_precision, precision, - (argc <= 0 ? "" : (argc--, *argv++))); - break; + print_direc (direc_start, direc_length, *f, + have_field_width, field_width, + have_precision, precision, + (argc <= 0 ? "" : (argc--, *argv++))); + break; - case '\\': - f += print_esc (f, false); - break; + case '\\': + f += print_esc (f, false); + break; - default: - putchar (*f); - } + default: + putchar (*f); + } } return save_argc - argc; @@ -649,14 +649,14 @@ main (int argc, char **argv) if (argc == 2) { if (STREQ (argv[1], "--help")) - usage (EXIT_SUCCESS); + usage (EXIT_SUCCESS); if (STREQ (argv[1], "--version")) - { - version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, - (char *) NULL); - exit (EXIT_SUCCESS); - } + { + version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, + (char *) NULL); + exit (EXIT_SUCCESS); + } } /* The above handles --help and --version. @@ -687,8 +687,8 @@ main (int argc, char **argv) if (argc > 0) error (0, 0, - _("warning: ignoring excess arguments, starting with %s"), - quote (argv[0])); + _("warning: ignoring excess arguments, starting with %s"), + quote (argv[0])); exit (exit_status); } diff --git a/src/bin/coreutils/src/ptx.c b/src/bin/coreutils/src/ptx.c index 5d29bd1458..806908eeeb 100644 --- a/src/bin/coreutils/src/ptx.c +++ b/src/bin/coreutils/src/ptx.c @@ -44,7 +44,7 @@ #define ISODIGIT(C) ((C) >= '0' && (C) <= '7') #define HEXTOBIN(C) ((C) >= 'a' && (C) <= 'f' ? (C)-'a'+10 \ - : (C) >= 'A' && (C) <= 'F' ? (C)-'A'+10 : (C)-'0') + : (C) >= 'A' && (C) <= 'F' ? (C)-'A'+10 : (C)-'0') #define OCTTOBIN(C) ((C) - '0') /* Debugging the memory allocator. */ @@ -82,10 +82,10 @@ static bool right_reference = false; /* output refs after right context */ static int line_width = 72; /* output line width in characters */ static int gap_size = 3; /* number of spaces between output fields */ static const char *truncation_string = "/"; - /* string used to mark line truncations */ + /* string used to mark line truncations */ static const char *macro_name = "xx"; /* macro name for roff or TeX output */ static enum Format output_format = UNKNOWN_FORMAT; - /* output format */ + /* output format */ static bool ignore_case = false; /* fold lower to upper for sorting */ static const char *break_file = NULL; /* name of the `Break characters' file */ @@ -306,94 +306,94 @@ copy_unescaped_string (const char *string) while (*string) { if (*string == '\\') - { - string++; - switch (*string) - { - case 'x': /* \xhhh escape, 3 chars maximum */ - value = 0; - for (length = 0, string++; - length < 3 && isxdigit (to_uchar (*string)); - length++, string++) - value = value * 16 + HEXTOBIN (*string); - if (length == 0) - { - *cursor++ = '\\'; - *cursor++ = 'x'; - } - else - *cursor++ = value; - break; + { + string++; + switch (*string) + { + case 'x': /* \xhhh escape, 3 chars maximum */ + value = 0; + for (length = 0, string++; + length < 3 && isxdigit (to_uchar (*string)); + length++, string++) + value = value * 16 + HEXTOBIN (*string); + if (length == 0) + { + *cursor++ = '\\'; + *cursor++ = 'x'; + } + else + *cursor++ = value; + break; - case '0': /* \0ooo escape, 3 chars maximum */ - value = 0; - for (length = 0, string++; - length < 3 && ISODIGIT (*string); - length++, string++) - value = value * 8 + OCTTOBIN (*string); - *cursor++ = value; - break; + case '0': /* \0ooo escape, 3 chars maximum */ + value = 0; + for (length = 0, string++; + length < 3 && ISODIGIT (*string); + length++, string++) + value = value * 8 + OCTTOBIN (*string); + *cursor++ = value; + break; - case 'a': /* alert */ + case 'a': /* alert */ #if __STDC__ - *cursor++ = '\a'; + *cursor++ = '\a'; #else - *cursor++ = 7; + *cursor++ = 7; #endif - string++; - break; + string++; + break; - case 'b': /* backspace */ - *cursor++ = '\b'; - string++; - break; + case 'b': /* backspace */ + *cursor++ = '\b'; + string++; + break; - case 'c': /* cancel the rest of the output */ - while (*string) - string++; - break; + case 'c': /* cancel the rest of the output */ + while (*string) + string++; + break; - case 'f': /* form feed */ - *cursor++ = '\f'; - string++; - break; + case 'f': /* form feed */ + *cursor++ = '\f'; + string++; + break; - case 'n': /* new line */ - *cursor++ = '\n'; - string++; - break; + case 'n': /* new line */ + *cursor++ = '\n'; + string++; + break; - case 'r': /* carriage return */ - *cursor++ = '\r'; - string++; - break; + case 'r': /* carriage return */ + *cursor++ = '\r'; + string++; + break; - case 't': /* horizontal tab */ - *cursor++ = '\t'; - string++; - break; + case 't': /* horizontal tab */ + *cursor++ = '\t'; + string++; + break; - case 'v': /* vertical tab */ + case 'v': /* vertical tab */ #if __STDC__ - *cursor++ = '\v'; + *cursor++ = '\v'; #else - *cursor++ = 11; + *cursor++ = 11; #endif - string++; - break; + string++; + break; - case '\0': /* lone backslash at end of string */ - /* ignore it */ - break; + case '\0': /* lone backslash at end of string */ + /* ignore it */ + break; - default: - *cursor++ = '\\'; - *cursor++ = *string++; - break; - } - } + default: + *cursor++ = '\\'; + *cursor++ = *string++; + break; + } + } else - *cursor++ = *string++; + *cursor++ = *string++; } *cursor = '\0'; @@ -453,7 +453,7 @@ initialize_regex (void) if (context_regex.string) { if (!*context_regex.string) - context_regex.string = NULL; + context_regex.string = NULL; } else if (gnu_extensions & !input_reference) context_regex.string = "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*"; @@ -476,23 +476,23 @@ initialize_regex (void) else if (!break_file) { if (gnu_extensions) - { + { - /* Simulate \w+. */ + /* Simulate \w+. */ - for (character = 0; character < CHAR_SET_SIZE; character++) - word_fastmap[character] = !! isalpha (character); - } + for (character = 0; character < CHAR_SET_SIZE; character++) + word_fastmap[character] = !! isalpha (character); + } else - { + { - /* Simulate [^ \t\n]+. */ + /* Simulate [^ \t\n]+. */ - memset (word_fastmap, 1, CHAR_SET_SIZE); - word_fastmap[' '] = 0; - word_fastmap['\t'] = 0; - word_fastmap['\n'] = 0; - } + memset (word_fastmap, 1, CHAR_SET_SIZE); + word_fastmap[' '] = 0; + word_fastmap['\t'] = 0; + word_fastmap['\n'] = 0; + } } } @@ -541,23 +541,23 @@ swallow_file_in_memory (const char *file_name, BLOCK *block) block->start = xmalloc ((size_t) stat_block.st_size); if ((in_memory_size = read (file_handle, - block->start, (size_t) stat_block.st_size)) - != stat_block.st_size) - { + block->start, (size_t) stat_block.st_size)) + != stat_block.st_size) + { #if MSDOS - /* On MSDOS, in memory size may be smaller than the file - size, because of end of line conversions. But it can - never be smaller than half the file size, because the - minimum is when all lines are empty and terminated by - CR+LF. */ - if (in_memory_size != (size_t)-1 - && in_memory_size >= stat_block.st_size / 2) - block->start = xrealloc (block->start, in_memory_size); - else + /* On MSDOS, in memory size may be smaller than the file + size, because of end of line conversions. But it can + never be smaller than half the file size, because the + minimum is when all lines are empty and terminated by + CR+LF. */ + if (in_memory_size != (size_t)-1 + && in_memory_size >= stat_block.st_size / 2) + block->start = xrealloc (block->start, in_memory_size); + else #endif /* not MSDOS */ - error (EXIT_FAILURE, errno, "%s", file_name); - } + error (EXIT_FAILURE, errno, "%s", file_name); + } block->end = block->start + in_memory_size; } else @@ -567,21 +567,21 @@ swallow_file_in_memory (const char *file_name, BLOCK *block) allocated_length = (1 << SWALLOW_REALLOC_LOG); while (read_length = read (file_handle, - block->start + used_length, - allocated_length - used_length), - read_length > 0) - { - used_length += read_length; - if (used_length == allocated_length) - { - allocated_length += (1 << SWALLOW_REALLOC_LOG); - block->start - = xrealloc (block->start, allocated_length); - } - } + block->start + used_length, + allocated_length - used_length), + read_length > 0) + { + used_length += read_length; + if (used_length == allocated_length) + { + allocated_length += (1 << SWALLOW_REALLOC_LOG); + block->start + = xrealloc (block->start, allocated_length); + } + } if (read_length < 0) - error (EXIT_FAILURE, errno, "%s", file_name); + error (EXIT_FAILURE, errno, "%s", file_name); block->end = block->start + used_length; } @@ -616,22 +616,22 @@ compare_words (const void *void_first, const void *void_second) if (ignore_case) { for (counter = 0; counter < length; counter++) - { - value = (folded_chars [to_uchar (first->start[counter])] - - folded_chars [to_uchar (second->start[counter])]); - if (value != 0) - return value; - } + { + value = (folded_chars [to_uchar (first->start[counter])] + - folded_chars [to_uchar (second->start[counter])]); + if (value != 0) + return value; + } } else { for (counter = 0; counter < length; counter++) - { - value = (to_uchar (first->start[counter]) - - to_uchar (second->start[counter])); - if (value != 0) - return value; - } + { + value = (to_uchar (first->start[counter]) + - to_uchar (second->start[counter])); + if (value != 0) + return value; + } } return first->size - second->size; @@ -677,11 +677,11 @@ search_table (WORD *word, WORD_TABLE *table) middle = (lowest + highest) / 2; value = compare_words (word, table->start + middle); if (value < 0) - highest = middle - 1; + highest = middle - 1; else if (value > 0) - lowest = middle + 1; + lowest = middle + 1; else - return 1; + return 1; } return 0; } @@ -699,7 +699,7 @@ sort_found_occurs (void) /* Only one language for the time being. */ qsort (occurs_table[0], number_of_occurs[0], sizeof **occurs_table, - compare_occurs); + compare_occurs); } /* Parameter files reading routines. */ @@ -728,10 +728,10 @@ digest_break_file (const char *file_name) { /* If GNU extensions are enabled, the only way to avoid newline as - a break character is to write all the break characters in the - file with no newline at all, not even at the end of the file. - If disabled, spaces, tabs and newlines are always considered as - break characters even if not included in the break file. */ + a break character is to write all the break characters in the + file with no newline at all, not even at the end of the file. + If disabled, spaces, tabs and newlines are always considered as + break characters even if not included in the break file. */ word_fastmap[' '] = 0; word_fastmap['\t'] = 0; @@ -773,30 +773,30 @@ digest_word_file (const char *file_name, WORD_TABLE *table) word_start = cursor; while (cursor < file_contents.end && *cursor != '\n') - cursor++; + cursor++; /* Record the word in table if it is not empty. */ if (cursor > word_start) - { - if (table->length == table->alloc) - { - if ((SIZE_MAX / sizeof *table->start - 1) / 2 < table->alloc) - xalloc_die (); - table->alloc = table->alloc * 2 + 1; - table->start = xrealloc (table->start, - table->alloc * sizeof *table->start); - } + { + if (table->length == table->alloc) + { + if ((SIZE_MAX / sizeof *table->start - 1) / 2 < table->alloc) + xalloc_die (); + table->alloc = table->alloc * 2 + 1; + table->start = xrealloc (table->start, + table->alloc * sizeof *table->start); + } - table->start[table->length].start = word_start; - table->start[table->length].size = cursor - word_start; - table->length++; - } + table->start[table->length].start = word_start; + table->start[table->length].size = cursor - word_start; + table->length++; + } /* This test allows for an incomplete line at end of file. */ if (cursor < file_contents.end) - cursor++; + cursor++; } /* Finally, sort all the words read. */ @@ -859,223 +859,223 @@ find_occurs_in_text (void) { /* `context_start' gets initialized before the processing of each - line, or once for the whole buffer if no end of line or sentence - sequence separator. */ + line, or once for the whole buffer if no end of line or sentence + sequence separator. */ context_start = cursor; /* If a end of line or end of sentence sequence is defined and - non-empty, `next_context_start' will be recomputed to be the end of - each line or sentence, before each one is processed. If no such - sequence, then `next_context_start' is set at the end of the whole - buffer, which is then considered to be a single line or sentence. - This test also accounts for the case of an incomplete line or - sentence at the end of the buffer. */ + non-empty, `next_context_start' will be recomputed to be the end of + each line or sentence, before each one is processed. If no such + sequence, then `next_context_start' is set at the end of the whole + buffer, which is then considered to be a single line or sentence. + This test also accounts for the case of an incomplete line or + sentence at the end of the buffer. */ next_context_start = text_buffer.end; if (context_regex.string) - switch (re_search (&context_regex.pattern, cursor, - text_buffer.end - cursor, - 0, text_buffer.end - cursor, &context_regs)) - { - case -2: - matcher_error (); + switch (re_search (&context_regex.pattern, cursor, + text_buffer.end - cursor, + 0, text_buffer.end - cursor, &context_regs)) + { + case -2: + matcher_error (); - case -1: - break; + case -1: + break; - default: - next_context_start = cursor + context_regs.end[0]; - break; - } + default: + next_context_start = cursor + context_regs.end[0]; + break; + } /* Include the separator into the right context, but not any suffix - white space in this separator; this insures it will be seen in - output and will not take more space than necessary. */ + white space in this separator; this insures it will be seen in + output and will not take more space than necessary. */ context_end = next_context_start; SKIP_WHITE_BACKWARDS (context_end, context_start); /* Read and process a single input line or sentence, one word at a - time. */ + time. */ while (1) - { - if (word_regex.string) + { + if (word_regex.string) - /* If a word regexp has been compiled, use it to skip at the - beginning of the next word. If there is no such word, exit - the loop. */ + /* If a word regexp has been compiled, use it to skip at the + beginning of the next word. If there is no such word, exit + the loop. */ - { - regoff_t r = re_search (&word_regex.pattern, cursor, - context_end - cursor, - 0, context_end - cursor, &word_regs); - if (r == -2) - matcher_error (); - if (r == -1) - break; - word_start = cursor + word_regs.start[0]; - word_end = cursor + word_regs.end[0]; - } - else + { + regoff_t r = re_search (&word_regex.pattern, cursor, + context_end - cursor, + 0, context_end - cursor, &word_regs); + if (r == -2) + matcher_error (); + if (r == -1) + break; + word_start = cursor + word_regs.start[0]; + word_end = cursor + word_regs.end[0]; + } + else - /* Avoid re_search and use the fastmap to skip to the - beginning of the next word. If there is no more word in - the buffer, exit the loop. */ + /* Avoid re_search and use the fastmap to skip to the + beginning of the next word. If there is no more word in + the buffer, exit the loop. */ - { - scan = cursor; - while (scan < context_end - && !word_fastmap[to_uchar (*scan)]) - scan++; + { + scan = cursor; + while (scan < context_end + && !word_fastmap[to_uchar (*scan)]) + scan++; - if (scan == context_end) - break; + if (scan == context_end) + break; - word_start = scan; + word_start = scan; - while (scan < context_end - && word_fastmap[to_uchar (*scan)]) - scan++; + while (scan < context_end + && word_fastmap[to_uchar (*scan)]) + scan++; - word_end = scan; - } + word_end = scan; + } - /* Skip right to the beginning of the found word. */ + /* Skip right to the beginning of the found word. */ - cursor = word_start; + cursor = word_start; - /* Skip any zero length word. Just advance a single position, - then go fetch the next word. */ + /* Skip any zero length word. Just advance a single position, + then go fetch the next word. */ - if (word_end == word_start) - { - cursor++; - continue; - } + if (word_end == word_start) + { + cursor++; + continue; + } - /* This is a genuine, non empty word, so save it as a possible - key. Then skip over it. Also, maintain the maximum length of - all words read so far. It is mandatory to take the maximum - length of all words in the file, without considering if they - are actually kept or rejected, because backward jumps at output - generation time may fall in *any* word. */ + /* This is a genuine, non empty word, so save it as a possible + key. Then skip over it. Also, maintain the maximum length of + all words read so far. It is mandatory to take the maximum + length of all words in the file, without considering if they + are actually kept or rejected, because backward jumps at output + generation time may fall in *any* word. */ - possible_key.start = cursor; - possible_key.size = word_end - word_start; - cursor += possible_key.size; + possible_key.start = cursor; + possible_key.size = word_end - word_start; + cursor += possible_key.size; - if (possible_key.size > maximum_word_length) - maximum_word_length = possible_key.size; + if (possible_key.size > maximum_word_length) + maximum_word_length = possible_key.size; - /* In input reference mode, update `line_start' from its previous - value. Count the lines just in case auto reference mode is - also selected. If it happens that the word just matched is - indeed part of a reference; just ignore it. */ + /* In input reference mode, update `line_start' from its previous + value. Count the lines just in case auto reference mode is + also selected. If it happens that the word just matched is + indeed part of a reference; just ignore it. */ - if (input_reference) - { - while (line_scan < possible_key.start) - if (*line_scan == '\n') - { - total_line_count++; - line_scan++; - line_start = line_scan; - SKIP_NON_WHITE (line_scan, text_buffer.end); - reference_length = line_scan - line_start; - } - else - line_scan++; - if (line_scan > possible_key.start) - continue; - } + if (input_reference) + { + while (line_scan < possible_key.start) + if (*line_scan == '\n') + { + total_line_count++; + line_scan++; + line_start = line_scan; + SKIP_NON_WHITE (line_scan, text_buffer.end); + reference_length = line_scan - line_start; + } + else + line_scan++; + if (line_scan > possible_key.start) + continue; + } - /* Ignore the word if an `Ignore words' table exists and if it is - part of it. Also ignore the word if an `Only words' table and - if it is *not* part of it. + /* Ignore the word if an `Ignore words' table exists and if it is + part of it. Also ignore the word if an `Only words' table and + if it is *not* part of it. - It is allowed that both tables be used at once, even if this - may look strange for now. Just ignore a word that would appear - in both. If regexps are eventually implemented for these - tables, the Ignore table could then reject words that would - have been previously accepted by the Only table. */ + It is allowed that both tables be used at once, even if this + may look strange for now. Just ignore a word that would appear + in both. If regexps are eventually implemented for these + tables, the Ignore table could then reject words that would + have been previously accepted by the Only table. */ - if (ignore_file && search_table (&possible_key, &ignore_table)) - continue; - if (only_file && !search_table (&possible_key, &only_table)) - continue; + if (ignore_file && search_table (&possible_key, &ignore_table)) + continue; + if (only_file && !search_table (&possible_key, &only_table)) + continue; - /* A non-empty word has been found. First of all, insure - proper allocation of the next OCCURS, and make a pointer to - where it will be constructed. */ + /* A non-empty word has been found. First of all, insure + proper allocation of the next OCCURS, and make a pointer to + where it will be constructed. */ - if (number_of_occurs[0] == occurs_alloc[0]) - { - if ((SIZE_MAX / sizeof *occurs_table[0] - 1) / 2 - < occurs_alloc[0]) - xalloc_die (); - occurs_alloc[0] = occurs_alloc[0] * 2 + 1; - occurs_table[0] = xrealloc (occurs_table[0], - occurs_alloc[0] * sizeof *occurs_table[0]); - } + if (number_of_occurs[0] == occurs_alloc[0]) + { + if ((SIZE_MAX / sizeof *occurs_table[0] - 1) / 2 + < occurs_alloc[0]) + xalloc_die (); + occurs_alloc[0] = occurs_alloc[0] * 2 + 1; + occurs_table[0] = xrealloc (occurs_table[0], + occurs_alloc[0] * sizeof *occurs_table[0]); + } - occurs_cursor = occurs_table[0] + number_of_occurs[0]; + occurs_cursor = occurs_table[0] + number_of_occurs[0]; - /* Define the refence field, if any. */ + /* Define the refence field, if any. */ - if (auto_reference) - { + if (auto_reference) + { - /* While auto referencing, update `line_start' from its - previous value, counting lines as we go. If input - referencing at the same time, `line_start' has been - advanced earlier, and the following loop is never really - executed. */ + /* While auto referencing, update `line_start' from its + previous value, counting lines as we go. If input + referencing at the same time, `line_start' has been + advanced earlier, and the following loop is never really + executed. */ - while (line_scan < possible_key.start) - if (*line_scan == '\n') - { - total_line_count++; - line_scan++; - line_start = line_scan; - SKIP_NON_WHITE (line_scan, text_buffer.end); - } - else - line_scan++; + while (line_scan < possible_key.start) + if (*line_scan == '\n') + { + total_line_count++; + line_scan++; + line_start = line_scan; + SKIP_NON_WHITE (line_scan, text_buffer.end); + } + else + line_scan++; - occurs_cursor->reference = total_line_count; - } - else if (input_reference) - { + occurs_cursor->reference = total_line_count; + } + else if (input_reference) + { - /* If only input referencing, `line_start' has been computed - earlier to detect the case the word matched would be part - of the reference. The reference position is simply the - value of `line_start'. */ + /* If only input referencing, `line_start' has been computed + earlier to detect the case the word matched would be part + of the reference. The reference position is simply the + value of `line_start'. */ - occurs_cursor->reference - = (DELTA) (line_start - possible_key.start); - if (reference_length > reference_max_width) - reference_max_width = reference_length; - } + occurs_cursor->reference + = (DELTA) (line_start - possible_key.start); + if (reference_length > reference_max_width) + reference_max_width = reference_length; + } - /* Exclude the reference from the context in simple cases. */ + /* Exclude the reference from the context in simple cases. */ - if (input_reference && line_start == context_start) - { - SKIP_NON_WHITE (context_start, context_end); - SKIP_WHITE (context_start, context_end); - } + if (input_reference && line_start == context_start) + { + SKIP_NON_WHITE (context_start, context_end); + SKIP_WHITE (context_start, context_end); + } - /* Completes the OCCURS structure. */ + /* Completes the OCCURS structure. */ - occurs_cursor->key = possible_key; - occurs_cursor->left = context_start - possible_key.start; - occurs_cursor->right = context_end - possible_key.start; + occurs_cursor->key = possible_key; + occurs_cursor->left = context_start - possible_key.start; + occurs_cursor->right = context_end - possible_key.start; - number_of_occurs[0]++; - } + number_of_occurs[0]++; + } } } @@ -1112,144 +1112,144 @@ print_field (BLOCK field) { unsigned char character = *cursor; if (edited_flag[character]) - { + { - /* First check if this is a diacriticized character. + /* First check if this is a diacriticized character. - This works only for TeX. I do not know how diacriticized - letters work with `roff'. Please someone explain it to me! */ + This works only for TeX. I do not know how diacriticized + letters work with `roff'. Please someone explain it to me! */ - diacritic = todiac (character); - if (diacritic != 0 && output_format == TEX_FORMAT) - { - base = tobase (character); - switch (diacritic) - { + diacritic = todiac (character); + if (diacritic != 0 && output_format == TEX_FORMAT) + { + base = tobase (character); + switch (diacritic) + { - case 1: /* Latin diphthongs */ - switch (base) - { - case 'o': - fputs ("\\oe{}", stdout); - break; + case 1: /* Latin diphthongs */ + switch (base) + { + case 'o': + fputs ("\\oe{}", stdout); + break; - case 'O': - fputs ("\\OE{}", stdout); - break; + case 'O': + fputs ("\\OE{}", stdout); + break; - case 'a': - fputs ("\\ae{}", stdout); - break; + case 'a': + fputs ("\\ae{}", stdout); + break; - case 'A': - fputs ("\\AE{}", stdout); - break; + case 'A': + fputs ("\\AE{}", stdout); + break; - default: - putchar (' '); - } - break; + default: + putchar (' '); + } + break; - case 2: /* Acute accent */ - printf ("\\'%s%c", (base == 'i' ? "\\" : ""), base); - break; + case 2: /* Acute accent */ + printf ("\\'%s%c", (base == 'i' ? "\\" : ""), base); + break; - case 3: /* Grave accent */ - printf ("\\`%s%c", (base == 'i' ? "\\" : ""), base); - break; + case 3: /* Grave accent */ + printf ("\\`%s%c", (base == 'i' ? "\\" : ""), base); + break; - case 4: /* Circumflex accent */ - printf ("\\^%s%c", (base == 'i' ? "\\" : ""), base); - break; + case 4: /* Circumflex accent */ + printf ("\\^%s%c", (base == 'i' ? "\\" : ""), base); + break; - case 5: /* Diaeresis */ - printf ("\\\"%s%c", (base == 'i' ? "\\" : ""), base); - break; + case 5: /* Diaeresis */ + printf ("\\\"%s%c", (base == 'i' ? "\\" : ""), base); + break; - case 6: /* Tilde accent */ - printf ("\\~%s%c", (base == 'i' ? "\\" : ""), base); - break; + case 6: /* Tilde accent */ + printf ("\\~%s%c", (base == 'i' ? "\\" : ""), base); + break; - case 7: /* Cedilla */ - printf ("\\c{%c}", base); - break; + case 7: /* Cedilla */ + printf ("\\c{%c}", base); + break; - case 8: /* Small circle beneath */ - switch (base) - { - case 'a': - fputs ("\\aa{}", stdout); - break; + case 8: /* Small circle beneath */ + switch (base) + { + case 'a': + fputs ("\\aa{}", stdout); + break; - case 'A': - fputs ("\\AA{}", stdout); - break; + case 'A': + fputs ("\\AA{}", stdout); + break; - default: - putchar (' '); - } - break; + default: + putchar (' '); + } + break; - case 9: /* Strike through */ - switch (base) - { - case 'o': - fputs ("\\o{}", stdout); - break; + case 9: /* Strike through */ + switch (base) + { + case 'o': + fputs ("\\o{}", stdout); + break; - case 'O': - fputs ("\\O{}", stdout); - break; + case 'O': + fputs ("\\O{}", stdout); + break; - default: - putchar (' '); - } - break; - } - } - else + default: + putchar (' '); + } + break; + } + } + else - /* This is not a diacritic character, so handle cases which are - really specific to `roff' or TeX. All white space processing - is done as the default case of this switch. */ + /* This is not a diacritic character, so handle cases which are + really specific to `roff' or TeX. All white space processing + is done as the default case of this switch. */ - switch (character) - { - case '"': - /* In roff output format, double any quote. */ - putchar ('"'); - putchar ('"'); - break; + switch (character) + { + case '"': + /* In roff output format, double any quote. */ + putchar ('"'); + putchar ('"'); + break; - case '$': - case '%': - case '&': - case '#': - case '_': - /* In TeX output format, precede these with a backslash. */ - putchar ('\\'); - putchar (character); - break; + case '$': + case '%': + case '&': + case '#': + case '_': + /* In TeX output format, precede these with a backslash. */ + putchar ('\\'); + putchar (character); + break; - case '{': - case '}': - /* In TeX output format, precede these with a backslash and - force mathematical mode. */ - printf ("$\\%c$", character); - break; + case '{': + case '}': + /* In TeX output format, precede these with a backslash and + force mathematical mode. */ + printf ("$\\%c$", character); + break; - case '\\': - /* In TeX output mode, request production of a backslash. */ - fputs ("\\backslash{}", stdout); - break; + case '\\': + /* In TeX output mode, request production of a backslash. */ + fputs ("\\backslash{}", stdout); + break; - default: - /* Any other flagged character produces a single space. */ - putchar (' '); - } - } + default: + /* Any other flagged character produces a single space. */ + putchar (' '); + } + } else - putchar (*cursor); + putchar (*cursor); } } @@ -1278,17 +1278,17 @@ fix_output_parameters (void) { reference_max_width = 0; for (file_index = 0; file_index < number_input_files; file_index++) - { - line_ordinal = file_line_count[file_index] + 1; - if (file_index > 0) - line_ordinal -= file_line_count[file_index - 1]; - sprintf (ordinal_string, "%d", line_ordinal); - reference_width = strlen (ordinal_string); - if (input_file_name[file_index]) - reference_width += strlen (input_file_name[file_index]); - if (reference_width > reference_max_width) - reference_max_width = reference_width; - } + { + line_ordinal = file_line_count[file_index] + 1; + if (file_index > 0) + line_ordinal -= file_line_count[file_index - 1]; + sprintf (ordinal_string, "%d", line_ordinal); + reference_width = strlen (ordinal_string); + if (input_file_name[file_index]) + reference_width += strlen (input_file_name[file_index]); + if (reference_width > reference_max_width) + reference_max_width = reference_width; + } reference_max_width++; reference.start = xmalloc ((size_t) reference_max_width + 1); } @@ -1328,40 +1328,40 @@ fix_output_parameters (void) { /* When flagging truncation at the left of the keyword, the - truncation mark goes at the beginning of the before field, - unless there is a head field, in which case the mark goes at the - left of the head field. When flagging truncation at the right - of the keyword, the mark goes at the end of the keyafter field, - unless there is a tail field, in which case the mark goes at the - end of the tail field. Only eight combination cases could arise - for truncation marks: + truncation mark goes at the beginning of the before field, + unless there is a head field, in which case the mark goes at the + left of the head field. When flagging truncation at the right + of the keyword, the mark goes at the end of the keyafter field, + unless there is a tail field, in which case the mark goes at the + end of the tail field. Only eight combination cases could arise + for truncation marks: - . None. - . One beginning the before field. - . One beginning the head field. - . One ending the keyafter field. - . One ending the tail field. - . One beginning the before field, another ending the keyafter field. - . One ending the tail field, another beginning the before field. - . One ending the keyafter field, another beginning the head field. + . None. + . One beginning the before field. + . One beginning the head field. + . One ending the keyafter field. + . One ending the tail field. + . One beginning the before field, another ending the keyafter field. + . One ending the tail field, another beginning the before field. + . One ending the keyafter field, another beginning the head field. - So, there is at most two truncation marks, which could appear both - on the left side of the center of the output line, both on the - right side, or one on either side. */ + So, there is at most two truncation marks, which could appear both + on the left side of the center of the output line, both on the + right side, or one on either side. */ before_max_width -= 2 * truncation_string_length; if (before_max_width < 0) - before_max_width = 0; + before_max_width = 0; keyafter_max_width -= 2 * truncation_string_length; } else { /* I never figured out exactly how UNIX' ptx plans the output width - of its various fields. If GNU extensions are disabled, do not - try computing the field widths correctly; instead, use the - following formula, which does not completely imitate UNIX' ptx, - but almost. */ + of its various fields. If GNU extensions are disabled, do not + try computing the field widths correctly; instead, use the + following formula, which does not completely imitate UNIX' ptx, + but almost. */ keyafter_max_width -= 2 * truncation_string_length + 1; } @@ -1397,13 +1397,13 @@ fix_output_parameters (void) /* Various characters need special processing. */ for (cursor = "$%&#_{}\\"; *cursor; cursor++) - edited_flag[to_uchar (*cursor)] = 1; + edited_flag[to_uchar (*cursor)] = 1; /* Any character with 8th bit set will print to a single space, unless - it is diacriticized. */ + it is diacriticized. */ for (character = 0200; character < CHAR_SET_SIZE; character++) - edited_flag[character] = todiac (character) != 0; + edited_flag[character] = todiac (character) != 0; break; } } @@ -1439,7 +1439,7 @@ define_all_fields (OCCURS *occurs) cursor = keyafter.end; while (cursor < right_context_end - && cursor <= keyafter.start + keyafter_max_width) + && cursor <= keyafter.start + keyafter_max_width) { keyafter.end = cursor; SKIP_SOMETHING (cursor, right_context_end); @@ -1466,7 +1466,7 @@ define_all_fields (OCCURS *occurs) if (-occurs->left > half_line_width + maximum_word_length) { left_field_start - = keyafter.start - (half_line_width + maximum_word_length); + = keyafter.start - (half_line_width + maximum_word_length); SKIP_SOMETHING (left_field_start, keyafter.start); } else @@ -1514,22 +1514,22 @@ define_all_fields (OCCURS *occurs) tail.end = tail.start; cursor = tail.end; while (cursor < right_context_end - && cursor < tail.start + tail_max_width) - { - tail.end = cursor; - SKIP_SOMETHING (cursor, right_context_end); - } + && cursor < tail.start + tail_max_width) + { + tail.end = cursor; + SKIP_SOMETHING (cursor, right_context_end); + } if (cursor < tail.start + tail_max_width) - tail.end = cursor; + tail.end = cursor; if (tail.end > tail.start) - { - keyafter_truncation = 0; - tail_truncation = truncation_string && tail.end < right_context_end; - } + { + keyafter_truncation = 0; + tail_truncation = truncation_string && tail.end < right_context_end; + } else - tail_truncation = 0; + tail_truncation = 0; SKIP_WHITE_BACKWARDS (tail.end, tail.start); } @@ -1559,16 +1559,16 @@ define_all_fields (OCCURS *occurs) head.start = left_field_start; while (head.start + head_max_width < head.end) - SKIP_SOMETHING (head.start, head.end); + SKIP_SOMETHING (head.start, head.end); if (head.end > head.start) - { - before_truncation = 0; - head_truncation = (truncation_string - && head.start > left_context_start); - } + { + before_truncation = 0; + head_truncation = (truncation_string + && head.start > left_context_start); + } else - head_truncation = 0; + head_truncation = 0; SKIP_WHITE (head.start, head.end); } @@ -1586,21 +1586,21 @@ define_all_fields (OCCURS *occurs) { /* Construct the reference text in preallocated space from the file - name and the line number. Find out in which file the reference - occurred. Standard input yields an empty file name. Insure line - numbers are one based, even if they are computed zero based. */ + name and the line number. Find out in which file the reference + occurred. Standard input yields an empty file name. Insure line + numbers are one based, even if they are computed zero based. */ file_index = 0; while (file_line_count[file_index] < occurs->reference) - file_index++; + file_index++; file_name = input_file_name[file_index]; if (!file_name) - file_name = ""; + file_name = ""; line_ordinal = occurs->reference + 1; if (file_index > 0) - line_ordinal -= file_line_count[file_index - 1]; + line_ordinal -= file_line_count[file_index - 1]; sprintf (reference.start, "%s:%d", file_name, line_ordinal); reference.end = reference.start + strlen (reference.start); @@ -1609,7 +1609,7 @@ define_all_fields (OCCURS *occurs) { /* Reference starts at saved position for reference and extends right - until some white space is met. */ + until some white space is met. */ reference.start = keyafter.start + (DELTA) occurs->reference; reference.end = reference.start; @@ -1718,29 +1718,29 @@ output_one_dumb_line (void) if (!right_reference) { if (auto_reference) - { + { - /* Output the `reference' field, in such a way that GNU emacs - next-error will handle it. The ending colon is taken from the - gap which follows. */ + /* Output the `reference' field, in such a way that GNU emacs + next-error will handle it. The ending colon is taken from the + gap which follows. */ - print_field (reference); - putchar (':'); - print_spaces (reference_max_width - + gap_size - - (reference.end - reference.start) - - 1); - } + print_field (reference); + putchar (':'); + print_spaces (reference_max_width + + gap_size + - (reference.end - reference.start) + - 1); + } else - { + { - /* Output the `reference' field and its following gap. */ + /* Output the `reference' field and its following gap. */ - print_field (reference); - print_spaces (reference_max_width - + gap_size - - (reference.end - reference.start)); - } + print_field (reference); + print_spaces (reference_max_width + + gap_size + - (reference.end - reference.start)); + } } if (tail.start < tail.end) @@ -1749,18 +1749,18 @@ output_one_dumb_line (void) print_field (tail); if (tail_truncation) - fputs (truncation_string, stdout); + fputs (truncation_string, stdout); print_spaces (half_line_width - gap_size - - (before.end - before.start) - - (before_truncation ? truncation_string_length : 0) - - (tail.end - tail.start) - - (tail_truncation ? truncation_string_length : 0)); + - (before.end - before.start) + - (before_truncation ? truncation_string_length : 0) + - (tail.end - tail.start) + - (tail_truncation ? truncation_string_length : 0)); } else print_spaces (half_line_width - gap_size - - (before.end - before.start) - - (before_truncation ? truncation_string_length : 0)); + - (before.end - before.start) + - (before_truncation ? truncation_string_length : 0)); /* Output the `before' field. */ @@ -1781,20 +1781,20 @@ output_one_dumb_line (void) /* Output the `head' field. */ print_spaces (half_line_width - - (keyafter.end - keyafter.start) - - (keyafter_truncation ? truncation_string_length : 0) - - (head.end - head.start) - - (head_truncation ? truncation_string_length : 0)); + - (keyafter.end - keyafter.start) + - (keyafter_truncation ? truncation_string_length : 0) + - (head.end - head.start) + - (head_truncation ? truncation_string_length : 0)); if (head_truncation) - fputs (truncation_string, stdout); + fputs (truncation_string, stdout); print_field (head); } else if ((auto_reference | input_reference) & right_reference) print_spaces (half_line_width - - (keyafter.end - keyafter.start) - - (keyafter_truncation ? truncation_string_length : 0)); + - (keyafter.end - keyafter.start) + - (keyafter_truncation ? truncation_string_length : 0)); if ((auto_reference | input_reference) & right_reference) { @@ -1837,29 +1837,29 @@ generate_all_output (void) for (occurs_index = 0; occurs_index < number_of_occurs[0]; occurs_index++) { /* Compute the exact size of every field and whenever truncation flags - are present or not. */ + are present or not. */ define_all_fields (occurs_cursor); /* Produce one output line according to selected format. */ switch (output_format) - { - case UNKNOWN_FORMAT: - /* Should never happen. */ + { + case UNKNOWN_FORMAT: + /* Should never happen. */ - case DUMB_FORMAT: - output_one_dumb_line (); - break; + case DUMB_FORMAT: + output_one_dumb_line (); + break; - case ROFF_FORMAT: - output_one_roff_line (); - break; + case ROFF_FORMAT: + output_one_roff_line (); + break; - case TEX_FORMAT: - output_one_tex_line (); - break; - } + case TEX_FORMAT: + output_one_tex_line (); + break; + } /* Advance the cursor into the occurs table. */ @@ -1878,13 +1878,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [INPUT]... (without -G)\n\ or: %s -G [OPTION]... [INPUT [OUTPUT]]\n"), - program_name, program_name); + program_name, program_name); fputs (_("\ Output a permuted index, including context, of the words in the input files.\n\ \n\ @@ -1988,105 +1988,105 @@ main (int argc, char **argv) #endif while (optchar = getopt_long (argc, argv, "AF:GM:ORS:TW:b:i:fg:o:trw:", - long_options, NULL), - optchar != EOF) + long_options, NULL), + optchar != EOF) { switch (optchar) - { - default: - usage (EXIT_FAILURE); + { + default: + usage (EXIT_FAILURE); - case 'G': - gnu_extensions = false; - break; + case 'G': + gnu_extensions = false; + break; - case 'b': - break_file = optarg; - break; + case 'b': + break_file = optarg; + break; - case 'f': - ignore_case = true; - break; + case 'f': + ignore_case = true; + break; - case 'g': - { - unsigned long int tmp_ulong; - if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK - || ! (0 < tmp_ulong && tmp_ulong <= INT_MAX)) - error (EXIT_FAILURE, 0, _("invalid gap width: %s"), - quotearg (optarg)); - gap_size = tmp_ulong; - break; - } + case 'g': + { + unsigned long int tmp_ulong; + if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK + || ! (0 < tmp_ulong && tmp_ulong <= INT_MAX)) + error (EXIT_FAILURE, 0, _("invalid gap width: %s"), + quotearg (optarg)); + gap_size = tmp_ulong; + break; + } - case 'i': - ignore_file = optarg; - break; + case 'i': + ignore_file = optarg; + break; - case 'o': - only_file = optarg; - break; + case 'o': + only_file = optarg; + break; - case 'r': - input_reference = true; - break; + case 'r': + input_reference = true; + break; - case 't': - /* Yet to understand... */ - break; + case 't': + /* Yet to understand... */ + break; - case 'w': - { - unsigned long int tmp_ulong; - if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK - || ! (0 < tmp_ulong && tmp_ulong <= INT_MAX)) - error (EXIT_FAILURE, 0, _("invalid line width: %s"), - quotearg (optarg)); - line_width = tmp_ulong; - break; - } + case 'w': + { + unsigned long int tmp_ulong; + if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) != LONGINT_OK + || ! (0 < tmp_ulong && tmp_ulong <= INT_MAX)) + error (EXIT_FAILURE, 0, _("invalid line width: %s"), + quotearg (optarg)); + line_width = tmp_ulong; + break; + } - case 'A': - auto_reference = true; - break; + case 'A': + auto_reference = true; + break; - case 'F': - truncation_string = copy_unescaped_string (optarg); - break; + case 'F': + truncation_string = copy_unescaped_string (optarg); + break; - case 'M': - macro_name = optarg; - break; + case 'M': + macro_name = optarg; + break; - case 'O': - output_format = ROFF_FORMAT; - break; + case 'O': + output_format = ROFF_FORMAT; + break; - case 'R': - right_reference = true; - break; + case 'R': + right_reference = true; + break; - case 'S': - context_regex.string = copy_unescaped_string (optarg); - break; + case 'S': + context_regex.string = copy_unescaped_string (optarg); + break; - case 'T': - output_format = TEX_FORMAT; - break; + case 'T': + output_format = TEX_FORMAT; + break; - case 'W': - word_regex.string = copy_unescaped_string (optarg); - if (!*word_regex.string) - word_regex.string = NULL; - break; + case 'W': + word_regex.string = copy_unescaped_string (optarg); + if (!*word_regex.string) + word_regex.string = NULL; + break; - case 10: - output_format = XARGMATCH ("--format", optarg, - format_args, format_vals); - case_GETOPT_HELP_CHAR; + case 10: + output_format = XARGMATCH ("--format", optarg, + format_args, format_vals); + case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - } + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + } } /* Process remaining arguments. If GNU extensions are enabled, process @@ -2110,13 +2110,13 @@ main (int argc, char **argv) file_line_count = xmalloc (number_input_files * sizeof *file_line_count); for (file_index = 0; file_index < number_input_files; file_index++) - { - if (!*argv[optind] || STREQ (argv[optind], "-")) - input_file_name[file_index] = NULL; - else - input_file_name[file_index] = argv[optind]; - optind++; - } + { + if (!*argv[optind] || STREQ (argv[optind], "-")) + input_file_name[file_index] = NULL; + else + input_file_name[file_index] = argv[optind]; + optind++; + } } else { @@ -2127,27 +2127,27 @@ main (int argc, char **argv) input_file_name = xmalloc (sizeof *input_file_name); file_line_count = xmalloc (sizeof *file_line_count); if (!*argv[optind] || STREQ (argv[optind], "-")) - input_file_name[0] = NULL; + input_file_name[0] = NULL; else - input_file_name[0] = argv[optind]; + input_file_name[0] = argv[optind]; optind++; /* Redirect standard output, only if requested. */ if (optind < argc) - { - if (! freopen (argv[optind], "w", stdout)) - error (EXIT_FAILURE, errno, "%s", argv[optind]); - optind++; - } + { + if (! freopen (argv[optind], "w", stdout)) + error (EXIT_FAILURE, errno, "%s", argv[optind]); + optind++; + } /* Diagnose any other argument as an error. */ if (optind < argc) - { - error (0, 0, _("extra operand %s"), quote (argv[optind])); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("extra operand %s"), quote (argv[optind])); + usage (EXIT_FAILURE); + } } /* If the output format has not been explicitly selected, choose dumb @@ -2173,14 +2173,14 @@ main (int argc, char **argv) { digest_word_file (ignore_file, &ignore_table); if (ignore_table.length == 0) - ignore_file = NULL; + ignore_file = NULL; } if (only_file) { digest_word_file (only_file, &only_table); if (only_table.length == 0) - only_file = NULL; + only_file = NULL; } /* Prepare to study all the input files. */ @@ -2199,8 +2199,8 @@ main (int argc, char **argv) find_occurs_in_text (); /* Maintain for each file how many lines has been read so far when its - end is reached. Incrementing the count first is a simple kludge to - handle a possible incomplete line at end of file. */ + end is reached. Incrementing the count first is a simple kludge to + handle a possible incomplete line at end of file. */ total_line_count++; file_line_count[file_index] = total_line_count; diff --git a/src/bin/coreutils/src/pwd.c b/src/bin/coreutils/src/pwd.c index 47c0c42836..b74ba47071 100644 --- a/src/bin/coreutils/src/pwd.c +++ b/src/bin/coreutils/src/pwd.c @@ -51,7 +51,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]...\n"), program_name); @@ -102,9 +102,9 @@ file_name_prepend (struct file_name *p, char const *s, size_t s_len) { size_t half = p->n_alloc + 1 + s_len; /* Use xnmalloc+free rather than xnrealloc, since with the latter - we'd end up copying the data twice: once via realloc, then again - to align it with the end of the new buffer. With xnmalloc, we - copy it only once. */ + we'd end up copying the data twice: once via realloc, then again + to align it with the end of the new buffer. With xnmalloc, we + copy it only once. */ char *q = xnmalloc (2, half); size_t n_used = p->n_alloc - n_free; p->start = q + 2 * half - n_used; @@ -149,7 +149,7 @@ nth_parent (size_t n) static void find_dir_entry (struct stat *dot_sb, struct file_name *file_name, - size_t parent_height) + size_t parent_height) { DIR *dirp; int fd; @@ -160,16 +160,16 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name, dirp = opendir (".."); if (dirp == NULL) error (EXIT_FAILURE, errno, _("cannot open directory %s"), - quote (nth_parent (parent_height))); + quote (nth_parent (parent_height))); fd = dirfd (dirp); if ((0 <= fd ? fchdir (fd) : chdir ("..")) < 0) error (EXIT_FAILURE, errno, _("failed to chdir to %s"), - quote (nth_parent (parent_height))); + quote (nth_parent (parent_height))); if ((0 <= fd ? fstat (fd, &parent_sb) : stat (".", &parent_sb)) < 0) error (EXIT_FAILURE, errno, _("failed to stat %s"), - quote (nth_parent (parent_height))); + quote (nth_parent (parent_height))); /* If parent and child directory are on different devices, then we can't rely on d_ino for useful i-node numbers; use lstat instead. */ @@ -184,57 +184,57 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name, errno = 0; if ((dp = readdir_ignoring_dot_and_dotdot (dirp)) == NULL) - { - if (errno) - { - /* Save/restore errno across closedir call. */ - int e = errno; - closedir (dirp); - errno = e; + { + if (errno) + { + /* Save/restore errno across closedir call. */ + int e = errno; + closedir (dirp); + errno = e; - /* Arrange to give a diagnostic after exiting this loop. */ - dirp = NULL; - } - break; - } + /* Arrange to give a diagnostic after exiting this loop. */ + dirp = NULL; + } + break; + } ino = D_INO (dp); if (ino == NOT_AN_INODE_NUMBER || use_lstat) - { - if (lstat (dp->d_name, &ent_sb) < 0) - { - /* Skip any entry we can't stat. */ - continue; - } - ino = ent_sb.st_ino; - } + { + if (lstat (dp->d_name, &ent_sb) < 0) + { + /* Skip any entry we can't stat. */ + continue; + } + ino = ent_sb.st_ino; + } if (ino != dot_sb->st_ino) - continue; + continue; /* If we're not crossing a device boundary, then a simple i-node - match is enough. */ + match is enough. */ if ( ! use_lstat || ent_sb.st_dev == dot_sb->st_dev) - { - file_name_prepend (file_name, dp->d_name, _D_EXACT_NAMLEN (dp)); - found = true; - break; - } + { + file_name_prepend (file_name, dp->d_name, _D_EXACT_NAMLEN (dp)); + found = true; + break; + } } if (dirp == NULL || closedir (dirp) != 0) { /* Note that this diagnostic serves for both readdir - and closedir failures. */ + and closedir failures. */ error (EXIT_FAILURE, errno, _("reading directory %s"), - quote (nth_parent (parent_height))); + quote (nth_parent (parent_height))); } if ( ! found) error (EXIT_FAILURE, 0, - _("couldn't find directory entry in %s with matching i-node"), - quote (nth_parent (parent_height))); + _("couldn't find directory entry in %s with matching i-node"), + quote (nth_parent (parent_height))); *dot_sb = parent_sb; } @@ -272,7 +272,7 @@ robust_getcwd (struct file_name *file_name) if (root_dev_ino == NULL) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + quote ("/")); if (stat (".", &dot_sb) < 0) error (EXIT_FAILURE, errno, _("failed to stat %s"), quote (".")); @@ -281,7 +281,7 @@ robust_getcwd (struct file_name *file_name) { /* If we've reached the root, we're done. */ if (SAME_INODE (dot_sb, *root_dev_ino)) - break; + break; find_dir_entry (&dot_sb, file_name, height++); } @@ -309,8 +309,8 @@ logical_getcwd (void) while ((p = strstr (p, "/."))) { if (!p[2] || p[2] == '/' - || (p[2] == '.' && (!p[3] || p[3] == '/'))) - return NULL; + || (p[2] == '.' && (!p[3] || p[3] == '/'))) + return NULL; p++; } @@ -340,23 +340,23 @@ main (int argc, char **argv) { int c = getopt_long (argc, argv, "LP", longopts, NULL); if (c == -1) - break; + break; switch (c) - { - case 'L': - logical = true; - break; - case 'P': - logical = false; - break; + { + case 'L': + logical = true; + break; + case 'P': + logical = false; + 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); - } + default: + usage (EXIT_FAILURE); + } } if (optind < argc) @@ -366,10 +366,10 @@ main (int argc, char **argv) { wd = logical_getcwd (); if (wd) - { - puts (wd); - exit (EXIT_SUCCESS); - } + { + puts (wd); + exit (EXIT_SUCCESS); + } } wd = xgetcwd (); diff --git a/src/bin/coreutils/src/readlink.c b/src/bin/coreutils/src/readlink.c index 444a02a01b..a6f42f5c0e 100644 --- a/src/bin/coreutils/src/readlink.c +++ b/src/bin/coreutils/src/readlink.c @@ -57,12 +57,12 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... FILE\n"), program_name); fputs (_("Print value of a symbolic link or canonical file name\n\n"), - stdout); + stdout); fputs (_("\ -f, --canonicalize canonicalize by following every symlink in\n\ every component of the given name recursively;\n\ @@ -112,31 +112,31 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "efmnqsv", longopts, NULL)) != -1) { switch (optc) - { - case 'e': - can_mode = CAN_EXISTING; - break; - case 'f': - can_mode = CAN_ALL_BUT_LAST; - break; - case 'm': - can_mode = CAN_MISSING; - break; - case 'n': - no_newline = true; - break; - case 'q': - case 's': - verbose = false; - break; - case 'v': - verbose = true; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + { + case 'e': + can_mode = CAN_EXISTING; + break; + case 'f': + can_mode = CAN_ALL_BUT_LAST; + break; + case 'm': + can_mode = CAN_MISSING; + break; + case 'n': + no_newline = true; + break; + case 'q': + case 's': + verbose = false; + break; + case 'v': + verbose = true; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (optind >= argc) @@ -154,8 +154,8 @@ main (int argc, char **argv) } value = (can_mode != -1 - ? canonicalize_filename_mode (fname, can_mode) - : areadlink_with_size (fname, 63)); + ? canonicalize_filename_mode (fname, can_mode) + : areadlink_with_size (fname, 63)); if (value) { printf ("%s%s", value, (no_newline ? "" : "\n")); diff --git a/src/bin/coreutils/src/remove.c b/src/bin/coreutils/src/remove.c index 154a3450e7..d7bb86390b 100644 --- a/src/bin/coreutils/src/remove.c +++ b/src/bin/coreutils/src/remove.c @@ -307,7 +307,7 @@ pop_dir (Dirstack_state *ds) static size_t right_justify (char *dst, size_t dst_len, const char *src, size_t src_len, - char **result, bool *truncated) + char **result, bool *truncated) { const char *sp; char *dp; @@ -346,7 +346,7 @@ full_filename0 (Dirstack_state const *ds, const char *filename) { char *new_buf = realloc (g_buf, n_bytes_needed); if (new_buf == NULL) - return NULL; + return NULL; g_buf = new_buf; g_n_allocated = n_bytes_needed; @@ -355,15 +355,15 @@ full_filename0 (Dirstack_state const *ds, const char *filename) if (STREQ (filename, ".") && dir_len) { /* FILENAME is just `.' and dir_len is nonzero. - Copy the directory part, omitting the trailing slash, - and append a trailing zero byte. */ + Copy the directory part, omitting the trailing slash, + and append a trailing zero byte. */ char *p = mempcpy (g_buf, dir_name, dir_len - 1); *p = 0; } else { /* Copy the directory part, including trailing slash, and then - append the filename part, including a trailing zero byte. */ + append the filename part, including a trailing zero byte. */ memcpy (mempcpy (g_buf, dir_name, dir_len), filename, filename_len + 1); assert (strlen (g_buf) + 1 == n_bytes_needed); } @@ -415,14 +415,14 @@ full_filename_ (Dirstack_state const *ds, const char *filename) free (g_buf); n_bytes_remaining = right_justify (static_buf, SBUF_SIZE, filename, - strlen (filename) + 1, &p, - &file_truncated); + strlen (filename) + 1, &p, + &file_truncated); right_justify (static_buf, n_bytes_remaining, dir_name, dir_len, - &p, &dir_truncated); + &p, &dir_truncated); if (file_truncated || dir_truncated) { - memcpy (static_buf, ELLIPSES_PREFIX, - sizeof (ELLIPSES_PREFIX) - 1); + memcpy (static_buf, ELLIPSES_PREFIX, + sizeof (ELLIPSES_PREFIX) - 1); } errno = saved_errno; return p; @@ -558,7 +558,7 @@ AD_pop_and_chdir (DIR *dirp, int *fdp, Dirstack_state *ds) of a directory that this rm process would encounter, which would result in a false-positive cycle indication. */ CYCLE_CHECK_REFLECT_CHDIR_UP (&ds->cycle_check_state, - top->dev_ino, leaf_dev_ino); + top->dev_ino, leaf_dev_ino); /* Propagate any failure to parent. */ UPDATE_STATUS (top->status, old_status); @@ -570,55 +570,55 @@ AD_pop_and_chdir (DIR *dirp, int *fdp, Dirstack_state *ds) struct stat sb; int fd = openat (dirfd (dirp), "..", O_RDONLY); if (closedir (dirp) != 0) - { - error (0, errno, _("FATAL: failed to close directory %s"), - quote (full_filename (prev_dir))); - goto next_cmdline_arg; - } + { + error (0, errno, _("FATAL: failed to close directory %s"), + quote (full_filename (prev_dir))); + goto next_cmdline_arg; + } /* The above fails with EACCES when DIRP is readable but not - searchable, when using Solaris' openat. Without this openat - call, tests/rm2 would fail to remove directories a/2 and a/3. */ + searchable, when using Solaris' openat. Without this openat + call, tests/rm2 would fail to remove directories a/2 and a/3. */ if (fd < 0) - fd = openat (AT_FDCWD, xfull_filename (ds, "."), O_RDONLY); + fd = openat (AT_FDCWD, xfull_filename (ds, "."), O_RDONLY); if (fd < 0) - { - error (0, errno, _("FATAL: cannot open .. from %s"), - quote (full_filename (prev_dir))); - goto next_cmdline_arg; - } + { + error (0, errno, _("FATAL: cannot open .. from %s"), + quote (full_filename (prev_dir))); + goto next_cmdline_arg; + } if (fstat (fd, &sb)) - { - error (0, errno, - _("FATAL: cannot ensure %s (returned to via ..) is safe"), - quote (full_filename ("."))); - goto close_and_next; - } + { + error (0, errno, + _("FATAL: cannot ensure %s (returned to via ..) is safe"), + quote (full_filename ("."))); + goto close_and_next; + } /* Ensure that post-chdir dev/ino match the stored ones. */ if ( ! SAME_INODE (sb, top->dev_ino)) - { - error (0, 0, _("FATAL: directory %s changed dev/ino"), - quote (full_filename ("."))); - close_and_next:; - close (fd); + { + error (0, 0, _("FATAL: directory %s changed dev/ino"), + quote (full_filename ("."))); + close_and_next:; + close (fd); - next_cmdline_arg:; - free (prev_dir); - longjmp (ds->current_arg_jumpbuf, 1); - } + next_cmdline_arg:; + free (prev_dir); + longjmp (ds->current_arg_jumpbuf, 1); + } *fdp = fd; } else { if (closedir (dirp) != 0) - { - error (0, errno, _("FATAL: failed to close directory %s"), - quote (full_filename (prev_dir))); - goto next_cmdline_arg; - } + { + error (0, errno, _("FATAL: failed to close directory %s"), + quote (full_filename (prev_dir))); + goto next_cmdline_arg; + } *fdp = AT_FDCWD; } @@ -632,9 +632,9 @@ AD_ensure_initialized (Hash_table **ht) if (*ht == NULL) { *ht = hash_initialize (HT_UNREMOVABLE_INITIAL_CAPACITY, NULL, hash_pjw, - hash_compare_strings, hash_freer); + hash_compare_strings, hash_freer); if (*ht == NULL) - xalloc_die (); + xalloc_die (); } return *ht; @@ -651,7 +651,7 @@ AD_mark_helper (Hash_table **ht, char *filename) else { if (ent != filename) - free (filename); + free (filename); } } @@ -708,7 +708,7 @@ AD_push_initial (Dirstack_state *ds) replaced DIR with e.g., a symlink to some other directory. */ static void AD_push (int fd_cwd, Dirstack_state *ds, char const *dir, - struct stat const *dir_sb_from_parent) + struct stat const *dir_sb_from_parent) { struct AD_ent *top; @@ -720,19 +720,19 @@ AD_push (int fd_cwd, Dirstack_state *ds, char const *dir, { struct stat sb; if (fstat (fd_cwd, &sb) != 0) - { - error (0, errno, _("FATAL: cannot enter directory %s"), - quote (full_filename ("."))); - longjmp (ds->current_arg_jumpbuf, 1); - } + { + error (0, errno, _("FATAL: cannot enter directory %s"), + quote (full_filename ("."))); + longjmp (ds->current_arg_jumpbuf, 1); + } if ( ! SAME_INODE (sb, *dir_sb_from_parent)) - { - error (0, 0, - _("FATAL: just-changed-to directory %s changed dev/ino"), - quote (full_filename ("."))); - longjmp (ds->current_arg_jumpbuf, 1); - } + { + error (0, 0, + _("FATAL: just-changed-to directory %s changed dev/ino"), + quote (full_filename ("."))); + longjmp (ds->current_arg_jumpbuf, 1); + } } if (cycle_check (&ds->cycle_check_state, dir_sb_from_parent)) @@ -742,7 +742,7 @@ WARNING: Circular directory structure.\n\ This almost certainly means that you have a corrupted file system.\n\ NOTIFY YOUR SYSTEM MANAGER.\n\ The following directory is part of the cycle:\n %s\n"), - quote (full_filename ("."))); + quote (full_filename ("."))); longjmp (ds->current_arg_jumpbuf, 1); } @@ -751,7 +751,7 @@ The following directory is part of the cycle:\n %s\n"), /* The active directory stack must be one larger than the length stack. */ assert (AD_stack_height (ds) == - 1 + obstack_object_size (&ds->len_stack) / sizeof (size_t)); + 1 + obstack_object_size (&ds->len_stack) / sizeof (size_t)); /* Fill in the new values. */ top = AD_stack_top (ds); @@ -774,9 +774,9 @@ AD_is_removable (Dirstack_state const *ds, char const *file) This is to avoid calling euidaccess when FILE is a symlink. */ static int write_protected_non_symlink (int fd_cwd, - char const *file, - Dirstack_state const *ds, - struct stat *buf) + char const *file, + Dirstack_state const *ds, + struct stat *buf) { if (can_write_any_file ()) return 0; @@ -795,42 +795,42 @@ write_protected_non_symlink (int fd_cwd, /* In the absence of a native eaccessat function, here are some of the implementation choices [#4 and #5 were suggested by Paul Eggert]: 1) call openat with O_WRONLY|O_NOCTTY - Disadvantage: may create the file and doesn't work for directory, - may mistakenly report `unwritable' for EROFS or ACLs even though - perm bits say the file is writable. + Disadvantage: may create the file and doesn't work for directory, + may mistakenly report `unwritable' for EROFS or ACLs even though + perm bits say the file is writable. 2) fake eaccessat (save_cwd, fchdir, call euidaccess, restore_cwd) - Disadvantage: changes working directory (not reentrant) and can't - work if save_cwd fails. + Disadvantage: changes working directory (not reentrant) and can't + work if save_cwd fails. 3) if (euidaccess (xfull_filename (file), W_OK) == 0) - Disadvantage: doesn't work if xfull_filename is too long. - Inefficient for very deep trees (O(Depth^2)). + Disadvantage: doesn't work if xfull_filename is too long. + Inefficient for very deep trees (O(Depth^2)). 4) If the full pathname is sufficiently short (say, less than - PATH_MAX or 8192 bytes, whichever is shorter): - use method (3) (i.e., euidaccess (xfull_filename (file), W_OK)); - Otherwise: vfork, fchdir in the child, run euidaccess in the - child, then the child exits with a status that tells the parent - whether euidaccess succeeded. + PATH_MAX or 8192 bytes, whichever is shorter): + use method (3) (i.e., euidaccess (xfull_filename (file), W_OK)); + Otherwise: vfork, fchdir in the child, run euidaccess in the + child, then the child exits with a status that tells the parent + whether euidaccess succeeded. - This avoids the O(N**2) algorithm of method (3), and it also avoids - the failure-due-to-too-long-file-names of method (3), but it's fast - in the normal shallow case. It also avoids the lack-of-reentrancy - and the save_cwd problems. - Disadvantage; it uses a process slot for very-long file names, - and would be very slow for hierarchies with many such files. + This avoids the O(N**2) algorithm of method (3), and it also avoids + the failure-due-to-too-long-file-names of method (3), but it's fast + in the normal shallow case. It also avoids the lack-of-reentrancy + and the save_cwd problems. + Disadvantage; it uses a process slot for very-long file names, + and would be very slow for hierarchies with many such files. 5) If the full file name is sufficiently short (say, less than - PATH_MAX or 8192 bytes, whichever is shorter): - use method (3) (i.e., euidaccess (xfull_filename (file), W_OK)); - Otherwise: look just at the file bits. Perhaps issue a warning - the first time this occurs. + PATH_MAX or 8192 bytes, whichever is shorter): + use method (3) (i.e., euidaccess (xfull_filename (file), W_OK)); + Otherwise: look just at the file bits. Perhaps issue a warning + the first time this occurs. - This is like (4), except for the "Otherwise" case where it isn't as - "perfect" as (4) but is considerably faster. It conforms to current - POSIX, and is uniformly better than what Solaris and FreeBSD do (they - mess up with long file names). */ + This is like (4), except for the "Otherwise" case where it isn't as + "perfect" as (4) but is considerably faster. It conforms to current + POSIX, and is uniformly better than what Solaris and FreeBSD do (they + mess up with long file names). */ { /* This implements #5: */ @@ -843,8 +843,8 @@ write_protected_non_symlink (int fd_cwd, return 0; if (errno == EACCES) { - errno = 0; - return 1; + errno = 0; + return 1; } /* Perhaps some other process has removed the file, or perhaps this @@ -869,9 +869,9 @@ write_protected_non_symlink (int fd_cwd, Don't even try to set *IS_EMPTY when MODE == PA_REMOVE_DIR. */ static enum RM_status prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, - int *pdirent_type, struct stat *sbuf, - struct rm_options const *x, enum Prompt_action mode, - Ternary *is_empty) + int *pdirent_type, struct stat *sbuf, + struct rm_options const *x, enum Prompt_action mode, + Ternary *is_empty) { int write_protected = 0; int dirent_type = *pdirent_type; @@ -895,86 +895,86 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, if (write_protected || errno || x->interactive == RMI_ALWAYS) { if (0 <= write_protected && dirent_type == DT_UNKNOWN) - { - if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) == 0) - { - if (S_ISLNK (sbuf->st_mode)) - dirent_type = DT_LNK; - else if (S_ISDIR (sbuf->st_mode)) - dirent_type = DT_DIR; - /* Otherwise it doesn't matter, so leave it DT_UNKNOWN. */ - *pdirent_type = dirent_type; - } - else - { - /* This happens, e.g., with `rm '''. */ - write_protected = -1; - wp_errno = errno; - } - } + { + if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) == 0) + { + if (S_ISLNK (sbuf->st_mode)) + dirent_type = DT_LNK; + else if (S_ISDIR (sbuf->st_mode)) + dirent_type = DT_DIR; + /* Otherwise it doesn't matter, so leave it DT_UNKNOWN. */ + *pdirent_type = dirent_type; + } + else + { + /* This happens, e.g., with `rm '''. */ + write_protected = -1; + wp_errno = errno; + } + } if (0 <= write_protected) - switch (dirent_type) - { - case DT_LNK: - /* Using permissions doesn't make sense for symlinks. */ - if (x->interactive != RMI_ALWAYS) - return RM_OK; - break; + switch (dirent_type) + { + case DT_LNK: + /* Using permissions doesn't make sense for symlinks. */ + if (x->interactive != RMI_ALWAYS) + return RM_OK; + break; - case DT_DIR: - if (!x->recursive) - { - write_protected = -1; - wp_errno = EISDIR; - } - break; - } + case DT_DIR: + if (!x->recursive) + { + write_protected = -1; + wp_errno = EISDIR; + } + break; + } { char const *quoted_name = quote (full_filename (filename)); if (write_protected < 0) - { - error (0, wp_errno, _("cannot remove %s"), quoted_name); - return RM_ERROR; - } + { + error (0, wp_errno, _("cannot remove %s"), quoted_name); + return RM_ERROR; + } /* Issue the prompt. */ /* FIXME: use a variant of error (instead of fprintf) that doesn't - append a newline. Then we won't have to declare program_name in - this file. */ + append a newline. Then we won't have to declare program_name in + this file. */ if (dirent_type == DT_DIR - && mode == PA_DESCEND_INTO_DIR - && ((*is_empty = (is_empty_dir (fd_cwd, filename) ? T_YES : T_NO)) - == T_NO)) - fprintf (stderr, - (write_protected - ? _("%s: descend into write-protected directory %s? ") - : _("%s: descend into directory %s? ")), - program_name, quoted_name); + && mode == PA_DESCEND_INTO_DIR + && ((*is_empty = (is_empty_dir (fd_cwd, filename) ? T_YES : T_NO)) + == T_NO)) + fprintf (stderr, + (write_protected + ? _("%s: descend into write-protected directory %s? ") + : _("%s: descend into directory %s? ")), + program_name, quoted_name); else - { - if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0) - { - error (0, errno, _("cannot remove %s"), quoted_name); - return RM_ERROR; - } + { + if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0) + { + error (0, errno, _("cannot remove %s"), quoted_name); + return RM_ERROR; + } - fprintf (stderr, - (write_protected - /* TRANSLATORS: You may find it more convenient to - translate "%s: remove %s (write-protected) %s? " - instead. It should avoid grammatical problems - with the output of file_type. */ - ? _("%s: remove write-protected %s %s? ") - : _("%s: remove %s %s? ")), - program_name, file_type (sbuf), quoted_name); - } + fprintf (stderr, + (write_protected + /* TRANSLATORS: You may find it more convenient to + translate "%s: remove %s (write-protected) %s? " + instead. It should avoid grammatical problems + with the output of file_type. */ + ? _("%s: remove write-protected %s %s? ") + : _("%s: remove %s %s? ")), + program_name, file_type (sbuf), quoted_name); + } } if (!yesno ()) - return RM_USER_DECLINED; + return RM_USER_DECLINED; } return RM_OK; } @@ -1013,14 +1013,14 @@ is_nondir_lstat (int fd_cwd, char const *filename, struct stat *st) do \ { \ if (unlinkat (Fd_cwd, Filename, 0) == 0) \ - { \ - if ((X)->verbose) \ - printf (_("removed %s\n"), quote (full_filename (Filename))); \ - return RM_OK; \ - } \ - \ + { \ + if ((X)->verbose) \ + printf (_("removed %s\n"), quote (full_filename (Filename))); \ + return RM_OK; \ + } \ + \ if (ignorable_missing (X, errno)) \ - return RM_OK; \ + return RM_OK; \ } \ while (0) @@ -1028,18 +1028,18 @@ is_nondir_lstat (int fd_cwd, char const *filename, struct stat *st) do \ { \ if (unlinkat (Fd_cwd, Filename, AT_REMOVEDIR) == 0) /* rmdir */ \ - { \ - if ((X)->verbose) \ - printf (_("removed directory: %s\n"), \ - quote (full_filename (Filename))); \ - return RM_OK; \ - } \ - \ + { \ + if ((X)->verbose) \ + printf (_("removed directory: %s\n"), \ + quote (full_filename (Filename))); \ + return RM_OK; \ + } \ + \ if (ignorable_missing (X, errno)) \ - return RM_OK; \ - \ + return RM_OK; \ + \ if (errno == ENOTEMPTY || errno == EEXIST) \ - return RM_NONEMPTY_DIR; \ + return RM_NONEMPTY_DIR; \ } \ while (0) @@ -1078,13 +1078,13 @@ ignorable_missing (struct rm_options const *x, int errnum) static enum RM_status remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, - int dirent_type_arg, struct stat *st, - struct rm_options const *x) + int dirent_type_arg, struct stat *st, + struct rm_options const *x) { Ternary is_empty_directory; enum RM_status s = prompt (fd_cwd, ds, filename, &dirent_type_arg, st, x, - PA_DESCEND_INTO_DIR, - &is_empty_directory); + PA_DESCEND_INTO_DIR, + &is_empty_directory); int dirent_type = dirent_type_arg; if (s != RM_OK) return s; @@ -1106,101 +1106,101 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, if (cannot_unlink_dir ()) { if (dirent_type == DT_DIR && ! x->recursive) - { - error (0, EISDIR, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; - } + { + error (0, EISDIR, _("cannot remove %s"), + quote (full_filename (filename))); + return RM_ERROR; + } /* is_empty_directory is set iff it's ok to use rmdir. - Note that it's set only in interactive mode -- in which case it's - an optimization that arranges so that the user is asked just - once whether to remove the directory. */ + Note that it's set only in interactive mode -- in which case it's + an optimization that arranges so that the user is asked just + once whether to remove the directory. */ if (is_empty_directory == T_YES) - DO_RMDIR (fd_cwd, filename, x); + DO_RMDIR (fd_cwd, filename, x); /* If we happen to know that FILENAME is a directory, return now - and let the caller remove it -- this saves the overhead of a failed - unlink call. If FILENAME is a command-line argument, then - DIRENT_TYPE is DT_UNKNOWN so we'll first try to unlink it. - Using unlink here is ok, because it cannot remove a - directory. */ + and let the caller remove it -- this saves the overhead of a failed + unlink call. If FILENAME is a command-line argument, then + DIRENT_TYPE is DT_UNKNOWN so we'll first try to unlink it. + Using unlink here is ok, because it cannot remove a + directory. */ if (dirent_type == DT_DIR) - return RM_NONEMPTY_DIR; + return RM_NONEMPTY_DIR; DO_UNLINK (fd_cwd, filename, x); /* Upon a failed attempt to unlink a directory, most non GNU/Linux - systems set errno to the POSIX-required value EPERM. In that case, - change errno to EISDIR so that we emit a better diagnostic. */ + systems set errno to the POSIX-required value EPERM. In that case, + change errno to EISDIR so that we emit a better diagnostic. */ if (! x->recursive && errno == EPERM && is_dir_lstat (fd_cwd, - filename, st)) - errno = EISDIR; + filename, st)) + errno = EISDIR; if (! x->recursive - || (cache_stat_ok (st) && !S_ISDIR (st->st_mode)) - || ((errno == EACCES || errno == EPERM) - && is_nondir_lstat (fd_cwd, filename, st)) - ) - { - if (ignorable_missing (x, errno)) - return RM_OK; + || (cache_stat_ok (st) && !S_ISDIR (st->st_mode)) + || ((errno == EACCES || errno == EPERM) + && is_nondir_lstat (fd_cwd, filename, st)) + ) + { + if (ignorable_missing (x, errno)) + return RM_OK; - /* Either --recursive is not in effect, or the file cannot be a - directory. Report the unlink problem and fail. */ - error (0, errno, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; - } + /* Either --recursive is not in effect, or the file cannot be a + directory. Report the unlink problem and fail. */ + error (0, errno, _("cannot remove %s"), + quote (full_filename (filename))); + return RM_ERROR; + } assert (!cache_stat_ok (st) || S_ISDIR (st->st_mode)); } else { /* If we don't already know whether FILENAME is a directory, - find out now. Then, if it's a non-directory, we can use - unlink on it. */ + find out now. Then, if it's a non-directory, we can use + unlink on it. */ if (dirent_type == DT_UNKNOWN) - { - if (fstatat (fd_cwd, filename, st, AT_SYMLINK_NOFOLLOW)) - { - if (ignorable_missing (x, errno)) - return RM_OK; + { + if (fstatat (fd_cwd, filename, st, AT_SYMLINK_NOFOLLOW)) + { + if (ignorable_missing (x, errno)) + return RM_OK; - error (0, errno, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; - } + error (0, errno, _("cannot remove %s"), + quote (full_filename (filename))); + return RM_ERROR; + } - if (S_ISDIR (st->st_mode)) - dirent_type = DT_DIR; - } + if (S_ISDIR (st->st_mode)) + dirent_type = DT_DIR; + } if (dirent_type != DT_DIR) - { - /* At this point, barring race conditions, FILENAME is known - to be a non-directory, so it's ok to try to unlink it. */ - DO_UNLINK (fd_cwd, filename, x); + { + /* At this point, barring race conditions, FILENAME is known + to be a non-directory, so it's ok to try to unlink it. */ + DO_UNLINK (fd_cwd, filename, x); - /* unlink failed with some other error code. report it. */ - error (0, errno, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; - } + /* unlink failed with some other error code. report it. */ + error (0, errno, _("cannot remove %s"), + quote (full_filename (filename))); + return RM_ERROR; + } if (! x->recursive) - { - error (0, EISDIR, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; - } + { + error (0, EISDIR, _("cannot remove %s"), + quote (full_filename (filename))); + return RM_ERROR; + } if (is_empty_directory == T_YES) - { - DO_RMDIR (fd_cwd, filename, x); - /* Don't diagnose any failure here. - It'll be detected when the caller tries another way. */ - } + { + DO_RMDIR (fd_cwd, filename, x); + /* Don't diagnose any failure here. + It'll be detected when the caller tries another way. */ + } } return RM_NONEMPTY_DIR; @@ -1223,9 +1223,9 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, isn't restored. */ static DIR * fd_to_subdirp (int fd_cwd, char const *f, - int prev_errno, - struct stat *subdir_sb, - int *cwd_errno ATTRIBUTE_UNUSED) + int prev_errno, + struct stat *subdir_sb, + int *cwd_errno ATTRIBUTE_UNUSED) { int open_flags = O_RDONLY | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK; int fd_sub = openat_permissive (fd_cwd, f, open_flags, 0, cwd_errno); @@ -1242,7 +1242,7 @@ fd_to_subdirp (int fd_cwd, char const *f, { DIR *subdir_dirp = fdopendir (fd_sub); if (subdir_dirp) - return subdir_dirp; + return subdir_dirp; saved_errno = errno; } else @@ -1267,7 +1267,7 @@ compare_ino (void const *av, void const *bv) struct readdir_data const *const *a = av; struct readdir_data const *const *b = bv; return (a[0]->ino < b[0]->ino ? -1 - : b[0]->ino < a[0]->ino ? 1 : 0); + : b[0]->ino < a[0]->ino ? 1 : 0); } /* Return an approximation of the maximum number of dirent entries @@ -1308,7 +1308,7 @@ dirent_inode_sort_may_be_useful (int dir_fd) case S_MAGIC_TMPFS: case S_MAGIC_NFS: /* On a file system of any of these types, sorting - is unnecessary, and hence wasteful. */ + is unnecessary, and hence wasteful. */ return false; default: @@ -1316,7 +1316,10 @@ dirent_inode_sort_may_be_useful (int dir_fd) } } # else /* !HAVE_STRUCT_STATFS_F_TYPE */ -static bool dirent_inode_sort_may_be_useful (int dir_fd) { return true; } +static bool dirent_inode_sort_may_be_useful (int dir_fd ATTRIBUTE_UNUSED) +{ + return true; +} # endif /* !HAVE_STRUCT_STATFS_F_TYPE */ #endif /* HAVE_STRUCT_DIRENT_D_TYPE */ @@ -1354,18 +1357,18 @@ preprocess_dir (DIR **dirp, struct rm_options const *x) || x->verbose /* - privileged users can unlink nonempty directories. - Otherwise, there'd be a race condition between the readdir - call (in which we learn dirent.d_type) and the unlink, by - which time the non-directory may be replaced with a directory. */ + Otherwise, there'd be a race condition between the readdir + call (in which we learn dirent.d_type) and the unlink, by + which time the non-directory may be replaced with a directory. */ || ! cannot_unlink_dir () /* - we can't fstat the file descriptor */ || fstat (dir_fd, &st) != 0 /* - the directory is smaller than some threshold. - Estimate the number of inodes with a heuristic. + Estimate the number of inodes with a heuristic. There's no significant benefit to sorting if there are - too few inodes. */ + too few inodes. */ || dirent_count (&st) < INODE_SORT_DIR_ENTRIES_THRESHOLD /* Sort only if it might help. */ @@ -1386,9 +1389,9 @@ preprocess_dir (DIR **dirp, struct rm_options const *x) obstack_init_minimal (&o_p); obstack_specify_allocation_with_arg (&o_readdir_data, 0, 0, - rm_malloc, rm_free, &readdir_jumpbuf); + rm_malloc, rm_free, &readdir_jumpbuf); obstack_specify_allocation_with_arg (&o_p, 0, 0, - rm_malloc, rm_free, &readdir_jumpbuf); + rm_malloc, rm_free, &readdir_jumpbuf); /* Read all entries, storing for each non-dir one. Maintain a parallel list of pointers into the primary buffer. */ @@ -1398,11 +1401,11 @@ preprocess_dir (DIR **dirp, struct rm_options const *x) dp = readdir_ignoring_dot_and_dotdot (*dirp); /* no need to distinguish EOF from failure */ if (dp == NULL) - break; + break; /* Skip known-directory and type-unknown entries. */ if (D_TYPE (dp) == DT_UNKNOWN || D_TYPE (dp) == DT_DIR) - break; + break; size_t name_len = strlen (dp->d_name); size_t ent_len = offsetof (struct readdir_data, name) + name_len + 1; @@ -1447,8 +1450,8 @@ preprocess_dir (DIR **dirp, struct rm_options const *x) possible, continuing even if we fail to remove some entries. */ static enum RM_status remove_cwd_entries (DIR **dirp, - Dirstack_state *ds, char **subdir, struct stat *subdir_sb, - struct rm_options const *x) + Dirstack_state *ds, char **subdir, struct stat *subdir_sb, + struct rm_options const *x) { struct AD_ent *top = AD_stack_top (ds); enum RM_status status = top->status; @@ -1468,105 +1471,105 @@ remove_cwd_entries (DIR **dirp, const char *f; /* Set errno to zero so we can distinguish between a readdir failure - and when readdir simply finds that there are no more entries. */ + and when readdir simply finds that there are no more entries. */ errno = 0; dp = readdir_ignoring_dot_and_dotdot (*dirp); if (dp == NULL) - { - if (errno) - { - /* fall through */ - } - else if (NEED_REWIND (n_unlinked_since_opendir_or_last_rewind)) - { - /* Call rewinddir if we've called unlink or rmdir so many times - (since the opendir or the previous rewinddir) that this - NULL-return may be the symptom of a buggy readdir. */ - rewinddir (*dirp); - n_unlinked_since_opendir_or_last_rewind = 0; - continue; - } - break; - } + { + if (errno) + { + /* fall through */ + } + else if (NEED_REWIND (n_unlinked_since_opendir_or_last_rewind)) + { + /* Call rewinddir if we've called unlink or rmdir so many times + (since the opendir or the previous rewinddir) that this + NULL-return may be the symptom of a buggy readdir. */ + rewinddir (*dirp); + n_unlinked_since_opendir_or_last_rewind = 0; + continue; + } + break; + } f = dp->d_name; /* Skip files we've already tried/failed to remove. */ if ( ! AD_is_removable (ds, f)) - continue; + continue; /* Pass dp->d_type info to remove_entry so the non-glibc - case can decide whether to use unlink or chdir. - Systems without the d_type member will have to endure - the performance hit of first calling lstat F. */ + case can decide whether to use unlink or chdir. + Systems without the d_type member will have to endure + the performance hit of first calling lstat F. */ cache_stat_init (subdir_sb); tmp_status = remove_entry (dirfd (*dirp), ds, f, - D_TYPE (dp), subdir_sb, x); + D_TYPE (dp), subdir_sb, x); switch (tmp_status) - { - case RM_OK: - /* Count how many files we've unlinked since the initial - opendir or the last rewinddir. On buggy systems, if you - remove too many, readdir returns NULL even though there - remain unprocessed directory entries. */ - ++n_unlinked_since_opendir_or_last_rewind; - break; + { + case RM_OK: + /* Count how many files we've unlinked since the initial + opendir or the last rewinddir. On buggy systems, if you + remove too many, readdir returns NULL even though there + remain unprocessed directory entries. */ + ++n_unlinked_since_opendir_or_last_rewind; + break; - case RM_ERROR: - case RM_USER_DECLINED: - AD_mark_as_unremovable (ds, f); - UPDATE_STATUS (status, tmp_status); - break; + case RM_ERROR: + case RM_USER_DECLINED: + AD_mark_as_unremovable (ds, f); + UPDATE_STATUS (status, tmp_status); + break; - case RM_NONEMPTY_DIR: - { - DIR *subdir_dirp = fd_to_subdirp (dirfd (*dirp), f, - errno, subdir_sb, NULL); - if (subdir_dirp == NULL) - { - status = RM_ERROR; + case RM_NONEMPTY_DIR: + { + DIR *subdir_dirp = fd_to_subdirp (dirfd (*dirp), f, + errno, subdir_sb, NULL); + if (subdir_dirp == NULL) + { + status = RM_ERROR; - /* CAUTION: this test and diagnostic are identical to - those following the other use of fd_to_subdirp. */ - if (ignorable_missing (x, errno)) - { - /* With -f, don't report "file not found". */ - } - else - { - /* Upon fd_to_subdirp failure, try to remove F directly, - in case it's just an empty directory. */ - int saved_errno = errno; - if (unlinkat (dirfd (*dirp), f, AT_REMOVEDIR) == 0) - status = RM_OK; - else - error (0, saved_errno, - _("cannot remove %s"), quote (full_filename (f))); - } + /* CAUTION: this test and diagnostic are identical to + those following the other use of fd_to_subdirp. */ + if (ignorable_missing (x, errno)) + { + /* With -f, don't report "file not found". */ + } + else + { + /* Upon fd_to_subdirp failure, try to remove F directly, + in case it's just an empty directory. */ + int saved_errno = errno; + if (unlinkat (dirfd (*dirp), f, AT_REMOVEDIR) == 0) + status = RM_OK; + else + error (0, saved_errno, + _("cannot remove %s"), quote (full_filename (f))); + } - if (status == RM_ERROR) - AD_mark_as_unremovable (ds, f); - break; - } + if (status == RM_ERROR) + AD_mark_as_unremovable (ds, f); + break; + } - *subdir = xstrdup (f); - if (closedir (*dirp) != 0) - { - error (0, 0, _("failed to close directory %s"), - quote (full_filename ("."))); - status = RM_ERROR; - } - *dirp = subdir_dirp; + *subdir = xstrdup (f); + if (closedir (*dirp) != 0) + { + error (0, 0, _("failed to close directory %s"), + quote (full_filename ("."))); + status = RM_ERROR; + } + *dirp = subdir_dirp; - break; - } - } + break; + } + } /* Record status for this directory. */ UPDATE_STATUS (top->status, status); if (*subdir) - break; + break; } /* Ensure that *dirp is not NULL and that its file descriptor is valid. */ @@ -1595,8 +1598,8 @@ remove_cwd_entries (DIR **dirp, static enum RM_status remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir, - struct stat *dir_st, - struct rm_options const *x, int *cwd_errno) + struct stat *dir_st, + struct rm_options const *x, int *cwd_errno) { enum RM_status status; dev_t current_dev = dir_st->st_dev; @@ -1614,22 +1617,22 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir, if (dirp == NULL) { /* CAUTION: this test and diagnostic are identical to - those following the other use of fd_to_subdirp. */ + those following the other use of fd_to_subdirp. */ if (ignorable_missing (x, errno)) - { - /* With -f, don't report "file not found". */ - } + { + /* With -f, don't report "file not found". */ + } else - { - /* Upon fd_to_subdirp failure, try to remove DIR directly, - in case it's just an empty directory. */ - int saved_errno = errno; - if (unlinkat (fd_cwd, dir, AT_REMOVEDIR) == 0) - return RM_OK; + { + /* Upon fd_to_subdirp failure, try to remove DIR directly, + in case it's just an empty directory. */ + int saved_errno = errno; + if (unlinkat (fd_cwd, dir, AT_REMOVEDIR) == 0) + return RM_OK; - error (0, saved_errno, - _("cannot remove %s"), quote (full_filename (dir))); - } + error (0, saved_errno, + _("cannot remove %s"), quote (full_filename (dir))); + } return RM_ERROR; } @@ -1655,93 +1658,93 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir, tmp_status = remove_cwd_entries (&dirp, ds, &subdir, &subdir_sb, x); if (tmp_status != RM_OK) - { - UPDATE_STATUS (status, tmp_status); - AD_mark_current_as_unremovable (ds); - } + { + UPDATE_STATUS (status, tmp_status); + AD_mark_current_as_unremovable (ds); + } if (subdir) - { - if ( ! x->one_file_system - || subdir_sb.st_dev == current_dev) - { - AD_push (dirfd (dirp), ds, subdir, &subdir_sb); - AD_INIT_OTHER_MEMBERS (); - free (subdir); - continue; - } + { + if ( ! x->one_file_system + || subdir_sb.st_dev == current_dev) + { + AD_push (dirfd (dirp), ds, subdir, &subdir_sb); + AD_INIT_OTHER_MEMBERS (); + free (subdir); + continue; + } - /* Here, --one-file-system is in effect, and with remove_cwd_entries' - traversal into the current directory, (known as SUBDIR, from ..), - DIRP's device number is different from CURRENT_DEV. Arrange not - to do anything more with this hierarchy. */ - error (0, 0, _("skipping %s, since it's on a different device"), - quote (full_filename (subdir))); - free (subdir); - AD_mark_current_as_unremovable (ds); - tmp_status = RM_ERROR; - UPDATE_STATUS (status, tmp_status); - } + /* Here, --one-file-system is in effect, and with remove_cwd_entries' + traversal into the current directory, (known as SUBDIR, from ..), + DIRP's device number is different from CURRENT_DEV. Arrange not + to do anything more with this hierarchy. */ + error (0, 0, _("skipping %s, since it's on a different device"), + quote (full_filename (subdir))); + free (subdir); + AD_mark_current_as_unremovable (ds); + tmp_status = RM_ERROR; + UPDATE_STATUS (status, tmp_status); + } /* Execution reaches this point when we've removed the last - removable entry from the current directory -- or, with - --one-file-system, when the current directory is on a - different file system. */ + removable entry from the current directory -- or, with + --one-file-system, when the current directory is on a + different file system. */ { - int fd; - /* The name of the directory that we have just processed, - nominally removing all of its contents. */ - char *empty_dir = AD_pop_and_chdir (dirp, &fd, ds); - dirp = NULL; - assert (fd != AT_FDCWD || AD_stack_height (ds) == 1); + int fd; + /* The name of the directory that we have just processed, + nominally removing all of its contents. */ + char *empty_dir = AD_pop_and_chdir (dirp, &fd, ds); + dirp = NULL; + assert (fd != AT_FDCWD || AD_stack_height (ds) == 1); - /* Try to remove EMPTY_DIR only if remove_cwd_entries succeeded. */ - if (tmp_status == RM_OK) - { - struct stat empty_st; - Ternary is_empty; - int dirent_type = DT_DIR; - enum RM_status s = prompt (fd, ds, empty_dir, &dirent_type, - cache_stat_init (&empty_st), x, - PA_REMOVE_DIR, &is_empty); + /* Try to remove EMPTY_DIR only if remove_cwd_entries succeeded. */ + if (tmp_status == RM_OK) + { + struct stat empty_st; + Ternary is_empty; + int dirent_type = DT_DIR; + enum RM_status s = prompt (fd, ds, empty_dir, &dirent_type, + cache_stat_init (&empty_st), x, + PA_REMOVE_DIR, &is_empty); - if (s != RM_OK) - { - free (empty_dir); - status = s; - if (fd != AT_FDCWD) - close (fd); - goto closedir_and_return; - } + if (s != RM_OK) + { + free (empty_dir); + status = s; + if (fd != AT_FDCWD) + close (fd); + goto closedir_and_return; + } - if (unlinkat (fd, empty_dir, AT_REMOVEDIR) == 0) - { - if (x->verbose) - printf (_("removed directory: %s\n"), - quote (full_filename (empty_dir))); - } - else - { - error (0, errno, _("cannot remove directory %s"), - quote (full_filename (empty_dir))); - AD_mark_as_unremovable (ds, empty_dir); - status = RM_ERROR; - UPDATE_STATUS (AD_stack_top(ds)->status, status); - } - } + if (unlinkat (fd, empty_dir, AT_REMOVEDIR) == 0) + { + if (x->verbose) + printf (_("removed directory: %s\n"), + quote (full_filename (empty_dir))); + } + else + { + error (0, errno, _("cannot remove directory %s"), + quote (full_filename (empty_dir))); + AD_mark_as_unremovable (ds, empty_dir); + status = RM_ERROR; + UPDATE_STATUS (AD_stack_top(ds)->status, status); + } + } - free (empty_dir); + free (empty_dir); - if (fd == AT_FDCWD) - break; + if (fd == AT_FDCWD) + break; - dirp = fdopendir (fd); - if (dirp == NULL) - { - error (0, errno, _("FATAL: cannot return to .. from %s"), - quote (full_filename ("."))); - close (fd); - longjmp (ds->current_arg_jumpbuf, 1); - } + dirp = fdopendir (fd); + if (dirp == NULL) + { + error (0, errno, _("FATAL: cannot return to .. from %s"), + quote (full_filename ("."))); + close (fd); + longjmp (ds->current_arg_jumpbuf, 1); + } } } @@ -1753,7 +1756,7 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir, if (dirp != NULL && closedir (dirp) != 0) { error (0, 0, _("failed to close directory %s"), - quote (full_filename ("."))); + quote (full_filename ("."))); status = RM_ERROR; } @@ -1771,9 +1774,9 @@ rm_1 (Dirstack_state *ds, char const *filename, if (dot_or_dotdot (base)) { error (0, 0, _(base == filename - ? N_("cannot remove directory %s") - : N_("cannot remove %s directory %s")), - quote_n (0, base), quote_n (1, filename)); + ? N_("cannot remove directory %s") + : N_("cannot remove %s directory %s")), + quote_n (0, base), quote_n (1, filename)); return RM_ERROR; } @@ -1784,17 +1787,17 @@ rm_1 (Dirstack_state *ds, char const *filename, if (x->root_dev_ino) { if (cache_fstatat (AT_FDCWD, filename, &st, AT_SYMLINK_NOFOLLOW) != 0) - { - if (ignorable_missing (x, errno)) - return RM_OK; - error (0, errno, _("cannot remove %s"), quote (filename)); - return RM_ERROR; - } + { + if (ignorable_missing (x, errno)) + return RM_OK; + error (0, errno, _("cannot remove %s"), quote (filename)); + return RM_ERROR; + } if (SAME_INODE (st, *(x->root_dev_ino))) - { - error (0, 0, _("cannot remove root directory %s"), quote (filename)); - return RM_ERROR; - } + { + error (0, 0, _("cannot remove root directory %s"), quote (filename)); + return RM_ERROR; + } } AD_push_initial (ds); @@ -1802,16 +1805,16 @@ rm_1 (Dirstack_state *ds, char const *filename, { enum RM_status status = remove_entry (AT_FDCWD, ds, filename, - DT_UNKNOWN, &st, x); + DT_UNKNOWN, &st, x); if (status == RM_NONEMPTY_DIR) { /* In the event that remove_dir->remove_cwd_entries detects - a directory cycle, arrange to fail, give up on this FILE, but - continue on with any other arguments. */ + a directory cycle, arrange to fail, give up on this FILE, but + continue on with any other arguments. */ if (setjmp (ds->current_arg_jumpbuf)) - status = RM_ERROR; + status = RM_ERROR; else - status = remove_dir (AT_FDCWD, ds, filename, &st, x, cwd_errno); + status = remove_dir (AT_FDCWD, ds, filename, &st, x, cwd_errno); AD_stack_clear (ds); } @@ -1844,22 +1847,22 @@ rm (size_t n_files, char const *const *file, struct rm_options const *x) for (i = 0; i < n_files; i++) { if (cwd_errno && IS_RELATIVE_FILE_NAME (file[i])) - { - error (0, 0, _("cannot remove relative-named %s"), quote (file[i])); - status = RM_ERROR; - } + { + error (0, 0, _("cannot remove relative-named %s"), quote (file[i])); + status = RM_ERROR; + } else - { - enum RM_status s = rm_1 (&ds, file[i], x, &cwd_errno); - assert (VALID_STATUS (s)); - UPDATE_STATUS (status, s); - } + { + enum RM_status s = rm_1 (&ds, file[i], x, &cwd_errno); + assert (VALID_STATUS (s)); + UPDATE_STATUS (status, s); + } } if (x->require_restore_cwd && cwd_errno) { error (0, cwd_errno, - _("cannot restore current working directory")); + _("cannot restore current working directory")); status = RM_ERROR; } diff --git a/src/bin/coreutils/src/remove.h b/src/bin/coreutils/src/remove.h index 8d5fd4994a..ed1a0214e4 100644 --- a/src/bin/coreutils/src/remove.h +++ b/src/bin/coreutils/src/remove.h @@ -83,12 +83,12 @@ enum RM_status do \ { \ if ((New_value) == RM_ERROR \ - || ((New_value) == RM_USER_DECLINED && (S) == RM_OK)) \ - (S) = (New_value); \ + || ((New_value) == RM_USER_DECLINED && (S) == RM_OK)) \ + (S) = (New_value); \ } \ while (0) enum RM_status rm (size_t n_files, char const *const *file, - struct rm_options const *x); + struct rm_options const *x); #endif diff --git a/src/bin/coreutils/src/rm.c b/src/bin/coreutils/src/rm.c index dfd38c7e39..191d2c89eb 100644 --- a/src/bin/coreutils/src/rm.c +++ b/src/bin/coreutils/src/rm.c @@ -137,14 +137,14 @@ diagnose_leading_hyphen (int argc, char **argv) struct stat st; if (arg[0] == '-' && arg[1] && lstat (arg, &st) == 0) - { - fprintf (stderr, - _("Try `%s ./%s' to remove the file %s.\n"), - argv[0], - quotearg_n_style (1, shell_quoting_style, arg), - quote (arg)); - break; - } + { + fprintf (stderr, + _("Try `%s ./%s' to remove the file %s.\n"), + argv[0], + quotearg_n_style (1, shell_quoting_style, arg), + quote (arg)); + break; + } } } @@ -153,7 +153,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... FILE...\n"), program_name); @@ -196,7 +196,7 @@ use one of these commands:\n\ \n\ %s ./-foo\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ \n\ Note that if you use rm to remove a file, it is usually possible to recover\n\ @@ -248,104 +248,104 @@ main (int argc, char **argv) while ((c = getopt_long (argc, argv, "dfirvIR", long_opts, NULL)) != -1) { switch (c) - { - case 'd': - /* Ignore this option, for backward compatibility with - coreutils 5.92. FIXME: Some time after 2005, change this - to report an error (or perhaps behave like FreeBSD does) - instead of ignoring the option. */ - break; + { + case 'd': + /* Ignore this option, for backward compatibility with + coreutils 5.92. FIXME: Some time after 2005, change this + to report an error (or perhaps behave like FreeBSD does) + instead of ignoring the option. */ + break; - case 'f': - x.interactive = RMI_NEVER; - x.ignore_missing_files = true; - prompt_once = false; - break; + case 'f': + x.interactive = RMI_NEVER; + x.ignore_missing_files = true; + prompt_once = false; + break; - case 'i': - x.interactive = RMI_ALWAYS; - x.ignore_missing_files = false; - prompt_once = false; - break; + case 'i': + x.interactive = RMI_ALWAYS; + x.ignore_missing_files = false; + prompt_once = false; + break; - case 'I': - x.interactive = RMI_NEVER; - x.ignore_missing_files = false; - prompt_once = true; - break; + case 'I': + x.interactive = RMI_NEVER; + x.ignore_missing_files = false; + prompt_once = true; + break; - case 'r': - case 'R': - x.recursive = true; - break; + case 'r': + case 'R': + x.recursive = true; + break; - case INTERACTIVE_OPTION: - { - int i; - if (optarg) - i = XARGMATCH ("--interactive", optarg, interactive_args, - interactive_types); - else - i = interactive_always; - switch (i) - { - case interactive_never: - x.interactive = RMI_NEVER; - prompt_once = false; - break; + case INTERACTIVE_OPTION: + { + int i; + if (optarg) + i = XARGMATCH ("--interactive", optarg, interactive_args, + interactive_types); + else + i = interactive_always; + switch (i) + { + case interactive_never: + x.interactive = RMI_NEVER; + prompt_once = false; + break; - case interactive_once: - x.interactive = RMI_SOMETIMES; - x.ignore_missing_files = false; - prompt_once = true; - break; + case interactive_once: + x.interactive = RMI_SOMETIMES; + x.ignore_missing_files = false; + prompt_once = true; + break; - case interactive_always: - x.interactive = RMI_ALWAYS; - x.ignore_missing_files = false; - prompt_once = false; - break; - } - break; - } + case interactive_always: + x.interactive = RMI_ALWAYS; + x.ignore_missing_files = false; + prompt_once = false; + break; + } + break; + } - case ONE_FILE_SYSTEM: - x.one_file_system = true; - break; + case ONE_FILE_SYSTEM: + x.one_file_system = true; + break; - case NO_PRESERVE_ROOT: - preserve_root = false; - break; + case NO_PRESERVE_ROOT: + preserve_root = false; + break; - case PRESERVE_ROOT: - preserve_root = true; - break; + case PRESERVE_ROOT: + preserve_root = true; + break; - case PRESUME_INPUT_TTY_OPTION: - x.stdin_tty = true; - break; + case PRESUME_INPUT_TTY_OPTION: + x.stdin_tty = true; + break; - case 'v': - x.verbose = true; - break; + case 'v': + x.verbose = true; + break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - diagnose_leading_hyphen (argc, argv); - usage (EXIT_FAILURE); - } + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + diagnose_leading_hyphen (argc, argv); + usage (EXIT_FAILURE); + } } if (argc <= optind) { if (x.ignore_missing_files) - exit (EXIT_SUCCESS); + exit (EXIT_SUCCESS); else - { - error (0, 0, _("missing operand")); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("missing operand")); + usage (EXIT_FAILURE); + } } if (x.recursive & preserve_root) @@ -353,8 +353,8 @@ main (int argc, char **argv) static struct dev_ino dev_ino_buf; x.root_dev_ino = get_root_dev_ino (&dev_ino_buf); if (x.root_dev_ino == NULL) - error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), - quote ("/")); + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), + quote ("/")); } { @@ -364,12 +364,12 @@ main (int argc, char **argv) if (prompt_once && (x.recursive || 3 < n_files)) { fprintf (stderr, - (x.recursive - ? _("%s: remove all arguments recursively? ") - : _("%s: remove all arguments? ")), - program_name); + (x.recursive + ? _("%s: remove all arguments recursively? ") + : _("%s: remove all arguments? ")), + program_name); if (!yesno ()) - exit (EXIT_SUCCESS); + exit (EXIT_SUCCESS); } { enum RM_status status = rm (n_files, file, &x); diff --git a/src/bin/coreutils/src/rmdir.c b/src/bin/coreutils/src/rmdir.c index a319b1fda1..3bfff22d45 100644 --- a/src/bin/coreutils/src/rmdir.c +++ b/src/bin/coreutils/src/rmdir.c @@ -17,8 +17,8 @@ /* Options: -p, --parent Remove any parent dirs that are explicitly mentioned - in an argument, if they become empty after the - argument file is removed. + in an argument, if they become empty after the + argument file is removed. David MacKenzie */ @@ -101,9 +101,9 @@ static bool ignorable_failure (int error_number, char const *dir) { return (ignore_fail_on_non_empty - && (errno_rmdir_non_empty (error_number) - || (errno_may_be_empty (error_number) - && is_empty_dir (AT_FDCWD, dir)))); + && (errno_rmdir_non_empty (error_number) + || (errno_may_be_empty (error_number) + && is_empty_dir (AT_FDCWD, dir)))); } /* Remove any empty parent directories of DIR. @@ -122,34 +122,34 @@ remove_parents (char *dir) { slash = strrchr (dir, '/'); if (slash == NULL) - break; + break; /* Remove any characters after the slash, skipping any extra - slashes in a row. */ + slashes in a row. */ while (slash > dir && *slash == '/') - --slash; + --slash; slash[1] = 0; /* Give a diagnostic for each attempted removal if --verbose. */ if (verbose) - prog_fprintf (stdout, _("removing directory, %s"), quote (dir)); + prog_fprintf (stdout, _("removing directory, %s"), quote (dir)); ok = (rmdir (dir) == 0); if (!ok) - { - /* Stop quietly if --ignore-fail-on-non-empty. */ - if (ignorable_failure (errno, dir)) - { - ok = true; - } - else - { - /* Barring race conditions, DIR is expected to be a directory. */ - error (0, errno, _("failed to remove directory %s"), - quote (dir)); - } - break; - } + { + /* Stop quietly if --ignore-fail-on-non-empty. */ + if (ignorable_failure (errno, dir)) + { + ok = true; + } + else + { + /* Barring race conditions, DIR is expected to be a directory. */ + error (0, errno, _("failed to remove directory %s"), + quote (dir)); + } + break; + } } return ok; } @@ -159,7 +159,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... DIRECTORY...\n"), program_name); @@ -201,21 +201,21 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "pv", longopts, NULL)) != -1) { switch (optc) - { - case 'p': - remove_empty_parents = true; - break; - case IGNORE_FAIL_ON_NON_EMPTY_OPTION: - ignore_fail_on_non_empty = true; - break; - case 'v': - verbose = true; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + { + case 'p': + remove_empty_parents = true; + break; + case IGNORE_FAIL_ON_NON_EMPTY_OPTION: + ignore_fail_on_non_empty = true; + break; + case 'v': + verbose = true; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (optind == argc) @@ -230,22 +230,22 @@ main (int argc, char **argv) /* Give a diagnostic for each attempted removal if --verbose. */ if (verbose) - prog_fprintf (stdout, _("removing directory, %s"), quote (dir)); + prog_fprintf (stdout, _("removing directory, %s"), quote (dir)); if (rmdir (dir) != 0) - { - if (ignorable_failure (errno, dir)) - continue; + { + if (ignorable_failure (errno, dir)) + continue; - /* Here, the diagnostic is less precise, since we have no idea - whether DIR is a directory. */ - error (0, errno, _("failed to remove %s"), quote (dir)); - ok = false; - } + /* Here, the diagnostic is less precise, since we have no idea + whether DIR is a directory. */ + error (0, errno, _("failed to remove %s"), quote (dir)); + ok = false; + } else if (remove_empty_parents) - { - ok &= remove_parents (dir); - } + { + ok &= remove_parents (dir); + } } exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); diff --git a/src/bin/coreutils/src/runcon.c b/src/bin/coreutils/src/runcon.c index 2331f938b2..7bf256821d 100644 --- a/src/bin/coreutils/src/runcon.c +++ b/src/bin/coreutils/src/runcon.c @@ -78,7 +78,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -131,47 +131,47 @@ main (int argc, char **argv) { int option_index = 0; int c = getopt_long (argc, argv, "+r:t:u:l:c", long_options, - &option_index); + &option_index); if (c == -1) - break; + break; switch (c) - { - case 'r': - if (role) - error (EXIT_FAILURE, 0, _("multiple roles")); - role = optarg; - break; - case 't': - if (type) - error (EXIT_FAILURE, 0, _("multiple types")); - type = optarg; - break; - case 'u': - if (user) - error (EXIT_FAILURE, 0, _("multiple users")); - user = optarg; - break; - case 'l': - if (range) - error (EXIT_FAILURE, 0, _("multiple levelranges")); - range = optarg; - break; - case 'c': - compute_trans = true; - break; + { + case 'r': + if (role) + error (EXIT_FAILURE, 0, _("multiple roles")); + role = optarg; + break; + case 't': + if (type) + error (EXIT_FAILURE, 0, _("multiple types")); + type = optarg; + break; + case 'u': + if (user) + error (EXIT_FAILURE, 0, _("multiple users")); + user = optarg; + break; + case 'l': + if (range) + error (EXIT_FAILURE, 0, _("multiple levelranges")); + range = optarg; + break; + case 'c': + compute_trans = true; + break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - break; - } + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + break; + } } if (argc - optind == 0) { if (getcon (&cur_context) < 0) - error (EXIT_FAILURE, errno, _("failed to get current context")); + error (EXIT_FAILURE, errno, _("failed to get current context")); fputs (cur_context, stdout); fputc ('\n', stdout); exit (EXIT_SUCCESS); @@ -180,10 +180,10 @@ main (int argc, char **argv) if (!(user || role || type || range || compute_trans)) { if (optind >= argc) - { - error (0, 0, _("you must specify -c, -t, -u, -l, -r, or context")); - usage (1); - } + { + error (0, 0, _("you must specify -c, -t, -u, -l, -r, or context")); + usage (1); + } context = argv[optind++]; } @@ -195,62 +195,62 @@ main (int argc, char **argv) if (is_selinux_enabled () != 1) error (EXIT_FAILURE, 0, - _("runcon may be used only on a SELinux kernel")); + _("runcon may be used only on a SELinux kernel")); if (context) { con = context_new (context); if (!con) - error (EXIT_FAILURE, errno, _("failed to create security context: %s"), - quotearg_colon (context)); + error (EXIT_FAILURE, errno, _("failed to create security context: %s"), + quotearg_colon (context)); } else { if (getcon (&cur_context) < 0) - error (EXIT_FAILURE, errno, _("failed to get current context")); + error (EXIT_FAILURE, errno, _("failed to get current context")); /* We will generate context based on process transition */ if (compute_trans) - { - /* Get context of file to be executed */ - if (getfilecon (argv[optind], &file_context) == -1) - error (EXIT_FAILURE, errno, - _("failed to get security context of %s"), - quote (argv[optind])); - /* compute result of process transition */ - if (security_compute_create (cur_context, file_context, - SECCLASS_PROCESS, &new_context) != 0) - error (EXIT_FAILURE, errno, - _("failed to compute a new context")); - /* free contexts */ - freecon (file_context); - freecon (cur_context); + { + /* Get context of file to be executed */ + if (getfilecon (argv[optind], &file_context) == -1) + error (EXIT_FAILURE, errno, + _("failed to get security context of %s"), + quote (argv[optind])); + /* compute result of process transition */ + if (security_compute_create (cur_context, file_context, + SECCLASS_PROCESS, &new_context) != 0) + error (EXIT_FAILURE, errno, + _("failed to compute a new context")); + /* free contexts */ + freecon (file_context); + freecon (cur_context); - /* set cur_context equal to new_context */ - cur_context = new_context; - } + /* set cur_context equal to new_context */ + cur_context = new_context; + } con = context_new (cur_context); if (!con) - error (EXIT_FAILURE, errno, _("failed to create security context: %s"), - quotearg_colon (cur_context)); + error (EXIT_FAILURE, errno, _("failed to create security context: %s"), + quotearg_colon (cur_context)); if (user && context_user_set (con, user)) - error (EXIT_FAILURE, errno, _("failed to set new user %s"), user); + error (EXIT_FAILURE, errno, _("failed to set new user %s"), user); if (type && context_type_set (con, type)) - error (EXIT_FAILURE, errno, _("failed to set new type %s"), type); + error (EXIT_FAILURE, errno, _("failed to set new type %s"), type); if (range && context_range_set (con, range)) - error (EXIT_FAILURE, errno, _("failed to set new range %s"), range); + error (EXIT_FAILURE, errno, _("failed to set new range %s"), range); if (role && context_role_set (con, role)) - error (EXIT_FAILURE, errno, _("failed to set new role %s"), role); + error (EXIT_FAILURE, errno, _("failed to set new role %s"), role); } if (security_check_context (context_str (con)) < 0) error (EXIT_FAILURE, errno, _("invalid context: %s"), - quotearg_colon (context_str (con))); + quotearg_colon (context_str (con))); if (setexeccon (context_str (con)) != 0) error (EXIT_FAILURE, errno, _("unable to set security context %s"), - quote (context_str (con))); + quote (context_str (con))); if (cur_context != NULL) freecon (cur_context); diff --git a/src/bin/coreutils/src/seq.c b/src/bin/coreutils/src/seq.c index 1ec2725398..e47de58133 100644 --- a/src/bin/coreutils/src/seq.c +++ b/src/bin/coreutils/src/seq.c @@ -64,7 +64,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -150,26 +150,26 @@ scan_arg (const char *arg) { char const *decimal_point = strchr (arg, '.'); if (! decimal_point) - ret.precision = 0; + ret.precision = 0; else - { - size_t fraction_len = strcspn (decimal_point + 1, "eE"); - if (fraction_len <= INT_MAX) - ret.precision = fraction_len; - ret.width += (fraction_len == 0 /* #. -> # */ - ? -1 - : (decimal_point == arg /* .# -> 0.# */ - || ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */ - } + { + size_t fraction_len = strcspn (decimal_point + 1, "eE"); + if (fraction_len <= INT_MAX) + ret.precision = fraction_len; + ret.width += (fraction_len == 0 /* #. -> # */ + ? -1 + : (decimal_point == arg /* .# -> 0.# */ + || ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */ + } { char const *e = strchr (arg, 'e'); if (! e) - e = strchr (arg, 'E'); + e = strchr (arg, 'E'); if (e) - { - long exponent = strtol (e + 1, NULL, 10); - ret.precision += exponent < 0 ? -exponent : 0; - } + { + long exponent = strtol (e + 1, NULL, 10); + ret.precision += exponent < 0 ? -exponent : 0; + } } } @@ -193,8 +193,8 @@ long_double_format (char const *fmt, struct layout *layout) for (i = 0; ! (fmt[i] == '%' && fmt[i + 1] != '%'); i += (fmt[i] == '%') + 1) { if (!fmt[i]) - error (EXIT_FAILURE, 0, - _("format %s has no %% directive"), quote (fmt)); + error (EXIT_FAILURE, 0, + _("format %s has no %% directive"), quote (fmt)); prefix_len++; } @@ -214,25 +214,25 @@ long_double_format (char const *fmt, struct layout *layout) error (EXIT_FAILURE, 0, _("format %s ends in %%"), quote (fmt)); if (! strchr ("efgaEFGA", fmt[i])) error (EXIT_FAILURE, 0, - _("format %s has unknown %%%c directive"), quote (fmt), fmt[i]); + _("format %s has unknown %%%c directive"), quote (fmt), fmt[i]); for (i++; ; i += (fmt[i] == '%') + 1) if (fmt[i] == '%' && fmt[i + 1] != '%') error (EXIT_FAILURE, 0, _("format %s has too many %% directives"), - quote (fmt)); + quote (fmt)); else if (fmt[i]) suffix_len++; else { - size_t format_size = i + 1; - char *ldfmt = xmalloc (format_size + 1); - memcpy (ldfmt, fmt, length_modifier_offset); - ldfmt[length_modifier_offset] = 'L'; - strcpy (ldfmt + length_modifier_offset + 1, - fmt + length_modifier_offset + has_L); - layout->prefix_len = prefix_len; - layout->suffix_len = suffix_len; - return ldfmt; + size_t format_size = i + 1; + char *ldfmt = xmalloc (format_size + 1); + memcpy (ldfmt, fmt, length_modifier_offset); + ldfmt[length_modifier_offset] = 'L'; + strcpy (ldfmt + length_modifier_offset + 1, + fmt + length_modifier_offset + has_L); + layout->prefix_len = prefix_len; + layout->suffix_len = suffix_len; + return ldfmt; } } @@ -241,7 +241,7 @@ long_double_format (char const *fmt, struct layout *layout) static void print_numbers (char const *fmt, struct layout layout, - long double first, long double step, long double last) + long double first, long double step, long double last) { bool out_of_range = (step < 0 ? first < last : last < first); @@ -251,51 +251,51 @@ print_numbers (char const *fmt, struct layout layout, long double i; for (i = 1; ; i++) - { - long double x0 = x; - printf (fmt, x); - if (out_of_range) - break; - x = first + i * step; - out_of_range = (step < 0 ? x < last : last < x); + { + long double x0 = x; + printf (fmt, x); + if (out_of_range) + break; + x = first + i * step; + out_of_range = (step < 0 ? x < last : last < x); - if (out_of_range) - { - /* If the number just past LAST prints as a value equal - to LAST, and prints differently from the previous - number, then print the number. This avoids problems - with rounding. For example, with the x86 it causes - "seq 0 0.000001 0.000003" to print 0.000003 instead - of stopping at 0.000002. */ + if (out_of_range) + { + /* If the number just past LAST prints as a value equal + to LAST, and prints differently from the previous + number, then print the number. This avoids problems + with rounding. For example, with the x86 it causes + "seq 0 0.000001 0.000003" to print 0.000003 instead + of stopping at 0.000002. */ - bool print_extra_number = false; - long double x_val; - char *x_str; - int x_strlen; - setlocale (LC_NUMERIC, "C"); - x_strlen = asprintf (&x_str, fmt, x); - setlocale (LC_NUMERIC, ""); - if (x_strlen < 0) - xalloc_die (); - x_str[x_strlen - layout.suffix_len] = '\0'; + bool print_extra_number = false; + long double x_val; + char *x_str; + int x_strlen; + setlocale (LC_NUMERIC, "C"); + x_strlen = asprintf (&x_str, fmt, x); + setlocale (LC_NUMERIC, ""); + if (x_strlen < 0) + xalloc_die (); + x_str[x_strlen - layout.suffix_len] = '\0'; - if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, c_strtold) - && x_val == last) - { - char *x0_str = NULL; - if (asprintf (&x0_str, fmt, x0) < 0) - xalloc_die (); - print_extra_number = !STREQ (x0_str, x_str); - free (x0_str); - } + if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, c_strtold) + && x_val == last) + { + char *x0_str = NULL; + if (asprintf (&x0_str, fmt, x0) < 0) + xalloc_die (); + print_extra_number = !STREQ (x0_str, x_str); + free (x0_str); + } - free (x_str); - if (! print_extra_number) - break; - } + free (x_str); + if (! print_extra_number) + break; + } - fputs (separator, stdout); - } + fputs (separator, stdout); + } fputs (terminator, stdout); } @@ -312,30 +312,30 @@ get_default_format (operand first, operand step, operand last) if (prec != INT_MAX && last.precision != INT_MAX) { if (equal_width) - { - /* increase first_width by any increased precision in step */ - size_t first_width = first.width + (prec - first.precision); - /* adjust last_width to use precision from first/step */ - size_t last_width = last.width + (prec - last.precision); - if (last.precision && prec == 0) - last_width--; /* don't include space for '.' */ - if (last.precision == 0 && prec) - last_width++; /* include space for '.' */ - { - size_t width = MAX (first_width, last_width); - if (width <= INT_MAX) - { - int w = width; - sprintf (format_buf, "%%0%d.%dLf", w, prec); - return format_buf; - } - } - } + { + /* increase first_width by any increased precision in step */ + size_t first_width = first.width + (prec - first.precision); + /* adjust last_width to use precision from first/step */ + size_t last_width = last.width + (prec - last.precision); + if (last.precision && prec == 0) + last_width--; /* don't include space for '.' */ + if (last.precision == 0 && prec) + last_width++; /* include space for '.' */ + { + size_t width = MAX (first_width, last_width); + if (width <= INT_MAX) + { + int w = width; + sprintf (format_buf, "%%0%d.%dLf", w, prec); + return format_buf; + } + } + } else - { - sprintf (format_buf, "%%.%dLf", prec); - return format_buf; - } + { + sprintf (format_buf, "%%.%dLf", prec); + return format_buf; + } } return "%Lg"; @@ -370,37 +370,37 @@ main (int argc, char **argv) while (optind < argc) { if (argv[optind][0] == '-' - && ((optc = argv[optind][1]) == '.' || ISDIGIT (optc))) - { - /* means negative number */ - break; - } + && ((optc = argv[optind][1]) == '.' || ISDIGIT (optc))) + { + /* means negative number */ + break; + } optc = getopt_long (argc, argv, "+f:s:w", long_options, NULL); if (optc == -1) - break; + break; switch (optc) - { - case 'f': - format_str = optarg; - break; + { + case 'f': + format_str = optarg; + break; - case 's': - separator = optarg; - break; + case 's': + separator = optarg; + break; - case 'w': - equal_width = true; - break; + case 'w': + equal_width = 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); - } + default: + usage (EXIT_FAILURE); + } } if (argc - optind < 1) @@ -426,10 +426,10 @@ main (int argc, char **argv) last = scan_arg (argv[optind++]); if (optind < argc) - { - step = last; - last = scan_arg (argv[optind++]); - } + { + step = last; + last = scan_arg (argv[optind++]); + } } if (format_str != NULL && equal_width) diff --git a/src/bin/coreutils/src/setuidgid.c b/src/bin/coreutils/src/setuidgid.c index 7d8ca3f2ff..43aa16480f 100644 --- a/src/bin/coreutils/src/setuidgid.c +++ b/src/bin/coreutils/src/setuidgid.c @@ -214,9 +214,3 @@ main (int argc, char **argv) exit (exit_status); } } - -/* - * Local variables: - * indent-tabs-mode: nil - * End: - */ diff --git a/src/bin/coreutils/src/shred.c b/src/bin/coreutils/src/shred.c index 4497a88cae..ea0d25cd76 100644 --- a/src/bin/coreutils/src/shred.c +++ b/src/bin/coreutils/src/shred.c @@ -152,7 +152,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... FILE...\n"), program_name); @@ -282,9 +282,9 @@ static bool ignorable_sync_errno (int errno_val) { return (errno_val == EINVAL - || errno_val == EBADF - /* HP-UX does this */ - || errno_val == EISDIR); + || errno_val == EBADF + /* HP-UX does this */ + || errno_val == EISDIR); } /* Request that all data for FD be transferred to the corresponding @@ -333,13 +333,13 @@ direct_mode (int fd, bool enable) { int fd_flags = fcntl (fd, F_GETFL); if (0 < fd_flags) - { - int new_flags = (enable - ? (fd_flags | O_DIRECT) - : (fd_flags & ~O_DIRECT)); - if (new_flags != fd_flags) - fcntl (fd, F_SETFL, new_flags); - } + { + int new_flags = (enable + ? (fd_flags | O_DIRECT) + : (fd_flags & ~O_DIRECT)); + if (new_flags != fd_flags) + fcntl (fd, F_SETFL, new_flags); + } } #if HAVE_DIRECTIO && defined DIRECTIO_ON && defined DIRECTIO_OFF @@ -361,7 +361,7 @@ direct_mode (int fd, bool enable) */ static int dopass (int fd, char const *qname, off_t *sizep, int type, - struct randread_source *s, unsigned long int k, unsigned long int n) + struct randread_source *s, unsigned long int k, unsigned long int n) { off_t size = *sizep; off_t offset; /* Current file posiiton */ @@ -422,144 +422,144 @@ dopass (int fd, char const *qname, off_t *sizep, int type, /* How much to write this time? */ lim = sizeof r; if (0 <= size && size - offset < sizeof_r) - { - if (size < offset) - break; - lim = size - offset; - if (!lim) - break; - } + { + if (size < offset) + break; + lim = size - offset; + if (!lim) + break; + } if (type < 0) - randread (s, &r, lim); + randread (s, &r, lim); /* Loop to retry partial writes. */ for (soff = 0; soff < lim; soff += ssize, first_write = false) - { - ssize = write (fd, r.c + soff, lim - soff); - if (ssize <= 0) - { - if (size < 0 && (ssize == 0 || errno == ENOSPC)) - { - /* Ah, we have found the end of the file */ - *sizep = size = offset + soff; - break; - } - else - { - int errnum = errno; - char buf[INT_BUFSIZE_BOUND (uintmax_t)]; + { + ssize = write (fd, r.c + soff, lim - soff); + if (ssize <= 0) + { + if (size < 0 && (ssize == 0 || errno == ENOSPC)) + { + /* Ah, we have found the end of the file */ + *sizep = size = offset + soff; + break; + } + else + { + int errnum = errno; + char buf[INT_BUFSIZE_BOUND (uintmax_t)]; - /* If the first write of the first pass for a given file - has just failed with EINVAL, turn off direct mode I/O - and try again. This works around a bug in Linux kernel - 2.4 whereby opening with O_DIRECT would succeed for some - file system types (e.g., ext3), but any attempt to - access a file through the resulting descriptor would - fail with EINVAL. */ - if (k == 1 && first_write && errno == EINVAL) - { - direct_mode (fd, false); - ssize = 0; - continue; - } - error (0, errnum, _("%s: error writing at offset %s"), - qname, umaxtostr (offset + soff, buf)); + /* If the first write of the first pass for a given file + has just failed with EINVAL, turn off direct mode I/O + and try again. This works around a bug in Linux kernel + 2.4 whereby opening with O_DIRECT would succeed for some + file system types (e.g., ext3), but any attempt to + access a file through the resulting descriptor would + fail with EINVAL. */ + if (k == 1 && first_write && errno == EINVAL) + { + direct_mode (fd, false); + ssize = 0; + continue; + } + error (0, errnum, _("%s: error writing at offset %s"), + qname, umaxtostr (offset + soff, buf)); - /* 'shred' is often used on bad media, before throwing it - out. Thus, it shouldn't give up on bad blocks. This - code works because lim is always a multiple of - SECTOR_SIZE, except at the end. */ - { verify (sizeof r % SECTOR_SIZE == 0); } - if (errnum == EIO && 0 <= size && (soff | SECTOR_MASK) < lim) - { - size_t soff1 = (soff | SECTOR_MASK) + 1; - if (lseek (fd, offset + soff1, SEEK_SET) != -1) - { - /* Arrange to skip this block. */ - ssize = soff1 - soff; - write_error = true; - continue; - } - error (0, errno, _("%s: lseek failed"), qname); - } - return -1; - } - } - } + /* 'shred' is often used on bad media, before throwing it + out. Thus, it shouldn't give up on bad blocks. This + code works because lim is always a multiple of + SECTOR_SIZE, except at the end. */ + { verify (sizeof r % SECTOR_SIZE == 0); } + if (errnum == EIO && 0 <= size && (soff | SECTOR_MASK) < lim) + { + size_t soff1 = (soff | SECTOR_MASK) + 1; + if (lseek (fd, offset + soff1, SEEK_SET) != -1) + { + /* Arrange to skip this block. */ + ssize = soff1 - soff; + write_error = true; + continue; + } + error (0, errno, _("%s: lseek failed"), qname); + } + return -1; + } + } + } /* Okay, we have written "soff" bytes. */ if (offset > OFF_T_MAX - (off_t) soff) - { - error (0, 0, _("%s: file too large"), qname); - return -1; - } + { + error (0, 0, _("%s: file too large"), qname); + return -1; + } offset += soff; /* Time to print progress? */ if (n - && ((offset == size && *previous_human_offset) - || thresh <= (now = time (NULL)))) - { - char offset_buf[LONGEST_HUMAN_READABLE + 1]; - char size_buf[LONGEST_HUMAN_READABLE + 1]; - int human_progress_opts = (human_autoscale | human_SI - | human_base_1024 | human_B); - char const *human_offset - = human_readable (offset, offset_buf, - human_floor | human_progress_opts, 1, 1); + && ((offset == size && *previous_human_offset) + || thresh <= (now = time (NULL)))) + { + char offset_buf[LONGEST_HUMAN_READABLE + 1]; + char size_buf[LONGEST_HUMAN_READABLE + 1]; + int human_progress_opts = (human_autoscale | human_SI + | human_base_1024 | human_B); + char const *human_offset + = human_readable (offset, offset_buf, + human_floor | human_progress_opts, 1, 1); - if (offset == size - || !STREQ (previous_human_offset, human_offset)) - { - if (size < 0) - error (0, 0, _("%s: pass %lu/%lu (%s)...%s"), - qname, k, n, pass_string, human_offset); - else - { - uintmax_t off = offset; - int percent = (size == 0 - ? 100 - : (off <= TYPE_MAXIMUM (uintmax_t) / 100 - ? off * 100 / size - : off / (size / 100))); - char const *human_size - = human_readable (size, size_buf, - human_ceiling | human_progress_opts, - 1, 1); - if (offset == size) - human_offset = human_size; - error (0, 0, _("%s: pass %lu/%lu (%s)...%s/%s %d%%"), - qname, k, n, pass_string, human_offset, human_size, - percent); - } + if (offset == size + || !STREQ (previous_human_offset, human_offset)) + { + if (size < 0) + error (0, 0, _("%s: pass %lu/%lu (%s)...%s"), + qname, k, n, pass_string, human_offset); + else + { + uintmax_t off = offset; + int percent = (size == 0 + ? 100 + : (off <= TYPE_MAXIMUM (uintmax_t) / 100 + ? off * 100 / size + : off / (size / 100))); + char const *human_size + = human_readable (size, size_buf, + human_ceiling | human_progress_opts, + 1, 1); + if (offset == size) + human_offset = human_size; + error (0, 0, _("%s: pass %lu/%lu (%s)...%s/%s %d%%"), + qname, k, n, pass_string, human_offset, human_size, + percent); + } - strcpy (previous_offset_buf, human_offset); - previous_human_offset = previous_offset_buf; - thresh = now + VERBOSE_UPDATE; + strcpy (previous_offset_buf, human_offset); + previous_human_offset = previous_offset_buf; + thresh = now + VERBOSE_UPDATE; - /* - * Force periodic syncs to keep displayed progress accurate - * FIXME: Should these be present even if -v is not enabled, - * to keep the buffer cache from filling with dirty pages? - * It's a common problem with programs that do lots of writes, - * like mkfs. - */ - if (dosync (fd, qname) != 0) - { - if (errno != EIO) - return -1; - write_error = true; - } - } - } + /* + * Force periodic syncs to keep displayed progress accurate + * FIXME: Should these be present even if -v is not enabled, + * to keep the buffer cache from filling with dirty pages? + * It's a common problem with programs that do lots of writes, + * like mkfs. + */ + if (dosync (fd, qname) != 0) + { + if (errno != EIO) + return -1; + write_error = true; + } + } + } } /* Force what we just wrote to hit the media. */ if (dosync (fd, qname) != 0) { if (errno != EIO) - return -1; + return -1; write_error = true; } @@ -631,7 +631,7 @@ static int const 12, 0x111, 0x222, 0x333, 0x444, 0x666, 0x777, 0x888, 0x999, 0xBBB, 0xCCC, 0xDDD, 0xEEE, /* 4-bit */ -1, /* 1 random pass */ - /* The following patterns have the frst bit per block flipped */ + /* The following patterns have the frst bit per block flipped */ 8, 0x1000, 0x1249, 0x1492, 0x16DB, 0x1924, 0x1B6D, 0x1DB6, 0x1FFF, 14, 0x1111, 0x1222, 0x1333, 0x1444, 0x1555, 0x1666, 0x1777, 0x1888, 0x1999, 0x1AAA, 0x1BBB, 0x1CCC, 0x1DDD, 0x1EEE, @@ -668,47 +668,46 @@ genpattern (int *dest, size_t num, struct randint_source *s) { k = *p++; /* Block descriptor word */ if (!k) - { /* Loop back to the beginning */ - p = patterns; - } + { /* Loop back to the beginning */ + p = patterns; + } else if (k < 0) - { /* -k random passes */ - k = -k; - if ((size_t) k >= n) - { - randpasses += n; - n = 0; - break; - } - randpasses += k; - n -= k; - } + { /* -k random passes */ + k = -k; + if ((size_t) k >= n) + { + randpasses += n; + break; + } + randpasses += k; + n -= k; + } else if ((size_t) k <= n) - { /* Full block of patterns */ - memcpy (d, p, k * sizeof (int)); - p += k; - d += k; - n -= k; - } + { /* Full block of patterns */ + memcpy (d, p, k * sizeof (int)); + p += k; + d += k; + n -= k; + } else if (n < 2 || 3 * n < (size_t) k) - { /* Finish with random */ - randpasses += n; - break; - } + { /* Finish with random */ + randpasses += n; + break; + } else - { /* Pad out with k of the n available */ - do - { - if (n == (size_t) k || randint_choose (s, k) < n) - { - *d++ = *p; - n--; - } - p++; - } - while (n); - break; - } + { /* Pad out with k of the n available */ + do + { + if (n == (size_t) k || randint_choose (s, k) < n) + { + *d++ = *p; + n--; + } + p++; + } + while (n); + break; + } } top = num - randpasses; /* Top of initialized data */ /* assert (d == dest+top); */ @@ -738,18 +737,18 @@ genpattern (int *dest, size_t num, struct randint_source *s) for (n = 0; n < num; n++) { if (accum <= randpasses) - { - accum += num - 1; - dest[top++] = dest[n]; - dest[n] = -1; - } + { + accum += num - 1; + dest[top++] = dest[n]; + dest[n] = -1; + } else - { - swap = n + randint_choose (s, top - n); - k = dest[n]; - dest[n] = dest[swap]; - dest[swap] = k; - } + { + swap = n + randint_choose (s, top - n); + k = dest[n]; + dest[n] = dest[swap]; + dest[swap] = k; + } accum -= randpasses; } /* assert (top == num); */ @@ -761,7 +760,7 @@ genpattern (int *dest, size_t num, struct randint_source *s) */ static bool do_wipefd (int fd, char const *qname, struct randint_source *s, - struct Options const *flags) + struct Options const *flags) { size_t i; struct stat st; @@ -801,36 +800,36 @@ do_wipefd (int fd, char const *qname, struct randint_source *s, if (size == -1) { /* Accept a length of zero only if it's a regular file. - For any other type of file, try to get the size another way. */ + For any other type of file, try to get the size another way. */ if (S_ISREG (st.st_mode)) - { - size = st.st_size; - if (size < 0) - { - error (0, 0, _("%s: file has negative size"), qname); - return false; - } - } + { + size = st.st_size; + if (size < 0) + { + error (0, 0, _("%s: file has negative size"), qname); + return false; + } + } else - { - size = lseek (fd, 0, SEEK_END); - if (size <= 0) - { - /* We are unable to determine the length, up front. - Let dopass do that as part of its first iteration. */ - size = -1; - } - } + { + size = lseek (fd, 0, SEEK_END); + if (size <= 0) + { + /* We are unable to determine the length, up front. + Let dopass do that as part of its first iteration. */ + size = -1; + } + } /* Allow `rounding up' only for regular files. */ if (0 <= size && !(flags->exact) && S_ISREG (st.st_mode)) - { - size += ST_BLKSIZE (st) - 1 - (size - 1) % ST_BLKSIZE (st); + { + size += ST_BLKSIZE (st) - 1 - (size - 1) % ST_BLKSIZE (st); - /* If in rounding up, we've just overflowed, use the maximum. */ - if (size < 0) - size = TYPE_MAXIMUM (off_t); - } + /* If in rounding up, we've just overflowed, use the maximum. */ + if (size < 0) + size = TYPE_MAXIMUM (off_t); + } } /* Schedule the passes in random order. */ @@ -843,15 +842,15 @@ do_wipefd (int fd, char const *qname, struct randint_source *s, { int err = dopass (fd, qname, &size, passarray[i], rs, i + 1, n); if (err) - { - if (err < 0) - { - memset (passarray, 0, flags->n_iterations * sizeof (int)); - free (passarray); - return false; - } - ok = false; - } + { + if (err < 0) + { + memset (passarray, 0, flags->n_iterations * sizeof (int)); + free (passarray); + return false; + } + ok = false; + } } memset (passarray, 0, flags->n_iterations * sizeof (int)); @@ -861,11 +860,11 @@ do_wipefd (int fd, char const *qname, struct randint_source *s, { int err = dopass (fd, qname, &size, 0, rs, flags->n_iterations + 1, n); if (err) - { - if (err < 0) - return false; - ok = false; - } + { + if (err < 0) + return false; + ok = false; + } } /* Okay, now deallocate the data. The effect of ftruncate on @@ -884,7 +883,7 @@ do_wipefd (int fd, char const *qname, struct randint_source *s, /* A wrapper with a little more checking for fds on the command line */ static bool wipefd (int fd, char const *qname, struct randint_source *s, - struct Options const *flags) + struct Options const *flags) { int fd_flags = fcntl (fd, F_GETFL); @@ -921,10 +920,10 @@ incname (char *name, size_t len) /* If this character has a successor, use it. */ if (p[1]) - { - name[len] = p[1]; - return true; - } + { + name[len] = p[1]; + return true; + } /* Otherwise, set this digit to 0 and increment the prefix. */ name[len] = nameset[0]; @@ -980,40 +979,40 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags) memset (base, nameset[0], len); base[len] = 0; do - { - struct stat st; - if (lstat (newname, &st) < 0) - { - if (rename (oldname, newname) == 0) - { - if (0 <= dir_fd && dosync (dir_fd, qdir) != 0) - ok = false; - if (flags->verbose) - { - /* - * People seem to understand this better than talking - * about renaming oldname. newname doesn't need - * quoting because we picked it. oldname needs to - * be quoted only the first time. - */ - char const *old = (first ? qoldname : oldname); - error (0, 0, _("%s: renamed to %s"), old, newname); - first = false; - } - memcpy (oldname + (base - newname), base, len + 1); - break; - } - else - { - /* The rename failed: give up on this length. */ - break; - } - } - else - { - /* newname exists, so increment BASE so we use another */ - } - } + { + struct stat st; + if (lstat (newname, &st) < 0) + { + if (rename (oldname, newname) == 0) + { + if (0 <= dir_fd && dosync (dir_fd, qdir) != 0) + ok = false; + if (flags->verbose) + { + /* + * People seem to understand this better than talking + * about renaming oldname. newname doesn't need + * quoting because we picked it. oldname needs to + * be quoted only the first time. + */ + char const *old = (first ? qoldname : oldname); + error (0, 0, _("%s: renamed to %s"), old, newname); + first = false; + } + memcpy (oldname + (base - newname), base, len + 1); + break; + } + else + { + /* The rename failed: give up on this length. */ + break; + } + } + else + { + /* newname exists, so increment BASE so we use another */ + } + } while (incname (base, len)); len--; } @@ -1027,12 +1026,12 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags) if (0 <= dir_fd) { if (dosync (dir_fd, qdir) != 0) - ok = false; + ok = false; if (close (dir_fd) != 0) - { - error (0, errno, _("%s: failed to close"), qdir); - ok = false; - } + { + error (0, errno, _("%s: failed to close"), qdir); + ok = false; + } } free (newname); free (dir); @@ -1054,7 +1053,7 @@ wipename (char *oldname, char const *qoldname, struct Options const *flags) */ static bool wipefile (char *name, char const *qname, - struct randint_source *s, struct Options const *flags) + struct randint_source *s, struct Options const *flags) { bool ok; int fd; @@ -1120,66 +1119,66 @@ main (int argc, char **argv) while ((c = getopt_long (argc, argv, "fn:s:uvxz", long_opts, NULL)) != -1) { switch (c) - { - case 'f': - flags.force = true; - break; + { + case 'f': + flags.force = true; + break; - case 'n': - { - uintmax_t tmp; - if (xstrtoumax (optarg, NULL, 10, &tmp, NULL) != LONGINT_OK - || MIN (UINT32_MAX, SIZE_MAX / sizeof (int)) < tmp) - { - error (EXIT_FAILURE, 0, _("%s: invalid number of passes"), - quotearg_colon (optarg)); - } - flags.n_iterations = tmp; - } - break; + case 'n': + { + uintmax_t tmp; + if (xstrtoumax (optarg, NULL, 10, &tmp, NULL) != LONGINT_OK + || MIN (UINT32_MAX, SIZE_MAX / sizeof (int)) < tmp) + { + error (EXIT_FAILURE, 0, _("%s: invalid number of passes"), + quotearg_colon (optarg)); + } + flags.n_iterations = tmp; + } + break; - case RANDOM_SOURCE_OPTION: - if (random_source && !STREQ (random_source, optarg)) - error (EXIT_FAILURE, 0, _("multiple random sources specified")); - random_source = optarg; - break; + case RANDOM_SOURCE_OPTION: + if (random_source && !STREQ (random_source, optarg)) + error (EXIT_FAILURE, 0, _("multiple random sources specified")); + random_source = optarg; + break; - case 'u': - flags.remove_file = true; - break; + case 'u': + flags.remove_file = true; + break; - case 's': - { - uintmax_t tmp; - if (xstrtoumax (optarg, NULL, 0, &tmp, "cbBkKMGTPEZY0") - != LONGINT_OK) - { - error (EXIT_FAILURE, 0, _("%s: invalid file size"), - quotearg_colon (optarg)); - } - flags.size = tmp; - } - break; + case 's': + { + uintmax_t tmp; + if (xstrtoumax (optarg, NULL, 0, &tmp, "cbBkKMGTPEZY0") + != LONGINT_OK) + { + error (EXIT_FAILURE, 0, _("%s: invalid file size"), + quotearg_colon (optarg)); + } + flags.size = tmp; + } + break; - case 'v': - flags.verbose = true; - break; + case 'v': + flags.verbose = true; + break; - case 'x': - flags.exact = true; - break; + case 'x': + flags.exact = true; + break; - case 'z': - flags.zero_fill = true; - break; + case 'z': + flags.zero_fill = 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); - } + default: + usage (EXIT_FAILURE); + } } file = argv + optind; @@ -1200,14 +1199,14 @@ main (int argc, char **argv) { char *qname = xstrdup (quotearg_colon (file[i])); if (STREQ (file[i], "-")) - { - ok &= wipefd (STDOUT_FILENO, qname, randint_source, &flags); - } + { + ok &= wipefd (STDOUT_FILENO, qname, randint_source, &flags); + } else - { - /* Plain filename - Note that this overwrites *argv! */ - ok &= wipefile (file[i], qname, randint_source, &flags); - } + { + /* Plain filename - Note that this overwrites *argv! */ + ok &= wipefile (file[i], qname, randint_source, &flags); + } free (qname); } diff --git a/src/bin/coreutils/src/shuf.c b/src/bin/coreutils/src/shuf.c index 8cacf8b10f..0e61e32dd6 100644 --- a/src/bin/coreutils/src/shuf.c +++ b/src/bin/coreutils/src/shuf.c @@ -41,7 +41,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -49,7 +49,7 @@ Usage: %s [OPTION]... [FILE]\n\ or: %s -e [OPTION]... [ARG]...\n\ or: %s -i LO-HI [OPTION]...\n\ "), - program_name, program_name, program_name); + program_name, program_name, program_name); fputs (_("\ Write a random permutation of the input lines to standard output.\n\ \n\ @@ -163,27 +163,27 @@ read_input (FILE *in, char eolbyte, char ***pline) off_t file_size = instat.st_size; off_t current_offset = ftello (in); if (0 <= current_offset) - { - off_t remaining_size = - (current_offset < file_size ? file_size - current_offset : 0); - if (SIZE_MAX - 2 < remaining_size) - xalloc_die (); - next_alloc = remaining_size + 2; - } + { + off_t remaining_size = + (current_offset < file_size ? file_size - current_offset : 0); + if (SIZE_MAX - 2 < remaining_size) + xalloc_die (); + next_alloc = remaining_size + 2; + } } do { if (alloc <= used + 1) - { - if (alloc == SIZE_MAX) - xalloc_die (); - alloc = next_alloc; - next_alloc = alloc * 2; - if (next_alloc < alloc) - next_alloc = SIZE_MAX; - buf = xrealloc (buf, alloc); - } + { + if (alloc == SIZE_MAX) + xalloc_die (); + alloc = next_alloc; + next_alloc = alloc * 2; + if (next_alloc < alloc) + next_alloc = SIZE_MAX; + buf = xrealloc (buf, alloc); + } bytes_to_read = alloc - used - 1; nread = fread (buf + used, sizeof (char), bytes_to_read, in); @@ -214,24 +214,24 @@ read_input (FILE *in, char eolbyte, char ***pline) static int write_permuted_output (size_t n_lines, char * const *line, size_t lo_input, - size_t const *permutation, char eolbyte) + size_t const *permutation, char eolbyte) { size_t i; if (line) for (i = 0; i < n_lines; i++) { - char * const *p = line + permutation[i]; - size_t len = p[1] - p[0]; - if (fwrite (p[0], sizeof *p[0], len, stdout) != len) - return -1; + char * const *p = line + permutation[i]; + size_t len = p[1] - p[0]; + if (fwrite (p[0], sizeof *p[0], len, stdout) != len) + return -1; } else for (i = 0; i < n_lines; i++) { - unsigned long int n = lo_input + permutation[i]; - if (printf ("%lu%c", n, eolbyte) < 0) - return -1; + unsigned long int n = lo_input + permutation[i]; + if (printf ("%lu%c", n, eolbyte) < 0) + return -1; } return 0; @@ -269,75 +269,75 @@ main (int argc, char **argv) switch (optc) { case 'e': - echo = true; - break; + echo = true; + break; case 'i': - { - unsigned long int argval = 0; - char *p = strchr (optarg, '-'); - char const *hi_optarg = optarg; - bool invalid = !p; + { + unsigned long int argval = 0; + char *p = strchr (optarg, '-'); + char const *hi_optarg = optarg; + bool invalid = !p; - if (input_numbers_option_used (lo_input, hi_input)) - error (EXIT_FAILURE, 0, _("multiple -i options specified")); + if (input_numbers_option_used (lo_input, hi_input)) + error (EXIT_FAILURE, 0, _("multiple -i options specified")); - if (p) - { - *p = '\0'; - invalid = ((xstrtoul (optarg, NULL, 10, &argval, NULL) - != LONGINT_OK) - || SIZE_MAX < argval); - *p = '-'; - lo_input = argval; - hi_optarg = p + 1; - } + if (p) + { + *p = '\0'; + invalid = ((xstrtoul (optarg, NULL, 10, &argval, NULL) + != LONGINT_OK) + || SIZE_MAX < argval); + *p = '-'; + lo_input = argval; + hi_optarg = p + 1; + } - invalid |= ((xstrtoul (hi_optarg, NULL, 10, &argval, NULL) - != LONGINT_OK) - || SIZE_MAX < argval); - hi_input = argval; - n_lines = hi_input - lo_input + 1; - invalid |= ((lo_input <= hi_input) == (n_lines == 0)); - if (invalid) - error (EXIT_FAILURE, 0, _("invalid input range %s"), - quote (optarg)); - } - break; + invalid |= ((xstrtoul (hi_optarg, NULL, 10, &argval, NULL) + != LONGINT_OK) + || SIZE_MAX < argval); + hi_input = argval; + n_lines = hi_input - lo_input + 1; + invalid |= ((lo_input <= hi_input) == (n_lines == 0)); + if (invalid) + error (EXIT_FAILURE, 0, _("invalid input range %s"), + quote (optarg)); + } + break; case 'n': - { - unsigned long int argval; - strtol_error e = xstrtoul (optarg, NULL, 10, &argval, NULL); + { + unsigned long int argval; + strtol_error e = xstrtoul (optarg, NULL, 10, &argval, NULL); - if (e == LONGINT_OK) - head_lines = MIN (head_lines, argval); - else if (e != LONGINT_OVERFLOW) - error (EXIT_FAILURE, 0, _("invalid line count %s"), - quote (optarg)); - } - break; + if (e == LONGINT_OK) + head_lines = MIN (head_lines, argval); + else if (e != LONGINT_OVERFLOW) + error (EXIT_FAILURE, 0, _("invalid line count %s"), + quote (optarg)); + } + break; case 'o': - if (outfile && !STREQ (outfile, optarg)) - error (EXIT_FAILURE, 0, _("multiple output files specified")); - outfile = optarg; - break; + if (outfile && !STREQ (outfile, optarg)) + error (EXIT_FAILURE, 0, _("multiple output files specified")); + outfile = optarg; + break; case RANDOM_SOURCE_OPTION: - if (random_source && !STREQ (random_source, optarg)) - error (EXIT_FAILURE, 0, _("multiple random sources specified")); - random_source = optarg; - break; + if (random_source && !STREQ (random_source, optarg)) + error (EXIT_FAILURE, 0, _("multiple random sources specified")); + random_source = optarg; + break; case 'z': - eolbyte = '\0'; - break; + eolbyte = '\0'; + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: - usage (EXIT_FAILURE); + usage (EXIT_FAILURE); } n_operands = argc - optind; @@ -346,7 +346,7 @@ main (int argc, char **argv) if (echo) { if (input_numbers_option_used (lo_input, hi_input)) - error (EXIT_FAILURE, 0, _("cannot combine -e and -i options")); + error (EXIT_FAILURE, 0, _("cannot combine -e and -i options")); input_from_argv (operand, n_operands, eolbyte); n_lines = n_operands; line = operand; @@ -354,29 +354,29 @@ main (int argc, char **argv) else if (input_numbers_option_used (lo_input, hi_input)) { if (n_operands) - { - error (0, 0, _("extra operand %s\n"), quote (operand[0])); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("extra operand %s\n"), quote (operand[0])); + usage (EXIT_FAILURE); + } n_lines = hi_input - lo_input + 1; line = NULL; } else { switch (n_operands) - { - case 0: - break; + { + case 0: + break; - case 1: - if (! (STREQ (operand[0], "-") || freopen (operand[0], "r", stdin))) - error (EXIT_FAILURE, errno, "%s", operand[0]); - break; + case 1: + if (! (STREQ (operand[0], "-") || freopen (operand[0], "r", stdin))) + error (EXIT_FAILURE, errno, "%s", operand[0]); + break; - default: - error (0, 0, _("extra operand %s"), quote (operand[1])); - usage (EXIT_FAILURE); - } + default: + error (0, 0, _("extra operand %s"), quote (operand[1])); + usage (EXIT_FAILURE); + } n_lines = read_input (stdin, eolbyte, &input_lines); line = input_lines; @@ -385,7 +385,7 @@ main (int argc, char **argv) head_lines = MIN (head_lines, n_lines); randint_source = randint_all_new (random_source, - randperm_bound (head_lines, n_lines)); + randperm_bound (head_lines, n_lines)); if (! randint_source) error (EXIT_FAILURE, errno, "%s", quotearg_colon (random_source)); diff --git a/src/bin/coreutils/src/sleep.c b/src/bin/coreutils/src/sleep.c index 42a7cf9045..4c203e6214 100644 --- a/src/bin/coreutils/src/sleep.c +++ b/src/bin/coreutils/src/sleep.c @@ -40,7 +40,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -53,7 +53,7 @@ point number. Given two or more arguments, pause for the amount of time\n\ specified by the sum of their values.\n\ \n\ "), - program_name, program_name); + program_name, program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_bug_reporting_address (); @@ -112,7 +112,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); @@ -127,16 +127,16 @@ main (int argc, char **argv) double s; const char *p; if (! xstrtod (argv[i], &p, &s, c_strtod) - /* Nonnegative interval. */ - || ! (0 <= s) - /* No extra chars after the number and an optional s,m,h,d char. */ - || (*p && *(p+1)) - /* Check any suffix char and update S based on the suffix. */ - || ! apply_suffix (&s, *p)) - { - error (0, 0, _("invalid time interval %s"), quote (argv[i])); - ok = false; - } + /* Nonnegative interval. */ + || ! (0 <= s) + /* No extra chars after the number and an optional s,m,h,d char. */ + || (*p && *(p+1)) + /* Check any suffix char and update S based on the suffix. */ + || ! apply_suffix (&s, *p)) + { + error (0, 0, _("invalid time interval %s"), quote (argv[i])); + ok = false; + } seconds += s; } diff --git a/src/bin/coreutils/src/sort.c b/src/bin/coreutils/src/sort.c index af17f0547b..7a8eaaa29a 100644 --- a/src/bin/coreutils/src/sort.c +++ b/src/bin/coreutils/src/sort.c @@ -148,10 +148,10 @@ struct line struct buffer { char *buf; /* Dynamically allocated buffer, - partitioned into 3 regions: - - input data; - - unused area; - - an array of lines, in reverse order. */ + partitioned into 3 regions: + - input data; + - unused area; + - an array of lines, in reverse order. */ size_t used; /* Number of bytes used for input data. */ size_t nlines; /* Number of lines in the line array. */ size_t alloc; /* Number of bytes allocated. */ @@ -171,13 +171,13 @@ struct keyfield bool skipsblanks; /* Skip leading blanks when finding start. */ bool skipeblanks; /* Skip leading blanks when finding end. */ bool numeric; /* Flag for numeric comparison. Handle - strings of digits with optional decimal - point, but no exponential notation. */ + strings of digits with optional decimal + point, but no exponential notation. */ bool random; /* Sort by random hash of key. */ bool general_numeric; /* Flag for general, numeric comparison. - Handle numbers in exponential notation. */ + Handle numbers in exponential notation. */ bool human_numeric; /* Flag for sorting by human readable - units with either SI xor IEC prefixes. */ + units with either SI xor IEC prefixes. */ int si_present; /* Flag for checking for mixed SI and IEC. */ bool month; /* Flag for comparison by month name. */ bool reverse; /* Reverse the sense of comparison. */ @@ -310,14 +310,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ or: %s [OPTION]... --files0-from=F\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Write sorted concatenation of all FILE(s) to standard output.\n\ \n\ @@ -611,8 +611,8 @@ reap (pid_t pid) else if (0 < cpid) { if (! WIFEXITED (status) || WEXITSTATUS (status)) - error (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"), - compress_program); + error (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"), + compress_program); --nprocs; } @@ -631,11 +631,11 @@ register_proc (pid_t pid) if (! proctab) { proctab = hash_initialize (INIT_PROCTAB_SIZE, NULL, - proctab_hasher, - proctab_comparator, - free); + proctab_hasher, + proctab_comparator, + free); if (! proctab) - xalloc_die (); + xalloc_die (); } test.pid = pid; @@ -731,7 +731,7 @@ exit_cleanup (void) if (temphead) { /* Clean up any remaining temporary files in a critical section so - that a signal handler does not try to clean them too. */ + that a signal handler does not try to clean them too. */ struct cs_status cs = cs_enter (); cleanup (); cs_leave (cs); @@ -782,8 +782,8 @@ create_temp_file (int *pfd, bool survive_fd_exhaustion) if (fd < 0) { if (! (survive_fd_exhaustion && errno == EMFILE)) - error (SORT_FAILURE, errno, _("cannot create temporary file in %s"), - quote (temp_dir)); + error (SORT_FAILURE, errno, _("cannot create temporary file in %s"), + quote (temp_dir)); free (node); node = NULL; } @@ -833,18 +833,18 @@ xfclose (FILE *fp, char const *file) case STDIN_FILENO: /* Allow reading stdin from tty more than once. */ if (feof (fp)) - clearerr (fp); + clearerr (fp); break; case STDOUT_FILENO: /* Don't close stdout just yet. close_stdout does that. */ if (fflush (fp) != 0) - die (_("fflush failed"), file); + die (_("fflush failed"), file); break; default: if (fclose (fp) != 0) - die (_("close failed"), file); + die (_("close failed"), file); break; } } @@ -877,7 +877,7 @@ pipe_fork (int pipefds[2], size_t tries) while (tries--) { /* This is so the child process won't delete our temp files - if it receives a signal before exec-ing. */ + if it receives a signal before exec-ing. */ cs = cs_enter (); saved_temphead = temphead; temphead = NULL; @@ -885,19 +885,19 @@ pipe_fork (int pipefds[2], size_t tries) pid = fork (); saved_errno = errno; if (pid) - temphead = saved_temphead; + temphead = saved_temphead; cs_leave (cs); errno = saved_errno; if (0 <= pid || errno != EAGAIN) - break; + break; else - { - sleep (wait_retry); - wait_retry *= 2; - reap_some (); - } + { + sleep (wait_retry); + wait_retry *= 2; + reap_some (); + } } if (pid < 0) @@ -946,27 +946,27 @@ maybe_create_temp (FILE **pfp, pid_t *ppid, bool survive_fd_exhaustion) node->pid = pipe_fork (pipefds, MAX_FORK_TRIES_COMPRESS); if (0 < node->pid) - { - close (tempfd); - close (pipefds[0]); - tempfd = pipefds[1]; + { + close (tempfd); + close (pipefds[0]); + tempfd = pipefds[1]; - register_proc (node->pid); - } + register_proc (node->pid); + } else if (node->pid == 0) - { - close (pipefds[1]); - dup2_or_die (tempfd, STDOUT_FILENO); - close (tempfd); - dup2_or_die (pipefds[0], STDIN_FILENO); - close (pipefds[0]); + { + close (pipefds[1]); + dup2_or_die (tempfd, STDOUT_FILENO); + close (tempfd); + dup2_or_die (pipefds[0], STDIN_FILENO); + close (pipefds[0]); - if (execlp (compress_program, compress_program, (char *) NULL) < 0) - error (SORT_FAILURE, errno, _("couldn't execute %s"), - compress_program); - } + if (execlp (compress_program, compress_program, (char *) NULL) < 0) + error (SORT_FAILURE, errno, _("couldn't execute %s"), + compress_program); + } else - node->pid = 0; + node->pid = 0; } *pfp = fdopen (tempfd, "w"); @@ -1011,8 +1011,8 @@ open_temp (const char *name, pid_t pid) { case -1: if (errno != EMFILE) - error (SORT_FAILURE, errno, _("couldn't create process for %s -d"), - compress_program); + error (SORT_FAILURE, errno, _("couldn't create process for %s -d"), + compress_program); close (tempfd); errno = EMFILE; break; @@ -1026,7 +1026,7 @@ open_temp (const char *name, pid_t pid) execlp (compress_program, compress_program, "-d", (char *) NULL); error (SORT_FAILURE, errno, _("couldn't execute %s -d"), - compress_program); + compress_program); default: close (tempfd); @@ -1034,11 +1034,11 @@ open_temp (const char *name, pid_t pid) fp = fdopen (pipefds[0], "r"); if (! fp) - { - int saved_errno = errno; - close (pipefds[0]); - errno = saved_errno; - } + { + int saved_errno = errno; + close (pipefds[0]); + errno = saved_errno; + } break; } @@ -1124,23 +1124,23 @@ inittables (void) if (hard_LC_TIME) { for (i = 0; i < MONTHS_PER_YEAR; i++) - { - char const *s; - size_t s_len; - size_t j; - char *name; + { + char const *s; + size_t s_len; + size_t j; + char *name; - s = (char *) nl_langinfo (ABMON_1 + i); - s_len = strlen (s); - monthtab[i].name = name = xmalloc (s_len + 1); - monthtab[i].val = i + 1; + s = (char *) nl_langinfo (ABMON_1 + i); + s_len = strlen (s); + monthtab[i].name = name = xmalloc (s_len + 1); + monthtab[i].val = i + 1; - for (j = 0; j < s_len; j++) - name[j] = fold_toupper[to_uchar (s[j])]; - name[j] = '\0'; - } + for (j = 0; j < s_len; j++) + name[j] = fold_toupper[to_uchar (s[j])]; + name[j] = '\0'; + } qsort ((void *) monthtab, MONTHS_PER_YEAR, - sizeof *monthtab, struct_month_cmp); + sizeof *monthtab, struct_month_cmp); } #endif } @@ -1159,43 +1159,43 @@ specify_nmerge (int oi, char c, char const *s) to open. We need at least nmerge + 3 (STDIN_FILENO, STDOUT_FILENO and STDERR_FILENO). */ unsigned int max_nmerge = ((getrlimit (RLIMIT_NOFILE, &rlimit) == 0 - ? rlimit.rlim_cur - : OPEN_MAX) - - 3); + ? rlimit.rlim_cur + : OPEN_MAX) + - 3); if (e == LONGINT_OK) { nmerge = n; if (nmerge != n) - e = LONGINT_OVERFLOW; + e = LONGINT_OVERFLOW; else - { - if (nmerge < 2) - { - error (0, 0, _("invalid --%s argument %s"), - long_options[oi].name, quote(s)); - error (SORT_FAILURE, 0, - _("minimum --%s argument is %s"), - long_options[oi].name, quote("2")); - } - else if (max_nmerge < nmerge) - { - e = LONGINT_OVERFLOW; - } - else - return; - } + { + if (nmerge < 2) + { + error (0, 0, _("invalid --%s argument %s"), + long_options[oi].name, quote(s)); + error (SORT_FAILURE, 0, + _("minimum --%s argument is %s"), + long_options[oi].name, quote("2")); + } + else if (max_nmerge < nmerge) + { + e = LONGINT_OVERFLOW; + } + else + return; + } } if (e == LONGINT_OVERFLOW) { char max_nmerge_buf[INT_BUFSIZE_BOUND (unsigned int)]; error (0, 0, _("--%s argument %s too large"), - long_options[oi].name, quote(s)); + long_options[oi].name, quote(s)); error (SORT_FAILURE, 0, - _("maximum --%s argument with current rlimit is %s"), - long_options[oi].name, - uinttostr (max_nmerge, max_nmerge_buf)); + _("maximum --%s argument with current rlimit is %s"), + long_options[oi].name, + uinttostr (max_nmerge, max_nmerge_buf)); } else xstrtol_fatal (e, oi, c, long_options, s); @@ -1213,9 +1213,9 @@ specify_sort_size (int oi, char c, char const *s) if (e == LONGINT_OK && ISDIGIT (suffix[-1])) { if (n <= UINTMAX_MAX / 1024) - n *= 1024; + n *= 1024; else - e = LONGINT_OVERFLOW; + e = LONGINT_OVERFLOW; } /* A 'b' suffix means bytes; a '%' suffix means percent of memory. */ @@ -1223,38 +1223,38 @@ specify_sort_size (int oi, char c, char const *s) switch (suffix[0]) { case 'b': - e = LONGINT_OK; - break; + e = LONGINT_OK; + break; case '%': - { - double mem = physmem_total () * n / 100; + { + double mem = physmem_total () * n / 100; - /* Use "<", not "<=", to avoid problems with rounding. */ - if (mem < UINTMAX_MAX) - { - n = mem; - e = LONGINT_OK; - } - else - e = LONGINT_OVERFLOW; - } - break; + /* Use "<", not "<=", to avoid problems with rounding. */ + if (mem < UINTMAX_MAX) + { + n = mem; + e = LONGINT_OK; + } + else + e = LONGINT_OVERFLOW; + } + break; } if (e == LONGINT_OK) { /* If multiple sort sizes are specified, take the maximum, so - that option order does not matter. */ + that option order does not matter. */ if (n < sort_size) - return; + return; sort_size = n; if (sort_size == n) - { - sort_size = MAX (sort_size, MIN_SORT_SIZE); - return; - } + { + sort_size = MAX (sort_size, MIN_SORT_SIZE); + return; + } e = LONGINT_OVERFLOW; } @@ -1312,8 +1312,8 @@ default_sort_size (void) static size_t sort_buffer_size (FILE *const *fps, size_t nfps, - char *const *files, size_t nfiles, - size_t line_bytes) + char *const *files, size_t nfiles, + size_t line_bytes) { /* A bound on the input size. If zero, the bound hasn't been determined yet. */ @@ -1335,36 +1335,36 @@ sort_buffer_size (FILE *const *fps, size_t nfps, size_t worst_case; if ((i < nfps ? fstat (fileno (fps[i]), &st) - : STREQ (files[i], "-") ? fstat (STDIN_FILENO, &st) - : stat (files[i], &st)) - != 0) - die (_("stat failed"), files[i]); + : STREQ (files[i], "-") ? fstat (STDIN_FILENO, &st) + : stat (files[i], &st)) + != 0) + die (_("stat failed"), files[i]); if (S_ISREG (st.st_mode)) - file_size = st.st_size; + file_size = st.st_size; else - { - /* The file has unknown size. If the user specified a sort - buffer size, use that; otherwise, guess the size. */ - if (sort_size) - return sort_size; - file_size = INPUT_FILE_SIZE_GUESS; - } + { + /* The file has unknown size. If the user specified a sort + buffer size, use that; otherwise, guess the size. */ + if (sort_size) + return sort_size; + file_size = INPUT_FILE_SIZE_GUESS; + } if (! size_bound) - { - size_bound = sort_size; - if (! size_bound) - size_bound = default_sort_size (); - } + { + size_bound = sort_size; + if (! size_bound) + size_bound = default_sort_size (); + } /* Add the amount of memory needed to represent the worst case - where the input consists entirely of newlines followed by a - single non-newline. Check for overflow. */ + where the input consists entirely of newlines followed by a + single non-newline. Check for overflow. */ worst_case = file_size * worst_case_per_input_byte + 1; if (file_size != worst_case / worst_case_per_input_byte - || size_bound - size <= worst_case) - return size_bound; + || size_bound - size <= worst_case) + return size_bound; size += worst_case; } @@ -1387,10 +1387,10 @@ initbuf (struct buffer *buf, size_t line_bytes, size_t alloc) alloc += sizeof (struct line) - alloc % sizeof (struct line); buf->buf = malloc (alloc); if (buf->buf) - break; + break; alloc /= 2; if (alloc <= line_bytes + 1) - xalloc_die (); + xalloc_die (); } buf->line_bytes = line_bytes; @@ -1423,18 +1423,18 @@ begfield (const struct line *line, const struct keyfield *key) if (tab != TAB_DEFAULT) while (ptr < lim && sword--) { - while (ptr < lim && *ptr != tab) - ++ptr; - if (ptr < lim) - ++ptr; + while (ptr < lim && *ptr != tab) + ++ptr; + if (ptr < lim) + ++ptr; } else while (ptr < lim && sword--) { - while (ptr < lim && blanks[to_uchar (*ptr)]) - ++ptr; - while (ptr < lim && !blanks[to_uchar (*ptr)]) - ++ptr; + while (ptr < lim && blanks[to_uchar (*ptr)]) + ++ptr; + while (ptr < lim && !blanks[to_uchar (*ptr)]) + ++ptr; } /* If we're ignoring leading blanks when computing the Start @@ -1471,18 +1471,18 @@ limfield (const struct line *line, const struct keyfield *key) if (tab != TAB_DEFAULT) while (ptr < lim && eword--) { - while (ptr < lim && *ptr != tab) - ++ptr; - if (ptr < lim && (eword | echar)) - ++ptr; + while (ptr < lim && *ptr != tab) + ++ptr; + if (ptr < lim && (eword | echar)) + ++ptr; } else while (ptr < lim && eword--) { - while (ptr < lim && blanks[to_uchar (*ptr)]) - ++ptr; - while (ptr < lim && !blanks[to_uchar (*ptr)]) - ++ptr; + while (ptr < lim && blanks[to_uchar (*ptr)]) + ++ptr; + while (ptr < lim && !blanks[to_uchar (*ptr)]) + ++ptr; } #ifdef POSIX_UNSPECIFIED @@ -1522,16 +1522,16 @@ limfield (const struct line *line, const struct keyfield *key) char *newlim; newlim = memchr (ptr, tab, lim - ptr); if (newlim) - lim = newlim; + lim = newlim; } else { char *newlim; newlim = ptr; while (newlim < lim && blanks[to_uchar (*newlim)]) - ++newlim; + ++newlim; while (newlim < lim && !blanks[to_uchar (*newlim)]) - ++newlim; + ++newlim; lim = newlim; } #endif @@ -1539,10 +1539,10 @@ limfield (const struct line *line, const struct keyfield *key) if (echar != 0) /* We need to skip over a portion of the end field. */ { /* If we're ignoring leading blanks when computing the End - of the field, skip past them here. */ + of the field, skip past them here. */ if (key->skipeblanks) - while (ptr < lim && blanks[to_uchar (*ptr)]) - ++ptr; + while (ptr < lim && blanks[to_uchar (*ptr)]) + ++ptr; /* Advance PTR by ECHAR (if possible), but no further than LIM. */ ptr = MIN (lim, ptr + echar); @@ -1584,85 +1584,85 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) char *line_start = buf->nlines ? line->text + line->length : buf->buf; while (line_bytes + 1 < avail) - { - /* Read as many bytes as possible, but do not read so many - bytes that there might not be enough room for the - corresponding line array. The worst case is when the - rest of the input file consists entirely of newlines, - except that the last byte is not a newline. */ - size_t readsize = (avail - 1) / (line_bytes + 1); - size_t bytes_read = fread (ptr, 1, readsize, fp); - char *ptrlim = ptr + bytes_read; - char *p; - avail -= bytes_read; + { + /* Read as many bytes as possible, but do not read so many + bytes that there might not be enough room for the + corresponding line array. The worst case is when the + rest of the input file consists entirely of newlines, + except that the last byte is not a newline. */ + size_t readsize = (avail - 1) / (line_bytes + 1); + size_t bytes_read = fread (ptr, 1, readsize, fp); + char *ptrlim = ptr + bytes_read; + char *p; + avail -= bytes_read; - if (bytes_read != readsize) - { - if (ferror (fp)) - die (_("read failed"), file); - if (feof (fp)) - { - buf->eof = true; - if (buf->buf == ptrlim) - return false; - if (ptrlim[-1] != eol) - *ptrlim++ = eol; - } - } + if (bytes_read != readsize) + { + if (ferror (fp)) + die (_("read failed"), file); + if (feof (fp)) + { + buf->eof = true; + if (buf->buf == ptrlim) + return false; + if (ptrlim[-1] != eol) + *ptrlim++ = eol; + } + } - /* Find and record each line in the just-read input. */ - while ((p = memchr (ptr, eol, ptrlim - ptr))) - { - ptr = p + 1; - line--; - line->text = line_start; - line->length = ptr - line_start; - mergesize = MAX (mergesize, line->length); - avail -= line_bytes; + /* Find and record each line in the just-read input. */ + while ((p = memchr (ptr, eol, ptrlim - ptr))) + { + ptr = p + 1; + line--; + line->text = line_start; + line->length = ptr - line_start; + mergesize = MAX (mergesize, line->length); + avail -= line_bytes; - if (key) - { - /* Precompute the position of the first key for - efficiency. */ - line->keylim = (key->eword == SIZE_MAX - ? p - : limfield (line, key)); + if (key) + { + /* Precompute the position of the first key for + efficiency. */ + line->keylim = (key->eword == SIZE_MAX + ? p + : limfield (line, key)); - if (key->sword != SIZE_MAX) - line->keybeg = begfield (line, key); - else - { - if (key->skipsblanks) - while (blanks[to_uchar (*line_start)]) - line_start++; - line->keybeg = line_start; - } - } + if (key->sword != SIZE_MAX) + line->keybeg = begfield (line, key); + else + { + if (key->skipsblanks) + while (blanks[to_uchar (*line_start)]) + line_start++; + line->keybeg = line_start; + } + } - line_start = ptr; - } + line_start = ptr; + } - ptr = ptrlim; - if (buf->eof) - break; - } + ptr = ptrlim; + if (buf->eof) + break; + } buf->used = ptr - buf->buf; buf->nlines = buffer_linelim (buf) - line; if (buf->nlines != 0) - { - buf->left = ptr - line_start; - merge_buffer_size = mergesize + MIN_MERGE_BUFFER_SIZE; - return true; - } + { + buf->left = ptr - line_start; + merge_buffer_size = mergesize + MIN_MERGE_BUFFER_SIZE; + return true; + } { - /* The current input line is too long to fit in the buffer. - Double the buffer size and try again, keeping it properly - aligned. */ - size_t line_alloc = buf->alloc / sizeof (struct line); - buf->buf = x2nrealloc (buf->buf, &line_alloc, sizeof (struct line)); - buf->alloc = line_alloc * sizeof (struct line); + /* The current input line is too long to fit in the buffer. + Double the buffer size and try again, keeping it properly + aligned. */ + size_t line_alloc = buf->alloc / sizeof (struct line); + buf->buf = x2nrealloc (buf->buf, &line_alloc, sizeof (struct line)); + buf->alloc = line_alloc * sizeof (struct line); } } } @@ -1746,9 +1746,9 @@ find_unit_order (const char *number, struct keyfield *key) p++; if (*p == decimal_point && ISDIGIT (*(p + 1))) - p += 2; + p += 2; else if (*p == thousands_sep && ISDIGIT (*(p + 1))) - p += 2; + p += 2; } { @@ -1780,8 +1780,8 @@ human_numcompare (const char *a, const char *b, struct keyfield *key) int order_b = find_unit_order (b, key); return (order_a > order_b ? 1 - : order_a < order_b ? -1 - : strnumcmp (a, b, decimal_point, thousands_sep)); + : order_a < order_b ? -1 + : strnumcmp (a, b, decimal_point, thousands_sep)); } } @@ -1807,11 +1807,11 @@ general_numcompare (const char *sa, const char *sb) conversion errors but before numbers; sort them by internal bit-pattern, for lack of a more portable alternative. */ return (a < b ? -1 - : a > b ? 1 - : a == b ? 0 - : b == b ? -1 - : a == a ? 1 - : memcmp ((char *) &a, (char *) &b, sizeof a)); + : a > b ? 1 + : a == b ? 0 + : b == b ? -1 + : a == a ? 1 + : memcmp ((char *) &a, (char *) &b, sizeof a)); } /* Return an integer in 1..12 of the month name MONTH with length LEN. @@ -1827,9 +1827,9 @@ getmonth (char const *month, size_t len) for (;;) { if (month == monthlim) - return 0; + return 0; if (!blanks[to_uchar (*month)]) - break; + break; ++month; } @@ -1840,20 +1840,20 @@ getmonth (char const *month, size_t len) char const *n = monthtab[ix].name; for (;; m++, n++) - { - if (!*n) - return monthtab[ix].val; - if (m == monthlim || fold_toupper[to_uchar (*m)] < to_uchar (*n)) - { - hi = ix; - break; - } - else if (fold_toupper[to_uchar (*m)] > to_uchar (*n)) - { - lo = ix + 1; - break; - } - } + { + if (!*n) + return monthtab[ix].val; + if (m == monthlim || fold_toupper[to_uchar (*m)] < to_uchar (*n)) + { + hi = ix; + break; + } + else if (fold_toupper[to_uchar (*m)] > to_uchar (*n)) + { + lo = ix + 1; + break; + } + } } while (lo < hi); @@ -1885,10 +1885,10 @@ random_state (size_t i) used++; if (allocated <= i) - { - state = X2NREALLOC (state, &allocated); - s = &state[i]; - } + { + state = X2NREALLOC (state, &allocated); + s = &state[i]; + } randread (randread_source, buf, sizeof buf); md5_init_ctx (s); @@ -1904,7 +1904,7 @@ random_state (size_t i) static int cmp_hashes (char const *texta, size_t lena, - char const *textb, size_t lenb) + char const *textb, size_t lenb) { /* Try random hashes until a pair of hashes disagree. But if the first pair of random hashes agree, check whether the keys are @@ -1920,9 +1920,9 @@ cmp_hashes (char const *texta, size_t lena, md5_process_bytes (textb, lenb, &s[1]); md5_finish_ctx (&s[1], dig[1]); diff = memcmp (dig[0], dig[1], sizeof dig[0]); if (diff != 0) - break; + break; if (i == 0 && lena == lenb && memcmp (texta, textb, lena) == 0) - break; + break; } return diff; @@ -1933,7 +1933,7 @@ cmp_hashes (char const *texta, size_t lena, static int compare_random (char *restrict texta, size_t lena, - char *restrict textb, size_t lenb) + char *restrict textb, size_t lenb) { int diff; @@ -1942,32 +1942,32 @@ compare_random (char *restrict texta, size_t lena, else { /* Transform the text into the basis of comparison, so that byte - strings that would otherwise considered to be equal are - considered equal here even if their bytes differ. */ + strings that would otherwise considered to be equal are + considered equal here even if their bytes differ. */ char *buf = NULL; char stackbuf[4000]; size_t tlena = xmemxfrm (stackbuf, sizeof stackbuf, texta, lena); bool a_fits = tlena <= sizeof stackbuf; size_t tlenb = xmemxfrm ((a_fits ? stackbuf + tlena : NULL), - (a_fits ? sizeof stackbuf - tlena : 0), - textb, lenb); + (a_fits ? sizeof stackbuf - tlena : 0), + textb, lenb); if (a_fits && tlena + tlenb <= sizeof stackbuf) - buf = stackbuf; + buf = stackbuf; else - { - /* Adding 1 to the buffer size lets xmemxfrm run a bit - faster by avoiding the need for an extra buffer copy. */ - buf = xmalloc (tlena + tlenb + 1); - xmemxfrm (buf, tlena + 1, texta, lena); - xmemxfrm (buf + tlena, tlenb + 1, textb, lenb); - } + { + /* Adding 1 to the buffer size lets xmemxfrm run a bit + faster by avoiding the need for an extra buffer copy. */ + buf = xmalloc (tlena + tlenb + 1); + xmemxfrm (buf, tlena + 1, texta, lena); + xmemxfrm (buf + tlena, tlenb + 1, textb, lenb); + } diff = cmp_hashes (buf, tlena, buf + tlena, tlenb); if (buf != stackbuf) - free (buf); + free (buf); } return diff; @@ -1978,7 +1978,7 @@ compare_random (char *restrict texta, size_t lena, static int compare_version (char *restrict texta, size_t lena, - char *restrict textb, size_t lenb) + char *restrict textb, size_t lenb) { int diff; @@ -2033,147 +2033,147 @@ keycompare (const struct line *a, const struct line *b) /* Actually compare the fields. */ if (key->random) - diff = compare_random (texta, lena, textb, lenb); + diff = compare_random (texta, lena, textb, lenb); else if (key->numeric | key->general_numeric | key->human_numeric) - { - char savea = *lima, saveb = *limb; + { + char savea = *lima, saveb = *limb; - *lima = *limb = '\0'; - diff = (key->numeric ? numcompare (texta, textb) - : key->general_numeric ? general_numcompare (texta, textb) - : human_numcompare (texta, textb, key)); - *lima = savea, *limb = saveb; - } + *lima = *limb = '\0'; + diff = (key->numeric ? numcompare (texta, textb) + : key->general_numeric ? general_numcompare (texta, textb) + : human_numcompare (texta, textb, key)); + *lima = savea, *limb = saveb; + } else if (key->version) - diff = compare_version (texta, lena, textb, lenb); + diff = compare_version (texta, lena, textb, lenb); else if (key->month) - diff = getmonth (texta, lena) - getmonth (textb, lenb); + diff = getmonth (texta, lena) - getmonth (textb, lenb); /* Sorting like this may become slow, so in a simple locale the user - can select a faster sort that is similar to ascii sort. */ + can select a faster sort that is similar to ascii sort. */ else if (hard_LC_COLLATE) - { - if (ignore || translate) - { - char buf[4000]; - size_t size = lena + 1 + lenb + 1; - char *copy_a = (size <= sizeof buf ? buf : xmalloc (size)); - char *copy_b = copy_a + lena + 1; - size_t new_len_a, new_len_b, i; + { + if (ignore || translate) + { + char buf[4000]; + size_t size = lena + 1 + lenb + 1; + char *copy_a = (size <= sizeof buf ? buf : xmalloc (size)); + char *copy_b = copy_a + lena + 1; + size_t new_len_a, new_len_b, i; - /* Ignore and/or translate chars before comparing. */ - for (new_len_a = new_len_b = i = 0; i < MAX (lena, lenb); i++) - { - if (i < lena) - { - copy_a[new_len_a] = (translate - ? translate[to_uchar (texta[i])] - : texta[i]); - if (!ignore || !ignore[to_uchar (texta[i])]) - ++new_len_a; - } - if (i < lenb) - { - copy_b[new_len_b] = (translate - ? translate[to_uchar (textb[i])] - : textb [i]); - if (!ignore || !ignore[to_uchar (textb[i])]) - ++new_len_b; - } - } + /* Ignore and/or translate chars before comparing. */ + for (new_len_a = new_len_b = i = 0; i < MAX (lena, lenb); i++) + { + if (i < lena) + { + copy_a[new_len_a] = (translate + ? translate[to_uchar (texta[i])] + : texta[i]); + if (!ignore || !ignore[to_uchar (texta[i])]) + ++new_len_a; + } + if (i < lenb) + { + copy_b[new_len_b] = (translate + ? translate[to_uchar (textb[i])] + : textb [i]); + if (!ignore || !ignore[to_uchar (textb[i])]) + ++new_len_b; + } + } - diff = xmemcoll (copy_a, new_len_a, copy_b, new_len_b); + diff = xmemcoll (copy_a, new_len_a, copy_b, new_len_b); - if (sizeof buf < size) - free (copy_a); - } - else if (lena == 0) - diff = - NONZERO (lenb); - else if (lenb == 0) - goto greater; - else - diff = xmemcoll (texta, lena, textb, lenb); - } + if (sizeof buf < size) + free (copy_a); + } + else if (lena == 0) + diff = - NONZERO (lenb); + else if (lenb == 0) + goto greater; + else + diff = xmemcoll (texta, lena, textb, lenb); + } else if (ignore) - { + { #define CMP_WITH_IGNORE(A, B) \ do \ { \ - for (;;) \ - { \ - while (texta < lima && ignore[to_uchar (*texta)]) \ - ++texta; \ - while (textb < limb && ignore[to_uchar (*textb)]) \ - ++textb; \ - if (! (texta < lima && textb < limb)) \ - break; \ - diff = to_uchar (A) - to_uchar (B); \ - if (diff) \ - goto not_equal; \ - ++texta; \ - ++textb; \ - } \ - \ - diff = (texta < lima) - (textb < limb); \ + for (;;) \ + { \ + while (texta < lima && ignore[to_uchar (*texta)]) \ + ++texta; \ + while (textb < limb && ignore[to_uchar (*textb)]) \ + ++textb; \ + if (! (texta < lima && textb < limb)) \ + break; \ + diff = to_uchar (A) - to_uchar (B); \ + if (diff) \ + goto not_equal; \ + ++texta; \ + ++textb; \ + } \ + \ + diff = (texta < lima) - (textb < limb); \ } \ while (0) - if (translate) - CMP_WITH_IGNORE (translate[to_uchar (*texta)], - translate[to_uchar (*textb)]); - else - CMP_WITH_IGNORE (*texta, *textb); - } + if (translate) + CMP_WITH_IGNORE (translate[to_uchar (*texta)], + translate[to_uchar (*textb)]); + else + CMP_WITH_IGNORE (*texta, *textb); + } else if (lena == 0) - diff = - NONZERO (lenb); + diff = - NONZERO (lenb); else if (lenb == 0) - goto greater; + goto greater; else - { - if (translate) - { - while (texta < lima && textb < limb) - { - diff = (to_uchar (translate[to_uchar (*texta++)]) - - to_uchar (translate[to_uchar (*textb++)])); - if (diff) - goto not_equal; - } - } - else - { - diff = memcmp (texta, textb, MIN (lena, lenb)); - if (diff) - goto not_equal; - } - diff = lena < lenb ? -1 : lena != lenb; - } + { + if (translate) + { + while (texta < lima && textb < limb) + { + diff = (to_uchar (translate[to_uchar (*texta++)]) + - to_uchar (translate[to_uchar (*textb++)])); + if (diff) + goto not_equal; + } + } + else + { + diff = memcmp (texta, textb, MIN (lena, lenb)); + if (diff) + goto not_equal; + } + diff = lena < lenb ? -1 : lena != lenb; + } if (diff) - goto not_equal; + goto not_equal; key = key->next; if (! key) - break; + break; /* Find the beginning and limit of the next field. */ if (key->eword != SIZE_MAX) - lima = limfield (a, key), limb = limfield (b, key); + lima = limfield (a, key), limb = limfield (b, key); else - lima = a->text + a->length - 1, limb = b->text + b->length - 1; + lima = a->text + a->length - 1, limb = b->text + b->length - 1; if (key->sword != SIZE_MAX) - texta = begfield (a, key), textb = begfield (b, key); + texta = begfield (a, key), textb = begfield (b, key); else - { - texta = a->text, textb = b->text; - if (key->skipsblanks) - { - while (texta < lima && blanks[to_uchar (*texta)]) - ++texta; - while (textb < limb && blanks[to_uchar (*textb)]) - ++textb; - } - } + { + texta = a->text, textb = b->text; + if (key->skipsblanks) + { + while (texta < lima && blanks[to_uchar (*texta)]) + ++texta; + while (textb < limb && blanks[to_uchar (*textb)]) + ++textb; + } + } } } @@ -2201,7 +2201,7 @@ compare (const struct line *a, const struct line *b) { diff = keycompare (a, b); if (diff | unique | stable) - return diff; + return diff; } /* If the keys all compare equal (or no keys were specified) @@ -2238,7 +2238,7 @@ check (char const *file_name, char checkonly) bool ordered = true; initbuf (&buf, sizeof (struct line), - MAX (merge_buffer_size, sort_size)); + MAX (merge_buffer_size, sort_size)); temp.text = NULL; while (fillbuf (&buf, fp, file_name)) @@ -2247,59 +2247,59 @@ check (char const *file_name, char checkonly) struct line const *linebase = line - buf.nlines; /* Make sure the line saved from the old buffer contents is - less than or equal to the first line of the new buffer. */ + less than or equal to the first line of the new buffer. */ if (alloc && nonunique <= compare (&temp, line - 1)) - { - found_disorder: - { - if (checkonly == 'c') - { - struct line const *disorder_line = line - 1; - uintmax_t disorder_line_number = - buffer_linelim (&buf) - disorder_line + line_number; - char hr_buf[INT_BUFSIZE_BOUND (uintmax_t)]; - fprintf (stderr, _("%s: %s:%s: disorder: "), - program_name, file_name, - umaxtostr (disorder_line_number, hr_buf)); - write_bytes (disorder_line->text, disorder_line->length, - stderr, _("standard error")); - } + { + found_disorder: + { + if (checkonly == 'c') + { + struct line const *disorder_line = line - 1; + uintmax_t disorder_line_number = + buffer_linelim (&buf) - disorder_line + line_number; + char hr_buf[INT_BUFSIZE_BOUND (uintmax_t)]; + fprintf (stderr, _("%s: %s:%s: disorder: "), + program_name, file_name, + umaxtostr (disorder_line_number, hr_buf)); + write_bytes (disorder_line->text, disorder_line->length, + stderr, _("standard error")); + } - ordered = false; - break; - } - } + ordered = false; + break; + } + } /* Compare each line in the buffer with its successor. */ while (linebase < --line) - if (nonunique <= compare (line, line - 1)) - goto found_disorder; + if (nonunique <= compare (line, line - 1)) + goto found_disorder; line_number += buf.nlines; /* Save the last line of the buffer. */ if (alloc < line->length) - { - do - { - alloc *= 2; - if (! alloc) - { - alloc = line->length; - break; - } - } - while (alloc < line->length); + { + do + { + alloc *= 2; + if (! alloc) + { + alloc = line->length; + break; + } + } + while (alloc < line->length); - temp.text = xrealloc (temp.text, alloc); - } + temp.text = xrealloc (temp.text, alloc); + } memcpy (temp.text, line->text, line->length); temp.length = line->length; if (key) - { - temp.keybeg = temp.text + (line->keybeg - line->text); - temp.keylim = temp.text + (line->keylim - line->text); - } + { + temp.keybeg = temp.text + (line->keybeg - line->text); + temp.keylim = temp.text + (line->keylim - line->text); + } } xfclose (fp, file_name); @@ -2323,10 +2323,10 @@ open_input_files (struct sortfile *files, size_t nfiles, FILE ***pfps) for (i = 0; i < nfiles; i++) { fps[i] = (files[i].pid - ? open_temp (files[i].name, files[i].pid) - : stream_open (files[i].name, "r")); + ? open_temp (files[i].name, files[i].pid) + : stream_open (files[i].name, "r")); if (!fps[i]) - break; + break; } return i; @@ -2342,22 +2342,22 @@ open_input_files (struct sortfile *files, size_t nfiles, FILE ***pfps) static void mergefps (struct sortfile *files, size_t ntemps, size_t nfiles, - FILE *ofp, char const *output_file, FILE **fps) + FILE *ofp, char const *output_file, FILE **fps) { struct buffer *buffer = xnmalloc (nfiles, sizeof *buffer); - /* Input buffers for each file. */ + /* Input buffers for each file. */ struct line saved; /* Saved line storage for unique check. */ struct line const *savedline = NULL; - /* &saved if there is a saved line. */ + /* &saved if there is a saved line. */ size_t savealloc = 0; /* Size allocated for the saved line. */ struct line const **cur = xnmalloc (nfiles, sizeof *cur); - /* Current line in each line table. */ + /* Current line in each line table. */ struct line const **base = xnmalloc (nfiles, sizeof *base); - /* Base of each line table. */ + /* Base of each line table. */ size_t *ord = xnmalloc (nfiles, sizeof *ord); - /* Table representing a permutation of fps, - such that cur[ord[0]] is the smallest line - and will be next output. */ + /* Table representing a permutation of fps, + such that cur[ord[0]] is the smallest line + and will be next output. */ size_t i; size_t j; size_t t; @@ -2368,31 +2368,31 @@ mergefps (struct sortfile *files, size_t ntemps, size_t nfiles, for (i = 0; i < nfiles; ) { initbuf (&buffer[i], sizeof (struct line), - MAX (merge_buffer_size, sort_size / nfiles)); + MAX (merge_buffer_size, sort_size / nfiles)); if (fillbuf (&buffer[i], fps[i], files[i].name)) - { - struct line const *linelim = buffer_linelim (&buffer[i]); - cur[i] = linelim - 1; - base[i] = linelim - buffer[i].nlines; - i++; - } + { + struct line const *linelim = buffer_linelim (&buffer[i]); + cur[i] = linelim - 1; + base[i] = linelim - buffer[i].nlines; + i++; + } else - { - /* fps[i] is empty; eliminate it from future consideration. */ - xfclose (fps[i], files[i].name); - if (i < ntemps) - { - ntemps--; - zaptemp (files[i].name); - } - free (buffer[i].buf); - --nfiles; - for (j = i; j < nfiles; ++j) - { - files[j] = files[j + 1]; - fps[j] = fps[j + 1]; - } - } + { + /* fps[i] is empty; eliminate it from future consideration. */ + xfclose (fps[i], files[i].name); + if (i < ntemps) + { + ntemps--; + zaptemp (files[i].name); + } + free (buffer[i].buf); + --nfiles; + for (j = i; j < nfiles; ++j) + { + files[j] = files[j + 1]; + fps[j] = fps[j + 1]; + } + } } /* Set up the ord table according to comparisons among input lines. @@ -2410,112 +2410,112 @@ mergefps (struct sortfile *files, size_t ntemps, size_t nfiles, struct line const *smallest = cur[ord[0]]; /* If uniquified output is turned on, output only the first of - an identical series of lines. */ + an identical series of lines. */ if (unique) - { - if (savedline && compare (savedline, smallest)) - { - savedline = NULL; - write_bytes (saved.text, saved.length, ofp, output_file); - } - if (!savedline) - { - savedline = &saved; - if (savealloc < smallest->length) - { - do - if (! savealloc) - { - savealloc = smallest->length; - break; - } - while ((savealloc *= 2) < smallest->length); + { + if (savedline && compare (savedline, smallest)) + { + savedline = NULL; + write_bytes (saved.text, saved.length, ofp, output_file); + } + if (!savedline) + { + savedline = &saved; + if (savealloc < smallest->length) + { + do + if (! savealloc) + { + savealloc = smallest->length; + break; + } + while ((savealloc *= 2) < smallest->length); - saved.text = xrealloc (saved.text, savealloc); - } - saved.length = smallest->length; - memcpy (saved.text, smallest->text, saved.length); - if (key) - { - saved.keybeg = - saved.text + (smallest->keybeg - smallest->text); - saved.keylim = - saved.text + (smallest->keylim - smallest->text); - } - } - } + saved.text = xrealloc (saved.text, savealloc); + } + saved.length = smallest->length; + memcpy (saved.text, smallest->text, saved.length); + if (key) + { + saved.keybeg = + saved.text + (smallest->keybeg - smallest->text); + saved.keylim = + saved.text + (smallest->keylim - smallest->text); + } + } + } else - write_bytes (smallest->text, smallest->length, ofp, output_file); + write_bytes (smallest->text, smallest->length, ofp, output_file); /* Check if we need to read more lines into core. */ if (base[ord[0]] < smallest) - cur[ord[0]] = smallest - 1; + cur[ord[0]] = smallest - 1; else - { - if (fillbuf (&buffer[ord[0]], fps[ord[0]], files[ord[0]].name)) - { - struct line const *linelim = buffer_linelim (&buffer[ord[0]]); - cur[ord[0]] = linelim - 1; - base[ord[0]] = linelim - buffer[ord[0]].nlines; - } - else - { - /* We reached EOF on fps[ord[0]]. */ - for (i = 1; i < nfiles; ++i) - if (ord[i] > ord[0]) - --ord[i]; - --nfiles; - xfclose (fps[ord[0]], files[ord[0]].name); - if (ord[0] < ntemps) - { - ntemps--; - zaptemp (files[ord[0]].name); - } - free (buffer[ord[0]].buf); - for (i = ord[0]; i < nfiles; ++i) - { - fps[i] = fps[i + 1]; - files[i] = files[i + 1]; - buffer[i] = buffer[i + 1]; - cur[i] = cur[i + 1]; - base[i] = base[i + 1]; - } - for (i = 0; i < nfiles; ++i) - ord[i] = ord[i + 1]; - continue; - } - } + { + if (fillbuf (&buffer[ord[0]], fps[ord[0]], files[ord[0]].name)) + { + struct line const *linelim = buffer_linelim (&buffer[ord[0]]); + cur[ord[0]] = linelim - 1; + base[ord[0]] = linelim - buffer[ord[0]].nlines; + } + else + { + /* We reached EOF on fps[ord[0]]. */ + for (i = 1; i < nfiles; ++i) + if (ord[i] > ord[0]) + --ord[i]; + --nfiles; + xfclose (fps[ord[0]], files[ord[0]].name); + if (ord[0] < ntemps) + { + ntemps--; + zaptemp (files[ord[0]].name); + } + free (buffer[ord[0]].buf); + for (i = ord[0]; i < nfiles; ++i) + { + fps[i] = fps[i + 1]; + files[i] = files[i + 1]; + buffer[i] = buffer[i + 1]; + cur[i] = cur[i + 1]; + base[i] = base[i + 1]; + } + for (i = 0; i < nfiles; ++i) + ord[i] = ord[i + 1]; + continue; + } + } /* The new line just read in may be larger than other lines - already in main memory; push it back in the queue until we - encounter a line larger than it. Optimize for the common - case where the new line is smallest. */ + already in main memory; push it back in the queue until we + encounter a line larger than it. Optimize for the common + case where the new line is smallest. */ { - size_t lo = 1; - size_t hi = nfiles; - size_t probe = lo; - size_t ord0 = ord[0]; - size_t count_of_smaller_lines; + size_t lo = 1; + size_t hi = nfiles; + size_t probe = lo; + size_t ord0 = ord[0]; + size_t count_of_smaller_lines; - while (lo < hi) - { - int cmp = compare (cur[ord0], cur[ord[probe]]); - if (cmp < 0 || (cmp == 0 && ord0 < ord[probe])) - hi = probe; - else - lo = probe + 1; - probe = (lo + hi) / 2; - } + while (lo < hi) + { + int cmp = compare (cur[ord0], cur[ord[probe]]); + if (cmp < 0 || (cmp == 0 && ord0 < ord[probe])) + hi = probe; + else + lo = probe + 1; + probe = (lo + hi) / 2; + } - count_of_smaller_lines = lo - 1; - for (j = 0; j < count_of_smaller_lines; j++) - ord[j] = ord[j + 1]; - ord[count_of_smaller_lines] = ord0; + count_of_smaller_lines = lo - 1; + for (j = 0; j < count_of_smaller_lines; j++) + ord[j] = ord[j + 1]; + ord[count_of_smaller_lines] = ord0; } /* Free up some resources every once in a while. */ if (MAX_PROCS_BEFORE_REAP < nprocs) - reap_some (); + reap_some (); } if (unique && savedline) @@ -2544,7 +2544,7 @@ mergefps (struct sortfile *files, size_t ntemps, size_t nfiles, static size_t mergefiles (struct sortfile *files, size_t ntemps, size_t nfiles, - FILE *ofp, char const *output_file) + FILE *ofp, char const *output_file) { FILE **fps; size_t nopened = open_input_files (files, nfiles, &fps); @@ -2561,32 +2561,32 @@ mergefiles (struct sortfile *files, size_t ntemps, size_t nfiles, static inline void mergelines (struct line *t, - struct line const *lo, size_t nlo, - struct line const *hi, size_t nhi) + struct line const *lo, size_t nlo, + struct line const *hi, size_t nhi) { for (;;) if (compare (lo - 1, hi - 1) <= 0) { - *--t = *--lo; - if (! --nlo) - { - /* HI - NHI equalled T - (NLO + NHI) when this function - began. Therefore HI must equal T now, and there is no - need to copy from HI to T. */ - return; - } + *--t = *--lo; + if (! --nlo) + { + /* HI - NHI equalled T - (NLO + NHI) when this function + began. Therefore HI must equal T now, and there is no + need to copy from HI to T. */ + return; + } } else { - *--t = *--hi; - if (! --nhi) - { - do - *--t = *--lo; - while (--nlo); + *--t = *--hi; + if (! --nhi) + { + do + *--t = *--lo; + while (--nlo); - return; - } + return; + } } } @@ -2608,11 +2608,11 @@ sortlines (struct line *lines, size_t nlines, struct line *temp) if (nlines == 2) { if (0 < compare (&lines[-1], &lines[-2])) - { - struct line tmp = lines[-1]; - lines[-1] = lines[-2]; - lines[-2] = tmp; - } + { + struct line tmp = lines[-1]; + lines[-1] = lines[-2]; + lines[-2] = tmp; + } } else { @@ -2624,9 +2624,9 @@ sortlines (struct line *lines, size_t nlines, struct line *temp) sortlines (hi, nhi, temp); if (1 < nlo) - sortlines_temp (lo, nlo, sorted_lo); + sortlines_temp (lo, nlo, sorted_lo); else - sorted_lo[-1] = lo[-1]; + sorted_lo[-1] = lo[-1]; mergelines (lines, sorted_lo, nlo, hi, nhi); } @@ -2641,8 +2641,8 @@ sortlines_temp (struct line *lines, size_t nlines, struct line *temp) if (nlines == 2) { /* Declare `swap' as int, not bool, to work around a bug - - in the IBM xlc 6.0.0.0 compiler in 64-bit mode. */ + + in the IBM xlc 6.0.0.0 compiler in 64-bit mode. */ int swap = (0 < compare (&lines[-1], &lines[-2])); temp[-1] = lines[-1 - swap]; temp[-2] = lines[-2 + swap]; @@ -2657,7 +2657,7 @@ sortlines_temp (struct line *lines, size_t nlines, struct line *temp) sortlines_temp (hi, nhi, sorted_hi); if (1 < nlo) - sortlines (lo, nlo, temp); + sortlines (lo, nlo, temp); mergelines (temp, lo, nlo, sorted_hi, nhi); } @@ -2682,7 +2682,7 @@ sortlines_temp (struct line *lines, size_t nlines, struct line *temp) static size_t avoid_trashing_input (struct sortfile *files, size_t ntemps, - size_t nfiles, char const *outfile) + size_t nfiles, char const *outfile) { size_t i; bool got_outstat = false; @@ -2695,47 +2695,47 @@ avoid_trashing_input (struct sortfile *files, size_t ntemps, struct stat instat; if (outfile && STREQ (outfile, files[i].name) && !is_stdin) - same = true; + same = true; else - { - if (! got_outstat) - { - if ((outfile - ? stat (outfile, &outstat) - : fstat (STDOUT_FILENO, &outstat)) - != 0) - break; - got_outstat = true; - } + { + if (! got_outstat) + { + if ((outfile + ? stat (outfile, &outstat) + : fstat (STDOUT_FILENO, &outstat)) + != 0) + break; + got_outstat = true; + } - same = (((is_stdin - ? fstat (STDIN_FILENO, &instat) - : stat (files[i].name, &instat)) - == 0) - && SAME_INODE (instat, outstat)); - } + same = (((is_stdin + ? fstat (STDIN_FILENO, &instat) + : stat (files[i].name, &instat)) + == 0) + && SAME_INODE (instat, outstat)); + } if (same) - { - FILE *tftp; - pid_t pid; - char *temp = create_temp (&tftp, &pid); - size_t num_merged = 0; - do - { - num_merged += mergefiles (&files[i], 0, nfiles - i, tftp, temp); - files[i].name = temp; - files[i].pid = pid; + { + FILE *tftp; + pid_t pid; + char *temp = create_temp (&tftp, &pid); + size_t num_merged = 0; + do + { + num_merged += mergefiles (&files[i], 0, nfiles - i, tftp, temp); + files[i].name = temp; + files[i].pid = pid; - if (i + num_merged < nfiles) - memmove(&files[i + 1], &files[i + num_merged], - num_merged * sizeof *files); - ntemps += 1; - nfiles -= num_merged - 1;; - i += num_merged; - } - while (i < nfiles); - } + if (i + num_merged < nfiles) + memmove(&files[i + 1], &files[i + num_merged], + num_merged * sizeof *files); + ntemps += 1; + nfiles -= num_merged - 1;; + i += num_merged; + } + while (i < nfiles); + } } return nfiles; @@ -2759,7 +2759,7 @@ merge (struct sortfile *files, size_t ntemps, size_t nfiles, size_t out; /* nfiles % NMERGE; this counts input files that are left over - after all full-sized merges have been done. */ + after all full-sized merges have been done. */ size_t remainder; /* Number of easily-available slots at the next loop iteration. */ @@ -2769,40 +2769,40 @@ merge (struct sortfile *files, size_t ntemps, size_t nfiles, nmerge is bogus, increment by the maximum number of file descriptors allowed. */ for (out = in = 0; nmerge <= nfiles - in; out++) - { - FILE *tfp; - pid_t pid; - char *temp = create_temp (&tfp, &pid); - size_t num_merged = mergefiles (&files[in], MIN (ntemps, nmerge), - nmerge, tfp, temp); - ntemps -= MIN (ntemps, num_merged); - files[out].name = temp; - files[out].pid = pid; - in += num_merged; - } + { + FILE *tfp; + pid_t pid; + char *temp = create_temp (&tfp, &pid); + size_t num_merged = mergefiles (&files[in], MIN (ntemps, nmerge), + nmerge, tfp, temp); + ntemps -= MIN (ntemps, num_merged); + files[out].name = temp; + files[out].pid = pid; + in += num_merged; + } remainder = nfiles - in; cheap_slots = nmerge - out % nmerge; if (cheap_slots < remainder) - { - /* So many files remain that they can't all be put into the last - NMERGE-sized output window. Do one more merge. Merge as few - files as possible, to avoid needless I/O. */ - size_t nshortmerge = remainder - cheap_slots + 1; - FILE *tfp; - pid_t pid; - char *temp = create_temp (&tfp, &pid); - size_t num_merged = mergefiles (&files[in], MIN (ntemps, nshortmerge), - nshortmerge, tfp, temp); - ntemps -= MIN (ntemps, num_merged); - files[out].name = temp; - files[out++].pid = pid; - in += num_merged; - } + { + /* So many files remain that they can't all be put into the last + NMERGE-sized output window. Do one more merge. Merge as few + files as possible, to avoid needless I/O. */ + size_t nshortmerge = remainder - cheap_slots + 1; + FILE *tfp; + pid_t pid; + char *temp = create_temp (&tfp, &pid); + size_t num_merged = mergefiles (&files[in], MIN (ntemps, nshortmerge), + nshortmerge, tfp, temp); + ntemps -= MIN (ntemps, num_merged); + files[out].name = temp; + files[out++].pid = pid; + in += num_merged; + } /* Put the remaining input files into the last NMERGE-sized output - window, so they will be merged in the next pass. */ + window, so they will be merged in the next pass. */ memmove(&files[out], &files[in], (nfiles - in) * sizeof *files); ntemps += out; nfiles -= in - out; @@ -2821,34 +2821,34 @@ merge (struct sortfile *files, size_t ntemps, size_t nfiles, size_t nopened = open_input_files (files, nfiles, &fps); if (nopened == nfiles) - { - FILE *ofp = stream_open (output_file, "w"); - if (ofp) - { - mergefps (files, ntemps, nfiles, ofp, output_file, fps); - break; - } - if (errno != EMFILE || nopened <= 2) - die (_("open failed"), output_file); - } + { + FILE *ofp = stream_open (output_file, "w"); + if (ofp) + { + mergefps (files, ntemps, nfiles, ofp, output_file, fps); + break; + } + if (errno != EMFILE || nopened <= 2) + die (_("open failed"), output_file); + } else if (nopened <= 2) - die (_("open failed"), files[nopened].name); + die (_("open failed"), files[nopened].name); /* We ran out of file descriptors. Close one of the input - files, to gain a file descriptor. Then create a temporary - file with our spare file descriptor. Retry if that failed - (e.g., some other process could open a file between the time - we closed and tried to create). */ + files, to gain a file descriptor. Then create a temporary + file with our spare file descriptor. Retry if that failed + (e.g., some other process could open a file between the time + we closed and tried to create). */ { FILE *tfp; pid_t pid; char *temp; do - { - nopened--; - xfclose (fps[nopened], files[nopened].name); - temp = maybe_create_temp (&tfp, &pid, ! (nopened <= 2)); - } + { + nopened--; + xfclose (fps[nopened], files[nopened].name); + temp = maybe_create_temp (&tfp, &pid, ! (nopened <= 2)); + } while (!temp); /* Merge into the newly allocated temporary. */ @@ -2882,67 +2882,67 @@ sort (char * const *files, size_t nfiles, char const *output_file) FILE *fp = xfopen (file, "r"); FILE *tfp; size_t bytes_per_line = (2 * sizeof (struct line) - - sizeof (struct line) / 2); + - sizeof (struct line) / 2); if (! buf.alloc) - initbuf (&buf, bytes_per_line, - sort_buffer_size (&fp, 1, files, nfiles, bytes_per_line)); + initbuf (&buf, bytes_per_line, + sort_buffer_size (&fp, 1, files, nfiles, bytes_per_line)); buf.eof = false; files++; nfiles--; while (fillbuf (&buf, fp, file)) - { - struct line *line; - struct line *linebase; + { + struct line *line; + struct line *linebase; - if (buf.eof && nfiles - && (bytes_per_line + 1 - < (buf.alloc - buf.used - bytes_per_line * buf.nlines))) - { - /* End of file, but there is more input and buffer room. - Concatenate the next input file; this is faster in - the usual case. */ - buf.left = buf.used; - break; - } + if (buf.eof && nfiles + && (bytes_per_line + 1 + < (buf.alloc - buf.used - bytes_per_line * buf.nlines))) + { + /* End of file, but there is more input and buffer room. + Concatenate the next input file; this is faster in + the usual case. */ + buf.left = buf.used; + break; + } - line = buffer_linelim (&buf); - linebase = line - buf.nlines; - if (1 < buf.nlines) - sortlines (line, buf.nlines, linebase); - if (buf.eof && !nfiles && !ntemps && !buf.left) - { - xfclose (fp, file); - tfp = xfopen (output_file, "w"); - temp_output = output_file; - output_file_created = true; - } - else - { - ++ntemps; - temp_output = create_temp (&tfp, NULL); - } + line = buffer_linelim (&buf); + linebase = line - buf.nlines; + if (1 < buf.nlines) + sortlines (line, buf.nlines, linebase); + if (buf.eof && !nfiles && !ntemps && !buf.left) + { + xfclose (fp, file); + tfp = xfopen (output_file, "w"); + temp_output = output_file; + output_file_created = true; + } + else + { + ++ntemps; + temp_output = create_temp (&tfp, NULL); + } - do - { - line--; - write_bytes (line->text, line->length, tfp, temp_output); - if (unique) - while (linebase < line && compare (line, line - 1) == 0) - line--; - } - while (linebase < line); + do + { + line--; + write_bytes (line->text, line->length, tfp, temp_output); + if (unique) + while (linebase < line && compare (line, line - 1) == 0) + line--; + } + while (linebase < line); - xfclose (tfp, temp_output); + xfclose (tfp, temp_output); - /* Free up some resources every once in a while. */ - if (MAX_PROCS_BEFORE_REAP < nprocs) - reap_some (); + /* Free up some resources every once in a while. */ + if (MAX_PROCS_BEFORE_REAP < nprocs) + reap_some (); - if (output_file_created) - goto finish; - } + if (output_file_created) + goto finish; + } xfclose (fp, file); } @@ -2955,11 +2955,11 @@ sort (char * const *files, size_t nfiles, char const *output_file) struct tempnode *node = temphead; struct sortfile *tempfiles = xnmalloc (ntemps, sizeof *tempfiles); for (i = 0; node; i++) - { - tempfiles[i].name = node->name; - tempfiles[i].pid = node->pid; - node = node->next; - } + { + tempfiles[i].name = node->name; + tempfiles[i].pid = node->pid; + node = node->next; + } merge (tempfiles, ntemps, ntemps, output_file); free (tempfiles); } @@ -2987,7 +2987,7 @@ static void badfieldspec (char const *spec, char const *msgid) { error (SORT_FAILURE, 0, _("%s: invalid field specification %s"), - _(msgid), quote (spec)); + _(msgid), quote (spec)); abort (); } @@ -3010,32 +3010,32 @@ check_ordering_compatibility (void) for (key = keylist; key; key = key->next) if ((1 < (key->random + key->numeric + key->general_numeric + key->month - + key->version + !!key->ignore + key->human_numeric)) - || (key->random && key->translate)) + + key->version + !!key->ignore + key->human_numeric)) + || (key->random && key->translate)) { - /* The following is too big, but guaranteed to be "big enough". */ - char opts[sizeof short_options]; - char *p = opts; - if (key->ignore == nondictionary) - *p++ = 'd'; - if (key->translate) - *p++ = 'f'; - if (key->general_numeric) - *p++ = 'g'; - if (key->human_numeric) - *p++ = 'h'; - if (key->ignore == nonprinting) - *p++ = 'i'; - if (key->month) - *p++ = 'M'; - if (key->numeric) - *p++ = 'n'; - if (key->version) - *p++ = 'V'; - if (key->random) - *p++ = 'R'; - *p = '\0'; - incompatible_options (opts); + /* The following is too big, but guaranteed to be "big enough". */ + char opts[sizeof short_options]; + char *p = opts; + if (key->ignore == nondictionary) + *p++ = 'd'; + if (key->translate) + *p++ = 'f'; + if (key->general_numeric) + *p++ = 'g'; + if (key->human_numeric) + *p++ = 'h'; + if (key->ignore == nonprinting) + *p++ = 'i'; + if (key->month) + *p++ = 'M'; + if (key->numeric) + *p++ = 'n'; + if (key->version) + *p++ = 'V'; + if (key->random) + *p++ = 'R'; + *p = '\0'; + incompatible_options (opts); } } @@ -3057,7 +3057,7 @@ parse_field_count (char const *string, size_t *val, char const *msgid) case LONGINT_INVALID_SUFFIX_CHAR: *val = n; if (*val == n) - break; + break; /* Fall through. */ case LONGINT_OVERFLOW: case LONGINT_OVERFLOW | LONGINT_INVALID_SUFFIX_CHAR: @@ -3066,8 +3066,8 @@ parse_field_count (char const *string, size_t *val, char const *msgid) case LONGINT_INVALID: if (msgid) - error (SORT_FAILURE, 0, _("%s: invalid count at start of %s"), - _(msgid), quote (string)); + error (SORT_FAILURE, 0, _("%s: invalid count at start of %s"), + _(msgid), quote (string)); return NULL; } @@ -3099,49 +3099,49 @@ set_ordering (const char *s, struct keyfield *key, enum blanktype blanktype) while (*s) { switch (*s) - { - case 'b': - if (blanktype == bl_start || blanktype == bl_both) - key->skipsblanks = true; - if (blanktype == bl_end || blanktype == bl_both) - key->skipeblanks = true; - break; - case 'd': - key->ignore = nondictionary; - break; - case 'f': - key->translate = fold_toupper; - break; - case 'g': - key->general_numeric = true; - break; - case 'h': - key->human_numeric = true; - break; - case 'i': - /* Option order should not matter, so don't let -i override - -d. -d implies -i, but -i does not imply -d. */ - if (! key->ignore) - key->ignore = nonprinting; - break; - case 'M': - key->month = true; - break; - case 'n': - key->numeric = true; - break; - case 'R': - key->random = true; - break; - case 'r': - key->reverse = true; - break; - case 'V': - key->version = true; - break; - default: - return (char *) s; - } + { + case 'b': + if (blanktype == bl_start || blanktype == bl_both) + key->skipsblanks = true; + if (blanktype == bl_end || blanktype == bl_both) + key->skipeblanks = true; + break; + case 'd': + key->ignore = nondictionary; + break; + case 'f': + key->translate = fold_toupper; + break; + case 'g': + key->general_numeric = true; + break; + case 'h': + key->human_numeric = true; + break; + case 'i': + /* Option order should not matter, so don't let -i override + -d. -d implies -i, but -i does not imply -d. */ + if (! key->ignore) + key->ignore = nonprinting; + break; + case 'M': + key->month = true; + break; + case 'n': + key->numeric = true; + break; + case 'R': + key->random = true; + break; + case 'r': + key->reverse = true; + break; + case 'V': + key->version = true; + break; + default: + return (char *) s; + } ++s; } return (char *) s; @@ -3213,22 +3213,22 @@ main (int argc, char **argv) size_t i; static int const sig[] = { - /* The usual suspects. */ - SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, + /* The usual suspects. */ + SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, #ifdef SIGPOLL - SIGPOLL, + SIGPOLL, #endif #ifdef SIGPROF - SIGPROF, + SIGPROF, #endif #ifdef SIGVTALRM - SIGVTALRM, + SIGVTALRM, #endif #ifdef SIGXCPU - SIGXCPU, + SIGXCPU, #endif #ifdef SIGXFSZ - SIGXFSZ, + SIGXFSZ, #endif }; enum { nsigs = ARRAY_CARDINALITY (sig) }; @@ -3239,9 +3239,9 @@ main (int argc, char **argv) sigemptyset (&caught_signals); for (i = 0; i < nsigs; i++) { - sigaction (sig[i], NULL, &act); - if (act.sa_handler != SIG_IGN) - sigaddset (&caught_signals, sig[i]); + sigaction (sig[i], NULL, &act); + if (act.sa_handler != SIG_IGN) + sigaddset (&caught_signals, sig[i]); } act.sa_handler = sighandler; @@ -3250,14 +3250,14 @@ main (int argc, char **argv) for (i = 0; i < nsigs; i++) if (sigismember (&caught_signals, sig[i])) - sigaction (sig[i], &act, NULL); + sigaction (sig[i], &act, NULL); #else for (i = 0; i < nsigs; i++) if (signal (sig[i], SIG_IGN) != SIG_IGN) - { - signal (sig[i], sighandler); - siginterrupt (sig[i], 1); - } + { + signal (sig[i], sighandler); + siginterrupt (sig[i], 1); + } #endif } @@ -3278,256 +3278,256 @@ main (int argc, char **argv) for (;;) { /* Parse an operand as a file after "--" was seen; or if - pedantic and a file was seen, unless the POSIX version - predates 1003.1-2001 and -c was not seen and the operand is - "-o FILE" or "-oFILE". */ + pedantic and a file was seen, unless the POSIX version + predates 1003.1-2001 and -c was not seen and the operand is + "-o FILE" or "-oFILE". */ int oi = -1; if (c == -1 - || (posixly_correct && nfiles != 0 - && ! (obsolete_usage - && ! checkonly - && optind != argc - && argv[optind][0] == '-' && argv[optind][1] == 'o' - && (argv[optind][2] || optind + 1 != argc))) - || ((c = getopt_long (argc, argv, short_options, - long_options, &oi)) - == -1)) - { - if (argc <= optind) - break; - files[nfiles++] = argv[optind++]; - } + || (posixly_correct && nfiles != 0 + && ! (obsolete_usage + && ! checkonly + && optind != argc + && argv[optind][0] == '-' && argv[optind][1] == 'o' + && (argv[optind][2] || optind + 1 != argc))) + || ((c = getopt_long (argc, argv, short_options, + long_options, &oi)) + == -1)) + { + if (argc <= optind) + break; + files[nfiles++] = argv[optind++]; + } else switch (c) - { - case 1: - key = NULL; - if (optarg[0] == '+') - { - bool minus_pos_usage = (optind != argc && argv[optind][0] == '-' - && ISDIGIT (argv[optind][1])); - obsolete_usage |= minus_pos_usage & ~posixly_correct; - if (obsolete_usage) - { - /* Treat +POS1 [-POS2] as a key if possible; but silently - treat an operand as a file if it is not a valid +POS1. */ - key = key_init (&key_buf); - s = parse_field_count (optarg + 1, &key->sword, NULL); - if (s && *s == '.') - s = parse_field_count (s + 1, &key->schar, NULL); - if (! (key->sword | key->schar)) - key->sword = SIZE_MAX; - if (! s || *set_ordering (s, key, bl_start)) - key = NULL; - else - { - if (minus_pos_usage) - { - char const *optarg1 = argv[optind++]; - s = parse_field_count (optarg1 + 1, &key->eword, - N_("invalid number after `-'")); - if (*s == '.') - s = parse_field_count (s + 1, &key->echar, - N_("invalid number after `.'")); - if (*set_ordering (s, key, bl_end)) - badfieldspec (optarg1, - N_("stray character in field spec")); - } - insertkey (key); - } - } - } - if (! key) - files[nfiles++] = optarg; - break; + { + case 1: + key = NULL; + if (optarg[0] == '+') + { + bool minus_pos_usage = (optind != argc && argv[optind][0] == '-' + && ISDIGIT (argv[optind][1])); + obsolete_usage |= minus_pos_usage & ~posixly_correct; + if (obsolete_usage) + { + /* Treat +POS1 [-POS2] as a key if possible; but silently + treat an operand as a file if it is not a valid +POS1. */ + key = key_init (&key_buf); + s = parse_field_count (optarg + 1, &key->sword, NULL); + if (s && *s == '.') + s = parse_field_count (s + 1, &key->schar, NULL); + if (! (key->sword | key->schar)) + key->sword = SIZE_MAX; + if (! s || *set_ordering (s, key, bl_start)) + key = NULL; + else + { + if (minus_pos_usage) + { + char const *optarg1 = argv[optind++]; + s = parse_field_count (optarg1 + 1, &key->eword, + N_("invalid number after `-'")); + if (*s == '.') + s = parse_field_count (s + 1, &key->echar, + N_("invalid number after `.'")); + if (*set_ordering (s, key, bl_end)) + badfieldspec (optarg1, + N_("stray character in field spec")); + } + insertkey (key); + } + } + } + if (! key) + files[nfiles++] = optarg; + break; - case SORT_OPTION: - c = XARGMATCH ("--sort", optarg, sort_args, sort_types); - /* Fall through. */ - case 'b': - case 'd': - case 'f': - case 'g': - case 'h': - case 'i': - case 'M': - case 'n': - case 'r': - case 'R': - case 'V': - { - char str[2]; - str[0] = c; - str[1] = '\0'; - set_ordering (str, &gkey, bl_both); - } - break; + case SORT_OPTION: + c = XARGMATCH ("--sort", optarg, sort_args, sort_types); + /* Fall through. */ + case 'b': + case 'd': + case 'f': + case 'g': + case 'h': + case 'i': + case 'M': + case 'n': + case 'r': + case 'R': + case 'V': + { + char str[2]; + str[0] = c; + str[1] = '\0'; + set_ordering (str, &gkey, bl_both); + } + break; - case CHECK_OPTION: - c = (optarg - ? XARGMATCH ("--check", optarg, check_args, check_types) - : 'c'); - /* Fall through. */ - case 'c': - case 'C': - if (checkonly && checkonly != c) - incompatible_options ("cC"); - checkonly = c; - break; + case CHECK_OPTION: + c = (optarg + ? XARGMATCH ("--check", optarg, check_args, check_types) + : 'c'); + /* Fall through. */ + case 'c': + case 'C': + if (checkonly && checkonly != c) + incompatible_options ("cC"); + checkonly = c; + break; - case COMPRESS_PROGRAM_OPTION: - if (compress_program && !STREQ (compress_program, optarg)) - error (SORT_FAILURE, 0, _("multiple compress programs specified")); - compress_program = optarg; - break; + case COMPRESS_PROGRAM_OPTION: + if (compress_program && !STREQ (compress_program, optarg)) + error (SORT_FAILURE, 0, _("multiple compress programs specified")); + compress_program = optarg; + break; - case FILES0_FROM_OPTION: - files_from = optarg; - break; + case FILES0_FROM_OPTION: + files_from = optarg; + break; - case 'k': - key = key_init (&key_buf); + case 'k': + key = key_init (&key_buf); - /* Get POS1. */ - s = parse_field_count (optarg, &key->sword, - N_("invalid number at field start")); - if (! key->sword--) - { - /* Provoke with `sort -k0' */ - badfieldspec (optarg, N_("field number is zero")); - } - if (*s == '.') - { - s = parse_field_count (s + 1, &key->schar, - N_("invalid number after `.'")); - if (! key->schar--) - { - /* Provoke with `sort -k1.0' */ - badfieldspec (optarg, N_("character offset is zero")); - } - } - if (! (key->sword | key->schar)) - key->sword = SIZE_MAX; - s = set_ordering (s, key, bl_start); - if (*s != ',') - { - key->eword = SIZE_MAX; - key->echar = 0; - } - else - { - /* Get POS2. */ - s = parse_field_count (s + 1, &key->eword, - N_("invalid number after `,'")); - if (! key->eword--) - { - /* Provoke with `sort -k1,0' */ - badfieldspec (optarg, N_("field number is zero")); - } - if (*s == '.') - { - s = parse_field_count (s + 1, &key->echar, - N_("invalid number after `.'")); - } - s = set_ordering (s, key, bl_end); - } - if (*s) - badfieldspec (optarg, N_("stray character in field spec")); - insertkey (key); - break; + /* Get POS1. */ + s = parse_field_count (optarg, &key->sword, + N_("invalid number at field start")); + if (! key->sword--) + { + /* Provoke with `sort -k0' */ + badfieldspec (optarg, N_("field number is zero")); + } + if (*s == '.') + { + s = parse_field_count (s + 1, &key->schar, + N_("invalid number after `.'")); + if (! key->schar--) + { + /* Provoke with `sort -k1.0' */ + badfieldspec (optarg, N_("character offset is zero")); + } + } + if (! (key->sword | key->schar)) + key->sword = SIZE_MAX; + s = set_ordering (s, key, bl_start); + if (*s != ',') + { + key->eword = SIZE_MAX; + key->echar = 0; + } + else + { + /* Get POS2. */ + s = parse_field_count (s + 1, &key->eword, + N_("invalid number after `,'")); + if (! key->eword--) + { + /* Provoke with `sort -k1,0' */ + badfieldspec (optarg, N_("field number is zero")); + } + if (*s == '.') + { + s = parse_field_count (s + 1, &key->echar, + N_("invalid number after `.'")); + } + s = set_ordering (s, key, bl_end); + } + if (*s) + badfieldspec (optarg, N_("stray character in field spec")); + insertkey (key); + break; - case 'm': - mergeonly = true; - break; + case 'm': + mergeonly = true; + break; - case NMERGE_OPTION: - specify_nmerge (oi, c, optarg); - break; + case NMERGE_OPTION: + specify_nmerge (oi, c, optarg); + break; - case 'o': - if (outfile && !STREQ (outfile, optarg)) - error (SORT_FAILURE, 0, _("multiple output files specified")); - outfile = optarg; - break; + case 'o': + if (outfile && !STREQ (outfile, optarg)) + error (SORT_FAILURE, 0, _("multiple output files specified")); + outfile = optarg; + break; - case RANDOM_SOURCE_OPTION: - if (random_source && !STREQ (random_source, optarg)) - error (SORT_FAILURE, 0, _("multiple random sources specified")); - random_source = optarg; - break; + case RANDOM_SOURCE_OPTION: + if (random_source && !STREQ (random_source, optarg)) + error (SORT_FAILURE, 0, _("multiple random sources specified")); + random_source = optarg; + break; - case 's': - stable = true; - break; + case 's': + stable = true; + break; - case 'S': - specify_sort_size (oi, c, optarg); - break; + case 'S': + specify_sort_size (oi, c, optarg); + break; - case 't': - { - char newtab = optarg[0]; - if (! newtab) - error (SORT_FAILURE, 0, _("empty tab")); - if (optarg[1]) - { - if (STREQ (optarg, "\\0")) - newtab = '\0'; - else - { - /* Provoke with `sort -txx'. Complain about - "multi-character tab" instead of "multibyte tab", so - that the diagnostic's wording does not need to be - changed once multibyte characters are supported. */ - error (SORT_FAILURE, 0, _("multi-character tab %s"), - quote (optarg)); - } - } - if (tab != TAB_DEFAULT && tab != newtab) - error (SORT_FAILURE, 0, _("incompatible tabs")); - tab = newtab; - } - break; + case 't': + { + char newtab = optarg[0]; + if (! newtab) + error (SORT_FAILURE, 0, _("empty tab")); + if (optarg[1]) + { + if (STREQ (optarg, "\\0")) + newtab = '\0'; + else + { + /* Provoke with `sort -txx'. Complain about + "multi-character tab" instead of "multibyte tab", so + that the diagnostic's wording does not need to be + changed once multibyte characters are supported. */ + error (SORT_FAILURE, 0, _("multi-character tab %s"), + quote (optarg)); + } + } + if (tab != TAB_DEFAULT && tab != newtab) + error (SORT_FAILURE, 0, _("incompatible tabs")); + tab = newtab; + } + break; - case 'T': - add_temp_dir (optarg); - break; + case 'T': + add_temp_dir (optarg); + break; - case 'u': - unique = true; - break; + case 'u': + unique = true; + break; - case 'y': - /* Accept and ignore e.g. -y0 for compatibility with Solaris 2.x - through Solaris 7. It is also accepted by many non-Solaris - "sort" implementations, e.g., AIX 5.2, HP-UX 11i v2, IRIX 6.5. - -y is marked as obsolete starting with Solaris 8 (1999), but is - still accepted as of Solaris 10 prerelease (2004). + case 'y': + /* Accept and ignore e.g. -y0 for compatibility with Solaris 2.x + through Solaris 7. It is also accepted by many non-Solaris + "sort" implementations, e.g., AIX 5.2, HP-UX 11i v2, IRIX 6.5. + -y is marked as obsolete starting with Solaris 8 (1999), but is + still accepted as of Solaris 10 prerelease (2004). - Solaris 2.5.1 "sort -y 100" reads the input file "100", but - emulate Solaris 8 and 9 "sort -y 100" which ignores the "100", - and which in general ignores the argument after "-y" if it - consists entirely of digits (it can even be empty). */ - if (optarg == argv[optind - 1]) - { - char const *p; - for (p = optarg; ISDIGIT (*p); p++) - continue; - optind -= (*p != '\0'); - } - break; + Solaris 2.5.1 "sort -y 100" reads the input file "100", but + emulate Solaris 8 and 9 "sort -y 100" which ignores the "100", + and which in general ignores the argument after "-y" if it + consists entirely of digits (it can even be empty). */ + if (optarg == argv[optind - 1]) + { + char const *p; + for (p = optarg; ISDIGIT (*p); p++) + continue; + optind -= (*p != '\0'); + } + break; - case 'z': - eolchar = 0; - break; + case 'z': + eolchar = 0; + 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 (SORT_FAILURE); - } + default: + usage (SORT_FAILURE); + } } if (files_from) @@ -3535,74 +3535,74 @@ main (int argc, char **argv) FILE *stream; /* When using --files0-from=F, you may not specify any files - on the command-line. */ + on the command-line. */ if (nfiles) - { - error (0, 0, _("extra operand %s"), quote (files[0])); - fprintf (stderr, "%s\n", - _("file operands cannot be combined with --files0-from")); - usage (SORT_FAILURE); - } + { + error (0, 0, _("extra operand %s"), quote (files[0])); + fprintf (stderr, "%s\n", + _("file operands cannot be combined with --files0-from")); + usage (SORT_FAILURE); + } if (STREQ (files_from, "-")) - stream = stdin; + stream = stdin; else - { - stream = fopen (files_from, "r"); - if (stream == NULL) - error (SORT_FAILURE, errno, _("cannot open %s for reading"), - quote (files_from)); - } + { + stream = fopen (files_from, "r"); + if (stream == NULL) + error (SORT_FAILURE, errno, _("cannot open %s for reading"), + quote (files_from)); + } readtokens0_init (&tok); if (! readtokens0 (stream, &tok) || fclose (stream) != 0) - error (SORT_FAILURE, 0, _("cannot read file names from %s"), - quote (files_from)); + error (SORT_FAILURE, 0, _("cannot read file names from %s"), + quote (files_from)); if (tok.n_tok) - { - size_t i; - free (files); - files = tok.tok; - nfiles = tok.n_tok; - for (i = 0; i < nfiles; i++) - { - if (STREQ (files[i], "-")) - error (SORT_FAILURE, 0, _("when reading file names from stdin, " - "no file name of %s allowed"), - quote (files[i])); - else if (files[i][0] == '\0') - { - /* Using the standard `filename:line-number:' prefix here is - not totally appropriate, since NUL is the separator, not NL, - but it might be better than nothing. */ - unsigned long int file_number = i + 1; - error (SORT_FAILURE, 0, - _("%s:%lu: invalid zero-length file name"), - quotearg_colon (files_from), file_number); - } - } - } + { + size_t i; + free (files); + files = tok.tok; + nfiles = tok.n_tok; + for (i = 0; i < nfiles; i++) + { + if (STREQ (files[i], "-")) + error (SORT_FAILURE, 0, _("when reading file names from stdin, " + "no file name of %s allowed"), + quote (files[i])); + else if (files[i][0] == '\0') + { + /* Using the standard `filename:line-number:' prefix here is + not totally appropriate, since NUL is the separator, not NL, + but it might be better than nothing. */ + unsigned long int file_number = i + 1; + error (SORT_FAILURE, 0, + _("%s:%lu: invalid zero-length file name"), + quotearg_colon (files_from), file_number); + } + } + } else - error (SORT_FAILURE, 0, _("no input from %s"), - quote (files_from)); + error (SORT_FAILURE, 0, _("no input from %s"), + quote (files_from)); } /* Inheritance of global options to individual keys. */ for (key = keylist; key; key = key->next) { if (! (key->ignore - || key->translate - || (key->skipsblanks - | key->reverse - | key->skipeblanks - | key->month - | key->numeric - | key->version - | key->general_numeric - | key->human_numeric - | key->random))) + || key->translate + || (key->skipsblanks + | key->reverse + | key->skipeblanks + | key->month + | key->numeric + | key->version + | key->general_numeric + | key->human_numeric + | key->random))) { key->ignore = gkey.ignore; key->translate = gkey.translate; @@ -3621,15 +3621,15 @@ main (int argc, char **argv) } if (!keylist && (gkey.ignore - || gkey.translate - || (gkey.skipsblanks - | gkey.skipeblanks - | gkey.month - | gkey.numeric - | gkey.general_numeric - | gkey.human_numeric - | gkey.random - | gkey.version))) + || gkey.translate + || (gkey.skipsblanks + | gkey.skipeblanks + | gkey.month + | gkey.numeric + | gkey.general_numeric + | gkey.human_numeric + | gkey.random + | gkey.version))) { insertkey (&gkey); need_random |= gkey.random; @@ -3643,7 +3643,7 @@ main (int argc, char **argv) { randread_source = randread_new (random_source, MD5_DIGEST_SIZE); if (! randread_source) - die (_("open failed"), random_source); + die (_("open failed"), random_source); } if (temp_dir_count == 0) @@ -3668,18 +3668,18 @@ main (int argc, char **argv) if (checkonly) { if (nfiles > 1) - error (SORT_FAILURE, 0, _("extra operand %s not allowed with -%c"), - quote (files[1]), checkonly); + error (SORT_FAILURE, 0, _("extra operand %s not allowed with -%c"), + quote (files[1]), checkonly); if (outfile) - { - static char opts[] = {0, 'o', 0}; - opts[0] = checkonly; - incompatible_options (opts); - } + { + static char opts[] = {0, 'o', 0}; + opts[0] = checkonly; + incompatible_options (opts); + } /* POSIX requires that sort return 1 IFF invoked with -c or -C and the - input is not properly sorted. */ + input is not properly sorted. */ exit (check (files[0], checkonly) ? EXIT_SUCCESS : SORT_OUT_OF_ORDER); } @@ -3689,7 +3689,7 @@ main (int argc, char **argv) size_t i; for (i = 0; i < nfiles; ++i) - sortfiles[i].name = files[i]; + sortfiles[i].name = files[i]; merge (sortfiles, 0, nfiles, outfile); IF_LINT (free (sortfiles)); diff --git a/src/bin/coreutils/src/split.c b/src/bin/coreutils/src/split.c index ca25c8baf5..e02f7433a4 100644 --- a/src/bin/coreutils/src/split.c +++ b/src/bin/coreutils/src/split.c @@ -97,13 +97,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [INPUT [PREFIX]]\n\ "), - program_name); + program_name); fputs (_("\ Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default\n\ size is 1000 lines, and default PREFIX is `x'. With no INPUT, or when INPUT\n\ @@ -126,12 +126,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - fputs (_("\ -\n\ -SIZE may have a multiplier suffix:\n\ -b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,\n\ -GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.\n\ -"), stdout); + emit_size_note (); emit_bug_reporting_address (); } exit (status); @@ -153,7 +148,7 @@ next_file_name (void) size_t outbase_length = strlen (outbase); size_t outfile_length = outbase_length + suffix_length; if (outfile_length + 1 < outbase_length) - xalloc_die (); + xalloc_die (); outfile = xmalloc (outfile_length + 1); outfile_mid = outfile + outbase_length; memcpy (outfile, outbase, outbase_length); @@ -163,15 +158,15 @@ next_file_name (void) #if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX /* POSIX requires that if the output file name is too long for - its directory, `split' must fail without creating any files. - This must be checked for explicitly on operating systems that - silently truncate file names. */ + its directory, `split' must fail without creating any files. + This must be checked for explicitly on operating systems that + silently truncate file names. */ { - char *dir = dir_name (outfile); - long name_max = pathconf (dir, _PC_NAME_MAX); - if (0 <= name_max && name_max < base_len (last_component (outfile))) - error (EXIT_FAILURE, ENAMETOOLONG, "%s", outfile); - free (dir); + char *dir = dir_name (outfile); + long name_max = pathconf (dir, _PC_NAME_MAX); + if (0 <= name_max && name_max < base_len (last_component (outfile))) + error (EXIT_FAILURE, ENAMETOOLONG, "%s", outfile); + free (dir); } #endif } @@ -181,14 +176,14 @@ next_file_name (void) size_t i = suffix_length; while (i-- != 0) - { - sufindex[i]++; - outfile_mid[i] = suffix_alphabet[sufindex[i]]; - if (outfile_mid[i]) - return; - sufindex[i] = 0; - outfile_mid[i] = suffix_alphabet[sufindex[i]]; - } + { + sufindex[i]++; + outfile_mid[i] = suffix_alphabet[sufindex[i]]; + if (outfile_mid[i]) + return; + sufindex[i] = 0; + outfile_mid[i] = suffix_alphabet[sufindex[i]]; + } error (EXIT_FAILURE, 0, _("output file suffixes exhausted")); } } @@ -203,17 +198,17 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes) if (new_file_flag) { if (output_desc >= 0 && close (output_desc) < 0) - error (EXIT_FAILURE, errno, "%s", outfile); + error (EXIT_FAILURE, errno, "%s", outfile); next_file_name (); if (verbose) - fprintf (stdout, _("creating file %s\n"), quote (outfile)); + fprintf (stdout, _("creating file %s\n"), quote (outfile)); output_desc = open (outfile, - O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, - (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP - | S_IROTH | S_IWOTH)); + O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, + (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP + | S_IROTH | S_IWOTH)); if (output_desc < 0) - error (EXIT_FAILURE, errno, "%s", outfile); + error (EXIT_FAILURE, errno, "%s", outfile); } if (full_write (output_desc, bp, bytes) != bytes) error (EXIT_FAILURE, errno, "%s", outfile); @@ -239,27 +234,27 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize) bp_out = buf; to_read = n_read; for (;;) - { - if (to_read < to_write) - { - if (to_read) /* do not write 0 bytes! */ - { - cwrite (new_file_flag, bp_out, to_read); - to_write -= to_read; - new_file_flag = false; - } - break; - } - else - { - size_t w = to_write; - cwrite (new_file_flag, bp_out, w); - bp_out += w; - to_read -= w; - new_file_flag = true; - to_write = n_bytes; - } - } + { + if (to_read < to_write) + { + if (to_read) /* do not write 0 bytes! */ + { + cwrite (new_file_flag, bp_out, to_read); + to_write -= to_read; + new_file_flag = false; + } + break; + } + else + { + size_t w = to_write; + cwrite (new_file_flag, bp_out, w); + bp_out += w; + to_read -= w; + new_file_flag = true; + to_write = n_bytes; + } + } } while (n_read == bufsize); } @@ -279,33 +274,33 @@ lines_split (uintmax_t n_lines, char *buf, size_t bufsize) { n_read = full_read (STDIN_FILENO, buf, bufsize); if (n_read == SAFE_READ_ERROR) - error (EXIT_FAILURE, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); bp = bp_out = buf; eob = bp + n_read; *eob = '\n'; for (;;) - { - bp = memchr (bp, '\n', eob - bp + 1); - if (bp == eob) - { - if (eob != bp_out) /* do not write 0 bytes! */ - { - size_t len = eob - bp_out; - cwrite (new_file_flag, bp_out, len); - new_file_flag = false; - } - break; - } + { + bp = memchr (bp, '\n', eob - bp + 1); + if (bp == eob) + { + if (eob != bp_out) /* do not write 0 bytes! */ + { + size_t len = eob - bp_out; + cwrite (new_file_flag, bp_out, len); + new_file_flag = false; + } + break; + } - ++bp; - if (++n >= n_lines) - { - cwrite (new_file_flag, bp_out, bp - bp_out); - bp_out = bp; - new_file_flag = true; - n = 0; - } - } + ++bp; + if (++n >= n_lines) + { + cwrite (new_file_flag, bp_out, bp - bp_out); + bp_out = bp; + new_file_flag = true; + n = 0; + } + } } while (n_read == bufsize); } @@ -331,37 +326,37 @@ line_bytes_split (size_t n_bytes) n_read = full_read (STDIN_FILENO, buf + n_buffered, n_bytes - n_buffered); if (n_read == SAFE_READ_ERROR) - error (EXIT_FAILURE, errno, "%s", infile); + error (EXIT_FAILURE, errno, "%s", infile); n_buffered += n_read; if (n_buffered != n_bytes) - { - if (n_buffered == 0) - break; - eof = true; - } + { + if (n_buffered == 0) + break; + eof = true; + } /* Find where to end this chunk. */ bp = buf + n_buffered; if (n_buffered == n_bytes) - { - while (bp > buf && bp[-1] != '\n') - bp--; - } + { + while (bp > buf && bp[-1] != '\n') + bp--; + } /* If chunk has no newlines, use all the chunk. */ if (bp == buf) - bp = buf + n_buffered; + bp = buf + n_buffered; /* Output the chars as one output file. */ cwrite (true, buf, bp - buf); /* Discard the chars we just output; move rest of chunk - down to be the start of the next chunk. Source and - destination probably overlap. */ + down to be the start of the next chunk. Source and + destination probably overlap. */ n_buffered -= bp - buf; if (n_buffered > 0) - memmove (buf, bp, n_buffered); + memmove (buf, bp, n_buffered); } while (!eof); free (buf); @@ -411,103 +406,103 @@ main (int argc, char **argv) c = getopt_long (argc, argv, "0123456789C:a:b:dl:", longopts, NULL); if (c == -1) - break; + break; switch (c) - { - case 'a': - { - unsigned long tmp; - if (xstrtoul (optarg, NULL, 10, &tmp, "") != LONGINT_OK - || SIZE_MAX / sizeof (size_t) < tmp) - { - error (0, 0, _("%s: invalid suffix length"), optarg); - usage (EXIT_FAILURE); - } - suffix_length = tmp; - } - break; + { + case 'a': + { + unsigned long tmp; + if (xstrtoul (optarg, NULL, 10, &tmp, "") != LONGINT_OK + || SIZE_MAX / sizeof (size_t) < tmp) + { + error (0, 0, _("%s: invalid suffix length"), optarg); + usage (EXIT_FAILURE); + } + suffix_length = tmp; + } + break; - case 'b': - if (split_type != type_undef) - FAIL_ONLY_ONE_WAY (); - split_type = type_bytes; - if (xstrtoumax (optarg, NULL, 10, &n_units, multipliers) != LONGINT_OK - || n_units == 0) - { - error (0, 0, _("%s: invalid number of bytes"), optarg); - usage (EXIT_FAILURE); - } - break; + case 'b': + if (split_type != type_undef) + FAIL_ONLY_ONE_WAY (); + split_type = type_bytes; + if (xstrtoumax (optarg, NULL, 10, &n_units, multipliers) != LONGINT_OK + || n_units == 0) + { + error (0, 0, _("%s: invalid number of bytes"), optarg); + usage (EXIT_FAILURE); + } + break; - case 'l': - if (split_type != type_undef) - FAIL_ONLY_ONE_WAY (); - split_type = type_lines; - if (xstrtoumax (optarg, NULL, 10, &n_units, "") != LONGINT_OK - || n_units == 0) - { - error (0, 0, _("%s: invalid number of lines"), optarg); - usage (EXIT_FAILURE); - } - break; + case 'l': + if (split_type != type_undef) + FAIL_ONLY_ONE_WAY (); + split_type = type_lines; + if (xstrtoumax (optarg, NULL, 10, &n_units, "") != LONGINT_OK + || n_units == 0) + { + error (0, 0, _("%s: invalid number of lines"), optarg); + usage (EXIT_FAILURE); + } + break; - case 'C': - if (split_type != type_undef) - FAIL_ONLY_ONE_WAY (); - split_type = type_byteslines; - if (xstrtoumax (optarg, NULL, 10, &n_units, multipliers) != LONGINT_OK - || n_units == 0 || SIZE_MAX < n_units) - { - error (0, 0, _("%s: invalid number of bytes"), optarg); - usage (EXIT_FAILURE); - } - break; + case 'C': + if (split_type != type_undef) + FAIL_ONLY_ONE_WAY (); + split_type = type_byteslines; + if (xstrtoumax (optarg, NULL, 10, &n_units, multipliers) != LONGINT_OK + || n_units == 0 || SIZE_MAX < n_units) + { + error (0, 0, _("%s: invalid number of bytes"), optarg); + usage (EXIT_FAILURE); + } + break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (split_type == type_undef) - { - split_type = type_digits; - n_units = 0; - } - if (split_type != type_undef && split_type != type_digits) - FAIL_ONLY_ONE_WAY (); - if (digits_optind != 0 && digits_optind != this_optind) - n_units = 0; /* More than one number given; ignore other. */ - digits_optind = this_optind; - if (!DECIMAL_DIGIT_ACCUMULATE (n_units, c - '0', uintmax_t)) - { - char buffer[INT_BUFSIZE_BOUND (uintmax_t)]; - error (EXIT_FAILURE, 0, - _("line count option -%s%c... is too large"), - umaxtostr (n_units, buffer), c); - } - break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (split_type == type_undef) + { + split_type = type_digits; + n_units = 0; + } + if (split_type != type_undef && split_type != type_digits) + FAIL_ONLY_ONE_WAY (); + if (digits_optind != 0 && digits_optind != this_optind) + n_units = 0; /* More than one number given; ignore other. */ + digits_optind = this_optind; + if (!DECIMAL_DIGIT_ACCUMULATE (n_units, c - '0', uintmax_t)) + { + char buffer[INT_BUFSIZE_BOUND (uintmax_t)]; + error (EXIT_FAILURE, 0, + _("line count option -%s%c... is too large"), + umaxtostr (n_units, buffer), c); + } + break; - case 'd': - suffix_alphabet = "0123456789"; - break; + case 'd': + suffix_alphabet = "0123456789"; + break; - case VERBOSE_OPTION: - verbose = true; - break; + case VERBOSE_OPTION: + verbose = 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); - } + default: + usage (EXIT_FAILURE); + } } /* Handle default case. */ @@ -541,7 +536,7 @@ main (int argc, char **argv) if (! STREQ (infile, "-") && fd_reopen (STDIN_FILENO, infile, O_RDONLY, 0) < 0) error (EXIT_FAILURE, errno, _("cannot open %s for reading"), - quote (infile)); + quote (infile)); /* Binary I/O is safer when bytecounts are used. */ if (O_BINARY && ! isatty (STDIN_FILENO)) diff --git a/src/bin/coreutils/src/stat.c b/src/bin/coreutils/src/stat.c index 63c5911c42..3302270279 100644 --- a/src/bin/coreutils/src/stat.c +++ b/src/bin/coreutils/src/stat.c @@ -22,7 +22,7 @@ ../m4/stat-prog.m4. */ #if (STAT_STATVFS \ && (HAVE_STRUCT_STATVFS_F_BASETYPE || HAVE_STRUCT_STATVFS_F_FSTYPENAME \ - || (! HAVE_STRUCT_STATFS_F_FSTYPENAME && HAVE_STRUCT_STATVFS_F_TYPE))) + || (! HAVE_STRUCT_STATFS_F_FSTYPENAME && HAVE_STRUCT_STATVFS_F_TYPE))) # define USE_STATVFS 1 #else # define USE_STATVFS 0 @@ -96,11 +96,11 @@ statfs (char const *filename, struct fs_info *buf) if (device < 0) { errno = (device == B_ENTRY_NOT_FOUND ? ENOENT - : device == B_BAD_VALUE ? EINVAL - : device == B_NAME_TOO_LONG ? ENAMETOOLONG - : device == B_NO_MEMORY ? ENOMEM - : device == B_FILE_ERROR ? EIO - : 0); + : device == B_BAD_VALUE ? EINVAL + : device == B_NAME_TOO_LONG ? ENAMETOOLONG + : device == B_NO_MEMORY ? ENOMEM + : device == B_FILE_ERROR ? EIO + : 0); return -1; } /* If successful, buf->dev will be == device. */ @@ -145,7 +145,7 @@ statfs (char const *filename, struct fs_info *buf) #define isodigit(c) ('0' <= (c) && (c) <= '7') #define octtobin(c) ((c) - '0') #define hextobin(c) ((c) >= 'a' && (c) <= 'f' ? (c) - 'a' + 10 : \ - (c) >= 'A' && (c) <= 'F' ? (c) - 'A' + 10 : (c) - '0') + (c) >= 'A' && (c) <= 'F' ? (c) - 'A' + 10 : (c) - '0') #define PROGRAM_NAME "stat" @@ -197,23 +197,23 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) # if defined __linux__ /* Compare with what's in libc: - f=/a/libc/sysdeps/unix/sysv/linux/linux_fsinfo.h - sed -n '/ADFS_SUPER_MAGIC/,/SYSFS_MAGIC/p' $f \ - | perl -n -e '/#define (.*?)_(?:SUPER_)MAGIC\s+0x(\S+)/' \ - -e 'and print "case S_MAGIC_$1: /\* 0x" . uc($2) . " *\/\n"' \ - | sort > sym_libc - perl -ne '/^\s+(case S_MAGIC_.*?): \/\* 0x(\S+) \*\//' \ - -e 'and do { $v=uc$2; print "$1: /\* 0x$v *\/\n"}' stat.c \ - | sort > sym_stat - diff -u sym_stat sym_libc + f=/a/libc/sysdeps/unix/sysv/linux/linux_fsinfo.h + sed -n '/ADFS_SUPER_MAGIC/,/SYSFS_MAGIC/p' $f \ + | perl -n -e '/#define (.*?)_(?:SUPER_)MAGIC\s+0x(\S+)/' \ + -e 'and print "case S_MAGIC_$1: /\* 0x" . uc($2) . " *\/\n"' \ + | sort > sym_libc + perl -ne '/^\s+(case S_MAGIC_.*?): \/\* 0x(\S+) \*\//' \ + -e 'and do { $v=uc$2; print "$1: /\* 0x$v *\/\n"}' stat.c \ + | sort > sym_stat + diff -u sym_stat sym_libc */ /* Also sync from the list in "man 2 statfs". */ /* IMPORTANT NOTE: Each of the following `case S_MAGIC_...:' - statements must be followed by a hexadecimal constant in - a comment. The S_MAGIC_... name and constant are automatically - combined to produce the #define directives in fs.h. */ + statements must be followed by a hexadecimal constant in + a comment. The S_MAGIC_... name and constant are automatically + combined to produce the #define directives in fs.h. */ case S_MAGIC_ADFS: /* 0xADF5 */ return "adfs"; @@ -384,11 +384,11 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) # endif default: { - unsigned long int type = statfsbuf->f_type; - static char buf[sizeof "UNKNOWN (0x%lx)" - 3 - + (sizeof type * CHAR_BIT + 3) / 4]; - sprintf (buf, "UNKNOWN (0x%lx)", type); - return buf; + unsigned long int type = statfsbuf->f_type; + static char buf[sizeof "UNKNOWN (0x%lx)" - 3 + + (sizeof type * CHAR_BIT + 3) / 4]; + sprintf (buf, "UNKNOWN (0x%lx)", type); + return buf; } } #endif @@ -407,9 +407,9 @@ static char * human_time (struct timespec t) { static char str[MAX (INT_BUFSIZE_BOUND (intmax_t), - (INT_STRLEN_BOUND (int) /* YYYY */ - + 1 /* because YYYY might equal INT_MAX + 1900 */ - + sizeof "-MM-DD HH:MM:SS.NNNNNNNNN +ZZZZ"))]; + (INT_STRLEN_BOUND (int) /* YYYY */ + + 1 /* because YYYY might equal INT_MAX + 1900 */ + + sizeof "-MM-DD HH:MM:SS.NNNNNNNNN +ZZZZ"))]; struct tm const *tm = localtime (&t.tv_sec); if (tm == NULL) return timetostr (t.tv_sec, str); @@ -459,7 +459,7 @@ out_file_context (char const *filename, char *pformat, size_t prefix_len) : lgetfilecon (filename, &scontext)) < 0) { error (0, errno, _("failed to get security context of %s"), - quote (filename)); + quote (filename)); scontext = NULL; } strcpy (pformat + prefix_len, "s"); @@ -471,7 +471,7 @@ out_file_context (char const *filename, char *pformat, size_t prefix_len) /* print statfs info */ static void print_statfs (char *pformat, size_t prefix_len, char m, char const *filename, - void const *data) + void const *data) { STRUCT_STATVFS const *statfsbuf = data; @@ -484,26 +484,26 @@ print_statfs (char *pformat, size_t prefix_len, char m, char const *filename, case 'i': { #if STRUCT_STATXFS_F_FSID_IS_INTEGER - uintmax_t fsid = statfsbuf->f_fsid; + uintmax_t fsid = statfsbuf->f_fsid; #else - typedef unsigned int fsid_word; - verify (alignof (STRUCT_STATVFS) % alignof (fsid_word) == 0); - verify (offsetof (STRUCT_STATVFS, f_fsid) % alignof (fsid_word) == 0); - verify (sizeof statfsbuf->f_fsid % alignof (fsid_word) == 0); - fsid_word const *p = (fsid_word *) &statfsbuf->f_fsid; + typedef unsigned int fsid_word; + verify (alignof (STRUCT_STATVFS) % alignof (fsid_word) == 0); + verify (offsetof (STRUCT_STATVFS, f_fsid) % alignof (fsid_word) == 0); + verify (sizeof statfsbuf->f_fsid % alignof (fsid_word) == 0); + fsid_word const *p = (fsid_word *) &statfsbuf->f_fsid; - /* Assume a little-endian word order, as that is compatible - with glibc's statvfs implementation. */ - uintmax_t fsid = 0; - int words = sizeof statfsbuf->f_fsid / sizeof *p; - int i; - for (i = 0; i < words && i * sizeof *p < sizeof fsid; i++) - { - uintmax_t u = p[words - 1 - i]; - fsid |= u << (i * CHAR_BIT * sizeof *p); - } + /* Assume a little-endian word order, as that is compatible + with glibc's statvfs implementation. */ + uintmax_t fsid = 0; + int words = sizeof statfsbuf->f_fsid / sizeof *p; + int i; + for (i = 0; i < words && i * sizeof *p < sizeof fsid; i++) + { + uintmax_t u = p[words - 1 - i]; + fsid |= u << (i * CHAR_BIT * sizeof *p); + } #endif - out_uint_x (pformat, prefix_len, fsid); + out_uint_x (pformat, prefix_len, fsid); } break; @@ -534,10 +534,10 @@ print_statfs (char *pformat, size_t prefix_len, char m, char const *filename, break; case 'S': { - uintmax_t frsize = STATFS_FRSIZE (statfsbuf); - if (! frsize) - frsize = statfsbuf->f_bsize; - out_uint (pformat, prefix_len, frsize); + uintmax_t frsize = STATFS_FRSIZE (statfsbuf); + if (! frsize) + frsize = statfsbuf->f_bsize; + out_uint (pformat, prefix_len, frsize); } break; case 'c': @@ -558,7 +558,7 @@ print_statfs (char *pformat, size_t prefix_len, char m, char const *filename, /* print stat info */ static void print_stat (char *pformat, size_t prefix_len, char m, - char const *filename, void const *data) + char const *filename, void const *data) { struct stat *statbuf = (struct stat *) data; struct passwd *pw_ent; @@ -572,17 +572,17 @@ print_stat (char *pformat, size_t prefix_len, char m, case 'N': out_string (pformat, prefix_len, quote (filename)); if (S_ISLNK (statbuf->st_mode)) - { - char *linkname = areadlink_with_size (filename, statbuf->st_size); - if (linkname == NULL) - { - error (0, errno, _("cannot read symbolic link %s"), - quote (filename)); - return; - } - printf (" -> "); - out_string (pformat, prefix_len, quote (linkname)); - } + { + char *linkname = areadlink_with_size (filename, statbuf->st_size); + if (linkname == NULL) + { + error (0, errno, _("cannot read symbolic link %s"), + quote (filename)); + return; + } + printf (" -> "); + out_string (pformat, prefix_len, quote (linkname)); + } break; case 'd': out_uint (pformat, prefix_len, statbuf->st_dev); @@ -615,7 +615,7 @@ print_stat (char *pformat, size_t prefix_len, char m, setpwent (); pw_ent = getpwuid (statbuf->st_uid); out_string (pformat, prefix_len, - pw_ent ? pw_ent->pw_name : "UNKNOWN"); + pw_ent ? pw_ent->pw_name : "UNKNOWN"); break; case 'g': out_uint (pformat, prefix_len, statbuf->st_gid); @@ -624,7 +624,7 @@ print_stat (char *pformat, size_t prefix_len, char m, setgrent (); gw_ent = getgrgid (statbuf->st_gid); out_string (pformat, prefix_len, - gw_ent ? gw_ent->gr_name : "UNKNOWN"); + gw_ent ? gw_ent->gr_name : "UNKNOWN"); break; case 't': out_uint_x (pformat, prefix_len, major (statbuf->st_rdev)); @@ -649,27 +649,27 @@ print_stat (char *pformat, size_t prefix_len, char m, break; case 'X': if (TYPE_SIGNED (time_t)) - out_int (pformat, prefix_len, statbuf->st_atime); + out_int (pformat, prefix_len, statbuf->st_atime); else - out_uint (pformat, prefix_len, statbuf->st_atime); + out_uint (pformat, prefix_len, statbuf->st_atime); break; case 'y': out_string (pformat, prefix_len, human_time (get_stat_mtime (statbuf))); break; case 'Y': if (TYPE_SIGNED (time_t)) - out_int (pformat, prefix_len, statbuf->st_mtime); + out_int (pformat, prefix_len, statbuf->st_mtime); else - out_uint (pformat, prefix_len, statbuf->st_mtime); + out_uint (pformat, prefix_len, statbuf->st_mtime); break; case 'z': out_string (pformat, prefix_len, human_time (get_stat_ctime (statbuf))); break; case 'Z': if (TYPE_SIGNED (time_t)) - out_int (pformat, prefix_len, statbuf->st_ctime); + out_int (pformat, prefix_len, statbuf->st_ctime); else - out_uint (pformat, prefix_len, statbuf->st_ctime); + out_uint (pformat, prefix_len, statbuf->st_ctime); break; case 'C': out_file_context (filename, pformat, prefix_len); @@ -720,17 +720,17 @@ print_esc_char (char c) static void print_it (char const *format, char const *filename, - void (*print_func) (char *, size_t, char, char const *, void const *), - void const *data) + void (*print_func) (char *, size_t, char, char const *, void const *), + void const *data) { /* Add 2 to accommodate our conversion of the stat `%s' format string to the longer printf `%llu' one. */ enum { MAX_ADDITIONAL_BYTES = - (MAX (sizeof PRIdMAX, - MAX (sizeof PRIoMAX, MAX (sizeof PRIuMAX, sizeof PRIxMAX))) - - 1) + (MAX (sizeof PRIdMAX, + MAX (sizeof PRIoMAX, MAX (sizeof PRIuMAX, sizeof PRIxMAX))) + - 1) }; size_t n_alloc = strlen (format) + MAX_ADDITIONAL_BYTES + 1; char *dest = xmalloc (n_alloc); @@ -738,85 +738,85 @@ print_it (char const *format, char const *filename, for (b = format; *b; b++) { switch (*b) - { - case '%': - { - size_t len = strspn (b + 1, "#-+.I 0123456789"); - char const *fmt_char = b + len + 1; - memcpy (dest, b, len + 1); + { + case '%': + { + size_t len = strspn (b + 1, "#-+.I 0123456789"); + char const *fmt_char = b + len + 1; + memcpy (dest, b, len + 1); - b = fmt_char; - switch (*fmt_char) - { - case '\0': - --b; - /* fall through */ - case '%': - if (0 < len) - { - dest[len + 1] = *fmt_char; - dest[len + 2] = '\0'; - error (EXIT_FAILURE, 0, _("%s: invalid directive"), - quotearg_colon (dest)); - } - putchar ('%'); - break; - default: - print_func (dest, len + 1, *fmt_char, filename, data); - break; - } - break; - } + b = fmt_char; + switch (*fmt_char) + { + case '\0': + --b; + /* fall through */ + case '%': + if (0 < len) + { + dest[len + 1] = *fmt_char; + dest[len + 2] = '\0'; + error (EXIT_FAILURE, 0, _("%s: invalid directive"), + quotearg_colon (dest)); + } + putchar ('%'); + break; + default: + print_func (dest, len + 1, *fmt_char, filename, data); + break; + } + break; + } - case '\\': - if ( ! interpret_backslash_escapes) - { - putchar ('\\'); - break; - } - ++b; - if (isodigit (*b)) - { - int esc_value = octtobin (*b); - int esc_length = 1; /* number of octal digits */ - for (++b; esc_length < 3 && isodigit (*b); - ++esc_length, ++b) - { - esc_value = esc_value * 8 + octtobin (*b); - } - putchar (esc_value); - --b; - } - else if (*b == 'x' && isxdigit (to_uchar (b[1]))) - { - int esc_value = hextobin (b[1]); /* Value of \xhh escape. */ - /* A hexadecimal \xhh escape sequence must have - 1 or 2 hex. digits. */ - ++b; - if (isxdigit (to_uchar (b[1]))) - { - ++b; - esc_value = esc_value * 16 + hextobin (*b); - } - putchar (esc_value); - } - else if (*b == '\0') - { - error (0, 0, _("warning: backslash at end of format")); - putchar ('\\'); - /* Arrange to exit the loop. */ - --b; - } - else - { - print_esc_char (*b); - } - break; + case '\\': + if ( ! interpret_backslash_escapes) + { + putchar ('\\'); + break; + } + ++b; + if (isodigit (*b)) + { + int esc_value = octtobin (*b); + int esc_length = 1; /* number of octal digits */ + for (++b; esc_length < 3 && isodigit (*b); + ++esc_length, ++b) + { + esc_value = esc_value * 8 + octtobin (*b); + } + putchar (esc_value); + --b; + } + else if (*b == 'x' && isxdigit (to_uchar (b[1]))) + { + int esc_value = hextobin (b[1]); /* Value of \xhh escape. */ + /* A hexadecimal \xhh escape sequence must have + 1 or 2 hex. digits. */ + ++b; + if (isxdigit (to_uchar (b[1]))) + { + ++b; + esc_value = esc_value * 16 + hextobin (*b); + } + putchar (esc_value); + } + else if (*b == '\0') + { + error (0, 0, _("warning: backslash at end of format")); + putchar ('\\'); + /* Arrange to exit the loop. */ + --b; + } + else + { + print_esc_char (*b); + } + break; - default: - putchar (*b); - break; - } + default: + putchar (*b); + break; + } } free (dest); @@ -832,19 +832,19 @@ do_statfs (char const *filename, bool terse, char const *format) if (STATFS (filename, &statfsbuf) != 0) { error (0, errno, _("cannot read file system information for %s"), - quote (filename)); + quote (filename)); return false; } if (format == NULL) { format = (terse - ? "%n %i %l %t %s %S %b %f %a %c %d\n" - : " File: \"%n\"\n" - " ID: %-8i Namelen: %-7l Type: %T\n" - "Block size: %-10s Fundamental block size: %S\n" - "Blocks: Total: %-10b Free: %-10f Available: %a\n" - "Inodes: Total: %-10c Free: %d\n"); + ? "%n %i %l %t %s %S %b %f %a %c %d\n" + : " File: \"%n\"\n" + " ID: %-8i Namelen: %-7l Type: %T\n" + "Block size: %-10s Fundamental block size: %S\n" + "Blocks: Total: %-10b Free: %-10f Available: %a\n" + "Inodes: Total: %-10c Free: %d\n"); } print_it (format, filename, print_statfs, &statfsbuf); @@ -866,33 +866,33 @@ do_stat (char const *filename, bool terse, char const *format) if (format == NULL) { if (terse) - { - format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n"; - } + { + format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n"; + } else - { - /* Temporary hack to match original output until conditional - implemented. */ - if (S_ISBLK (statbuf.st_mode) || S_ISCHR (statbuf.st_mode)) - { - format = - " File: %N\n" - " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" - "Device: %Dh/%dd\tInode: %-10i Links: %-5h" - " Device type: %t,%T\n" - "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n" - "Access: %x\n" "Modify: %y\n" "Change: %z\n"; - } - else - { - format = - " File: %N\n" - " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" - "Device: %Dh/%dd\tInode: %-10i Links: %h\n" - "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n" - "Access: %x\n" "Modify: %y\n" "Change: %z\n"; - } - } + { + /* Temporary hack to match original output until conditional + implemented. */ + if (S_ISBLK (statbuf.st_mode) || S_ISCHR (statbuf.st_mode)) + { + format = + " File: %N\n" + " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" + "Device: %Dh/%dd\tInode: %-10i Links: %-5h" + " Device type: %t,%T\n" + "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n" + "Access: %x\n" "Modify: %y\n" "Change: %z\n"; + } + else + { + format = + " File: %N\n" + " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" + "Device: %Dh/%dd\tInode: %-10i Links: %h\n" + "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n" + "Access: %x\n" "Modify: %y\n" "Change: %z\n"; + } + } } print_it (format, filename, print_stat, &statbuf); return true; @@ -903,7 +903,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... FILE...\n"), program_name); @@ -1009,47 +1009,47 @@ main (int argc, char *argv[]) while ((c = getopt_long (argc, argv, "c:fLtZ", long_options, NULL)) != -1) { switch (c) - { - case PRINTF_OPTION: - format = optarg; - interpret_backslash_escapes = true; - trailing_delim = ""; - break; + { + case PRINTF_OPTION: + format = optarg; + interpret_backslash_escapes = true; + trailing_delim = ""; + break; - case 'c': - format = optarg; - interpret_backslash_escapes = false; - trailing_delim = "\n"; - break; + case 'c': + format = optarg; + interpret_backslash_escapes = false; + trailing_delim = "\n"; + break; - case 'L': - follow_links = true; - break; + case 'L': + follow_links = true; + break; - case 'f': - fs = true; - break; + case 'f': + fs = true; + break; - case 't': - terse = true; - break; + case 't': + terse = true; + break; - case 'Z': /* FIXME: remove in 2010 */ - /* Ignore, for compatibility with distributions - that implemented this before upstream. - But warn of impending removal. */ - error (0, 0, - _("the --context (-Z) option is obsolete and will be removed\n" - "in a future release")); - break; + case 'Z': /* FIXME: remove in 2010 */ + /* Ignore, for compatibility with distributions + that implemented this before upstream. + But warn of impending removal. */ + error (0, 0, + _("the --context (-Z) option is obsolete and will be removed\n" + "in a future release")); + 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); - } + default: + usage (EXIT_FAILURE); + } } if (argc == optind) @@ -1060,8 +1060,8 @@ main (int argc, char *argv[]) for (i = optind; i < argc; i++) ok &= (fs - ? do_statfs (argv[i], terse, format) - : do_stat (argv[i], terse, format)); + ? do_statfs (argv[i], terse, format) + : do_stat (argv[i], terse, format)); exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/bin/coreutils/src/stdbuf.c b/src/bin/coreutils/src/stdbuf.c index 5da934191a..007cc21946 100644 --- a/src/bin/coreutils/src/stdbuf.c +++ b/src/bin/coreutils/src/stdbuf.c @@ -108,10 +108,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); fputs (_("\n\ -If MODE is `L' then corresponding stream will be line buffered.\n\ +If MODE is `L' the corresponding stream will be line buffered.\n\ This option is invalid with standard input.\n"), stdout); fputs (_("\n\ -If MODE is `0' then corresponding stream will be unbuffered.\n\ +If MODE is `0' the corresponding stream will be unbuffered.\n\ "), stdout); fputs (_("\n\ Otherwise MODE is a number which may be followed by one of the following:\n\ @@ -378,9 +378,3 @@ main (int argc, char **argv) exit (exit_status); } } - -/* - * Local variables: - * indent-tabs-mode: nil - * End: - */ diff --git a/src/bin/coreutils/src/stty.c b/src/bin/coreutils/src/stty.c index 389ab9eb90..b980e8482f 100644 --- a/src/bin/coreutils/src/stty.c +++ b/src/bin/coreutils/src/stty.c @@ -279,10 +279,18 @@ static struct mode_info const mode_info[] = {"cr0", output, SANE_SET, CR0, CRDLY}, #endif #ifdef TABDLY +#ifdef TAB3 {"tab3", output, SANE_UNSET, TAB3, TABDLY}, +#endif +#ifdef TAB2 {"tab2", output, SANE_UNSET, TAB2, TABDLY}, +#endif +#ifdef TAB1 {"tab1", output, SANE_UNSET, TAB1, TABDLY}, +#endif +#ifdef TAB0 {"tab0", output, SANE_SET, TAB0, TABDLY}, +#endif #else # ifdef OXTABS {"tab3", output, SANE_UNSET, OXTABS, 0}, @@ -419,7 +427,7 @@ static unsigned long int baud_to_value (speed_t speed); static bool recover_mode (char const *arg, struct termios *mode); static int screen_columns (void); static bool set_mode (struct mode_info const *info, bool reversed, - struct termios *mode); + struct termios *mode); static unsigned long int integer_arg (const char *s, unsigned long int max); static speed_t string_to_baud (const char *arg); static tcflag_t *mode_type_flag (enum mode_type type, struct termios *mode); @@ -427,16 +435,16 @@ static void display_all (struct termios *mode, char const *device_name); static void display_changed (struct termios *mode); static void display_recoverable (struct termios *mode); static void display_settings (enum output_type output_type, - struct termios *mode, - const char *device_name); + struct termios *mode, + const char *device_name); static void display_speed (struct termios *mode, bool fancy); static void display_window_size (bool fancy, char const *device_name); static void sane_mode (struct termios *mode); static void set_control_char (struct control_info const *info, - const char *arg, - struct termios *mode); + const char *arg, + struct termios *mode); static void set_speed (enum speed_setting type, const char *arg, - struct termios *mode); + struct termios *mode); static void set_window_size (int rows, int cols, char const *device_name); /* The width of the screen, for output wrapping. */ @@ -479,15 +487,15 @@ wrapf (const char *message,...) if (0 < current_col) { if (max_col - current_col < buflen) - { - putchar ('\n'); - current_col = 0; - } + { + putchar ('\n'); + current_col = 0; + } else - { - putchar (' '); - current_col++; - } + { + putchar (' '); + current_col++; + } } fputs (buf, stdout); @@ -500,7 +508,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -508,7 +516,7 @@ Usage: %s [-F DEVICE | --file=DEVICE] [SETTING]...\n\ or: %s [-F DEVICE | --file=DEVICE] [-a|--all]\n\ or: %s [-F DEVICE | --file=DEVICE] [-g|--save]\n\ "), - program_name, program_name, program_name); + program_name, program_name, program_name); fputs (_("\ Print or change terminal characteristics.\n\ \n\ @@ -764,60 +772,60 @@ main (int argc, char **argv) short and long options, --, POSIXLY_CORRECT, etc. */ while ((optc = getopt_long (argc - argi, argv + argi, "-agF:", - longopts, NULL)) - != -1) + longopts, NULL)) + != -1) { switch (optc) - { - case 'a': - verbose_output = true; - output_type = all; - break; + { + case 'a': + verbose_output = true; + output_type = all; + break; - case 'g': - recoverable_output = true; - output_type = recoverable; - break; + case 'g': + recoverable_output = true; + output_type = recoverable; + break; - case 'F': - if (file_name) - error (EXIT_FAILURE, 0, _("only one device may be specified")); - file_name = optarg; - break; + case 'F': + if (file_name) + error (EXIT_FAILURE, 0, _("only one device may be specified")); + file_name = optarg; + break; - case_GETOPT_HELP_CHAR; + case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - noargs = false; + default: + noargs = false; - /* Skip the argument containing this unrecognized option; - the 2nd pass will analyze it. */ - argi += opti; + /* Skip the argument containing this unrecognized option; + the 2nd pass will analyze it. */ + argi += opti; - /* Restart getopt_long from the first unskipped argument. */ - opti = 1; - optind = 0; + /* Restart getopt_long from the first unskipped argument. */ + opti = 1; + optind = 0; - break; - } + break; + } /* Clear fully-parsed arguments, so they don't confuse the 2nd pass. */ while (opti < optind) - argv[argi + opti++] = NULL; + argv[argi + opti++] = NULL; } /* Specifying both -a and -g gets an error. */ if (verbose_output & recoverable_output) error (EXIT_FAILURE, 0, - _("the options for verbose and stty-readable output styles are\n" - "mutually exclusive")); + _("the options for verbose and stty-readable output styles are\n" + "mutually exclusive")); /* Specifying any other arguments with -a or -g gets an error. */ if (!noargs && (verbose_output | recoverable_output)) error (EXIT_FAILURE, 0, - _("when specifying an output style, modes may not be set")); + _("when specifying an output style, modes may not be set")); /* FIXME: it'd be better not to open the file until we've verified that all arguments are valid. Otherwise, we could end up doing @@ -829,11 +837,11 @@ main (int argc, char **argv) int fdflags; device_name = file_name; if (fd_reopen (STDIN_FILENO, device_name, O_RDONLY | O_NONBLOCK, 0) < 0) - error (EXIT_FAILURE, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); if ((fdflags = fcntl (STDIN_FILENO, F_GETFL)) == -1 - || fcntl (STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0) - error (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"), - device_name); + || fcntl (STDIN_FILENO, F_SETFL, fdflags & ~O_NONBLOCK) < 0) + error (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"), + device_name); } else device_name = _("standard input"); @@ -859,199 +867,199 @@ main (int argc, char **argv) int i; if (! arg) - continue; + continue; if (arg[0] == '-') - { - ++arg; - reversed = true; - } + { + ++arg; + reversed = true; + } for (i = 0; mode_info[i].name != NULL; ++i) - { - if (STREQ (arg, mode_info[i].name)) - { - match_found = set_mode (&mode_info[i], reversed, &mode); - require_set_attr = true; - break; - } - } + { + if (STREQ (arg, mode_info[i].name)) + { + match_found = set_mode (&mode_info[i], reversed, &mode); + require_set_attr = true; + break; + } + } if (!match_found & reversed) - { - error (0, 0, _("invalid argument %s"), quote (arg - 1)); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("invalid argument %s"), quote (arg - 1)); + usage (EXIT_FAILURE); + } if (!match_found) - { - for (i = 0; control_info[i].name != NULL; ++i) - { - if (STREQ (arg, control_info[i].name)) - { - if (k == argc - 1) - { - error (0, 0, _("missing argument to %s"), quote (arg)); - usage (EXIT_FAILURE); - } - match_found = true; - ++k; - set_control_char (&control_info[i], argv[k], &mode); - require_set_attr = true; - break; - } - } - } + { + for (i = 0; control_info[i].name != NULL; ++i) + { + if (STREQ (arg, control_info[i].name)) + { + if (k == argc - 1) + { + error (0, 0, _("missing argument to %s"), quote (arg)); + usage (EXIT_FAILURE); + } + match_found = true; + ++k; + set_control_char (&control_info[i], argv[k], &mode); + require_set_attr = true; + break; + } + } + } if (!match_found) - { - if (STREQ (arg, "ispeed")) - { - if (k == argc - 1) - { - error (0, 0, _("missing argument to %s"), quote (arg)); - usage (EXIT_FAILURE); - } - ++k; - set_speed (input_speed, argv[k], &mode); - speed_was_set = true; - require_set_attr = true; - } - else if (STREQ (arg, "ospeed")) - { - if (k == argc - 1) - { - error (0, 0, _("missing argument to %s"), quote (arg)); - usage (EXIT_FAILURE); - } - ++k; - set_speed (output_speed, argv[k], &mode); - speed_was_set = true; - require_set_attr = true; - } + { + if (STREQ (arg, "ispeed")) + { + if (k == argc - 1) + { + error (0, 0, _("missing argument to %s"), quote (arg)); + usage (EXIT_FAILURE); + } + ++k; + set_speed (input_speed, argv[k], &mode); + speed_was_set = true; + require_set_attr = true; + } + else if (STREQ (arg, "ospeed")) + { + if (k == argc - 1) + { + error (0, 0, _("missing argument to %s"), quote (arg)); + usage (EXIT_FAILURE); + } + ++k; + set_speed (output_speed, argv[k], &mode); + speed_was_set = true; + require_set_attr = true; + } #ifdef TIOCGWINSZ - else if (STREQ (arg, "rows")) - { - if (k == argc - 1) - { - error (0, 0, _("missing argument to %s"), quote (arg)); - usage (EXIT_FAILURE); - } - ++k; - set_window_size (integer_arg (argv[k], INT_MAX), -1, - device_name); - } - else if (STREQ (arg, "cols") - || STREQ (arg, "columns")) - { - if (k == argc - 1) - { - error (0, 0, _("missing argument to %s"), quote (arg)); - usage (EXIT_FAILURE); - } - ++k; - set_window_size (-1, integer_arg (argv[k], INT_MAX), - device_name); - } - else if (STREQ (arg, "size")) - { - max_col = screen_columns (); - current_col = 0; - display_window_size (false, device_name); - } + else if (STREQ (arg, "rows")) + { + if (k == argc - 1) + { + error (0, 0, _("missing argument to %s"), quote (arg)); + usage (EXIT_FAILURE); + } + ++k; + set_window_size (integer_arg (argv[k], INT_MAX), -1, + device_name); + } + else if (STREQ (arg, "cols") + || STREQ (arg, "columns")) + { + if (k == argc - 1) + { + error (0, 0, _("missing argument to %s"), quote (arg)); + usage (EXIT_FAILURE); + } + ++k; + set_window_size (-1, integer_arg (argv[k], INT_MAX), + device_name); + } + else if (STREQ (arg, "size")) + { + max_col = screen_columns (); + current_col = 0; + display_window_size (false, device_name); + } #endif #ifdef HAVE_C_LINE - else if (STREQ (arg, "line")) - { - unsigned long int value; - if (k == argc - 1) - { - error (0, 0, _("missing argument to %s"), quote (arg)); - usage (EXIT_FAILURE); - } - ++k; - mode.c_line = value = integer_arg (argv[k], ULONG_MAX); - if (mode.c_line != value) - error (0, 0, _("invalid line discipline %s"), quote (argv[k])); - require_set_attr = true; - } + else if (STREQ (arg, "line")) + { + unsigned long int value; + if (k == argc - 1) + { + error (0, 0, _("missing argument to %s"), quote (arg)); + usage (EXIT_FAILURE); + } + ++k; + mode.c_line = value = integer_arg (argv[k], ULONG_MAX); + if (mode.c_line != value) + error (0, 0, _("invalid line discipline %s"), quote (argv[k])); + require_set_attr = true; + } #endif - else if (STREQ (arg, "speed")) - { - max_col = screen_columns (); - display_speed (&mode, false); - } - else if (string_to_baud (arg) != (speed_t) -1) - { - set_speed (both_speeds, arg, &mode); - speed_was_set = true; - require_set_attr = true; - } - else - { - if (! recover_mode (arg, &mode)) - { - error (0, 0, _("invalid argument %s"), quote (arg)); - usage (EXIT_FAILURE); - } - require_set_attr = true; - } - } + else if (STREQ (arg, "speed")) + { + max_col = screen_columns (); + display_speed (&mode, false); + } + else if (string_to_baud (arg) != (speed_t) -1) + { + set_speed (both_speeds, arg, &mode); + speed_was_set = true; + require_set_attr = true; + } + else + { + if (! recover_mode (arg, &mode)) + { + error (0, 0, _("invalid argument %s"), quote (arg)); + usage (EXIT_FAILURE); + } + require_set_attr = true; + } + } } if (require_set_attr) { /* Initialize to all zeroes so there is no risk memcmp will report a - spurious difference in an uninitialized portion of the structure. */ + spurious difference in an uninitialized portion of the structure. */ DECLARE_ZEROED_AGGREGATE (struct termios, new_mode); if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode)) - error (EXIT_FAILURE, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); /* POSIX (according to Zlotnick's book) tcsetattr returns zero if - it performs *any* of the requested operations. This means it - can report `success' when it has actually failed to perform - some proper subset of the requested operations. To detect - this partial failure, get the current terminal attributes and - compare them to the requested ones. */ + it performs *any* of the requested operations. This means it + can report `success' when it has actually failed to perform + some proper subset of the requested operations. To detect + this partial failure, get the current terminal attributes and + compare them to the requested ones. */ if (tcgetattr (STDIN_FILENO, &new_mode)) - error (EXIT_FAILURE, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); /* Normally, one shouldn't use memcmp to compare structures that - may have `holes' containing uninitialized data, but we have been - careful to initialize the storage of these two variables to all - zeroes. One might think it more efficient simply to compare the - modified fields, but that would require enumerating those fields -- - and not all systems have the same fields in this structure. */ + may have `holes' containing uninitialized data, but we have been + careful to initialize the storage of these two variables to all + zeroes. One might think it more efficient simply to compare the + modified fields, but that would require enumerating those fields -- + and not all systems have the same fields in this structure. */ if (memcmp (&mode, &new_mode, sizeof (mode)) != 0) - { + { #ifdef CIBAUD - /* SunOS 4.1.3 (at least) has the problem that after this sequence, - tcgetattr (&m1); tcsetattr (&m1); tcgetattr (&m2); - sometimes (m1 != m2). The only difference is in the four bits - of the c_cflag field corresponding to the baud rate. To save - Sun users a little confusion, don't report an error if this - happens. But suppress the error only if we haven't tried to - set the baud rate explicitly -- otherwise we'd never give an - error for a true failure to set the baud rate. */ + /* SunOS 4.1.3 (at least) has the problem that after this sequence, + tcgetattr (&m1); tcsetattr (&m1); tcgetattr (&m2); + sometimes (m1 != m2). The only difference is in the four bits + of the c_cflag field corresponding to the baud rate. To save + Sun users a little confusion, don't report an error if this + happens. But suppress the error only if we haven't tried to + set the baud rate explicitly -- otherwise we'd never give an + error for a true failure to set the baud rate. */ - new_mode.c_cflag &= (~CIBAUD); - if (speed_was_set || memcmp (&mode, &new_mode, sizeof (mode)) != 0) + new_mode.c_cflag &= (~CIBAUD); + if (speed_was_set || memcmp (&mode, &new_mode, sizeof (mode)) != 0) #endif - { - error (EXIT_FAILURE, 0, - _("%s: unable to perform all requested operations"), - device_name); + { + error (EXIT_FAILURE, 0, + _("%s: unable to perform all requested operations"), + device_name); #ifdef TESTING - { - size_t i; - printf ("new_mode: mode\n"); - for (i = 0; i < sizeof (new_mode); i++) - printf ("0x%02x: 0x%02x\n", - *(((unsigned char *) &new_mode) + i), - *(((unsigned char *) &mode) + i)); - } + { + size_t i; + printf ("new_mode: mode\n"); + for (i = 0; i < sizeof (new_mode); i++) + printf ("0x%02x: 0x%02x\n", + *(((unsigned char *) &new_mode) + i), + *(((unsigned char *) &mode) + i)); + } #endif - } - } + } + } } exit (EXIT_SUCCESS); @@ -1074,189 +1082,189 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) { /* Combination mode. */ if (STREQ (info->name, "evenp") || STREQ (info->name, "parity")) - { - if (reversed) - mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; - else - mode->c_cflag = (mode->c_cflag & ~PARODD & ~CSIZE) | PARENB | CS7; - } + { + if (reversed) + mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; + else + mode->c_cflag = (mode->c_cflag & ~PARODD & ~CSIZE) | PARENB | CS7; + } else if (STREQ (info->name, "oddp")) - { - if (reversed) - mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; - else - mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARODD | PARENB; - } + { + if (reversed) + mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; + else + mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARODD | PARENB; + } else if (STREQ (info->name, "nl")) - { - if (reversed) - { - mode->c_iflag = (mode->c_iflag | ICRNL) & ~INLCR & ~IGNCR; - mode->c_oflag = (mode->c_oflag + { + if (reversed) + { + mode->c_iflag = (mode->c_iflag | ICRNL) & ~INLCR & ~IGNCR; + mode->c_oflag = (mode->c_oflag #ifdef ONLCR - | ONLCR + | ONLCR #endif - ) + ) #ifdef OCRNL - & ~OCRNL + & ~OCRNL #endif #ifdef ONLRET - & ~ONLRET + & ~ONLRET #endif - ; - } - else - { - mode->c_iflag = mode->c_iflag & ~ICRNL; + ; + } + else + { + mode->c_iflag = mode->c_iflag & ~ICRNL; #ifdef ONLCR - mode->c_oflag = mode->c_oflag & ~ONLCR; + mode->c_oflag = mode->c_oflag & ~ONLCR; #endif - } - } + } + } else if (STREQ (info->name, "ek")) - { - mode->c_cc[VERASE] = CERASE; - mode->c_cc[VKILL] = CKILL; - } + { + mode->c_cc[VERASE] = CERASE; + mode->c_cc[VKILL] = CKILL; + } else if (STREQ (info->name, "sane")) - sane_mode (mode); + sane_mode (mode); else if (STREQ (info->name, "cbreak")) - { - if (reversed) - mode->c_lflag |= ICANON; - else - mode->c_lflag &= ~ICANON; - } + { + if (reversed) + mode->c_lflag |= ICANON; + else + mode->c_lflag &= ~ICANON; + } else if (STREQ (info->name, "pass8")) - { - if (reversed) - { - mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; - mode->c_iflag |= ISTRIP; - } - else - { - mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; - mode->c_iflag &= ~ISTRIP; - } - } + { + if (reversed) + { + mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; + mode->c_iflag |= ISTRIP; + } + else + { + mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; + mode->c_iflag &= ~ISTRIP; + } + } else if (STREQ (info->name, "litout")) - { - if (reversed) - { - mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; - mode->c_iflag |= ISTRIP; - mode->c_oflag |= OPOST; - } - else - { - mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; - mode->c_iflag &= ~ISTRIP; - mode->c_oflag &= ~OPOST; - } - } + { + if (reversed) + { + mode->c_cflag = (mode->c_cflag & ~CSIZE) | CS7 | PARENB; + mode->c_iflag |= ISTRIP; + mode->c_oflag |= OPOST; + } + else + { + mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8; + mode->c_iflag &= ~ISTRIP; + mode->c_oflag &= ~OPOST; + } + } else if (STREQ (info->name, "raw") || STREQ (info->name, "cooked")) - { - if ((info->name[0] == 'r' && reversed) - || (info->name[0] == 'c' && !reversed)) - { - /* Cooked mode. */ - mode->c_iflag |= BRKINT | IGNPAR | ISTRIP | ICRNL | IXON; - mode->c_oflag |= OPOST; - mode->c_lflag |= ISIG | ICANON; + { + if ((info->name[0] == 'r' && reversed) + || (info->name[0] == 'c' && !reversed)) + { + /* Cooked mode. */ + mode->c_iflag |= BRKINT | IGNPAR | ISTRIP | ICRNL | IXON; + mode->c_oflag |= OPOST; + mode->c_lflag |= ISIG | ICANON; #if VMIN == VEOF - mode->c_cc[VEOF] = CEOF; + mode->c_cc[VEOF] = CEOF; #endif #if VTIME == VEOL - mode->c_cc[VEOL] = CEOL; + mode->c_cc[VEOL] = CEOL; #endif - } - else - { - /* Raw mode. */ - mode->c_iflag = 0; - mode->c_oflag &= ~OPOST; - mode->c_lflag &= ~(ISIG | ICANON + } + else + { + /* Raw mode. */ + mode->c_iflag = 0; + mode->c_oflag &= ~OPOST; + mode->c_lflag &= ~(ISIG | ICANON #ifdef XCASE - | XCASE + | XCASE #endif - ); - mode->c_cc[VMIN] = 1; - mode->c_cc[VTIME] = 0; - } - } + ); + mode->c_cc[VMIN] = 1; + mode->c_cc[VTIME] = 0; + } + } #ifdef IXANY else if (STREQ (info->name, "decctlq")) - { - if (reversed) - mode->c_iflag |= IXANY; - else - mode->c_iflag &= ~IXANY; - } + { + if (reversed) + mode->c_iflag |= IXANY; + else + mode->c_iflag &= ~IXANY; + } #endif #ifdef TABDLY else if (STREQ (info->name, "tabs")) - { - if (reversed) - mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; - else - mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB0; - } + { + if (reversed) + mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB3; + else + mode->c_oflag = (mode->c_oflag & ~TABDLY) | TAB0; + } #else # ifdef OXTABS else if (STREQ (info->name, "tabs")) - { - if (reversed) - mode->c_oflag = mode->c_oflag | OXTABS; - else - mode->c_oflag = mode->c_oflag & ~OXTABS; - } + { + if (reversed) + mode->c_oflag = mode->c_oflag | OXTABS; + else + mode->c_oflag = mode->c_oflag & ~OXTABS; + } # endif #endif #if defined XCASE && defined IUCLC && defined OLCUC else if (STREQ (info->name, "lcase") - || STREQ (info->name, "LCASE")) - { - if (reversed) - { - mode->c_lflag &= ~XCASE; - mode->c_iflag &= ~IUCLC; - mode->c_oflag &= ~OLCUC; - } - else - { - mode->c_lflag |= XCASE; - mode->c_iflag |= IUCLC; - mode->c_oflag |= OLCUC; - } - } + || STREQ (info->name, "LCASE")) + { + if (reversed) + { + mode->c_lflag &= ~XCASE; + mode->c_iflag &= ~IUCLC; + mode->c_oflag &= ~OLCUC; + } + else + { + mode->c_lflag |= XCASE; + mode->c_iflag |= IUCLC; + mode->c_oflag |= OLCUC; + } + } #endif else if (STREQ (info->name, "crt")) - mode->c_lflag |= ECHOE + mode->c_lflag |= ECHOE #ifdef ECHOCTL - | ECHOCTL + | ECHOCTL #endif #ifdef ECHOKE - | ECHOKE + | ECHOKE #endif - ; + ; else if (STREQ (info->name, "dec")) - { - mode->c_cc[VINTR] = 3; /* ^C */ - mode->c_cc[VERASE] = 127; /* DEL */ - mode->c_cc[VKILL] = 21; /* ^U */ - mode->c_lflag |= ECHOE + { + mode->c_cc[VINTR] = 3; /* ^C */ + mode->c_cc[VERASE] = 127; /* DEL */ + mode->c_cc[VKILL] = 21; /* ^U */ + mode->c_lflag |= ECHOE #ifdef ECHOCTL - | ECHOCTL + | ECHOCTL #endif #ifdef ECHOKE - | ECHOKE + | ECHOKE #endif - ; + ; #ifdef IXANY - mode->c_iflag &= ~IXANY; + mode->c_iflag &= ~IXANY; #endif - } + } } else if (reversed) *bitsp = *bitsp & ~info->mask & ~info->bits; @@ -1268,7 +1276,7 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) static void set_control_char (struct control_info const *info, const char *arg, - struct termios *mode) + struct termios *mode) { unsigned long int value; @@ -1281,9 +1289,9 @@ set_control_char (struct control_info const *info, const char *arg, else if (arg[0] == '^' && arg[1] != '\0') /* Ignore any trailing junk. */ { if (arg[1] == '?') - value = 127; + value = 127; else - value = to_uchar (arg[1]) & ~0140; /* Non-letters get weird results. */ + value = to_uchar (arg[1]) & ~0140; /* Non-letters get weird results. */ } else value = integer_arg (arg, TYPE_MAXIMUM (cc_t)); @@ -1319,7 +1327,7 @@ set_window_size (int rows, int cols, char const *device_name) if (get_win_size (STDIN_FILENO, &win)) { if (errno != EINVAL) - error (EXIT_FAILURE, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); memset (&win, 0, sizeof (win)); } @@ -1361,10 +1369,10 @@ set_window_size (int rows, int cols, char const *device_name) win.ws_col = 1; if (ioctl (STDIN_FILENO, TIOCSWINSZ, (char *) &win)) - error (EXIT_FAILURE, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); if (ioctl (STDIN_FILENO, TIOCSSIZE, (char *) &ttysz)) - error (EXIT_FAILURE, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); return; } # endif @@ -1381,17 +1389,17 @@ display_window_size (bool fancy, char const *device_name) if (get_win_size (STDIN_FILENO, &win)) { if (errno != EINVAL) - error (EXIT_FAILURE, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); if (!fancy) - error (EXIT_FAILURE, 0, - _("%s: no size information for this device"), device_name); + error (EXIT_FAILURE, 0, + _("%s: no size information for this device"), device_name); } else { wrapf (fancy ? "rows %d; columns %d;" : "%d %d\n", - win.ws_row, win.ws_col); + win.ws_row, win.ws_col); if (!fancy) - current_col = 0; + current_col = 0; } } #endif @@ -1416,9 +1424,9 @@ screen_columns (void) char *col_string = getenv ("COLUMNS"); long int n_columns; if (!(col_string != NULL - && xstrtol (col_string, NULL, 0, &n_columns, "") == LONGINT_OK - && 0 < n_columns - && n_columns <= INT_MAX)) + && xstrtol (col_string, NULL, 0, &n_columns, "") == LONGINT_OK + && 0 < n_columns + && n_columns <= INT_MAX)) n_columns = 80; return n_columns; } @@ -1451,7 +1459,7 @@ mode_type_flag (enum mode_type type, struct termios *mode) static void display_settings (enum output_type output_type, struct termios *mode, - char const *device_name) + char const *device_name) { switch (output_type) { @@ -1489,29 +1497,29 @@ display_changed (struct termios *mode) for (i = 0; !STREQ (control_info[i].name, "min"); ++i) { if (mode->c_cc[control_info[i].offset] == control_info[i].saneval) - continue; + continue; /* If swtch is the same as susp, don't print both. */ #if VSWTCH == VSUSP if (STREQ (control_info[i].name, "swtch")) - continue; + continue; #endif /* If eof uses the same slot as min, only print whichever applies. */ #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0 - && (STREQ (control_info[i].name, "eof") - || STREQ (control_info[i].name, "eol"))) - continue; + && (STREQ (control_info[i].name, "eof") + || STREQ (control_info[i].name, "eol"))) + continue; #endif empty_line = false; wrapf ("%s = %s;", control_info[i].name, - visible (mode->c_cc[control_info[i].offset])); + visible (mode->c_cc[control_info[i].offset])); } if ((mode->c_lflag & ICANON) == 0) { wrapf ("min = %lu; time = %lu;\n", - (unsigned long int) mode->c_cc[VMIN], - (unsigned long int) mode->c_cc[VTIME]); + (unsigned long int) mode->c_cc[VMIN], + (unsigned long int) mode->c_cc[VTIME]); } else if (!empty_line) putchar ('\n'); @@ -1521,33 +1529,33 @@ display_changed (struct termios *mode) for (i = 0; mode_info[i].name != NULL; ++i) { if (mode_info[i].flags & OMIT) - continue; + continue; if (mode_info[i].type != prev_type) - { - if (!empty_line) - { - putchar ('\n'); - current_col = 0; - empty_line = true; - } - prev_type = mode_info[i].type; - } + { + if (!empty_line) + { + putchar ('\n'); + current_col = 0; + empty_line = true; + } + prev_type = mode_info[i].type; + } bitsp = mode_type_flag (mode_info[i].type, mode); mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits; if ((*bitsp & mask) == mode_info[i].bits) - { - if (mode_info[i].flags & SANE_UNSET) - { - wrapf ("%s", mode_info[i].name); - empty_line = false; - } - } + { + if (mode_info[i].flags & SANE_UNSET) + { + wrapf ("%s", mode_info[i].name); + empty_line = false; + } + } else if ((mode_info[i].flags & (SANE_SET | REV)) == (SANE_SET | REV)) - { - wrapf ("-%s", mode_info[i].name); - empty_line = false; - } + { + wrapf ("-%s", mode_info[i].name); + empty_line = false; + } } if (!empty_line) putchar ('\n'); @@ -1577,24 +1585,24 @@ display_all (struct termios *mode, char const *device_name) /* If swtch is the same as susp, don't print both. */ #if VSWTCH == VSUSP if (STREQ (control_info[i].name, "swtch")) - continue; + continue; #endif /* If eof uses the same slot as min, only print whichever applies. */ #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0 - && (STREQ (control_info[i].name, "eof") - || STREQ (control_info[i].name, "eol"))) - continue; + && (STREQ (control_info[i].name, "eof") + || STREQ (control_info[i].name, "eol"))) + continue; #endif wrapf ("%s = %s;", control_info[i].name, - visible (mode->c_cc[control_info[i].offset])); + visible (mode->c_cc[control_info[i].offset])); } #if VEOF == VMIN if ((mode->c_lflag & ICANON) == 0) #endif wrapf ("min = %lu; time = %lu;", - (unsigned long int) mode->c_cc[VMIN], - (unsigned long int) mode->c_cc[VTIME]); + (unsigned long int) mode->c_cc[VMIN], + (unsigned long int) mode->c_cc[VTIME]); if (current_col != 0) putchar ('\n'); current_col = 0; @@ -1602,20 +1610,20 @@ display_all (struct termios *mode, char const *device_name) for (i = 0; mode_info[i].name != NULL; ++i) { if (mode_info[i].flags & OMIT) - continue; + continue; if (mode_info[i].type != prev_type) - { - putchar ('\n'); - current_col = 0; - prev_type = mode_info[i].type; - } + { + putchar ('\n'); + current_col = 0; + prev_type = mode_info[i].type; + } bitsp = mode_type_flag (mode_info[i].type, mode); mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits; if ((*bitsp & mask) == mode_info[i].bits) - wrapf ("%s", mode_info[i].name); + wrapf ("%s", mode_info[i].name); else if (mode_info[i].flags & REV) - wrapf ("-%s", mode_info[i].name); + wrapf ("-%s", mode_info[i].name); } putchar ('\n'); current_col = 0; @@ -1626,11 +1634,11 @@ display_speed (struct termios *mode, bool fancy) { if (cfgetispeed (mode) == 0 || cfgetispeed (mode) == cfgetospeed (mode)) wrapf (fancy ? "speed %lu baud;" : "%lu\n", - baud_to_value (cfgetospeed (mode))); + baud_to_value (cfgetospeed (mode))); else wrapf (fancy ? "ispeed %lu baud; ospeed %lu baud;" : "%lu %lu\n", - baud_to_value (cfgetispeed (mode)), - baud_to_value (cfgetospeed (mode))); + baud_to_value (cfgetispeed (mode)), + baud_to_value (cfgetospeed (mode))); if (!fancy) current_col = 0; } @@ -1641,10 +1649,10 @@ display_recoverable (struct termios *mode) size_t i; printf ("%lx:%lx:%lx:%lx", - (unsigned long int) mode->c_iflag, - (unsigned long int) mode->c_oflag, - (unsigned long int) mode->c_cflag, - (unsigned long int) mode->c_lflag); + (unsigned long int) mode->c_iflag, + (unsigned long int) mode->c_oflag, + (unsigned long int) mode->c_cflag, + (unsigned long int) mode->c_lflag); for (i = 0; i < NCCS; ++i) printf (":%lx", (unsigned long int) mode->c_cc[i]); putchar ('\n'); @@ -1653,7 +1661,7 @@ display_recoverable (struct termios *mode) /* NOTE: identical to below, modulo use of tcflag_t */ static int strtoul_tcflag_t (char const *s, int base, char **p, tcflag_t *result, - char delim) + char delim) { unsigned long ul; errno = 0; @@ -1689,7 +1697,7 @@ recover_mode (char const *arg, struct termios *mode) { char *p; if (strtoul_tcflag_t (s, 16, &p, flag + i, ':') != 0) - return false; + return false; s = p + 1; } mode->c_iflag = flag[0]; @@ -1702,7 +1710,7 @@ recover_mode (char const *arg, struct termios *mode) char *p; char delim = i < NCCS - 1 ? ':' : '\0'; if (strtoul_cc_t (s, 16, &p, mode->c_cc + i, delim) != 0) - return false; + return false; s = p + 1; } @@ -1817,7 +1825,7 @@ sane_mode (struct termios *mode) { #if VMIN == VEOF if (STREQ (control_info[i].name, "min")) - break; + break; #endif mode->c_cc[control_info[i].offset] = control_info[i].saneval; } @@ -1825,15 +1833,15 @@ sane_mode (struct termios *mode) for (i = 0; mode_info[i].name != NULL; ++i) { if (mode_info[i].flags & SANE_SET) - { - bitsp = mode_type_flag (mode_info[i].type, mode); - *bitsp = (*bitsp & ~mode_info[i].mask) | mode_info[i].bits; - } + { + bitsp = mode_type_flag (mode_info[i].type, mode); + *bitsp = (*bitsp & ~mode_info[i].mask) | mode_info[i].bits; + } else if (mode_info[i].flags & SANE_UNSET) - { - bitsp = mode_type_flag (mode_info[i].type, mode); - *bitsp = *bitsp & ~mode_info[i].mask & ~mode_info[i].bits; - } + { + bitsp = mode_type_flag (mode_info[i].type, mode); + *bitsp = *bitsp & ~mode_info[i].mask & ~mode_info[i].bits; + } } } @@ -1852,32 +1860,32 @@ visible (cc_t ch) if (ch >= 32) { if (ch < 127) - *bpout++ = ch; + *bpout++ = ch; else if (ch == 127) - { - *bpout++ = '^'; - *bpout++ = '?'; - } + { + *bpout++ = '^'; + *bpout++ = '?'; + } else - { - *bpout++ = 'M'; - *bpout++ = '-'; - if (ch >= 128 + 32) - { - if (ch < 128 + 127) - *bpout++ = ch - 128; - else - { - *bpout++ = '^'; - *bpout++ = '?'; - } - } - else - { - *bpout++ = '^'; - *bpout++ = ch - 128 + 64; - } - } + { + *bpout++ = 'M'; + *bpout++ = '-'; + if (ch >= 128 + 32) + { + if (ch < 128 + 127) + *bpout++ = ch - 128; + else + { + *bpout++ = '^'; + *bpout++ = '?'; + } + } + else + { + *bpout++ = '^'; + *bpout++ = ch - 128 + 64; + } + } } else { diff --git a/src/bin/coreutils/src/su.c b/src/bin/coreutils/src/su.c index f4f1171c3a..ec9c6001ca 100644 --- a/src/bin/coreutils/src/su.c +++ b/src/bin/coreutils/src/su.c @@ -184,7 +184,7 @@ log_su (struct passwd const *pw, bool successful) if (!old_user) { /* getlogin can fail -- usually due to lack of utmp entry. - Resort to getpwuid. */ + Resort to getpwuid. */ struct passwd *pwd = getpwuid (getuid ()); old_user = (pwd ? pwd->pw_name : ""); } @@ -194,20 +194,20 @@ log_su (struct passwd const *pw, bool successful) /* 4.2BSD openlog doesn't have the third parameter. */ openlog (last_component (program_name), 0 # ifdef LOG_AUTH - , LOG_AUTH + , LOG_AUTH # endif - ); + ); syslog (LOG_NOTICE, # ifdef SYSLOG_NON_ROOT - "%s(to %s) %s on %s", + "%s(to %s) %s on %s", # else - "%s%s on %s", + "%s%s on %s", # endif - successful ? "" : "FAILED SU ", + successful ? "" : "FAILED SU ", # ifdef SYSLOG_NON_ROOT - new_user, + new_user, # endif - old_user, tty); + old_user, tty); closelog (); } #endif @@ -258,33 +258,33 @@ modify_environment (const struct passwd *pw, const char *shell) Unset all other environment variables. */ char const *term = getenv ("TERM"); if (term) - term = xstrdup (term); + term = xstrdup (term); environ = xmalloc ((6 + !!term) * sizeof (char *)); environ[0] = NULL; if (term) - xsetenv ("TERM", term); + xsetenv ("TERM", term); xsetenv ("HOME", pw->pw_dir); xsetenv ("SHELL", shell); xsetenv ("USER", pw->pw_name); xsetenv ("LOGNAME", pw->pw_name); xsetenv ("PATH", (pw->pw_uid - ? DEFAULT_LOGIN_PATH - : DEFAULT_ROOT_LOGIN_PATH)); + ? DEFAULT_LOGIN_PATH + : DEFAULT_ROOT_LOGIN_PATH)); } else { /* Set HOME, SHELL, and if not becoming a super-user, - USER and LOGNAME. */ + USER and LOGNAME. */ if (change_environment) - { - xsetenv ("HOME", pw->pw_dir); - xsetenv ("SHELL", shell); - if (pw->pw_uid) - { - xsetenv ("USER", pw->pw_name); - xsetenv ("LOGNAME", pw->pw_name); - } - } + { + xsetenv ("HOME", pw->pw_dir); + xsetenv ("SHELL", shell); + if (pw->pw_uid) + { + xsetenv ("USER", pw->pw_name); + xsetenv ("LOGNAME", pw->pw_name); + } + } } } @@ -312,7 +312,7 @@ change_identity (const struct passwd *pw) static void run_shell (char const *shell, char const *command, char **additional_args, - size_t n_additional_args) + size_t n_additional_args) { size_t n_args = 1 + fast_startup + 2 * !!command + n_additional_args + 1; char const **args = xnmalloc (n_args, sizeof *args); @@ -361,10 +361,10 @@ restricted_shell (const char *shell) while ((line = getusershell ()) != NULL) { if (*line != '#' && STREQ (line, shell)) - { - endusershell (); - return false; - } + { + endusershell (); + return false; + } } endusershell (); return true; @@ -375,7 +375,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... [-] [USER [ARG]...]\n"), program_name); @@ -426,35 +426,35 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "c:flmps:", longopts, NULL)) != -1) { switch (optc) - { - case 'c': - command = optarg; - break; + { + case 'c': + command = optarg; + break; - case 'f': - fast_startup = true; - break; + case 'f': + fast_startup = true; + break; - case 'l': - simulate_login = true; - break; + case 'l': + simulate_login = true; + break; - case 'm': - case 'p': - change_environment = false; - break; + case 'm': + case 'p': + change_environment = false; + break; - case 's': - shell = optarg; - break; + case 's': + shell = optarg; + 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); - } + default: + usage (EXIT_FAILURE); + } } if (optind < argc && STREQ (argv[optind], "-")) @@ -467,7 +467,7 @@ main (int argc, char **argv) pw = getpwnam (new_user); if (! (pw && pw->pw_name && pw->pw_name[0] && pw->pw_dir && pw->pw_dir[0] - && pw->pw_passwd)) + && pw->pw_passwd)) error (EXIT_FAILURE, 0, _("user %s does not exist"), new_user); /* Make a copy of the password information and point pw at the local @@ -482,8 +482,8 @@ main (int argc, char **argv) pw->pw_passwd = xstrdup (pw->pw_passwd); pw->pw_dir = xstrdup (pw->pw_dir); pw->pw_shell = xstrdup (pw->pw_shell && pw->pw_shell[0] - ? pw->pw_shell - : DEFAULT_SHELL); + ? pw->pw_shell + : DEFAULT_SHELL); endpwent (); if (!correct_password (pw)) @@ -505,9 +505,9 @@ main (int argc, char **argv) if (shell && getuid () != 0 && restricted_shell (pw->pw_shell)) { /* The user being su'd to has a nonstandard shell, and so is - probably a uucp account or has restricted access. Don't - compromise the account by allowing access with a standard - shell. */ + probably a uucp account or has restricted access. Don't + compromise the account by allowing access with a standard + shell. */ error (0, 0, _("using restricted shell %s"), pw->pw_shell); shell = NULL; } diff --git a/src/bin/coreutils/src/sum.c b/src/bin/coreutils/src/sum.c index ed62c2faf1..e53bad2ca6 100644 --- a/src/bin/coreutils/src/sum.c +++ b/src/bin/coreutils/src/sum.c @@ -53,13 +53,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Print checksum and block counts for each FILE.\n\ \n\ @@ -98,16 +98,16 @@ bsd_sum_file (const char *file, int print_name) fp = stdin; have_read_stdin = true; if (O_BINARY && ! isatty (STDIN_FILENO)) - xfreopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { fp = fopen (file, (O_BINARY ? "rb" : "r")); if (fp == NULL) - { - error (0, errno, "%s", file); - return false; - } + { + error (0, errno, "%s", file); + return false; + } } while ((ch = getc (fp)) != EOF) @@ -122,7 +122,7 @@ bsd_sum_file (const char *file, int print_name) { error (0, errno, "%s", file); if (!is_stdin) - fclose (fp); + fclose (fp); return false; } @@ -133,7 +133,7 @@ bsd_sum_file (const char *file, int print_name) } printf ("%05d %5s", checksum, - human_readable (total_bytes, hbuf, human_ceiling, 1, 1024)); + human_readable (total_bytes, hbuf, human_ceiling, 1, 1024)); if (print_name > 1) printf (" %s", file); putchar ('\n'); @@ -166,16 +166,16 @@ sysv_sum_file (const char *file, int print_name) fd = STDIN_FILENO; have_read_stdin = true; if (O_BINARY && ! isatty (STDIN_FILENO)) - xfreopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { fd = open (file, O_RDONLY | O_BINARY); if (fd == -1) - { - error (0, errno, "%s", file); - return false; - } + { + error (0, errno, "%s", file); + return false; + } } while (1) @@ -184,18 +184,18 @@ sysv_sum_file (const char *file, int print_name) size_t bytes_read = safe_read (fd, buf, sizeof buf); if (bytes_read == 0) - break; + break; if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, "%s", file); - if (!is_stdin) - close (fd); - return false; - } + { + error (0, errno, "%s", file); + if (!is_stdin) + close (fd); + return false; + } for (i = 0; i < bytes_read; i++) - s += buf[i]; + s += buf[i]; total_bytes += bytes_read; } @@ -209,7 +209,7 @@ sysv_sum_file (const char *file, int print_name) checksum = (r & 0xffff) + (r >> 16); printf ("%d %s", checksum, - human_readable (total_bytes, hbuf, human_ceiling, 1, 512)); + human_readable (total_bytes, hbuf, human_ceiling, 1, 512)); if (print_name) printf (" %s", file); putchar ('\n'); @@ -238,22 +238,22 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "rs", longopts, NULL)) != -1) { switch (optc) - { - case 'r': /* For SysV compatibility. */ - sum_func = bsd_sum_file; - break; + { + case 'r': /* For SysV compatibility. */ + sum_func = bsd_sum_file; + break; - case 's': - sum_func = sysv_sum_file; - break; + case 's': + sum_func = sysv_sum_file; + 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); - } + default: + usage (EXIT_FAILURE); + } } files_given = argc - optind; diff --git a/src/bin/coreutils/src/sync.c b/src/bin/coreutils/src/sync.c index 318f87675e..593071347b 100644 --- a/src/bin/coreutils/src/sync.c +++ b/src/bin/coreutils/src/sync.c @@ -35,7 +35,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]\n"), program_name); @@ -62,7 +62,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/system.h b/src/bin/coreutils/src/system.h index 74d86bbeeb..a15c298b8b 100644 --- a/src/bin/coreutils/src/system.h +++ b/src/bin/coreutils/src/system.h @@ -188,8 +188,8 @@ enum anyone knows of a system for which this limit is too small, please report it as a bug in this code. */ # define ST_BLKSIZE(statbuf) ((0 < (statbuf).st_blksize \ - && (statbuf).st_blksize <= SIZE_MAX / 8 + 1) \ - ? (statbuf).st_blksize : DEV_BSIZE) + && (statbuf).st_blksize <= SIZE_MAX / 8 + 1) \ + ? (statbuf).st_blksize : DEV_BSIZE) # if defined hpux || defined __hpux__ || defined __hpux /* HP-UX counts st_blocks in 1024-byte units. This loses when mixing HP-UX and BSD file systems with NFS. */ @@ -335,7 +335,7 @@ uid_t getuid (); Ensure that sizeof *(P) is *not* 1. In that case, it'd be better to use X2REALLOC, although not strictly necessary. */ #define X2NREALLOC(P, PN) ((void) verify_true (sizeof *(P) != 1), \ - x2nrealloc (P, PN, sizeof *(P))) + x2nrealloc (P, PN, sizeof *(P))) /* Using x2realloc (when appropriate) usually makes your code more readable than using x2nrealloc, but it also makes it so your @@ -370,7 +370,7 @@ readdir_ignoring_dot_and_dotdot (DIR *dirp) { struct dirent const *dp = readdir (dirp); if (dp == NULL || ! dot_or_dotdot (dp->d_name)) - return dp; + return dp; } } @@ -382,8 +382,8 @@ is_empty_dir (int fd_cwd, char const *dir) struct dirent const *dp; int saved_errno; int fd = openat (fd_cwd, dir, - (O_RDONLY | O_DIRECTORY - | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK)); + (O_RDONLY | O_DIRECTORY + | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK)); if (fd < 0) return false; @@ -616,27 +616,46 @@ ptr_align (void const *ptr, size_t alignment) ? false : (((Accum) = (Accum) * 10 + (Digit_val)), true)) \ ) +static inline void +emit_size_note (void) +{ + fputs (_("\n\ +SIZE may be (or may be an integer optionally followed by) one of following:\n\ +KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\ +"), stdout); +} + +static inline void +emit_blocksize_note (char const *program) +{ + printf (_("\n\ +Display values are in units of the first available SIZE from --block-size,\n\ +and the %s_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.\n\ +Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).\n\ +"), program); +} + #include "hard-locale.h" static inline void emit_bug_reporting_address (void) { printf (_("\nReport %s bugs to %s\n"), last_component (program_name), - PACKAGE_BUGREPORT); + PACKAGE_BUGREPORT); /* FIXME 2010: use AC_PACKAGE_URL once we require autoconf-2.64 */ printf (_("%s home page: \n"), - PACKAGE_NAME, PACKAGE); + PACKAGE_NAME, PACKAGE); fputs (_("General help using GNU software: \n"), - stdout); + stdout); if (hard_locale (LC_MESSAGES)) { /* TRANSLATORS: Replace LANG_CODE in this URL with your language code - to form one of - the URLs at http://translationproject.org/team/. Otherwise, replace - the entire URL with your translation team's email address. */ + to form one of + the URLs at http://translationproject.org/team/. Otherwise, replace + the entire URL with your translation team's email address. */ printf (_("Report %s translation bugs to " - "\n"), - last_component (program_name)); + "\n"), + last_component (program_name)); } } @@ -646,8 +665,8 @@ static inline char * timetostr (time_t t, char *buf) { return (TYPE_SIGNED (time_t) - ? imaxtostr (t, buf) - : umaxtostr (t, buf)); + ? imaxtostr (t, buf) + : umaxtostr (t, buf)); } static inline char * diff --git a/src/bin/coreutils/src/tac-pipe.c b/src/bin/coreutils/src/tac-pipe.c index 17e86c070f..1612e2d486 100644 --- a/src/bin/coreutils/src/tac-pipe.c +++ b/src/bin/coreutils/src/tac-pipe.c @@ -62,52 +62,52 @@ buf_init_from_stdin (Buf *x, char eol_byte) size_t bytes_read; if (buf == NULL) - { - /* Fall back on the code that relies on a temporary file. - Write all buffers to that file and free them. */ - /* FIXME */ - ok = false; - break; - } + { + /* Fall back on the code that relies on a temporary file. + Write all buffers to that file and free them. */ + /* FIXME */ + ok = false; + break; + } bytes_read = full_read (STDIN_FILENO, buf, BUFFER_SIZE); if (bytes_read != buffer_size && errno != 0) - error (EXIT_FAILURE, errno, _("read error")); + error (EXIT_FAILURE, errno, _("read error")); { - struct B_pair bp; - bp.start = buf; - bp.one_past_end = buf + bytes_read; - obstack_grow (OBS, &bp, sizeof (bp)); + struct B_pair bp; + bp.start = buf; + bp.one_past_end = buf + bytes_read; + obstack_grow (OBS, &bp, sizeof (bp)); } if (bytes_read != 0) - last_byte_is_eol_byte = (buf[bytes_read - 1] == eol_byte); + last_byte_is_eol_byte = (buf[bytes_read - 1] == eol_byte); if (bytes_read < BUFFER_SIZE) - break; + break; } if (ok) { /* If the file was non-empty and lacked an EOL_BYTE at its end, - then add a buffer containing just that one byte. */ + then add a buffer containing just that one byte. */ if (!last_byte_is_eol_byte) - { - char *buf = malloc (1); - if (buf == NULL) - { - /* FIXME: just like above */ - ok = false; - } - else - { - struct B_pair bp; - *buf = eol_byte; - bp.start = buf; - bp.one_past_end = buf + 1; - obstack_grow (OBS, &bp, sizeof (bp)); - } - } + { + char *buf = malloc (1); + if (buf == NULL) + { + /* FIXME: just like above */ + ok = false; + } + else + { + struct B_pair bp; + *buf = eol_byte; + bp.start = buf; + bp.one_past_end = buf + 1; + obstack_grow (OBS, &bp, sizeof (bp)); + } + } } x->n_bufs = obstack_object_size (OBS) / sizeof (x->p[0]); @@ -172,7 +172,7 @@ line_ptr_increment (const Buf *x, const Line_ptr *lp) static bool find_bol (const Buf *x, - const Line_ptr *last_bol, Line_ptr *new_bol, char eol_byte) + const Line_ptr *last_bol, Line_ptr *new_bol, char eol_byte) { size_t i; Line_ptr tmp; @@ -188,16 +188,16 @@ find_bol (const Buf *x, { char *nl = memrchr (x->p[i].start, last_bol_ptr, eol_byte); if (nl) - { - Line_ptr nl_pos; - nl_pos.i = i; - nl_pos.ptr = nl; - *new_bol = line_ptr_increment (x, &nl_pos); - return true; - } + { + Line_ptr nl_pos; + nl_pos.i = i; + nl_pos.ptr = nl; + *new_bol = line_ptr_increment (x, &nl_pos); + return true; + } if (i == 0) - break; + break; --i; last_bol_ptr = ONE_PAST_END (x, i); @@ -218,7 +218,7 @@ find_bol (const Buf *x, static void print_line (FILE *out_stream, const Buf *x, - const Line_ptr *bol, const Line_ptr *bol_next) + const Line_ptr *bol, const Line_ptr *bol_next) { size_t i; for (i = bol->i; i <= bol_next->i; i++) @@ -254,7 +254,7 @@ tac_mem () { Line_ptr new_bol; if (! find_bol (&x, &bol, &new_bol, eol_byte)) - break; + break; print_line (stdout, &x, &new_bol, &bol); bol = new_bol; } diff --git a/src/bin/coreutils/src/tac.c b/src/bin/coreutils/src/tac.c index 8af1f039e6..e1f71945fb 100644 --- a/src/bin/coreutils/src/tac.c +++ b/src/bin/coreutils/src/tac.c @@ -26,7 +26,7 @@ Options: -b, --before The separator is attached to the beginning - of the record that it precedes in the file. + of the record that it precedes in the file. -r, --regex The separator is a regular expression. -s, --separator=separator Use SEPARATOR as the record separator. @@ -127,13 +127,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Write each FILE to standard output, last line first.\n\ With no FILE, or when FILE is -, read standard input.\n\ @@ -248,133 +248,133 @@ tac_seekable (int input_fd, const char *file) for (;;) { /* Search backward from `match_start' - 1 to `G_buffer' for a match - with `separator'; for speed, use strncmp if `separator' contains no - metacharacters. - If the match succeeds, set `match_start' to point to the start of - the match and `match_length' to the length of the match. - Otherwise, make `match_start' < `G_buffer'. */ + with `separator'; for speed, use strncmp if `separator' contains no + metacharacters. + If the match succeeds, set `match_start' to point to the start of + the match and `match_length' to the length of the match. + Otherwise, make `match_start' < `G_buffer'. */ if (sentinel_length == 0) - { - size_t i = match_start - G_buffer; - regoff_t ri = i; - regoff_t range = 1 - ri; - regoff_t ret; + { + size_t i = match_start - G_buffer; + regoff_t ri = i; + regoff_t range = 1 - ri; + regoff_t ret; - if (1 < range) - error (EXIT_FAILURE, 0, _("record too large")); + if (1 < range) + error (EXIT_FAILURE, 0, _("record too large")); - if (range == 1 - || ((ret = re_search (&compiled_separator, G_buffer, - i, i - 1, range, ®s)) - == -1)) - match_start = G_buffer - 1; - else if (ret == -2) - { - error (EXIT_FAILURE, 0, - _("error in regular expression search")); - } - else - { - match_start = G_buffer + regs.start[0]; - match_length = regs.end[0] - regs.start[0]; - } - } + if (range == 1 + || ((ret = re_search (&compiled_separator, G_buffer, + i, i - 1, range, ®s)) + == -1)) + match_start = G_buffer - 1; + else if (ret == -2) + { + error (EXIT_FAILURE, 0, + _("error in regular expression search")); + } + else + { + match_start = G_buffer + regs.start[0]; + match_length = regs.end[0] - regs.start[0]; + } + } else - { - /* `match_length' is constant for non-regexp boundaries. */ - while (*--match_start != first_char - || (match_length1 && strncmp (match_start + 1, separator1, - match_length1))) - /* Do nothing. */ ; - } + { + /* `match_length' is constant for non-regexp boundaries. */ + while (*--match_start != first_char + || (match_length1 && strncmp (match_start + 1, separator1, + match_length1))) + /* Do nothing. */ ; + } /* Check whether we backed off the front of `G_buffer' without finding a match for `separator'. */ if (match_start < G_buffer) - { - if (file_pos == 0) - { - /* Hit the beginning of the file; print the remaining record. */ - output (G_buffer, past_end); - return true; - } + { + if (file_pos == 0) + { + /* Hit the beginning of the file; print the remaining record. */ + output (G_buffer, past_end); + return true; + } - saved_record_size = past_end - G_buffer; - if (saved_record_size > read_size) - { - /* `G_buffer_size' is about twice `read_size', so since - we want to read in another `read_size' bytes before - the data already in `G_buffer', we need to increase - `G_buffer_size'. */ - char *newbuffer; - size_t offset = sentinel_length ? sentinel_length : 1; - ptrdiff_t match_start_offset = match_start - G_buffer; - ptrdiff_t past_end_offset = past_end - G_buffer; - size_t old_G_buffer_size = G_buffer_size; + saved_record_size = past_end - G_buffer; + if (saved_record_size > read_size) + { + /* `G_buffer_size' is about twice `read_size', so since + we want to read in another `read_size' bytes before + the data already in `G_buffer', we need to increase + `G_buffer_size'. */ + char *newbuffer; + size_t offset = sentinel_length ? sentinel_length : 1; + ptrdiff_t match_start_offset = match_start - G_buffer; + ptrdiff_t past_end_offset = past_end - G_buffer; + size_t old_G_buffer_size = G_buffer_size; - read_size *= 2; - G_buffer_size = read_size * 2 + sentinel_length + 2; - if (G_buffer_size < old_G_buffer_size) - xalloc_die (); - newbuffer = xrealloc (G_buffer - offset, G_buffer_size); - newbuffer += offset; - /* Adjust the pointers for the new buffer location. */ - match_start = newbuffer + match_start_offset; - past_end = newbuffer + past_end_offset; - G_buffer = newbuffer; - } + read_size *= 2; + G_buffer_size = read_size * 2 + sentinel_length + 2; + if (G_buffer_size < old_G_buffer_size) + xalloc_die (); + newbuffer = xrealloc (G_buffer - offset, G_buffer_size); + newbuffer += offset; + /* Adjust the pointers for the new buffer location. */ + match_start = newbuffer + match_start_offset; + past_end = newbuffer + past_end_offset; + G_buffer = newbuffer; + } - /* Back up to the start of the next bufferfull of the file. */ - if (file_pos >= read_size) - file_pos -= read_size; - else - { - read_size = file_pos; - file_pos = 0; - } - if (lseek (input_fd, file_pos, SEEK_SET) < 0) - error (0, errno, _("%s: seek failed"), quotearg_colon (file)); + /* Back up to the start of the next bufferfull of the file. */ + if (file_pos >= read_size) + file_pos -= read_size; + else + { + read_size = file_pos; + file_pos = 0; + } + if (lseek (input_fd, file_pos, SEEK_SET) < 0) + error (0, errno, _("%s: seek failed"), quotearg_colon (file)); - /* Shift the pending record data right to make room for the new. - The source and destination regions probably overlap. */ - memmove (G_buffer + read_size, G_buffer, saved_record_size); - past_end = G_buffer + read_size + saved_record_size; - /* For non-regexp searches, avoid unneccessary scanning. */ - if (sentinel_length) - match_start = G_buffer + read_size; - else - match_start = past_end; + /* Shift the pending record data right to make room for the new. + The source and destination regions probably overlap. */ + memmove (G_buffer + read_size, G_buffer, saved_record_size); + past_end = G_buffer + read_size + saved_record_size; + /* For non-regexp searches, avoid unneccessary scanning. */ + if (sentinel_length) + match_start = G_buffer + read_size; + else + match_start = past_end; - if (safe_read (input_fd, G_buffer, read_size) != read_size) - { - error (0, errno, _("%s: read error"), quotearg_colon (file)); - return false; - } - } + if (safe_read (input_fd, G_buffer, read_size) != read_size) + { + error (0, errno, _("%s: read error"), quotearg_colon (file)); + return false; + } + } else - { - /* Found a match of `separator'. */ - if (separator_ends_record) - { - char *match_end = match_start + match_length; + { + /* Found a match of `separator'. */ + if (separator_ends_record) + { + char *match_end = match_start + match_length; - /* If this match of `separator' isn't at the end of the - file, print the record. */ - if (!first_time || match_end != past_end) - output (match_end, past_end); - past_end = match_end; - first_time = false; - } - else - { - output (match_start, past_end); - past_end = match_start; - } + /* If this match of `separator' isn't at the end of the + file, print the record. */ + if (!first_time || match_end != past_end) + output (match_end, past_end); + past_end = match_end; + first_time = false; + } + else + { + output (match_start, past_end); + past_end = match_start; + } - /* For non-regex matching, we can back up. */ - if (sentinel_length > 0) - match_start -= match_length - 1; - } + /* For non-regex matching, we can back up. */ + if (sentinel_length > 0) + match_start -= match_length - 1; + } } } @@ -435,7 +435,7 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) char const * const Template = "%s/tacXXXXXX"; tempdir = getenv ("TMPDIR"); if (tempdir == NULL) - tempdir = DEFAULT_TMPDIR; + tempdir = DEFAULT_TMPDIR; /* Subtract 2 for `%s' and add 1 for the trailing NUL byte. */ template = xmalloc (strlen (tempdir) + strlen (Template) - 2 + 1); @@ -456,7 +456,7 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) if (fd < 0) { error (0, errno, _("cannot create temporary file in %s"), - quote (tempdir)); + quote (tempdir)); return false; } @@ -475,18 +475,18 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) { size_t bytes_read = safe_read (input_fd, G_buffer, read_size); if (bytes_read == 0) - break; + break; if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, _("%s: read error"), quotearg_colon (file)); - goto Fail; - } + { + error (0, errno, _("%s: read error"), quotearg_colon (file)); + goto Fail; + } if (fwrite (G_buffer, 1, bytes_read, tmp) != bytes_read) - { - error (0, errno, _("%s: write error"), quotearg_colon (tempfile)); - goto Fail; - } + { + error (0, errno, _("%s: write error"), quotearg_colon (tempfile)); + goto Fail; + } } if (fflush (tmp) != 0) @@ -513,7 +513,7 @@ tac_nonseekable (int input_fd, const char *file) FILE *tmp_stream; char *tmp_file; return (copy_to_temp (&tmp_stream, &tmp_file, input_fd, file) - && tac_seekable (fileno (tmp_stream), tmp_file)); + && tac_seekable (fileno (tmp_stream), tmp_file)); } /* Print FILE in reverse, copying it to a temporary @@ -534,23 +534,23 @@ tac_file (const char *filename) fd = STDIN_FILENO; filename = _("standard input"); if (O_BINARY && ! isatty (STDIN_FILENO)) - xfreopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else { fd = open (filename, O_RDONLY | O_BINARY); if (fd < 0) - { - error (0, errno, _("cannot open %s for reading"), quote (filename)); - return false; - } + { + error (0, errno, _("cannot open %s for reading"), quote (filename)); + return false; + } } file_size = lseek (fd, (off_t) 0, SEEK_END); ok = (file_size < 0 || isatty (fd) - ? tac_nonseekable (fd, filename) - : tac_seekable (fd, filename)); + ? tac_nonseekable (fd, filename) + : tac_seekable (fd, filename)); if (!is_stdin && close (fd) != 0) { @@ -588,23 +588,23 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "brs:", longopts, NULL)) != -1) { switch (optc) - { - case 'b': - separator_ends_record = false; - break; - case 'r': - sentinel_length = 0; - break; - case 's': - separator = optarg; - if (*separator == 0) - error (EXIT_FAILURE, 0, _("separator cannot be empty")); - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + { + case 'b': + separator_ends_record = false; + break; + case 'r': + sentinel_length = 0; + break; + case 's': + separator = optarg; + if (*separator == 0) + error (EXIT_FAILURE, 0, _("separator cannot be empty")); + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (EXIT_FAILURE); + } } if (sentinel_length == 0) @@ -614,9 +614,9 @@ main (int argc, char **argv) compiled_separator.fastmap = compiled_separator_fastmap; compiled_separator.translate = NULL; error_message = re_compile_pattern (separator, strlen (separator), - &compiled_separator); + &compiled_separator); if (error_message) - error (EXIT_FAILURE, 0, "%s", error_message); + error (EXIT_FAILURE, 0, "%s", error_message); } else match_length = sentinel_length = strlen (separator); @@ -625,7 +625,7 @@ main (int argc, char **argv) while (sentinel_length >= read_size / 2) { if (SIZE_MAX / 2 < read_size) - xalloc_die (); + xalloc_die (); read_size *= 2; } half_buffer_size = read_size + sentinel_length + 1; @@ -644,8 +644,8 @@ main (int argc, char **argv) } file = (optind < argc - ? (char const *const *) &argv[optind] - : default_file_list); + ? (char const *const *) &argv[optind] + : default_file_list); if (O_BINARY && ! isatty (STDOUT_FILENO)) xfreopen (NULL, "wb", stdout); diff --git a/src/bin/coreutils/src/tail.c b/src/bin/coreutils/src/tail.c index 6f83706258..3f583f114b 100644 --- a/src/bin/coreutils/src/tail.c +++ b/src/bin/coreutils/src/tail.c @@ -201,6 +201,10 @@ static bool have_read_stdin; more expensive) code unconditionally. Intended solely for testing. */ static bool presume_input_pipe; +/* If nonzero then don't use inotify even if available. + Intended solely for testing. */ +static bool disable_inotify; + /* For long options that have no equivalent short option, use a non-character as a pseudo short option, starting with CHAR_MAX + 1. */ enum @@ -209,7 +213,8 @@ enum MAX_UNCHANGED_STATS_OPTION, PID_OPTION, PRESUME_INPUT_PIPE_OPTION, - LONG_FOLLOW_OPTION + LONG_FOLLOW_OPTION, + DISABLE_INOTIFY_OPTION }; static struct option const long_options[] = @@ -218,6 +223,8 @@ static struct option const long_options[] = {"follow", optional_argument, NULL, LONG_FOLLOW_OPTION}, {"lines", required_argument, NULL, 'n'}, {"max-unchanged-stats", required_argument, NULL, MAX_UNCHANGED_STATS_OPTION}, + {"-disable-inotify", no_argument, NULL, + DISABLE_INOTIFY_OPTION}, /* do not document */ {"pid", required_argument, NULL, PID_OPTION}, {"-presume-input-pipe", no_argument, NULL, PRESUME_INPUT_PIPE_OPTION}, /* do not document */ @@ -236,13 +243,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); printf (_("\ Print the last %d lines of each FILE to standard output.\n\ With more than one FILE, precede each with a header giving the file name.\n\ @@ -272,9 +279,9 @@ Mandatory arguments to long options are mandatory for short options too.\n\ to see if it has been unlinked or renamed\n\ (this is the usual case of rotated log files)\n\ "), - DEFAULT_N_LINES, - DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS - ); + DEFAULT_N_LINES, + DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS + ); fputs (_("\ --pid=PID with -f, terminate after process ID, PID dies\n\ -q, --quiet, --silent never output headers giving file names\n\ @@ -283,7 +290,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ name, i.e., with --follow=name\n\ "), stdout); fputs (_("\ - -s, --sleep-interval=S with -f, sleep for approximately S seconds\n\ + -s, --sleep-interval=N with -f, sleep for approximately N seconds\n\ (default 1.0) between iterations\n\ -v, --verbose always output headers giving file names\n\ "), stdout); @@ -340,8 +347,8 @@ xwrite_stdout (char const *buffer, size_t n_bytes) static void record_open_fd (struct File_spec *f, int fd, - off_t size, struct stat const *st, - int blocking) + off_t size, struct stat const *st, + int blocking) { f->fd = fd; f->size = size; @@ -351,7 +358,7 @@ record_open_fd (struct File_spec *f, int fd, f->mode = st->st_mode; f->blocking = blocking; f->n_unchanged_stats = 0; - f->ignore = 0; + f->ignore = false; } /* Close the file with descriptor FD and name FILENAME. */ @@ -392,22 +399,22 @@ dump_remainder (const char *pretty_filename, int fd, uintmax_t n_bytes) size_t n = MIN (n_remaining, BUFSIZ); size_t bytes_read = safe_read (fd, buffer, n); if (bytes_read == SAFE_READ_ERROR) - { - if (errno != EAGAIN) - error (EXIT_FAILURE, errno, _("error reading %s"), - quote (pretty_filename)); - break; - } + { + if (errno != EAGAIN) + error (EXIT_FAILURE, errno, _("error reading %s"), + quote (pretty_filename)); + break; + } if (bytes_read == 0) - break; + break; xwrite_stdout (buffer, bytes_read); n_written += bytes_read; if (n_bytes != COPY_TO_EOF) - { - n_remaining -= bytes_read; - if (n_remaining == 0 || n_bytes == COPY_A_BUFFER) - break; - } + { + n_remaining -= bytes_read; + if (n_remaining == 0 || n_bytes == COPY_A_BUFFER) + break; + } } return n_written; @@ -433,15 +440,15 @@ xlseek (int fd, off_t offset, int whence, char const *filename) { case SEEK_SET: error (0, errno, _("%s: cannot seek to offset %s"), - filename, s); + filename, s); break; case SEEK_CUR: error (0, errno, _("%s: cannot seek to relative offset %s"), - filename, s); + filename, s); break; case SEEK_END: error (0, errno, _("%s: cannot seek to end-relative offset %s"), - filename, s); + filename, s); break; default: abort (); @@ -461,7 +468,7 @@ xlseek (int fd, off_t offset, int whence, char const *filename) static bool file_lines (const char *pretty_filename, int fd, uintmax_t n_lines, - off_t start_pos, off_t end_pos, uintmax_t *read_pos) + off_t start_pos, off_t end_pos, uintmax_t *read_pos) { char buffer[BUFSIZ]; size_t bytes_read; @@ -497,43 +504,43 @@ file_lines (const char *pretty_filename, int fd, uintmax_t n_lines, size_t n = bytes_read; while (n) - { - char const *nl; - nl = memrchr (buffer, '\n', n); - if (nl == NULL) - break; - n = nl - buffer; - if (n_lines-- == 0) - { - /* If this newline isn't the last character in the buffer, - output the part that is after it. */ - if (n != bytes_read - 1) - xwrite_stdout (nl + 1, bytes_read - (n + 1)); - *read_pos += dump_remainder (pretty_filename, fd, - end_pos - (pos + bytes_read)); - return true; - } - } + { + char const *nl; + nl = memrchr (buffer, '\n', n); + if (nl == NULL) + break; + n = nl - buffer; + if (n_lines-- == 0) + { + /* If this newline isn't the last character in the buffer, + output the part that is after it. */ + if (n != bytes_read - 1) + xwrite_stdout (nl + 1, bytes_read - (n + 1)); + *read_pos += dump_remainder (pretty_filename, fd, + end_pos - (pos + bytes_read)); + return true; + } + } /* Not enough newlines in that bufferfull. */ if (pos == start_pos) - { - /* Not enough lines in the file; print everything from - start_pos to the end. */ - xlseek (fd, start_pos, SEEK_SET, pretty_filename); - *read_pos = start_pos + dump_remainder (pretty_filename, fd, - end_pos); - return true; - } + { + /* Not enough lines in the file; print everything from + start_pos to the end. */ + xlseek (fd, start_pos, SEEK_SET, pretty_filename); + *read_pos = start_pos + dump_remainder (pretty_filename, fd, + end_pos); + return true; + } pos -= BUFSIZ; xlseek (fd, pos, SEEK_SET, pretty_filename); bytes_read = safe_read (fd, buffer, BUFSIZ); if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, _("error reading %s"), quote (pretty_filename)); - return false; - } + { + error (0, errno, _("error reading %s"), quote (pretty_filename)); + return false; + } *read_pos = pos + bytes_read; } @@ -549,7 +556,7 @@ file_lines (const char *pretty_filename, int fd, uintmax_t n_lines, static bool pipe_lines (const char *pretty_filename, int fd, uintmax_t n_lines, - uintmax_t *read_pos) + uintmax_t *read_pos) { struct linebuffer { @@ -574,7 +581,7 @@ pipe_lines (const char *pretty_filename, int fd, uintmax_t n_lines, { n_read = safe_read (fd, tmp->buffer, BUFSIZ); if (n_read == 0 || n_read == SAFE_READ_ERROR) - break; + break; tmp->nbytes = n_read; *read_pos += n_read; tmp->nlines = 0; @@ -582,13 +589,13 @@ pipe_lines (const char *pretty_filename, int fd, uintmax_t n_lines, /* Count the number of newlines just read. */ { - char const *buffer_end = tmp->buffer + n_read; - char const *p = tmp->buffer; - while ((p = memchr (p, '\n', buffer_end - p))) - { - ++p; - ++tmp->nlines; - } + char const *buffer_end = tmp->buffer + n_read; + char const *p = tmp->buffer; + while ((p = memchr (p, '\n', buffer_end - p))) + { + ++p; + ++tmp->nlines; + } } total_lines += tmp->nlines; @@ -596,28 +603,28 @@ pipe_lines (const char *pretty_filename, int fd, uintmax_t n_lines, one to it. This is because when reading from a pipe, `n_read' can often be very small. */ if (tmp->nbytes + last->nbytes < BUFSIZ) - { - memcpy (&last->buffer[last->nbytes], tmp->buffer, tmp->nbytes); - last->nbytes += tmp->nbytes; - last->nlines += tmp->nlines; - } + { + memcpy (&last->buffer[last->nbytes], tmp->buffer, tmp->nbytes); + last->nbytes += tmp->nbytes; + last->nlines += tmp->nlines; + } else - { - /* If there's not enough room, link the new buffer onto the end of - the list, then either free up the oldest buffer for the next - read if that would leave enough lines, or else malloc a new one. - Some compaction mechanism is possible but probably not - worthwhile. */ - last = last->next = tmp; - if (total_lines - first->nlines > n_lines) - { - tmp = first; - total_lines -= first->nlines; - first = first->next; - } - else - tmp = xmalloc (sizeof (LBUFFER)); - } + { + /* If there's not enough room, link the new buffer onto the end of + the list, then either free up the oldest buffer for the next + read if that would leave enough lines, or else malloc a new one. + Some compaction mechanism is possible but probably not + worthwhile. */ + last = last->next = tmp; + if (total_lines - first->nlines > n_lines) + { + tmp = first; + total_lines -= first->nlines; + first = first->next; + } + else + tmp = xmalloc (sizeof (LBUFFER)); + } } free (tmp); @@ -655,15 +662,15 @@ pipe_lines (const char *pretty_filename, int fd, uintmax_t n_lines, char const *buffer_end = tmp->buffer + tmp->nbytes; if (total_lines > n_lines) { - /* Skip `total_lines' - `n_lines' newlines. We made sure that - `total_lines' - `n_lines' <= `tmp->nlines'. */ - size_t j; - for (j = total_lines - n_lines; j; --j) - { - beg = memchr (beg, '\n', buffer_end - beg); - assert (beg); - ++beg; - } + /* Skip `total_lines' - `n_lines' newlines. We made sure that + `total_lines' - `n_lines' <= `tmp->nlines'. */ + size_t j; + for (j = total_lines - n_lines; j; --j) + { + beg = memchr (beg, '\n', buffer_end - beg); + assert (beg); + ++beg; + } } xwrite_stdout (beg, buffer_end - beg); @@ -688,7 +695,7 @@ free_lbuffers: static bool pipe_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, - uintmax_t *read_pos) + uintmax_t *read_pos) { struct charbuffer { @@ -713,7 +720,7 @@ pipe_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, { n_read = safe_read (fd, tmp->buffer, BUFSIZ); if (n_read == 0 || n_read == SAFE_READ_ERROR) - break; + break; *read_pos += n_read; tmp->nbytes = n_read; tmp->next = NULL; @@ -723,29 +730,29 @@ pipe_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, one to it. This is because when reading from a pipe, `nbytes' can often be very small. */ if (tmp->nbytes + last->nbytes < BUFSIZ) - { - memcpy (&last->buffer[last->nbytes], tmp->buffer, tmp->nbytes); - last->nbytes += tmp->nbytes; - } + { + memcpy (&last->buffer[last->nbytes], tmp->buffer, tmp->nbytes); + last->nbytes += tmp->nbytes; + } else - { - /* If there's not enough room, link the new buffer onto the end of - the list, then either free up the oldest buffer for the next - read if that would leave enough characters, or else malloc a new - one. Some compaction mechanism is possible but probably not - worthwhile. */ - last = last->next = tmp; - if (total_bytes - first->nbytes > n_bytes) - { - tmp = first; - total_bytes -= first->nbytes; - first = first->next; - } - else - { - tmp = xmalloc (sizeof (CBUFFER)); - } - } + { + /* If there's not enough room, link the new buffer onto the end of + the list, then either free up the oldest buffer for the next + read if that would leave enough characters, or else malloc a new + one. Some compaction mechanism is possible but probably not + worthwhile. */ + last = last->next = tmp; + if (total_bytes - first->nbytes > n_bytes) + { + tmp = first; + total_bytes -= first->nbytes; + first = first->next; + } + else + { + tmp = xmalloc (sizeof (CBUFFER)); + } + } } free (tmp); @@ -789,7 +796,7 @@ free_cbuffers: static int start_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, - uintmax_t *read_pos) + uintmax_t *read_pos) { char buffer[BUFSIZ]; @@ -797,22 +804,22 @@ start_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, { size_t bytes_read = safe_read (fd, buffer, BUFSIZ); if (bytes_read == 0) - return -1; + return -1; if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, _("error reading %s"), quote (pretty_filename)); - return 1; - } + { + error (0, errno, _("error reading %s"), quote (pretty_filename)); + return 1; + } read_pos += bytes_read; if (bytes_read <= n_bytes) - n_bytes -= bytes_read; + n_bytes -= bytes_read; else - { - size_t n_remaining = bytes_read - n_bytes; - if (n_remaining) - xwrite_stdout (&buffer[n_bytes], n_remaining); - break; - } + { + size_t n_remaining = bytes_read - n_bytes; + if (n_remaining) + xwrite_stdout (&buffer[n_bytes], n_remaining); + break; + } } return 0; @@ -824,7 +831,7 @@ start_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, static int start_lines (const char *pretty_filename, int fd, uintmax_t n_lines, - uintmax_t *read_pos) + uintmax_t *read_pos) { if (n_lines == 0) return 0; @@ -836,25 +843,25 @@ start_lines (const char *pretty_filename, int fd, uintmax_t n_lines, size_t bytes_read = safe_read (fd, buffer, BUFSIZ); char *buffer_end = buffer + bytes_read; if (bytes_read == 0) /* EOF */ - return -1; + return -1; if (bytes_read == SAFE_READ_ERROR) /* error */ - { - error (0, errno, _("error reading %s"), quote (pretty_filename)); - return 1; - } + { + error (0, errno, _("error reading %s"), quote (pretty_filename)); + return 1; + } *read_pos += bytes_read; while ((p = memchr (p, '\n', buffer_end - p))) - { - ++p; - if (--n_lines == 0) - { - if (p < buffer_end) - xwrite_stdout (p, buffer_end - p); - return 0; - } - } + { + ++p; + if (--n_lines == 0) + { + if (p < buffer_end) + xwrite_stdout (p, buffer_end - p); + return 0; + } + } } } @@ -871,8 +878,8 @@ recheck (struct File_spec *f, bool blocking) int prev_errnum = f->errnum; bool new_file; int fd = (is_stdin - ? STDIN_FILENO - : open (f->name, O_RDONLY | (blocking ? 0 : O_NONBLOCK))); + ? STDIN_FILENO + : open (f->name, O_RDONLY | (blocking ? 0 : O_NONBLOCK))); assert (valid_file_spec (f)); @@ -885,25 +892,25 @@ recheck (struct File_spec *f, bool blocking) ok = false; f->errnum = errno; if (!f->tailable) - { - if (was_tailable) - { - /* FIXME-maybe: detect the case in which the file first becomes - unreadable (perms), and later becomes readable again and can - be seen to be the same file (dev/ino). Otherwise, tail prints - the entire contents of the file when it becomes readable. */ - error (0, f->errnum, _("%s has become inaccessible"), - quote (pretty_name (f))); - } - else - { - /* say nothing... it's still not tailable */ - } - } + { + if (was_tailable) + { + /* FIXME-maybe: detect the case in which the file first becomes + unreadable (perms), and later becomes readable again and can + be seen to be the same file (dev/ino). Otherwise, tail prints + the entire contents of the file when it becomes readable. */ + error (0, f->errnum, _("%s has become inaccessible"), + quote (pretty_name (f))); + } + else + { + /* say nothing... it's still not tailable */ + } + } else if (prev_errnum != errno) - { - error (0, errno, "%s", pretty_name (f)); - } + { + error (0, errno, "%s", pretty_name (f)); + } } else if (!IS_TAILABLE_FILE_TYPE (new_stats.st_mode)) { @@ -911,7 +918,7 @@ recheck (struct File_spec *f, bool blocking) f->errnum = -1; error (0, 0, _("%s has been replaced with an untailable file;\ giving up on this name"), - quote (pretty_name (f))); + quote (pretty_name (f))); f->ignore = true; } else @@ -936,36 +943,36 @@ recheck (struct File_spec *f, bool blocking) { new_file = true; if (f->fd == -1) - { - error (0, 0, - _("%s has appeared; following end of new file"), - quote (pretty_name (f))); - } + { + error (0, 0, + _("%s has appeared; following end of new file"), + quote (pretty_name (f))); + } else - { - /* Close the old one. */ - close_fd (f->fd, pretty_name (f)); + { + /* Close the old one. */ + close_fd (f->fd, pretty_name (f)); - /* File has been replaced (e.g., via log rotation) -- - tail the new one. */ - error (0, 0, - _("%s has been replaced; following end of new file"), - quote (pretty_name (f))); - } + /* File has been replaced (e.g., via log rotation) -- + tail the new one. */ + error (0, 0, + _("%s has been replaced; following end of new file"), + quote (pretty_name (f))); + } } else { if (f->fd == -1) - { - /* This happens when one iteration finds the file missing, - then the preceding pair is reused as the - file is recreated. */ - new_file = true; - } + { + /* This happens when one iteration finds the file missing, + then the preceding pair is reused as the + file is recreated. */ + new_file = true; + } else - { - close_fd (fd, pretty_name (f)); - } + { + close_fd (fd, pretty_name (f)); + } } if (new_file) @@ -1002,7 +1009,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval) { /* Use blocking I/O as an optimization, when it's easy. */ bool blocking = (pid == 0 && follow_mode == Follow_descriptor - && n_files == 1 && ! S_ISREG (f[0].mode)); + && n_files == 1 && ! S_ISREG (f[0].mode)); size_t last; bool writer_is_dead = false; @@ -1014,132 +1021,132 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval) bool any_input = false; for (i = 0; i < n_files; i++) - { - int fd; - char const *name; - mode_t mode; - struct stat stats; - uintmax_t bytes_read; + { + int fd; + char const *name; + mode_t mode; + struct stat stats; + uintmax_t bytes_read; - if (f[i].ignore) - continue; + if (f[i].ignore) + continue; - if (f[i].fd < 0) - { - recheck (&f[i], blocking); - continue; - } + if (f[i].fd < 0) + { + recheck (&f[i], blocking); + continue; + } - fd = f[i].fd; - name = pretty_name (&f[i]); - mode = f[i].mode; + fd = f[i].fd; + name = pretty_name (&f[i]); + mode = f[i].mode; - if (f[i].blocking != blocking) - { - int old_flags = fcntl (fd, F_GETFL); - int new_flags = old_flags | (blocking ? 0 : O_NONBLOCK); - if (old_flags < 0 - || (new_flags != old_flags - && fcntl (fd, F_SETFL, new_flags) == -1)) - { - /* Don't update f[i].blocking if fcntl fails. */ - if (S_ISREG (f[i].mode) && errno == EPERM) - { - /* This happens when using tail -f on a file with - the append-only attribute. */ - } - else - error (EXIT_FAILURE, errno, - _("%s: cannot change nonblocking mode"), name); - } - else - f[i].blocking = blocking; - } + if (f[i].blocking != blocking) + { + int old_flags = fcntl (fd, F_GETFL); + int new_flags = old_flags | (blocking ? 0 : O_NONBLOCK); + if (old_flags < 0 + || (new_flags != old_flags + && fcntl (fd, F_SETFL, new_flags) == -1)) + { + /* Don't update f[i].blocking if fcntl fails. */ + if (S_ISREG (f[i].mode) && errno == EPERM) + { + /* This happens when using tail -f on a file with + the append-only attribute. */ + } + else + error (EXIT_FAILURE, errno, + _("%s: cannot change nonblocking mode"), name); + } + else + f[i].blocking = blocking; + } - if (!f[i].blocking) - { - if (fstat (fd, &stats) != 0) - { - f[i].fd = -1; - f[i].errnum = errno; - error (0, errno, "%s", name); - continue; - } + if (!f[i].blocking) + { + if (fstat (fd, &stats) != 0) + { + f[i].fd = -1; + f[i].errnum = errno; + error (0, errno, "%s", name); + continue; + } - if (f[i].mode == stats.st_mode - && (! S_ISREG (stats.st_mode) || f[i].size == stats.st_size) - && timespec_cmp (f[i].mtime, get_stat_mtime (&stats)) == 0) - { - if ((max_n_unchanged_stats_between_opens - <= f[i].n_unchanged_stats++) - && follow_mode == Follow_name) - { - recheck (&f[i], f[i].blocking); - f[i].n_unchanged_stats = 0; - } - continue; - } + if (f[i].mode == stats.st_mode + && (! S_ISREG (stats.st_mode) || f[i].size == stats.st_size) + && timespec_cmp (f[i].mtime, get_stat_mtime (&stats)) == 0) + { + if ((max_n_unchanged_stats_between_opens + <= f[i].n_unchanged_stats++) + && follow_mode == Follow_name) + { + recheck (&f[i], f[i].blocking); + f[i].n_unchanged_stats = 0; + } + continue; + } - /* This file has changed. Print out what we can, and - then keep looping. */ + /* This file has changed. Print out what we can, and + then keep looping. */ - f[i].mtime = get_stat_mtime (&stats); - f[i].mode = stats.st_mode; + f[i].mtime = get_stat_mtime (&stats); + f[i].mode = stats.st_mode; - /* reset counter */ - f[i].n_unchanged_stats = 0; + /* reset counter */ + f[i].n_unchanged_stats = 0; - if (S_ISREG (mode) && stats.st_size < f[i].size) - { - error (0, 0, _("%s: file truncated"), name); - last = i; - xlseek (fd, stats.st_size, SEEK_SET, name); - f[i].size = stats.st_size; - continue; - } + if (S_ISREG (mode) && stats.st_size < f[i].size) + { + error (0, 0, _("%s: file truncated"), name); + last = i; + xlseek (fd, stats.st_size, SEEK_SET, name); + f[i].size = stats.st_size; + continue; + } - if (i != last) - { - if (print_headers) - write_header (name); - last = i; - } - } + if (i != last) + { + if (print_headers) + write_header (name); + last = i; + } + } - bytes_read = dump_remainder (name, fd, - (f[i].blocking - ? COPY_A_BUFFER : COPY_TO_EOF)); - any_input |= (bytes_read != 0); - f[i].size += bytes_read; - } + bytes_read = dump_remainder (name, fd, + (f[i].blocking + ? COPY_A_BUFFER : COPY_TO_EOF)); + any_input |= (bytes_read != 0); + f[i].size += bytes_read; + } if (! any_live_files (f, n_files) && ! reopen_inaccessible_files) - { - error (0, 0, _("no files remaining")); - break; - } + { + error (0, 0, _("no files remaining")); + break; + } if ((!any_input | blocking) && fflush (stdout) != 0) - error (EXIT_FAILURE, errno, _("write error")); + error (EXIT_FAILURE, errno, _("write error")); /* If nothing was read, sleep and/or check for dead writers. */ if (!any_input) - { - if (writer_is_dead) - break; + { + if (writer_is_dead) + break; - if (xnanosleep (sleep_interval)) - error (EXIT_FAILURE, errno, _("cannot read realtime clock")); + if (xnanosleep (sleep_interval)) + error (EXIT_FAILURE, errno, _("cannot read realtime clock")); - /* Once the writer is dead, read the files once more to - avoid a race condition. */ - writer_is_dead = (pid != 0 - && kill (pid, 0) != 0 - /* Handle the case in which you cannot send a - signal to the writer, so kill fails and sets - errno to EPERM. */ - && errno != EPERM); - } + /* Once the writer is dead, read the files once more to + avoid a race condition. */ + writer_is_dead = (pid != 0 + && kill (pid, 0) != 0 + /* Handle the case in which you cannot send a + signal to the writer, so kill fails and sets + errno to EPERM. */ + && errno != EPERM); + } } } @@ -1392,7 +1399,6 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, if (fflush (stdout) != 0) error (EXIT_FAILURE, errno, _("write error")); } - } #endif @@ -1401,7 +1407,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, static bool tail_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, - uintmax_t *read_pos) + uintmax_t *read_pos) { struct stat stats; @@ -1414,50 +1420,50 @@ tail_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, if (from_start) { if ( ! presume_input_pipe - && S_ISREG (stats.st_mode) && n_bytes <= OFF_T_MAX) - { - xlseek (fd, n_bytes, SEEK_CUR, pretty_filename); - *read_pos += n_bytes; - } + && S_ISREG (stats.st_mode) && n_bytes <= OFF_T_MAX) + { + xlseek (fd, n_bytes, SEEK_CUR, pretty_filename); + *read_pos += n_bytes; + } else - { - int t = start_bytes (pretty_filename, fd, n_bytes, read_pos); - if (t) - return t < 0; - } + { + int t = start_bytes (pretty_filename, fd, n_bytes, read_pos); + if (t) + return t < 0; + } *read_pos += dump_remainder (pretty_filename, fd, COPY_TO_EOF); } else { if ( ! presume_input_pipe - && S_ISREG (stats.st_mode) && n_bytes <= OFF_T_MAX) - { - off_t current_pos = xlseek (fd, 0, SEEK_CUR, pretty_filename); - off_t end_pos = xlseek (fd, 0, SEEK_END, pretty_filename); - off_t diff = end_pos - current_pos; - /* Be careful here. The current position may actually be - beyond the end of the file. */ - off_t bytes_remaining = (diff = end_pos - current_pos) < 0 ? 0 : diff; - off_t nb = n_bytes; + && S_ISREG (stats.st_mode) && n_bytes <= OFF_T_MAX) + { + off_t current_pos = xlseek (fd, 0, SEEK_CUR, pretty_filename); + off_t end_pos = xlseek (fd, 0, SEEK_END, pretty_filename); + off_t diff = end_pos - current_pos; + /* Be careful here. The current position may actually be + beyond the end of the file. */ + off_t bytes_remaining = diff < 0 ? 0 : diff; + off_t nb = n_bytes; - if (bytes_remaining <= nb) - { - /* From the current position to end of file, there are no - more bytes than have been requested. So reposition the - file pointer to the incoming current position and print - everything after that. */ - *read_pos = xlseek (fd, current_pos, SEEK_SET, pretty_filename); - } - else - { - /* There are more bytes remaining than were requested. - Back up. */ - *read_pos = xlseek (fd, -nb, SEEK_END, pretty_filename); - } - *read_pos += dump_remainder (pretty_filename, fd, n_bytes); - } + if (bytes_remaining <= nb) + { + /* From the current position to end of file, there are no + more bytes than have been requested. So reposition the + file pointer to the incoming current position and print + everything after that. */ + *read_pos = xlseek (fd, current_pos, SEEK_SET, pretty_filename); + } + else + { + /* There are more bytes remaining than were requested. + Back up. */ + *read_pos = xlseek (fd, -nb, SEEK_END, pretty_filename); + } + *read_pos += dump_remainder (pretty_filename, fd, n_bytes); + } else - return pipe_bytes (pretty_filename, fd, n_bytes, read_pos); + return pipe_bytes (pretty_filename, fd, n_bytes, read_pos); } return true; } @@ -1467,7 +1473,7 @@ tail_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, static bool tail_lines (const char *pretty_filename, int fd, uintmax_t n_lines, - uintmax_t *read_pos) + uintmax_t *read_pos) { struct stat stats; @@ -1481,7 +1487,7 @@ tail_lines (const char *pretty_filename, int fd, uintmax_t n_lines, { int t = start_lines (pretty_filename, fd, n_lines, read_pos); if (t) - return t < 0; + return t < 0; *read_pos += dump_remainder (pretty_filename, fd, COPY_TO_EOF); } else @@ -1490,29 +1496,29 @@ tail_lines (const char *pretty_filename, int fd, uintmax_t n_lines, off_t end_pos; /* Use file_lines only if FD refers to a regular file for - which lseek (... SEEK_END) works. */ + which lseek (... SEEK_END) works. */ if ( ! presume_input_pipe - && S_ISREG (stats.st_mode) - && (start_pos = lseek (fd, 0, SEEK_CUR)) != -1 - && start_pos < (end_pos = lseek (fd, 0, SEEK_END))) - { - *read_pos = end_pos; - if (end_pos != 0 - && ! file_lines (pretty_filename, fd, n_lines, - start_pos, end_pos, read_pos)) - return false; - } + && S_ISREG (stats.st_mode) + && (start_pos = lseek (fd, 0, SEEK_CUR)) != -1 + && start_pos < (end_pos = lseek (fd, 0, SEEK_END))) + { + *read_pos = end_pos; + if (end_pos != 0 + && ! file_lines (pretty_filename, fd, n_lines, + start_pos, end_pos, read_pos)) + return false; + } else - { - /* Under very unlikely circumstances, it is possible to reach - this point after positioning the file pointer to end of file - via the `lseek (...SEEK_END)' above. In that case, reposition - the file pointer back to start_pos before calling pipe_lines. */ - if (start_pos != -1) - xlseek (fd, start_pos, SEEK_SET, pretty_filename); + { + /* Under very unlikely circumstances, it is possible to reach + this point after positioning the file pointer to end of file + via the `lseek (...SEEK_END)' above. In that case, reposition + the file pointer back to start_pos before calling pipe_lines. */ + if (start_pos != -1) + xlseek (fd, start_pos, SEEK_SET, pretty_filename); - return pipe_lines (pretty_filename, fd, n_lines, read_pos); - } + return pipe_lines (pretty_filename, fd, n_lines, read_pos); + } } return true; } @@ -1554,7 +1560,7 @@ tail_file (struct File_spec *f, uintmax_t n_units) have_read_stdin = true; fd = STDIN_FILENO; if (O_BINARY && ! isatty (STDIN_FILENO)) - xfreopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); } else fd = open (f->name, O_RDONLY | O_BINARY); @@ -1564,15 +1570,15 @@ tail_file (struct File_spec *f, uintmax_t n_units) if (fd == -1) { if (forever) - { - f->fd = -1; - f->errnum = errno; - f->ignore = false; - f->ino = 0; - f->dev = 0; - } + { + f->fd = -1; + f->errnum = errno; + f->ignore = false; + f->ino = 0; + f->dev = 0; + } error (0, errno, _("cannot open %s for reading"), - quote (pretty_name (f))); + quote (pretty_name (f))); ok = false; } else @@ -1580,56 +1586,56 @@ tail_file (struct File_spec *f, uintmax_t n_units) uintmax_t read_pos; if (print_headers) - write_header (pretty_name (f)); + write_header (pretty_name (f)); ok = tail (pretty_name (f), fd, n_units, &read_pos); if (forever) - { - struct stat stats; + { + struct stat stats; #if TEST_RACE_BETWEEN_FINAL_READ_AND_INITIAL_FSTAT - /* Before the tail function provided `read_pos', there was - a race condition described in the URL below. This sleep - call made the window big enough to exercise the problem. */ - sleep (1); + /* Before the tail function provided `read_pos', there was + a race condition described in the URL below. This sleep + call made the window big enough to exercise the problem. */ + sleep (1); #endif - f->errnum = ok - 1; - if (fstat (fd, &stats) < 0) - { - ok = false; - f->errnum = errno; - error (0, errno, _("error reading %s"), quote (pretty_name (f))); - } - else if (!IS_TAILABLE_FILE_TYPE (stats.st_mode)) - { - error (0, 0, _("%s: cannot follow end of this type of file;\ + f->errnum = ok - 1; + if (fstat (fd, &stats) < 0) + { + ok = false; + f->errnum = errno; + error (0, errno, _("error reading %s"), quote (pretty_name (f))); + } + else if (!IS_TAILABLE_FILE_TYPE (stats.st_mode)) + { + error (0, 0, _("%s: cannot follow end of this type of file;\ giving up on this name"), - pretty_name (f)); - ok = false; - f->errnum = -1; - f->ignore = true; - } + pretty_name (f)); + ok = false; + f->errnum = -1; + f->ignore = true; + } - if (!ok) - { - close_fd (fd, pretty_name (f)); - f->fd = -1; - } - else - { - /* Note: we must use read_pos here, not stats.st_size, - to avoid a race condition described by Ken Raeburn: - http://mail.gnu.org/archive/html/bug-textutils/2003-05/msg00007.html */ - record_open_fd (f, fd, read_pos, &stats, (is_stdin ? -1 : 1)); - } - } + if (!ok) + { + close_fd (fd, pretty_name (f)); + f->fd = -1; + } + else + { + /* Note: we must use read_pos here, not stats.st_size, + to avoid a race condition described by Ken Raeburn: + http://mail.gnu.org/archive/html/bug-textutils/2003-05/msg00007.html */ + record_open_fd (f, fd, read_pos, &stats, (is_stdin ? -1 : 1)); + } + } else - { - if (!is_stdin && close (fd)) - { - error (0, errno, _("error reading %s"), quote (pretty_name (f))); - ok = false; - } - } + { + if (!is_stdin && close (fd)) + { + error (0, errno, _("error reading %s"), quote (pretty_name (f))); + ok = false; + } + } } return ok; @@ -1659,8 +1665,8 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) /* With the obsolete form, there is one option string and at most one file argument. Watch out for "-" and "--", though. */ if (! (argc == 2 - || (argc == 3 && ! (argv[2][0] == '-' && argv[2][1])) - || (3 <= argc && argc <= 4 && STREQ (argv[2], "--")))) + || (argc == 3 && ! (argv[2][0] == '-' && argv[2][1])) + || (3 <= argc && argc <= 4 && STREQ (argv[2], "--")))) return false; obsolete_usage = (posix2_version () < 200112); @@ -1674,18 +1680,18 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) case '+': /* Leading "+" is a file name in the non-obsolete form. */ if (!obsolete_usage) - return false; + return false; t_from_start = true; break; case '-': /* In the non-obsolete form, "-" is standard input and "-c" - requires an option-argument. The obsolete multidigit options - are supported as a GNU extension even when conforming to - POSIX 1003.1-2001, so don't complain about them. */ + requires an option-argument. The obsolete multidigit options + are supported as a GNU extension even when conforming to + POSIX 1003.1-2001, so don't complain about them. */ if (!obsolete_usage && !p[p[0] == 'c']) - return false; + return false; t_from_start = false; break; @@ -1715,8 +1721,8 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) if (n_string == n_string_end) *n_units = default_count; else if ((xstrtoumax (n_string, NULL, 10, n_units, "b") - & ~LONGINT_INVALID_SUFFIX_CHAR) - != LONGINT_OK) + & ~LONGINT_INVALID_SUFFIX_CHAR) + != LONGINT_OK) error (EXIT_FAILURE, 0, _("number in %s is too large"), quote (argv[1])); /* Set globals. */ @@ -1729,118 +1735,122 @@ parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units) static void parse_options (int argc, char **argv, - uintmax_t *n_units, enum header_mode *header_mode, - double *sleep_interval) + uintmax_t *n_units, enum header_mode *header_mode, + double *sleep_interval) { int c; while ((c = getopt_long (argc, argv, "c:n:fFqs:v0123456789", - long_options, NULL)) - != -1) + long_options, NULL)) + != -1) { switch (c) - { - case 'F': - forever = true; - follow_mode = Follow_name; - reopen_inaccessible_files = true; - break; + { + case 'F': + forever = true; + follow_mode = Follow_name; + reopen_inaccessible_files = true; + break; - case 'c': - case 'n': - count_lines = (c == 'n'); - if (*optarg == '+') - from_start = true; - else if (*optarg == '-') - ++optarg; + case 'c': + case 'n': + count_lines = (c == 'n'); + if (*optarg == '+') + from_start = true; + else if (*optarg == '-') + ++optarg; - { - strtol_error s_err; - s_err = xstrtoumax (optarg, NULL, 10, n_units, "bkKmMGTPEZY0"); - if (s_err != LONGINT_OK) - { - error (EXIT_FAILURE, 0, "%s: %s", optarg, - (c == 'n' - ? _("invalid number of lines") - : _("invalid number of bytes"))); - } - } - break; + { + strtol_error s_err; + s_err = xstrtoumax (optarg, NULL, 10, n_units, "bkKmMGTPEZY0"); + if (s_err != LONGINT_OK) + { + error (EXIT_FAILURE, 0, "%s: %s", optarg, + (c == 'n' + ? _("invalid number of lines") + : _("invalid number of bytes"))); + } + } + break; - case 'f': - case LONG_FOLLOW_OPTION: - forever = true; - if (optarg == NULL) - follow_mode = DEFAULT_FOLLOW_MODE; - else - follow_mode = XARGMATCH ("--follow", optarg, - follow_mode_string, follow_mode_map); - break; + case 'f': + case LONG_FOLLOW_OPTION: + forever = true; + if (optarg == NULL) + follow_mode = DEFAULT_FOLLOW_MODE; + else + follow_mode = XARGMATCH ("--follow", optarg, + follow_mode_string, follow_mode_map); + break; - case RETRY_OPTION: - reopen_inaccessible_files = true; - break; + case RETRY_OPTION: + reopen_inaccessible_files = true; + break; - case MAX_UNCHANGED_STATS_OPTION: - /* --max-unchanged-stats=N */ - if (xstrtoumax (optarg, NULL, 10, - &max_n_unchanged_stats_between_opens, - "") - != LONGINT_OK) - { - error (EXIT_FAILURE, 0, - _("%s: invalid maximum number of unchanged stats between opens"), - optarg); - } - break; + case MAX_UNCHANGED_STATS_OPTION: + /* --max-unchanged-stats=N */ + if (xstrtoumax (optarg, NULL, 10, + &max_n_unchanged_stats_between_opens, + "") + != LONGINT_OK) + { + error (EXIT_FAILURE, 0, + _("%s: invalid maximum number of unchanged stats between opens"), + optarg); + } + break; - case PID_OPTION: - { - strtol_error s_err; - unsigned long int tmp_ulong; - s_err = xstrtoul (optarg, NULL, 10, &tmp_ulong, ""); - if (s_err != LONGINT_OK || tmp_ulong > PID_T_MAX) - { - error (EXIT_FAILURE, 0, _("%s: invalid PID"), optarg); - } - pid = tmp_ulong; - } - break; + case DISABLE_INOTIFY_OPTION: + disable_inotify = true; + break; - case PRESUME_INPUT_PIPE_OPTION: - presume_input_pipe = true; - break; + case PID_OPTION: + { + strtol_error s_err; + unsigned long int tmp_ulong; + s_err = xstrtoul (optarg, NULL, 10, &tmp_ulong, ""); + if (s_err != LONGINT_OK || tmp_ulong > PID_T_MAX) + { + error (EXIT_FAILURE, 0, _("%s: invalid PID"), optarg); + } + pid = tmp_ulong; + } + break; - case 'q': - *header_mode = never; - break; + case PRESUME_INPUT_PIPE_OPTION: + presume_input_pipe = true; + break; - case 's': - { - double s; - if (! (xstrtod (optarg, NULL, &s, c_strtod) && 0 <= s)) - error (EXIT_FAILURE, 0, - _("%s: invalid number of seconds"), optarg); - *sleep_interval = s; - } - break; + case 'q': + *header_mode = never; + break; - case 'v': - *header_mode = always; - break; + case 's': + { + double s; + if (! (xstrtod (optarg, NULL, &s, c_strtod) && 0 <= s)) + error (EXIT_FAILURE, 0, + _("%s: invalid number of seconds"), optarg); + *sleep_interval = s; + } + break; - case_GETOPT_HELP_CHAR; + case 'v': + *header_mode = always; + break; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + case_GETOPT_HELP_CHAR; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - error (EXIT_FAILURE, 0, - _("option used in invalid context -- %c"), c); + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - usage (EXIT_FAILURE); - } + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + error (EXIT_FAILURE, 0, + _("option used in invalid context -- %c"), c); + + default: + usage (EXIT_FAILURE); + } } if (reopen_inaccessible_files && follow_mode != Follow_name) @@ -1848,7 +1858,7 @@ parse_options (int argc, char **argv, if (pid && !forever) error (0, 0, - _("warning: PID ignored; --pid=PID is useful only when following")); + _("warning: PID ignored; --pid=PID is useful only when following")); else if (pid && kill (pid, 0) != 0 && errno == ENOSYS) { error (0, 0, _("warning: --pid=PID is not supported on this system")); @@ -1899,7 +1909,7 @@ main (int argc, char **argv) if (from_start) { if (n_units) - --n_units; + --n_units; } if (optind < argc) @@ -1912,28 +1922,6 @@ main (int argc, char **argv) static char *dummy_stdin = (char *) "-"; n_files = 1; file = &dummy_stdin; - - /* POSIX says that -f is ignored if no file operand is specified - and standard input is a pipe. However, the GNU coding - standards say that program behavior should not depend on - device type, because device independence is an important - principle of the system's design. - - Follow the POSIX requirement only if POSIXLY_CORRECT is set. */ - - if (forever && getenv ("POSIXLY_CORRECT")) - { - struct stat st; - int is_a_fifo_or_pipe = - (fstat (STDIN_FILENO, &st) != 0 ? -1 - : S_ISFIFO (st.st_mode) ? 1 - : HAVE_FIFO_PIPES == 1 ? 0 - : isapipe (STDIN_FILENO)); - if (is_a_fifo_or_pipe < 0) - error (EXIT_FAILURE, errno, _("standard input")); - if (is_a_fifo_or_pipe) - forever = false; - } } { @@ -1941,7 +1929,7 @@ main (int argc, char **argv) for (i = 0; i < n_files; i++) if (STREQ (file[i], "-")) - found_hyphen = true; + found_hyphen = true; /* When following by name, there must be a name. */ if (found_hyphen && follow_mode == Follow_name) @@ -1952,7 +1940,7 @@ main (int argc, char **argv) and that from any non-stdin files) might still be useful. */ if (forever && found_hyphen && isatty (STDIN_FILENO)) error (0, 0, _("warning: following standard input" - " indefinitely is ineffective")); + " indefinitely is ineffective")); } F = xnmalloc (n_files, sizeof *F); @@ -1969,22 +1957,64 @@ main (int argc, char **argv) for (i = 0; i < n_files; i++) ok &= tail_file (&F[i], n_units); - if (forever) + /* When there is no FILE operand and stdin is a pipe or FIFO + POSIX requires that tail ignore the -f option. + Since we allow multiple FILE operands, we extend that to say: + ignore any "-" operand that corresponds to a pipe or FIFO. */ + { + size_t n_viable = 0; + for (i = 0; i < n_files; i++) + { + bool is_a_fifo_or_pipe = + (STREQ (F[i].name, "-") + && !F[i].ignore + && 0 <= F[i].fd + && (S_ISFIFO (F[i].mode) + || (HAVE_FIFO_PIPES != 1 && isapipe (F[i].fd)))); + if (is_a_fifo_or_pipe) + F[i].ignore = true; + else + ++n_viable; + } + + if (forever && n_viable) { #if HAVE_INOTIFY - int wd = inotify_init (); - if (wd < 0) - error (0, errno, _("inotify cannot be used, reverting to polling")); - else - { - tail_forever_inotify (wd, F, n_files, sleep_interval); + /* If the user specifies stdin via a command line argument of "-", + or implicitly by providing no arguments, we won't use inotify. + Technically, on systems with a working /dev/stdin, we *could*, + but would it be worth it? Verifying that it's a real device + and hooked up to stdin is not trivial, while reverting to + non-inotify-based tail_forever is easy and portable. */ + bool stdin_cmdline_arg = false; - /* The only way the above returns is upon failure. */ - exit (EXIT_FAILURE); + for (i = 0; i < n_files; i++) + if (!F[i].ignore && STREQ (F[i].name, "-")) + stdin_cmdline_arg = true; + + if (!disable_inotify && !stdin_cmdline_arg) + { + int wd = inotify_init (); + if (wd < 0) + error (0, errno, _("inotify cannot be used, reverting to polling")); + else + { + /* Flush any output from tail_file, now, since + tail_forever_inotify flushes only after writing, + not before reading. */ + if (fflush (stdout) != 0) + error (EXIT_FAILURE, errno, _("write error")); + + tail_forever_inotify (wd, F, n_files, sleep_interval); + + /* The only way the above returns is upon failure. */ + exit (EXIT_FAILURE); + } } #endif tail_forever (F, n_files, sleep_interval); } + } if (have_read_stdin && close (STDIN_FILENO) < 0) error (EXIT_FAILURE, errno, "-"); diff --git a/src/bin/coreutils/src/tee.c b/src/bin/coreutils/src/tee.c index a1b1a27880..03a33b0602 100644 --- a/src/bin/coreutils/src/tee.c +++ b/src/bin/coreutils/src/tee.c @@ -56,7 +56,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name); @@ -97,22 +97,22 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "ai", long_options, NULL)) != -1) { switch (optc) - { - case 'a': - append = true; - break; + { + case 'a': + append = true; + break; - case 'i': - ignore_interrupts = true; - break; + case 'i': + ignore_interrupts = 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); - } + default: + usage (EXIT_FAILURE); + } } if (ignore_interrupts) @@ -166,15 +166,15 @@ tee_files (int nfiles, const char **files) for (i = 1; i <= nfiles; i++) { descriptors[i] = (STREQ (files[i], "-") - ? stdout - : fopen (files[i], mode_string)); + ? stdout + : fopen (files[i], mode_string)); if (descriptors[i] == NULL) - { - error (0, errno, "%s", files[i]); - ok = false; - } + { + error (0, errno, "%s", files[i]); + ok = false; + } else - setvbuf (descriptors[i], NULL, _IONBF, 0); + setvbuf (descriptors[i], NULL, _IONBF, 0); } while (1) @@ -185,18 +185,18 @@ tee_files (int nfiles, const char **files) continue; #endif if (bytes_read <= 0) - break; + break; /* Write to all NFILES + 1 descriptors. - Standard output is the first one. */ + Standard output is the first one. */ for (i = 0; i <= nfiles; i++) - if (descriptors[i] - && fwrite (buffer, bytes_read, 1, descriptors[i]) != 1) - { - error (0, errno, "%s", files[i]); - descriptors[i] = NULL; - ok = false; - } + if (descriptors[i] + && fwrite (buffer, bytes_read, 1, descriptors[i]) != 1) + { + error (0, errno, "%s", files[i]); + descriptors[i] = NULL; + ok = false; + } } if (bytes_read == -1) @@ -208,10 +208,10 @@ tee_files (int nfiles, const char **files) /* Close the files, but not standard output. */ for (i = 1; i <= nfiles; i++) if (!STREQ (files[i], "-") - && descriptors[i] && fclose (descriptors[i]) != 0) + && descriptors[i] && fclose (descriptors[i]) != 0) { - error (0, errno, "%s", files[i]); - ok = false; + error (0, errno, "%s", files[i]); + ok = false; } free (descriptors); diff --git a/src/bin/coreutils/src/test.c b/src/bin/coreutils/src/test.c index 1825e901af..f7c689cf9c 100644 --- a/src/bin/coreutils/src/test.c +++ b/src/bin/coreutils/src/test.c @@ -143,11 +143,11 @@ find_int (char const *string) if (ISDIGIT (*p++)) { while (ISDIGIT (*p)) - p++; + p++; while (isblank (to_uchar (*p))) - p++; + p++; if (!*p) - return number_start; + return number_start; } test_syntax_error (_("invalid integer %s"), quote (string)); @@ -174,9 +174,9 @@ static bool binop (char const *s) { return ((STREQ (s, "=")) || (STREQ (s, "!=")) || (STREQ (s, "-nt")) || - (STREQ (s, "-ot")) || (STREQ (s, "-ef")) || (STREQ (s, "-eq")) || - (STREQ (s, "-ne")) || (STREQ (s, "-lt")) || (STREQ (s, "-le")) || - (STREQ (s, "-gt")) || (STREQ (s, "-ge"))); + (STREQ (s, "-ot")) || (STREQ (s, "-ef")) || (STREQ (s, "-eq")) || + (STREQ (s, "-ne")) || (STREQ (s, "-lt")) || (STREQ (s, "-le")) || + (STREQ (s, "-gt")) || (STREQ (s, "-ge"))); } /* @@ -221,20 +221,20 @@ term (void) advance (true); for (nargs = 1; - pos + nargs < argc && ! STREQ (argv[pos + nargs], ")"); - nargs++) - if (nargs == 4) - { - nargs = argc - pos; - break; - } + pos + nargs < argc && ! STREQ (argv[pos + nargs], ")"); + nargs++) + if (nargs == 4) + { + nargs = argc - pos; + break; + } value = posixtest (nargs); if (argv[pos] == 0) - test_syntax_error (_("')' expected"), NULL); + test_syntax_error (_("')' expected"), NULL); else if (argv[pos][0] != ')' || argv[pos][1]) - test_syntax_error (_("')' expected, found %s"), argv[pos]); + test_syntax_error (_("')' expected, found %s"), argv[pos]); advance (false); } @@ -248,9 +248,9 @@ term (void) else if (argv[pos][0] == '-' && argv[pos][1] && argv[pos][2] == '\0') { if (test_unop (argv[pos])) - value = unary_operator (); + value = unary_operator (); else - test_syntax_error (_("%s: unary operator expected"), argv[pos]); + test_syntax_error (_("%s: unary operator expected"), argv[pos]); } else { @@ -285,76 +285,76 @@ binary_operator (bool l_is_l) { /* check for eq, nt, and stuff */ if ((((argv[op][1] == 'l' || argv[op][1] == 'g') - && (argv[op][2] == 'e' || argv[op][2] == 't')) - || (argv[op][1] == 'e' && argv[op][2] == 'q') - || (argv[op][1] == 'n' && argv[op][2] == 'e')) - && !argv[op][3]) - { - char lbuf[INT_BUFSIZE_BOUND (uintmax_t)]; - char rbuf[INT_BUFSIZE_BOUND (uintmax_t)]; - char const *l = (l_is_l - ? umaxtostr (strlen (argv[op - 1]), lbuf) - : find_int (argv[op - 1])); - char const *r = (r_is_l - ? umaxtostr (strlen (argv[op + 2]), rbuf) - : find_int (argv[op + 1])); - int cmp = strintcmp (l, r); - bool xe_operator = (argv[op][2] == 'e'); - pos += 3; - return (argv[op][1] == 'l' ? cmp < xe_operator - : argv[op][1] == 'g' ? cmp > - xe_operator - : (cmp != 0) == xe_operator); - } + && (argv[op][2] == 'e' || argv[op][2] == 't')) + || (argv[op][1] == 'e' && argv[op][2] == 'q') + || (argv[op][1] == 'n' && argv[op][2] == 'e')) + && !argv[op][3]) + { + char lbuf[INT_BUFSIZE_BOUND (uintmax_t)]; + char rbuf[INT_BUFSIZE_BOUND (uintmax_t)]; + char const *l = (l_is_l + ? umaxtostr (strlen (argv[op - 1]), lbuf) + : find_int (argv[op - 1])); + char const *r = (r_is_l + ? umaxtostr (strlen (argv[op + 2]), rbuf) + : find_int (argv[op + 1])); + int cmp = strintcmp (l, r); + bool xe_operator = (argv[op][2] == 'e'); + pos += 3; + return (argv[op][1] == 'l' ? cmp < xe_operator + : argv[op][1] == 'g' ? cmp > - xe_operator + : (cmp != 0) == xe_operator); + } switch (argv[op][1]) - { - default: - break; + { + default: + break; - case 'n': - if (argv[op][2] == 't' && !argv[op][3]) - { - /* nt - newer than */ - struct timespec lt, rt; - bool le, re; - pos += 3; - if (l_is_l | r_is_l) - test_syntax_error (_("-nt does not accept -l"), NULL); - le = get_mtime (argv[op - 1], <); - re = get_mtime (argv[op + 1], &rt); - return le && (!re || timespec_cmp (lt, rt) > 0); - } - break; + case 'n': + if (argv[op][2] == 't' && !argv[op][3]) + { + /* nt - newer than */ + struct timespec lt, rt; + bool le, re; + pos += 3; + if (l_is_l | r_is_l) + test_syntax_error (_("-nt does not accept -l"), NULL); + le = get_mtime (argv[op - 1], <); + re = get_mtime (argv[op + 1], &rt); + return le && (!re || timespec_cmp (lt, rt) > 0); + } + break; - case 'e': - if (argv[op][2] == 'f' && !argv[op][3]) - { - /* ef - hard link? */ - pos += 3; - if (l_is_l | r_is_l) - test_syntax_error (_("-ef does not accept -l"), NULL); - return (stat (argv[op - 1], &stat_buf) == 0 - && stat (argv[op + 1], &stat_spare) == 0 - && stat_buf.st_dev == stat_spare.st_dev - && stat_buf.st_ino == stat_spare.st_ino); - } - break; + case 'e': + if (argv[op][2] == 'f' && !argv[op][3]) + { + /* ef - hard link? */ + pos += 3; + if (l_is_l | r_is_l) + test_syntax_error (_("-ef does not accept -l"), NULL); + return (stat (argv[op - 1], &stat_buf) == 0 + && stat (argv[op + 1], &stat_spare) == 0 + && stat_buf.st_dev == stat_spare.st_dev + && stat_buf.st_ino == stat_spare.st_ino); + } + break; - case 'o': - if ('t' == argv[op][2] && '\000' == argv[op][3]) - { - /* ot - older than */ - struct timespec lt, rt; - bool le, re; - pos += 3; - if (l_is_l | r_is_l) - test_syntax_error (_("-ot does not accept -l"), NULL); - le = get_mtime (argv[op - 1], <); - re = get_mtime (argv[op + 1], &rt); - return re && (!le || timespec_cmp (lt, rt) < 0); - } - break; - } + case 'o': + if ('t' == argv[op][2] && '\000' == argv[op][3]) + { + /* ot - older than */ + struct timespec lt, rt; + bool le, re; + pos += 3; + if (l_is_l | r_is_l) + test_syntax_error (_("-ot does not accept -l"), NULL); + le = get_mtime (argv[op - 1], <); + re = get_mtime (argv[op + 1], &rt); + return re && (!le || timespec_cmp (lt, rt) < 0); + } + break; + } /* FIXME: is this dead code? */ test_syntax_error (_("unknown binary operator"), argv[op]); @@ -389,9 +389,9 @@ unary_operator (void) return false; /* All of the following unary operators use unary_advance (), which - checks to make sure that there is an argument, and then advances - pos right past it. This means that pos - 1 is the location of the - argument. */ + checks to make sure that there is an argument, and then advances + pos right past it. This means that pos - 1 is the location of the + argument. */ case 'a': /* file exists in the file system? */ case 'e': @@ -413,49 +413,49 @@ unary_operator (void) case 'O': /* File is owned by you? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && (geteuid () == stat_buf.st_uid)); + && (geteuid () == stat_buf.st_uid)); case 'G': /* File is owned by your group? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && (getegid () == stat_buf.st_gid)); + && (getegid () == stat_buf.st_gid)); case 'f': /* File is a file? */ unary_advance (); /* Under POSIX, -f is true if the given file exists - and is a regular file. */ + and is a regular file. */ return (stat (argv[pos - 1], &stat_buf) == 0 - && S_ISREG (stat_buf.st_mode)); + && S_ISREG (stat_buf.st_mode)); case 'd': /* File is a directory? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && S_ISDIR (stat_buf.st_mode)); + && S_ISDIR (stat_buf.st_mode)); case 's': /* File has something in it? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && 0 < stat_buf.st_size); + && 0 < stat_buf.st_size); case 'S': /* File is a socket? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && S_ISSOCK (stat_buf.st_mode)); + && S_ISSOCK (stat_buf.st_mode)); case 'c': /* File is character special? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && S_ISCHR (stat_buf.st_mode)); + && S_ISCHR (stat_buf.st_mode)); case 'b': /* File is block special? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && S_ISBLK (stat_buf.st_mode)); + && S_ISBLK (stat_buf.st_mode)); case 'p': /* File is a named pipe? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && S_ISFIFO (stat_buf.st_mode)); + && S_ISFIFO (stat_buf.st_mode)); case 'L': /* Same as -h */ /*FALLTHROUGH*/ @@ -463,32 +463,32 @@ unary_operator (void) case 'h': /* File is a symbolic link? */ unary_advance (); return (lstat (argv[pos - 1], &stat_buf) == 0 - && S_ISLNK (stat_buf.st_mode)); + && S_ISLNK (stat_buf.st_mode)); case 'u': /* File is setuid? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && (stat_buf.st_mode & S_ISUID)); + && (stat_buf.st_mode & S_ISUID)); case 'g': /* File is setgid? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && (stat_buf.st_mode & S_ISGID)); + && (stat_buf.st_mode & S_ISGID)); case 'k': /* File has sticky bit set? */ unary_advance (); return (stat (argv[pos - 1], &stat_buf) == 0 - && (stat_buf.st_mode & S_ISVTX)); + && (stat_buf.st_mode & S_ISVTX)); case 't': /* File (fd) is a terminal? */ { - long int fd; - char const *arg; - unary_advance (); - arg = find_int (argv[pos - 1]); - errno = 0; - fd = strtol (arg, NULL, 10); - return (errno != ERANGE && 0 <= fd && fd <= INT_MAX && isatty (fd)); + long int fd; + char const *arg; + unary_advance (); + arg = find_int (argv[pos - 1]); + errno = 0; + fd = strtol (arg, NULL, 10); + return (errno != ERANGE && 0 <= fd && fd <= INT_MAX && isatty (fd)); } case 'n': /* True if arg has some length. */ @@ -515,7 +515,7 @@ and (void) { value &= term (); if (! (pos < argc && STREQ (argv[pos], "-a"))) - return value; + return value; advance (false); } } @@ -534,7 +534,7 @@ or (void) { value |= and (); if (! (pos < argc && STREQ (argv[pos], "-o"))) - return value; + return value; advance (false); } } @@ -589,13 +589,13 @@ two_arguments (void) value = ! one_argument (); } else if (argv[pos][0] == '-' - && argv[pos][1] != '\0' - && argv[pos][2] == '\0') + && argv[pos][1] != '\0' + && argv[pos][2] == '\0') { if (test_unop (argv[pos])) - value = unary_operator (); + value = unary_operator (); else - test_syntax_error (_("%s: unary operator expected"), argv[pos]); + test_syntax_error (_("%s: unary operator expected"), argv[pos]); } else beyond (); @@ -636,37 +636,37 @@ posixtest (int nargs) switch (nargs) { case 1: - value = one_argument (); - break; + value = one_argument (); + break; case 2: - value = two_arguments (); - break; + value = two_arguments (); + break; case 3: - value = three_arguments (); - break; + value = three_arguments (); + break; case 4: - if (STREQ (argv[pos], "!")) - { - advance (true); - value = !three_arguments (); - break; - } - if (STREQ (argv[pos], "(") && STREQ (argv[pos + 3], ")")) - { - advance (false); - value = two_arguments (); - advance (false); - break; - } - /* FALLTHROUGH */ + if (STREQ (argv[pos], "!")) + { + advance (true); + value = !three_arguments (); + break; + } + if (STREQ (argv[pos], "(") && STREQ (argv[pos + 3], ")")) + { + advance (false); + value = two_arguments (); + advance (false); + break; + } + /* FALLTHROUGH */ case 5: default: - if (nargs <= 0) - abort (); - value = expr (); + if (nargs <= 0) + abort (); + value = expr (); } return (value); @@ -679,7 +679,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { fputs (_("\ @@ -818,25 +818,25 @@ main (int margc, char **margv) if (LBRACKET) { /* Recognize --help or --version, but only when invoked in the - "[" form, when the last argument is not "]". Use direct - parsing, rather than parse_long_options, to avoid accepting - abbreviations. POSIX allows "[ --help" and "[ --version" to - have the usual GNU behavior, but it requires "test --help" - and "test --version" to exit silently with status 0. */ + "[" form, when the last argument is not "]". Use direct + parsing, rather than parse_long_options, to avoid accepting + abbreviations. POSIX allows "[ --help" and "[ --version" to + have the usual GNU behavior, but it requires "test --help" + and "test --version" to exit silently with status 0. */ if (margc == 2) - { - if (STREQ (margv[1], "--help")) - usage (EXIT_SUCCESS); + { + if (STREQ (margv[1], "--help")) + usage (EXIT_SUCCESS); - if (STREQ (margv[1], "--version")) - { - version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, - (char *) NULL); - test_exit (EXIT_SUCCESS); - } - } + if (STREQ (margv[1], "--version")) + { + version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, + (char *) NULL); + test_exit (EXIT_SUCCESS); + } + } if (margc < 2 || !STREQ (margv[margc - 1], "]")) - test_syntax_error (_("missing `]'"), NULL); + test_syntax_error (_("missing `]'"), NULL); --margc; } diff --git a/src/bin/coreutils/src/timeout.c b/src/bin/coreutils/src/timeout.c index 405ae986c9..6d9d109128 100644 --- a/src/bin/coreutils/src/timeout.c +++ b/src/bin/coreutils/src/timeout.c @@ -268,7 +268,6 @@ main (int argc, char **argv) } optind++; - argc -= optind; argv += optind; /* Ensure we're in our own group so all subprocesses can be killed. @@ -317,12 +316,25 @@ main (int argc, char **argv) child exits, not on this process receiving a signal. Also we're not passing WUNTRACED | WCONTINUED to a waitpid() call and so will not get indication that the child has stopped or continued. */ - wait (&status); - - if (WIFEXITED (status)) - status = WEXITSTATUS (status); - else if (WIFSIGNALED (status)) - status = WTERMSIG (status) + 128; /* what sh does at least. */ + if (wait (&status) == -1) + { + /* shouldn't happen. */ + error (0, errno, _("error waiting for command")); + status = EXIT_CANCELED; + } + else + { + if (WIFEXITED (status)) + status = WEXITSTATUS (status); + else if (WIFSIGNALED (status)) + status = WTERMSIG (status) + 128; /* what sh does at least. */ + else + { + /* shouldn't happen. */ + error (0, 0, _("unknown status from command (0x%X)"), status); + status = EXIT_FAILURE; + } + } if (timed_out) return EXIT_TIMEDOUT; @@ -330,9 +342,3 @@ main (int argc, char **argv) return status; } } - -/* - * Local variables: - * indent-tabs-mode: nil - * End: - */ diff --git a/src/bin/coreutils/src/touch.c b/src/bin/coreutils/src/touch.c index 3d6d9fac26..ed9847175c 100644 --- a/src/bin/coreutils/src/touch.c +++ b/src/bin/coreutils/src/touch.c @@ -106,7 +106,7 @@ static int const time_masks[] = static void get_reldate (struct timespec *result, - char const *flex_date, struct timespec const *now) + char const *flex_date, struct timespec const *now) { if (! get_date (result, flex_date, now)) error (EXIT_FAILURE, 0, _("invalid date format %s"), quote (flex_date)); @@ -131,54 +131,54 @@ touch (const char *file) { /* Try to open FILE, creating it if necessary. */ fd = fd_reopen (STDIN_FILENO, file, - O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + O_WRONLY | O_CREAT | O_NONBLOCK | O_NOCTTY, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); /* Don't save a copy of errno if it's EISDIR, since that would lead - touch to give a bogus diagnostic for e.g., `touch /' (assuming - we don't own / or have write access to it). On Solaris 5.6, - and probably other systems, it is EINVAL. On SunOS4, it's EPERM. */ + touch to give a bogus diagnostic for e.g., `touch /' (assuming + we don't own / or have write access to it). On Solaris 5.6, + and probably other systems, it is EINVAL. On SunOS4, it's EPERM. */ if (fd == -1 && errno != EISDIR && errno != EINVAL && errno != EPERM) - open_errno = errno; + open_errno = errno; } if (change_times != (CH_ATIME | CH_MTIME)) { /* We're setting only one of the time values. stat the target to get - the other one. If we have the file descriptor already, use fstat. - Otherwise, either we're in no-create mode (and hence didn't call open) - or FILE is inaccessible or a directory, so we have to use stat. */ + the other one. If we have the file descriptor already, use fstat. + Otherwise, either we're in no-create mode (and hence didn't call open) + or FILE is inaccessible or a directory, so we have to use stat. */ if (fd != -1 ? fstat (fd, &sbuf) : stat (file, &sbuf)) - { - if (open_errno) - error (0, open_errno, _("creating %s"), quote (file)); - else - { - if (no_create && (errno == ENOENT || errno == EBADF)) - return true; - error (0, errno, _("failed to get attributes of %s"), - quote (file)); - } - if (fd == STDIN_FILENO) - close (fd); - return false; - } + { + if (open_errno) + error (0, open_errno, _("creating %s"), quote (file)); + else + { + if (no_create && (errno == ENOENT || errno == EBADF)) + return true; + error (0, errno, _("failed to get attributes of %s"), + quote (file)); + } + if (fd == STDIN_FILENO) + close (fd); + return false; + } } if (amtime_now) { /* Pass NULL to futimens so it will not fail if we have - write access to the file, but don't own it. */ + write access to the file, but don't own it. */ t = NULL; } else { timespec[0] = (change_times & CH_ATIME - ? newtime[0] - : get_stat_atime (&sbuf)); + ? newtime[0] + : get_stat_atime (&sbuf)); timespec[1] = (change_times & CH_MTIME - ? newtime[1] - : get_stat_mtime (&sbuf)); + ? newtime[1] + : get_stat_mtime (&sbuf)); t = timespec; } @@ -187,35 +187,35 @@ touch (const char *file) if (fd == STDIN_FILENO) { if (close (STDIN_FILENO) != 0) - { - error (0, errno, _("closing %s"), quote (file)); - return false; - } + { + error (0, errno, _("closing %s"), quote (file)); + return false; + } } else if (fd == STDOUT_FILENO) { /* Do not diagnose "touch -c - >&-". */ if (!ok && errno == EBADF && no_create - && change_times == (CH_ATIME | CH_MTIME)) - return true; + && change_times == (CH_ATIME | CH_MTIME)) + return true; } if (!ok) { if (open_errno) - { - /* The wording of this diagnostic should cover at least two cases: - - the file does not exist, but the parent directory is unwritable - - the file exists, but it isn't writable - I think it's not worth trying to distinguish them. */ - error (0, open_errno, _("cannot touch %s"), quote (file)); - } + { + /* The wording of this diagnostic should cover at least two cases: + - the file does not exist, but the parent directory is unwritable + - the file exists, but it isn't writable + I think it's not worth trying to distinguish them. */ + error (0, open_errno, _("cannot touch %s"), quote (file)); + } else - { - if (no_create && errno == ENOENT) - return true; - error (0, errno, _("setting times of %s"), quote (file)); - } + { + if (no_create && errno == ENOENT) + return true; + error (0, errno, _("setting times of %s"), quote (file)); + } return false; } @@ -227,7 +227,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... FILE...\n"), program_name); @@ -291,57 +291,57 @@ main (int argc, char **argv) while ((c = getopt_long (argc, argv, "acd:fmr:t:", longopts, &long_idx)) != -1) { switch (c) - { - case 'a': - change_times |= CH_ATIME; - break; + { + case 'a': + change_times |= CH_ATIME; + break; - case 'c': - no_create = true; - break; + case 'c': + no_create = true; + break; - case 'd': - flex_date = optarg; - break; + case 'd': + flex_date = optarg; + break; - case 'f': - break; + case 'f': + break; - case 'm': - change_times |= CH_MTIME; - break; + case 'm': + change_times |= CH_MTIME; + break; - case 'r': - if (long_idx == 3) - error (0, 0, - _("warning: the --%s option is obsolete; use --reference"), - longopts[long_idx].name); - use_ref = true; - ref_file = optarg; - break; + case 'r': + if (long_idx == 3) + error (0, 0, + _("warning: the --%s option is obsolete; use --reference"), + longopts[long_idx].name); + use_ref = true; + ref_file = optarg; + break; - case 't': - if (! posixtime (&newtime[0].tv_sec, optarg, - PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS)) - error (EXIT_FAILURE, 0, _("invalid date format %s"), - quote (optarg)); - newtime[0].tv_nsec = 0; - newtime[1] = newtime[0]; - date_set = true; - break; + case 't': + if (! posixtime (&newtime[0].tv_sec, optarg, + PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS)) + error (EXIT_FAILURE, 0, _("invalid date format %s"), + quote (optarg)); + newtime[0].tv_nsec = 0; + newtime[1] = newtime[0]; + date_set = true; + break; - case TIME_OPTION: /* --time */ - change_times |= XARGMATCH ("--time", optarg, - time_args, time_masks); - break; + case TIME_OPTION: /* --time */ + change_times |= XARGMATCH ("--time", optarg, + time_args, time_masks); + 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); - } + default: + usage (EXIT_FAILURE); + } } if (change_times == 0) @@ -357,69 +357,69 @@ main (int argc, char **argv) { struct stat ref_stats; if (stat (ref_file, &ref_stats)) - error (EXIT_FAILURE, errno, - _("failed to get attributes of %s"), quote (ref_file)); + error (EXIT_FAILURE, errno, + _("failed to get attributes of %s"), quote (ref_file)); newtime[0] = get_stat_atime (&ref_stats); newtime[1] = get_stat_mtime (&ref_stats); date_set = true; if (flex_date) - { - if (change_times & CH_ATIME) - get_reldate (&newtime[0], flex_date, &newtime[0]); - if (change_times & CH_MTIME) - get_reldate (&newtime[1], flex_date, &newtime[1]); - } + { + if (change_times & CH_ATIME) + get_reldate (&newtime[0], flex_date, &newtime[0]); + if (change_times & CH_MTIME) + get_reldate (&newtime[1], flex_date, &newtime[1]); + } } else { if (flex_date) - { - struct timespec now; - gettime (&now); - get_reldate (&newtime[0], flex_date, &now); - newtime[1] = newtime[0]; - date_set = true; + { + struct timespec now; + gettime (&now); + get_reldate (&newtime[0], flex_date, &now); + newtime[1] = newtime[0]; + date_set = true; - /* If neither -a nor -m is specified, treat "-d now" as if - it were absent; this lets "touch" succeed more often in - the presence of restrictive permissions. */ - if (change_times == (CH_ATIME | CH_MTIME) - && newtime[0].tv_sec == now.tv_sec - && newtime[0].tv_nsec == now.tv_nsec) - { - /* Check that it really was "-d now", and not a time - stamp that just happens to be the current time. */ - struct timespec notnow, notnow1; - notnow.tv_sec = now.tv_sec ^ 1; - notnow.tv_nsec = now.tv_nsec; - get_reldate (¬now1, flex_date, ¬now); - if (notnow1.tv_sec == notnow.tv_sec - && notnow1.tv_nsec == notnow.tv_nsec) - date_set = false; - } - } + /* If neither -a nor -m is specified, treat "-d now" as if + it were absent; this lets "touch" succeed more often in + the presence of restrictive permissions. */ + if (change_times == (CH_ATIME | CH_MTIME) + && newtime[0].tv_sec == now.tv_sec + && newtime[0].tv_nsec == now.tv_nsec) + { + /* Check that it really was "-d now", and not a time + stamp that just happens to be the current time. */ + struct timespec notnow, notnow1; + notnow.tv_sec = now.tv_sec ^ 1; + notnow.tv_nsec = now.tv_nsec; + get_reldate (¬now1, flex_date, ¬now); + if (notnow1.tv_sec == notnow.tv_sec + && notnow1.tv_nsec == notnow.tv_nsec) + date_set = false; + } + } } /* The obsolete `MMDDhhmm[YY]' form is valid IFF there are two or more non-option arguments. */ if (!date_set && 2 <= argc - optind && posix2_version () < 200112 && posixtime (&newtime[0].tv_sec, argv[optind], - PDS_TRAILING_YEAR | PDS_PRE_2000)) + PDS_TRAILING_YEAR | PDS_PRE_2000)) { newtime[0].tv_nsec = 0; newtime[1] = newtime[0]; date_set = true; if (! getenv ("POSIXLY_CORRECT")) - { - struct tm const *tm = localtime (&newtime[0].tv_sec); - error (0, 0, - _("warning: `touch %s' is obsolete; use " - "`touch -t %04ld%02d%02d%02d%02d.%02d'"), - argv[optind], - tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); - } + { + struct tm const *tm = localtime (&newtime[0].tv_sec); + error (0, 0, + _("warning: `touch %s' is obsolete; use " + "`touch -t %04ld%02d%02d%02d%02d.%02d'"), + argv[optind], + tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + } optind++; } @@ -427,12 +427,12 @@ main (int argc, char **argv) if (!date_set) { if (change_times == (CH_ATIME | CH_MTIME)) - amtime_now = true; + amtime_now = true; else - { - gettime (&newtime[0]); - newtime[1] = newtime[0]; - } + { + gettime (&newtime[0]); + newtime[1] = newtime[0]; + } } if (optind == argc) diff --git a/src/bin/coreutils/src/tr.c b/src/bin/coreutils/src/tr.c index c6622d0571..0b985f801a 100644 --- a/src/bin/coreutils/src/tr.c +++ b/src/bin/coreutils/src/tr.c @@ -107,21 +107,21 @@ struct List_element struct List_element *next; union { - unsigned char normal_char; - struct /* unnamed */ - { - unsigned char first_char; - unsigned char last_char; - } - range; - enum Char_class char_class; - unsigned char equiv_code; - struct /* unnamed */ - { - unsigned char the_repeated_char; - count repeat_count; - } - repeated_char; + unsigned char normal_char; + struct /* unnamed */ + { + unsigned char first_char; + unsigned char last_char; + } + range; + enum Char_class char_class; + unsigned char equiv_code; + struct /* unnamed */ + { + unsigned char the_repeated_char; + count repeat_count; + } + repeated_char; } u; }; @@ -280,13 +280,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... SET1 [SET2]\n\ "), - program_name); + program_name); fputs (_("\ Translate, squeeze, and/or delete characters from standard input,\n\ writing to standard output.\n\ @@ -445,94 +445,94 @@ unquote (char const *s, struct E_string *es) int oct_digit; switch (s[i]) - { - case '\\': - es->escaped[j] = true; - switch (s[i + 1]) - { - case '\\': - c = '\\'; - break; - case 'a': - c = '\a'; - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'v': - c = '\v'; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - c = s[i + 1] - '0'; - oct_digit = s[i + 2] - '0'; - if (0 <= oct_digit && oct_digit <= 7) - { - c = 8 * c + oct_digit; - ++i; - oct_digit = s[i + 2] - '0'; - if (0 <= oct_digit && oct_digit <= 7) - { - if (8 * c + oct_digit < N_CHARS) - { - c = 8 * c + oct_digit; - ++i; - } - else - { - /* A 3-digit octal number larger than \377 won't - fit in 8 bits. So we stop when adding the - next digit would put us over the limit and - give a warning about the ambiguity. POSIX - isn't clear on this, and we interpret this - lack of clarity as meaning the resulting behavior - is undefined, which means we're allowed to issue - a warning. */ - error (0, 0, _("warning: the ambiguous octal escape \ + { + case '\\': + es->escaped[j] = true; + switch (s[i + 1]) + { + case '\\': + c = '\\'; + break; + case 'a': + c = '\a'; + break; + case 'b': + c = '\b'; + break; + case 'f': + c = '\f'; + break; + case 'n': + c = '\n'; + break; + case 'r': + c = '\r'; + break; + case 't': + c = '\t'; + break; + case 'v': + c = '\v'; + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + c = s[i + 1] - '0'; + oct_digit = s[i + 2] - '0'; + if (0 <= oct_digit && oct_digit <= 7) + { + c = 8 * c + oct_digit; + ++i; + oct_digit = s[i + 2] - '0'; + if (0 <= oct_digit && oct_digit <= 7) + { + if (8 * c + oct_digit < N_CHARS) + { + c = 8 * c + oct_digit; + ++i; + } + else + { + /* A 3-digit octal number larger than \377 won't + fit in 8 bits. So we stop when adding the + next digit would put us over the limit and + give a warning about the ambiguity. POSIX + isn't clear on this, and we interpret this + lack of clarity as meaning the resulting behavior + is undefined, which means we're allowed to issue + a warning. */ + error (0, 0, _("warning: the ambiguous octal escape \ \\%c%c%c is being\n\tinterpreted as the 2-byte sequence \\0%c%c, %c"), - s[i], s[i + 1], s[i + 2], - s[i], s[i + 1], s[i + 2]); - } - } - } - break; - case '\0': - error (0, 0, _("warning: an unescaped backslash " - "at end of string is not portable")); - /* POSIX is not clear about this. */ - es->escaped[j] = false; - i--; - c = '\\'; - break; - default: - c = s[i + 1]; - break; - } - ++i; - es->s[j++] = c; - break; - default: - es->s[j++] = s[i]; - break; - } + s[i], s[i + 1], s[i + 2], + s[i], s[i + 1], s[i + 2]); + } + } + } + break; + case '\0': + error (0, 0, _("warning: an unescaped backslash " + "at end of string is not portable")); + /* POSIX is not clear about this. */ + es->escaped[j] = false; + i--; + c = '\\'; + break; + default: + c = s[i + 1]; + break; + } + ++i; + es->s[j++] = c; + break; + default: + es->s[j++] = s[i]; + break; + } } es->len = j; return true; @@ -548,7 +548,7 @@ look_up_char_class (char const *class_str, size_t len) for (i = 0; i < ARRAY_CARDINALITY (char_class_name); i++) if (strncmp (class_str, char_class_name[i], len) == 0 - && strlen (char_class_name[i]) == len) + && strlen (char_class_name[i]) == len) return i; return CC_NO_CLASS; } @@ -596,42 +596,42 @@ make_printable_str (char const *s, size_t len) unsigned char c = s[i]; switch (c) - { - case '\\': - tmp = "\\"; - break; - case '\a': - tmp = "\\a"; - break; - case '\b': - tmp = "\\b"; - break; - case '\f': - tmp = "\\f"; - break; - case '\n': - tmp = "\\n"; - break; - case '\r': - tmp = "\\r"; - break; - case '\t': - tmp = "\\t"; - break; - case '\v': - tmp = "\\v"; - break; - default: - if (isprint (c)) - { - buf[0] = c; - buf[1] = '\0'; - } - else - sprintf (buf, "\\%03o", c); - tmp = buf; - break; - } + { + case '\\': + tmp = "\\"; + break; + case '\a': + tmp = "\\a"; + break; + case '\b': + tmp = "\\b"; + break; + case '\f': + tmp = "\\f"; + break; + case '\n': + tmp = "\\n"; + break; + case '\r': + tmp = "\\r"; + break; + case '\t': + tmp = "\\t"; + break; + case '\v': + tmp = "\\v"; + break; + default: + if (isprint (c)) + { + buf[0] = c; + buf[1] = '\0'; + } + else + sprintf (buf, "\\%03o", c); + tmp = buf; + break; + } p = stpcpy (p, tmp); } return printable_buf; @@ -671,7 +671,7 @@ append_range (struct Spec_list *list, unsigned char first, unsigned char last) error (0, 0, _("range-endpoints of `%s-%s' are in reverse collating sequence order"), - tmp1, tmp2); + tmp1, tmp2); free (tmp1); free (tmp2); return false; @@ -694,7 +694,7 @@ append_range (struct Spec_list *list, unsigned char first, unsigned char last) static bool append_char_class (struct Spec_list *list, - char const *char_class_str, size_t len) + char const *char_class_str, size_t len) { enum Char_class char_class; struct List_element *new; @@ -719,7 +719,7 @@ append_char_class (struct Spec_list *list, static void append_repeated_char (struct Spec_list *list, unsigned char the_char, - count repeat_count) + count repeat_count) { struct List_element *new; @@ -741,7 +741,7 @@ append_repeated_char (struct Spec_list *list, unsigned char the_char, static bool append_equiv_class (struct Spec_list *list, - char const *equiv_class_str, size_t len) + char const *equiv_class_str, size_t len) { struct List_element *new; @@ -765,16 +765,16 @@ append_equiv_class (struct Spec_list *list, static bool find_closing_delim (const struct E_string *es, size_t start_idx, - char pre_bracket_char, size_t *result_idx) + char pre_bracket_char, size_t *result_idx) { size_t i; for (i = start_idx; i < es->len - 1; i++) if (es->s[i] == pre_bracket_char && es->s[i + 1] == ']' - && !es->escaped[i] && !es->escaped[i + 1]) + && !es->escaped[i] && !es->escaped[i + 1]) { - *result_idx = i; - return true; + *result_idx = i; + return true; } return false; } @@ -791,8 +791,8 @@ find_closing_delim (const struct E_string *es, size_t start_idx, static int find_bracketed_repeat (const struct E_string *es, size_t start_idx, - unsigned char *char_to_repeat, count *repeat_count, - size_t *closing_bracket_idx) + unsigned char *char_to_repeat, count *repeat_count, + size_t *closing_bracket_idx) { size_t i; @@ -803,38 +803,38 @@ find_bracketed_repeat (const struct E_string *es, size_t start_idx, for (i = start_idx + 2; i < es->len && !es->escaped[i]; i++) { if (es->s[i] == ']') - { - size_t digit_str_len = i - start_idx - 2; + { + size_t digit_str_len = i - start_idx - 2; - *char_to_repeat = es->s[start_idx]; - if (digit_str_len == 0) - { - /* We've matched [c*] -- no explicit repeat count. */ - *repeat_count = 0; - } - else - { - /* Here, we have found [c*s] where s should be a string - of octal (if it starts with `0') or decimal digits. */ - char const *digit_str = &es->s[start_idx + 2]; - char *d_end; - if ((xstrtoumax (digit_str, &d_end, *digit_str == '0' ? 8 : 10, - repeat_count, NULL) - != LONGINT_OK) - || REPEAT_COUNT_MAXIMUM < *repeat_count - || digit_str + digit_str_len != d_end) - { - char *tmp = make_printable_str (digit_str, digit_str_len); - error (0, 0, - _("invalid repeat count %s in [c*n] construct"), - quote (tmp)); - free (tmp); - return -2; - } - } - *closing_bracket_idx = i; - return 0; - } + *char_to_repeat = es->s[start_idx]; + if (digit_str_len == 0) + { + /* We've matched [c*] -- no explicit repeat count. */ + *repeat_count = 0; + } + else + { + /* Here, we have found [c*s] where s should be a string + of octal (if it starts with `0') or decimal digits. */ + char const *digit_str = &es->s[start_idx + 2]; + char *d_end; + if ((xstrtoumax (digit_str, &d_end, *digit_str == '0' ? 8 : 10, + repeat_count, NULL) + != LONGINT_OK) + || REPEAT_COUNT_MAXIMUM < *repeat_count + || digit_str + digit_str_len != d_end) + { + char *tmp = make_printable_str (digit_str, digit_str_len); + error (0, 0, + _("invalid repeat count %s in [c*n] construct"), + quote (tmp)); + free (tmp); + return -2; + } + } + *closing_bracket_idx = i; + return 0; + } } return -1; /* No bracket found. */ } @@ -863,10 +863,10 @@ star_digits_closebracket (const struct E_string *es, size_t idx) - [:str:] Character class where `str' is one of the 12 valid strings. - [=c=] Equivalence class where `c' is any single character. - [c*n] Repeat the single character `c' `n' times. n may be omitted. - However, if `n' is present, it must be a non-negative octal or - decimal integer. + However, if `n' is present, it must be a non-negative octal or + decimal integer. - r-s Range of characters from `r' to `s'. The second endpoint must - not precede the first in the current collating sequence. + not precede the first in the current collating sequence. - c Any other character is interpreted as itself. */ static bool @@ -887,120 +887,120 @@ build_spec_list (const struct E_string *es, struct Spec_list *result) for (i = 0; i + 2 < es->len; /* empty */) { if (es_match (es, i, '[')) - { - bool matched_multi_char_construct; - size_t closing_bracket_idx; - unsigned char char_to_repeat; - count repeat_count; - int err; + { + bool matched_multi_char_construct; + size_t closing_bracket_idx; + unsigned char char_to_repeat; + count repeat_count; + int err; - matched_multi_char_construct = true; - if (es_match (es, i + 1, ':') || es_match (es, i + 1, '=')) - { - size_t closing_delim_idx; + matched_multi_char_construct = true; + if (es_match (es, i + 1, ':') || es_match (es, i + 1, '=')) + { + size_t closing_delim_idx; - if (find_closing_delim (es, i + 2, p[i + 1], &closing_delim_idx)) - { - size_t opnd_str_len = closing_delim_idx - 1 - (i + 2) + 1; - char const *opnd_str = p + i + 2; + if (find_closing_delim (es, i + 2, p[i + 1], &closing_delim_idx)) + { + size_t opnd_str_len = closing_delim_idx - 1 - (i + 2) + 1; + char const *opnd_str = p + i + 2; - if (opnd_str_len == 0) - { - if (p[i + 1] == ':') - error (0, 0, _("missing character class name `[::]'")); - else - error (0, 0, - _("missing equivalence class character `[==]'")); - return false; - } + if (opnd_str_len == 0) + { + if (p[i + 1] == ':') + error (0, 0, _("missing character class name `[::]'")); + else + error (0, 0, + _("missing equivalence class character `[==]'")); + return false; + } - if (p[i + 1] == ':') - { - /* FIXME: big comment. */ - if (!append_char_class (result, opnd_str, opnd_str_len)) - { - if (star_digits_closebracket (es, i + 2)) - goto try_bracketed_repeat; - else - { - char *tmp = make_printable_str (opnd_str, - opnd_str_len); - error (0, 0, _("invalid character class %s"), - quote (tmp)); - free (tmp); - return false; - } - } - } - else - { - /* FIXME: big comment. */ - if (!append_equiv_class (result, opnd_str, opnd_str_len)) - { - if (star_digits_closebracket (es, i + 2)) - goto try_bracketed_repeat; - else - { - char *tmp = make_printable_str (opnd_str, - opnd_str_len); - error (0, 0, - _("%s: equivalence class operand must be a single character"), - tmp); - free (tmp); - return false; - } - } - } + if (p[i + 1] == ':') + { + /* FIXME: big comment. */ + if (!append_char_class (result, opnd_str, opnd_str_len)) + { + if (star_digits_closebracket (es, i + 2)) + goto try_bracketed_repeat; + else + { + char *tmp = make_printable_str (opnd_str, + opnd_str_len); + error (0, 0, _("invalid character class %s"), + quote (tmp)); + free (tmp); + return false; + } + } + } + else + { + /* FIXME: big comment. */ + if (!append_equiv_class (result, opnd_str, opnd_str_len)) + { + if (star_digits_closebracket (es, i + 2)) + goto try_bracketed_repeat; + else + { + char *tmp = make_printable_str (opnd_str, + opnd_str_len); + error (0, 0, + _("%s: equivalence class operand must be a single character"), + tmp); + free (tmp); + return false; + } + } + } - i = closing_delim_idx + 2; - continue; - } - /* Else fall through. This could be [:*] or [=*]. */ - } + i = closing_delim_idx + 2; + continue; + } + /* Else fall through. This could be [:*] or [=*]. */ + } - try_bracketed_repeat: + try_bracketed_repeat: - /* Determine whether this is a bracketed repeat range - matching the RE \[.\*(dec_or_oct_number)?\]. */ - err = find_bracketed_repeat (es, i + 1, &char_to_repeat, - &repeat_count, - &closing_bracket_idx); - if (err == 0) - { - append_repeated_char (result, char_to_repeat, repeat_count); - i = closing_bracket_idx + 1; - } - else if (err == -1) - { - matched_multi_char_construct = false; - } - else - { - /* Found a string that looked like [c*n] but the - numeric part was invalid. */ - return false; - } + /* Determine whether this is a bracketed repeat range + matching the RE \[.\*(dec_or_oct_number)?\]. */ + err = find_bracketed_repeat (es, i + 1, &char_to_repeat, + &repeat_count, + &closing_bracket_idx); + if (err == 0) + { + append_repeated_char (result, char_to_repeat, repeat_count); + i = closing_bracket_idx + 1; + } + else if (err == -1) + { + matched_multi_char_construct = false; + } + else + { + /* Found a string that looked like [c*n] but the + numeric part was invalid. */ + return false; + } - if (matched_multi_char_construct) - continue; + if (matched_multi_char_construct) + continue; - /* We reach this point if P does not match [:str:], [=c=], - [c*n], or [c*]. Now, see if P looks like a range `[-c' - (from `[' to `c'). */ - } + /* We reach this point if P does not match [:str:], [=c=], + [c*n], or [c*]. Now, see if P looks like a range `[-c' + (from `[' to `c'). */ + } /* Look ahead one char for ranges like a-z. */ if (es_match (es, i + 1, '-')) - { - if (!append_range (result, p[i], p[i + 2])) - return false; - i += 3; - } + { + if (!append_range (result, p[i], p[i + 2])) + return false; + i += 3; + } else - { - append_normal_char (result, p[i]); - ++i; - } + { + append_normal_char (result, p[i]); + ++i; + } } /* Now handle the (2 or fewer) remaining characters p[i]..p[es->len - 1]. */ @@ -1063,53 +1063,53 @@ get_next (struct Spec_list *s, enum Upper_Lower_class *class) case RE_RANGE: if (s->state == NEW_ELEMENT) - s->state = p->u.range.first_char; + s->state = p->u.range.first_char; else - ++(s->state); + ++(s->state); return_val = s->state; if (s->state == p->u.range.last_char) - { - s->tail = p->next; - s->state = NEW_ELEMENT; - } + { + s->tail = p->next; + s->state = NEW_ELEMENT; + } break; case RE_CHAR_CLASS: if (class) - { - switch (p->u.char_class) - { - case CC_LOWER: - *class = UL_LOWER; - break; - case CC_UPPER: - *class = UL_UPPER; - break; - default: - break; - } - } + { + switch (p->u.char_class) + { + case CC_LOWER: + *class = UL_LOWER; + break; + case CC_UPPER: + *class = UL_UPPER; + break; + default: + break; + } + } if (s->state == NEW_ELEMENT) - { - for (i = 0; i < N_CHARS; i++) - if (is_char_class_member (p->u.char_class, i)) - break; - assert (i < N_CHARS); - s->state = i; - } + { + for (i = 0; i < N_CHARS; i++) + if (is_char_class_member (p->u.char_class, i)) + break; + assert (i < N_CHARS); + s->state = i; + } assert (is_char_class_member (p->u.char_class, s->state)); return_val = s->state; for (i = s->state + 1; i < N_CHARS; i++) - if (is_char_class_member (p->u.char_class, i)) - break; + if (is_char_class_member (p->u.char_class, i)) + break; if (i < N_CHARS) - s->state = i; + s->state = i; else - { - s->tail = p->next; - s->state = NEW_ELEMENT; - } + { + s->tail = p->next; + s->state = NEW_ELEMENT; + } break; case RE_EQUIV_CLASS: @@ -1126,25 +1126,25 @@ get_next (struct Spec_list *s, enum Upper_Lower_class *class) case RE_REPEATED_CHAR: /* Here, a repeat count of n == 0 means don't repeat at all. */ if (p->u.repeated_char.repeat_count == 0) - { - s->tail = p->next; - s->state = NEW_ELEMENT; - return_val = get_next (s, class); - } + { + s->tail = p->next; + s->state = NEW_ELEMENT; + return_val = get_next (s, class); + } else - { - if (s->state == NEW_ELEMENT) - { - s->state = 0; - } - ++(s->state); - return_val = p->u.repeated_char.the_repeated_char; - if (s->state == p->u.repeated_char.repeat_count) - { - s->tail = p->next; - s->state = NEW_ELEMENT; - } - } + { + if (s->state == NEW_ELEMENT) + { + s->state = 0; + } + ++(s->state); + return_val = p->u.repeated_char.the_repeated_char; + if (s->state == p->u.repeated_char.repeat_count) + { + s->tail = p->next; + s->state = NEW_ELEMENT; + } + } break; default: @@ -1206,61 +1206,61 @@ get_spec_stats (struct Spec_list *s) count new_length; switch (p->type) - { - case RE_NORMAL_CHAR: - len = 1; - break; + { + case RE_NORMAL_CHAR: + len = 1; + break; - case RE_RANGE: - assert (p->u.range.last_char >= p->u.range.first_char); - len = p->u.range.last_char - p->u.range.first_char + 1; - break; + case RE_RANGE: + assert (p->u.range.last_char >= p->u.range.first_char); + len = p->u.range.last_char - p->u.range.first_char + 1; + break; - case RE_CHAR_CLASS: - s->has_char_class = true; - for (i = 0; i < N_CHARS; i++) - if (is_char_class_member (p->u.char_class, i)) - ++len; - switch (p->u.char_class) - { - case CC_UPPER: - case CC_LOWER: - break; - default: - s->has_restricted_char_class = true; - break; - } - break; + case RE_CHAR_CLASS: + s->has_char_class = true; + for (i = 0; i < N_CHARS; i++) + if (is_char_class_member (p->u.char_class, i)) + ++len; + switch (p->u.char_class) + { + case CC_UPPER: + case CC_LOWER: + break; + default: + s->has_restricted_char_class = true; + break; + } + break; - case RE_EQUIV_CLASS: - for (i = 0; i < N_CHARS; i++) - if (is_equiv_class_member (p->u.equiv_code, i)) - ++len; - s->has_equiv_class = true; - break; + case RE_EQUIV_CLASS: + for (i = 0; i < N_CHARS; i++) + if (is_equiv_class_member (p->u.equiv_code, i)) + ++len; + s->has_equiv_class = true; + break; - case RE_REPEATED_CHAR: - if (p->u.repeated_char.repeat_count > 0) - len = p->u.repeated_char.repeat_count; - else - { - s->indefinite_repeat_element = p; - ++(s->n_indefinite_repeats); - } - break; + case RE_REPEATED_CHAR: + if (p->u.repeated_char.repeat_count > 0) + len = p->u.repeated_char.repeat_count; + else + { + s->indefinite_repeat_element = p; + ++(s->n_indefinite_repeats); + } + break; - default: - abort (); - break; - } + default: + abort (); + break; + } /* Check for arithmetic overflow in computing length. Also, reject - any length greater than the maximum repeat count, in case the - length is later used to compute the repeat count for an - indefinite element. */ + any length greater than the maximum repeat count, in case the + length is later used to compute the repeat count for an + indefinite element. */ new_length = length + len; if (! (length <= new_length && new_length <= REPEAT_COUNT_MAXIMUM)) - error (EXIT_FAILURE, 0, _("too many characters in set")); + error (EXIT_FAILURE, 0, _("too many characters in set")); length = new_length; } @@ -1282,7 +1282,7 @@ get_s2_spec_stats (struct Spec_list *s2, count len_s1) if (len_s1 >= s2->length && s2->n_indefinite_repeats == 1) { s2->indefinite_repeat_element->u.repeated_char.repeat_count = - len_s1 - s2->length; + len_s1 - s2->length; s2->length = len_s1; } } @@ -1347,8 +1347,8 @@ string2_extend (const struct Spec_list *s1, struct Spec_list *s2) break; case RE_CHAR_CLASS: for (i = N_CHARS - 1; i >= 0; i--) - if (is_char_class_member (p->u.char_class, i)) - break; + if (is_char_class_member (p->u.char_class, i)) + break; assert (i >= 0); char_to_repeat = i; break; @@ -1408,7 +1408,7 @@ validate (struct Spec_list *s1, struct Spec_list *s2) if (s1->n_indefinite_repeats > 0) { error (EXIT_FAILURE, 0, - _("the [c*] repeat construct may not appear in string1")); + _("the [c*] repeat construct may not appear in string1")); } if (s2) @@ -1416,57 +1416,57 @@ validate (struct Spec_list *s1, struct Spec_list *s2) get_s2_spec_stats (s2, s1->length); if (s2->n_indefinite_repeats > 1) - { - error (EXIT_FAILURE, 0, - _("only one [c*] repeat construct may appear in string2")); - } + { + error (EXIT_FAILURE, 0, + _("only one [c*] repeat construct may appear in string2")); + } if (translating) - { - if (s2->has_equiv_class) - { - error (EXIT_FAILURE, 0, - _("[=c=] expressions may not appear in string2 \ + { + if (s2->has_equiv_class) + { + error (EXIT_FAILURE, 0, + _("[=c=] expressions may not appear in string2 \ when translating")); - } + } - if (s1->length > s2->length) - { - if (!truncate_set1) - { - /* string2 must be non-empty unless --truncate-set1 is - given or string1 is empty. */ + if (s1->length > s2->length) + { + if (!truncate_set1) + { + /* string2 must be non-empty unless --truncate-set1 is + given or string1 is empty. */ - if (s2->length == 0) - error (EXIT_FAILURE, 0, - _("when not truncating set1, string2 must be non-empty")); - string2_extend (s1, s2); - } - } + if (s2->length == 0) + error (EXIT_FAILURE, 0, + _("when not truncating set1, string2 must be non-empty")); + string2_extend (s1, s2); + } + } - if (complement && s1->has_char_class - && ! (s2->length == s1->length && homogeneous_spec_list (s2))) - { - error (EXIT_FAILURE, 0, - _("when translating with complemented character classes,\ + if (complement && s1->has_char_class + && ! (s2->length == s1->length && homogeneous_spec_list (s2))) + { + error (EXIT_FAILURE, 0, + _("when translating with complemented character classes,\ \nstring2 must map all characters in the domain to one")); - } + } - if (s2->has_restricted_char_class) - { - error (EXIT_FAILURE, 0, - _("when translating, the only character classes that may \ + if (s2->has_restricted_char_class) + { + error (EXIT_FAILURE, 0, + _("when translating, the only character classes that may \ appear in\nstring2 are `upper' and `lower'")); - } - } + } + } else - /* Not translating. */ - { - if (s2->n_indefinite_repeats > 0) - error (EXIT_FAILURE, 0, - _("the [c*] construct may appear in string2 only \ + /* Not translating. */ + { + if (s2->n_indefinite_repeats > 0) + error (EXIT_FAILURE, 0, + _("the [c*] construct may appear in string2 only \ when translating")); - } + } } } @@ -1494,74 +1494,74 @@ squeeze_filter (char *buf, size_t size, size_t (*reader) (char *, size_t)) size_t begin; if (i >= nr) - { - nr = reader (buf, size); - if (nr == 0) - break; - i = 0; - } + { + nr = reader (buf, size); + if (nr == 0) + break; + i = 0; + } begin = i; if (char_to_squeeze == NOT_A_CHAR) - { - size_t out_len; - /* Here, by being a little tricky, we can get a significant - performance increase in most cases when the input is - reasonably large. Since tr will modify the input only - if two consecutive (and identical) input characters are - in the squeeze set, we can step by two through the data - when searching for a character in the squeeze set. This - means there may be a little more work in a few cases and - perhaps twice as much work in the worst cases where most - of the input is removed by squeezing repeats. But most - uses of this functionality seem to remove less than 20-30% - of the input. */ - for (; i < nr && !in_squeeze_set[to_uchar (buf[i])]; i += 2) - continue; + { + size_t out_len; + /* Here, by being a little tricky, we can get a significant + performance increase in most cases when the input is + reasonably large. Since tr will modify the input only + if two consecutive (and identical) input characters are + in the squeeze set, we can step by two through the data + when searching for a character in the squeeze set. This + means there may be a little more work in a few cases and + perhaps twice as much work in the worst cases where most + of the input is removed by squeezing repeats. But most + uses of this functionality seem to remove less than 20-30% + of the input. */ + for (; i < nr && !in_squeeze_set[to_uchar (buf[i])]; i += 2) + continue; - /* There is a special case when i == nr and we've just - skipped a character (the last one in buf) that is in - the squeeze set. */ - if (i == nr && in_squeeze_set[to_uchar (buf[i - 1])]) - --i; + /* There is a special case when i == nr and we've just + skipped a character (the last one in buf) that is in + the squeeze set. */ + if (i == nr && in_squeeze_set[to_uchar (buf[i - 1])]) + --i; - if (i >= nr) - out_len = nr - begin; - else - { - char_to_squeeze = buf[i]; - /* We're about to output buf[begin..i]. */ - out_len = i - begin + 1; + if (i >= nr) + out_len = nr - begin; + else + { + char_to_squeeze = buf[i]; + /* We're about to output buf[begin..i]. */ + out_len = i - begin + 1; - /* But since we stepped by 2 in the loop above, - out_len may be one too large. */ - if (i > 0 && buf[i - 1] == char_to_squeeze) - --out_len; + /* But since we stepped by 2 in the loop above, + out_len may be one too large. */ + if (i > 0 && buf[i - 1] == char_to_squeeze) + --out_len; - /* Advance i to the index of first character to be - considered when looking for a char different from - char_to_squeeze. */ - ++i; - } - if (out_len > 0 - && fwrite (&buf[begin], 1, out_len, stdout) != out_len) - error (EXIT_FAILURE, errno, _("write error")); - } + /* Advance i to the index of first character to be + considered when looking for a char different from + char_to_squeeze. */ + ++i; + } + if (out_len > 0 + && fwrite (&buf[begin], 1, out_len, stdout) != out_len) + error (EXIT_FAILURE, errno, _("write error")); + } if (char_to_squeeze != NOT_A_CHAR) - { - /* Advance i to index of first char != char_to_squeeze - (or to nr if all the rest of the characters in this - buffer are the same as char_to_squeeze). */ - for (; i < nr && buf[i] == char_to_squeeze; i++) - continue; - if (i < nr) - char_to_squeeze = NOT_A_CHAR; - /* If (i >= nr) we've squeezed the last character in this buffer. - So now we have to read a new buffer and continue comparing - characters against char_to_squeeze. */ - } + { + /* Advance i to index of first char != char_to_squeeze + (or to nr if all the rest of the characters in this + buffer are the same as char_to_squeeze). */ + for (; i < nr && buf[i] == char_to_squeeze; i++) + continue; + if (i < nr) + char_to_squeeze = NOT_A_CHAR; + /* If (i >= nr) we've squeezed the last character in this buffer. + So now we have to read a new buffer and continue comparing + characters against char_to_squeeze. */ + } } } @@ -1594,7 +1594,7 @@ read_and_delete (char *buf, size_t size) size_t nr = plain_read (buf, size); if (nr == 0) - return 0; + return 0; /* This first loop may be a waste of code, but gives much better performance when no characters are deleted in @@ -1602,12 +1602,12 @@ read_and_delete (char *buf, size_t size) of buf[i] into buf[n_saved] when it would be a NOP. */ for (i = 0; i < nr && !in_delete_set[to_uchar (buf[i])]; i++) - continue; + continue; n_saved = i; for (++i; i < nr; i++) - if (!in_delete_set[to_uchar (buf[i])]) - buf[n_saved++] = buf[i]; + if (!in_delete_set[to_uchar (buf[i])]) + buf[n_saved++] = buf[i]; } while (n_saved == 0); @@ -1672,32 +1672,32 @@ main (int argc, char **argv) while ((c = getopt_long (argc, argv, "+cCdst", long_options, NULL)) != -1) { switch (c) - { - case 'c': - case 'C': - complement = true; - break; + { + case 'c': + case 'C': + complement = true; + break; - case 'd': - delete = true; - break; + case 'd': + delete = true; + break; - case 's': - squeeze_repeats = true; - break; + case 's': + squeeze_repeats = true; + break; - case 't': - truncate_set1 = true; - break; + case 't': + truncate_set1 = 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); - break; - } + default: + usage (EXIT_FAILURE); + break; + } } non_option_args = argc - optind; @@ -1708,16 +1708,16 @@ main (int argc, char **argv) if (non_option_args < min_operands) { if (non_option_args == 0) - error (0, 0, _("missing operand")); + error (0, 0, _("missing operand")); else - { - error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); - fprintf (stderr, "%s\n", - _(squeeze_repeats - ? N_("Two strings must be given when " - "both deleting and squeezing repeats.") - : N_("Two strings must be given when translating."))); - } + { + error (0, 0, _("missing operand after %s"), quote (argv[argc - 1])); + fprintf (stderr, "%s\n", + _(squeeze_repeats + ? N_("Two strings must be given when " + "both deleting and squeezing repeats.") + : N_("Two strings must be given when translating."))); + } usage (EXIT_FAILURE); } @@ -1725,9 +1725,9 @@ main (int argc, char **argv) { error (0, 0, _("extra operand %s"), quote (argv[optind + max_operands])); if (non_option_args == 2) - fprintf (stderr, "%s\n", - _("Only one string may be given when " - "deleting without squeezing repeats.")); + fprintf (stderr, "%s\n", + _("Only one string may be given when " + "deleting without squeezing repeats.")); usage (EXIT_FAILURE); } @@ -1739,7 +1739,7 @@ main (int argc, char **argv) { spec_init (s2); if (!parse_str (argv[optind + 1], s2)) - exit (EXIT_FAILURE); + exit (EXIT_FAILURE); } else s2 = NULL; @@ -1764,13 +1764,13 @@ main (int argc, char **argv) set_initialize (s1, complement, in_delete_set); for (;;) - { - size_t nr = read_and_delete (io_buf, sizeof io_buf); - if (nr == 0) - break; - if (fwrite (io_buf, 1, nr, stdout) != nr) - error (EXIT_FAILURE, errno, _("write error")); - } + { + size_t nr = read_and_delete (io_buf, sizeof io_buf); + if (nr == 0) + break; + if (fwrite (io_buf, 1, nr, stdout) != nr) + error (EXIT_FAILURE, errno, _("write error")); + } } else if (squeeze_repeats && delete && non_option_args == 2) { @@ -1781,111 +1781,111 @@ main (int argc, char **argv) else if (translating) { if (complement) - { - int i; - bool *in_s1 = in_delete_set; + { + int i; + bool *in_s1 = in_delete_set; - set_initialize (s1, false, in_s1); - s2->state = BEGIN_STATE; - for (i = 0; i < N_CHARS; i++) - xlate[i] = i; - for (i = 0; i < N_CHARS; i++) - { - if (!in_s1[i]) - { - int ch = get_next (s2, NULL); - assert (ch != -1 || truncate_set1); - if (ch == -1) - { - /* This will happen when tr is invoked like e.g. - tr -cs A-Za-z0-9 '\012'. */ - break; - } - xlate[i] = ch; - } - } - } + set_initialize (s1, false, in_s1); + s2->state = BEGIN_STATE; + for (i = 0; i < N_CHARS; i++) + xlate[i] = i; + for (i = 0; i < N_CHARS; i++) + { + if (!in_s1[i]) + { + int ch = get_next (s2, NULL); + assert (ch != -1 || truncate_set1); + if (ch == -1) + { + /* This will happen when tr is invoked like e.g. + tr -cs A-Za-z0-9 '\012'. */ + break; + } + xlate[i] = ch; + } + } + } else - { - int c1, c2; - int i; - bool case_convert = false; - enum Upper_Lower_class class_s1; - enum Upper_Lower_class class_s2; + { + int c1, c2; + int i; + bool case_convert = false; + enum Upper_Lower_class class_s1; + enum Upper_Lower_class class_s2; - for (i = 0; i < N_CHARS; i++) - xlate[i] = i; - s1->state = BEGIN_STATE; - s2->state = BEGIN_STATE; - for (;;) - { - /* When the previous pair identified case-converting classes, - advance S1 and S2 so that each points to the following - construct. */ - if (case_convert) - { - skip_construct (s1); - skip_construct (s2); - case_convert = false; - } + for (i = 0; i < N_CHARS; i++) + xlate[i] = i; + s1->state = BEGIN_STATE; + s2->state = BEGIN_STATE; + for (;;) + { + /* When the previous pair identified case-converting classes, + advance S1 and S2 so that each points to the following + construct. */ + if (case_convert) + { + skip_construct (s1); + skip_construct (s2); + case_convert = false; + } - c1 = get_next (s1, &class_s1); - c2 = get_next (s2, &class_s2); + c1 = get_next (s1, &class_s1); + c2 = get_next (s2, &class_s2); - /* When translating and there is an [:upper:] or [:lower:] - class in SET2, then there must be a corresponding [:lower:] - or [:upper:] class in SET1. */ - if (class_s1 == UL_NONE - && (class_s2 == UL_LOWER || class_s2 == UL_UPPER)) - error (EXIT_FAILURE, 0, - _("misaligned [:upper:] and/or [:lower:] construct")); + /* When translating and there is an [:upper:] or [:lower:] + class in SET2, then there must be a corresponding [:lower:] + or [:upper:] class in SET1. */ + if (class_s1 == UL_NONE + && (class_s2 == UL_LOWER || class_s2 == UL_UPPER)) + error (EXIT_FAILURE, 0, + _("misaligned [:upper:] and/or [:lower:] construct")); - if (class_s1 == UL_LOWER && class_s2 == UL_UPPER) - { - case_convert = true; - for (i = 0; i < N_CHARS; i++) - if (islower (i)) - xlate[i] = toupper (i); - } - else if (class_s1 == UL_UPPER && class_s2 == UL_LOWER) - { - case_convert = true; - for (i = 0; i < N_CHARS; i++) - if (isupper (i)) - xlate[i] = tolower (i); - } - else if ((class_s1 == UL_LOWER && class_s2 == UL_LOWER) - || (class_s1 == UL_UPPER && class_s2 == UL_UPPER)) - { - /* POSIX says the behavior of `tr "[:upper:]" "[:upper:]"' - is undefined. Treat it as a no-op. */ - } - else - { - /* The following should have been checked by validate... */ - if (c1 == -1 || c2 == -1) - break; - xlate[c1] = c2; - } - } - assert (c1 == -1 || truncate_set1); - } + if (class_s1 == UL_LOWER && class_s2 == UL_UPPER) + { + case_convert = true; + for (i = 0; i < N_CHARS; i++) + if (islower (i)) + xlate[i] = toupper (i); + } + else if (class_s1 == UL_UPPER && class_s2 == UL_LOWER) + { + case_convert = true; + for (i = 0; i < N_CHARS; i++) + if (isupper (i)) + xlate[i] = tolower (i); + } + else if ((class_s1 == UL_LOWER && class_s2 == UL_LOWER) + || (class_s1 == UL_UPPER && class_s2 == UL_UPPER)) + { + /* POSIX says the behavior of `tr "[:upper:]" "[:upper:]"' + is undefined. Treat it as a no-op. */ + } + else + { + /* The following should have been checked by validate... */ + if (c1 == -1 || c2 == -1) + break; + xlate[c1] = c2; + } + } + assert (c1 == -1 || truncate_set1); + } if (squeeze_repeats) - { - set_initialize (s2, false, in_squeeze_set); - squeeze_filter (io_buf, sizeof io_buf, read_and_xlate); - } + { + set_initialize (s2, false, in_squeeze_set); + squeeze_filter (io_buf, sizeof io_buf, read_and_xlate); + } else - { - for (;;) - { - size_t bytes_read = read_and_xlate (io_buf, sizeof io_buf); - if (bytes_read == 0) - break; - if (fwrite (io_buf, 1, bytes_read, stdout) != bytes_read) - error (EXIT_FAILURE, errno, _("write error")); - } - } + { + for (;;) + { + size_t bytes_read = read_and_xlate (io_buf, sizeof io_buf); + if (bytes_read == 0) + break; + if (fwrite (io_buf, 1, bytes_read, stdout) != bytes_read) + error (EXIT_FAILURE, errno, _("write error")); + } + } } if (close (STDIN_FILENO) != 0) diff --git a/src/bin/coreutils/src/true.c b/src/bin/coreutils/src/true.c index 46b41b988f..66d1e01116 100644 --- a/src/bin/coreutils/src/true.c +++ b/src/bin/coreutils/src/true.c @@ -39,11 +39,11 @@ usage (int status) Usage: %s [ignored command line arguments]\n\ or: %s OPTION\n\ "), - program_name, program_name); + program_name, program_name); printf ("%s\n\n", - _(EXIT_STATUS == EXIT_SUCCESS - ? N_("Exit with a status code indicating success.") - : N_("Exit with a status code indicating failure."))); + _(EXIT_STATUS == EXIT_SUCCESS + ? N_("Exit with a status code indicating success.") + : N_("Exit with a status code indicating failure."))); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); @@ -67,11 +67,11 @@ main (int argc, char **argv) if (argc == 2) { if (STREQ (argv[1], "--help")) - usage (EXIT_STATUS); + usage (EXIT_STATUS); if (STREQ (argv[1], "--version")) - version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, - (char *) NULL); + version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS, + (char *) NULL); } exit (EXIT_STATUS); diff --git a/src/bin/coreutils/src/truncate.c b/src/bin/coreutils/src/truncate.c index 31b3aa635f..77783794ea 100644 --- a/src/bin/coreutils/src/truncate.c +++ b/src/bin/coreutils/src/truncate.c @@ -124,10 +124,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -s, --size=SIZE use this SIZE\n"), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - fputs (_("\n\ -SIZE is a number which may be followed by one of the following suffixes:\n\ -KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\ -"), stdout); + emit_size_note (); fputs (_("\n\ SIZE may also be prefixed by one of the following modifying characters:\n\ `+' extend by, `-' reduce by, `<' at most, `>' at least,\n\ @@ -416,9 +413,3 @@ main (int argc, char **argv) return errors ? EXIT_FAILURE : EXIT_SUCCESS; } - -/* - * Local variables: - * indent-tabs-mode: nil - * End: - */ diff --git a/src/bin/coreutils/src/tsort.c b/src/bin/coreutils/src/tsort.c index 614ba9dbad..d74b620919 100644 --- a/src/bin/coreutils/src/tsort.c +++ b/src/bin/coreutils/src/tsort.c @@ -76,7 +76,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ @@ -141,120 +141,120 @@ search_item (struct item *root, const char *str) /* A2. Compare. */ a = strcmp (str, p->str); if (a == 0) - return p; + return p; /* A3 & A4. Move left & right. */ if (a < 0) - q = p->left; + q = p->left; else - q = p->right; + q = p->right; if (q == NULL) - { - /* A5. Insert. */ - q = new_item (str); + { + /* A5. Insert. */ + q = new_item (str); - /* A3 & A4. (continued). */ - if (a < 0) - p->left = q; - else - p->right = q; + /* A3 & A4. (continued). */ + if (a < 0) + p->left = q; + else + p->right = q; - /* A6. Adjust balance factors. */ - assert (!STREQ (str, s->str)); - if (strcmp (str, s->str) < 0) - { - r = p = s->left; - a = -1; - } - else - { - r = p = s->right; - a = 1; - } + /* A6. Adjust balance factors. */ + assert (!STREQ (str, s->str)); + if (strcmp (str, s->str) < 0) + { + r = p = s->left; + a = -1; + } + else + { + r = p = s->right; + a = 1; + } - while (p != q) - { - assert (!STREQ (str, p->str)); - if (strcmp (str, p->str) < 0) - { - p->balance = -1; - p = p->left; - } - else - { - p->balance = 1; - p = p->right; - } - } + while (p != q) + { + assert (!STREQ (str, p->str)); + if (strcmp (str, p->str) < 0) + { + p->balance = -1; + p = p->left; + } + else + { + p->balance = 1; + p = p->right; + } + } - /* A7. Balancing act. */ - if (s->balance == 0 || s->balance == -a) - { - s->balance += a; - return q; - } + /* A7. Balancing act. */ + if (s->balance == 0 || s->balance == -a) + { + s->balance += a; + return q; + } - if (r->balance == a) - { - /* A8. Single Rotation. */ - p = r; - if (a < 0) - { - s->left = r->right; - r->right = s; - } - else - { - s->right = r->left; - r->left = s; - } - s->balance = r->balance = 0; - } - else - { - /* A9. Double rotation. */ - if (a < 0) - { - p = r->right; - r->right = p->left; - p->left = r; - s->left = p->right; - p->right = s; - } - else - { - p = r->left; - r->left = p->right; - p->right = r; - s->right = p->left; - p->left = s; - } + if (r->balance == a) + { + /* A8. Single Rotation. */ + p = r; + if (a < 0) + { + s->left = r->right; + r->right = s; + } + else + { + s->right = r->left; + r->left = s; + } + s->balance = r->balance = 0; + } + else + { + /* A9. Double rotation. */ + if (a < 0) + { + p = r->right; + r->right = p->left; + p->left = r; + s->left = p->right; + p->right = s; + } + else + { + p = r->left; + r->left = p->right; + p->right = r; + s->right = p->left; + p->left = s; + } - s->balance = 0; - r->balance = 0; - if (p->balance == a) - s->balance = -a; - else if (p->balance == -a) - r->balance = a; - p->balance = 0; - } + s->balance = 0; + r->balance = 0; + if (p->balance == a) + s->balance = -a; + else if (p->balance == -a) + r->balance = a; + p->balance = 0; + } - /* A10. Finishing touch. */ - if (s == t->right) - t->right = p; - else - t->left = p; + /* A10. Finishing touch. */ + if (s == t->right) + t->right = p; + else + t->left = p; - return q; - } + return q; + } /* A3 & A4. (continued). */ if (q->balance) - { - t = p; - s = q; - } + { + t = p; + s = q; + } p = q; } @@ -293,9 +293,9 @@ scan_zeros (struct item *k) if (k->count == 0 && k->str) { if (head == NULL) - head = k; + head = k; else - zeros->qlink = k; + zeros->qlink = k; zeros = k; } @@ -327,67 +327,67 @@ detect_loop (struct item *k) if (k->count > 0) { /* K does not have to be part of a cycle. It is however part of - a graph that contains a cycle. */ + a graph that contains a cycle. */ if (loop == NULL) - /* Start traversing the graph at K. */ - loop = k; + /* Start traversing the graph at K. */ + loop = k; else - { - struct successor **p = &k->top; + { + struct successor **p = &k->top; - while (*p) - { - if ((*p)->suc == loop) - { - if (k->qlink) - { - /* We have found a loop. Retrace our steps. */ - while (loop) - { - struct item *tmp = loop->qlink; + while (*p) + { + if ((*p)->suc == loop) + { + if (k->qlink) + { + /* We have found a loop. Retrace our steps. */ + while (loop) + { + struct item *tmp = loop->qlink; - fprintf (stderr, "%s: %s\n", program_name, - loop->str); + fprintf (stderr, "%s: %s\n", program_name, + loop->str); - /* Until we encounter K again. */ - if (loop == k) - { - /* Remove relation. */ - (*p)->suc->count--; - *p = (*p)->next; - break; - } + /* Until we encounter K again. */ + if (loop == k) + { + /* Remove relation. */ + (*p)->suc->count--; + *p = (*p)->next; + break; + } - /* Tidy things up since we might have to + /* Tidy things up since we might have to detect another loop. */ - loop->qlink = NULL; - loop = tmp; - } + loop->qlink = NULL; + loop = tmp; + } - while (loop) - { - struct item *tmp = loop->qlink; + while (loop) + { + struct item *tmp = loop->qlink; - loop->qlink = NULL; - loop = tmp; - } + loop->qlink = NULL; + loop = tmp; + } - /* Since we have found the loop, stop walking + /* Since we have found the loop, stop walking the tree. */ - return true; - } - else - { - k->qlink = loop; - loop = k; - break; - } - } + return true; + } + else + { + k->qlink = loop; + loop = k; + break; + } + } - p = &(*p)->next; - } - } + p = &(*p)->next; + } + } } return false; @@ -404,13 +404,13 @@ recurse_tree (struct item *root, bool (*action) (struct item *)) else { if (root->left != NULL) - if (recurse_tree (root->left, action)) - return true; + if (recurse_tree (root->left, action)) + return true; if ((*action) (root)) - return true; + return true; if (root->right != NULL) - if (recurse_tree (root->right, action)) - return true; + if (recurse_tree (root->right, action)) + return true; } return false; @@ -451,24 +451,24 @@ tsort (const char *file) /* T2. Next Relation. */ size_t len = readtoken (stdin, DELIM, sizeof (DELIM) - 1, &tokenbuffer); if (len == (size_t) -1) - break; + break; assert (len != 0); k = search_item (root, tokenbuffer.buffer); if (j) - { - /* T3. Record the relation. */ - record_relation (j, k); - k = NULL; - } + { + /* T3. Record the relation. */ + record_relation (j, k); + k = NULL; + } j = k; } if (k != NULL) error (EXIT_FAILURE, 0, _("%s: input contains an odd number of tokens"), - file); + file); /* T1. Initialize (N <- n). */ walk_tree (root, count_items); @@ -479,48 +479,48 @@ tsort (const char *file) walk_tree (root, scan_zeros); while (head) - { - struct successor *p = head->top; + { + struct successor *p = head->top; - /* T5. Output front of queue. */ - puts (head->str); - head->str = NULL; /* Avoid printing the same string twice. */ - n_strings--; + /* T5. Output front of queue. */ + puts (head->str); + head->str = NULL; /* Avoid printing the same string twice. */ + n_strings--; - /* T6. Erase relations. */ - while (p) - { - p->suc->count--; - if (p->suc->count == 0) - { - zeros->qlink = p->suc; - zeros = p->suc; - } + /* T6. Erase relations. */ + while (p) + { + p->suc->count--; + if (p->suc->count == 0) + { + zeros->qlink = p->suc; + zeros = p->suc; + } - p = p->next; - } + p = p->next; + } - /* T7. Remove from queue. */ - head = head->qlink; - } + /* T7. Remove from queue. */ + head = head->qlink; + } /* T8. End of process. */ if (n_strings > 0) - { - /* The input contains a loop. */ - error (0, 0, _("%s: input contains a loop:"), file); - ok = false; + { + /* The input contains a loop. */ + error (0, 0, _("%s: input contains a loop:"), file); + ok = false; - /* Print the loop and remove a relation to break it. */ - do - walk_tree (root, detect_loop); - while (loop); - } + /* Print the loop and remove a relation to break it. */ + do + walk_tree (root, detect_loop); + while (loop); + } } if (fclose (stdin) != 0) error (EXIT_FAILURE, errno, "%s", - is_stdin ? _("standard input") : quote (file)); + is_stdin ? _("standard input") : quote (file)); return ok; } @@ -539,7 +539,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/tty.c b/src/bin/coreutils/src/tty.c index 12a2140cc0..cc15cfe4af 100644 --- a/src/bin/coreutils/src/tty.c +++ b/src/bin/coreutils/src/tty.c @@ -59,7 +59,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]...\n"), program_name); @@ -95,18 +95,18 @@ main (int argc, char **argv) while ((optc = getopt_long (argc, argv, "s", longopts, NULL)) != -1) { switch (optc) - { - case 's': - silent = true; - break; + { + case 's': + silent = 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 (TTY_FAILURE); - } + default: + usage (TTY_FAILURE); + } } if (optind < argc) @@ -116,9 +116,9 @@ main (int argc, char **argv) if (!silent) { if (tty) - puts (tty); + puts (tty); else - puts (_("not a tty")); + puts (_("not a tty")); } exit (isatty (STDIN_FILENO) ? EXIT_SUCCESS : EXIT_FAILURE); diff --git a/src/bin/coreutils/src/uname.c b/src/bin/coreutils/src/uname.c index 12dc7d53dd..63b3374e39 100644 --- a/src/bin/coreutils/src/uname.c +++ b/src/bin/coreutils/src/uname.c @@ -116,7 +116,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]...\n"), program_name); @@ -139,14 +139,14 @@ Print certain system information. With no OPTION, same as -s.\n\ -i, --hardware-platform print the hardware platform or \"unknown\"\n\ -o, --operating-system print the operating system\n\ "), stdout); - } + } else { - fputs (_("\ + fputs (_("\ Print machine architecture.\n\ \n\ "), stdout); - } + } fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -181,71 +181,71 @@ decode_switches (int argc, char **argv) if (uname_mode == UNAME_ARCH) { while ((c = getopt_long (argc, argv, "", - arch_long_options, NULL)) != -1) - { - switch (c) - { - case_GETOPT_HELP_CHAR; + arch_long_options, NULL)) != -1) + { + switch (c) + { + case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, ARCH_AUTHORS); + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, ARCH_AUTHORS); - default: - usage (EXIT_FAILURE); - } + default: + usage (EXIT_FAILURE); + } } toprint = PRINT_MACHINE; } else { while ((c = getopt_long (argc, argv, "asnrvmpio", - uname_long_options, NULL)) != -1) + uname_long_options, NULL)) != -1) { - switch (c) - { - case 'a': - toprint = UINT_MAX; - break; + switch (c) + { + case 'a': + toprint = UINT_MAX; + break; - case 's': - toprint |= PRINT_KERNEL_NAME; - break; + case 's': + toprint |= PRINT_KERNEL_NAME; + break; - case 'n': - toprint |= PRINT_NODENAME; - break; + case 'n': + toprint |= PRINT_NODENAME; + break; - case 'r': - toprint |= PRINT_KERNEL_RELEASE; - break; + case 'r': + toprint |= PRINT_KERNEL_RELEASE; + break; - case 'v': - toprint |= PRINT_KERNEL_VERSION; - break; + case 'v': + toprint |= PRINT_KERNEL_VERSION; + break; - case 'm': - toprint |= PRINT_MACHINE; - break; + case 'm': + toprint |= PRINT_MACHINE; + break; - case 'p': - toprint |= PRINT_PROCESSOR; - break; + case 'p': + toprint |= PRINT_PROCESSOR; + break; - case 'i': - toprint |= PRINT_HARDWARE_PLATFORM; - break; + case 'i': + toprint |= PRINT_HARDWARE_PLATFORM; + break; - case 'o': - toprint |= PRINT_OPERATING_SYSTEM; - break; + case 'o': + toprint |= PRINT_OPERATING_SYSTEM; + 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); - } - } + default: + usage (EXIT_FAILURE); + } + } } if (argc != optind) @@ -280,23 +280,23 @@ main (int argc, char **argv) if (toprint & (PRINT_KERNEL_NAME | PRINT_NODENAME | PRINT_KERNEL_RELEASE - | PRINT_KERNEL_VERSION | PRINT_MACHINE)) + | PRINT_KERNEL_VERSION | PRINT_MACHINE)) { struct utsname name; if (uname (&name) == -1) - error (EXIT_FAILURE, errno, _("cannot get system name")); + error (EXIT_FAILURE, errno, _("cannot get system name")); if (toprint & PRINT_KERNEL_NAME) - print_element (name.sysname); + print_element (name.sysname); if (toprint & PRINT_NODENAME) - print_element (name.nodename); + print_element (name.nodename); if (toprint & PRINT_KERNEL_RELEASE) - print_element (name.release); + print_element (name.release); if (toprint & PRINT_KERNEL_VERSION) - print_element (name.version); + print_element (name.version); if (toprint & PRINT_MACHINE) - print_element (name.machine); + print_element (name.machine); } if (toprint & PRINT_PROCESSOR) @@ -304,43 +304,43 @@ main (int argc, char **argv) char const *element = unknown; #if HAVE_SYSINFO && defined SI_ARCHITECTURE { - static char processor[257]; - if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) - element = processor; + static char processor[257]; + if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor)) + element = processor; } #endif #ifdef UNAME_PROCESSOR if (element == unknown) - { - static char processor[257]; - size_t s = sizeof processor; - static int mib[] = { CTL_HW, UNAME_PROCESSOR }; - if (sysctl (mib, 2, processor, &s, 0, 0) >= 0) - element = processor; + { + static char processor[257]; + size_t s = sizeof processor; + static int mib[] = { CTL_HW, UNAME_PROCESSOR }; + if (sysctl (mib, 2, processor, &s, 0, 0) >= 0) + element = processor; # ifdef __APPLE__ - /* This kludge works around a bug in Mac OS X. */ - if (element == unknown) - { - cpu_type_t cputype; - size_t s = sizeof cputype; - NXArchInfo const *ai; - if (sysctlbyname ("hw.cputype", &cputype, &s, NULL, 0) == 0 - && (ai = NXGetArchInfoFromCpuType (cputype, - CPU_SUBTYPE_MULTIPLE)) - != NULL) - element = ai->name; + /* This kludge works around a bug in Mac OS X. */ + if (element == unknown) + { + cpu_type_t cputype; + size_t s = sizeof cputype; + NXArchInfo const *ai; + if (sysctlbyname ("hw.cputype", &cputype, &s, NULL, 0) == 0 + && (ai = NXGetArchInfoFromCpuType (cputype, + CPU_SUBTYPE_MULTIPLE)) + != NULL) + element = ai->name; - /* Hack "safely" around the ppc vs. powerpc return value. */ - if (cputype == CPU_TYPE_POWERPC - && strncmp (element, "ppc", 3) == 0) - element = "powerpc"; - } + /* Hack "safely" around the ppc vs. powerpc return value. */ + if (cputype == CPU_TYPE_POWERPC + && strncmp (element, "ppc", 3) == 0) + element = "powerpc"; + } # endif - } + } #endif if (! (toprint == UINT_MAX && element == unknown)) - print_element (element); + print_element (element); } if (toprint & PRINT_HARDWARE_PLATFORM) @@ -348,24 +348,24 @@ main (int argc, char **argv) char const *element = unknown; #if HAVE_SYSINFO && defined SI_PLATFORM { - static char hardware_platform[257]; - if (0 <= sysinfo (SI_PLATFORM, - hardware_platform, sizeof hardware_platform)) - element = hardware_platform; + static char hardware_platform[257]; + if (0 <= sysinfo (SI_PLATFORM, + hardware_platform, sizeof hardware_platform)) + element = hardware_platform; } #endif #ifdef UNAME_HARDWARE_PLATFORM if (element == unknown) - { - static char hardware_platform[257]; - size_t s = sizeof hardware_platform; - static int mib[] = { CTL_HW, UNAME_HARDWARE_PLATFORM }; - if (sysctl (mib, 2, hardware_platform, &s, 0, 0) >= 0) - element = hardware_platform; - } + { + static char hardware_platform[257]; + size_t s = sizeof hardware_platform; + static int mib[] = { CTL_HW, UNAME_HARDWARE_PLATFORM }; + if (sysctl (mib, 2, hardware_platform, &s, 0, 0) >= 0) + element = hardware_platform; + } #endif if (! (toprint == UINT_MAX && element == unknown)) - print_element (element); + print_element (element); } if (toprint & PRINT_OPERATING_SYSTEM) diff --git a/src/bin/coreutils/src/unexpand.c b/src/bin/coreutils/src/unexpand.c index 9f6a6d7a21..bfe22964ea 100644 --- a/src/bin/coreutils/src/unexpand.c +++ b/src/bin/coreutils/src/unexpand.c @@ -24,12 +24,12 @@ --tabs=tab1[,tab2[,...]] -t tab1[,tab2[,...]] -tab1[,tab2[,...]] If only one tab stop is given, set the tabs tab1 - columns apart instead of the default 8. Otherwise, - set the tabs at columns tab1, tab2, etc. (numbered from - 0); preserve any blanks beyond the tab stops given. + columns apart instead of the default 8. Otherwise, + set the tabs at columns tab1, tab2, etc. (numbered from + 0); preserve any blanks beyond the tab stops given. --all -a Use tabs wherever they would replace 2 or more blanks, - not just at the beginnings of lines. + not just at the beginnings of lines. David MacKenzie */ @@ -107,13 +107,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ "), - program_name); + program_name); fputs (_("\ Convert blanks in each FILE to tabs, writing to standard output.\n\ With no FILE, or when FILE is -, read standard input.\n\ @@ -150,7 +150,7 @@ add_tab_stop (uintmax_t tabval) if (max_column_width < column_width) { if (SIZE_MAX < column_width) - error (EXIT_FAILURE, 0, _("tabs are too far apart")); + error (EXIT_FAILURE, 0, _("tabs are too far apart")); max_column_width = column_width; } } @@ -169,38 +169,38 @@ parse_tab_stops (char const *stops) for (; *stops; stops++) { if (*stops == ',' || isblank (to_uchar (*stops))) - { - if (have_tabval) - add_tab_stop (tabval); - have_tabval = false; - } + { + if (have_tabval) + add_tab_stop (tabval); + have_tabval = false; + } else if (ISDIGIT (*stops)) - { - if (!have_tabval) - { - tabval = 0; - have_tabval = true; - num_start = stops; - } + { + if (!have_tabval) + { + tabval = 0; + have_tabval = true; + num_start = stops; + } - /* Detect overflow. */ - if (!DECIMAL_DIGIT_ACCUMULATE (tabval, *stops - '0', uintmax_t)) - { - size_t len = strspn (num_start, "0123456789"); - char *bad_num = xstrndup (num_start, len); - error (0, 0, _("tab stop is too large %s"), quote (bad_num)); - free (bad_num); - ok = false; - stops = num_start + len - 1; - } - } + /* Detect overflow. */ + if (!DECIMAL_DIGIT_ACCUMULATE (tabval, *stops - '0', uintmax_t)) + { + size_t len = strspn (num_start, "0123456789"); + char *bad_num = xstrndup (num_start, len); + error (0, 0, _("tab stop is too large %s"), quote (bad_num)); + free (bad_num); + ok = false; + stops = num_start + len - 1; + } + } else - { - error (0, 0, _("tab size contains invalid character(s): %s"), - quote (stops)); - ok = false; - break; - } + { + error (0, 0, _("tab size contains invalid character(s): %s"), + quote (stops)); + ok = false; + break; + } } if (!ok) @@ -222,9 +222,9 @@ validate_tab_stops (uintmax_t const *tabs, size_t entries) for (i = 0; i < entries; i++) { if (tabs[i] == 0) - error (EXIT_FAILURE, 0, _("tab size cannot be 0")); + error (EXIT_FAILURE, 0, _("tab size cannot be 0")); if (tabs[i] <= prev_tab) - error (EXIT_FAILURE, 0, _("tab sizes must be ascending")); + error (EXIT_FAILURE, 0, _("tab sizes must be ascending")); prev_tab = tabs[i]; } } @@ -243,33 +243,33 @@ next_file (FILE *fp) if (fp) { if (ferror (fp)) - { - error (0, errno, "%s", prev_file); - exit_status = EXIT_FAILURE; - } + { + error (0, errno, "%s", prev_file); + exit_status = EXIT_FAILURE; + } if (STREQ (prev_file, "-")) - clearerr (fp); /* Also clear EOF. */ + clearerr (fp); /* Also clear EOF. */ else if (fclose (fp) != 0) - { - error (0, errno, "%s", prev_file); - exit_status = EXIT_FAILURE; - } + { + error (0, errno, "%s", prev_file); + exit_status = EXIT_FAILURE; + } } while ((file = *file_list++) != NULL) { if (STREQ (file, "-")) - { - have_read_stdin = true; - prev_file = file; - return stdin; - } + { + have_read_stdin = true; + prev_file = file; + return stdin; + } fp = fopen (file, "r"); if (fp) - { - prev_file = file; - return fp; - } + { + prev_file = file; + return fp; + } error (0, errno, "%s", file); exit_status = EXIT_FAILURE; } @@ -308,7 +308,7 @@ unexpand (void) /* The following variables have valid values only when CONVERT - is true: */ + is true: */ /* Column of next input character. */ uintmax_t column = 0; @@ -323,8 +323,8 @@ unexpand (void) bool one_blank_before_tab_stop = false; /* If true, the previous input character was a blank. This is - initially true, since initial strings of blanks are treated - as if the line was preceded by a blank. */ + initially true, since initial strings of blanks are treated + as if the line was preceded by a blank. */ bool prev_blank = true; /* Number of pending columns of blanks. */ @@ -334,113 +334,113 @@ unexpand (void) /* Convert a line of text. */ do - { - while ((c = getc (fp)) < 0 && (fp = next_file (fp))) - continue; + { + while ((c = getc (fp)) < 0 && (fp = next_file (fp))) + continue; - if (convert) - { - bool blank = !! isblank (c); + if (convert) + { + bool blank = !! isblank (c); - if (blank) - { - if (next_tab_column <= column) - { - if (tab_size) - next_tab_column = - column + (tab_size - column % tab_size); - else - for (;;) - if (tab_index == first_free_tab) - { - convert = false; - break; - } - else - { - uintmax_t tab = tab_list[tab_index++]; - if (column < tab) - { - next_tab_column = tab; - break; - } - } - } + if (blank) + { + if (next_tab_column <= column) + { + if (tab_size) + next_tab_column = + column + (tab_size - column % tab_size); + else + for (;;) + if (tab_index == first_free_tab) + { + convert = false; + break; + } + else + { + uintmax_t tab = tab_list[tab_index++]; + if (column < tab) + { + next_tab_column = tab; + break; + } + } + } - if (convert) - { - if (next_tab_column < column) - error (EXIT_FAILURE, 0, _("input line is too long")); + if (convert) + { + if (next_tab_column < column) + error (EXIT_FAILURE, 0, _("input line is too long")); - if (c == '\t') - { - column = next_tab_column; + if (c == '\t') + { + column = next_tab_column; - /* Discard pending blanks, unless it was a single - blank just before the previous tab stop. */ - if (! (pending == 1 && one_blank_before_tab_stop)) - { - pending = 0; - one_blank_before_tab_stop = false; - } - } - else - { - column++; + /* Discard pending blanks, unless it was a single + blank just before the previous tab stop. */ + if (! (pending == 1 && one_blank_before_tab_stop)) + { + pending = 0; + one_blank_before_tab_stop = false; + } + } + else + { + column++; - if (! (prev_blank && column == next_tab_column)) - { - /* It is not yet known whether the pending blanks - will be replaced by tabs. */ - if (column == next_tab_column) - one_blank_before_tab_stop = true; - pending_blank[pending++] = c; - prev_blank = true; - continue; - } + if (! (prev_blank && column == next_tab_column)) + { + /* It is not yet known whether the pending blanks + will be replaced by tabs. */ + if (column == next_tab_column) + one_blank_before_tab_stop = true; + pending_blank[pending++] = c; + prev_blank = true; + continue; + } - /* Replace the pending blanks by a tab or two. */ - pending_blank[0] = c = '\t'; - pending = one_blank_before_tab_stop; - } - } - } - else if (c == '\b') - { - /* Go back one column, and force recalculation of the - next tab stop. */ - column -= !!column; - next_tab_column = column; - tab_index -= !!tab_index; - } - else - { - column++; - if (!column) - error (EXIT_FAILURE, 0, _("input line is too long")); - } + /* Replace the pending blanks by a tab or two. */ + pending_blank[0] = c = '\t'; + pending = one_blank_before_tab_stop; + } + } + } + else if (c == '\b') + { + /* Go back one column, and force recalculation of the + next tab stop. */ + column -= !!column; + next_tab_column = column; + tab_index -= !!tab_index; + } + else + { + column++; + if (!column) + error (EXIT_FAILURE, 0, _("input line is too long")); + } - if (pending) - { - if (fwrite (pending_blank, 1, pending, stdout) != pending) - error (EXIT_FAILURE, errno, _("write error")); - pending = 0; - one_blank_before_tab_stop = false; - } + if (pending) + { + if (fwrite (pending_blank, 1, pending, stdout) != pending) + error (EXIT_FAILURE, errno, _("write error")); + pending = 0; + one_blank_before_tab_stop = false; + } - prev_blank = blank; - convert &= convert_entire_line | blank; - } + prev_blank = blank; + convert &= convert_entire_line | blank; + } - if (c < 0) - { - free (pending_blank); - return; - } + if (c < 0) + { + free (pending_blank); + return; + } - if (putchar (c) < 0) - error (EXIT_FAILURE, errno, _("write error")); - } + if (putchar (c) < 0) + error (EXIT_FAILURE, errno, _("write error")); + } while (c != '\n'); } } @@ -471,39 +471,39 @@ main (int argc, char **argv) first_free_tab = 0; while ((c = getopt_long (argc, argv, ",0123456789at:", longopts, NULL)) - != -1) + != -1) { switch (c) - { - case '?': - usage (EXIT_FAILURE); - case 'a': - convert_entire_line = true; - break; - case 't': - convert_entire_line = true; - parse_tab_stops (optarg); - break; - case CONVERT_FIRST_ONLY_OPTION: - convert_first_only = true; - break; - case ',': - if (have_tabval) - add_tab_stop (tabval); - have_tabval = false; - break; - case_GETOPT_HELP_CHAR; - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - default: - if (!have_tabval) - { - tabval = 0; - have_tabval = true; - } - if (!DECIMAL_DIGIT_ACCUMULATE (tabval, c - '0', uintmax_t)) - error (EXIT_FAILURE, 0, _("tab stop value is too large")); - break; - } + { + case '?': + usage (EXIT_FAILURE); + case 'a': + convert_entire_line = true; + break; + case 't': + convert_entire_line = true; + parse_tab_stops (optarg); + break; + case CONVERT_FIRST_ONLY_OPTION: + convert_first_only = true; + break; + case ',': + if (have_tabval) + add_tab_stop (tabval); + have_tabval = false; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + if (!have_tabval) + { + tabval = 0; + have_tabval = true; + } + if (!DECIMAL_DIGIT_ACCUMULATE (tabval, c - '0', uintmax_t)) + error (EXIT_FAILURE, 0, _("tab stop value is too large")); + break; + } } if (convert_first_only) diff --git a/src/bin/coreutils/src/uniq.c b/src/bin/coreutils/src/uniq.c index 0a16b670ee..13aaebccc3 100644 --- a/src/bin/coreutils/src/uniq.c +++ b/src/bin/coreutils/src/uniq.c @@ -127,13 +127,13 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [INPUT [OUTPUT]]\n\ "), - program_name); + program_name); fputs (_("\ Filter adjacent matching lines from INPUT (or standard input),\n\ writing to OUTPUT (or standard output).\n\ @@ -215,9 +215,9 @@ find_field (struct linebuffer const *line) for (count = 0; count < skip_fields; count++) { while (i < size && isblank (to_uchar (lp[i]))) - i++; + i++; while (i < size && !isblank (to_uchar (lp[i]))) - i++; + i++; } for (count = 0; count < skip_chars && i < size; count++) @@ -258,11 +258,11 @@ different (char *old, char *new, size_t oldlen, size_t newlen) static void writeline (struct linebuffer const *line, - bool match, uintmax_t linecount) + bool match, uintmax_t linecount) { if (! (linecount == 0 ? output_unique - : !match ? output_first_repeated - : output_later_repeated)) + : !match ? output_first_repeated + : output_later_repeated)) return; if (countmode == count_occurrences) @@ -304,24 +304,24 @@ check_file (const char *infile, const char *outfile, char delimiter) size_t prevlen IF_LINT (= 0); while (!feof (stdin)) - { - char *thisfield; - size_t thislen; - if (readlinebuffer_delim (thisline, stdin, delimiter) == 0) - break; - thisfield = find_field (thisline); - thislen = thisline->length - 1 - (thisfield - thisline->buffer); - if (prevline->length == 0 - || different (thisfield, prevfield, thislen, prevlen)) - { - fwrite (thisline->buffer, sizeof (char), - thisline->length, stdout); + { + char *thisfield; + size_t thislen; + if (readlinebuffer_delim (thisline, stdin, delimiter) == 0) + break; + thisfield = find_field (thisline); + thislen = thisline->length - 1 - (thisfield - thisline->buffer); + if (prevline->length == 0 + || different (thisfield, prevfield, thislen, prevlen)) + { + fwrite (thisline->buffer, sizeof (char), + thisline->length, stdout); - SWAP_LINES (prevline, thisline); - prevfield = thisfield; - prevlen = thislen; - } - } + SWAP_LINES (prevline, thisline); + prevfield = thisfield; + prevlen = thislen; + } + } } else { @@ -331,59 +331,59 @@ check_file (const char *infile, const char *outfile, char delimiter) bool first_delimiter = true; if (readlinebuffer_delim (prevline, stdin, delimiter) == 0) - goto closefiles; + goto closefiles; prevfield = find_field (prevline); prevlen = prevline->length - 1 - (prevfield - prevline->buffer); while (!feof (stdin)) - { - bool match; - char *thisfield; - size_t thislen; - if (readlinebuffer_delim (thisline, stdin, delimiter) == 0) - { - if (ferror (stdin)) - goto closefiles; - break; - } - thisfield = find_field (thisline); - thislen = thisline->length - 1 - (thisfield - thisline->buffer); - match = !different (thisfield, prevfield, thislen, prevlen); - match_count += match; + { + bool match; + char *thisfield; + size_t thislen; + if (readlinebuffer_delim (thisline, stdin, delimiter) == 0) + { + if (ferror (stdin)) + goto closefiles; + break; + } + thisfield = find_field (thisline); + thislen = thisline->length - 1 - (thisfield - thisline->buffer); + match = !different (thisfield, prevfield, thislen, prevlen); + match_count += match; - if (match_count == UINTMAX_MAX) - { - if (count_occurrences) - error (EXIT_FAILURE, 0, _("too many repeated lines")); - match_count--; - } + if (match_count == UINTMAX_MAX) + { + if (count_occurrences) + error (EXIT_FAILURE, 0, _("too many repeated lines")); + match_count--; + } if (delimit_groups != DM_NONE) - { - if (!match) - { - if (match_count) /* a previous match */ - first_delimiter = false; /* Only used when DM_SEPARATE */ - } - else if (match_count == 1) - { - if ((delimit_groups == DM_PREPEND) - || (delimit_groups == DM_SEPARATE - && !first_delimiter)) - putchar (delimiter); - } - } + { + if (!match) + { + if (match_count) /* a previous match */ + first_delimiter = false; /* Only used when DM_SEPARATE */ + } + else if (match_count == 1) + { + if ((delimit_groups == DM_PREPEND) + || (delimit_groups == DM_SEPARATE + && !first_delimiter)) + putchar (delimiter); + } + } - if (!match || output_later_repeated) - { - writeline (prevline, match, match_count); - SWAP_LINES (prevline, thisline); - prevfield = thisfield; - prevlen = thislen; - if (!match) - match_count = 0; - } - } + if (!match || output_later_repeated) + { + writeline (prevline, match, match_count); + SWAP_LINES (prevline, thisline); + prevfield = thisfield; + prevlen = thislen; + if (!match) + match_count = 0; + } + } writeline (prevline, false, match_count); } @@ -440,121 +440,121 @@ main (int argc, char **argv) obsolete. */ if (optc == -1 - || (posixly_correct && nfiles != 0) - || ((optc = getopt_long (argc, argv, - "-0123456789Dcdf:is:uw:z", longopts, NULL)) - == -1)) - { - if (argc <= optind) - break; - if (nfiles == 2) - { - error (0, 0, _("extra operand %s"), quote (argv[optind])); - usage (EXIT_FAILURE); - } - file[nfiles++] = argv[optind++]; - } + || (posixly_correct && nfiles != 0) + || ((optc = getopt_long (argc, argv, + "-0123456789Dcdf:is:uw:z", longopts, NULL)) + == -1)) + { + if (argc <= optind) + break; + if (nfiles == 2) + { + error (0, 0, _("extra operand %s"), quote (argv[optind])); + usage (EXIT_FAILURE); + } + file[nfiles++] = argv[optind++]; + } else switch (optc) - { - case 1: - { - unsigned long int size; - if (optarg[0] == '+' - && posix2_version () < 200112 - && xstrtoul (optarg, NULL, 10, &size, "") == LONGINT_OK - && size <= SIZE_MAX) - skip_chars = size; - else if (nfiles == 2) - { - error (0, 0, _("extra operand %s"), quote (optarg)); - usage (EXIT_FAILURE); - } - else - file[nfiles++] = optarg; - } - break; + { + case 1: + { + unsigned long int size; + if (optarg[0] == '+' + && posix2_version () < 200112 + && xstrtoul (optarg, NULL, 10, &size, "") == LONGINT_OK + && size <= SIZE_MAX) + skip_chars = size; + else if (nfiles == 2) + { + error (0, 0, _("extra operand %s"), quote (optarg)); + usage (EXIT_FAILURE); + } + else + file[nfiles++] = optarg; + } + break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - if (skip_field_option_type == SFO_NEW) - skip_fields = 0; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + if (skip_field_option_type == SFO_NEW) + skip_fields = 0; - if (!DECIMAL_DIGIT_ACCUMULATE (skip_fields, optc - '0', size_t)) - skip_fields = SIZE_MAX; + if (!DECIMAL_DIGIT_ACCUMULATE (skip_fields, optc - '0', size_t)) + skip_fields = SIZE_MAX; - skip_field_option_type = SFO_OBSOLETE; - } - break; + skip_field_option_type = SFO_OBSOLETE; + } + break; - case 'c': - countmode = count_occurrences; - break; + case 'c': + countmode = count_occurrences; + break; - case 'd': - output_unique = false; - break; + case 'd': + output_unique = false; + break; - case 'D': - output_unique = false; - output_later_repeated = true; - if (optarg == NULL) - delimit_groups = DM_NONE; - else - delimit_groups = XARGMATCH ("--all-repeated", optarg, - delimit_method_string, - delimit_method_map); - break; + case 'D': + output_unique = false; + output_later_repeated = true; + if (optarg == NULL) + delimit_groups = DM_NONE; + else + delimit_groups = XARGMATCH ("--all-repeated", optarg, + delimit_method_string, + delimit_method_map); + break; - case 'f': - skip_field_option_type = SFO_NEW; - skip_fields = size_opt (optarg, - N_("invalid number of fields to skip")); - break; + case 'f': + skip_field_option_type = SFO_NEW; + skip_fields = size_opt (optarg, + N_("invalid number of fields to skip")); + break; - case 'i': - ignore_case = true; - break; + case 'i': + ignore_case = true; + break; - case 's': - skip_chars = size_opt (optarg, - N_("invalid number of bytes to skip")); - break; + case 's': + skip_chars = size_opt (optarg, + N_("invalid number of bytes to skip")); + break; - case 'u': - output_first_repeated = false; - break; + case 'u': + output_first_repeated = false; + break; - case 'w': - check_chars = size_opt (optarg, - N_("invalid number of bytes to compare")); - break; + case 'w': + check_chars = size_opt (optarg, + N_("invalid number of bytes to compare")); + break; - case 'z': - delimiter = '\0'; - break; + case 'z': + delimiter = '\0'; + 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); - } + default: + usage (EXIT_FAILURE); + } } if (countmode == count_occurrences && output_later_repeated) { error (0, 0, - _("printing all duplicated lines and repeat counts is meaningless")); + _("printing all duplicated lines and repeat counts is meaningless")); usage (EXIT_FAILURE); } diff --git a/src/bin/coreutils/src/unlink.c b/src/bin/coreutils/src/unlink.c index c82733f506..47cbfb2e31 100644 --- a/src/bin/coreutils/src/unlink.c +++ b/src/bin/coreutils/src/unlink.c @@ -40,14 +40,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s FILE\n\ or: %s OPTION\n"), program_name, program_name); fputs (_("Call the unlink function to remove the specified FILE.\n\n"), - stdout); + stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_bug_reporting_address (); @@ -67,7 +67,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/uptime.c b/src/bin/coreutils/src/uptime.c index 78cd52b2a5..175fe8f73b 100644 --- a/src/bin/coreutils/src/uptime.c +++ b/src/bin/coreutils/src/uptime.c @@ -68,13 +68,13 @@ print_uptime (size_t n, const STRUCT_UTMP *this) char buf[BUFSIZ]; char *b = fgets (buf, BUFSIZ, fp); if (b == buf) - { - char *end_ptr; - double upsecs = c_strtod (buf, &end_ptr); - if (buf != end_ptr) - uptime = (0 <= upsecs && upsecs < TYPE_MAXIMUM (time_t) - ? upsecs : -1); - } + { + char *end_ptr; + double upsecs = c_strtod (buf, &end_ptr); + if (buf != end_ptr) + uptime = (0 <= upsecs && upsecs < TYPE_MAXIMUM (time_t) + ? upsecs : -1); + } fclose (fp); } @@ -108,7 +108,7 @@ print_uptime (size_t n, const STRUCT_UTMP *this) { entries += IS_USER_PROCESS (this); if (UT_TYPE_BOOT_TIME (this)) - boot_time = UT_TIME_MEMBER (this); + boot_time = UT_TIME_MEMBER (this); ++this; } #endif @@ -118,7 +118,7 @@ print_uptime (size_t n, const STRUCT_UTMP *this) #endif { if (boot_time == 0) - error (EXIT_FAILURE, errno, _("couldn't get boot time")); + error (EXIT_FAILURE, errno, _("couldn't get boot time")); uptime = time_now - boot_time; } updays = uptime / 86400; @@ -137,15 +137,15 @@ print_uptime (size_t n, const STRUCT_UTMP *this) else { if (0 < updays) - printf (ngettext ("up %ld day %2d:%02d, ", - "up %ld days %2d:%02d, ", - select_plural (updays)), - updays, uphours, upmins); + printf (ngettext ("up %ld day %2d:%02d, ", + "up %ld days %2d:%02d, ", + select_plural (updays)), + updays, uphours, upmins); else - printf ("up %2d:%02d, ", uphours, upmins); + printf ("up %2d:%02d, ", uphours, upmins); } printf (ngettext ("%lu user", "%lu users", entries), - (unsigned long int) entries); + (unsigned long int) entries); #if defined HAVE_GETLOADAVG || defined C_GETLOADAVG loads = getloadavg (avg, 3); @@ -158,13 +158,13 @@ print_uptime (size_t n, const STRUCT_UTMP *this) else { if (loads > 0) - printf (_(", load average: %.2f"), avg[0]); + printf (_(", load average: %.2f"), avg[0]); if (loads > 1) - printf (", %.2f", avg[1]); + printf (", %.2f", avg[1]); if (loads > 2) - printf (", %.2f", avg[2]); + printf (", %.2f", avg[2]); if (loads > 0) - putchar ('\n'); + putchar ('\n'); } } @@ -191,7 +191,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... [FILE]\n"), program_name); @@ -201,9 +201,9 @@ the number of users on the system, and the average number of jobs\n\ in the run queue over the last 1, 5 and 15 minutes.")); #ifdef __linux__ /* It would be better to introduce a configure test for this, - but such a test is hard to write. For the moment then, we - have a hack which depends on the preprocessor used at compile - time to tell us what the running kernel is. Ugh. */ + but such a test is hard to write. For the moment then, we + have a hack which depends on the preprocessor used at compile + time to tell us what the running kernel is. Ugh. */ printf(_(" \ Processes in\n\ an uninterruptible sleep state also contribute to the load average.\n")); @@ -213,7 +213,7 @@ an uninterruptible sleep state also contribute to the load average.\n")); printf (_("\ If FILE is not specified, use %s. %s as FILE is common.\n\ \n"), - UTMP_FILE, WTMP_FILE); + UTMP_FILE, WTMP_FILE); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_bug_reporting_address (); @@ -233,7 +233,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/users.c b/src/bin/coreutils/src/users.c index f471807562..d5115c6911 100644 --- a/src/bin/coreutils/src/users.c +++ b/src/bin/coreutils/src/users.c @@ -53,14 +53,14 @@ list_entries_users (size_t n, const STRUCT_UTMP *this) while (n--) { if (IS_USER_PROCESS (this)) - { - char *trimmed_name; + { + char *trimmed_name; - trimmed_name = extract_trimmed_name (this); + trimmed_name = extract_trimmed_name (this); - u[n_entries] = trimmed_name; - ++n_entries; - } + u[n_entries] = trimmed_name; + ++n_entries; + } this++; } @@ -100,7 +100,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... [FILE]\n"), program_name); @@ -109,7 +109,7 @@ Output who is currently logged in according to FILE.\n\ If FILE is not specified, use %s. %s as FILE is common.\n\ \n\ "), - UTMP_FILE, WTMP_FILE); + UTMP_FILE, WTMP_FILE); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_bug_reporting_address (); @@ -129,7 +129,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/wc.c b/src/bin/coreutils/src/wc.c index 780ff234ca..a75c15b7d8 100644 --- a/src/bin/coreutils/src/wc.c +++ b/src/bin/coreutils/src/wc.c @@ -106,14 +106,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [OPTION]... [FILE]...\n\ or: %s [OPTION]... --files0-from=F\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Print newline, word, and byte counts for each FILE, and a total line if\n\ more than one FILE is specified. With no FILE, or when FILE is -,\n\ @@ -140,11 +140,11 @@ read standard input.\n\ associated with the specified counters. */ static void write_counts (uintmax_t lines, - uintmax_t words, - uintmax_t chars, - uintmax_t bytes, - uintmax_t linelength, - const char *file) + uintmax_t words, + uintmax_t chars, + uintmax_t bytes, + uintmax_t linelength, + const char *file) { static char const format_sp_int[] = " %*s"; char const *format_int = format_sp_int + 1; @@ -225,52 +225,52 @@ wc (int fd, char const *file_x, struct fstatus *fstatus) off_t current_pos, end_pos; if (0 < fstatus->failed) - fstatus->failed = fstat (fd, &fstatus->st); + fstatus->failed = fstat (fd, &fstatus->st); if (! fstatus->failed && S_ISREG (fstatus->st.st_mode) - && (current_pos = lseek (fd, (off_t) 0, SEEK_CUR)) != -1 - && (end_pos = lseek (fd, (off_t) 0, SEEK_END)) != -1) - { - /* Be careful here. The current position may actually be - beyond the end of the file. As in the example above. */ - bytes = end_pos < current_pos ? 0 : end_pos - current_pos; - } + && (current_pos = lseek (fd, (off_t) 0, SEEK_CUR)) != -1 + && (end_pos = lseek (fd, (off_t) 0, SEEK_END)) != -1) + { + /* Be careful here. The current position may actually be + beyond the end of the file. As in the example above. */ + bytes = end_pos < current_pos ? 0 : end_pos - current_pos; + } else - { - while ((bytes_read = safe_read (fd, buf, BUFFER_SIZE)) > 0) - { - if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, "%s", file); - ok = false; - break; - } - bytes += bytes_read; - } - } + { + while ((bytes_read = safe_read (fd, buf, BUFFER_SIZE)) > 0) + { + if (bytes_read == SAFE_READ_ERROR) + { + error (0, errno, "%s", file); + ok = false; + break; + } + bytes += bytes_read; + } + } } else if (!count_chars && !count_complicated) { /* Use a separate loop when counting only lines or lines and bytes -- - but not chars or words. */ + but not chars or words. */ while ((bytes_read = safe_read (fd, buf, BUFFER_SIZE)) > 0) - { - char *p = buf; + { + char *p = buf; - if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, "%s", file); - ok = false; - break; - } + if (bytes_read == SAFE_READ_ERROR) + { + error (0, errno, "%s", file); + ok = false; + break; + } - while ((p = memchr (p, '\n', (buf + bytes_read) - p))) - { - ++p; - ++lines; - } - bytes += bytes_read; - } + while ((p = memchr (p, '\n', (buf + bytes_read) - p))) + { + ++p; + ++lines; + } + bytes += bytes_read; + } } #if MB_LEN_MAX > 1 # define SUPPORT_OLD_MBRTOWC 1 @@ -282,133 +282,133 @@ wc (int fd, char const *file_x, struct fstatus *fstatus) bool in_shift = false; # if SUPPORT_OLD_MBRTOWC /* Back-up the state before each multibyte character conversion and - move the last incomplete character of the buffer to the front - of the buffer. This is needed because we don't know whether - the `mbrtowc' function updates the state when it returns -2, - - this is the ISO C 99 and glibc-2.2 behaviour - or not - amended - ANSI C, glibc-2.1 and Solaris 5.7 behaviour. We don't have an - autoconf test for this, yet. */ + move the last incomplete character of the buffer to the front + of the buffer. This is needed because we don't know whether + the `mbrtowc' function updates the state when it returns -2, - + this is the ISO C 99 and glibc-2.2 behaviour - or not - amended + ANSI C, glibc-2.1 and Solaris 5.7 behaviour. We don't have an + autoconf test for this, yet. */ size_t prev = 0; /* number of bytes carried over from previous round */ # else const size_t prev = 0; # endif while ((bytes_read = safe_read (fd, buf + prev, BUFFER_SIZE - prev)) > 0) - { - const char *p; + { + const char *p; # if SUPPORT_OLD_MBRTOWC - mbstate_t backup_state; + mbstate_t backup_state; # endif - if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, "%s", file); - ok = false; - break; - } + if (bytes_read == SAFE_READ_ERROR) + { + error (0, errno, "%s", file); + ok = false; + break; + } - bytes += bytes_read; - p = buf; - bytes_read += prev; - do - { - wchar_t wide_char; - size_t n; + bytes += bytes_read; + p = buf; + bytes_read += prev; + do + { + wchar_t wide_char; + size_t n; - if (!in_shift && is_basic (*p)) - { - /* Handle most ASCII characters quickly, without calling - mbrtowc(). */ - n = 1; - wide_char = *p; - } - else - { - in_shift = true; + if (!in_shift && is_basic (*p)) + { + /* Handle most ASCII characters quickly, without calling + mbrtowc(). */ + n = 1; + wide_char = *p; + } + else + { + in_shift = true; # if SUPPORT_OLD_MBRTOWC - backup_state = state; + backup_state = state; # endif - n = mbrtowc (&wide_char, p, bytes_read, &state); - if (n == (size_t) -2) - { + n = mbrtowc (&wide_char, p, bytes_read, &state); + if (n == (size_t) -2) + { # if SUPPORT_OLD_MBRTOWC - state = backup_state; + state = backup_state; # endif - break; - } - if (n == (size_t) -1) - { - /* Remember that we read a byte, but don't complain - about the error. Because of the decoding error, - this is a considered to be byte but not a - character (that is, chars is not incremented). */ - p++; - bytes_read--; - continue; - } - if (mbsinit (&state)) - in_shift = false; - if (n == 0) - { - wide_char = 0; - n = 1; - } - } - p += n; - bytes_read -= n; - chars++; - switch (wide_char) - { - case '\n': - lines++; - /* Fall through. */ - case '\r': - case '\f': - if (linepos > linelength) - linelength = linepos; - linepos = 0; - goto mb_word_separator; - case '\t': - linepos += 8 - (linepos % 8); - goto mb_word_separator; - case ' ': - linepos++; - /* Fall through. */ - case '\v': - mb_word_separator: - words += in_word; - in_word = false; - break; - default: - if (iswprint (wide_char)) - { - int width = wcwidth (wide_char); - if (width > 0) - linepos += width; - if (iswspace (wide_char)) - goto mb_word_separator; - in_word = true; - } - break; - } - } - while (bytes_read > 0); + break; + } + if (n == (size_t) -1) + { + /* Remember that we read a byte, but don't complain + about the error. Because of the decoding error, + this is a considered to be byte but not a + character (that is, chars is not incremented). */ + p++; + bytes_read--; + continue; + } + if (mbsinit (&state)) + in_shift = false; + if (n == 0) + { + wide_char = 0; + n = 1; + } + } + p += n; + bytes_read -= n; + chars++; + switch (wide_char) + { + case '\n': + lines++; + /* Fall through. */ + case '\r': + case '\f': + if (linepos > linelength) + linelength = linepos; + linepos = 0; + goto mb_word_separator; + case '\t': + linepos += 8 - (linepos % 8); + goto mb_word_separator; + case ' ': + linepos++; + /* Fall through. */ + case '\v': + mb_word_separator: + words += in_word; + in_word = false; + break; + default: + if (iswprint (wide_char)) + { + int width = wcwidth (wide_char); + if (width > 0) + linepos += width; + if (iswspace (wide_char)) + goto mb_word_separator; + in_word = true; + } + break; + } + } + while (bytes_read > 0); # if SUPPORT_OLD_MBRTOWC - if (bytes_read > 0) - { - if (bytes_read == BUFFER_SIZE) - { - /* Encountered a very long redundant shift sequence. */ - p++; - bytes_read--; - } - memmove (buf, p, bytes_read); - } - prev = bytes_read; + if (bytes_read > 0) + { + if (bytes_read == BUFFER_SIZE) + { + /* Encountered a very long redundant shift sequence. */ + p++; + bytes_read--; + } + memmove (buf, p, bytes_read); + } + prev = bytes_read; # endif - } + } if (linepos > linelength) - linelength = linepos; + linelength = linepos; words += in_word; } #endif @@ -418,55 +418,55 @@ wc (int fd, char const *file_x, struct fstatus *fstatus) uintmax_t linepos = 0; while ((bytes_read = safe_read (fd, buf, BUFFER_SIZE)) > 0) - { - const char *p = buf; - if (bytes_read == SAFE_READ_ERROR) - { - error (0, errno, "%s", file); - ok = false; - break; - } + { + const char *p = buf; + if (bytes_read == SAFE_READ_ERROR) + { + error (0, errno, "%s", file); + ok = false; + break; + } - bytes += bytes_read; - do - { - switch (*p++) - { - case '\n': - lines++; - /* Fall through. */ - case '\r': - case '\f': - if (linepos > linelength) - linelength = linepos; - linepos = 0; - goto word_separator; - case '\t': - linepos += 8 - (linepos % 8); - goto word_separator; - case ' ': - linepos++; - /* Fall through. */ - case '\v': - word_separator: - words += in_word; - in_word = false; - break; - default: - if (isprint (to_uchar (p[-1]))) - { - linepos++; - if (isspace (to_uchar (p[-1]))) - goto word_separator; - in_word = true; - } - break; - } - } - while (--bytes_read); - } + bytes += bytes_read; + do + { + switch (*p++) + { + case '\n': + lines++; + /* Fall through. */ + case '\r': + case '\f': + if (linepos > linelength) + linelength = linepos; + linepos = 0; + goto word_separator; + case '\t': + linepos += 8 - (linepos % 8); + goto word_separator; + case ' ': + linepos++; + /* Fall through. */ + case '\v': + word_separator: + words += in_word; + in_word = false; + break; + default: + if (isprint (to_uchar (p[-1]))) + { + linepos++; + if (isspace (to_uchar (p[-1]))) + goto word_separator; + in_word = true; + } + break; + } + } + while (--bytes_read); + } if (linepos > linelength) - linelength = linepos; + linelength = linepos; words += in_word; } @@ -491,27 +491,27 @@ wc_file (char const *file, struct fstatus *fstatus) { have_read_stdin = true; if (O_BINARY && ! isatty (STDIN_FILENO)) - xfreopen (NULL, "rb", stdin); + xfreopen (NULL, "rb", stdin); return wc (STDIN_FILENO, file, fstatus); } else { int fd = open (file, O_RDONLY | O_BINARY); if (fd == -1) - { - error (0, errno, "%s", file); - return false; - } + { + error (0, errno, "%s", file); + return false; + } else - { - bool ok = wc (fd, file, fstatus); - if (close (fd) != 0) - { - error (0, errno, "%s", file); - return false; - } - return ok; - } + { + bool ok = wc (fd, file, fstatus); + if (close (fd) != 0) + { + error (0, errno, "%s", file); + return false; + } + return ok; + } } } @@ -528,18 +528,18 @@ get_input_fstatus (int nfiles, char *const *file) if (nfiles == 0 || (nfiles == 1 - && ((print_lines + print_words + print_chars - + print_bytes + print_linelength) - == 1))) + && ((print_lines + print_words + print_chars + + print_bytes + print_linelength) + == 1))) fstatus[0].failed = 1; else { int i; for (i = 0; i < nfiles; i++) - fstatus[i].failed = (! file[i] || STREQ (file[i], "-") - ? fstat (STDIN_FILENO, &fstatus[i].st) - : stat (file[i], &fstatus[i].st)); + fstatus[i].failed = (! file[i] || STREQ (file[i], "-") + ? fstat (STDIN_FILENO, &fstatus[i].st) + : stat (file[i], &fstatus[i].st)); } return fstatus; @@ -561,18 +561,18 @@ compute_number_width (int nfiles, struct fstatus const *fstatus) int i; for (i = 0; i < nfiles; i++) - if (! fstatus[i].failed) - { - if (S_ISREG (fstatus[i].st.st_mode)) - regular_total += fstatus[i].st.st_size; - else - minimum_width = 7; - } + if (! fstatus[i].failed) + { + if (S_ISREG (fstatus[i].st.st_mode)) + regular_total += fstatus[i].st.st_size; + else + minimum_width = 7; + } for (; 10 <= regular_total; regular_total /= 10) - width++; + width++; if (width < minimum_width) - width = minimum_width; + width = minimum_width; } return width; @@ -609,39 +609,39 @@ main (int argc, char **argv) switch (optc) { case 'c': - print_bytes = true; - break; + print_bytes = true; + break; case 'm': - print_chars = true; - break; + print_chars = true; + break; case 'l': - print_lines = true; - break; + print_lines = true; + break; case 'w': - print_words = true; - break; + print_words = true; + break; case 'L': - print_linelength = true; - break; + print_linelength = true; + break; case FILES0_FROM_OPTION: - files_from = optarg; - break; + files_from = optarg; + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: - usage (EXIT_FAILURE); + usage (EXIT_FAILURE); } if (! (print_lines | print_words | print_chars | print_bytes - | print_linelength)) + | print_linelength)) print_lines = print_words = print_bytes = true; if (files_from) @@ -650,46 +650,46 @@ main (int argc, char **argv) struct stat st; /* When using --files0-from=F, you may not specify any files - on the command-line. */ + on the command-line. */ if (optind < argc) - { - error (0, 0, _("extra operand %s"), quote (argv[optind])); - fprintf (stderr, "%s\n", - _("file operands cannot be combined with --files0-from")); - usage (EXIT_FAILURE); - } + { + error (0, 0, _("extra operand %s"), quote (argv[optind])); + fprintf (stderr, "%s\n", + _("file operands cannot be combined with --files0-from")); + usage (EXIT_FAILURE); + } if (STREQ (files_from, "-")) - stream = stdin; + stream = stdin; else - { - stream = fopen (files_from, "r"); - if (stream == NULL) - error (EXIT_FAILURE, errno, _("cannot open %s for reading"), - quote (files_from)); - } + { + stream = fopen (files_from, "r"); + if (stream == NULL) + error (EXIT_FAILURE, errno, _("cannot open %s for reading"), + quote (files_from)); + } /* Read the file list into RAM if we can detect its size and that - size is reasonable. Otherwise, we'll read a name at a time. */ + size is reasonable. Otherwise, we'll read a name at a time. */ if (fstat (fileno (stream), &st) == 0 - && S_ISREG (st.st_mode) - && st.st_size <= MIN (10 * 1024 * 1024, physmem_available () / 2)) - { - read_tokens = true; - readtokens0_init (&tok); - if (! readtokens0 (stream, &tok) || fclose (stream) != 0) - error (EXIT_FAILURE, 0, _("cannot read file names from %s"), - quote (files_from)); - files = tok.tok; - nfiles = tok.n_tok; - ai = argv_iter_init_argv (files); - } + && S_ISREG (st.st_mode) + && st.st_size <= MIN (10 * 1024 * 1024, physmem_available () / 2)) + { + read_tokens = true; + readtokens0_init (&tok); + if (! readtokens0 (stream, &tok) || fclose (stream) != 0) + error (EXIT_FAILURE, 0, _("cannot read file names from %s"), + quote (files_from)); + files = tok.tok; + nfiles = tok.n_tok; + ai = argv_iter_init_argv (files); + } else - { - files = NULL; - nfiles = 0; - ai = argv_iter_init_stream (stream); - } + { + files = NULL; + nfiles = 0; + ai = argv_iter_init_stream (stream); + } } else { @@ -709,55 +709,55 @@ main (int argc, char **argv) enum argv_iter_err ai_err; char *file_name = argv_iter (ai, &ai_err); if (ai_err == AI_ERR_EOF) - break; + break; if (!file_name) - { - switch (ai_err) - { - case AI_ERR_READ: - error (0, errno, _("%s: read error"), quote (files_from)); - skip_file = true; - continue; - case AI_ERR_MEM: - xalloc_die (); - default: - assert (!"unexpected error code from argv_iter"); - } - } + { + switch (ai_err) + { + case AI_ERR_READ: + error (0, errno, _("%s: read error"), quote (files_from)); + skip_file = true; + continue; + case AI_ERR_MEM: + xalloc_die (); + default: + assert (!"unexpected error code from argv_iter"); + } + } if (files_from && STREQ (files_from, "-") && STREQ (file_name, "-")) - { - /* Give a better diagnostic in an unusual case: - printf - | wc --files0-from=- */ - error (0, 0, _("when reading file names from stdin, " - "no file name of %s allowed"), - quote (file_name)); - skip_file = true; - } + { + /* Give a better diagnostic in an unusual case: + printf - | wc --files0-from=- */ + error (0, 0, _("when reading file names from stdin, " + "no file name of %s allowed"), + quote (file_name)); + skip_file = true; + } if (!file_name[0]) - { - /* Diagnose a zero-length file name. When it's one - among many, knowing the record number may help. - FIXME: currently print the record number only with - --files0-from=FILE. Maybe do it for argv, too? */ - if (files_from == NULL) - error (0, 0, "%s", _("invalid zero-length file name")); - else - { - /* Using the standard `filename:line-number:' prefix here is - not totally appropriate, since NUL is the separator, not NL, - but it might be better than nothing. */ - unsigned long int file_number = argv_iter_n_args (ai); - error (0, 0, "%s:%lu: %s", quotearg_colon (files_from), - file_number, _("invalid zero-length file name")); - } - skip_file = true; - } + { + /* Diagnose a zero-length file name. When it's one + among many, knowing the record number may help. + FIXME: currently print the record number only with + --files0-from=FILE. Maybe do it for argv, too? */ + if (files_from == NULL) + error (0, 0, "%s", _("invalid zero-length file name")); + else + { + /* Using the standard `filename:line-number:' prefix here is + not totally appropriate, since NUL is the separator, not NL, + but it might be better than nothing. */ + unsigned long int file_number = argv_iter_n_args (ai); + error (0, 0, "%s:%lu: %s", quotearg_colon (files_from), + file_number, _("invalid zero-length file name")); + } + skip_file = true; + } if (skip_file) - ok = false; + ok = false; else - ok &= wc_file (file_name, &fstatus[nfiles ? i : 0]); + ok &= wc_file (file_name, &fstatus[nfiles ? i : 0]); } /* No arguments on the command line is fine. That means read from stdin. @@ -771,7 +771,7 @@ main (int argc, char **argv) if (1 < argv_iter_n_args (ai)) write_counts (total_lines, total_words, total_chars, total_bytes, - max_line_length, _("total")); + max_line_length, _("total")); argv_iter_free (ai); diff --git a/src/bin/coreutils/src/wheel-gen.pl b/src/bin/coreutils/src/wheel-gen.pl index 987619de3c..96fb48f05f 100755 --- a/src/bin/coreutils/src/wheel-gen.pl +++ b/src/bin/coreutils/src/wheel-gen.pl @@ -50,7 +50,7 @@ sub is_prime ($) and return 0; $d += $w; $q < $d - and last; + and last; $w = 2; } return 1; @@ -68,12 +68,12 @@ sub is_prime ($) for (my $i = 3; ; $i += 2) { if (is_prime $i) - { - push @primes, $i; - $product *= $i; - ++$n_primes == $wheel_size - and last; - } + { + push @primes, $i; + $product *= $i; + ++$n_primes == $wheel_size + and last; + } } my $ws_m1 = $wheel_size - 1; @@ -92,20 +92,20 @@ EOF { my $rel_prime = 1; foreach my $divisor (@primes) - { - $i != $divisor && $i % $divisor == 0 - and $rel_prime = 0; - } + { + $i != $divisor && $i % $divisor == 0 + and $rel_prime = 0; + } if ($rel_prime) - { - #warn $i, ' ', $i - $prev, "\n"; - push @increments, $i - $prev; - $prev = $i; + { + #warn $i, ' ', $i - $prev, "\n"; + push @increments, $i - $prev; + $prev = $i; - $product + 1 < $i - and last; - } + $product + 1 < $i + and last; + } } print join (",\n", @increments), "\n"; diff --git a/src/bin/coreutils/src/who.c b/src/bin/coreutils/src/who.c index b49942d0fe..f162fab58a 100644 --- a/src/bin/coreutils/src/who.c +++ b/src/bin/coreutils/src/who.c @@ -195,15 +195,15 @@ idle_string (time_t when, time_t boottime) { int seconds_idle = now - when; if (seconds_idle < 60) - return " . "; + return " . "; else - { - static char idle_hhmm[IDLESTR_LEN]; - sprintf (idle_hhmm, "%02d:%02d", - seconds_idle / (60 * 60), - (seconds_idle % (60 * 60)) / 60); - return idle_hhmm; - } + { + static char idle_hhmm[IDLESTR_LEN]; + sprintf (idle_hhmm, "%02d:%02d", + seconds_idle / (60 * 60), + (seconds_idle % (60 * 60)) / 60); + return idle_hhmm; + } } return _(" old "); @@ -238,9 +238,9 @@ time_string (const STRUCT_UTMP *utmp_ent) pids, etc. */ static void print_line (int userlen, const char *user, const char state, - int linelen, const char *line, - const char *time_str, const char *idle, const char *pid, - const char *comment, const char *exitstr) + int linelen, const char *line, + const char *time_str, const char *idle, const char *pid, + const char *comment, const char *exitstr) { static char mesg[3] = { ' ', 'x', '\0' }; char *buf; @@ -268,29 +268,29 @@ print_line (int userlen, const char *user, const char state, *x_exitstr = '\0'; err = asprintf (&buf, - "%-8.*s" - "%s" - " %-12.*s" - " %-*s" - "%s" - "%s" - " %-8s" - "%s" - , - userlen, user ? user : " .", - include_mesg ? mesg : "", - linelen, line, - time_format_width, - time_str, - x_idle, - x_pid, - /* FIXME: it's not really clear whether the following - field should be in the short_output. A strict reading - of SUSv2 would suggest not, but I haven't seen any - implementations that actually work that way... */ - comment, - x_exitstr - ); + "%-8.*s" + "%s" + " %-12.*s" + " %-*s" + "%s" + "%s" + " %-8s" + "%s" + , + userlen, user ? user : " .", + include_mesg ? mesg : "", + linelen, line, + time_format_width, + time_str, + x_idle, + x_pid, + /* FIXME: it's not really clear whether the following + field should be in the short_output. A strict reading + of SUSv2 would suggest not, but I haven't seen any + implementations that actually work that way... */ + comment, + x_exitstr + ); if (err == -1) xalloc_die (); @@ -339,7 +339,7 @@ print_user (const STRUCT_UTMP *utmp_ent, time_t boottime) { strcpy (line, DEV_DIR_WITH_TRAILING_SLASH); strncpy (line + DEV_DIR_LEN, utmp_ent->ut_line, - sizeof (utmp_ent->ut_line)); + sizeof (utmp_ent->ut_line)); line[DEV_DIR_LEN + sizeof (utmp_ent->ut_line)] = '\0'; } @@ -373,61 +373,61 @@ print_user (const STRUCT_UTMP *utmp_ent, time_t boottime) /* Look for an X display. */ display = strchr (ut_host, ':'); if (display) - *display++ = '\0'; + *display++ = '\0'; if (*ut_host && do_lookup) - { - /* See if we can canonicalize it. */ - host = canon_host (ut_host); - } + { + /* See if we can canonicalize it. */ + host = canon_host (ut_host); + } if (! host) - host = ut_host; + host = ut_host; if (display) - { - if (hostlen < strlen (host) + strlen (display) + 4) - { - hostlen = strlen (host) + strlen (display) + 4; - hoststr = xrealloc (hoststr, hostlen); - } - sprintf (hoststr, "(%s:%s)", host, display); - } + { + if (hostlen < strlen (host) + strlen (display) + 4) + { + hostlen = strlen (host) + strlen (display) + 4; + hoststr = xrealloc (hoststr, hostlen); + } + sprintf (hoststr, "(%s:%s)", host, display); + } else - { - if (hostlen < strlen (host) + 3) - { - hostlen = strlen (host) + 3; - hoststr = xrealloc (hoststr, hostlen); - } - sprintf (hoststr, "(%s)", host); - } + { + if (hostlen < strlen (host) + 3) + { + hostlen = strlen (host) + 3; + hoststr = xrealloc (hoststr, hostlen); + } + sprintf (hoststr, "(%s)", host); + } if (host != ut_host) - free (host); + free (host); } else { if (hostlen < 1) - { - hostlen = 1; - hoststr = xrealloc (hoststr, hostlen); - } + { + hostlen = 1; + hoststr = xrealloc (hoststr, hostlen); + } *hoststr = '\0'; } #endif print_line (sizeof UT_USER (utmp_ent), UT_USER (utmp_ent), mesg, - sizeof utmp_ent->ut_line, utmp_ent->ut_line, - time_string (utmp_ent), idlestr, pidstr, - hoststr ? hoststr : "", ""); + sizeof utmp_ent->ut_line, utmp_ent->ut_line, + time_string (utmp_ent), idlestr, pidstr, + hoststr ? hoststr : "", ""); } static void print_boottime (const STRUCT_UTMP *utmp_ent) { print_line (-1, "", ' ', -1, _("system boot"), - time_string (utmp_ent), "", "", "", ""); + time_string (utmp_ent), "", "", "", ""); } static char * @@ -449,17 +449,17 @@ print_deadprocs (const STRUCT_UTMP *utmp_ent) if (!exitstr) exitstr = xmalloc (strlen (_("term=")) - + INT_STRLEN_BOUND (UT_EXIT_E_TERMINATION (utmp_ent)) + 1 - + strlen (_("exit=")) - + INT_STRLEN_BOUND (UT_EXIT_E_EXIT (utmp_ent)) - + 1); + + INT_STRLEN_BOUND (UT_EXIT_E_TERMINATION (utmp_ent)) + 1 + + strlen (_("exit=")) + + INT_STRLEN_BOUND (UT_EXIT_E_EXIT (utmp_ent)) + + 1); sprintf (exitstr, "%s%d %s%d", _("term="), UT_EXIT_E_TERMINATION (utmp_ent), - _("exit="), UT_EXIT_E_EXIT (utmp_ent)); + _("exit="), UT_EXIT_E_EXIT (utmp_ent)); /* FIXME: add idle time? */ print_line (-1, "", ' ', sizeof utmp_ent->ut_line, utmp_ent->ut_line, - time_string (utmp_ent), "", pidstr, comment, exitstr); + time_string (utmp_ent), "", pidstr, comment, exitstr); free (comment); } @@ -472,7 +472,7 @@ print_login (const STRUCT_UTMP *utmp_ent) /* FIXME: add idle time? */ print_line (-1, _("LOGIN"), ' ', sizeof utmp_ent->ut_line, utmp_ent->ut_line, - time_string (utmp_ent), "", pidstr, comment, ""); + time_string (utmp_ent), "", pidstr, comment, ""); free (comment); } @@ -483,7 +483,7 @@ print_initspawn (const STRUCT_UTMP *utmp_ent) PIDSTR_DECL_AND_INIT (pidstr, utmp_ent); print_line (-1, "", ' ', sizeof utmp_ent->ut_line, utmp_ent->ut_line, - time_string (utmp_ent), "", pidstr, comment, ""); + time_string (utmp_ent), "", pidstr, comment, ""); free (comment); } @@ -492,7 +492,7 @@ print_clockchange (const STRUCT_UTMP *utmp_ent) { /* FIXME: handle NEW_TIME & OLD_TIME both */ print_line (-1, "", ' ', -1, _("clock change"), - time_string (utmp_ent), "", "", "", ""); + time_string (utmp_ent), "", "", "", ""); } static void @@ -511,7 +511,7 @@ print_runlevel (const STRUCT_UTMP *utmp_ent) sprintf (comment, "%s%c", _("last="), (last == 'N') ? 'S' : last); print_line (-1, "", ' ', -1, runlevline, time_string (utmp_ent), - "", "", c_isprint (last) ? comment : "", ""); + "", "", c_isprint (last) ? comment : "", ""); return; } @@ -527,16 +527,16 @@ list_entries_who (size_t n, const STRUCT_UTMP *utmp_buf) while (n--) { if (IS_USER_PROCESS (utmp_buf)) - { - char *trimmed_name; + { + char *trimmed_name; - trimmed_name = extract_trimmed_name (utmp_buf); + trimmed_name = extract_trimmed_name (utmp_buf); - printf ("%s%s", separator, trimmed_name); - free (trimmed_name); - separator = " "; - entries++; - } + printf ("%s%s", separator, trimmed_name); + free (trimmed_name); + separator = " "; + entries++; + } utmp_buf++; } printf (_("\n# users=%lu\n"), entries); @@ -546,7 +546,7 @@ static void print_heading (void) { print_line (-1, _("NAME"), ' ', -1, _("LINE"), _("TIME"), _("IDLE"), - _("PID"), _("COMMENT"), _("EXIT")); + _("PID"), _("COMMENT"), _("EXIT")); } /* Display UTMP_BUF, which should have N entries. */ @@ -563,38 +563,38 @@ scan_entries (size_t n, const STRUCT_UTMP *utmp_buf) { ttyname_b = ttyname (STDIN_FILENO); if (!ttyname_b) - return; + return; if (strncmp (ttyname_b, DEV_DIR_WITH_TRAILING_SLASH, DEV_DIR_LEN) == 0) - ttyname_b += DEV_DIR_LEN; /* Discard /dev/ prefix. */ + ttyname_b += DEV_DIR_LEN; /* Discard /dev/ prefix. */ } while (n--) { if (!my_line_only || - strncmp (ttyname_b, utmp_buf->ut_line, - sizeof (utmp_buf->ut_line)) == 0) - { - if (need_users && IS_USER_PROCESS (utmp_buf)) - print_user (utmp_buf, boottime); - else if (need_runlevel && UT_TYPE_RUN_LVL (utmp_buf)) - print_runlevel (utmp_buf); - else if (need_boottime && UT_TYPE_BOOT_TIME (utmp_buf)) - print_boottime (utmp_buf); - /* I've never seen one of these, so I don't know what it should - look like :^) - FIXME: handle OLD_TIME also, perhaps show the delta? */ - else if (need_clockchange && UT_TYPE_NEW_TIME (utmp_buf)) - print_clockchange (utmp_buf); - else if (need_initspawn && UT_TYPE_INIT_PROCESS (utmp_buf)) - print_initspawn (utmp_buf); - else if (need_login && UT_TYPE_LOGIN_PROCESS (utmp_buf)) - print_login (utmp_buf); - else if (need_deadprocs && UT_TYPE_DEAD_PROCESS (utmp_buf)) - print_deadprocs (utmp_buf); - } + strncmp (ttyname_b, utmp_buf->ut_line, + sizeof (utmp_buf->ut_line)) == 0) + { + if (need_users && IS_USER_PROCESS (utmp_buf)) + print_user (utmp_buf, boottime); + else if (need_runlevel && UT_TYPE_RUN_LVL (utmp_buf)) + print_runlevel (utmp_buf); + else if (need_boottime && UT_TYPE_BOOT_TIME (utmp_buf)) + print_boottime (utmp_buf); + /* I've never seen one of these, so I don't know what it should + look like :^) + FIXME: handle OLD_TIME also, perhaps show the delta? */ + else if (need_clockchange && UT_TYPE_NEW_TIME (utmp_buf)) + print_clockchange (utmp_buf); + else if (need_initspawn && UT_TYPE_INIT_PROCESS (utmp_buf)) + print_initspawn (utmp_buf); + else if (need_login && UT_TYPE_LOGIN_PROCESS (utmp_buf)) + print_login (utmp_buf); + else if (need_deadprocs && UT_TYPE_DEAD_PROCESS (utmp_buf)) + print_deadprocs (utmp_buf); + } if (UT_TYPE_BOOT_TIME (utmp_buf)) - boottime = UT_TIME_MEMBER (utmp_buf); + boottime = UT_TIME_MEMBER (utmp_buf); utmp_buf++; } @@ -624,7 +624,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]... [ FILE | ARG1 ARG2 ]\n"), program_name); @@ -685,96 +685,96 @@ main (int argc, char **argv) atexit (close_stdout); while ((optc = getopt_long (argc, argv, "abdlmpqrstuwHT", longopts, NULL)) - != -1) + != -1) { switch (optc) - { - case 'a': - need_boottime = true; - need_deadprocs = true; - need_login = true; - need_initspawn = true; - need_runlevel = true; - need_clockchange = true; - need_users = true; - include_mesg = true; - include_idle = true; - include_exit = true; - assumptions = false; - break; + { + case 'a': + need_boottime = true; + need_deadprocs = true; + need_login = true; + need_initspawn = true; + need_runlevel = true; + need_clockchange = true; + need_users = true; + include_mesg = true; + include_idle = true; + include_exit = true; + assumptions = false; + break; - case 'b': - need_boottime = true; - assumptions = false; - break; + case 'b': + need_boottime = true; + assumptions = false; + break; - case 'd': - need_deadprocs = true; - include_idle = true; - include_exit = true; - assumptions = false; - break; + case 'd': + need_deadprocs = true; + include_idle = true; + include_exit = true; + assumptions = false; + break; - case 'H': - include_heading = true; - break; + case 'H': + include_heading = true; + break; - case 'l': - need_login = true; - include_idle = true; - assumptions = false; - break; + case 'l': + need_login = true; + include_idle = true; + assumptions = false; + break; - case 'm': - my_line_only = true; - break; + case 'm': + my_line_only = true; + break; - case 'p': - need_initspawn = true; - assumptions = false; - break; + case 'p': + need_initspawn = true; + assumptions = false; + break; - case 'q': - short_list = true; - break; + case 'q': + short_list = true; + break; - case 'r': - need_runlevel = true; - include_idle = true; - assumptions = false; - break; + case 'r': + need_runlevel = true; + include_idle = true; + assumptions = false; + break; - case 's': - short_output = true; - break; + case 's': + short_output = true; + break; - case 't': - need_clockchange = true; - assumptions = false; - break; + case 't': + need_clockchange = true; + assumptions = false; + break; - case 'T': - case 'w': - include_mesg = true; - break; + case 'T': + case 'w': + include_mesg = true; + break; - case 'u': - need_users = true; - include_idle = true; - assumptions = false; - break; + case 'u': + need_users = true; + include_idle = true; + assumptions = false; + break; - case LOOKUP_OPTION: - do_lookup = true; - break; + case LOOKUP_OPTION: + do_lookup = 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); - } + default: + usage (EXIT_FAILURE); + } } if (assumptions) diff --git a/src/bin/coreutils/src/whoami.c b/src/bin/coreutils/src/whoami.c index 4c84d58300..928f69e455 100644 --- a/src/bin/coreutils/src/whoami.c +++ b/src/bin/coreutils/src/whoami.c @@ -40,7 +40,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("Usage: %s [OPTION]...\n"), program_name); @@ -71,7 +71,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "", NULL, NULL) != -1) usage (EXIT_FAILURE); @@ -89,6 +89,6 @@ main (int argc, char **argv) exit (EXIT_SUCCESS); } fprintf (stderr, _("%s: cannot find name for user ID %lu\n"), - program_name, (unsigned long int) uid); + program_name, (unsigned long int) uid); exit (EXIT_FAILURE); } diff --git a/src/bin/coreutils/src/yes.c b/src/bin/coreutils/src/yes.c index 12c4dcab8f..e974de29fb 100644 --- a/src/bin/coreutils/src/yes.c +++ b/src/bin/coreutils/src/yes.c @@ -36,14 +36,14 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_name); else { printf (_("\ Usage: %s [STRING]...\n\ or: %s OPTION\n\ "), - program_name, program_name); + program_name, program_name); fputs (_("\ Repeatedly output a line with all specified STRING(s), or `y'.\n\ @@ -68,7 +68,7 @@ main (int argc, char **argv) atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); + usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "+", NULL, NULL) != -1) usage (EXIT_FAILURE); @@ -82,11 +82,11 @@ main (int argc, char **argv) { int i; for (i = optind; i < argc; i++) - if (fputs (argv[i], stdout) == EOF - || putchar (i == argc - 1 ? '\n' : ' ') == EOF) - { - error (0, errno, _("standard output")); - exit (EXIT_FAILURE); - } + if (fputs (argv[i], stdout) == EOF + || putchar (i == argc - 1 ? '\n' : ' ') == EOF) + { + error (0, errno, _("standard output")); + exit (EXIT_FAILURE); + } } }