about summary refs log tree commit diff
path: root/Src/Zle/zle_tricky.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-08-03 15:37:49 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-08-03 15:37:49 +0000
commit48d6402e65f87427d83a516e5296d677735f0022 (patch)
tree8879ee181827627d65ac60f3f822f5294c845778 /Src/Zle/zle_tricky.c
parent07f11ba6bf609797f42c1ac768184b359a4e6ad7 (diff)
downloadzsh-48d6402e65f87427d83a516e5296d677735f0022.tar.gz
zsh-48d6402e65f87427d83a516e5296d677735f0022.tar.xz
zsh-48d6402e65f87427d83a516e5296d677735f0022.zip
rationalise mb<->wc conversions to use restartable form
Diffstat (limited to 'Src/Zle/zle_tricky.c')
-rw-r--r--Src/Zle/zle_tricky.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index fb0ebad2a..4b7d3126d 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2464,16 +2464,20 @@ magicspace(char **args)
     ZLE_STRING_T bangq;
     ZLE_CHAR_T zlebangchar[1];
     int ret;
+#ifdef MULTIBYTE_SUPPORT
+    mbstate_t mbs;
+#endif
+
     fixmagicspace();
 
 #ifdef MULTIBYTE_SUPPORT
     /*
-     * TODO: bangchar should really be a multibyte string representing
-     * a single character, since there's no fundamental reason why
-     * it shouldn't be a Unicode character.  In practice this is
-     * very minor, however.
+     * Use mbrtowc() here for consistency and to ensure the
+     * state is initialised properly.  bangchar is unsigned char,
+     * but must be ASCII, so we simply cast the pointer.
      */
-    if (mbtowc(zlebangchar, (char *)&bangchar, 1) < 0)
+    memset(&mbs, 0, sizeof(mbs));
+    if (mbrtowc(zlebangchar, (char *)&bangchar, 1, &mbs) < 0)
 	return selfinsert(args);
 #else
     zlebangchar[0] = bangchar;