diff options
author | Carlo Marcelo Arenas Belón <carenas@gmail.com> | 2023-01-06 20:40:07 -0800 |
---|---|---|
committer | Jim Meyering <meyering@meta.com> | 2023-01-11 10:24:09 -0800 |
commit | 8f6a1e90e4f14390ef2171aa37a1866f90292914 (patch) | |
tree | 064339efea3f71ab2b67bb7dd33de4f604501621 /src | |
parent | 5e3b760f65f13856e5717e5b9d935f5b4a615be3 (diff) | |
download | grep-8f6a1e90e4f14390ef2171aa37a1866f90292914.tar.gz |
pcre: use UTF only when available in the library
Before this change, if linked with a PCRE library without unicode
any invocations of grep when using a UTF locale will error with:
grep: this version of PCRE2 does not have Unicode support
* src/pcresearch.c: Check whether Unicode was compiled in.
* tests/pcre-utf8-w: Add check to skip test.
* tests/pcre-utf8: Update check.
Diffstat (limited to 'src')
-rw-r--r-- | src/pcresearch.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pcresearch.c b/src/pcresearch.c index 45b67eed..a8034fbc 100644 --- a/src/pcresearch.c +++ b/src/pcresearch.c @@ -145,7 +145,9 @@ Pcompile (char *pattern, idx_t size, reg_syntax_t ignored, bool exact) = pcre2_general_context_create (private_malloc, private_free, NULL); pcre2_compile_context *ccontext = pcre2_compile_context_create (gcontext); - if (localeinfo.multibyte) + uint32_t unicode = 1; + pcre2_config (PCRE2_CONFIG_UNICODE, &unicode); + if (unicode && localeinfo.multibyte) { if (! localeinfo.using_utf8) die (EXIT_TROUBLE, 0, _("-P supports only unibyte and UTF-8 locales")); |