about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2006-01-11 20:01:27 +0000
committerWayne Davison <wayned@users.sourceforge.net>2006-01-11 20:01:27 +0000
commit23bd860ef74da155745a4644d7d396e320eec913 (patch)
tree76e0572ce826bd579c9887a53d87767bd81e2f0b /Src
parentc6798bc1516dcd1f81b43ca010b448b65dc68228 (diff)
downloadzsh-23bd860ef74da155745a4644d7d396e320eec913.tar.gz
zsh-23bd860ef74da155745a4644d7d396e320eec913.tar.xz
zsh-23bd860ef74da155745a4644d7d396e320eec913.zip
The return value of mbrtowc() is a size_t (unsigned), so don't
assign it to an int and then check if it's <= 0, as that won't
work on a system where an int is larger than a size_t.
Diffstat (limited to 'Src')
-rw-r--r--Src/utils.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Src/utils.c b/Src/utils.c
index 3882a22ab..0c808ca25 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3560,20 +3560,20 @@ mb_width(const char *s)
      */
     while (umlen > 0) {
 	wchar_t cc;
-	int ret = mbrtowc(&cc, umptr, umlen, &mbs);
+	size_t cnt = mbrtowc(&cc, umptr, umlen, &mbs);
 
-	if (ret <= 0) {
+	if (cnt == 0 || cnt == (size_t)-1 || cnt == (size_t)-2) {
 	    /* Assume a single-width character. */
 	    width++;
-	    ret = 1;
+	    cnt = 1;
 	} else {
 	    int wret = wcwidth(cc);
 	    if (wret > 0)
 		width += wret;
 	}
 
-	umlen -= ret;
-	umptr += ret;
+	umlen -= cnt;
+	umptr += cnt;
     }
 
     free(ums);
@@ -3887,7 +3887,7 @@ dquotedztrdup(char const *s)
 		    if(pending)
 			*p++ = '\\';
 		    *p++ = '\\';
-		    /* fall through */
+		    /* FALL THROUGH */
 		default:
 		    *p++ = c;
 		    pending = 0;