summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2012-11-04timeout: add --preserve-status to always propagate the exit statusÁngel González
It's useful for commands that support running for an indeterminite amount of time, to not return a specific timeout exit status (124), and instead let the command handle the timeout signal and return a status for the work done so far. * doc/coreutils.texi (timeout invocation): Describe the new option. * src/timeout.c (preserve_status): A new global boolean to enable the --preserve-status behavior. (usage): Describe the new option. (main): Don't return EXIT_TIMEOUT of preserve_status is set. * tests/misc/timeout.sh: Add a test for the new option.
2012-11-04build: avoid build failure on some HPPA systemsPádraig Brady
* src/longlong.h: Restrict some HPPA assembly variants to PA RISC V2.0. Note we also avoid this assembly for ilp32 runtimes, since even though the assembly is accepted there, it's not safe as the context can get clobbered between the 'add' and 'add,dc'. This fixes a compile failure with newer HPPA systems with default GCC CPU options. Reported by John David Anglin
2012-11-04build: don't assume uintmax_t is 64 bitsPádraig Brady
This was not seen to be an issue in practise, but to make the code more robust, don't assume uintmax_t is 64 bits. * src/factor.c (W_TYPE_SIZE): Define based on integer limits. * src/make-prime-list.c (output_primes): Define format width based on integer limits.
2012-11-04build: don't rely on support for '%j' printf formatPádraig Brady
* src/factor.c (print_uintmaxes): Replace with PRIuMAX. * src/join.c (check_order): Likewise. * cfg.mk (sc_check-j-printf-format): Add a syntax-check rule to flag new cases of this.
2012-11-04build: don't rely on support for '%*j' printf formatPádraig Brady
* src/make-prime-list.c: Hardcode the uintmax_t width to 16 hex digits (64 bit), to avoid this compile issue on HPUS systems at least.
2012-10-25pr: fix -n to pad consistently and not crashPádraig Brady
* src/pr.c: Replace the code to truncate the most significant digits of line numbers, with much simpler string manipulation that supports arbitrary widths. Before this, specifying a width >= 32 to -n would result in a divide by zero error. Also remove the inconsistent padding with zeros and spaces, which would result in zero padding for widths 12 and 15. * tests/pr/pr-tests.pl: Added a test to ensure no zero padding, and also a test for the divide by zero case. * NEWS: Mentioned the fix Reported by Ondrej Oprala
2012-10-25build: ensure factor links the iconv libraryPádraig Brady
* src/local.mk (src_factor_LDADD): Append $(LIBICONV). * crg.mk (sc_check-I18N-AUTHORS): A new syntax check rule to ensure we add LIBICONV where appropriate. * THANKS.in: Add the reporter. Reported by Christian Jullien Syntax check suggested by Jim Meyering
2012-10-23factor: add commentsJim Meyering
* src/factor.c (is_square): Use active voice in comment, not passive. (factor): Add function-describing comment. (mp_factor): Likewise.
2012-10-23build: avoid warnings about unused variables and macrosPádraig Brady
src/factor.c (__GMP_DECLSPEC): Move back from longlong.h to treat consistently with other stub macros. (__GMP_GNUC_PREREQ): Reference to avoid -Wunused-macros warning. (__GMP_DECLSPEC): Likewise. (ASSERT): Likewise. (__clz_tab): Likewise. (factor_using_division): Mark a variable as unused. (mulredc): Likewise. (mulredc2): Likewise. (divexact_21): Likewise.
2012-10-23build: avoid compile warnings in factor.c on some systemsPádraig Brady
* src/factor.c (factor_using_pollard_rho2): On some systems (like sparc) we need to promote all addmod2() parameters to uintmax_t to avoid warnings.
2012-10-23build: avoid build failure on some sparc systemsPádraig Brady
* src/longlong.h: Restrict some sparc assembly variants to sparc V9. This was seen to be an issue with newer sparc systems with default gcc CPU options.
2012-10-17cp: avoid data-corrupting free-memory-readJim Meyering
* src/extent-scan.c (extent_scan_read): Reset our last_ei pointer whenever the parent buffer might have just been freed. * tests/cp/fiemap-extent-FMR.sh: New test. * tests/local.mk (all_tests): Add it. * NEWS (Bug fixes): Mention it. Reported by Mike Gerth in http://bugs.gnu.org/12656, and with help from Alan Curry. Bug introduced in commit v8.10-60-g18f5a85.
2012-10-09factor: fix integer validation and GMP fallbackPádraig Brady
In the recent factor rewrite, the GMP code wasn't actually used; just an error was printed on integer overflow. While fixing that it was noticed that correct input validation wasn't done in all cases when falling back to the GMP code. * src/factor.c (print_factors) Fallback to GMP on overflow. (strto2uintmax): Scan the string for invalid characters, so that case can be detected independently of overflow. Return an error when an empty string is passed. Also allow leading spaces and '+' in input numbers. * tests/misc/factor.pl: Ensure the GMP code is exercised when compiled in. Also add a test to verify leading spaces and '+' are allowed.
2012-10-08build: support older GMP versionsPádraig Brady
The new factor code introduced usage of mpz_inits() and mpz_clears(), which are only available since GMP >= 5, and will result in a compile error when missing. * m4/gmp.m4 (cu_GMP): Define HAVE_DECL_MPZ_INITS appropriately. * src/factor (mpz_inits): New function, defined where missing. (mpz_clears): Likewise.
2012-10-07maint: avoid warning from gcc's -Wunused-macrosJim Meyering
On some systems, -Wunused-macros would warn about two macros: src/factor.c:148:0: warning: macro "__clz_tab" is not used src/factor.c:126:0: warning: macro "UHWtype" is not used * src/factor.c: Add a use to placate gcc.
2012-10-05build: avoid link failure when strerror is replacedJim Meyering
When building the new make-prime-list program on a system for which strerror is defined to rpl_strerror, we'd get a link failure. The problem is that we're including <config.h> for some definitions, but do not want the rpl_ ones, since this particular program must not be linked against gnulib (aka libcoreutils.a). This did not arise on Fedora 17 or 18, but did on Debian wheezy/sid. * src/make-prime-list.c (strerror): #undef. Build failure introduced by commit v8.19-152-gcf67e4c.
2012-10-04factor: 25% speed-up, on outputJim Meyering
* src/factor.c (print_factors_single): Use fputs and umaxtostr rather than printf with "%ju". This reduced the time required to compute and print the factors of the first 10^7 integers from over 8 seconds to 5.75s. Run this command: seq $((10**7)) | env time factor > /dev/null
2012-10-04factor: merge with preexisting factor; integrate tests; avoid warningsJim Meyering
* src/factor.c: Renamed from factor-ng.c, with the following changes: Adjust copyright header to be consistent with others. Use xmalloc and xrealloc, to avoid segv upon OOM. Switch back to using readtokens to handle input. Diagnose invalid inputs. s/fprintf+exit/error/ (print_factors): Add comments. (strto2uintmax): Return strtol_error, not int. (read_item): Remove, no longer used. (main): Use atexit(close_stdout) so that we don't ignore failed write. * cfg.mk: Exempt src/longlong.h from several tests. Exempt run.sh from the test-list-consistency test. Exempt make-prime-list.c from numerous tests, since we won't be making it conform: it must not link with libcoreutils.a. Exempt factor-ng.c from the no-upper-case error message test. * AUTHORS (factor): Add Torbjörn and Niels. * tests/local.mk (factor_tests): Encode the 37 tests. ($(factor_tests)): Rule to generate a test script for each test. * tests/factor/run.sh: New script, marked as very expensive. * .gitignore: Ignore new generated files. * src/local.mk (src/primes.h): New rule. (noinst_PROGRAMS): Add make-prime-list. (noinst_HEADERS): Add longlong.h. Remove all wheel-related rules and files. * src/wheel-gen.pl: Remove file. maint: mark set-but-not-used variables with ATTRIBUTE_UNUSED * src/factor-ng.c (redcify, prime_p, isqrt2): Mark them, so we don't have to disable -Wunused-but-set-variable. maint: use __builtin_expect only if __GNUC__ * src/factor-ng.c (LIKELY, UNLIKELY) [__GNUC__]: Add #ifdef guard. build: avoid warning about unused macro * src/factor-ng.c (__GMP_DECLSPEC): Don't define here * src/longlong.h (__GMP_DECLSPEC): Define if not already defined.
2012-10-04factor: more improvementsNiels Möller
* src/factor-ng.c: Import some improvements from http://gmplib.org:8000/factoring Co-authored-by: Torbjörn Granlund <tg@gmplib.org>
2012-10-04factor: new much-improved implementation; not yet integratedTorbjörn Granlund
* src/factor-ng.c: New file, from nt-factor. * src/longlong.h: New file. * NEWS (Improvements): Mention the upcoming improvements. Co-authored-by: Niels Möller
2012-10-04maint: make-prime-list: syntax conventions; be robust for large NJim Meyering
* src/make-prime-list.c: Insert spaces before parens. (main): Abort if the 8-delta value ever exceeds 255.
2012-10-04maint: make-prime-list: do not ignore write failureJim Meyering
Even though this is just a helper program that is run solely to create primes.h, it should not ignore a write failure. Normally we would simply call atexit (close_stdout), but we cannot do that from this helper program, since it must be built before the generated header, primes.h. If we were to make the linking of make-prime-list depend on libcoreutils.a, that would add all lib/*.o files to the list of dependents of $(BUILT_HEADERS). Then, since there is currently no provision to ensure that a file like lib/stdio.h (another built header) is built before the first lib/*.o file that also includes <stdio.h>, some lib/*.o files would be built before lib/stdio.h and some after. The former would provoke link failures due to undefined rpl_* functions. * src/make-prime-list.c: Include <errno.h>. (fclose): Undef, so that a definition to rpl_fclose does not cause a link failure. (main): Per the above, in this exceptional case, we check for fclose and ferror failure manually, and don't worry about the ferror-only failure case in which errno may not be relevant.
2012-10-04maint: make-prime-list: avoid -Wsuggest-attribute=const warningJim Meyering
* src/make-prime-list.c: Include <config.h>. (binvert): Add _GL_ATTRIBUTE_CONST.
2012-10-04factor: prepare for the new factor programTorbjörn Granlund
* src/make-prime-list.c: New file, from nt-factor. Co-authored-by: Niels Möller <nisse@lysator.liu.se>
2012-10-03build: remove redundant dependency: $(PROGRAMS): lib/libcoreutils.aJim Meyering
* src/local.mk: Remove the above dependency. A soon-to-be-added new program, make-prime-list, must not depend on that, since it is used to create a BUILT_SOURCES file. That dependency is already handled via the ..._LD_ADD variables, and so that redundant dependency has so far been harmless.
2012-09-30du: avoid abort on systems for which ->me_type is not malloc'dJim Meyering
On some systems (notably, BSD-based, like at least OpenBSD 4.9), the me_type member does not come from the heap. * src/du.c (fill_mount_table): Free the ->me_type member only when it was malloc'd, i.e., when ->me_type_malloced is nonzero. Bug introduced via commit v8.19-2-gcf7e1b5. Reported as http://bugs.gnu.org/12542.
2012-09-28doc: correct an old bit of ugliness in nice --help outputJim Meyering
* src/nice.c (usage): s/Nicenesses/Niceness values/
2012-09-28doc: disambiguate the niceness explanation in nice --helpPádraig Brady
* src/nice.c (usage): Specify the entity (process) that that relative terms are referring to. * THANKS: Update. Reported-by: David Diggles
2012-09-28cp: fix the --no-preserve=mode optionOndrej Oprala
The --no-preserve=mode option did not do what its name implies: it would mistakenly preserve permission mode bits. * NEWS: Mention the fix. * TODO: Remove an entry. * src/copy.c (copy_reg): Add a condition to properly handle the --no-preserve=mode option for files (copy_internal): Add a condition to properly handle the --no-preserve=mode option for directories. * src/copy.h (struct cp_options): Add a new boolean. * src/cp.c (cp_option_init,decode_preserve_arg): Set the new boolean value according to specified options. * src/install.c (struct cp_options): Initialize the new boolean. * src/mv.c (struct cp_options): Initialize the new boolean. * tests/cp/preserve-mode.sh: Add a new test. * tests/cp/link-preserve.sh (-a --no-preserve=mode): Adjust the expected perms: now, --no-preserve=mode overrides the --preserve=mode that is inherent in -a, as it should. * tests/local.mk: Add the new test to the list.
2012-09-24timeout: handle signals more transparentlyPádraig Brady
This was originally attempted in commit v8.12-117-g5a647a0, but reverted before release because of the unreliability of disabling core dumps using setrlimit() on Linux kernels. This new version instead uses prctl() where available to more reliably disable core dumps for the timeout process. * m4/jm-macros.m4: Define HAVE_SETRLIMIT and HAVE_PRCTL. * src/timeout.c (disable_core_dumps): A new function that disables coredumps using prctl or setrlimit if available. (main): If the child exited with a signal and we can disable core dumps, then raise that signal to the timeout process itself, so that callers may also see the signal status. Also print a message indicating when the monitored command dumped core, as that information is lost in the signal propagation through timeout.
2012-09-24dd: new option, status=none to suppress output statisticsPozsár Balázs
* src/dd.c (STATUS_NONE): A new bitmask combining all STATUS_ options, thus used to suppress all informational output. (struct symbol_value statuses): Expose the "none" option, corresponding to the STATUS_NONE bitmask above. (print_stats): Return early if STATUS_NONE is specified. Also move the call to gethrxtime() down so that it's only called when needed. (usage): Describe the new options. * doc/coreutils.texi (dd invocation): Likewise. * NEWS: Mention the new feature. * tests/dd/misc.sh: Ensure the new option works.
2012-09-23tail,stat: improve support for vmhgfsJim Meyering
Teach tail -f that it must use polling on vmhgfs file systems, and let stat -f --format=%T report the file system type name, "vmhgfs". * src/stat.c (human_fstype): Add a case: vmhgfs, 0xbacbacbc, remote. * NEWS (Improvements): Mention it. * THANKS.in: Update. Reported by Daniel Tschinder in http://bugs.gnu.org/12461.
2012-09-19rm: be even more careful when using a replacement errno valueJim Meyering
* src/remove.c (excise): The change in commit v8.19-107-gccbd3f3 made the "rm -rf D" (for unreadable dir, D) diagnostic worse on Solaris 10: -rm: cannot remove 'D': Permission denied +rm: cannot remove 'D': File exists That happened because unlinkat would fail with EEXIST there, given an unreadable directory, which made the two tests, tests/rm/unread2 and tests/rm/unreadable fail. Accommodate the EEXIST case, too.
2012-09-18dd: remove references to the word BLOCKS from help and texi docsBenno Schulenberg
The renaming from BLOCKS to N was done in v8.15-38-g140eca1, and documentation for N was added again in v8.17-26-g4f2e9d5 without noticing that. Now, finally remove the word BLOCKS from the documentation. * src/dd.c (usage): Remove the word BLOCKS. * doc/coreutils.texi (dd invocation): Likewise. Improved by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-09-16ls: fix coloring of dangling symlinks in default listing modePádraig Brady
When listing a directory containing dangling symlinks, and not outputting a long format listing, and orphaned links are set to no coloring in LS_COLORS, then the symlinks would get no color rather than reverting to the standard symlink color. The issue was introduced in v8.13-19-g84457c4 * src/ls.c (print_color_indicator): Use the standard method to check if coloring is specified for orphaned symlinks. The existing method would consider 'or=00' or 'or=0' as significant in LS_COLORS. Even 'or=' was significant as in that case the string='or=' and the length=0. Also apply the same change for missing symlinks for consistency. (gobble_file): Remove the simulation of linkok, which is only tested in print_color_indicator() which now handles this directly by keying on the LS_COLORS values correctly. * tests/misc/ls-misc.pl: Add a test case. * THANKS: Add the reporter. * NEWS: Mention the fix. Reported-by: David Matei
2012-09-14seq: enable the fast integer printing code in more casesPádraig Brady
* src/seq.c (main): Adjust the initial arbitrary precision seq_fast enablement checks to be more maintainable, and a little more general, by allowing single character separators to use seq_fast. Also check again after the number arguments are processed, to see if we can still use seq_fast, which while not allowing arbitarly large integers, it will handle integers of the form 10E10 etc. (seq_fast): Use a specified separator character, rather than hardcoding '\n'.
2012-09-14seq: 70x faster for non-negative whole numbers and incr==1Jim Meyering
Handle non-negative whole numbers robustly and efficiently when the increment is 1 and when no format-changing option is specified. On the correctness front, for very large numbers, seq now works fine: $ b=1000000000000000000000000000 $ src/seq ${b}09 ${b}11 100000000000000000000000000009 100000000000000000000000000010 100000000000000000000000000011 while the old one would infloop, printing garbage: $ seq ${b}09 ${b}11 | head -2 99999999999999999997315645440 99999999999999999997315645440 The new code is much more efficient, too: Old vs new: 55.81s vs 0.82s $ env time --f=%e seq $((10**8)) > /dev/null 55.81 $ env time --f=%e src/seq $((10**8)) > /dev/null 0.82 * seq.c (incr): New function, inspired by the one in cat.c. (cmp, seq_fast): New functions, inspired by code in nt-factor by Torbjörn Granlund and Niels Möller. (trim_leading_zeros): New function, without which cmp would malfunction. (all_digits_p): New function. (main): Hoist the format_str-vs-equal_width check to precede first treatment of operands, and insert code to call seq_fast when possible. * NEWS (Bug fixes): Mention the correctness fix. (Improvements): Mention the speed-up. * tests/misc/seq.pl: Exercise the new code. Improved by: Bernhard Voelker. http://thread.gmane.org/gmane.comp.gnu.coreutils.general/3340
2012-09-11build: build lib/ using non-recursive makeJim Meyering
* bootstrap.conf (gnulib_modules): Use the new module. (bootstrap_post_import_hook): Invoke prefix-gnulib-mk. * configure.ac (AC_CONFIG_FILES): Remove lib/Makefile. * lib/Makefile.am: Renamed... * lib/local.mk: ...to this. * src/local.mk (CLEANFILES): Append, don't set. (noinst_LIBRARIES): Likewise. (AM_CPPFLAGS): Don't set this here. * Makefile.am (AM_CPPFLAGS): Define here instead. (noinst_LIBRARIES, CLEANFILES, MOSTLYCLEANDIRS, MOSTLYCLEANFILES): Initialize here, so we can append to them from each included local.mk (SUBDIRS): Remove "lib".
2012-09-10maint: allow per-directory CFLAGS settings with non-recursive makeJim Meyering
* src/local.mk (AM_CFLAGS): Don't use $(WARN_CFLAGS) here. * cfg.mk (src_CFLAGS, lib_CFLAGS, gnulib-tests_CFLAGS): Define here instead. (AM_CFLAGS): Augment using the above. * configure.ac: Note that the configure-time option, --enable-gcc-warnings now functions only when using GNU make. Well, currently it does still work in gnulib-tests, but that should soon be fixed. Improved-by: Stefano Lattarini
2012-09-07factor: don't ever declare composites to be primeTorbjörn Granlund
The multiple-precision factoring code (with HAVE_GMP) was copied from a now-obsolete version of GMP that did not pass proper arguments to the mpz_probab_prime_p function. It makes that code perform no more than 3 Miller-Rabin tests only, which is not sufficient. A Miller-Rabin test will detect composites with at least a probability of 3/4. For a uniform random composite, the probability will actually be much higher. Or put another way, of the N-3 possible Miller-Rabin tests for checking the composite N, there is no number N for which more than (N-3)/4 of the tests will fail to detect the number as a composite. For most numbers N the number of "false witnesses" will be much, much lower. Problem numbers are of the form N=pq, p,q prime and (p-1)/(q-1) = s, where s is a small integer. (There are other problem forms too, involving 3 or more prime factors.) When s = 2, we get the 3/4 factor. It is easy to find numbers of that form that cause coreutils' factor to fail: 465658903 2242724851 6635692801 17709149503 17754345703 20889169003 42743470771 54890944111 72047131003 85862644003 98275842811 114654168091 117225546301 ... There are 9008992 composites of the form with s=2 below 2^64. With 3 Miller-Rabin tests, one would expect about 9008992/64 = 140766 to be invalidly recognized as primes in that range. * src/factor.c (MR_REPS): Define to 25. (factor_using_pollard_rho): Use MR_REPS, not 3. (print_factors_multi): Likewise. * THANKS.in: Remove my name, now that it will be automatically included in the generated THANKS file.
2012-09-06nproc: disallow non option command line parametersPádraig Brady
* src/nproc.c (main): Error if any non option parameters. * NEWS: Mention the change in behavior.
2012-09-06tail,stat: add support for VZFSJim Meyering
* src/stat.c (human_fstype): Add a case: vzfs, 0x565A4653 (local). Reported by Jens Rosenboom in http://bugs.gnu.org/12356 * NEWS (Improvement): Mention it.
2012-09-05rm: be more careful when using a replacement errno valueJim Meyering
* src/remove.c (excise): Tighten the test for when we defer to an old errno value: instead of relying solely on an FTS_DNR (unreadable directory) failure, also test current and replacement errno values. This change would also have solved the problem addressed by commit v8.19-106-g57dd067. For more info, see http://bugs.gnu.org/12339#113
2012-09-05rm: avoid bogus diagnostic for a slash-decorated symlink-to-dirJim Meyering
These commands would evoke an invalid diagnostic: $ mkdir d && ln -s d s && env rm -r s/ rm: cannot remove 's': Too many levels of symbolic links remove.c was stripping trailing slashes from "s/" before passing the name to "rm". But a trailing slash may change the semantics, and thus should not be stripped. * src/remove.c (rm_fts): Do not strip trailing slashes. * tests/rm/v-slash.sh: Adapt to new expected output. * gnulib: Update to latest, for an improved fts.c that merely normalizes trailing slashes. Reported by Paul Eggert in discussion of http://bugs.gnu.org/12339
2012-09-05build: remove two now-useless convenience targetsStefano Lattarini
* src/local.mk (built_programs.list, all_programs.list): These.
2012-09-05build: use 'check-local' to extend the 'check' targetStefano Lattarini
* tests/Makefile.am (check-local): Here, by making this depend on 'vc_exe_in_TESTS' ... (check): ... rather than making this depend on them. While the old usage worked, it relied on an implementation detail rather than on documented behavior. * src/local.mk (check-local): Similarly, make this depend on 'check-README' and 'check-duplicate-no-install' ... (check): ... rather than on this.
2012-09-02touch: line up long option in --help textBenno Schulenberg
* src/touch.c (usage): Indent --time=... to line up with all of the other long options.
2012-09-01build: fix VPATH issues in C compilationJim Meyering
* src/local.mk (AM_CPPFLAGS): Add 'src' to the directories that are searched for #include'd files.
2012-09-01build: simplify: get rid of some indirection variablesStefano Lattarini
The code deciding which coreutils programs to build (depending on defaults, system capabilities, and user requests) is overly complex and rather confusing. Let's begin simplifying it by removing some non-strictly-necessary indirection variables. * configure.ac: Adjust and improve few comments. (OPTIONAL_BIN_PROGS, OPTIONAL_PKGLIB_PROGS): Rename ... (bin_PROGRAMS, pkglibexec_PROGRAMS): ... like these, respectively. Ensure they aren't initialized in all Makefiles (which would lead to spurious errors), by calling AM_SUBST_NOTMAKE on them. * src/local.mk: Adjust and improve few comments. (bin_PROGRAMS, pkglibexec_PROGRAMS): Simply define to the corresponding '@substitution@'.
2012-09-01maint: update gitignore entriesStefano Lattarini
* src/.gitignore: Here, adding the '.dirstamp' file generated by the C compilation rules.