Skip to content

Commit

Permalink
libcmd/wclib: Fix for wide char handling (Solaris 055-CR7026179)
Browse files Browse the repository at this point in the history
This change is pulled from here:
https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/055-CR7026179.patch

It's a fix for wide-character handling in the wc (word count)
library.
  • Loading branch information
McDutchie committed Jan 8, 2021
1 parent 4c75920 commit c69bf54
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/libcmd/wclib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c69bf54

Please sign in to comment.