about summary refs log tree commit diff
path: root/Src/Zle
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-12-17 17:11:29 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-12-17 17:11:29 +0000
commit20607774dc14faaa514623ef2a2f666911aa8b66 (patch)
tree2eb3a6a5f542522aec9a21876c2ee683cc42bf3f /Src/Zle
parent1ac4f6a77f5dd7d57b01f8bcfa422f17613dfc37 (diff)
downloadzsh-20607774dc14faaa514623ef2a2f666911aa8b66.tar.gz
zsh-20607774dc14faaa514623ef2a2f666911aa8b66.tar.xz
zsh-20607774dc14faaa514623ef2a2f666911aa8b66.zip
24275: fixes for multibyte characters on Solaris
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/zle_utils.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 6583ef503..a146b67c0 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -294,6 +294,16 @@ stringaszleline(char *instr, int incs, int *outll, int *outsz, int *outcs)
 		 * (certainly true for Unicode and unlikely to be false
 		 * in any non-pathological multibyte representation). */
 		cnt = 1;
+	    } else if (cnt > ll) {
+		/*
+		 * Some multibyte implementations return the
+		 * full length of a previous incomplete character
+		 * instead of the remaining length.
+		 * This is paranoia: it only applies if we start
+		 * midway through a multibyte character, which
+		 * presumably can't happen.
+		 */
+		cnt = ll;
 	    }
 
 	    if (outcs) {
@@ -843,6 +853,12 @@ showmsg(char const *msg)
 		cnt = 1;
 		/* FALL THROUGH */
 	    default:
+		/*
+		 * Paranoia: only needed if we start in the middle
+		 * of a multibyte string and only in some implementations.
+		 */
+		if (cnt > ulen)
+		    cnt = ulen;
 		n = wcs_nicechar(c, &width, NULL);
 		break;
 	    }