summaryrefslogtreecommitdiff
path: root/Src/subst.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c15
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);