1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

50658 + test: Enable to switch between C/UTF-8 locales in PCRE

This commit is contained in:
Jun-ichi Takimoto 2022-09-26 10:52:50 +09:00
parent 6e827d8f9a
commit 1b421e4978
3 changed files with 18 additions and 8 deletions

View file

@ -1,3 +1,8 @@
2022-09-26 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
* 50658 + test: Src/Modules/pcre.c, Test/V07pcre.ztst: Enable to
switch between C/UTF-8 locales in PCRE
2022-09-25 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 50648: Functions/Misc/zcalc: Julian Prein: Use ZCALC_HISTFILE

View file

@ -47,8 +47,6 @@ zpcre_utf8_enabled(void)
#if defined(MULTIBYTE_SUPPORT) && defined(HAVE_NL_LANGINFO) && defined(CODESET)
static int have_utf8_pcre = -1;
/* value can toggle based on MULTIBYTE, so don't
* be too eager with caching */
if (have_utf8_pcre < -1)
return 0;
@ -56,15 +54,11 @@ zpcre_utf8_enabled(void)
return 0;
if ((have_utf8_pcre == -1) &&
(!strcmp(nl_langinfo(CODESET), "UTF-8"))) {
if (pcre_config(PCRE_CONFIG_UTF8, &have_utf8_pcre))
(pcre_config(PCRE_CONFIG_UTF8, &have_utf8_pcre))) {
have_utf8_pcre = -2; /* erk, failed to ask */
}
if (have_utf8_pcre < 0)
return 0;
return have_utf8_pcre;
return (have_utf8_pcre == 1) && (!strcmp(nl_langinfo(CODESET), "UTF-8"));
#else
return 0;

View file

@ -162,3 +162,14 @@
echo $match[2] )
0:regression for segmentation fault, workers/38307
>test
LANG_SAVE=$LANG
[[ é =~ '^.\z' ]]; echo $?
LANG=C
[[ é =~ '^..\z' ]]; echo $?
LANG=$LANG_SAVE
[[ é =~ '^.\z' ]]; echo $?
0:swich between C/UTF-8 locales
>0
>0
>0