Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug] busyloop upon $=var with NULs when $IFS contains both NUL and a byte > 0x7f
> 2022/11/18 23:27, Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
>
> With +o multibyte, no busy loop, but splitting doesn't work properly:
>
> $ LC_ALL=C zsh +o multibyte -c 'IFS=é$IFS; printf "<%q>\n" $=IFS'
> <$'\303'$'\251'>
> <''>
It seems this can be fixed by the following patch
(use the multibyte code only if MULTIBYTE option is on).
The test script above gives
<''>
<''>
<''>
<''>
I gess this is the expected result (the description of IFS in man
zshparam(1) is not easy to understand).
If this works OK, then I think we can force reset IFS if an invalid
character is found in it when multibyte option is on, because
if a user wants (in C locale) to include any byte in IFS then she/he
can unset multibyte option.
diff --git a/Src/utils.c b/Src/utils.c
index edf5d3df7..a182553e7 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -74,9 +74,6 @@ set_widearray(char *mb_array, Widechar_array wca)
}
wca->len = 0;
- if (!isset(MULTIBYTE))
- return;
-
if (mb_array) {
VARARR(wchar_t, tmpwcs, strlen(mb_array));
wchar_t *wcptr = tmpwcs;
@@ -4118,8 +4115,9 @@ inittyptab(void)
* having IIDENT here is a good idea at all, but this code
* should disappear into history...
*/
- for (t0 = 0240; t0 != 0400; t0++)
- typtab[t0] = IALPHA | IALNUM | IIDENT | IUSER | IWORD;
+ if isset(MULTIBYTE)
+ for (t0 = 0240; t0 != 0400; t0++)
+ typtab[t0] = IALPHA | IALNUM | IIDENT | IUSER | IWORD;
#endif
/* typtab['.'] |= IIDENT; */ /* Allow '.' in variable names - broken */
typtab['_'] = IIDENT | IUSER;
@@ -4138,7 +4136,7 @@ inittyptab(void)
DEFAULT_IFS_SH : DEFAULT_IFS; *s; s++) {
int c = STOUC(*s == Meta ? *++s ^ 32 : *s);
#ifdef MULTIBYTE_SUPPORT
- if (!isascii(c)) {
+ if (isset(MULTIBYTE) && !isascii(c)) {
/* see comment for wordchars below */
continue;
}
@@ -4154,7 +4152,7 @@ inittyptab(void)
for (s = wordchars ? wordchars : DEFAULT_WORDCHARS; *s; s++) {
int c = STOUC(*s == Meta ? *++s ^ 32 : *s);
#ifdef MULTIBYTE_SUPPORT
- if (!isascii(c)) {
+ if (isset(MULTIBYTE) && !isascii(c)) {
/*
* If we have support for multibyte characters, we don't
* handle non-ASCII characters here; instead, we turn
@@ -4168,9 +4166,11 @@ inittyptab(void)
typtab[c] |= IWORD;
}
#ifdef MULTIBYTE_SUPPORT
- set_widearray(wordchars, &wordchars_wide);
- set_widearray(ifs ? ifs : EMULATION(EMULATE_KSH|EMULATE_SH) ?
- DEFAULT_IFS_SH : DEFAULT_IFS, &ifs_wide);
+ if (isset(MULTIBYTE)) {
+ set_widearray(wordchars, &wordchars_wide);
+ set_widearray(ifs ? ifs : EMULATION(EMULATE_KSH|EMULATE_SH) ?
+ DEFAULT_IFS_SH : DEFAULT_IFS, &ifs_wide);
+ }
#endif
for (s = SPECCHARS; *s; s++)
typtab[STOUC(*s)] |= ISPECIAL;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author