1486 Commits

Author SHA1 Message Date
Jim Meyering
e1bb047793 build: update gnulib to latest 2025-01-03 09:46:44 -08:00
Collin Funk
4eb92b2a80 maint: use Gnulib's stat-time over our own version
* bootstrap.conf (gnulib_modules): Add stat-time.
* configure.ac: Remove check for the st_blksize in struct stat.
* src/system.h: Include stat-time.h.
(STAT_BLOCKSIZE): Remove definition.
* src/analyze.c (diff_2_files):
* src/cmp.c (main):
* src/diff3.c (read_diff):
* src/io.c (sip): Use ST_BLKSIZE instead of STAT_BLOCKSIZE.
2024-10-13 14:19:06 -07:00
Jim Meyering
f81b0a7c1c maint: avoid old-FSF-address syntax-check failure
* man/help2man: Update to help2man-1.48.5, but merging in the
latest #!/usr/bin/env change. Bruno Haible reported that it
failed a new gnulib syntax-check due to an old FSF mailing
address in https://bugs.gnu.org/73139
2024-09-10 15:06:17 -07:00
Bruno Haible
d22d1f67ca build: Fix use of perl on Guix, FreeBSD, NetBSD
* man/help2man: Search for perl in $PATH.
2024-07-22 08:03:47 -07:00
Bruno Haible
7f9bf95640 build: Generate programs' man pages in the source directory, per GCS
* man/Makefile.am ($(dist_man1_MANS)): Generate the *.1 files in
$(srcdir), not in the build dir.
2024-07-22 07:53:56 -07:00
Bruno Haible
5ec3ebf31c build: Fix a build failure in a VPATH build
* src/Makefile.am (cmp.$(OBJEXT) etc.): Depend on version.h.
2024-07-21 10:59:37 -07:00
Paul Eggert
e7387b4ce2 maint: adjust to Gnulib -Wsystem-headers change
* configure.ac (WERROR_CFLAGS): No need to disable
-Wsystem-headers as Gnulib no longer enables it by default.
2024-07-15 14:49:12 -07:00
Paul Eggert
4a6bc03a99 build: update gnulib submodule to latest 2024-07-15 14:49:12 -07:00
Jim Meyering
c31ff07758 build: update gnulib to latest; and update bootstrap 2024-07-04 13:20:23 -07:00
Collin Funk
1d2456f539 maint: import tests/init.sh from Gnulib during bootstrap
* bootstrap.conf (bootstrap_post_import_hook): Use gnulib-tool
--copy-file to import tests/init.sh.
* tests/init.sh: Remove file.
* .gitignore (/tests/init.sh): Add entry.
2024-07-04 13:15:35 -07:00
Collin Funk
8da1f14d84 tests: don't fail when --program-transform-name is used
Problem reported by Jun T <https://bugs.gnu.org/48062>.
* tests/diff3: Use --diff-program=diff since --program-transform-name
is applied after install.
* tests/help-version (sdiff_setup, diff3_setup): Likewise.
2024-06-23 17:47:26 -07:00
Paul Eggert
da0c15f381 diff: avoid memory leak with --color-palette
Problem found indirectly by Coverity, reported by Wasser Mai
(Bug#71535).  Although the Coverity report was wrong, there was a
different potential memory leak nearby.  Fix the problem by
modifying the string in place, avoiding the need to call malloc.
* src/util.c (color_ext_list, struct color_ext_type):
Remove.  Not needed, as the list wasn’t used.
All uses removed.
(get_funky_string): Omit last argument output_count, as it’s
easily calculated by caller.  This lets us call this function
when we don’t care about the count.
(color_palette): Now char *, not char const *, since we
now update through it.
(set_color_palette): Likewise.
(parse_diff_color): Process color palette into itself, to avoid
unnecessary malloc and free calls.  This pacifies Coverity, saves
a bit of space in the normal case, and avoids a memory leak in
some cases.  Do not process the palette twice, as its memory
has been modified and this function had no effect on the
color indicators the second time.
2024-06-19 23:42:53 -04:00
Paul Eggert
54c8930ca5 maint: update .gitignore to add lib/stdbit.h 2024-06-19 23:42:53 -04:00
Paul Eggert
d636f9c117 diff: port to FreeBSD, NetBSD
Problem reported by Bruno Haible <https://bugs.gnu.org/71486>.
* src/diff.c (NOFOLLOW_SYMLINK_ERRNO): New constant.
(compare_files): Use it instead of ELOOP.  When it is not ELOOP,
treat ELOOP as a failure in resolving the parent directory;
this saves a syscall in some situation.
2024-06-11 17:49:03 -07:00
Bruno Haible
d7588ed774 tests: Fix ignore-case failure on several platforms
* tests/ignore-case: Don't compare 'Ⓐ' with 'ⓐ'; this doesn't work on
NetBSD 10.0 and Solaris 11.4. Don't compare 'Ꞻ' with 'ꞻ'; this doesn't
work on CentOS 7, macOS, and Solaris 11 OmniOS.
2024-06-11 15:21:13 -07:00
Paul Eggert
8f8ee60502 maint: port ‘make distcheck’ to Ubuntu 24.04
* configure.ac: Don’t use -Wsystem-headers, as <stdbit.h>
uses static functions that couldn’t be called from
extern inline functions if they were in user code.
2024-06-11 11:59:34 -07:00
Paul Eggert
d82aac15e6 maint: pacify ‘make sc_tight_scope’
Problem reported by Bruno Haible <https://bugs.gnu.org/71455>.
* src/system.h (same_file, stat_size): Add ‘extern’.
2024-06-11 10:11:27 -07:00
Paul Eggert
a9cca43461 maint: port to birthtime platforms
Problem reported by Bruno Haible <https://bugs.gnu.org/71456>.
* src/system.c (same_file): Fix typo on platforms with birthtime.
2024-06-11 09:12:35 -07:00
Paul Eggert
b8b3ac5c20 build: update gnulib submodule to latest 2024-05-21 10:08:53 -07:00
Paul Eggert
ba8e55270f maint: adjust to Gnulib stdbit splitup
* bootstrap.conf (gnulib_modules): Remove stdbit; add stdc_bit_width.
2024-05-16 19:59:49 -07:00
Paul Eggert
8f1af93295 build: update gnulib submodule to latest 2024-05-16 19:59:49 -07:00
Paul Eggert
bf85e93a52 maint: move same_file and stat_size into system.c
Now that we have a system.c, there’s little point to these
being extern inline functions.
* src/system.c (same_file, stat_size): Move here from system.h,
and make them ordinary extern functions.
(proc_dev, symlink_size_ok): Now static, and private to their
functions.
* src/system.h (same_file, stat_size): Now just decls.
2024-05-15 14:13:53 -07:00
Paul Eggert
12dc6b3e6f build: update gnulib submodule to latest 2024-05-15 14:13:53 -07:00
Paul Eggert
62d075ad72 maint: be less fancy when defining extern vars
Bug reported by Bruno Haible in <https://bugs.gnu.org/70951>.
I never did like the XTERN macro and its descendants, as this
“extension” to C causes more confusion than it cures, so let’s
just get rid of it and use plain ‘extern’.
* cfg.mk (_gl_TS_extern): Remove XTERN, SYSTEM_EXTERN.
* src/Makefile.am (cmp_SOURCES, diff3_SOURCES, sdiff_SOURCES)
(diff_SOURCES): Add system.c.
* src/cmp.c, src/diff.c, src/diff3.c, src/sdiff.c (SYSTEM_INLINE):
Remove.
* src/diff.c: Define vars declared in diff.h.
* src/diff.h (DIFF_EXTERN): Remove.  All uses removed.
Just use ‘extern’ when declaring extern vars.
* src/system.h (SYSTEM_EXTERN): Likewise.
* src/system.c: New file.
2024-05-14 15:50:12 -07:00
Paul Eggert
195016c60f build: update gnulib submodule to latest 2024-05-14 15:50:12 -07:00
Paul Eggert
cceca01aba maint: pacify GCC 14 -Wmissing-variable-declarations
* src/Makefile.am (version.c): Have it include version.h,
so that it checks its own interface.
* src/diff.c (DIFF_INLINE): Define this instead of GDIFF_MAIN,
for consistency with SYSTEM_INLINE.
* src/diff.h (DIFF_EXTERN): New macro, replacing XTERN.
All uses changed.  Adjust to GDIFF_MAIN→DIFF_INLINE change.
* src/system.h (SYSTEM_EXTERN): Now takes an argument.
All uses changed.
2024-05-12 08:14:54 -07:00
Paul Eggert
a33c9b9e85 diff: prefer stdbit to count-leading-zeros
stdbit.h is standardized in C23, so use that instead of
the GNU-specific count-leading-zeros module.
* bootstrap.conf (gnulib_modules): Remove count-leading-zeros.
Add stdbit.
* src/system.h: Include stdbit.h instead of count-leading-zeros.h.
(floor_log2): Implement via stdc_bit_width instead of via
count_leading_zeros_ll.
2024-05-11 22:55:38 -07:00
Paul Eggert
d6fc5a8ce1 maint: update bootstrap to Gnulib version 2024-05-11 22:55:38 -07:00
Paul Eggert
561caf873f build: update gnulib submodule to latest 2024-05-11 22:55:38 -07:00
Paul Eggert
c9a237907b diff: improve GCC 13.3’s static checking
* src/io.c (slurp): GCC bug 110014 should be fixed in GCC 13.3.
2024-05-09 11:37:41 -07:00
Paul Eggert
3d1a56b906 diff: restrict scope of GCC bug 110014 workaround
* src/io.c (slurp): Work around GCC bug 110014 only if GCC 13,
since it’s reportedly fixed in GCC 14.
2024-02-18 00:27:56 -08:00
Jim Meyering
6c88db1f7b maint: make update-copyright 2024-01-05 09:01:59 -08:00
Jim Meyering
b477ddb1b8 build: update gnulib to latest; also update bootstrap 2024-01-05 08:59:50 -08:00
Jim Meyering
f1a8c476b6 build: suppress -Wmaybe-uninitialized for one function
* src/sdiff.c (edit): Suppress gcc's -Wmaybe-uninitialized warning
for this function. Whenever "cmd1 == 'e'", cmd2 **is** initialized.
2024-01-05 08:58:10 -08:00
Paul Eggert
774b942f70 diff: go back to C quoting for diff -c/-u headers
Gleb Fotengauer-Malinovskiy reported <https://bugs/gnu/org/66095>
that the recent change to quoting style broke GNU patch.
* src/util.c: Include quotearg.h.
(current_name): New static var, replacing the the old
current_name0 and current_name1.  All uses changed.
(begin_output): Go back to quoting file names for C,
not for the shell, when they contain troublesome characters.
This is not a simple revert, as the revised code handles
multi-byte characters even in non-UTF-8 locales.
* tests/filename-quoting: Revert previous change to this file.
2023-09-20 00:05:00 -07:00
Paul Eggert
8bd0414495 build: update gnulib submodule to latest 2023-09-20 00:05:00 -07:00
Jim Meyering
89b59a4337 build: avoid new build failure
* src/util.c (output_1_line): Append a semicolon to "default:"
label, now that the following line is a declaration. Avoids this:
  error: a label can only be part of a statement and a declaration is\
  not a statement
2023-09-16 15:41:01 -07:00
Paul Eggert
632deed390 maint: fix NEWS typos 2023-09-16 13:28:21 -07:00
Paul Eggert
5fdc79cc07 diff: tune when O_PATH fails with ELOOP
* src/diff.c (compare_files): If openat (..., "a/b/.../e/f",
O_PATH | ...) fails with ELOOP, one of a, a/b, ..., a/b/.../e
must be a symlink loop; a/b/.../e/f cannot itself be a symlink loop.
So in this case fail immediately rather than following up with
fstatat (..., "a/b/.../e/f", ..., AT_SYMLINK_NOFOLLOW).
2023-09-16 13:28:21 -07:00
Paul Eggert
f2d94e2e67 diff: tune 'diff --no-dereference --no-file-name-case SYMLINK DIR'
* src/diff.c (compare_files): If find_dir_file_pathname tells
us the file type, use that info to avoid unnecessary calls
to openat.
* src/dir.c (find_dir_file_pathname): New arg DETYPE.  All uses changed.
2023-09-16 13:28:21 -07:00
Paul Eggert
c1e838aeff maint: fix comment typo 2023-09-15 22:52:52 -07:00
Gleb Fotengauer-Malinovskiy
b82644eb22 diff: fix regression affecting the counting of diff context lines
This regression was introduced on 2023-05-22 in commit
v3.10-9-gda1697dcb6 ("diff: C99 decl style in context.c") during a code
style change.

This regression was discovered using the GNU patch testsuite:
FAIL: preserve-c-function-names
FAIL: reject-format

 * src/context.c (minus_prefix_lines): Initialize with a reversed value.

Tiny-change: yes
2023-09-15 19:41:46 -07:00
Paul Eggert
a8c3040e6a diff: publish attributes
* src/diff.h (translate_line_number, find_change):
Move attribute here ...
* src/util.c: ... from here.
2023-09-15 19:39:46 -07:00
Paul Eggert
2b82edcdf8 diff: respond faster to write failures
* src/util.c (output_1_line): Check for signals even
if there is a write failure, for faster response when
hammering on /dev/full etc.
2023-09-13 16:40:34 -05:00
Paul Eggert
7c5ade561b maint: be clearer about when ctype is needed
Include <ctype.h> and <c-ctype.h> only in modules where needed.
* src/cmp.c, src/context.c, src/diff.c, src/diff3.c, src/ifdef.c:
* src/sdiff.c: Include <c-ctype.h>.
* src/io.c: Include <ctype.h>.
* src/system.h: Do not include either <ctype.h> or <c-ctype.h>.
2023-09-13 16:40:34 -05:00
Paul Eggert
8ef3eb9d98 maint: diff no longer uses isblank directly
* bootstrap.conf (gnulib_modules): Remove isblank.
2023-09-13 16:40:34 -05:00
Paul Eggert
924f297e3e diff: improve util.c multi-byte handling
* bootstrap.conf (gnulib_modules): Add c32isprint.
* src/util.c: Include mcel.h.
(output_1_line): Return immediately on output error.
Scan multi-byte characters and count their widths.
(analyze_hunk): Ignore multi-byte white space too.
2023-09-13 01:23:43 -05:00
Paul Eggert
30c5e9e592 sdiff: port to odd isspace locales
* src/sdiff.c (skip_white): Use c_isspace, not isspace.
We are parsing diff output, and c_isspace is better here.
2023-09-13 01:23:43 -05:00
Paul Eggert
7ec1b5db35 diff: port --no-dereference changes to non-O_PATH
This fixes a recently-introduced portability bug
when running on platforms like Solaris 10 that lack O_PATH.
* src/diff.c (compare_files): On platforms without O_PATH,
when running 'diff --no-dereference symlink dir' do not
report an error merely because dir/symlink is a symbolic link
and cannot be opened for reading.
2023-09-07 23:30:57 -07:00
Paul Eggert
86d52a9a3e maint: switch to gnulib mcel
Drop diffutils-specific library code that has been moved into Gnulib.
* gl/lib/exclude.c, gl/lib/mbscasecmp.c, gl/lib/mcel.c:
* gl/lib/mcel.h, gl/modules/mcel, gl/modules/mcel-prefer:
* gl/modules/mcel-tests, gl/tests/test-mcel.c:
Remove; now taken from Gnulib.
2023-09-07 21:36:37 -07:00