summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* main: port subcommands to mingwPaul Eggert2012-05-143-67/+32
| | | | | | | | | | | | | | | | | | | Problem reported by Eli Zaretskii in <http://lists.gnu.org/archive/html/bug-gnu-utils/2012-05/msg00013.html>. Approach suggested by Bruno Haible as option (4) in <http://lists.gnu.org/archive/html/bug-gnu-utils/2012-05/msg00036.html>. * bootstrap.conf (gnulib_modules): Add system-quote. * src/diff3.c, src/sdiff.c, src/util.c: Include <system-quote.h>, not <sh-quote.h>. * src/diff3.c (read_diff): * src/sdiff.c (main, edit): * src/util.c (begin_output): Use system_quote_argv, for portability to Mingw. * src/sdiff.c (NUM_SIGS, handler_index_of_SIGINT): Now enum values, not macros; this is cleaner and avoids a GCC warning if !HAVE_WORKING_VFORK. * src/util.c (begin_output) [! HAVE_WORKING_FORK]: Do not use -f, for consistency with the HAVE_WORKING_FORK code.
* Use binary mode when testing for binary files.Paul Eggert2012-05-143-9/+24
| | | | | | | | | | | | | This reverts the 2006-01-05 change and modernizes to the current API. Idea suggested by Eli Zaretskii in: http://lists.gnu.org/archive/html/bug-gnu-utils/2012-05/msg00066.html * src/cmp.c (main): * src/diff.c (main, compare_files): Use set_binary_mode rather than SET_BINARY. * src/diff.c (compare_files): Omit unnecessary use of O_BINARY. * src/io.c (sip): Sample unknown files in binary mode, to see whether they are binary. (read_files): Read binary files in binary mode.
* diff: fix a typo that was always disabling the same_special_file macroJim Meyering2012-05-051-1/+1
| | | | | * src/system.h (same_special_file): Correct cpp guard expression: s/HAVE_ST_RDEV/HAVE_STRUCT_STAT_ST_RDEV/. Reported by Eli Zaretskii.
* usage: improve wording of --ignore-matching-linesEric Blake2012-03-071-2/+2
| | | | * src/diff.c (option_help_msgid): Tweak wording.
* doc: explain -I RE better in --help outputPaul Eggert2012-03-042-2/+2
| | | | | | | * src/diff.c, src/sdiff.c (option_help_msgid): For -I RE, change "whose lines all match" to "all whose lines match" to avoid unintended interpretation. Reported by Danijel Tasov in <http://bugs.debian.org/648411>.
* sdiff: remove dependency on sigprocmaskPaul Eggert2012-02-121-9/+0
| | | | | | * bootstrap.conf (gnulib_modules): Remove sigprocmask. * src/sdiff.c (temporary_file): No need to invoke sigprocmask here, since the signal handler merely sets a flag.
* diff: -N, --unidirectional-new-file now compare to "-" tooPaul Eggert2012-02-041-9/+7
| | | | | | | | | | | * NEWS: Document this. * doc/diffutils.texi (Comparing Directories): Likewise. Also, document that these options work at the top level. * src/diff.c (compare_files): Treat EBADF like ENOENT, to handle the case where "-" is closed. Allow the other file to be STDIN_FILENO, in case it's "-". * tests/Makefile.am (TESTS): Add new-file. * tests/new-file: New file.
* maint: quote 'like this' or "like this", not `like this'Paul Eggert2012-01-2513-91/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | This is in response to a recent change in the GNU coding standards, which now suggest quoting 'like this' or "like this", instead of `like this' or ``like this''. * HACKING, NEWS, README, README-hacking, TODO, doc/diagmeet.note: * doc/diffutils.texi, ms/config.bat, ms/config.site: * src/analyze.c, src/cmp.c, src/context.c, src/diff.c: * src/diff.h, src/diff3.c, src/dir.c, src/ifdef.c, src/io.c: * src/sdiff.c, src/side.c, src/system.h, src/util.c: * tests/help-version: Quote 'like this' or "like this" in commentary. * cfg.mk (old_NEWS_hash): Adjust to reflect new NEWS quoting. * man/help2man: Update to 1.40.4 version, with quoting fixed as above. * po/en.po: Remove translation involving `, as it's no longer needed. * src/cmp.c (try_help, specify_ignore_initial, usage, main): * src/diff.c (main, try_help, option_help_msgid, specify_value) (compare_files): * src/diff3.c (main, try_help, option_help_msgid, usage) (read_diff): * src/dir.c (compare_names): * src/sdiff.c (try_help, usage, check_child_status, main): * src/util.c (finish_output): * tests/help-version: Quote 'like this' in output.
* maint: avoid new syntax-check failureJim Meyering2012-01-121-1/+1
| | | | * src/diff.c (compare_files): Use STREQ, not strcmp.
* New option --no-dereference.Bruno Haible2012-01-082-4/+74
| | | | | | | | | | | | | | | * src/diff.h (no_dereference_symlinks): New variable. * src/diff.c: Include xreadlink.h. (longopts): Add --no-dereference option. (main): Accept --no-dereference option. (option_help_msgid): Mention the --no-dereference option. (compare_files): If no_dereference_symlinks is true, use lstat() instead of stat(). Compare symbolic links by comparing their values. * bootstrap.conf (gnulib_modules): Add lstat, stat, xreadlink. * doc/diffutils.texi (Comparing Directories, diff Options): Mention the --no-dereference option. * tests/no-dereference: New file. * tests/Makefile.am (TESTS): Add it.
* maint: update all copyright year number rangesJim Meyering2012-01-0116-16/+16
| | | | Run "make update-copyright".
* build: update to latest gnulib and adaptJim Meyering2011-12-146-8/+8
| | | | | | | | | | | | | | | | | * tests/binary: Reverse arguments to compare to avoid failure of new syntax-check rule. * configure.ac: Use -Wno-format-nonliteral. Mark functions as pure of const, per recommendations enabled by new gcc -W options. Use _GL_ATTRIBUTE_PURE and _GL_ATTRIBUTE_CONST. * lib/cmpbuf.h (buffer_lcm, block_compare): Apply pure and/or const attributes. * src/cmp.c (block_compare): Likewise. * src/context.c (find_hunk): Likewise. * src/diff.h (lines_differ): Likewise. * src/diff3.c (skipwhite): Likewise. * src/dir.c (dir_loop): Likewise. * src/util.c (find_change, find_reverse_change): Likewise. (translate_line_number): Likewise.
* portability: use SET_BINARY rather than xfreopen (NULL, ...Claudio Bley2011-10-042-5/+5
| | | | | | | * src/diff.c: Include binary-io.h, not xfreopen.h. (main): Use SET_BINARY (...) rather than xfreopen (NULL, X, ...), because the latter doesn't work on MinGW and crashes using MSVC. * src/cmp.c (main): Likewise.
* maint: avoid new "make sytnax-check" failure.Jim Meyering2011-08-151-1/+1
| | | | | * src/diff.h (find_dir_file_pathname): Mark declaration with "extern" keyword, in order to placate the tight-scope syntax check.
* * src/io.c (find_and_hash_each_line): Refactor for brevity.Paul Eggert2011-08-141-158/+77
|
* diff, sdiff: new option --ignore-trailing-space (-Z)Roland McGrath2011-08-145-55/+150
| | | | | | | | | | | | | | Derived from Roland McGrath's patch (dated June 2004!) in: http://lists.gnu.org/archive/html/bug-gnu-utils/2004-07/msg00000.html * NEWS: * doc/diffutils.texi (White Space, Blank Lines) (sdiff Option Summary, diff Options, sdiff Options): Document -Z. * src/diff.h (IGNORE_TRAILING_SPACE) (IGNORE_TAB_EXPANSION_AND_TRAILING_SPACE): New constants, for -Z. * src/diff.c (shortopts, longopts, main, option_help_msgid): * src/sdiff.c (longopts, option_help_msgid, main): * src/io.c (find_and_hash_each_line): * src/util.c (lines_differ, analyze_hunk): Support -Z.
* diff: --ignore-file-name-case now applies at top level tooTim Waugh2011-08-133-1/+48
| | | | | | | | | | | Derived from Tim Waugh's patch in: http://lists.gnu.org/archive/html/bug-diffutils/2011-08/msg00034.html * NEWS, doc/diffutils.texi (diff Options): Document this. * src/diff.c (compare_files): Implement this, by using find_dir_file_pathname. * src/diff.h (find_dir_file_pathname): New decl. * src/dir.c: Include filenamecat.h. (find_dir_file_pathname): New function.
* doc: insert comma in --help line for --ignore-space-change (-b)Santiago Vila2011-08-081-1/+1
| | | | | * src/diff.c (option_help_msgid): Insert omitted comma between "-b" and "--ignore-space-change". (tiny change)
* maint: remove inclusion of unused header, for "make syntax-check"Jim Meyering2011-07-032-2/+0
| | | | | * src/diff3.c: Don't include <inttostr.h>. Not used. * src/context.c: Likewise.
* build: ccache works better without embedded version stringsJim Meyering2011-06-136-4/+27
| | | | | | | | | | | | | * src/Makefile.am: Generate version.c and version.h and put the new symbol in a tiny library to be used by each program. (LDADD): Add the new library. * src/cmp.c (main): Use Version, not PACKAGE_VERSION, so the .o file does not change with each commit-derived version increment. * src/diff.c (main): Likewise. * src/diff3.c (main): Likewise. * src/sdiff.c (main): Likewise. * src/system.h: Include "version.h". * .gitignore: Add version.[ch]
* cmp, diff, diff3, sdiff: edit and align --help text.Karl Berry2011-06-084-103/+146
| | | | | | | | * cmp.c (option_help_msgid, usage), * diff.c (option_help_msgid, usage), * diff3.c (option_help_msgid, usage), * sdiff.c (option_help_msgid, usage): align descriptions in the --help output and slightly edit content.
* diff: don't use locales after local-specific sorting failsPaul Eggert2011-05-271-3/+1
| | | | | | | * src/dir.c (compare_names): Don't invoke strcasecmp if locale-specific sorting fails, because POSIX.1-2008 says strcasecmp has unspecified behavior outside the POSIX locale. See: http://lists.gnu.org/archive/html/bug-diffutils/2011-05/msg00008.html
* maint: prepare for the tight-scope checkJim Meyering2011-05-182-39/+45
| | | | | | | | | | * src/diff.h: Mark function declarations with "extern" in preparation for the tight-scope check. (ignore_white_space): Separate enum decl from declaration of this variable. * src/Makefile.am (diff_SOURCES): Move diff.h from here to ... (noinst_HEADERS): ...here. For convenience, since the tight-scope rule uses $(noinst_HEADERS).
* docs: diff --help should mention -LEric Blake2011-03-181-1/+1
| | | | * src/diff.c (option_help_msgid): Document -L.
* maint: remove all uses of vfork: use fork insteadJim Meyering2011-01-244-52/+14
| | | | | | | | | | | | | Our use of vfork now provokes warnings from gcc-4.6.0. Also, vfork is no longer even specified by POSIX.1-2008. * src/diff3.c (read_diff): Change each use of vfork to "fork". Remove #ifdef'd code. * src/util.c (begin_output, finish_output): Likewise. * src/sdiff.c (cleanup, main, edit): Likewise. (handler_index_of_SIGPIPE): Remove now-unused definition. * src/system.h: Don't include <vfork.h>. (vfork): Remove definition. * ms/config.site: Remove reference to vfork cache variable.
* maint: avoid new syntax-check failureJim Meyering2011-01-232-2/+2
| | | | | * src/diff.c (specify_value): Use !STREQ(...), not strcmp(...) != 0. * src/diff3.c (main): Likewise.
* maint: update copyright year ranges to include 2011Jim Meyering2011-01-0316-16/+16
| | | | Run "make update-copyright", so "make syntax-check" works in 2011.
* maint: avoid shadowing warningJim Meyering2010-09-041-3/+3
| | | | * src/dir.c (diff_dirs): Rename shadowed local cmp to "c".
* diff -r: avoid printing excess slashes in concatenated file namesJim Meyering2010-08-143-16/+4
| | | | | | | | | | | | * bootstrap.conf (gnulib_modules): Add filenamecat. * src/diff.c: Include "filenamecat.h". (compare_files): Use file_name_concat, rather than dir_file_pathname. * src/util.c (dir_file_pathname): Remove now-unused function. * src/diff.h: Remove its declaration. * tests/excess-slash: New script to test for this. * tests/Makefile.am (TESTS): Add it. Forwarded by Santiago Vila from <bugs.debian.org/586301a>, reported by Jari Aalto.
* diff: avoid spurious diffs when two distinct dir entries compare equalPaul Eggert2010-08-121-2/+39
| | | | | | | | | | | | Problem reported by Christoph Anton Mitterer in: http://lists.gnu.org/archive/html/bug-diffutils/2010-08/msg00000.html * NEWS: Mention this bug fix. * src/dir.c (compare_names_for_qsort): Fall back on file_name_cmp if two distinct entries in the same directory compare equal. (diff_dirs): Prefer a file_name_cmp match when available. * tests/Makefile.am (TESTS): New test colliding-file-names. * tests/colliding-file-names: New file.
* build: don't define macros that gnulib providesJim Meyering2010-05-091-13/+0
| | | | | | | | | * bootstrap.conf (gnulib_modules): Add signal, stdint. * lib/cmpbuf.c (SA_RESTART, SA_INTERRUPT): Remove definitions. (SIZE_MAX, PTRDIFF_MAX): Likewise. Include <stdint.h>. * src/system.h (WEXITSTATUS, WIFEXITED): Remove definitions. (SA_RESTART, SA_INTERRUPT): Likewise.
* build: rely on gnulib's sigprocmask moduleJim Meyering2010-05-091-23/+0
| | | | | * src/sdiff.c: Remove #if-!HAVE_SIGPROCMASK-guarded code. * bootstrap.conf (gnulib_modules): Add sigprocmask.
* maint: remove now-useless #if HAVE_HEADER_H guardsJim Meyering2010-04-301-3/+1
| | | | | | * src/system.h: Include <sys/wait.h> unconditionally, now that gnulib guarantees its presence. * lib/cmpbuf.c: Likewise for <unistd.h> and <inttypes.h>.
* Followon improvements for the fix for Debian bug 577832.Paul Eggert2010-04-161-13/+9
| | | | | | | * src/io.c (find_and_hash_each_line): Omit the inserted newline in a simpler way. * tests/no-newline-at-eof: Fix the test case so that it rejects the old, buggy behavior.
* diff: fix a regression when at least one input lacks a newline-at-EOF,Jim Meyering2010-04-161-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and the final hunk plus context-length aligns exactly with the end of the newline-lacking file. Diff would fail to output the required "\ No newline at end of file" line, thus rendering the output invalid. This bug appears to have been introduced by 2006-05-07 commit 58d0483b, "(find_identical_ends): Fix huge performance bug...", at least to the extent that reverting that change fixes the bug. Considering the stated effect of that change and lack of metrics, reverting it is not an option, so here we take a more direct approach. Given these inputs, printf '\n1'>a; printf '\n0\n\n1'>b and running diff like this: ./diff -U1 a b for input file "b", the pointer, files[1].linbuf[4][-1], to the last byte on the final line was mistakenly pointing at the sentinel newline at EOF, rather than at the preceding byte. (gdb) p files[1].linbuf[4][-1] $3 = 10 '\n' Thus, this test in the final print_1_line call: if ((!line_flag || line_flag[0]) && limit[-1] != '\n') fprintf (out, "\n\\ %s\n", _("No newline at end of file")); would fail, because limit[-1] (which is files[1].linbuf[4][-1]) was mistakenly '\n', rather than the desired '1'. My first thought was simply to adjust the final linbuf[line] setting, at the end of io.c's find_and_hash_each_line function function: if (p == bufend) - break; + { + if (current->missing_newline) + --linbuf[line]; + break; + } But that would make diff misbehave with this input (same as above, but with a newline appended to "a"), printf '\n1\n'>a; printf '\n0\n\n1'>b ./diff -U1 a b due to the block (100 lines above) that is triggered in that case (but not in the both-files-missing-newline case): if (p == bufend && current->missing_newline && ROBUST_OUTPUT_STYLE (output_style)) { /* This line is incomplete. If this is significant, put the line into buckets[-1]. */ if (ignore_white_space < IGNORE_SPACE_CHANGE) bucket = &buckets[-1]; /* Omit the inserted newline when computing linbuf later. */ p--; bufend = suffix_begin = p; } Note how "p" is decremented and "bufend" adjusted. When that happens, we certainly don't want to decrement "bufend" yet again. Since there is no other way to determine at the end whether "bufend" was already decremented, add a new variable to serve as witness. * NEWS (Bug fixes): Mention it. Reported by Timo Juhani Lindfors in http://bugs.debian.org/577832. Forwarded by Santiago Vila.
* diff -F/-p: don't depend on locale-specific white-space definitionJim Meyering2010-04-051-2/+3
| | | | | * src/context.c: Include "c-ctype.h". Use c_isspace, not isspace.
* with -F or -p, emit better function lines: no leading white spaceYannick Moy2010-03-181-5/+7
| | | | | | | | | | * src/diff.c (print_context_function): For languages like Ada that allow local functions and procedures, the plain context function line may start with enough blank characters that the function name does not get completely printed in the 40 characters limit. This patch solves this problem by removing these useless initial blank characters. * NEWS (Changes in behavior): Mention this change.
* revert 2002 change that removed "Binary " from "files A and B differ"Jim Meyering2010-02-231-3/+8
| | | | | | | | | | | With this change, "printf '\0'|diff - /dev/null" now prints "Binary files - and /dev/null differ" once again. This reverts 2002-06-28 commit a352f0980, "(briefly_report): Don't say "Binary files differ", ...". * src/analyze.c (briefly_report): Do include the "Binary " prefix in the diagnostic, when !brief. * NEWS (Changes in behavior): Mention the diagnostic change. Reported by Andreas Hoenen in http://bugs.debian.org/570064.
* avoid compilation failure on systems lacking both fork and vforkJuan Manuel Guerrero2010-02-142-2/+2
| | | | | | | * src/sdiff.c [!HAVE_WORKING_FORK && !HAVE_WORKING_VFORK] (main): Pass the right number of arguments to shell_quote_copy. * src/util.c [!HAVE_WORKING_FORK && !HAVE_WORKING_VFORK] (begin_output): Likewise.
* maint: change use of "|" to more maintainable "||" (no semantic change)Jim Meyering2010-02-101-1/+1
| | | | | | | | * src/analyze.c (diff_2_files): Using the "||" operator happens to be equivalent to using "|" in this case. It is also clearer and less prone to inadvertent bug introduction, in case the variable, "changes" were ever to take on a value not in {0,1}. Patch by Tim Waugh, via Mike Frysinger.
* portability: avoid "diff - ..." failure at least on *BSD and SolarisJim Meyering2010-02-101-1/+1
| | | | | | | The new "stdin" test was failing on many types of systems. * src/diff.c (compare_files): Guard use of xfreopen (NULL, "rb", ... also with O_BINARY, so as to avoid this unnecessary call on systems where it's not needed (on some it fails with "Bad address".
* build: allow compilation on cygwinEric Blake2010-01-041-1/+2
| | | | | * src/Makefile.am (cmp_LDADD): Move LIBICONV... (LDADD): ...into global flags, since all programs need it.
* maint: update all FSF copyright year lists to include 2010Jim Meyering2010-01-0116-18/+18
| | | | | | Use this command: git ls-files |grep -vE '^(\..*|COPYING|gnulib)$' |xargs \ env UPDATE_COPYRIGHT_USE_INTERVALS=1 build-aux/update-copyright
* build: enable warnings and -Werror.Jim Meyering2009-11-221-0/+1
| | | | | | | | * src/Makefile.am (AM_CFLAGS): Enable warnings and -Werror. Set to this: $(WARN_CFLAGS) $(WERROR_CFLAGS) * lib/Makefile.am (AM_CFLAGS): Similarly, but use this: $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) * configure.ac (GNULIB_WARN_CFLAGS): Don't turn off -Wuninitialized.
* build: fix test run on cygwinEric Blake2009-11-201-1/+1
| | | | | | | | This, plus a gnulib update for xalloc-die-tests, are necessary for make check to pass on cygwin. * tests/Makefile.am (built_programs): Ignore $(EXEEXT). * src/Makefile.am (paths.h): Add missing dependency.
* maint: remove vestiges of nanosleepJim Meyering2009-11-201-2/+1
| | | | | | * src/Makefile.am (LDADD): Remove $(LIB_NANOSLEEP), now that we no longer use the nanosleep module. Spotted by Eric Blake.
* build: link with now-required librariesJim Meyering2009-11-201-2/+12
| | | | | * src/Makefile.am (LDADD): Add gnulib-required libraries. (cmp_LDADD): Add $(LIBICONV), for cmp's use of proper_name_utf8.
* build: suppress warnings about bindtextdomain and textdomainJim Meyering2009-11-201-0/+6
| | | | * src/system.h (bindtextdomain, textdomain) [!ENABLE_NLS]: Define away.
* use xfreopen rather than freopenJim Meyering2009-11-203-7/+9
| | | | | | | | | * src/cmp.c: Include "xfreopen.h". Use xfreopen in place of freopen. * src/diff.c Likewise, and... (main): Set exit_failure to EXIT_TROUBLE, rather than to 2. * src/diff3.c: Likewise. * bootstrap.conf (gnulib_modules): Add xfreopen.
* maint: add an assertion to suppress clang-detected warningJim Meyering2009-11-201-2/+6
| | | | | | | | The clang static analyzer reported that a NULL parent could be dereferenced. However, that cannot happen, because for all callers, the parameter, parent, is always non-NULL at that point. * src/diff.c: Include <assert.h>. Assert that parent is not NULL.