summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2010-06-14dd: print a better diagnostic for an invalid block sizeJim Meyering
* src/dd.c (dd_copy): Give a better diagnostic than "dd: memory exhausted" for an over-large bs= block size setting. Same for ibs= and obs=. Reported by Imre Péntek in http://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/591969
2010-06-10ls: avoid just-introduced buffer overrunJim Meyering
* src/ls.c (gobble_file): Revert part of my preceding change, to avoid clobbering stack.
2010-06-08maint: adjust INT_BUFSIZE_BOUND usage for maintainabilityJim Meyering
* src/tail.c (xlseek): Give INT_BUFSIZE_BOUND a variable name, not a type name. * src/ls.c (gobble_file, format_user_or_group_width): Likewise. * src/head.c (elide_tail_bytes_pipe): Likewise. (elide_tail_lines_seekable, main): Likewise. [This change is not complete -- there are doubtless other uses that can be updated in the same way.]
2010-06-08sort: avoid unnecessary use of sprintfJim Meyering
sprintf is relatively heavy-weight. * src/sort.c (key_warnings): Use umaxtostr and stpcpy rather than sprintf. Also, replace each INT_BUFSIZE_BOUND "type_name" argument with the equivalent variable name. More maintainable that way.
2010-06-08dirname: tweak summary wordingEric Blake
* doc/coreutils.texi (dirname invocation): Reword to be more precise. * src/dirname.c (usage): Likewise. * THANKS: Update. Reported by Filipus Klutiero, bug 6175.
2010-06-02touch: remove support for --file=REF_FILE optionJim Meyering
* src/touch.c (main): Remove support for the deprecated, long-named --file option, which is an alternate name for --reference (-r). That option was undocumented with the arrival of --reference, in the 1995-10-29 commit, 8b92864e1d. Since the 2009-02-09 commit, ed85df444a, use of --file has elicited a warning. Not only was this code due for removal, but the long-name-use-detecting code was buggy in that it would use a stale or uninitialized "long_idx", as reported by Robin H. Johnson in http://bugs.gentoo.org/322421. * NEWS (Changes in behavior): Mention it.
2010-05-31maint: make spacing around "=" consistent, even in IF_LINTJim Meyering
E.g., - size_t desired_width IF_LINT (= 0); + size_t desired_width IF_LINT ( = 0); Use this command: g grep -l IF_LINT | grep '\.[ch]$' \ | xargs perl -pi -e 's/(IF_LINT \()= /$1 = /'
2010-05-31maint: replace each "for (;;)" with "while (true)"Jim Meyering
Run this command: git ls-files | grep '\.[ch]$' \ | xargs perl -pi -e 's/for \(;;\)/while (true)/g' ...except for randint.c, which does not include stdbool.h. In that case, use "while (1)". * gl/lib/randint.c (randint_genmax): Use "while (1)" for infloops. * src/cat.c (simple_cat, cat): Use "while (true)" for infloops. * gl/lib/randread.c (readsource, readisaac): Likewise. * src/copy.c (copy_reg): Likewise. * src/csplit.c (record_line_starts, process_regexp): Likewise. * src/cut.c (set_fields): Likewise. * src/dd.c (iread, parse_symbols): Likewise. * src/df.c (find_mount_point, main): Likewise. * src/du.c (main): Likewise. * src/expand.c (expand): Likewise. * src/factor.c (factor_using_division, do_stdin): Likewise. * src/fmt.c (get_space): Likewise. * src/ls.c (decode_switches): Likewise. * src/od.c (main): Likewise. * src/pr.c (main, read_line): Likewise. * src/shred.c (dopass, genpattern): Likewise. * src/sort.c (initbuf, fillbuf, getmonth, keycompare): Likewise. * src/split.c (bytes_split, lines_split): Likewise. * src/tac.c (tac_seekable): Likewise. * src/test.c (and, or): Likewise. * src/tr.c (squeeze_filter, main): Likewise. * src/tsort.c (search_item): Likewise. * src/unexpand.c (unexpand): Likewise. * src/uniq.c (main): Likewise. * src/yes.c (main): Likewise.
2010-05-31maint: correct indentation of case_GETOPT_* macro usesJim Meyering
* src/base64.c (main): Correct indentation of syntactically questionable case_GETOPT_HELP_CHAR and case_GETOPT_VERSION_CHAR macros. * src/who.c (main): Likewise.
2010-05-31stat: use gnulib's alignof moduleJim Meyering
* src/stat.c (alignof): Remove definition. Instead, include "alignof.h", and sort the #include directives. And get its definition from the gnulib module by that name: * bootstrap.conf (gnulib_modules): Add alignof.
2010-05-29truncate: improve handling of non regular filesPádraig Brady
Previously we copied `dd` and suppressed error messages when truncating neither regular files or shared mem objects. This was valid for `dd`, as truncation is ancillary to copying it may also do, but for `truncate` we should display all errors. Also we used the st_size from non regular files which is undefined, so we display an error when the user tries this. * src/truncate (do_truncate): Error when referencing the size of non regular files or non shared memory objects. Display all errors returned by ftruncate(). (main): Error when referencing the size of non regular files or non shared memory objects. Don't suppress error messages for any file types that can't be opened for writing. * tests/misc/truncate-dir-fail: Check that referencing the size of a directory is not supported. * tests/misc/truncate-fifo: Ensure the test doesn't hang by using the `timeout` command. Don't test the return from running ftruncate on the fifo as it's system dependent as to whether this fails or not. NEWS: Mention the change in behavior. Reported by Jim Meyering.
2010-05-28truncate: support sizes relative to an existing filePádraig Brady
* doc/coreutils.texi (truncate invocation): Mention that --reference bases the --size rather than just setting it. * src/truncate.c (usage): Likewise. Also remove the clause describing --size and --reference as being mutually exclusive. (do_truncate): Add an extra parameter to hold the size of a referenced file, and use it if positive. (main): Pass the size of a referenced file to do_truncate(). * tests/misc/truncate-parameters: Adjust for the new combinations. * NEWS: Mention the change Suggested by Richard W.M. Jones
2010-05-25maint: don't emit an extra newline in each of two diagnosticsJim Meyering
* src/shuf.c (main): Remove a stray newline in a diagnostic. * src/od.c (main): Likewise. Detected via these: git grep -A1 'error *(.*,$' | grep -C1 '\\n"[,)]' git grep 'error *(.*;$' | grep '\\n"[,)]'
2010-05-25maint: remove unneeded double quotes on RHS of shell assignmentsJim Meyering
Run this command: git grep -l 'LC_[A-Z]*="' \ | xargs perl -pi -e 's/(LC_[A-Z]*)="(.*?)"/$1=$2/' * src/Makefile.am: Write LC_ALL=$$locale, not LC_ALL="$$locale". * src/date.c (main): Similar, in a comment. * tests/misc/sort-month: Write LC_ALL=$LOC, not LC_ALL="$LOC".
2010-05-24sort: adjust the leading blanks --debug warningPádraig Brady
* src/sort.c (key_warnings): Always warn about significant leading blanks when character offsets are specified, unless they key is possibly a line offset, i.e. of the form -k1.x,1.y. Also suppress this warning if the user could be sorting right aligned indexes.
2010-05-19du: recognize -d N as equivalent to --max-depth=NJon Ringuette
* NEWS (New features): Mention it. * src/du.c (DEBUG_OPT): Remove. Use long-named ---debug instead. Commented out. (MAX_DEPTH_OPTION): Remove. Use 'd' instead. (main): Insert literal "d:"; remove DEBUG_OPT. * doc/coreutils.texi (du invocation): Add -d to indices. * tests/du/max-depth: Exercise -d, too.
2010-05-17maint: fix the fs-magic-compare ruleJim Meyering
* src/Makefile.am (fs-def): Sort definitions. This is required by fs-magic-compare's use of join.
2010-05-17build: avoid a new -Wformat-induced warningJim Meyering
* src/sort.c (mark_key): Add a cast-to-int of a printf field width, to placate -Wformat.
2010-05-16sort: --debug: output data independent warnings and infoPádraig Brady
* src/sort.c (usage): Mention --debug can output warnings to stderr. Also split the translatable string to aid translation. (default_key_compare): A new function refactored from main(), and now also called from the new key_warnings() function. (key_to_opts): A new function refactored from incompatible_options(), and now also called from the new key_warnings() function. (key_numeric): A new function refactored to test if key is numeric. (key_warnings): A new function to output warnings to stderr, about questionable use of various options. Currently it warns about zero length keys and ineffective global options. (incompatible_options): Refactor out key_to_opts() (main): Use key_init() to initialize gkey. Refactor out default_key_compare(). Call key_warnings() in debug mode. * doc/coreutils.texi (sort invocation): Mention that warnings are output by --debug. * tests/misc/sort-debug-warn: A new test for debug warnings. * tests/Makefile.am: Reference the new test. * NEWS: Mention the new feature
2010-05-12sort: add a --debug option to highlight key extentsPádraig Brady
* src/sort (usage): Add description for --debug. (write_bytes): Pass a line structure so it can subsequently be passed to compare to highlight the keys when in debug mode. Also transform TAB and NUL characters written to stdout so that the highlighting in debug mode aligns correctly. (human_numcompare): Pass an "endptr" so we can record the extent of the number matched. (general_numcompare): Likewise. (find_unit_order): Likewise. (getmonth): Likewise. (numcompare): Likewise. Note we reuse find_unit_order() for this, which is a good enough approximation, and means we don't need to change the strnumcmp() interface. (check_mixed_SI_IEC): Return whether iec_present, so that can be used to set the "endptr" in find_unit_order. Also make the key parameter optional, which will be the case from numcompare(). (count_tabs): A new function to determine how much to adjust the mbswidth() values by (TABs don't have a width). (mark_key): A new function to output the key highlighting to stdout. (debug_key): A new function to determine the offset and width of the key highlighting. (key_compare): Pass the show_debug parameter so the key highlighting is only displayed when explicitly called. For each key type, set the length (lena) and whether leading blanks are auto skipped (skipb) which are then used by debug_key() to highlight the portion of the key used in the comparison. (compare): Pass the show_debug parameter so the key highlighting is only displayed when explicitly called. Call debug_key() to highlight the last resort comparison. (check): Output highlighting for disorder line to stdout. (main): Process the --debug option and make it mutually exlusive with the -o option as I don't see it useful there, even potentially harmful if someone left a --debug in by mistake when updating a file. Also restricting debug output to stdout, simplifies the logic for dealing with temporary files. * doc/coreutils.texi (sort invocation): Describe the --debug option, and reference it from the --key description. * tests/misc/sort-debug-keys: A new test for highlighting keys. * tests/Makefile.am: Reference the new test. * NEWS: Mention the new feature.
2010-05-03maint: remove now-redundant definitions provided by signal.hJim Meyering
* src/dd.c (SA_NODEFER, SA_RESETHAND): Remove definitions, now that gnulib guarantees they are defined in <signal.h>. * src/ls.c (SA_RESTART): Likewise.
2010-05-03maint: remove now-redundant definitions provided by sys/wait.hJim Meyering
* src/timeout.c (WIFSIGNALED, WTERMSIG): Remove definitions, now that gnulib guarantees they are defined in <sys/wait.h>. * src/operand2sig.c: Likewise. * src/kill.c: Likewise.
2010-05-01sort: use long doubles only when effectivePaul Eggert
* src/sort.c (general_numcompare): Don't use long double if strtold is not available, as it may introduce needless overhead.
2010-04-29sort: use long doubles for general numeric modePádraig Brady
* src/sort.c (general_numcompare): Use long doubles unconditionally, and strtold when available, to convert numbers with greater range and precision. Performance was seen to be on par with standard doubles. * doc/coreutils.texi (sort invocation): Amend the -g description to mention long double rather than double, and strtold rather than strtod. * src/getlimits.c (main): Output floating point limits for use in tests. * tests/misc/sort-float: A new test to ensure sort is using long doubles when possible, and that locale specific floats are handled. * tests/Makefile.am: Reference the new test. * tests/test-lib.sh (getlimits_): Normalize indenting. * NEWS: Mention the new behaviour. Reported by Nelson Beebe.
2010-04-24maint: remove now-unnecessary #if HAVE_header_H tests.Jim Meyering
* .x-sc_prohibit_always_true_header_tests: New file. * Makefile.am (syntax_check_exceptions): Add it. * src/cat.c: Remove #if HAVE_SYS_IOCTL_H test. * src/copy.c: Likewise. * src/ls.c: Likewise. * src/stty.c: Likewise. * src/install.c: Remove #if HAVE_SYS_WAIT_H test. * src/kill.c: Likewise. * src/operand2sig.c: Likewise. * src/timeout.c: Likewise. * src/pathchk.c: Remove #if HAVE_WCHAR_H test. * src/stat.c: Remove #if HAVE_NETINET_IN_H test.
2010-04-23tests: fix exit status of signal handlers in shell scriptsDmitry V. Levin
The value of `$?' on entrance to signal handlers in shell scripts cannot be relied upon, so set the exit code explicitly. * cfg.mk (sc_always_defined_macros, sc_system_h_headers): Set the exit code in signal handler explicitly to 128 + SIG<SIGNAL>. * src/Makefile.am (sc_tight_scope): Likewise. * tests/test-lib.sh: Likewise.
2010-04-22base64: always treat input in binary modeEric Blake
Necessary for cygwin. Technically, this patch is not correct, in that it clobbers O_APPEND, but it is no different than any other use of xfreopen to force binary mode, so all such uses should be fixed at once in a later patch. * src/base64.c (main): Open input in binary mode. * THANKS: Update. Reported by Yutaka Amanai.
2010-04-20sort: fix parsing of end field in obsolescent key formatsPádraig Brady
This regression was introduced in commit 224a69b5, 2009-02-24, "sort: Fix two bugs with determining the end of field". The specific regression being that we include 1 field too many when an end field is specified using obsolescent key syntax (+POS -POS). * src/sort.c (struct keyfield): Clarify the description of the eword member, as suggested by Alan Curry. (main): When processing obsolescent format key specifications, normalize eword to a zero based count when no specific end char is given for an end field. This matches what's done when keys are specified with -k. * tests/misc/sort: Add a few more tests for the obsolescent key formats, with test 07i being the particular failure addressed by this change. * THANKS: Add Alan Curry who precisely identified the issue. * NEWS: Mention the fix. Reported by Santiago Rodríguez
2010-04-16cp: preserve "capabilities" when also preserving file ownershipPádraig Brady
* src/copy.c (copy_reg): Copy xattrs _after_ setting file ownership so that capabilities are not cleared when setting ownership. * tests/cp/capability: A new root test. * tests/Makefile.am (root_tests): Reference the new test. * NEWS: Mention the fix.
2010-04-16maint: fix build on platforms that replace strsignalPádraig Brady
* src/Makefile.am (kill_LDADD): Add $(LIBTHREAD) so that we link with the appropriate libraries to provide Thread Local Storage on platforms that replace strsignal (like AIX for example). Tested-by: Daniel Richard G. <danielg@teragram.com>
2010-04-13cp: treat selinux warnings consistentlyPádraig Brady
* src/copy.c (copy_reg): Suppress SELinux ENOTSUP warnings consistently between the destination being present or not. Previously we did not suppress ENOTSUP messages when the destination was present. (copy_internal): Use the same ENOTSUP supression method as copy_reg() even though the issue was not seen in this case. * tests/cp/cp-a-selinux: Add a test case for the issue and group the other test cases in the file more coherently. * tests/cp/cp-mv-enotsup-xattr: Do the same check for xattr warnings, even though they did not have the issue.
2010-04-12doc: clarify when cp and mv output xattr warningsPádraig Brady
The 2010-03-26 commit, 4c38625e, "doc: fix info on cp --preserve..." was not entirely correct as cp --preserve=all does produce some xattr warnings. * src/copy.h: Update and clarify the comments for reduce_diagnostics and require_preserve_{xattr,context}. * doc/coreutils.texi (cp invocation): Update the -a and --preserve=xattr,context options to say when and which xattr warnings are output. (mv invocation): Mention that some warnings are output when preserving xattrs.
2010-04-09dircolors: add rxvt-256color and rxvt-unicode256Mike Frysinger
* src/dircolors.hin: Add them.
2010-04-09maint: ftruncate is always available, even without gnulibJim Meyering
Now that even MinGW provides ftruncate, we know that all reasonable portability targets provide this function. Remove the workaround code. We nearly removed the gnulib module three years ago: http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/9203 and it is now officially "obsolete". * bootstrap.conf (gnulib_modules): Remove ftruncate. * src/copy.c (copy_reg): Remove use of HAVE_FTRUNCATE and its no-longer-used workaround code. * src/truncate.c: Remove a comment about handling missing ftruncate.
2010-04-08doc: make wc --help say how it defines a 'word'James Youngman
* src/wc.c (usage): Add wc's definition of "word".
2010-04-04tail: include sys/vfs.h (if possible) when sys/statfs.h is absentMarc Kleine-Budde
* src/tail.c [HAVE_INOTIFY && !HAVE_SYS_STATFS_H]: Include <sys/vfs.h>.
2010-03-29build: update after change in gnulib's lib-ignore moduleBruno Haible
* src/Makefile.am (AM_LDFLAGS): Define. Use gnulib's new $(IGNORE_UNUSED_LIBRARIES_CFLAGS).
2010-03-26nice,chroot: use more standard option parsingPádraig Brady
Related to the 2010-03-25 commit, 88d4b346, "timeout: use more standard option parsing". * src/nice.c (main): Don't use parse_long_options() which is a helper for commands that don't have any long options specific to them. * src/chroot.c (main): Likewise. * tests/misc/nice-fail: Remove a case that now passes due to us accepting multiple instances of the --help and --version options. * tests/misc/chroot-fail: Likewise.
2010-03-26timeout: use more standard option parsingKim Hansen
* src/timeout.c (main): Don't use parse_long_options() which is a helper for commands that don't have any long options specific to them. * tests/misc/timeout-parameters: Remove a case that now passes due to us accepting multiple instances of the --help and --version options. * THANKS: Add the author. Signed-off-by: Pádraig Brady <P@draigBrady.com>
2010-03-20maint: code formatting nitJim Meyering
* src/system.h (ST_NBLOCKS): Add space before paren.
2010-03-18rm: tweak wording about loss of data warningEric Blake
* src/rm.c (usage): Update wording to make two points more apparent: undelete is not trivial, and partial recovery should be a consideration factor in deciding whether rm is secure enough. Initially suggested by Reuben Thomas.
2010-03-18revert "maint: mark makefile "dist-hook" target as PHONY"Ralf Wildenhues
* src/Makefile.am (dist-hook): Do not mark this target as PHONY, explicitly. Automake does it for us.
2010-03-18doc: improve ls --help's description of --escape (-b)Eric Blake
* src/ls.c (usage): Be more precise about how --escape (-b) works: say "C-style escapes", not "octal escapes". Reported by Jacky Fong.
2010-03-18maint: mark makefile "dist-hook" target as PHONYJim Meyering
* src/Makefile.am (dist-hook): Mark target as PHONY.
2010-03-17maint: add a space before open-paren, where lackingJim Meyering
* src/copy.c (copy_reg): Likewise. * src/cut.c (main): Likewise. * src/dd.c (main): Likewise. * src/getlimits.c (print_int): Likewise. * src/join.c (join): Likewise. * src/pwd.c (logical_getcwd): Likewise. * src/sort.c (specify_nmerge, mergefps, avoid_trashing_input): Likewise. (merge): Likewise. * src/uptime.c (usage): Likewise.
2010-03-16timeout: add the --kill-after optionPádraig Brady
Based on a report from Kim Hansen who wanted to send a KILL signal to the monitored command when `timeout` itself received a termination signal. Rather than changing such a signal into a KILL, we provide the more general mechanism of sending the KILL after the specified grace period. * src/timeout.c (cleanup): If a non zero kill delay is specified, (re)set the alarm to that delay, after which a KILL signal will be sent to the process group. (usage): Mention the new option. Separate the description of DURATION since it's now specified in 2 places. Clarify that the duration is an integer. (parse_duration): A new function refactored from main(), since this logic is now called for two parameters. (main): Parse the -k option. * doc/coreutils.texi (timeout invocation): Describe the new --kill-after option and use @display rather than @table to show the duration suffixes. Clarify that a duration of 0 disables the associated timeout. * tests/misc/timeout-parameters: Check invalid --kill-after. * tests/misc/timeout: Check a valid --kill-after works. * NEWS: Mention the new feature.
2010-03-10remove: without -f, avoid unnecessary-expense/issues with euidaccessJim Meyering
* src/remove.c (write_protected_non_symlink): If faccessat fails, return 1 or -1 directly, rather than falling back on euidaccess*.
2010-03-04maint: rename the si_present variable in sort to iec_presentPádraig Brady
* src/sort.c: The units containing 'i' are actually IEC not SI.
2010-03-04sort: inform the system about our input access patternJoey Degges
Tell the system that we'll access input sequentially, so that we more efficiently process uncached files in a few cases: Reading from faster flash devices. E.g. 21 MB/s key: NORMAL 31.6s (26.8 user) SEQUENTIAL 27.7s WILLNEED 27.7s Processing in parallel with readahead when using a small 1M buffer: NORMAL 24.7s (21.1 user) SEQUENTIAL 22.7s WILLNEED 25.6s A small benefit when merging: NORMAL 25.0s (16.9 user) SEQUENTIAL 24.6s (16.6 user) WILLNEED 38.4s (13.1 user) Note WILLNEED is presented above for comparison to show it has some unwanted characteristics due to its synchronous prepopulation of the cache. It has a good benefit on a mechanical disk @ 80MB/s and a multicore system with competing processes: NORMAL 14.73s SEQUENTIAL 10.95s WILLNEED 05.22s However the scheduling differences causing this result are probably best explicitly managed using `nice` etc. * m4/jm-macros.m4 (coreutils_MACROS): check for posix_fadvise(). * src/sort.c (fadvise_input): A new function to apply the POSIX_FADV_SEQUENTIAL hint to an input stream. (stream_open): Call the above function for all input streams.
2010-03-01sort: fix issues with month sorting in some localesPádraig Brady
* src/sort.c (char fold_toupper[]): Change to unsigned so as the correct comparisons are made in getmonth(). This fixes unibyte locales where abbreviated months have characters that are > 0x7F, but it also works for multibyte locales with the caveat that multibyte characters are matched case sensitively. With this change, the following example sorts correctly: $ echo -e "1 márta\n2 Feabhra" | LANG=ga_IE.utf8 sort -k2,2M 2 Feabhra 1 márta * src/sort.c (inittables): Since we ignore blanks around months in the input, don't include them when they're present in the locale. With this change, the following example sorts correctly: $ echo -e "1 2月\n2 1月" | LANG=ja_JP.utf8 sort -k2,2M 2 1月 1 2月 * tests/misc/sort-month: A new test to exercise the above cases. * tests/Makefile.am: Reference the new test. * NEWS: Mention the fix.