From 23bd860ef74da155745a4644d7d396e320eec913 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Wed, 11 Jan 2006 20:01:27 +0000 Subject: 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. --- Src/utils.c | 12 ++++++------ 1 file 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; -- cgit 1.4.1