823 Commits

Author SHA1 Message Date
Jim Meyering
7ea9bf381b maint: remove now-useless #if HAVE_HEADER_H guards
* src/system.h: Include <sys/wait.h> unconditionally,
now that gnulib guarantees its presence.
* lib/cmpbuf.c: Likewise for <unistd.h> and <inttypes.h>.
2010-04-30 18:56:14 +02:00
Jim Meyering
59669066e7 tests: use original no-newline-at-eof test, but with -U1, not -U2
* tests/no-newline-at-eof: Revert to the smaller test, but with
-U1 rather than -U2, since that actually triggers the bug.
2010-04-17 08:29:36 +02:00
Paul Eggert
4ba438168d Followon improvements for the fix for Debian bug 577832.
* 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.
2010-04-16 22:20:04 -07:00
Jim Meyering
16e65488dd build: update gnulib submodule to latest 2010-04-16 11:28:46 +02:00
Jim Meyering
6bb3d29008 tests: test for the no-newline-at-EOF bug
* tests/no-newline-at-eof: New file.
* tests/Makefile.am (TESTS): Add it.
2010-04-16 11:28:46 +02:00
Jim Meyering
f444711a26 diff: fix a regression when at least one input lacks a newline-at-EOF,
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.
2010-04-16 11:28:04 +02:00
Jim Meyering
648802169a tests: update init.sh from gnulib
* tests/init.sh: Update from gnulib.
2010-04-16 11:03:34 +02:00
Jim Meyering
4065b154b0 build: include cfg.mk and dist-check.mk in the distribution tarball
* Makefile.am (EXTRA_DIST): Add cfg.mk and dist-check.mk.
2010-04-08 11:09:51 +02:00
Jim Meyering
70a02578ae maint: update to latest gnulib
* cfg.mk (sc_cross_check_PATH_usage_in_tests): Remove rule,
now that it's in gnulib's maint.mk.
* gnulib: Update to latest.
2010-04-08 11:03:09 +02:00
Jim Meyering
0c6d7eea33 tests: make new PATH-crosschecking syntax-check tighter
* cfg.mk (sc_cross_check_PATH_usage_in_tests): Use grep's -x (match
entire line) option with -F.
2010-04-07 11:43:14 +02:00
Jim Meyering
fe2d46d4aa tests: pull latest help-version from gzip
* tests/help-version: Update from gzip.
* Makefile.am (TESTS_ENVIRONMENT): Export VERSION,
as required for this new help-version script.
2010-04-07 11:01:31 +02:00
Jim Meyering
46773b6abb tests: add syntax-check rule to verify that tests use proper PATH
* cfg.mk (sc_cross_check_PATH_usage_in_tests): New rule, that is
useful only in conjunction with the help-version script.
2010-04-07 11:01:31 +02:00
Jim Meyering
55cf264a2b tests: use path_prepend_ consistently; remove unnecessary VERBOSE check
* tests/basic: Likewise.
* tests/binary: Likewise.
* tests/function-line-vs-leading-space: Likewise.
* tests/label-vs-func: Likewise.
* tests/stdin: Likewise.
2010-04-07 11:01:31 +02:00
Eric Blake
eb7d0cc491 maint: ignore generated files
* .gitignore: Ignore recent gnulib additions.
2010-04-06 10:11:35 -06:00
Eric Blake
a7784f93ef maint: update to latest bootstrap
* bootstrap: Copy from gnulib/build-aux.
2010-04-06 10:03:29 -06:00
Jim Meyering
adc5cf557b tests: get latest init.sh from gnulib
* tests/init.sh: Update from gnulib.
2010-04-05 22:19:57 +02:00
Jim Meyering
c5b10cdca9 build: update gnulib submodule to latest; adapt
* cfg.mk (local-checks-to-skip): Add new sc_texinfo_acronym, to skip it.
2010-04-05 22:19:57 +02:00
Jim Meyering
eb8258b8c6 diff -F/-p: don't depend on locale-specific white-space definition
* src/context.c: Include "c-ctype.h".
Use c_isspace, not isspace.
2010-04-05 22:19:49 +02:00
Jim Meyering
f21d1195ae tests: exercise new behavior of -F RE
* tests/function-line-vs-leading-space: New file.
* tests/Makefile.am (TESTS): Add it.
2010-03-18 18:05:10 +01:00
Yannick Moy
24cc227fa1 with -F or -p, emit better function lines: no leading white space
* 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.
2010-03-18 17:35:38 +01:00
Jim Meyering
d9c2b10e33 build: don't require a specific version of help2man
* bootstrap.conf (buildreq): Bootstrap can't deal with it,
perhaps because the command name contains a digit.
2010-03-17 16:53:17 +01:00
Jim Meyering
61fb56b314 build: make bootstrap ensure that help2man is available
* bootstrap.conf (buildreq): Add help2man.
2010-03-17 15:52:05 +01:00
Jim Meyering
1afa803849 tests: test for the "Binary files A and B differ" diagnostic
* tests/binary: New script.
* tests/Makefile.am (TESTS): Add it.
2010-02-23 10:29:02 +01:00
Jim Meyering
3f591f4bb5 revert 2002 change that removed "Binary " from "files A and B differ"
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.
2010-02-23 09:28:19 +01:00
Juan Manuel Guerrero
aa56d5f6d0 avoid compilation failure on systems lacking both fork and vfork
* 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.
2010-02-14 18:16:25 +01:00
Jim Meyering
9999d0b8df post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2010-02-11 11:09:01 +01:00
Jim Meyering
66f2f2d60a version 2.9
* NEWS: Record release date.
v2.9
2010-02-11 10:45:20 +01:00
Jim Meyering
fecd0079fe doc: document the release procedure
* README-release: New file.
2010-02-11 10:43:14 +01:00
Jim Meyering
9f735dd16a maint: change use of "|" to more maintainable "||" (no semantic change)
* 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.
2010-02-10 11:38:56 +01:00
Jim Meyering
b50a16567a portability: avoid "diff - ..." failure at least on *BSD and Solaris
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".
2010-02-10 09:11:33 +01:00
Jim Meyering
b22f6671d7 tests: honor VERBOSE
* tests/basic: Enable "set -x" if $VERBOSE.
* tests/help-version: Likewise.
* tests/label-vs-func: Likewise.
* tests/stdin: Likewise.
2010-02-10 08:55:59 +01:00
Jim Meyering
a1dcb61f03 build: update gnulib submodule to latest 2010-02-05 07:46:44 +01:00
Jim Meyering
3c0aac1e7e sync with gnulib
* gl/lib/regcomp.c.diff: Adjust to apply to the latest in gnulib.
* gnulib: Update submodule to latest.
2010-02-05 07:43:37 +01:00
Jim Meyering
6bb6713807 build: do not override gnulib-provided AM_CFLAGS options
Avoid a warning from automake:
lib/Makefile.am:23: AM_CFLAGS multiply defined in condition TRUE ...
lib/gnulib.mk:30: ... `AM_CFLAGS' previously defined here
lib/Makefile.am:18:   `lib/gnulib.mk' included from here

