summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2010-10-19md5sum: print a summary warning for improperly formatted linesBenno Schulenberg
And remove the now-superfluous totals from the other two warnings, so the plurals will also work in other languages than English. * src/md5sum.c (digest_check): Change as above. * tests/misc/md5sum (check-quiet2): Adjust accordingly.
2010-10-16fold: fix fadvise hintAndreas Schwab
* src/fold.c (fold_file): Apply fadvise to istream, not stdin. This bug would have inhibited the fadvise optimization when not reading from standard input.
2010-10-14bug#7213: [PATCH] sort: fix buffer overrun on 32-bit hosts when warning re ↵Paul Eggert
obsolete keys * src/sort.c (key_warnings): Local buffer should be of size INT_BUFSIZE_BOUND (uintmax_t), not INT_BUFSIZE_BOUND (sword). This bug was discovered by running 'make check' on a 32-bit Solaris 8 sparc host, using Sun cc. I saw several other instances of invoking umaxtostr on a buffer declared to be of size INT_BUFSIZE_BOUND (VAR), and these instances should at some point be replaced by INT_BUFSIZE_BOUND (uintmax_t) too, as that's a less error-prone style.
2010-10-13install: avoid warning with Solaris 10 ccPaul Eggert
* src/install.c (extra_mode): Don't assign ~S_IRWXUGO & ~S_IFMT to a mode_t variable, as the number might be too big to fit. Solaris 10 cc warns about this, and the C standard says it has undefined behavior.
2010-10-13sort: fix unportable cast of unsigned char * -> char *Paul Eggert
* src/sort.c (fold_toupper): Change this back from char to unsigned char, fixing a portability issue introduced in commit 59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the C Standard doesn't let you convert from unsigned char * to char * without a cast, and the (in theory more portable) style here is to convert char values, not pointer values. (getmonth): Convert char to unsigned char when needed for comparison.
2010-10-12tail: fix checking of currently unavailable directoriesPádraig Brady
* src/tail.c (tail_forever_inotify): Handle the case where tail --follow=name with inotify, is not able to add a watch on a specified directory. This may happen due to inotify resource limits or if the directory is currently missing or inaccessible. In all these cases, revert to polling which will try to reopen the file later. Note inotify returns ENOSPC when it runs out of resources, and instead we report a particular error message, lest users think one of their file systems is full. (main): Document another caveat with using inotify, where we currently don't recheck directories recreated after the initial watch is setup. * tests/tail-2/F-vs-rename: Fix the endless loop triggered by the above issue. * tests/tail-2/inotify-hash-abuse: Likewise. * tests/tail-2/wait: Don't fail in the resource exhaustion case. * tests/tail-2/F-vs-missing: A new test for this failure mode which was until now just triggered on older buggy linux kernels which returned ENOSPC constantly from inotify_add_watch(). * NEWS: Mention the fix.
2010-10-07split: fix reporting of read errorsPádraig Brady
The bug was introduced with commit 23f6d41f, 19-02-2003. * src/split.c (bytes_split, lines_split, line_bytes_split): Correctly check the return from full_read(). * tests/misc/split-fail: Ensure split fails when it can't read its input. * NEWS: Mention the fix.
2010-10-05build: complete the rename of get_dateEric Blake
* gnulib: Update to latest. * src/date.c (includes, batch_convert, main): Track rename. * src/touch.c (includes, get_reldate): Likewise. * doc/coreutils.texi (Top, Date input formats): Likewise. * bootstrap.conf (gnulib_modules): Likewise. * doc/Makefile.am (EXTRA_DIST): Likewise. * doc/.gitignore: Likewise. * bootstrap: Synchronize from upstream.
2010-10-05stat: drop %C support when printing file system detailsEric Blake
* src/stat.c (print_statfs, usage): Drop %C, since it applies to files, not file systems. (out_file_context): Match style of other out_* functions. (print_stat): Update caller. * doc/coreutils.texi (stat invocation): Document %C. * NEWS: Document the change.
2010-10-05stat: adjust the printing of SELinux contextPádraig Brady
* src/stat.c (default_format): Don't print SELinux context when in file system (-f) mode, as the context is associated with the file, not the file system. Fix logic inversion, so that in terse mode, %C is included only when is_selinux_enabled and not vice versa.
2010-10-03maint: suppress a bogus used-uninitialized warning in tr.cJim Meyering
* src/tr.c (string2_extend): Insert an abort call to tell gcc that char_to_repeat is not used uninitialized.
2010-10-01stat: print SELinux context when availableEric Blake
* src/stat.c (default_format): Include context when present. * NEWS: Update blurb explaining the replacement for -Z.
2010-10-01stat: optimize and translate default format stringsEric Blake
Yes, this patch intentionally leaks the results of default_format(), since it is called only twice, and since the results are in scope until main() exits. Not worth the extra code to pacify valgrind. * src/stat.c (main): Hoist default format computation out of loop. (do_statfs, do_stat): Move default format generation... (default_format): ...into new function. Allocate the result in pieces, rather than repeating mostly-similar chunks. Allow translation of verbose format. Pass a second format to do_stat, for the one aspect of the default format that is conditional on file type. * NEWS: Document the translation aspect.
2010-10-01stat: print timestamps to full resolutionEric Blake
* src/stat.c (epoch_time): New function. (print_stat): Use it for %[WXYZ]. * NEWS: Document this. * tests/touch/60-seconds: Adjust test to match. * tests/misc/stat-birthtime: Likewise.
2010-10-01stat: support printing birthtimeEric Blake
* src/stat.c (print_stat): New %w and %W formats. (do_stat): Include %w in default format. (usage): Document new specifiers. * doc/coreutils.texi (stat invocation): Likewise. * NEWS: Likewise.
2010-09-29tr: fix various issues with case conversionPádraig Brady
This valid translation spec aborted: LC_ALL=en_US.iso-8859-1 tr '[:upper:]- ' '[:lower:]_' This invalid translation spec aborted: LC_ALL=en_US.iso-8859-1 tr '[:upper:] ' '[:lower:]' This was caused by commit 6efd1046, 05-01-2008, "Avoid tr case-conversion failure in some locales" This misaligned conversion spec was allowed: LC_ALL=C tr 'A-Y[:lower:]' 'a-z[:upper:]' This was caused by commit af5d0c36, 21-10-2007, "tr: do not reject an unmatched [:lower:] or [:upper:] in SET1" This misaligned spec was allowed by extending the class: LC_ALL=C tr '[:upper:] ' '[:lower:]' * src/tr.c (validate_case_classes): A new function to check alignment of case conversion classes. Also it adjusts the length of the sets so that locales with different numbers of upper and lower case characters, don't cause issues. (string2_extend): Disallow extending the case conversion class as in the above example. That is locale dependent and most likely not what the user wants. (validate): Do the simple test for "restricted" char classes earlier, so we don't redundantly do more expensive validation. (main): Remove the case class validation, and simplify. * tests/misc/tr-case-class: A new test to test the various alignment and locale issues, associated with case conversion. * tests/misc/tr: Move case conversion tests to new tr-case-class. * tests/Makefile.am: Reference the new test. * NEWS: Mention the fixes.
2010-09-20sort: destroy spin locks portablyPaul Eggert
* src/sort.c (sortlines, sort): Use pthread_spin_destroy when a spin lock is no longer used. This isn't needed on GNU/Linux or Solaris, but POSIX says it may free up resources on some platforms.
2010-09-18build: use gnulib's new termios moduleJim Meyering
With it, we can remove the two sole tests of HAVE_TERMIOS_H. * bootstrap.conf (gnulib_modules): Add termios. * src/ls.c: Don't test HAVE_TERMIOS_H. * src/stty.c: Likewise. * m4/jm-macros.m4 (gl_CHECK_ALL_TYPES): Remove configure-time test for termios.h.
2010-09-17maint: update to latest gnulibEric Blake
* gnulib: Update to latest. * src/copy.c (copy_reg): Use fdutimens instead of gl_futimens. * src/touch.c (touch): Adjust parameter order. * tests/init.sh: Resync from upstream.
2010-09-17rm: remove no-op -d optionEric Blake
* src/rm.c (long_opts, main): Resolve a fixme. * NEWS: Document the change. Based on a report by William Plusnick.
2010-09-17maint: update to latest gnulibEric Blake
* gnulib: Update to latest. * bootstrap.conf (gnulib_modules): Add fdutimensat. * src/touch.c (touch): Use fdutimensat instead of gl_futimens.
2010-09-13dircolors: add rxvt-unicode-256color terminal typeDmitry V. Levin
rxvt-unicode introduced new terminal type: http://cvs.schmorp.de/rxvt-unicode/src/rxvt.h?r1=1.398&r2=1.399 * src/dircolors.hin: Add rxvt-unicode-256color terminal type. Reported by Alexey I. Froloff in <http://bugzilla.altlinux.org/24052>. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2010-09-01tac: suppress technically unneeded "free"Jim Meyering
* src/tac.c (main): Guard final free with #ifdef lint. Suggested by Paul Eggert.
2010-09-01join: improve performance when operating on whole linesPádraig Brady
Following on from commit f86bb696, 01-02-2010, "join: make -t '' operate on the whole line". Bypassing the delimiter search in this case, gives about an 8% performance boost. * src/join (xfields): Don't bother looking for '\n' in the data, which we know won't be present.
2010-08-28tac: avoid double freeJim Meyering
* src/tac.c (main): Reading a line longer than 16KiB would cause tac to realloc its primary buffer. Then, just before exit, tac would mistakenly free the original (now free'd) buffer. This bug was introduced by commit be6c13e7, "maint: always free a buffer, to avoid even semblance of a leak". * NEWS (Bug fixes): Mention it. * tests/misc/tac (double-free): New test, to exercise this. Reported by Salvo Tomaselli in <http://bugs.debian.org/594666>.
2010-08-27stat: add %m to output the mount point for a fileAaron Burgemeister
* src/find-mount-point.c: A new file refactoring find_mount_point() out from df.c * src/find-mount-point.h: Likewise. * src/df.c: Use the new find-mount-point module. * src/stat.c (print_stat): Handle the new %m format. (find_bind_mount): A new function to return the bind mount for a file if any. (out_mount_mount): Print the bind mount for a file, or else the standard mount point given by the find-mount-point module. (usage): Document the %m format directive. * src/Makefile.am: Reference the refactored find-mount-point.c * po/POTFILES.in: Add find_mount_point.c to the translation list * doc/coreutils.texi (stat invocation): Document %m, and how it may differ from the mount point that df outputs. * test/misc/stat-mount: A new test to correlate mount points output from df and stat. * tests/Makefile.am: Reference the new test. * NEWS: Mention the new feature * THANKS: Add the author Signed-off-by: Pádraig Brady <P@draigBrady.com>
2010-08-25df: always print the device name for bind mounted filesPádraig Brady
* src/df (show_point): Remove the optimization for comparing the specified path with the device name, as this produces inconsistent results in the presence of bind mounts. For bind mounts, the device name is populated with the bind mount target. * NEWS: Mention the change in behavior.
2010-08-23stat: fix a small memory leak with %NPádraig Brady
* src/stat.c (print_stat): Free the buffer returned from areadlink_with_size().
2010-08-10sort, who: prefer free+malloc to realloc when contents are irrelevantPaul Eggert
This change was prompted by the previous one: I audited the code looking for similar examples. Too bad valgrind doesn't catch this. * src/sort.c (check, mergefps): xrealloc -> free + xmalloc * src/who.c (print_user): Likewise.
2010-08-10sort: free/xmalloc rather than xreallocPaul Eggert
* src/sort.c (compare_random): Use free/xmalloc rather than xrealloc, since the old buffer contents need not be preserved. Also, don't fail if the guessed-sized malloc fails. Suggested by Bruno Haible.
2010-08-10sort: avoid gcc warning: explicitly ignore strtold resultJim Meyering
* src/sort.c: Include "ignore-value.h". (debug_key): Use ignore_value.
2010-08-09dircolors: add screen.rxvt & terminator to TERM listMike Frysinger
Resolves bug#6793. * src/dircolors.hin: Add screen.rxvt & terminator. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-08-08sort: speed up -R with long lines in hard localesPaul Eggert
* src/sort.c (compare_random): Guess that the output will be 3X the input. This avoids the overhead of calling strxfrm twice on typical implementations. Suggested by Bruno Haible.
2010-08-06sort: support all combinations of -d, -f, -i, -R, and -VPaul Eggert
* NEWS: Document this. * src/sort.c (getmonth): Omit LEN arg, as MONTH is now null-terminated. (compare_random): Don't null-terminate keys, as caller now does that. (compare_version): Remove. (debug_key): Null-terminate string for getmonth. (keycompare): Support combining -R with any of -d, -f, -i, -V. Also, support combining -V with any of -d, -i. (check_ordering_compatibility): Allow newly-supported combinations. * tests/misc/sort (02q, 02r, 02s): New tests, for new combinations. (incompat2): Now test -nR, since -fR are now compatible.
2010-08-05sort: tune and refactor --debug code, and fix minor underlining bugPaul Eggert
Formerly, the 'compare' function and some of its subroutines had a debugging flag, which caused them to output underlines. This change refactors the code so that debugging output is more-separated from the actual sorting. In the process, the change fixes a minor error in the debugging output. The change shortens the source code and executable size a tad, and improves CPU performance by 2.4% on my platform with a simple benchmark (C locale, line sorting, no debug). * src/sort.c (long_double, strtold): Move back to prelude, since they're now used by multiple functions again. (unit_order): Move to file scope, since it's now used by two functions. (find_unit_order, human_numcompare, numcompare, general_numcompare): Remove endptr parameter. All callers changed. (human_numcompare): Args are now const pointers. (getmonth): Endptr is now non-const. (key_numeric): Move up, since it's needed earlier. (debug_key): Take a line and a key as argument, instead of having the caller figure out where the field is. (debug_line): New function. (keycompare, compare): Omit debug parameter; debug output now done elsewhere. All callers changed. (write_line): Renamed from write_bytes; all callers changed. Use debug_line (not 'compare') to output debug info. Use a slightly faster check for whether output file is stdout. (check): Don't do debugging output; it's not that useful here, and it confuses the code. (main): Check for incompatibility between -c and --debug. Use standard diagnostic for incompatible options. * tests/misc/sort-debug-keys: Fix test case: "--Mi-1" is not a number, so its first character should not be underlined when debugging a numeric sort.
2010-08-04sort: -R now uses less memory on long lines with internal NULsPaul Eggert
* lib/Makefile.am (libcoreutils_a_SOURCES): Remove xmemxfrm.c, xmemxfrm.h. * lib/memxfrm.c, lib/memxfrm.h, lib/xmemxfrm.c, lib/xmemxfrm.h: Remove. * m4/memxfrm.m4: Likewise. * m4/prereq.m4 (gl_PREREQ): Remove gl_MEMXFRM. * po/POTFILES.in: Remove lib/xmemxfrm.c. * src/sort.c: Don't include xmemxfrm.h. (cmp_hashes): Remove. (xstrxfrm): New function. (compare_random): If a line contains NULs, don't create a big buffer that contains the strxfrm output of each string in the line. Instead, accumulate checksums and differences as we go, so that at any one time we have to store at most the output of a single strxfrm call when processing the line. This removes the need for an memxfrm function.
2010-08-03sort: fix bug in --debug when \0 is followed by \tPaul Eggert
* src/sort.c (debug_width): New function, which does not stop counting tabs at \0, and also invokes mbsnwidth. Stamp out strnlen! (count_tabs): Remove. (debug_key): Use debug_width instead of mbsnwidth and count_tabs. * tests/misc/sort-debug-keys: Check that \0 and \t intermix.
2010-08-02sort: revert recent -h changes and use a more-conservative approachPaul Eggert
* NEWS: Document changes to sort -h, which are now minor with respect to the pre-July-30th version. * doc/coreutils.texi (sort invocation): Likewise. The documentation now describes how -h comparison is done rather than being vague with border cases. * src/sort.c (long_double, strtold): Move back to general_numcompare. (LD, compute_human): Remove. (find_unit_order): Remove THOU_SEP parameter, since thousands separators are now allowed by all callers. Revert to previous behavior of sorting by suffix, and returning the order rather than 2 * order + binary, since we no longer care whether binary powers are being used. However, treat all zeros the same, instead of sorting 0M before 0G; this is more consistent with the desired behavior of sorting -1G before -1M. * tests/misc/sort (h1, h3, h6): Adjust to match mostly-reverted behavior. However, check that all zeros sort together. * tests/misc/sort-debug-keys: Omit a "_", since the trailing "i" in "1234Gi" is no longer part of the key.
2010-07-30sort: -h now handles comparisons such as 6000K vs 5M and 5MiB vs 5MBPaul Eggert
* NEWS: Document changes to sort -h. * doc/coreutils.texi (sort invocation): Likewise. * src/sort.c (long_double, strtold): Move to prelude, since they're now used by multiple functions. (LD): New macro. (struct keyfield.iec_present): Remove this member. All uses removed. (check_mixed_SI_IEC): Remove. This code was busted in the presence of multiple threads, as it had a race condition. (find_unit_order): Remove arg KEY; add arg THOU_SEP; arg ENDPTR is now char ** rather than char const **. Return an integer that distinguishes decimal from binary powers. Parse the number consistently with the intersection of strtold and strnumcmp. Set *ENDPTR unconditionally. (compute_human): New static function. (human_numcompare): Remove arg KEY. Remove 'const' from other args. Use strnumcmp if possible, but fall back on floating point if not. (numcompare, general_numcompare): Arg EA is now char ** rather than char const **. (numcompare): Adjust to new find_unit_order signature and behavior. (keycompare): Adjus to new human_numcompare signature. * tests/misc/sort (h1, h3, h4, h6): Adjust to new behavior. * tests/misc/sort-debug-keys: Likewise.
2010-07-27sort: fix --debug display with very large offsetsPaul Eggert
* src/sort.c (mark_key): Don't assume offset <= INT_MAX. Make the code a bit clearer when width != 0.
2010-07-26sort: fix bug with EOF at buffer refillPaul Eggert
* src/sort.c (fillbuf): Don't append eol unless the line is nonempty. This fixes a bug that was partly but not completely fixed by the aadc67dfdb47f28bb8d1fa5e0fe0f52e2a8c51bf commit (dated July 15). * tests/misc/sort (realloc-buf-2): New test, which catches this bug on 64-bit hosts.
2010-07-26sort: omit some "inline"sPaul Eggert
* src/sort.c (mergelines, queue_destroy, queue_init, queue_insert): (queue_pop, write_unique, mergelines_node, check_insert): (update_parent): No longer inline; these uses of "inline" seemed unlikely to help performance much.
2010-07-26sort: don't assume ASCII when parsing K, M, G suffixesPaul Eggert
* src/sort.c (find_unit_order): Don't assume ASCII.
2010-07-25sort: omit unnecessary mutex unlock+lock; simplify heap accessPaul R. Eggert
* src/sort.c (queue_pop): Omit unnecessary unlock+lock after pthread_cond_wait returns. Don't access "count" member of the heap; any efficiency gains should be quite minor, the access complicates this code, and "count" should be private anyway.
2010-07-25sort: omit 'restrict' in doubtful casesPaul R. Eggert
* src/sort.c (lock_node, unlock_node, queue_destroy, queue_init): (queue_pop): Omit 'restrict'; it shouldn't help here, as these functions have just one pointer parameter and don't access static storage. (queue_insert, check_insert, update_parent): Omit 'restrict', as the pointer types differ, and are not char * or unsigned char *, and therefore can't alias. (write_unique): Omit 'restrict', as the pointer types are all read-only. (merge_loop, sortlines): Omit 'restrict', as any performance advantages are extremely unlikely and it's not worth cluttering the code for that. (struct thread_args): Omit 'restrict': this seems to be incorrect. It's unlikely for 'restrict' to be correct inside a typedef.
2010-07-25sort: omit unnecessary castsPaul R. Eggert
* src/sort.c (inittables, general_numcompare, compare_nodes): (queue_init, queue_pop): Omit casts that are not needed, typically because they are between void * and some other pointer type.
2010-07-25sort: use more-consistent style with constPaul R. Eggert
* src/sort.c (proctab_hasher, proctab_comparator, stream_open, xfopen): (open_temp, zaptemp, struct_month_cmp, begfield, limfield): (find_unit_order, human_numcompare, numcompare, general_numcompare): (count_tabs, keycompare, compare, compare_nodes, lock_node): (unlock_node, queue_destroy, queue_init, queue_insert, queue_pop): (write_unique, mergelines_node, check_insert, update_parent): (merge_loop, sortlines, struct thread_args, set_ordering): Prefer the style "T const" to "const T". * gl/lib/heap.h (struct heap, heap_alloc): Likewise. * gl/lib/heap.c (heap_default_compare, heapify_down, heapify_up): (heap_alloc): Likewise.
2010-07-24du: tune, and fix some -L bugs with dangling or cyclic symlinksPaul R. Eggert
* src/du.c (process_file): Avoid recalculation of hashes and of file-exclusion for directories. Do not descend into the same directory more than once, unless -l is given; this is faster. Calculate stat buffer lazily, since it need not be computed at all for excluded files. Count space if FTS_ERR, since stat buffer is always valid then. No need for 'print' local variable. (main): Use FTS_NOSTAT. Use FTS_TIGHT_CYCLE_CHECK only when not hashing everything, since process_file finds cycles on its own when hashing everything. * tests/du/deref: Add test cases for -L bugs.
2010-07-22provide POSIX_FADV_SEQUENTIAL hint to appropriate utilsPádraig Brady
Following on from commit dae35bac, 01-03-2010, "sort: inform the system about our input access pattern" apply the same hint to all appropriate utils. This currently gives around a 5% speedup for reading large files from fast flash devices on GNU/Linux. * src/base64.c: Call fadvise (..., FADVISE_SEQUENTIAL); * src/cat.c: Likewise. * src/cksum.c: Likewise. * src/comm.c: Likewise. * src/cut.c: Likewise. * src/expand.c: Likewise. * src/fmt.c: Likewise. * src/fold.c: Likewise. * src/join.c: Likewise. * src/md5sum.c: Likewise. * src/nl.c: Likewise. * src/paste.c: Likewise. * src/pr.c: Likewise. * src/ptx.c: Likewise. * src/shuf.c: Likewise. * src/sum.c: Likewise. * src/tee.c: Likewise. * src/tr.c: Likewise. * src/tsort.c: Likewise. * src/unexpand.c: Likewise. * src/uniq.c: Likewise. * src/wc.c: Likewise, unless we don't actually read().
2010-07-22fadvise: new module providing a simpler interface to posix_fadvisePádraig Brady
* bootstrap.conf: Include the new module * gl/lib/fadvise.c: Provide a simpler interface to posix_fadvise. (fadvise): Provide hint to the whole file associated with a stream. (fdadvise): Provide hint to the specific portion of a file associated with a file descriptor. * gl/lib/fadvise.h: Redefine POSIX_FADV_* to FADVISE_* enums. * gl/modules/fadvise: New file. * m4/jm-macros.m4: Remove the no longer needed posix_fadvise check. * .x-sc_program_name: Exclude test-fadvise.c from this check. * gl/tests/test-fadvise (main): New test program. * gl/modules/fadvise-testss: A new index to reference the tests. * src/sort.c (stream_open): Use the new interface. * src/dd.c (iwrite): Likewise.