Paul Eggert 2b155a6c8b sed: support multibyte delimiters
* basicdefs.h: Do not include wchar.h, wctype.h.
(ISASCII, ISBLANK, ISSPACE): Remove.  All uses replaced
by c32isblank, c32isspace.
* bootstrap.conf (gnulib_modules): Add c32isblank, c32isprint,
c32isspace, c32rtomb, c32toower, c32toupper, mcel.  Remove btowc,
localcharset, mbrlen, mbrtowc, mbsinit, wcrtomb, wctob, wctype-h.
* configure.ac: Do not check for headers locale.h, errno.h,
wchar.h, wctype.h, mcheck.h.
Do not check for isascii.  Remove ac_cv_func_wcscoll hack.
(XFAIL_TESTS): Remove check for whether to run UTF-8 Cyrillic
tests, as I hope the other changes in this patch should fix
problems in that area.
* lib/.gitignore, m4/.gitignore: Adjust
* sed/compile.c (struct prog_info.prev): New member.
Adjust all users of this struct to update and use it when needed.
(INCHAR_EOF): New constant.
(inchar): Return a char32_t value for each wide character, a
negative byte value for encoding errors, and INCHAR_EOF for end of
input.  All callers changed.
(savchar): Now takes no arguments.  All callers changed.
(in_nonblank): Use char32_t tests rather than ctype.h tests.
(add_prev_to_buffer): New function.
(add_then_next, match_slash, read_text):
Use add_prev_to_buffer instead of add1_buffer when the idea is to
copy a character from input to output, as the character might be
multibyte and add1_buffer does only single-byte.
(match_slash): Support multibyte delimiters.  Test for matchers
individually rather than via strchr, to make it clearer that we
are not testing for '\0'.
* sed/compile.c (add_then_next, snarf_char_class):
* sed/debug.c (debug_print_mb):
* sed/execute.c (line_init, line_reset, line_copy, line_append)
(line_exchange):
Remove now-unnecessary arg.  All callers changed.
* sed/compile.c (compile_program, normalize_text):
* sed/debug.c (debug_print_regex_pattern):
* sed/execute.c (str_append_modified, do_list, translate_mb)
(debug_print_line):
Use mcel_scan/c32rtomb1 not mbrtowc1/mbrlen1/wcrtomb,
as mcel_scan should work better on MS-Windows.
* sed/debug.c (debug_print_char): Replace args c and clen
with an mcel_t arg g.  All callers changed.
(debug_print_mb): Adjust to new meaning of int “characters”.
* sed/execute.c (struct line.mbstate): Remove.  All uses removed.
(str_append): Omit no-longer-needed code put in just to update a
no-longer-needed mbstate_t.
(str_append_modified): Don’t worry about c32rtomb1 returning
(size_t) -1, as it now returns idx_t and anyway that cannot happen.
* sed/mbcs.c: Don’t include string.h, localcharset.h.
(is_mb_char, is_utf8): Remove.  All uses removed.
* sed/sed.h: Include mcel.h.
(mbrtowc1, mbrlen1): Remove.  All callers changed to use mcel_scan.
(c32rtomb1): New function.
(IS_MB_CHAR): Remove; no longer used.
* sed/utils.c (add1_buffer): Now returns void, since no caller
used the return value.  2nd arg is now char, not int.
Remove special case for EOF.  All callers changed.
* testsuite/mb-bad-delim.sh, testsuite/mb-y-translate.sh:
Multibyte delimiters are no longer prohibited, so adjust test
cases accordingly.  Put newlines at end of text files,
as required by POSIX.
2026-08-17 01:17:23 -07:00
2026-01-02 17:33:20 -08:00
2026-08-17 01:17:23 -07:00
2026-08-17 01:17:23 -07:00
2026-08-17 01:17:23 -07:00
2026-08-17 01:17:23 -07:00
2008-04-10 11:14:38 +02:00
2023-02-04 21:43:48 -08:00
2022-10-16 20:12:20 -07:00
2016-08-22 20:57:02 -04:00
2026-08-17 01:17:23 -07:00
2023-01-30 09:58:54 -08:00
2026-08-17 01:17:23 -07:00
2026-08-17 01:17:23 -07:00
2022-07-02 17:06:39 -05:00
2026-01-02 17:33:20 -08:00
2026-08-17 01:17:23 -07:00
2024-01-05 08:44:01 -08:00
2026-01-02 17:33:20 -08:00

This is the GNU implementation of sed, the Unix stream editor.

GNU Sed website: https://www.gnu.org/software/sed/

See the NEWS file for a brief summary and the ChangeLog for
more detailed descriptions of changes.

If you obtained this file as part of a "git clone", then see the
README-hacking file.  If this file came to you as part of a tar archive,
then see the file INSTALL for compilation and installation instructions.

See the file BUGS for instructions about reporting bugs.

See the files AUTHORS and THANKS for a list of authors and other contributors.

See the file COPYING for copying conditions.

After installation run 'sed --help' or 'man sed' for short usage information,
and 'info sed' for the complete manual. The manual is also available on
sed's website.
S
Description
SED (stream editor) - неинтерактивный текстовый редактор командной строки
https://www.gnu.org/software/sed/
Readme GPL-3.0
3 MiB
0 Stars 1 Watchers 0 Forks
Languages
Shell 43%
C 26.4%
Perl 16.5%
sed 7.3%
Makefile 5.2%
Other 1.6%