summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2023-01-12 19:35:08 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2023-01-12 23:32:16 -0800
commit3635121123e086b9092c7118dc0a99cb1736dc25 (patch)
treea40fffe23e2e869266d831dada475e88fa2e8eaf /src
parent8f6a1e90e4f14390ef2171aa37a1866f90292914 (diff)
downloadgrep-3635121123e086b9092c7118dc0a99cb1736dc25.tar.gz
grep: diagnose no UTF-8 support (Bug#60708)
* src/pcresearch.c (Pcompile): Issue a diagnostic and exit instead of misbehaving if libpcre2 does not support the requested locale.
Diffstat (limited to 'src')
-rw-r--r--src/pcresearch.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/pcresearch.c b/src/pcresearch.c
index a8034fbc..5b111bea 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -145,10 +145,12 @@ 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);
- uint32_t unicode = 1;
- pcre2_config (PCRE2_CONFIG_UNICODE, &unicode);
- if (unicode && localeinfo.multibyte)
+ if (localeinfo.multibyte)
{
+ uint32_t unicode;
+ if (pcre2_config (PCRE2_CONFIG_UNICODE, &unicode) < 0 || !unicode)
+ die (EXIT_TROUBLE, 0,
+ _("-P supports only unibyte locales on this platform"));
if (! localeinfo.using_utf8)
die (EXIT_TROUBLE, 0, _("-P supports only unibyte and UTF-8 locales"));
flags |= (PCRE2_UTF | PCRE2_UCP);