* 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.
50 lines
1.5 KiB
C
50 lines
1.5 KiB
C
/* GNU SED, a batch stream editor.
|
|
Copyright (C) 1998-2026 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; If not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef BASICDEFS_H
|
|
#define BASICDEFS_H
|
|
|
|
#include <locale.h>
|
|
#include <stdbool.h>
|
|
|
|
#include <gettext.h>
|
|
#define _(String) gettext(String)
|
|
|
|
#include "idx.h"
|
|
#include "xalloc.h"
|
|
|
|
#define obstack_chunk_alloc xzalloc
|
|
#define obstack_chunk_free free
|
|
|
|
/* MAX_PATH is not defined in some platforms, most notably GNU/Hurd.
|
|
In that case we define it here to some constant. Note however that
|
|
this relies in the fact that sed does reallocation if a buffer
|
|
needs to be larger than PATH_MAX. */
|
|
#ifndef PATH_MAX
|
|
# define PATH_MAX 200
|
|
#endif
|
|
|
|
#ifndef initialize_main
|
|
# ifdef __EMX__
|
|
# define initialize_main(argcp, argvp) \
|
|
{ _response (argcp, argvp); _wildcard (argcp, argvp); }
|
|
# else /* NOT __EMX__ */
|
|
# define initialize_main(argcp, argvp)
|
|
# endif
|
|
#endif
|
|
|
|
#endif /*!BASICDEFS_H*/
|