about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2005-01-22 04:03:05 +0000
committerClint Adams <clint@users.sourceforge.net>2005-01-22 04:03:05 +0000
commit0038b1a68265a2c8136f90d63fae15a121b9341c (patch)
treed1fd810bcf817cf9fa04da712bf304b33a6fc4e6 /Src/Zle
parentd94e9817cec2b0c2fd692fd839f77f376309008a (diff)
downloadzsh-0038b1a68265a2c8136f90d63fae15a121b9341c.tar.gz
zsh-0038b1a68265a2c8136f90d63fae15a121b9341c.tar.xz
zsh-0038b1a68265a2c8136f90d63fae15a121b9341c.zip
* 2073x: Src/Zle/zle_utils.c, Src/hist.c: modify zlegetline() and zlegetline
   caller so that the octet-based and wide-character versions should return
   the same string.
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/zle_utils.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 611e7414f..d769e8363 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -89,10 +89,35 @@ zleaddtoline(int chr)
 mod_export unsigned char *
 zlegetline(int *ll, int *cs)
 {
+    char *s;
+#ifdef ZLE_UNICODE_SUPPORT
+    char *mb_cursor;
+    int i, j;
+    size_t mb_len = 0;
+
+    mb_cursor = s = zalloc(zlell * MB_CUR_MAX);
+
+    for(i=0;i<=zlell;i++) {
+	if (i == zlecs)
+	    *cs = mb_len;
+	j = wctomb(mb_cursor, zleline[i]);
+	if (j == -1) {
+	    /* invalid char; what to do? */
+	} else {
+	    mb_len += j;
+	}
+    }
+
+    *ll = mb_len;
+
+    return (unsigned char *)s;
+#else
     *ll = zlell;
     *cs = zlecs;
 
-    return zleline;
+    s = ztrdup(zleline);
+    return (unsigned char *)s;
+#endif
 }