43 Commits

Author SHA1 Message Date
Jim Meyering
bbc1bdb771 maint: update copyright dates 2026-01-02 16:52:26 -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
ae1cdc7239 diff: modularize and tune mcel code
Go back to a single mcel module, instead of trying to break it up
into ucore and mcel pieces, as breaking it up hurt performance.
Use gnulib-tool’s --local-dir to create diffutils-specific modules
for mcel; the idea is that this will eventually migrate into Gnulib.
* bootstrap.conf (avoided_gnulib_modules): Add mbuiterf.
(gnulib_modules): Add mbscasecmp, mcel-prefer.
(gnulib_tool_option_extras): Add --local-dir=gl to pick up new files.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_doubled_word):
Do not exclude now-removed files lib/ucore.c, lib/ucore.h.
* lib/Makefile.am: Adjust to use of modules.
(noinst_HEADERS): Remove mcel.h, ucore.h.
(libdiffutils_a_SOURCES): Remove mcel.c, mcel-casecmp.c, ucore.c
* lib/mcel-casecmp.c, lib/ucore.c, lib/ucore.h: Remove.
* lib/mcel.h: Switch to LGPLv2.1+.  Do not include ucore.h.
All uses of ucore_t changed back to using char32_t.
Do what ucore.h used to do: include verify.h, limits.h, stddef.h,
uchar.h; require config.h, define _GL_LIKELY, _GL_UNLIKELY.
(MCEl_CHAR_MAX, MCEL_ERR_MIN, MCEL_ERR_MAX): New constants.
(mcel_t): Switch from single ucore_t c to a char32_t ch and
unsigned char err.  This has significantly better performance on
Fedora 38 x86-64.  All uses changed.  Check that unsigned char
promotes to int.
(mcel_ch, mcel_err, mcel_cmp, mcel_tocmp): New functions.
(MCEL_ERR_SHIFT): Rename from MCEL_ENCODING_ERROR_SHIFT.
All uses changed.
(mcel_isbasic): Add a _GL_LIKELY to help compilers.  All uses changed.
(mcel_scan, mcel_scant): Simplify by using mcel_ch, mcel_err.
(mcel_casecmp): Remove decl.  Callers changed to use mbscasecmp.
* gl/lib/mcel.c, gl/lib/mcel.h: Rename from lib/mcel.c, lib/mcel.h.
* gl/lib/mbscasecmp.c: New file.
* gl/modules/mcel, gl/modules/mcel-prefer, gl/modules/mcel-tests:
* gl/tests/test-mcel.c:
New files.
* src/io.c: Revert use of ucore API.  Use plain c32isspace etc.
instead of ucore_is.  Use .err instead of ucore_iserr.
(same_ch_err): Bring back, and use it instead of ucore_cmp.
* src/side.c (print_half_line):  Use .err instead of ucore_iserr.
2023-08-21 15:43:26 -07:00
Paul Eggert
12bcf0bd50 diff: simplify multi-byte code (mbcel -> mcel)
* lib/Makefile.am: Adjust to file renamings and additions.
* lib/mbcel.c, lib/mbcel.h: Split into two APIs, replacing with ...
* lib/mcel.c, lib/mcel.h, lib/ucore.c, lib/ucore.h: ... these new files.
* lib/mcel.h: Simplify by assuming ucore.h is included.
Check that bytes have 8 bits.
(MCEL_LEN_MAX, mcel_t, MCEL_INLINE, MCEL_ENCODING_ERROR_SHIFT)
(mcel_scan, mcel_scant, mcel_scanz, mcel_casecmp):
Rename from MBCEL_LEN_MAX, mbcel_t, MBCEL_INLINE,
MBCEL_ENCODING_ERROR_SHIFT, mbcel_scan, mbcel_scanz, mbcel_scant,
mbcel_casecmp.
(mcel_t): New member c, replacing old members ch and err.
All uses changed.
(MBCEL_UCHAR_FITS, MBCEL_UCHAR_EASILY_FITS): Remove.
All uses removed.  No longer needed now 8-bit bytes are assumed.
(MCEL_ENCODING_ERROR_SHIFT): Check that it matches UCORE_ERR_MIN.
(mcel_isbasic): New function.  Use it where appropriate.
(mbcel_cmp, mbcel_casecmp): Remove; replaced by ucore_cmp,
ucore_tocmp.  All uses changed.
* lib/mcel-casecmp.c: Rename from lib/mbcel-strcasecmp.c.
Include mcel.h instead of mbcel.h.
(mcel_casecmp): Rename from mbcel_strcasecmp.  All uses changed.
Assert that UCHAR_MAX <= INT_MAX, as POSIX requires,
and simplify code accordingly.  Use mcel rather than mbcel.
* lib/ucore.h: Include verify.h.
(ucore_t): New type.
(UCORE_CHAR_MAX, UCORE_ERR_MIN, UCORE_ERR_MAX, UCORE_C32_SAFE):
New constants.  Check that information is not lost by encoding
errors as integers; this is a weaker test than CHAR_BIT == 8.
(ucore_iserr, ucore_is, ucore_to): New functions.
(ucore_cmp, ucore_tocmp): New functions, replacing the old
mbcel_cmp, mbcel_casecmp.  All uses changed.
* src/dir.c, src/io.c, src/side.c: Use mcel rather than mbcel.
* src/io.c (same_ch_err): Remove.  All uses replaced by ucore_cmp.
2023-08-15 10:41:54 -07:00
Paul Eggert
69ae797392 cmp,diff,diff3,sdiff: quote more consistently
* lib/diagnose.c, lib/diagnose.h: New files.
* lib/Makefile.am (noinst_HEADERS, libdiffutils_a_SOURCES):
Add them.
* po/POTFILES.in: Add lib/diagnose.c.
* src/analyze.c, src/cmp.c, src/diff3.c, src/dir.c:
* src/sdiff.c, src/util.c:
Include diagnose.h.
* src/analyze.c (briefly_report, diff_2_files):
* src/cmp.c (usage, main, cmp):
* src/diff.c (add_regexp, summarize_regexp_list, main, compare_files):
* src/diff3.c (usage, process_diff, scan_diff_line):
* src/dir.c (diff_dirs):
* src/sdiff.c (usage, ck_fopen, main, edit):
* src/util.c (perror_with_name, begin_output):
Quote file names or regexps with squote.
* src/cmp.c, src/diff.c, src/diff3.c, src/dir.c, src/sdiff.c:
Include quote.h.
* src/cmp.c, src/diff.c, src/diff3.c, src/sdiff.c (try_help):
Remove; now in diagnose.c.
* src/cmp.c (specify_ignore_initial, main, cmp):
* src/diff.c (main, specify_value, specify_colors_style):
* src/diff3.c (main, read_diff):
* src/dir.c (compare_collated):
* src/sdiff.c (check_child_status, main):
* src/util.c (finish_output):
Quote strings with ‘quote’ or ‘quote_n’.
* src/system.h (EXIT_TROUBLE): Remove; now in diagnose.h
and now an enum.
* src/util.c (c_escape_char, c_escape):
Remove, as we now use squote.
* tests/cmp, tests/filename-quoting, tests/invalid-re:
Adjust to match new behavior.
2023-08-08 17:00:19 -07:00
Paul Eggert
6477dce501 diff: sort multi-byte file names better
* bootstrap.conf (gnulib_modules): Add builtin-expect.
* lib/mbcel-strcasecmp.c: New file.
* lib/Makefile.am (libdiffutils_a_SOURCES): Add it.
* lib/mbcel.h (MBCEL_LEN_MAX, MBCEL_ENCODING_ERROR_SHIFT)
(MBCEL_UCHAR_FITS, MBCEL_UCHAR_EASILY_FITS): New constants.
(_GL_LIKELY): New macro.
(mbcel_scan): Use it.  Simplify NetBSD code.
(mbcel_scant, mbcel_scanz, mbcel_cmp, mbcel_casecmp): New functions.
* src/dir.c (strcasecoll): Move defn here from system.h,
since only dir.c needs it.  Use mbcel_strcasecmp instead
of strcasecmp.
2023-07-21 11:23:53 -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
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
7ec5eb6c97 maint: remove prepargs
* lib/Makefile.am (noinst_HEADERS): Remove prepargs.h.
(libdiffutils_a_SOURCES): Remove prepargs.c.
* lib/prepargs.c, lib/prepargs.h: Remove.  Hasn’t been
needed for many years.
* src/diff.c: Do not include prepargs.h.
2021-08-22 14:02:21 -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
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
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
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
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
Jim Meyering
29e8de4885 maint: update copyright year ranges to include 2015; update gnulib 2015-01-01 22:31:27 -08:00
Jim Meyering
a0483cb2fc maint: update all copyright year number ranges
Run "make update-copyright".
2013-01-04 11:13:02 +01:00
Jim Meyering
301a23cdbb build: accommodate newer bootstrap from gnulib
* bootstrap.conf (gnulib_tool_option_extras): Add both --symlink
and --makefile-name=gnulib.mk.  Also remove now-obsolete $bt/ prefix.
* bootstrap: Update from gnulib.
* tests/init.sh: Update from gnulib.
* lib/Makefile.am: Initialize numerous variables, so that
generated code in gnulib.mk may use += to append to them.
2012-01-12 14:04:44 +01:00
Jim Meyering
45110a7927 maint: update all copyright year number ranges
Run "make update-copyright".
2012-01-01 09:32:41 +01:00
Jim Meyering
ce5367b6b3 maint: update copyright year ranges to include 2011
Run "make update-copyright", so "make syntax-check" works in 2011.
2011-01-03 22:13:35 +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
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
e58efa5bd2 build: enable warnings and -Werror.
* 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.
2009-11-22 17:16:25 +01:00
Jim Meyering
9bfafb33a6 admin: update all copyright notices to include the year 2009 2009-11-11 22:18:37 +01:00
Paul Eggert
43e4846f11 * COPYING: New file.
* AUTHORS: Update from GPLv2 to GPLv3.
* Makefile.am: Likewise.
* NEWS: Likewise.
* README: Likewise.
* README-hacking: Likewise.
* bootstrap: Likewise.
* bootstrap.conf: Likewise.
* configure.ac: Likewise.
* exgettext: Likewise.
* doc/Makefile.am: Likewise.
* lib/Makefile.am: Likewise.
* lib/cmpbuf.c: Likewise.
* lib/cmpbuf.h: Likewise.
* lib/prepargs.c: Likewise.
* m4/vararrays.m4: Likewise.
* man/Makefile.am: Likewise.
* ms/Makefile.am: Likewise.
* ms/README: Likewise.
* ms/config.bat: Likewise.
* ms/config.sed: Likewise.
* ms/config.site: Likewise.
* po/POTFILES.in: Likewise.
* src/Makefile.am: Likewise.
* src/analyze.c: Likewise.
* src/cmp.c: Likewise.
* src/context.c: Likewise.
* src/diff.c: Likewise.
* src/diff.h: Likewise.
* src/diff3.c: Likewise.
* src/dir.c: Likewise.
* src/ed.c: Likewise.
* src/io.c: Likewise.
* src/normal.c: Likewise.
* src/sdiff.c: Likewise.
* src/system.h: Likewise.
* src/util.c: Likewise.
2007-07-19 17:45:29 +00:00
Paul Eggert
2daf7bfa36 Modernize bootstrap procedure to match current gnulib.
* bootstrap: Sync with coreutils bootstrap, except check that
the directory build-aux exists before trying to copy to it.
* bootstrap.conf: New file.
(gnulib_modules): Add config-h, dup2, extensions, fcntl, fdl,
stat-macros, unistd.
* configure.ac: Invoke gl_EARLY and gl_INIT rather than
GNULIB_AUTOCONF_SNIPPET.
(AC_CONFIG_HEADER): Rename config.h to lib/config.h.
(AC_CHECK_HEADERS_ONCE): Don't check for fcntl.h, locale.h,
sys/file.h, unistd.h.  We now use the fcntl and unistd modules,
and locale.h can be assumed for any C89 compiler.
(DIFFUTILS_PREREQUISITES): Remove.  No longer needed now that
we use the stdint module.
(AC_CHECK_FUNCS_ONCE): Remove dup2, which is no longer needed
now that we use the dup2 module.
(AM_GNU_GETTEXT): Use need-formatstring-macros, and ...
(AM_GNU_GETTEXT_VERSION): specify version 0.15 instead of 0.14.5,
to be consistent with coreutils.
* lib/Makefile.am (noinst_LIBRARIES):
(lib_SOURCES, libdiffutils_a_LIBADD):
(libdiffutils_a_DEPENDENCIES, BUILT_SOURCES, EXTRA_DIST):
(MOSTLYCLEANFILES): Remove; now computed automatically.
(noinst_HEADERS, libdiffutils_a_SOURCES): Just append
our special files now.
* lib/cmpbuf.c: Include config.h unconditionally, since we
no longer define HAVE_CONFIG_H.
* lib/prepargs.c: Likewise.
* src/Makefile.am (LDADD): Use $(LIBINTL), not @LIBINTL@.
(diff_LDADD): Use $(LIB_CLOCK_GETTIME), not @LIB_CLOCK_GETTIME@.
* src/dir.c (dir_read): Use _D_EXACT_NAMLEN, not NAMELEN.
* src/system.h (volatile): Remove, since we assume C89 or better.
Include stat-macros.h.
(S_IRWXU, S_IRWXG, S_IRWXO, S_IRUSR, S_IWUSR):
Remove, since we now use stat-macros.h.
(SEEK_SET, SEEK_CUR): Remove, since we assume C89 or better.
Include unistd.h unconditionally, since we use unistd.
Likewise for fcntl.h.
(dup2): Remove, since we now use dup2.
(O_RDONLY, O_RWDR, O_BINARY): Remove, since we now use
fcntl.
Include dirent.h unconditionally.
(NAMLEN): Remove, replacing with....
(_D_EXACT_NAMLEN): New macro.
Include inttypes.h unconditionally.
(PTRDIFF_MAX, SIZE_MAX, UINTMAX_MAX, strtoumax): Remove, since
we now use inttypes.
Include locale.h unconditionally.
(setlocale): Remove, since we now assume locale.h.
2006-09-05 22:57:29 +00:00
Paul Eggert
f5c7610983 Update FSF address. 2006-01-05 07:23:55 +00:00
Paul Eggert
91b8605708 * src/cmp.c: Don't include <setmode.h>.
(specify_ignore_initial): Reword to avoid gcc -W warnings.
(main): Use freopen instead of setmode, since freopen is in POSIX.
* src/context.c: Revert most 2004-09-01 changes.  Then:
(TIMESPEC_NS): Remove.  All uses replaced by
get_stat_mtime_ns.
Include stat-time.h, strftime.h.
(nstrtime): Remove decl.
* src/diff.c: Revert most 2004-09-01 changes.  Then:
Don't include <posixver.h>, <quotesys.h>, <setmode.h>.
Include <sh-quote.h>, <stat-time.h>, <timespec.h>.
All uses of quotesys replaced by sh-quote.
(main, compare_files):
Use freopen instead of setmode, since freopen is in POSIX.
(main): Don't complain about "diff -NUM'.
(main, set_mtime_to_now):
Adjust to stat-time.h macros when accessing nanoseconds.
* src/diff3.c: Include sh-quote.h rather than quotesys.  All uses
changed.
* src/dir.c (dir_read): excluded_filename renamed to
excluded_file_name.
* src/io.c: Don't include <setmode.h>.
(sip, read_files): Remove binary file stuff, leaving a FIXME behind.
A DOS expert needs to look at this.
* src/diff.c: Include sh-quote.h rather than quotesys.h.
All uses changed.
* src/system.h: Include verify.h.
(verify): Remove.  All uses changed to verify.h version.
Include <intprops.h>.
(TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove.  Now uses
intprops.h versions.
(O_BINARY): New defns, taken from coreutils.
* src/util.c: Include sh-quote.h rather than quotesys.h.
All uses changed.
2006-01-05 07:08:23 +00:00
Paul Eggert
74bdeeafed (EXTRA_DIST): Add setmode.h. 2004-04-12 20:45:50 +00:00
Paul Eggert
2e22505469 Use inttostr module, so we needn't worry about specifying it ourself. 2004-04-12 20:30:57 +00:00
Paul Eggert
0ebd95fcbd (SUBDIRS): Remove.
(EXTRA_DIST, noinst_HEADERS): Remove most entries.
(libdiffutils_a_SOURCES): Now just lib_SOURCES.
(lib_SOURCES): New macro.
(DISTCLEANFILES, MOSTLYCLEANFILES): Set to empty now.
(gnulib.mk): Include: this does most of the work eliminated
by the above changes.
2004-04-12 07:44:35 +00:00
Paul Eggert
4ead5e1146 (noinst_HEADERS): Remove freesoft.h.
Add version-etc.h.
(libdiffutils_a_SOURCES): Remove freesoft.c.  Add version-etc.c.
2002-06-17 05:55:42 +00:00
Paul Eggert
bb9cc01d98 (EXTRA_DIST): Add fnmatch_loop.c.
(noinst_HEADERS): fnmatch_.h renamed from fnmatch.hin.
regex_.h renamed from regex.hin.
Add file-type.h.
(libdiffutils_a_SOURCES): Add file-type.c.
(DISTCLEANFILES): Remove fnmatch.hno, regex.hno.
2002-06-11 05:53:54 +00:00
Paul Eggert
dbea9821b7 (AUTOMAKE_OPTIONS): Remove. 2002-03-11 08:00:47 +00:00
Paul Eggert
a44befd50b (noinst_HEADERS): Add c-stack.h, exitfail.h.
(libdiffutils_a_SOURCES): Add c-stack.c, exitfail.c, quotesys.c.
(INCLUDES): Remove.
2002-02-28 04:28:07 +00:00
Paul Eggert
75cd3e885f (noinst_HEADERS): Add gettext.h. 2002-01-24 20:16:38 +00:00
Paul Eggert
412c4f3436 (noinst_HEADERS): Add dirname.h, setmode.h.
(libdiffutils_a_SOURCES): Add basename.c, setmode.c.
2001-12-11 08:09:04 +00:00
Paul Eggert
75ea63a2d7 (EXTRA_DIST): Add xstrtol.c.
(noinst_HEADERS): Add xstrtol.h.
(libdiffutils_a_SOURCES): Add xstrtoumax.c.
2001-12-03 13:12:06 +00:00
Paul Eggert
9b53dc8757 (EXTRA_DIST): Add strtoimax.c, strtol.c. 2001-11-25 07:36:42 +00:00
Paul Eggert
7577cc7fb6 (noinst_HEADERS): Add unlocked-io.h. 2001-11-25 07:25:31 +00:00
Paul Eggert
f78da6466e Initial revision 2001-11-23 13:28:32 +00:00