diff --git a/src/lib/libcmd/wclib.c b/src/lib/libcmd/wclib.c index 0d52fda40707..61efd176b07b 100644 --- a/src/lib/libcmd/wclib.c +++ b/src/lib/libcmd/wclib.c @@ -341,6 +341,7 @@ int wc_count(Wc_t *wp, Sfio_t *fd, const char* file) int xspace; int wasspace = 1; unsigned char* start; + int flagm = 0; lastchar = 0; start = (endbuff = side) + 1; @@ -367,6 +368,7 @@ int wc_count(Wc_t *wp, Sfio_t *fd, const char* file) if(mbc(lasttype)) { c = lasttype; + flagm = 1; goto mbyte; } if(!lasttype && spc(type[*cp])) @@ -415,6 +417,14 @@ int wc_count(Wc_t *wp, Sfio_t *fd, const char* file) skip = (c&7); adjust += skip; state = 0; + if(flagm==1) + { + flagm = 0; + oldc = *cp; + if(xspace && (iswspace(*cp)==1)) + state = 8; + continue; + } if(skip==2 && (cp[-1]&0xc)==0 && (state=(cp[-1]&0x3))) oldc = *cp; else if(xspace && cp[-1]==0xc2)