40 Commits
Author SHA1 Message Date
Jim Meyering cd0302744f build: update gnulib to latest; and bootstrap 2026-03-08 11:54:10 -07:00
Jim Meyering e137695202 sed: do not reject "\c[" in a regular expression
As a GNU extension, "\c[" in a regexp matches the ESC character
(i.e., control-[). Yet 's/\c[//' was rejected because "[" was treated
as the beginning of a bracket expression.
* sed/compile.c (match_slash): When matching "slash"es, treat \c as
an escape sequence, so that s/\c[// no longer fails because it
misinterprets [ as a bracket-group start.
* testsuite/misc.pl (bug79519_1,2,3,fail): Add tests.
* NEWS (Bug fixes): Mention it.
Reported by Michael Ludwig in https://bugs.gnu.org/79519.
2025-10-01 03:20:22 -07:00
Jim Meyering f124c83561 build: update gnulib to latest 2025-10-01 03:17:14 -07:00
Collin Funk 587cfe1716 build: fix compile errors on platforms without getopt.h
* bootstrap.conf (gnulib_modules): Add getopt-gnu.
* lib/.gitignore: Update from gnulib-tool --import.
* m4/.gitignore: Likewise.
* NEWS: Mention the fix.
2025-03-03 09:06:51 -08:00
Jim Meyering e37e61cb55 build: update gnulib to latest and update bootstrap and .gitignore files 2024-07-04 14:30:46 -07:00
Paul Eggert fd9898dc4b maint: omit unnecessary Gnulib modules
* basicdefs.h: Do not include alloca.h.
* bootstrap.conf (gnulib_modules): Remove alloca, stdalign,
c-ctype, closeout, mbrlen, verify.
Add version-etc.
* lib/.gitignore, m4/.gitignore: Omit now-unused files.
* po/POTFILES.in: Remove closeout.c.
* testsuite/test-mbrtowc.c: Do not include closeout.h.
(main): Close stdout by hand, to avoid a dependency on closeout.
2023-01-30 09:58:54 -08:00
Paul Eggert 8a13de6943 maint: update .gitignore files 2023-01-30 09:58:54 -08:00
Jim Meyering 4d231bb07d build: update gnulib to latest
* lib/.gitignore, m4/.gitignore: Also reflect regenerated .gitignore files.
2023-01-29 17:18:21 -08:00
Paul Eggert a9b1b679b6 sed: improve integer overflow checking
Fix some some longstanding but unlikely integer overflows.
Internally, 'sed' now more often prefers signed integer arithmetic,
which can be checked automatically via 'gcc -fsanitize=undefined'.
* basicdefs.h (countT): Remove.  All uses replaced
with a more-specific signed type, e.g., idx_t.
Similarly, change uses of types like size_t to
signed types like idx_t when appropriate.
(REALLOC): Remove; no longer used.  We now use xpalloc
because that detects integer overflow in size calculations.
Also, we no longer use XCALLOC since the code never relies
on the storage being zero, and leaving it uninitialized is
more likely to catch errors when debugging implementations
are used.  We use XNMALLOC instead, or xpalloc.
* bootstrap.conf (gnulib_modules): Add stdckdint, strtoimax.
* lib/.gitignore, m4/.gitignore: Update for new Gnulib modules.
* sed/compile.c: Include stdckdint.h.
(VECTOR_ALLOC_INCREMENT): Remove; no longer used.
(in_integer): Return maximal value if integer overflow.
All callers changed to expect this.
(next_cmd_entry): Use xpalloc instead of reallocating by hand,
which might suffer integer overflow.
(normalize_text): Don’t rely on system-defined conversion
of out-of-range size_t to int.
(next_cmd_entry): Arg is now pointer, not pointer-to-pointer.
All uses changed.
* sed/debug.c (debug_print_function): Don’t attempt to
fwrite a null pointer with a zero size.
* sed/execute.c: Include <stdckdint.h>, "minmax.h".
(resize_line): LEN arg is now increment, not total length,
to avoid overflow when calculating total length.
All uses changed.  Do not assume lb->alloc * 2 cannot overflow.
(resize_line, line_copy): Use xpalloc instead of doing realloc by
hand, which might suffer integer overflow.
(str_append_modified): Do not add n to to->length until
after it's known this cannot overflow.
(read_file_line): Don’t assume ssize_t fits in long.
(get_backup_file_name): Don’t assume string length fits in int.
Do not assume PTR-1+1 works; behavior is undefined if PTR
is at buffer start.  Check for integer overflow in buffer
size calculation.
(read_pattern_space): Check for line number overflow.
(match_address_p): Check for address overflow.
(debug_print_line): Omit unnecessary test for in->active being null.
(execute_program): Check for Q overflow.
* sed/regexp.c: Include <stdckdint.h>.
(match_regex): Don’t assume TYPE_MAXIMUM (regoff_t) == INT_MAX.
* sed/sed.c: Include inttypes.h, for strtoimax.
(main): Use strtoimax, not atoi.
* sed/utils.c (init_buffer): Use xmalloc and xpalloc
instead of guessing sizes ourselves, and unnecessarily
initializing.
(resize_buffer): Remove; all callers changed to use xpalloc.
(free_buffer): Don’t call free (NULL), since we already
test whether the pointer is null.
2022-12-19 12:35:32 -08:00
Paul Eggert b82f32d708 maint: update .gitignore 2022-12-17 20:57:23 -08:00
Paul Eggert cc351c8251 Update, simplify, and sort .gitignore files 2022-07-02 17:06:39 -05:00
Jim Meyering 3f469c20da build: update gnulib to latest
* gnulib: update to latest
* .gitignore files: Reflect gnulib changes.
* bootstrap: update from gnulib
2021-07-10 14:46:53 -07:00
Jim Meyering 598c3a0dd9 tests: handle missing perl
Before this change, the two perl-requiring tests would fail
on systems without perl. Now, they are skipped, as intended.
* bootstrap.conf (gnulib_modules): Add perl.
* testsuite/no-perl: New file. From coreutils.
* testsuite/local.mk (EXTRA_DIST): Add it.
(TESTSUITE_PERL): Include testsuite/ prefix.
2020-01-09 22:56:39 -08:00
Assaf Gordon 159675c030 maint: update .gitignore
Following gnulib recent update.
* lib/.gitignore, m4/.gitignore: Update file list.
2018-12-05 21:07:57 -07:00
Assaf Gordon 44d99bf5c9 gnulib: update to latest (with fix for dfa newline bug)
sed-4.3 would segfault due to dfa bug, see https://bugs.gnu.org/25390 .

* gnulib: Update to latest with various dfa fixes and improvement.
* m4/.gitignore: Add 'std-gnu11.m4', 'pthread_rwlock_rdlock.m4'.
2017-01-16 23:40:00 -05:00
Assaf Gordon 53e2747eb5 maint: update m4/.gitignore
* m4/.gitignore: Add 'dirfd.m4', 'hard-locale.m4'.
2016-12-22 09:44:33 +01:00
Jim Meyering 9ce9ee19f8 gnulib: update to latest and adapt to modified dfa API
* sed/regexp.c (compile_regex_1): Do away with use of DFA_CASE_FOLD.
This gnulib update pulls in a dfa module in which that symbol no
longer exists.  Instead, it uses RE_ICASE in syntax bits.
* m4/.gitignore: Add files created by running bootstrap.
* lib/.gitignore: Likewise.
2016-12-18 11:13:06 -08:00
Norihiro Tanaka 7c5b3bed65 sed: fix multi-line regex matching with -z
Sed incorrectly matches the anchor '^' to a newline character
(ASCII 10) despite using NUL line terminators (-z).
See https://bugs.gnu.org/24615 .

Previous (incorrect) behavior:

    $ printf "a\0b\0" | sed -z 'N;s/^/X/mg;' | od -An -a
       X   a nul   b nul

With this fix:

    $ printf "a\0b\0" | sed -z 'N;s/^/X/mg;' | od -An -a
       X   a nul   X   b nul

Current regex engine can not handle NUL multiline anchors.
Implement such search manually (by breaking the pattern into separate
NUL-terminated lines) and searching each one individually.

* NEWS: Mention it.
* sed/regexp.c (compile_regex_1): Don't use newline_anchor of regex, if
the buffer delimiter is not newline character.
(match_regex): Do above case line-by-line.
* testsuite/zero-anchor.good, testsuite/zero-anchor.inp,
  testsuite/zero-anchor.sed: New test.
* testsuite/local.mk: Add the test.
* testsuite/Makefile.tests: Add the test.
* bootstrap.conf: Add memrchr.
* lib/.gitignore, m4/.gitignore: Ignore memrchr files.
2016-11-04 21:03:46 -04:00
Jim Meyering b2d8e03acb gnulib: update to latest 2016-10-02 14:16:31 -07:00
Jim Meyering ba26be8954 dfa: reflect move of dfa code to new gnulib module
* bootstrap.conf (gnulib_modules): Add dfa.
* sed/dfa.c: Remove file.
* sed/dfa.h: Likewise.
* sed/local.mk (sed_sed_SOURCES): Remove dfa.c.
(NOINST_HEADERS): Remove dfa.h.
* sed/regexp.c (compile_regex_1): Use new dfasyntax API.
* sed/sed.c (localeinfo): New global.
(main): Call init_localeinfo to initialize it.
* sed/sed.h: Include localeinfo.h and declare the new global.
* lib/.gitignore: Ignore new gnulib-imported files.
* m4/.gitignore: Likewise.
* po/POTFILES.in: s,sed/dfa.c,lib/dfa.c,
2016-09-11 20:53:03 -07:00
Assaf Gordon bc182c966e maint: update .gitignore after bootstrap
Added by running ./bootstrap on a clean sed repository.

* build-aux/.gitignore: Add config.rpath.
* lib/.gitignore: Add additional gnulib C files.
* m4/.gitignore: Add additional gnulib m4 files.
* po/.gitignore: Add additional PO-related files.
2016-07-26 22:13:37 -04:00
Assaf Gordon 3b29bece3e build: switch to non-recursive makefile
* .gitignore: Ignore '.dirstamp' files
* bootstrap.conf: Add 'non-recursive-gnulib-prefix-hack' gnulib module.
  Add missing 'stdalign' module.
  (bootstrap_post_import_hook): Use module to adjust gnulib.mk file.
* configure.ac: Add 'subdir-objects' automake option, don't generate
  makefiles in subdirectories. Adjust path of XFAIL tests.
* Makefile.am: Include 'local.mk' files, adjust for non-recursive make.
* doc/Makefile.am: Rename to ...
* doc/local.mk: Adjust paths. Rename SED to
  SEDBIN variable, to avoid overriding the default system-wide SED value
  which is automatically set by autotools.
* lib/Makefile.am: Rename to ...
* lib/local.mk: Adjust paths.
* lib/.gitignore: Ignore 'stdalign.h' from gnulib module.
* sed/Makefile.am: Rename to ...
* sed/local.mk: Adjust paths.
* testsuite/Makefile.am: Rename to ...
* testsuite/local.mk: Adjust paths.
* testsuite/init.cfg: Move to ...
* init.cfg: ... here. Moved to avoid changing the path in init.sh, and to
  keep the same directory structure as coreutils.
  (require_en_utf8_locale_): Adjust path for get-mb-cur-max executable.
  (require_ja_shiftjis_locale_,require_valid_ja_shiftjis_locale_): Adjust
  path for test-mbrtowc executable.
* m4/.gitignore: Add gnulib's non-recusive-make module.
* testsuite/runtest: Adjust paths of Makefile.tests and dir variables,
  Skip utility program 'get-mb-cur-max' which is not a standalone test.
* testsuite/Makefile.tests: Adjust path of sed exeutable.
* testsuite/eval.sed, testsuite/eval.good: Adjust path of sed executable.
* testsuite/cmd-R.sh,
  testsuite/cmd-l.sh,
  testsuite/colon-with-no-label.sh,
  testsuite/comment-n.sh,
  testsuite/compile-errors.sh,
  testsuite/compile-tests.sh,
  testsuite/convert-number.sh,
  testsuite/execute-tests.sh,
  testsuite/follow-symlinks-stdin.sh,
  testsuite/follow-symlinks.sh,
  testsuite/help-version.sh,
  testsuite/in-place-hyphen.sh,
  testsuite/in-place-suffix-backup.sh,
  testsuite/invalid-mb-seq-UMR.sh,
  testsuite/mb-bad-delim.sh,
  testsuite/mb-charclass-non-utf8.sh,
  testsuite/mb-match-slash.sh,
  testsuite/mb-y-translate.sh,
  testsuite/normalize-text.sh,
  testsuite/nulldata.sh,
  testsuite/panic-tests.sh,
  testsuite/posix-char-class.sh,
  testsuite/posix-mode-N.sh,
  testsuite/posix-mode-addr.sh,
  testsuite/posix-mode-bad-ref.sh,
  testsuite/posix-mode-s.sh,
  testsuite/range-overlap.sh,
  testsuite/recursive-escape-c.sh,
  testsuite/regex-errors.sh,
  testsuite/stdin-prog.sh,
  testsuite/subst-mb-incomplete.sh,
  testsuite/subst-options.sh,
  testsuite/subst-replacement.sh,
  testsuite/temp-file-cleanup.sh,
  testsuite/unbuffered.sh: Adjust paths of init.sh, sed executable.
2016-07-24 22:22:53 -04:00
Assaf Gordon 77a7c6a731 tests: skip tests upon buggy mbrtowc implementations
Sed tests purposefully use invalid non-utf8 multibyte sequences to
test sed's handling of invalid input/program.
Some implementations wrongly accept invalid sequences, causing false
alarms. Add a test program to detect such buggy implementations and skip
the tests if needed.
See discussion in:
http://lists.gnu.org/archive/html/sed-devel/2016-07/msg00005.html
http://lists.gnu.org/archive/html/sed-devel/2016-07/msg00000.html
http://lists.gnu.org/archive/html/sed-devel/2016-06/msg00031.html
http://lists.gnu.org/archive/html/sed-devel/2016-06/msg00014.html

* bootstrap.conf: Add gnulib's closeout module.
* m4/.gitignore, lib/.gitignore, po/POTFILES.in: Adjust after adding
closeout module.
* testsuite/Makefile.am (check_PROGRAMS): Add new program.
* testsuite/test-mbrtowc.c: New program.
* testsuite/init.cfg (require_valid_ja_eucjp_locale_)
(require_valid_ja_shiftjis_locale_): New functions. Call test-mbrtowc
with known invalid multibyte sequences to ensure implementation is not
buggy and rejects them; Skip test otherwise.
* testsuite/invalid-mb-seq-UMR.sh: Use require_valid_ja_eucjp_locale_.
* testsuite/mb-charclass-non-utf8.sh: Use require_valid_ja_shiftjis_locale_.
2016-07-06 20:29:07 -04:00
Jim Meyering 29baca551b maint: add "/*~" to build-aux/ and m4/.gitignore files
Otherwise, bootstrap would add entries for individual file names.
* build-aux/.gitignore: Add /*~
* m4/.gitignore: Likewise.
2015-05-02 10:13:25 -07:00
Jim Meyering 082b25cc3e maint: update copyright year ranges to include 2015; update gnulib 2015-01-01 19:18:17 -08:00
Jim Meyering 671770af8b build: use gnulib's manywarnings module
bootstrap.conf: Add the module name.
configure.ac: Copy boilerplate and exclusions from coreutils.
sed/Makefile.am (AM_CFLAGS): Define in terms of the two new
variables, $(WARN_CFLAGS) and $(WERROR_CFLAGS).
m4/.gitignore: Add the two new .m4 files.
2014-11-30 21:08:33 -08:00
Jim Meyering f147efc9ef maint: update autogenerated .gitignore files 2014-11-30 18:59:32 -08:00
Paolo Bonzini a0f80adf07 Update to latest gnulib.
2012-12-21  Paolo Bonzini  <bonzini@gnu.org>

	* gnulib: Update.
	* testsuite/version.gin: Regenerate.
2012-12-22 15:17:30 +01:00
Paolo Bonzini 1e0501c438 update gnulib to latest
2012-03-16  Paolo Bonzini  <bonzini@gnu.org>

	* gnulib: Update.
2012-03-16 09:42:52 +01:00
Paolo Bonzini 90b2d54032 update .gitignore files 2011-08-29 10:29:31 +02:00
Paolo Bonzini 971249a020 update .gitignore files 2010-10-31 22:56:22 +01:00
Paolo Bonzini a9bf076c0b use version-etc-fsf
2010-08-30  Paolo Bonzini  <bonzini@gnu.org>

	* Makefile.am (dist-hook): Remove COPYRIGHT_YEAR check.
	* autoboot.conf (gnulib_modules): Add version-etc-fsf.
	* configure.ac (COPYRIGHT_YEAR): Remove.  Change package name to
	"GNU sed".
	* doc/sed.1: Regenerate.
	* sed/sed.c (AUTHORS): New.
	(main): Use version_etc.
2010-08-30 12:18:50 +02:00
Paolo Bonzini a85e83d0db use mkostemp(template, 0) instead of mkstemp to work around Cygwin oddity
2010-07-16  Paolo Bonzini  <bonzini@gnu.org>

	* autoboot.conf (gnulib_modules): Replace mkstemp with mkostemp.
	* bootstrap.sh.in: Compile mkostemp.c instead of mkstemp.c.
        * gnulib: Update.
        * NEWS: Mention change.
	* sed/utils.c (ck_mkstemp): Use mkostemp to work around Cygwin
	oddity.  Reported by Stepan Kasal.
2010-07-16 22:01:35 +02:00
Paolo Bonzini fa01dd7e73 preserve security contexts too on sed -i
2009-06-25  Paolo Bonzini  <bonzini@gnu.org>

	* autoboot.conf: Add selinux-h.
	* execute.c: Copy over file creation context before creating a new file.
2009-06-26 12:13:56 +02:00
Paolo Bonzini 9e971bab12 update gnulib prior to release 2009-03-31 10:02:59 +02:00
Paolo Bonzini a25af355ed remove memchr, memcmp, memmove compatibility code.
2009-01-20  Paolo Bonzini  <bonzini@gnu.org>

	* autoboot.conf, bootstrap.sh.in: Remove memchr, memcmp, memmove
	compatibility code.
	* gnulib: Update.
2009-01-20 10:20:38 +01:00
Paolo Bonzini e5e82af9ad update gnulib to fix two regex matcher bugs
2009-01-09  Paolo Bonzini  <bonzini@gnu.org>

	* tests/SPENCER.tests: Add testcases for glibc bugzilla 697.
2009-01-09 11:17:17 +01:00
Paolo Bonzini 559a106598 use gnulib's emulation for mb functions
2008-12-22  Paolo Bonzini  <bonzini@gnu.org>

	* autoboot.conf: Request modules emulating mb functions.
	* configure.ac: Do not look for mb functions here.
2008-12-22 11:26:19 +01:00
Paolo Bonzini 07df2df3c2 update gnulib
2008-09-28  Paolo Bonzini  <bonzini@gnu.org>

	* basicdefs.h: Replace alloca cruft with alloca.h.
	* bootstrap.sh.in: Update for new gnulib.
	* bootstrap.sh: Update for new gnulib.
	* configure.ac: Move gnulib macros earlier.
	* sed/execute.c: Do not include acl.h when bootstrapping.
2008-09-28 18:47:58 +02:00
Paolo Bonzini 48738553ce add m4/.gitignore file 2008-08-21 09:31:25 +02:00