* lib/Makefile.am (AM_CFLAGS): Append $(WARN_CFLAGS) and
$(WERROR_CFLAGS), i.e., use "+=", not "=".
This was introduced via 2009-12-17 commit e58efa5b
"build: enable warnings and -Werror.",
but fortunately is not a bug, because the definition
it would have overridden was always empty.
2010-02-04 20:03:03 +01:00
Jim Meyering
f51320402b maint: add to .gitignore
* .gitignore: Ignore more.
2010-01-17 11:16:24 +01:00
Jim Meyering
ef2251a3e5 doc: add to TODO
* TODO: Add an item, suggested by Dan Jacobson.
2010-01-16 08:32:06 +01:00
Jim Meyering
07e844a96d tests: ensure that an argument of "-" is treated as standard input
* tests/stdin: New test.
* tests/Makefile.am (TESTS): Add it.
2010-01-13 13:54:55 +01:00
Jim Meyering
2d648ae3fe tests: now "make distcheck" runs more tests, incl. syntax-check
* cfg.mk: Include dist-check.mk, from coreutils.
* Makefile.am (distcheck-hook): Define rule, to hook to...
* dist-check.mk: New file.
2010-01-10 11:45:20 +01:00
Jim Meyering
617600b422 build: update gnulib to latest, for fixed syntax-check rule 2010-01-09 11:48:57 +01:00
Jim Meyering
a5188c6f72 maint: record updated NEWS hash
* cfg.mk (old_NEWS_hash): Update to account for GFDL change.
2010-01-09 11:18:46 +01:00
Jim Meyering
a9d7c6d1a5 build: update gnulib submodule to latest 2010-01-09 11:07:25 +01:00
Jim Meyering
4e1233f063 tests: add a test of basic functionality
* tests/basic: Start adding tests.
* tests/Makefile.am (TESTS): Add it.
2010-01-09 11:07:25 +01:00
Jim Meyering
cadd497e27 maint: udpate GFDL license to 1.3
* doc/diff.texi: Update to use GFDL version 1.3.
2010-01-09 11:06:17 +01:00
Eric Blake
cb251009d3 build: allow compilation on cygwin
* src/Makefile.am (cmp_LDADD): Move LIBICONV...
(LDADD): ...into global flags, since all programs need it.
2010-01-04 05:56:43 -07:00
Jim Meyering
b20ae152dd maint: record update-copyright options for this package
* cfg.mk: Next time, just run "make update-copyright".
2010-01-03 18:54:21 +01:00
Jim Meyering
a6b73e6dd7 tests: prepend ../src, not "." to PATH
* tests/help-version: Correct PATH.
2010-01-03 18:40:33 +01:00
Jim Meyering
6a44886e24 maint: update all FSF copyright year lists to include 2010
Use this command:
git ls-files |grep -vE '^(\..*|COPYING|gnulib)$' |xargs \
env UPDATE_COPYRIGHT_USE_INTERVALS=1 build-aux/update-copyright
2010-01-01 16:18:27 +01:00
Jim Meyering
10d11122ea maint: newer gnulib; don't hard-code my GPG key ID
* cfg.mk (gpg_key_ID): Remove definition, now that maint.mk automates it.
* gnulib: Update to latest.
2009-12-31 17:30:54 +01:00
Jim Meyering
9fe26edf84 tests: exercise diff -p's function-name matching
* tests/label-vs-func: New file.
* tests/Makefile.am (TESTS): Add label-vs-func.
Reported by Simon Arlott <simon@fire.lp0.eu>
http://article.gmane.org/gmane.linux.kernel.janitors/14260
2009-12-31 17:30:50 +01:00
Jim Meyering
e0fc06c5ce tests: use gnulib's init.sh
* tests/Makefile.am (EXTRA_DIST): Add init.sh.
Remove test-lib.sh.
* tests/init.sh: New file.
* tests/test-lib.sh: Remove file.
* tests/help-version: Use init.sh, not test-lib.sh.
2009-12-31 17:29:55 +01:00