diff options
author | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2023-09-27 01:56:47 +0900 |
---|---|---|
committer | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2023-09-27 01:56:47 +0900 |
commit | 02e33c54d85208c7d9b96d91a26d04069ff19ed2 (patch) | |
tree | 2d4feecc28498ffd5cac25dbec09a319de380109 /Src/subst.c | |
parent | e4e9afe373479076ee448b16944a421836ba5a40 (diff) | |
download | zsh-02e33c54d85208c7d9b96d91a26d04069ff19ed2.tar.gz zsh-02e33c54d85208c7d9b96d91a26d04069ff19ed2.tar.xz zsh-02e33c54d85208c7d9b96d91a26d04069ff19ed2.zip |
52169: a few more improvements of (#) flag
fix (#X) in C locale in FreeBSD, DragonFly, NetBSD. Negative values such as ${(#X):--1} are now error. UCS4 is limited to < 0x8000_0000 (in OSes without __STDC_ISO_10646__).
Diffstat (limited to 'Src/subst.c')
-rw-r--r-- | Src/subst.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Src/subst.c b/Src/subst.c index f37ae935e..cdbfc138a 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -1501,16 +1501,15 @@ substevalchar(char *ptr) return noerrs ? dupstring(""): NULL; } errflag |= saved_errflag; + if (ires < 0) { + zerr("character not in range"); + } #ifdef MULTIBYTE_SUPPORT - if (isset(MULTIBYTE) && ires > 127) { - /* '\\' + 'U' + 8 bytes of character + '\0' */ - char buf[11]; - - /* inefficient: should separate out \U handling from getkeystring */ - sprintf(buf, "\\U%.8x", (unsigned int)ires & 0xFFFFFFFFu); - ptr = getkeystring(buf, &len, GETKEYS_BINDKEY, NULL); + else if (isset(MULTIBYTE) && ires > 127) { + ptr = zhalloc(MB_CUR_MAX); + len = ucs4tomb((unsigned int)ires & 0xffffffff, ptr); } - if (len == 0) + if (len <= 0) #endif { ptr = zhalloc(2); |