summaryrefslogtreecommitdiff
path: root/src/sort.c
AgeCommit message (Collapse)Author
2017-01-01maint: update all copyright year number rangesPádraig Brady
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2016-10-16maint: we use die; remove now-unnecessary uses of abortJim Meyering
* src/expr.c (integer_overflow): Remove an abort-after-die. * src/paste.c (write_error): Likewise. * src/sort.c (badfieldspec): Likewise. * src/tr.c (string2_extend): Likewise. Also remove a few break statements, each after an abort.
2016-10-16all: use die() rather than error(EXIT_FAILURE)Pádraig Brady
die() has the advantage of being apparent to the compiler that it doesn't return, which will avoid warnings in some cases, and possibly generate better code. * cfg.mk (sc_die_EXIT_FAILURE): A new syntax check rule to catch any new uses of error (CONSTANT, ...);
2016-09-07sort: port to strict C + valgrindPaul Eggert
* bootstrap.conf (gnulib_modules): Add flexmember. * src/sort.c: Include flexmember.h. (struct tempnode): Make the last member flexible. (create_temp_file): Port to strict C11/C99 rules for allocation alignment with flexible array members.
2016-07-18sort: with -h, disallow thousands separator between number and unitKamil Dudka
* src/sort.c (traverse_raw_number): Accept thousands separator only if it is immediately followed by a digit. * tests/misc/sort-h-thousands-sep.sh: Cover the fix for this bug. Suggested by Pádraig Brady in http://bugs.gnu.org/24015
2016-07-18sort: make -h work with -k and blank used as thousands separatorKamil Dudka
* src/sort.c (traverse_raw_number): Allow to skip only one occurrence of thousands_sep to avoid finding the unit in the next column in case thousands_sep matches as blank and is used as column delimiter. * tests/misc/sort-h-thousands-sep.sh: Add regression test for this bug. * tests/local.mk: Reference the test. * NEWS: Mention the bug fix. Reported at https://bugzilla.redhat.com/1355780 Fixes http://bugs.gnu.org/24015
2016-07-18maint: sort.c: deduplicate code for traversing numbersKamil Dudka
* src/sort.c (traverse_raw_number): New function for traversing numbers. (find_unit_order): Use traverse_raw_number() instead of open-coding it. (debug_key): Likewise.
2016-05-31sort: modify 'leading spaces' debug warning scenariosAssaf Gordon
Print warning regardless of locale, avoid warning if key is zero width. Problem reported by Karl Berry in http://bugs.gnu.org/23665 . * src/sort.c: (key_warnings): change conditions for 'leading spaces' warning. * tests/misc/sort-debug-warn.sh: adjust tests accordingly.
2016-02-23all: be less strict about usage if POSIX 2008Paul Eggert
sort, tail, and uniq now support traditional usage like 'sort +2' and 'tail +10' on systems conforming to POSIX 1003.1-2008 and later. * NEWS: Document this. * doc/coreutils.texi (Standards conformance, tail invocation) (sort invocation, uniq invocation, touch invocation): Document new behavior, or behavior's dependence on POSIX 1003.1-2001. * src/sort.c (struct keyfield.traditional_used): Rename from obsolete_used, since implementations are now allowed to support it. All uses changed. (main): Allow traditional usage if _POSIX2_VERSION is 200809. * src/tail.c (parse_obsolete_option): Distinguish between traditional usage (which POSIX 2008 and later allows) and obsolete (which it still does not). * src/uniq.c (strict_posix2): New function. (main): Allow traditional usage if _POSIX2_VERSION is 200809. * tests/misc/tail.pl: Test for new behavior.
2016-01-14sort: with --debug, flag setlocale() failures on OpenBSDPádraig Brady
Locale categories are not equivalent on OpenBSD, and LC_COLLATE only supports "C" for example. Now LC_ALL is supported to set multiple other categories on OpenBSD, so setlocale(LC_ALL, "") returns a string indicating which categories were updated and which ignored. Therefore... * src/sort.c (main): ...Call setlocale(LC_COLLATE, "") to explicitly check whether a specified LC_ALL or LC_COLLATE environment variable value is supported for the LC_COLLATE category. Also use !! to explicitly convert to bool to support c89 systems where bool is an int, and thus would get values > 1. Reported by Assaf Gordon.
2016-01-13join,sort,uniq: with -z, treat '\n' as a field separatorPádraig Brady
* NEWS: Mention the change in behavior. * doc/coreutils.texi (newlineFieldSeparator): A new description, referenced from ({join,sort,uniq} invocation). * src/system.h (field_sep): A new inline function to determine if a character is a field separator. * src/join.c (usage): s/whitespace/blank/ to be more accurate wrt which characters are field separators. (xfields): s/isblank/field_sep/. * src/sort.c (inittables): Likewise. * src/uniq.c (find_field): Likewise. * tests/misc/join.pl: Adjust -z test, and add a test/example for processing the whole record with field processing. * tests/misc/sort.pl: Add -z test cases, including case with '\n'. * tests/misc/uniq.pl: Add -z -f test case with \n.
2016-01-01maint: update all copyright year number rangesPádraig Brady
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2015-12-14sort: fix --debug marking for -b -k1.xPádraig Brady
We were erroneously skipping blanks in the marked comparison _after_ the key start offset was applied. * src/sort.c (debug_keys): Don't skip starting blanks if already handled by begfield(). * tests/misc/sort-debug-keys.sh: Add a test case. * NEWS: Mention the bug fix. Fixes http://bugs.gnu.org/22155
2015-12-14maint: fix incorrect spellings etcPádraig Brady
* NEWS: Use a standard version specification. * doc/coreutils.texi: Fix incorrect grammar. * src/df.c: Update a stale comment. * src/copy.c: Fix incorrect spellings. * src/factor.c: Likewise. * src/ls.c: Likewise. * src/pr.c: Likewise. * src/relpath.c: Likewise. * src/shred.c: Likewise. * src/sort.c: Likewise. * src/split.c: Likewise. * src/stdbuf.c: Likewise. * tests/misc/seq-precision.sh: Likewise.
2015-12-07sort: promote '--debug'Eric Blake
* src/sort.c (usage): Mention --debug in KEYDEF paragraph.
2015-12-04doc: improve the description of sort --random-sortPádraig Brady
* src/sort.c (usage): Avoid mentioning the implementation, rather focusing on the result of the operation.
2015-11-04all: avoid quoting file names when possiblePádraig Brady
Quote file names using the "shell-escape" or "shell-escape-always" methods, which quote as appropriate for most shells, and better support copy and paste of presented names. The "always" variant is used when the file name is embedded in an error message with surrounding spaces. * cfg.mk (sc_error_shell_quotes): A new syntax check rule to suggest quotef() where appropriate. (sc_error_shell_always_quotes): Likewise for quoteaf(). * src/system.h (quotef): A new define to apply shell quoting when needed. I.E. when shell character or ':' is present. (quoteaf): Likewise, but always quote. * src/*.c: Use quotef() and quoteaf() rather than quote() where appropriate. * tests/: Adjust accordingly.
2015-11-04all: replace most uses of quotearg_colon() with quote()Pádraig Brady
Related to commit v8.24-61-g6796698 this provides more consistent quoting, as quotearg_colon() defaults to "literal" quoting by default, while quote() provides appropriate quoting for diagnostics by default. * gl/modules/randread: Depend on quote module rather than quotearg. * gl/lib/randread.c: Used quote() not quotearg_colon(). * src/: Likewise. * src/shred.c: Likewise. Also avoid unnecessary quoting introducing overhead when wiping names. * cfg.mk: Relax the matching expression to allow "qname" variables as used in shred.c to satisfy the check. * tests/: Adjust accordingly.
2015-10-27all: quote string arguments in error messagesPádraig Brady
These strings are often file names or other user specified parameters, which can give confusing errors in the presence of unexpected characters for example. * cfg.mk (sc_error_quotes): A new syntax check rule. * src/*.c: Wrap error() string arguments with quote(). * tests/: Adjust accordingly. * NEWS: Mention the improvement.
2015-10-19doc: reference shuf(1) from the sort (-R) man pagePádraig Brady
* man/sort.x: Cross reference with shuf(1). * src/sort.c (usage): Mention shuf(1) with -R option. Suggested in http://bugs.debian.org/641166
2015-09-22sort,numfmt: with --debug, diagnose failure to set localePádraig Brady
* src/sort.c (main): With --debug, warn upon setlocale() failure, which can happen due to incorrectly specified environment variables, or due to memory exhaustion (simulated with ulimit -v), etc. * tests/misc/sort-debug-warn.sh: Add a test case. See also http://savannah.gnu.org/bugs/11004
2015-09-08maint: fix heap manipulations in previous commitPádraig Brady
* src/sort.c (main): Ensure we don't free() and invalid pointer when reading implicit stdin. Also avoid "definitely lost" valgrind warnings in the --files0-from case.
2015-09-04maint: avoid "definitely lost" valgrind warningsPádraig Brady
Since commit v8.23-19-g8defcee, main() will return, rather than call exit(), this inducing "definitely lost" warnings in valgrind's leak checker. That precludes using the following to flag memory leaks: valgrind --leak-check=full --error-exitcode=1 \ --errors-for-leak-kinds=definite * src/pr.c (main): In dev builds, explicitly free memory allocated. * src/sort.c (main): Likewise. * src/tail.c (main): Likewise. * src/tsort.c (tsort): Likewise.
2015-04-30doc: standardize messages about the '-' stdin FILEPádraig Brady
* src/system.h (emit_stdin_note): A new function, refactoring the usage note about the '-' FILE implying stdin. * src/base64.c (usage): Use the new function to emit the note in a standard location and with standard separation. * src/cat.c (usage): Likewise. * src/csplit.c (usage): Likewise. * src/cut.c (usage): Likewise. * src/expand.c (usage): Likewise. * src/fmt.c (usage): Likewise. * src/head.c (usage): Likewise. * src/md5sum.c (usage): Likewise. * src/nl.c (usage): Likewise. * src/od.c (usage): Likewise. * src/paste.c (usage): Likewise. * src/pr.c (usage): Likewise. * src/ptx.c (usage): Likewise. * src/shred.c (usage): Likewise. * src/shuf.c (usage): Likewise. * src/sort.c (usage): Likewise. * src/sum.c (usage): Likewise. * src/tac.c (usage): Likewise. * src/tail.c (usage): Likewise. * src/tsort.c (usage): Likewise. * src/unexpand.c (usage): Likewise. * src/wc.c (usage): Likewise. * src/join.c (usage): Adjust the separation used for the message referring to FILE1 or FILE2 as stdin. * src/comm.c (usage): Add a message using the same wording (translation) as used in join. * src/split.c (usage): Reword to using FILE rather than INPUT, allowing use of emit_stdin_note(). Also remove the mention of "fixed-size" pieces as this isn't now always the case. Fixes http://pad.lv/1450179
2015-01-01maint: update all copyright year number rangesPádraig Brady
Run "make update-copyright" and then... * tests/sample-test: Adjust to use the single most recent year. * tests/du/bind-mount-dir-cycle-v2.sh: Fix case in copyright message, so that year is updated automatically in future.
2014-09-19doc: output correct --help references with --program-prefixPádraig Brady
* src/system.h (emit_ancillary_info): Take the invariant PROGRAM_NAME as a parameter, so that consistent references are made to online docs and texinfo nodes, when a --program-prefix is in place. Note the man pages don't need this fix as they're generated before the program prefix is used. * NEWS: Mention the improvements in references to online documentation.
2014-09-08maint: prefer 'return status;' to 'exit (status);' in 'main'Paul Eggert
* build-aux/gen-single-binary.sh: Don't use ATTRIBUTE_NORETURN for main functions. * src/base64.c, src/basename.c, src/cat.c, src/chcon.c, src/chgrp.c: * src/chmod.c, src/chown.c, src/chroot.c, src/cksum.c, src/comm.c: * src/cp.c, src/csplit.c, src/cut.c, src/date.c, src/dd.c, src/df.c: * src/dircolors.c, src/dirname.c, src/du.c, src/echo.c, src/env.c: * src/expand.c, src/expr.c, src/factor.c, src/fmt.c, src/fold.c: * src/getlimits.c, src/groups.c, src/head.c, src/hostid.c: * src/hostname.c, src/id.c, src/install.c, src/join.c, src/kill.c: * src/link.c, src/ln.c, src/logname.c, src/ls.c, src/make-prime-list.c: * src/md5sum.c, src/mkdir.c, src/mkfifo.c, src/mknod.c, src/mktemp.c: * src/mv.c, src/nice.c, src/nl.c, src/nohup.c, src/nproc.c: * src/numfmt.c, src/od.c, src/paste.c, src/pathchk.c, src/pinky.c: * src/pr.c, src/printenv.c, src/printf.c, src/ptx.c, src/pwd.c: * src/readlink.c, src/realpath.c, src/rm.c, src/rmdir.c, src/runcon.c: * src/seq.c, src/shred.c, src/shuf.c, src/sleep.c, src/sort.c: * src/split.c, src/stat.c, src/stdbuf.c, src/stty.c, src/sum.c: * src/sync.c, src/tac.c, src/tail.c, src/tee.c, src/timeout.c: * src/touch.c, src/tr.c, src/true.c, src/truncate.c, src/tsort.c: * src/tty.c, src/uname.c, src/unexpand.c, src/uniq.c, src/unlink.c: * src/uptime.c, src/users.c, src/wc.c, src/who.c, src/whoami.c: In 'main' functions, Prefer 'return status;' to 'exit (status);'. * src/coreutils-arch.c (_single_binary_main_uname) (_single_binary_main_arch): * src/coreutils-dir.c, src/coreutils-vdir.c (_single_binary_main_ls) (_single_binary_main_dir, _single_binary_main_vdir): Omit ATTRIBUTE_NORETURN. Return a value. * src/coreutils.c (SINGLE_BINARY_PROGRAM): Omit ATTRIBUTE_NORETURN. (launch_program): Now static. * src/dd.c (finish_up): New function. (quit, main): Use it. * src/getlimits.c (main): Return a proper exit status. * src/test.c (test_main_return): New macro. (main): Use it. * src/logname.c, src/nohup.c, src/whoami.c: Use 'error' to simplify exit status in 'main' function. * src/yes.c (main): Use 'return' rather than 'error' to exit, so that GCC doesn't suggest ATTRIBUTE_NORETURN.
2014-07-13sort: avoid undefined operation with destroying locked mutexPádraig Brady
This didn't seem to cause any invalid operation on GNU/Linux at least, but depending on the implementation, mutex deadlocks could occur. For example this might be the cause of lockups seen on Solaris: http://lists.gnu.org/archive/html/coreutils/2013-03/msg00048.html This was identified with valgrind 3.9.0 with this setup: seq 200000 > file.sort valgrind --tool=drd src/sort file.sort -o file.sort With that, valgrind would _intermittently_ report the following: Destroying locked mutex: mutex 0x5419548, recursion count 1, owner 2. at 0x4C2E3F0: pthread_mutex_destroy(in vgpreload_drd-amd64-linux.so) by 0x409FA2: sortlines (sort.c:3649) by 0x409E26: sortlines (sort.c:3621) by 0x40AA9E: sort (sort.c:3955) by 0x40C5D9: main (sort.c:4739) mutex 0x5419548 was first observed at: at 0x4C2DE82: pthread_mutex_init(in vgpreload_drd-amd64-linux.so) by 0x409266: init_node (sort.c:3276) by 0x4092F4: init_node (sort.c:3286) by 0x4090DD: merge_tree_init (sort.c:3234) by 0x40AA5A: sort (sort.c:3951) by 0x40C5D9: main (sort.c:4739) Thread 2: The object at address 0x5419548 is not a mutex. at 0x4C2F4A4: pthread_mutex_unlock(in vgpreload_drd-amd64-linux.so) by 0x4093CA: unlock_node (sort.c:3323) by 0x409C85: merge_loop (sort.c:3531) by 0x409F8F: sortlines (sort.c:3644) by 0x409CE3: sortlines_thread (sort.c:3574) by 0x4E44F32: start_thread (in /usr/lib64/libpthread-2.18.so) by 0x514EEAC: clone (in /usr/lib64/libc-2.18.so) * src/sort.c (sortlines): Move pthread_mutex_destroy() out to merge_tree_destroy(), so that we don't overlap mutex destruction with threads still operating on the nodes. (sort): Call the destructors only with "lint" defined, as the memory used will be deallocated implicitly at process end. * NEWS: Mention the bug fix.
2014-07-13sort: fix two threading issues reported by valgrindShayan Pooya
Neither issue impacts on the correct operation of sort. The issues were detected by both valgrind 3.8.1 and 3.9.0 using: seq 200000 > file.sort valgrind --tool=drd src/sort file.sort -o file.sort For tool usage and error details see: http://valgrind.org/docs/manual/drd-manual.html * src/sort.c (queue_insert): Unlock mutex _after_ signalling the associated condition variable. Valgrind flags this with: "Probably a race condition: condition variable 0xffeffffb0 has been signaled but the associated mutex 0xffeffff88 is not locked by the signalling thread." The explanation at the above URL is: "Sending a signal to a condition variable while no lock is held on the mutex associated with the condition variable. This is a common programming error which can cause subtle race conditions and unpredictable behavior." This should at least give more defined scheduling behavior. (merge_tree_destroy): Make symmetrical with merge_tree_init() thus destroying the correct mutex. Valgrind flags this with: "The object at address 0x5476cf8 is not a mutex."
2014-05-26doc: clarify --zero-terminated optionPádraig Brady
* src/join.c (usage): Reword to avoid implication that the NUL byte is only generated as the output delimeter. * src/sort.c (usage): Likewise. * src/shuf.c (usage): Likewise. Also since we're changing the translation string take the opportunity to separate out the description to a separate string to reduce translation overhead. * src/uniq.c (usage): Likewise. * src/stty.c (usage): s/null/NUL/ for consistency. * src/basename.c (usage): Reword for accuracy/consistency. * src/dirname.c (usage): Likewise. * src/du.c (usage): Likewise. * src/env.c (usage): Likewise. * src/printenv.c (usage): Likewise. * src/readlink.c (usage): Likewise. * src/realpath.c (usage): Likewise. * doc/coreutils.texi: Consolidate/share the descriptions of --null, --zero and --zero-terminated.
2014-01-02maint: update all copyright year number rangesBernhard Voelker
Run "make update-copyright", but then also run this, perl -pi -e 's/2\d\d\d-//' tests/sample-test to make that one script use the single most recent year number.
2013-11-27sort: avoid issues when issuing diagnostics from child processesPádraig Brady
* src/sort.c: (async_safe_die): A new limited version of error(), that outputs fixed strings and unconverted errnos to stderr. This is safe to call in the limited context of a signal handler, or in this particular case, between the fork() and exec() of a multithreaded process. (move_fd_or_die): Use the async_safe_die() rather than error(). (maybe_create_temp): Likewise. (open_temp): Likewise. Fixes http://bugs.gnu.org/15970
2013-09-01maint: update out of date confusing commentsPádraig Brady
* src/copy.c (copy_internal): Change mention of the removed --reply=no option, to the similar in this context --no-clobber. * src/sort.c: SI and IEC suffixes can now be mixed when --human-numeric.
2013-05-18maint: port --enable-gcc-warnings to clangPaul Eggert
* configure.ac: If clang, add -Wno-format-extra-args and -Wno-tautological-constant-out-of-range-compare. * gl/lib/rand-isaac.c (ind): * gl/lib/randread.c (readisaac): * src/ls.c (dev_ino_push, dev_ino_pop): * src/sort.c (buffer_linelim): * src/system.h (is_nul): * src/tail.c (tail_forever_inotify): Rewrite to avoid casts that clang dislikes. It's good to avoid casts anyway. * src/expr.c (integer_overflow): Declare only if it exists. (die): Remove; unused. * src/ls.c (dev_ino_push): New function, replacing ... (DEV_INO_PUSH): ... this removed macro. All uses changed. (decode_switches): Rewrite "str"+i to &str[i].
2013-01-23maint: define usage note about mandatory args centrallyBernhard Voelker
Each program with at least one long option which is marked as 'required_argument' and which has also a short option for that option, should print a note about mandatory arguments. Define that well-known note centrally and use it rather than literal printf/fputs, and add it where it was missing. * src/system.h (emit_mandatory_arg_note): Add new function. * src/cp.c (usage): Use it rather than literal printf/fputs. * src/csplit.c, src/cut.c, src/date.c, src/df.c, src/du.c: * src/expand.c, src/fmt.c, src/fold.c, src/head.c, src/install.c: * src/kill.c, src/ln.c, src/ls.c, src/mkdir.c, src/mkfifo.c: * src/mknod.c, src/mv.c, src/nl.c, src/od.c, src/paste.c: * src/pr.c, src/ptx.c, src/shred.c, src/shuf.c, src/sort.c: * src/split.c, src/stdbuf.c, src/tac.c, src/tail.c, src/timeout.c: * src/touch.c, src/truncate.c, src/unexpand.c, src/uniq.c: Likewise. * src/base64.c (usage): Add call of the above new function because at least one long option has a required argument. * src/basename.c, src/chcon.c, src/date.c, src/env.c: * src/nice.c, src/runcon.c, src/seq.c, src/stat.c, src/stty.c: Likewise.
2013-01-01maint: update all copyright year number rangesJim Meyering
Run "make update-copyright", but then also run this, perl -pi -e 's/2\d\d\d-//' tests/sample-test to make that one script use the single most recent year number.
2012-08-18sort: simpler fix for sort -u data-loss bug, and for a FMR bugPaul Eggert
This also fixes a free-memory-read (FMR) bug: when fillbuf's realloc of buf->buf frees the buffer into which saved_line.text points, the processing of that just-read longer line includes comparison against the saved line in freed memory. * src/sort.c (overlap): Remove. (fillbuf): Do not try to copy saved lines, as that is too risky in the presence of parallelism, reallocated buffers, etc. (sort): Invalidate any saved line before sorting a new batch.
2012-08-17sort: sort --unique (-u) could cause data lossJim Meyering
sort -u could omit one or more lines of expected output. This bug arose because sort recorded the most recently printed line via reference, and if you were unlucky, the storage for that line would be reused (overwritten) as additional input was read into memory. If you were doubly unlucky, the new value of the "saved" line would not only match the very next line, but if that next line were also the first in a series of identical, not-yet-printed lines, then the corrupted "saved" line value would result in the omission of all matching lines. * src/sort.c (saved_line): New static/global, renamed and moved from... (write_unique): ...here. Old name was "saved", which was too generic for its new role as file-scoped global. (fillbuf): With --unique, when we're about to read into a buffer that overlaps the saved "preceding" line (saved_line), copy the line's .text member to a realloc'd-as-needed temporary buffer and adjust the line's key-defining members if they're set. (overlap): New function. * tests/misc/sort: New tests. * NEWS (Bug fixes): Mention it. * THANKS.in: Update. Bug introduced via commit v8.5-89-g9face83. Reported by Rasmus Borup Hansen in http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/23173/focus=24647
2012-08-16maint: correct a stale comment in sort.cJim Meyering
* src/sort.c (fillbuf): Fix comment typo. x2nrealloc no longer doubles the size of its input buffer.
2012-07-10sort: by default, do not exceed 3/4 of physical memoryPaul Eggert
* src/sort.c (default_sort_size): Do not exceed 3/4 of total memory. See Jeff Janes's bug report in <http://lists.gnu.org/archive/html/coreutils/2012-06/msg00018.html>.
2012-07-02sort: fix exit-status typoPaul Eggert
* src/sort.c (stream_open): EXIT_FAILURE -> SORT_FAILURE. Suggested by Pádraig Brady in <http://bugs.gnu.org/11816#34>.
2012-07-02sort: simplify -o handling to avoid fdopen, assertPaul Eggert
* src/sort.c (outfd): Remove. All uses replaced by STDOUT_FILENO. (stream_open): When writing, use stdout rather than fdopen. (move_fd_or_die): Renamed from dup2_or_die, with the added functionality of closing its first argument. All uses changed. (avoid_trashing_input): Special case for !outfile no longer needed. (check_output): Arrange for standard output to go to the file, rather than storing the fd in outfd.
2012-07-02sort: avoid redundant processing with inaccessible inputs or outputPádraig Brady
* src/sort.c (check_inputs): A new function to verify all inputs are accessible before further processing. (check_output): A new function to open or create a specified output file, before futher processing. (stream_open): Adjust to truncating the previously opened output file rather than opening directly. (avoid_trashing_input): Optimize to stat the output file descriptor, rather than the file name. (main): Call the new functions to check accessibility of inputs and output, before processing starts. * tests/misc/sort: Adjust to the changed error message. * tests/misc/sort-merge-fdlimit: Account for the earlier opened file descriptor of the specified output file. * tests/misc/sort-exit-early: A new test to exercise the improvements. * tests/Makefile.am: Reference the new test. * NEWS: Mention the improvement. Suggested-by: Bernhard Voelker
2012-06-20maint: sort: style adjustment to help clarify size determinationBernhard Voelker
* src/sort.c (default_sort_size): Move physmem code "down" to first use.
2012-05-16maint: add assertions to placate static analysis toolsJim Meyering
A static analysis tool (http://labs.oracle.com/projects/parfait/) produced some false positive diagnostics. Add assertions to help it understand that the code is correct. * src/stty.c: Include <assert.h>. (display_changed): Add an assertion to placate parfait. (display_all): Likewise. * src/sort.c: Include <assert.h>. (main): Add an assertion to placate parfait. * src/fmt.c: Include <assert.h>. (get_paragraph): Add an assertion to placate parfait.
2012-05-04maint: rely on gnulib's new sys_resource moduleJim Meyering
* bootstrap.conf (gnulib_modules): Add sys_resource. * src/sort.c: Remove #if HAVE_SYS_RESOURCE_H guard around inclusion of <sys/resource.h> and move the inclusion "up" into the alphabetized list of its peers. This also avoids a failure of the sc_prohibit_always_true_header_tests syntax-check rule. * m4/jm-macros.m4 (gl_CHECK_ALL_HEADERS): Remove sys/resource.h.
2012-02-25sort: default to physmem/8, not physmem/16Paul Eggert
* src/sort.c (default_sort_size): Don't divide advice by 2. Just divide the hard limits by 2. This matches the comments. Reported by Rogier Wolff in http://bugs.gnu.org/10877
2012-01-30maint: sort: remove the last uses of "'%s'" in diagnosticsJim Meyering
* src/sort.c (key_warnings): Use quote (quote_n, since there are two) rather than literal single quotes ('%s') in diagnostic.
2012-01-27maint: use single copyright year rangeJim Meyering
Run "make update-copyright".
2012-01-22maint: quote 'like this' or "like this", not `like this'Paul Eggert
* doc/coreutils.texi (Formatting the file names): coreutils now quotes 'like this'. * man/help2man: * src/timeout.c (usage): Quote 'like this' in diagnostics. * HACKING, Makefile.am, NEWS, README, README-hacking, TODO, cfg.mk: * doc/Makefile.am, doc/coreutils.texi, m4/jm-macros.m4: * man/Makefile.am, man/help2man, src/Makefile.am, src/copy.h: * src/extract-magic, src/ls.c, src/pinky.c, src/pr.c, src/sort.c: * src/split.c, src/timeout.c, src/who.c, tests/dd/skip-seek-past-file: * tests/pr/pr-tests: Quote 'like this' in commentary. * cfg.mk (old_NEWS_hash): Update due to changed old NEWS.