summaryrefslogtreecommitdiff
path: root/src/tac.c
AgeCommit message (Collapse)Author
2017-02-16maint: xsetmode renamed to xbinary-ioHEADmasterPaul Eggert
* bootstrap.conf, src/base64.c, src/cat.c, src/cksum.c: * src/head.c, src/md5sum.c, src/od.c, src/split.c, src/sum.c: * src/tac.c, src/tail.c, src/tee.c, src/tr.c, src/wc.c: Adjust to renaming of the xsetmode module to xbinary-io, and of the xsetmode function to xset_binary_mode.
2017-02-15maint: use xsetmode, not xfreopenPaul Eggert
This fixes a bug noted by Eric Blake. Code was using xfreopen to change files to binary mode, but this fails for stdout when in append mode. Such code should use xsetmode instead. This affects only the port on platforms like MS-Windows which distiguish text from binary I/O. * bootstrap.conf (gnulib_modules): Remove xfreopen and add xsetmode. Sort. * src/base64.c (main): * src/cat.c (main): * src/cksum.c (cksum): * src/head.c (head_file, main): * src/md5sum.c (digest_file): * src/od.c (open_next_file): * src/split.c (main): * src/sum.c (bsd_sum_file, sysv_sum_file): * src/tac.c (tac_file, main): * src/tail.c (tail_file): * src/tee.c (tee_files): * src/tr.c (main): * src/wc.c (wc_file): Use xsetmode, not xfreopen.
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-11-28tac: fix mem corruption when failing to read non seekable inputsPádraig Brady
This was detected with ASAN, but can also be seen without ASAN with: $ tac - - <&- tac: standard input: read error: Bad file descriptor *** Error in `tac': malloc(): memory corruption: 0x... * src/tac.c (copy_to_temp): Don't close our output stream on (possibly transient) output error, or on input error. (temp_stream): clearerr() on the stream about to be reused, to ensure future stream use is not impacted by transient errors. * tests/misc/tac-2-nonseekable.sh: Add a test case. * NEWS: Mention the bug fix. Fixes http://bugs.gnu.org/25041
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-01-13tac: support an empty (NUL) --separatorPádraig Brady
* doc/coreutils.texi (tac invocation): Mention the NUL delineation with an empty --separator. * src/tac.c (main): Allow an empty separator when -r not specified. * tests/misc/tac.pl: Add test cases. * NEWS: Mention the new feature. Fixes http://bugs.gnu.org/8103
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-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-05-30maint: avoid new coverity warningsPádraig Brady
* src/sync.c (sync_arg): Initialise variable to avoid unitialized access if assert is disabled. * src/head.c (elide_tail_bytes_file): Support this function with ---presume-input-pipe and larger files, which regressed with commit v8.23-47-g2662702. (elide_tail_lines_file): Likewise. * src/dd.c (dd_copy): Explicitly don't try to ftruncate() upon failure to lseek() (the existing check against st_size was already protecting that). * src/factor.c (factor_using_squfof): Assert (only when linting due to performance) to avoid the implication of divide by zero. * src/od.c (read_block): Remove dead code. * src/tac.c (tac_seekable): Likewise. * src/ls.c (gobble_file): 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-02-17maint: prefer STREQ_LEN and STRPREFIX over strncmp in all casesBernhard Voelker
* cfg.mk (sc_prohibit_strncmp): Improve the search pattern: use _sc_search_regexp to find all invocations of strncmp except when used on a macro definition line; just match the function name with an opening parenthesis. Before, the expression missed places where the comparison against 0 was in a subsequent line. * src/system.h (STRNCMP_LIT): Shorten 'literal' to 'lit' to move the whole definition of the macro into one line - thus making sc_prohibit_strncmp pass. (STRPREFIX): Add space before parenthesis. * src/du.c (main): Prefer STREQ_LEN over strncmp. * src/pinky.c (scan_entries): Likewise. * src/tac.c (tac_seekable): Likewise. * src/who.c (scan_entries): Likewise.
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-10-08maint: avoid new signed overflow warning on 32 bitPádraig Brady
Prompted by http://hydra.nixos.org/build/15682577 with GCC 4.8.3 on i686 src/tac.c:557:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] if (bytes_copied < 0) This happens because copy_to_temp() is inlined in tac_nonseekable(), thus reducing the comparison to the bytes_copied variable in copy_to_temp. Now this can't overflow on either 32 or 64 bit due to the protection of the preceding fwrite(). We could use a guard like "if (bytes_copied <= OFF_T_MAX - bytes_read)" to avoid the warning, but rather than a runtime branch, just use an unsigned type to avoid apparent signed overflow on systems where the accumulation is not promoted to unsigned (32 bit size_t, 64 bit off_t). * src/tac.c (copy_to_temp): Increment an unsigned type to avoid the subsequent signed overflow warning.
2014-10-07wc: don't miscount /sys and similar file systemsPaul Eggert
Fix similar problems in head, od, split, tac, and tail. Reported by George Shuklin in: http://bugs.gnu.org/18621 * NEWS: Document this. * src/head.c (elseek): Move up. (elide_tail_bytes_pipe, elide_tail_lines_pipe): New arg CURRENT_POS. All uses changed. (elide_tail_bytes_file, elide_tail_lines_file): New arg ST and remove arg SIZE. All uses changed. * src/head.c (elide_tail_bytes_file): * src/od.c (skip): Avoid optimization for /sys files, where st_size is bogus and st_size == st_blksize. Don't report error at EOF when not optimizing. * src/head.c, src/od.c, src/tail.c: Include "stat-size.h". * src/split.c (input_file_size): New function. (bytes_split, lines_chunk_split, bytes_chunk_extract): New arg INITIAL_READ. All uses changed. Use it to double-check st_size. * src/tac.c (tac_seekable): New arg FILE_POS. All uses changed. (copy_to_temp): Return size of temp file. All uses changed. * src/tac.c (tac_seekable): * src/tail.c (tail_bytes): * src/wc.c (wc): Don't trust st_size; double-check by reading. * src/wc.c (wc): New arg CURRENT_POS. All uses changed. * tests/local.mk (all_tests): Add tests/misc/wc-proc.sh, tests/misc/od-j.sh, tests/tail-2/tail-c.sh. * tests/misc/head-c.sh: * tests/misc/tac-2-nonseekable.sh: * tests/split/b-chunk.sh: Add tests for problems with /proc and /sys files. * tests/misc/od-j.sh, tests/misc/wc-proc.sh, tests/tail-2/tail-c.sh: New files.
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-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-02-20maint: cleanup up various uses of __attribute__Pádraig Brady
* src/cfg.mk (sc_prohibit-gl-attributes): Disallow the __attribute() form without trailing underscores as that is not elided where required. Also ensure we use gnulib macros rather than defining our own. * src/system.h: Remove gnulib provided macros. * src/chown-core.c: Likewise. * src/chroot.c: Likewise. * src/copy.c: Likewise. * src/csplit.c: Likewise. * src/dd.c: Likewise. * src/expr.c: Likewise. * src/extent-scan.c: Likewise. * src/factor.c: Likewise. * src/ls.c: Likewise. * src/od.c: Likewise. * src/paste.c: Likewise. * src/ptx.c: Likewise. * src/sort.c: Likewise. * src/stat.c: Likewise. * src/stty.c: Likewise. * src/system.h: Likewise. * src/tac.c: Likewise. * src/test.c: Likewise. * src/tsort.c: Likewise.
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-05-08maint: fix common spelling errorsKevin Lyda
These were identified using: https://github.com/lyda/misspell-check executed like: git ls-files | misspellings -f - * src/cat.c: Correct a spelling error. * src/comm.c: Likewise. * src/expr.c: Likewise. * src/pr.c: Likewise. * src/tac.c: Likewise. * src/test.c: Likewise. * src/ChangeLog-2005: Likewise. * src/ChangeLog-2007: Likewise. * src/NEWS: Likewise. * src/doc/coreutils.texi: Likewise. * src/lib/ChangeLog-2007: Likewise. * src/man/help2man: Likewise. * src/old/fileutils/ChangeLog-1997: Likewise. * src/old/fileutils/NEWS: Likewise. * src/old/sh-utils/ChangeLog.0: Likewise. * src/old/textutils/ChangeLog: Likewise. * src/tests/misc/comm: Likewise. * src/tests/misc/uniq: Likewise. * src/tests/mv/dir2dir: Likewise. * src/cfg.mk (old_NEWS_hash): update with `make update-NEWS-hash`
2012-04-19maint: tac: use memcpy, not strcpyJim Meyering
* src/tac.c (main): Use memcpy, not strcpy, since we know the length.
2012-03-21maint: use more modern fseeko, rather than fseekJim Meyering
* src/tac.c (temp_stream): Use fseeko, not fseek, on principle: use the more modern interface. In general it is better to avoid fseek due to its ABI-imposed 4GiB limit on the "offset", here its use was fine because the offset was always 0. Using fseeko also has the advantage of not triggering a GNULIB_POSIXCHECK warning. Reported by Eric Blake in http://thread.gmane.org/gmane.comp.gnu.coreutils.general/2426/focus=2489
2012-01-27maint: use single copyright year rangeJim Meyering
Run "make update-copyright".
2012-01-09maint: src/*.c: change remaining quotes (without embedded spaces)Jim Meyering
Run this (twice): git grep -E -l '`[^ ]+'\' src/*.c \ |xargs perl -pi -e 's/`([^ ]+'\'')/'\''$1/'
2012-01-07maint: use new emit_try_help in place of equivalent fprintfJim Meyering
Run this command: perl -0777 -pi -e \ 's/fprintf \(stderr, _\("Try `%s --help.*\n.*;/emit_try_help ();/m'\ src/*.c
2012-01-01maint: update all copyright year number rangesJim Meyering
Run "make update-copyright".
2011-10-19maint: tac: prefer "failed to" diagnostic over "cannot"Jim Meyering
* src/tac.c: Change wording in diagnostic: "failed to open" seems clearer than "cannot open".
2011-10-19tac: do not let failed allocation cause immediate exitJim Meyering
* src/tac.c (temp_stream): Don't exit immediately upon failed heap allocation, here. That would inhibit processing of any additional command-line arguments.
2011-10-19tac: use only one temporary file, with multiple nonseekable inputsJim Meyering
* src/tac.c (temp_stream): New function, factored out of... (copy_to_temp): ...here. (tac_nonseekable): Don't free or fclose, now that we reuse the file. Suggested by Ambrose Feinstein. * THANKS.in: Update.
2011-10-18maint: make tac.c slightly cleanerPaul Eggert
* src/tac.c (copy_to_temp): Now that the template string tacXXXXXX is used in only one place, don't bother using a separate variable. Also, using three unconditional assignments seems slightly clearer.
2011-10-17tac: don't leak a file descriptor for each non-seekable inputJim Meyering
* src/tac.c (tac_nonseekable): Call fclose and free tmp_file after each successful call to copy_to_temp.
2011-10-17tac: don't misbehave with multiple non-seekable inputsJim Meyering
* src/tac.c (copy_to_temp): Do not reuse the template buffer. Instead, scribble only on a freshly-xstrdup'd copy each time. Free that buffer both here, upon failure, and ... (tac_nonseekable): ...free the buffer in caller, upon success. * tests/misc/tac-2-nonseekable: New file. * tests/Makefile.am (TESTS): Add it. * NEWS (Bug fixes): Mention it. Reported by Ambrose Feinstein in http://debbugs.gnu.org/9762.
2011-10-17maint: tac: remove sole use of sprintf in favor of filenamecatJim Meyering
* src/tac.c: Include filenamecat.h. (copy_to_temp): Use filenamecat rather than xmalloc and sprintf. Move some declarations "down" to point of initialization.
2011-05-28maint: remove useless (off_t) cast of lseek argJim Meyering
* src/wc.c (wc): Remove unnecessary cast. * src/head.c (elide_tail_bytes_file, elide_tail_lines_file): Likewise. * src/tac.c (tac_seekable, tac_file): Likewise.
2011-01-01maint: update all copyright year number rangesJim Meyering
Run "make update-copyright".
2010-09-01tac: suppress technically unneeded "free"Jim Meyering
* src/tac.c (main): Guard final free with #ifdef lint. Suggested by Paul Eggert.
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-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-01-05maint: always free a buffer, to avoid even semblance of a leakJim Meyering
* src/tac.c (main): Free the input buffer in most cases.
2010-01-01maint: update all FSF copyright year lists to include 2010Jim Meyering
Use this command: git ls-files | grep -v COPYING \ | xargs env UPDATE_COPYRIGHT_USE_INTERVALS=1 \ build-aux/update-copyright
2009-09-21doc: mention the texinfo documentation in --helpPádraig Brady
* src/system.h: Rename emit_bug_reporting_address() to emit_ancillary_info() and update it to not print the translation project address in en_* locales, and _do_ print it in the 'C' (and other) locales so that it's included in the default man page. Also mention how to invoke the texinfo documentation for each command. Also move the "hard-locale.h" include to the 8 files that now use it. * man/help2man: Strip the newly added texinfo reference from the --help output as a more verbose version is already added by help2man. Suggestion from C de-Avillez
2009-08-25global: convert indentation-TABs to spacesJim Meyering
Transformed via this shell code: t=$'\t' git ls-files \ | grep -vE '(^|/)((GNU)?[Mm]akefile|ChangeLog)|\.(am|mk)$' \ | grep -vE 'tests/pr/|help2man' \ | xargs grep -lE "^ *$t" \ | xargs perl -MText::Tabs -ni -le \ '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
2009-06-23maint: update all Copyright year lists to include 2009Jim Meyering
2008-11-10use xfreopen in place of unchecked freopenJim Meyering
* bootstrap.conf (modules): Add xfreopen. * src/cat.c (main): Include "xfreopen.h". Use xfreopen. * src/cksum.c (cksum): Likewise. * src/head.c (head_file, main): Likewise. * src/md5sum.c (digest_file): Likewise. * src/od.c (open_next_file): Likewise. * src/split.c (type_undef): Likewise. * src/sum.c (bsd_sum_file, sysv_sum_file): Likewise. * src/tac.c (tac_file, main): Likewise. * src/tail.c (tail_file, main): Likewise. * src/tee.c (tee_files): Likewise. * src/tr.c (main): Likewise. * src/wc.c (wc_file): Likewise. * po/POTFILES.in: Add lib/xfreopen.c
2008-08-14mktemp, sort, tac: don't use undefined after mkstemp failureJim Meyering
When mkstemp fails, the template buffer may have undefined contents, so we must not print it. * src/sort.c (create_temp_file): Use temp_dir, not "file" when diagnosing failed mkstemp, because "file" may be undefined. * tests/misc/sort-merge: Adjust for new expected output. Jeph Cowan and Ralf Wildenhues reported the test failure: http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14235/focus=14257 * src/tac.c (copy_to_temp): Don't use template buffer after failed mkstemp call, since its contents may be undefined. * tests/misc/tac (pipe-bad-tmpdir): New test for the above. * src/mktemp.c (main): Save a copy of the template string, solely for use in case mkstemp fails. * tests/misc/mktemp (pipe-bad-tmpdir): New test for the above.
2008-06-16remove redundant const directivesJim Meyering
In 1463824d8e7f72c31f1d803d7cfe2b608ccafc5c, I added some missing "const" directives, as well as some new, redundant ones. This removes the redundant ones. Pointed out by Eric Blake. * base64.c, cat.c, chcon.c, chgrp.c, chmod.c, chown.c, comm.c: * cp.c, csplit.c, cut.c, date.c, dd.c, df.c, dircolors.c, du.c: * env.c, expand.c, fmt.c, fold.c, groups.c, head.c, id.c: * install.c, join.c, kill.c, ln.c, ls.c, md5sum.c, mkdir.c: * mkfifo.c, mknod.c, mktemp.c, mv.c, nice.c, nl.c, od.c: * paste.c, pathchk.c, pinky.c, pr.c, ptx.c, readlink.c, rm.c: * rmdir.c, runcon.c, seq.c, shred.c, shuf.c, sort.c, split.c: * stat.c, stty.c, su.c, sum.c, tac.c, tail.c, tee.c, timeout.c: * touch.c, tr.c, truncate.c, tty.c, uname.c, unexpand.c, uniq.c: * wc.c, who.c: Remove redundant const directives. * maint.mk (sc_const_long_option): Don't require redundant "const".
2008-06-14add "const" attribute, where possibleJim Meyering
* maint.mk (sc_const_long_option): New rule. Enforce global change. * src/base64.c (long_options): Use "const" where possible. * src/cat.c (main): Likewise. * src/chcon.c (long_options): Likewise. * src/chgrp.c (long_options): Likewise. * src/chmod.c (long_options): Likewise. * src/chown.c (long_options): Likewise. * src/comm.c (long_options, OUTPUT_DELIMITER_OPTION): Likewise. * src/cp.c (long_opts): Likewise. * src/csplit.c (longopts): Likewise. * src/cut.c (longopts): Likewise. * src/date.c (long_options): Likewise. * src/dd.c (conversions, flags, statuses): Likewise. * src/df.c (long_options): Likewise. * src/dircolors.c (long_options): Likewise. * src/du.c (long_options): Likewise. * src/env.c (longopts): Likewise. * src/expand.c (longopts): Likewise. * src/fmt.c (long_options): Likewise. * src/fold.c (longopts): Likewise. * src/groups.c (longopts): Likewise. * src/head.c (long_options): Likewise. * src/id.c (longopts): Likewise. * src/install.c (long_options): Likewise. * src/join.c (longopts): Likewise. * src/kill.c (long_options): Likewise. * src/ln.c (long_options): Likewise. * src/ls.c (long_time_format, long_options, sort_functions): Likewise. * src/md5sum.c (long_options): Likewise. * src/mkdir.c (longopts): Likewise. * src/mkfifo.c (longopts): Likewise. * src/mknod.c (longopts): Likewise. * src/mktemp.c (longopts): Likewise. * src/mv.c (long_options): Likewise. * src/nice.c (longopts): Likewise. * src/nl.c (longopts): Likewise. * src/od.c (charname, long_options): Likewise. * src/paste.c (longopts): Likewise. * src/pathchk.c (longopts): Likewise. * src/pinky.c (longopts): Likewise. * src/pr.c (long_options): Likewise. * src/ptx.c (long_options): Likewise. * src/readlink.c (longopts): Likewise. * src/rm.c (long_opts): Likewise. * src/rmdir.c (longopts): Likewise. * src/runcon.c (long_options): Likewise. * src/seq.c (long_options): Likewise. * src/shred.c (long_opts): Likewise. * src/shuf.c (long_opts): Likewise. * src/sort.c (monthtab, long_options): Likewise. * src/split.c (longopts): Likewise. * src/stat.c (long_options): Likewise. * src/stty.c (mode_info, control_info, longopts, set_mode) Likewise. (set_control_char, speeds): Likewise. * src/su.c (longopts): Likewise. * src/sum.c (longopts): Likewise. * src/tac.c (longopts): Likewise. * src/tail.c (long_options): Likewise. * src/tee.c (long_options): Likewise. * src/timeout.c (long_options): Likewise. * src/touch.c (longopts): Likewise. * src/tr.c (long_options): Likewise. * src/truncate.c (longopts): Likewise. * src/tty.c (longopts): Likewise. * src/uname.c (uname_long_options, arch_long_options): Likewise. * src/unexpand.c (longopts): Likewise. * src/uniq.c (longopts): Likewise. * src/wc.c (longopts): Likewise. * src/who.c (longopts): Likewise.