97 Commits

Author SHA1 Message Date
Jim Meyering
bbc1bdb771 maint: update copyright dates 2026-01-02 16:52:26 -08:00
Paul Eggert
33ce4260b8 diff: tweak -q, -s doc
Problem reported by Dan Jacobsen (bug#79959).
* src/diff.c (option_help_msgid): Tweak.
2025-12-07 09:41:44 -08:00
Jim Meyering
dfaa846f09 doc: rewrite the "Unusual File Names" section
* doc/diffutils.texi (Unusual File Names): Rewrite to reflect
that file names with e.g., NL and TAB are now quoted.
Reported by Matěj Cepl in <https://bugs.gnu.org/68695>.
2025-01-05 11:43:53 -08:00
Jim Meyering
d65b41664a maint: update all copyright dates via "make update-copyright" 2025-01-03 09:47:07 -08:00
Jim Meyering
6c88db1f7b maint: make update-copyright 2024-01-05 09:01:59 -08:00
Paul Eggert
71fd20c222 diff: prefer openat+fstat more often
This closes some more races, by using openat+fstat instead
of fstatat+openat which can get confused by some other process
renaming files in the meantime.  Not all races are closed of course.
* bootstrap.conf (gnulib_modules): Add d-type.
* src/diff.c (errno_encode, errno_decode): Remove, as file
descriptors are no longer portmanteau variables.  All uses removed.
(detype_from_mode): New function.
(dir_p): Use detype, not stat.st_mode.
(compare_files): New args DETYPE0 and DETYPE1.  All uses changed.
Update detype and err as new info arrives.
Adjust to desc's new use (no longer encodes errno).
Do not ignore lseek failures on regular files.
Prefer openat+fstat to fstatat+openat when detype shows that it's safe,
and avoid both fstat and fstatat if detype suffices.
Use ‘error’ with errno value rather than setting error
and then calling perror_with_name.  Coalesce two of these
error diagnostics into one by moving an error check before
the diagnostic is output.  Coalesce two calls to diff_dirs.
Print file type based on detype if available,
in case neither fstat nor fstatat was called.
* src/diff.h (enum detype): New type.
(struct file_data): New slots err, detype.
(NONEXISTENT, UNOPENED): Renumber so that -1 stands for open failed.
* src/dir.c (HAVE_STRUCT_DIRENT_D_TYPE): Default to false.
(dir_read): Return to caller the d_type, if available.
 	(diff_dirs): Pass detype to compare_files.
2023-08-05 11:01:41 -07:00
Paul Eggert
856f72409b doc: document tab behavior better
* doc/diffutils.texi (Tabs): Document issues with tabs,
encoding errors, and non-ASCII characters.
2023-07-17 15:34:05 -07:00
Paul Eggert
a542ab269a diff: support multi-byte comparison
* bootstrap.conf (gnulib_modules): Add c32isspace, c32tolower.
* lib/Makefile.am (noinst_HEADERS): Add mbcel.h.
(libdiffutils_a_SOURCES): Add mbcel.c
* lib/mbcel.c, lib/mbcel.h: New files.
* src/io.c: Include mbcel.h, uchar.h.
(hash): 2nd arg is now hash_value, not merely unsigned char,
since the caller might pass a char32_t now.
(find_and_hash_each_line): Support multi-byte input.
* src/util.c: Include mbcel.h, uchar.h.
(lines_differ): New args S1LEN, S2LEN, needed for mbcel_scan.
Caller changed.  Support multi-byte input.
* tests/ignore-case: New file.
* tests/Makefile.am (TESTS): Add it.
* tests/ignore-tab-expansion: Add UTF-8 test.
* tests/init.cfg (require_utf8_locale_): New function.
* tests/side-by-side: Use it.  Add a column-counting test.
2023-07-09 01:19:45 -07:00
Paul Eggert
ef5e8e03a8 cmp: make -bl locale-independent again
* src/cmp.c (sprintc): Use c_isprint, not isprint, fixing a bug I
introduced in 2004.
* tests/cmp: Test for the bug.
2023-06-26 18:51:54 -07:00
Bruno Haible
93c20ba3c0 build: Ensure that makeinfo ≥ 6.8 checks the @menu structure
See <https://lists.gnu.org/r/bug-texinfo/2023-06/msg00015.html>.

* doc/Makefile.am (MAKEINFO): New variable.
* cfg.mk (_makefile_at_at_check_exceptions): New variable.
2023-06-24 17:52:51 -07:00
Paul Eggert
77722b5c59 doc: mention new SI prefixes
* doc/diffutils.texi (cmp Options): Update for new SI prefixes R and Q.
Simplify the intro to be more like coreutils.
2023-06-20 15:50:20 -07:00
Jim Meyering
47a1f46f08 maint: update copyright dates 2023-01-01 17:19:37 -08:00
Jim Meyering
aec523d3a4 maint: make update-copyright 2022-01-03 11:49:11 -08:00
Paul Eggert
76f518677b doc: copy fdl.texi into git
This pacifies this notice from ./bootstrap: “Notice from module
fdl: Don't use this module! Instead, copy the referenced license
file into your version control repository.”
* bootstrap.conf (gnulib_modules): Remove fdl.
* doc/fdl.texi: New file, taken from Gnulib.
2021-10-16 01:11:15 -07:00
Jim Meyering
22fb055cca maint: update all copyright year number ranges
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.
2021-01-01 17:37:49 -08:00
Jim Meyering
2280c5b4a5 doc: correct an ancient "At present"
* doc/diffutils.texi (Unified Format): Correct the now
seriously outdated "At present" (referring to early 1990s)
statement to be more of a historical note.
Reported by Roland Illig in http://bugs.gnu.org/39184.
2020-01-19 08:48:21 -08:00
Jim Meyering
351f87d0c4 maint: update all copyright year number ranges
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.
2020-01-01 09:33:03 -08:00
Paul Eggert
2c9d956aac diff: remove unportable ‘diff -N - f <&-’ feature
* NEWS: Mention this.
* bootstrap.conf (gnulib_modules): Add stdopen.
* doc/diffutils.texi (Comparing Directories):
Do not document behavior if stdin is closed.
* src/diff.c: Include stdopen.h.
(main): Call stdopen early.
(compare_files) [__hpux]: Remove recently-introduced
special case for HP-UX exec with stdin closed.
* tests/new-file: Remove tests of the removed feature.
2019-01-05 19:20:36 -08:00
Jim Meyering
197d7d492f maint: update all copyright dates via "make update-copyright"
* gnulib: Also update submodule for its copyright updates.
2019-01-01 19:02:28 -08:00
Jim Meyering
4a38f715f1 maint: update gnulib and copyright dates for 2018
* gnulib: Update to latest.
* all files: Run "make update-copyright".
* bootstrap: Update from gnulib.
2018-01-06 16:51:19 -08:00
Jim Meyering
c881afb9b8 maint: stop using @acronym{...} in texinfo sources
* doc/diffutils.texi: Remove all uses of @acronym{...},
per recommendation by Karl Berry.
* cfg.mk (local-checks-to-skip): Remove exemption, enabling
the @acronym{-prohibiting syntax-check rule.
2017-05-06 12:24:42 -07:00
Paul Eggert
ac05c6d549 cmp: improve EOF diagnostic
This improves on yesterday's change, following up on a
remark by Jim Meyering (Bug#22816#21).
* doc/diffutils.texi (Invoking cmp, cmp Options): Follow POSIX more
closely in the documentation of the information appended to the EOF
diagnostic.
* src/cmp.c (cmp): Be more specific about the shorter file's length
and fix some off-by-1 issues in reporting line counts.
* tests/cmp: Adjust to match new behavior.
Don't assume internal details about stdio buffering.
2017-05-05 07:57:05 -07:00
Paul Eggert
1b1526b4f5 cmp: report prefix length when one file is shorter
Requested by Dan Jacobson (Bug#22816).
* NEWS:
* doc/diffutils.texi (Invoking cmp, cmp Options): Document this.
* src/cmp.c (cmp): Implement it.
* tests/Makefile.am (TESTS): Add cmp.
* tests/cmp: New file.
2017-05-04 17:54:46 -07:00
Jim Meyering
75173432ed maint: change "time stamp" to "timestamp" globally
This avoids a new syntax-check failure.
* ChangeLog-2008: Perform that change.
* doc/diffutils.texi: Likewise.
* NEWS: Likewise.
* cfg.mk: Update the old news hash accordingly.
2017-01-31 10:45:20 -08:00
Jim Meyering
90106d33ab maint: update gnulib and copyright dates for 2017
* gnulib: Update to latest.
* all files: Run "make update-copyright".
2017-01-01 03:22:44 -08:00
Paul Eggert
68b82f6f84 diff: fix big performance degradation in 3.4
* NEWS, doc/diffutils.texi (Overview): Document this.
* src/analyze.c (diff_2_files): Restore too_expensive heuristic,
but this time with a floor that is 16 times the old floor.  This
should fix Bug#16848, by generating good-quality output for its
test case, while not introducing Bug#24715, by running nearly as
fast as diff-3.3 for that test case.
2016-10-25 21:58:31 -07:00
Glenn Morris
752679190c doc: fix a reference to emacs' emerge node
* doc/diffutils.texi (Interactive Merging): Correct a reference to
emacs' emerge node: s/emerge/Emerge/.
This addresses http://debbugs.gnu.org/23613
2016-05-24 19:51:36 -07:00
Jim Meyering
7346a03010 maint: update copyright year, bootstrap, init.sh
Run "make update-copyright" and then...

* gnulib: Update to latest.
* tests/init.sh: Update from gnulib.
* bootstrap: Likewise.
2016-01-01 18:00:08 -08:00
Giuseppe Scrivano
04f6d57177 diff: add --palette
* bootstrap (gnulib_modules): Add 'argmatch'.
* doc/diffutils.texi: Add documentation for --palette
* src/diff.h (set_color_palette): New prototype.
* src/diff.c (set_color_palette): New function.
(color_palette): New variable.
* src/utils.c: Include "argmatch.h".
(struct bin_str): New struct.
(struct color_ext_type): New struct.
(color_indicator): New array.
(indicator_name): New array.
(indicator_no): New enum.
(parse_state): New enum.
(put_indicator): New function.
(get_funky_string): New function. Copied from coreutils ls.
(parse_diff_color):  New function. Copied from coreutils ls
"parse_ls_color" function.
(set_color_context): Use put_indicator instead of directly
outputting the sequence.
* po/POTFILES.in: Add 'lib/argmatch.c'
2015-11-29 08:20:53 -08:00
Giuseppe Scrivano
c0fa19fe92 diff: add support for --color
* doc/diffutils.texi (diff Options): Add documentation for --color.
Copied from coreutils ls --color.
* src/context.c (pr_unidiff_hunk): Set the color context.
(print_context_header): Likewise.
(pr_context_hunk): Likewise.
* src/diff.h (enum colors_style): New enum to record when to use colors.
(colors_style): New variable to memorize the argument value.
(set_color_context): Add function definition.
* src/diff.c: : Define COLOR_OPTION.
(specify_colors_style): New function.
(longopts): Add --color.
(main): Handle --color argument.
(option_help_msgid): Add usage string for --color.
* src/normal.c (print_normal_hunk): Set the color context.
* src/side.c (print_1sdiff_line): Likewise.
* src/util.c (print_1_line_nl): New function.
(print_1_line): Make it a wrapper of 'print_1_line_nl'.
(colors_enabled): New boolean variable.
(begin_output): Call check_color_output once the output file is
configured.
(output_1_line): Periodically call `process_signals'.
(caught_signals): New sigset_t.
(colors_enabled): New boolean variable.
(interrupt_signal): New sig_atomic_t.
(stop_signal_count): New sig_atomic_t.
(check_color_output): New function.
(install_signal_handlers): Likewise. Copied from coreutils ls.
(process_signals): Likewise.  Copied from coreutils ls.
(set_color_context): New function.
(sighandler): Likewise.  Copied from coreutils ls.
(stophandler): Likewise.  Copied from coreutils ls.
2015-11-29 08:20:53 -08:00
Jim Meyering
5801f8add8 doc: --no-dereference: improve wording/description
* doc/diffutils.texi (Comparing Directories): Correct grammar.
(diff Options) [--no-dereference]: Say a little more.
2015-07-10 09:55:43 -07:00
Jim Meyering
29e8de4885 maint: update copyright year ranges to include 2015; update gnulib 2015-01-01 22:31:27 -08:00
Jim Meyering
cfcba87350 maint: update copyright year range in texinfo documentation
* doc/diffutils.texi: Update copyright.
2014-08-23 14:06:31 -07:00
Jim Meyering
667864f284 maint: update bug-reporting address
* README: Change bug-gnu-utils@... to bug-diffutils@gnu.org.
* doc/diffutils.texi: Likewise.
Reported by Jamie Landeg Jones.
2014-04-15 08:05:55 -07:00
Paul Eggert
fee3cad6b7 doc: improve documentation about reading and stdin
See Bug#17075.
* doc/diffutils.texi (Comparison): Say that files need not be read.
(Invoking diff): Remove confusing remark about 'diff - -'.
It's not that useful, and it's not portable anyway.
2014-03-25 17:56:14 -07:00
Paul Eggert
9b48bf3d3e diff: remove TOO_EXPENSIVE heuristic
Problem reported by Vincent Lefevre in <http://bugs.gnu.org/16848>.
The simplest solution is to remove the TOO_EXPENSIVE heuristic
that I added to GNU diff in 1993.  Although appropriate for
circa-1993 hardware, these days the heuristic seems to be more
trouble than it's worth.
* NEWS: Document this.
* doc/diffutils.texi (Overview): Modernize citations.
Remove mention of TOO_EXPENSIVE heuristic.
* src/analyze.c (diff_2_files): Adjust to TOO_EXPENSIVE-related
API changes in gnulib's diffseq module.
2014-02-23 22:50:37 -08:00
Paul Eggert
bc4b4b2bbf diff: exit with status 1, not 2, when binary files differ
Problem reported by Vincent Lefevre in <http://bugs.gnu.org/16608>.
* NEWS:
* doc/diffutils.texi (Binary, Invoking diff): Document this.
* src/analyze.c (briefly_report): Return void, not int.
All uses changed.  Do not futz with exit status.  Simplify.
* tests/binary: Adjust to match new behavior.
2014-01-31 17:15:54 -08:00
Paul Eggert
6e68271b69 doc: fix menu typo
* doc/diffutils.texi (Comparing Three Files): Fix out-of-order menu.
Bug caught by Texinfo 5.0.
2013-03-23 00:26:39 -07:00
Jim Meyering
a0483cb2fc maint: update all copyright year number ranges
Run "make update-copyright".
2013-01-04 11:13:02 +01:00
Paul Eggert
42f6244ee0 * doc/diffutils.texi (cmp Options): Document -l format better. 2012-10-03 21:57:45 -07:00
Jim Meyering
5cb0eea638 maint: avoid new syntax-check failure due to @xref use
* doc/diffutils.texi: Change several "; @xref{..." to ".  @xref{...",
since @xref should start a sentence.
2012-08-28 10:59:03 +02:00
Paul Eggert
7f2f4bb365 diff: -N, --unidirectional-new-file now compare to "-" too
* 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.
2012-02-04 22:13:48 -08:00
Paul Eggert
62ca21c8c1 maint: quote 'like this' or "like this", not `like this'
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.
2012-01-25 23:54:38 -08:00
Bruno Haible
e3324651cc New option --no-dereference.
* 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.
2012-01-08 21:26:27 +01:00
Jim Meyering
45110a7927 maint: update all copyright year number ranges
Run "make update-copyright".
2012-01-01 09:32:41 +01:00
Roland McGrath
86a40dd6ac diff, sdiff: new option --ignore-trailing-space (-Z)
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.
2011-08-14 22:09:21 -07:00
Tim Waugh
70febebfe5 diff: --ignore-file-name-case now applies at top level too
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.
2011-08-13 13:17:40 -07:00
Jim Meyering
789252980f doc: relax restriction on front-cover and back-cover texts
* doc/diffutils.texi (copying): Relax restriction on front-cover
and back-cover texts (just as m4 did here:
http://git.savannah.gnu.org/cgit/m4.git/commit?id=ee1e92ec).
Reported by Santiago Vila.  Fix suggested by Eric Blake.
2011-08-04 18:59:29 +02:00
Jim Meyering
df0a31f611 doc: rename diff.texi to diffutils.texi
This makes the .texi basename the same as the package name,
which is consistent with most other GNU packages.
* doc/diffutils.texi: Rename from...
* doc/diff.texi: ...removed.
* doc/Makefile.am (info_TEXINFOS): Reflect name change.
(diffutils_TEXINFOS): Likewise.
* cfg.mk (gendocs_options_): Remove this customization.  It is no
longer needed, now that the .texi name matches that of the package.
* man/Makefile.am ($(dist_man1_MANS)): Remove now-unnecessary sed
filter.
* README: Update references to diffutils.texi etc. here, too.
* .gitignore: Update here, too.
Suggested by Karl Berry.
2011-06-12 09:47:27 +02:00
Eric Blake
ffd622a281 docs: info should mention -L
* doc/diff.texi (diff Options): Document -L.
2011-03-18 15:28:44 -06:00