mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
libcmd/wclib: Fix for wide char handling (Solaris 055-CR7026179)
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.
This commit is contained in:
parent
4c75920baa
commit
c69bf543cf
1 changed files with 10 additions and 0 deletions
|
@ -341,6 +341,7 @@ int wc_count(Wc_t *wp, Sfio_t *fd, const char* file)
|
||||||
int xspace;
|
int xspace;
|
||||||
int wasspace = 1;
|
int wasspace = 1;
|
||||||
unsigned char* start;
|
unsigned char* start;
|
||||||
|
int flagm = 0;
|
||||||
|
|
||||||
lastchar = 0;
|
lastchar = 0;
|
||||||
start = (endbuff = side) + 1;
|
start = (endbuff = side) + 1;
|
||||||
|
@ -367,6 +368,7 @@ int wc_count(Wc_t *wp, Sfio_t *fd, const char* file)
|
||||||
if(mbc(lasttype))
|
if(mbc(lasttype))
|
||||||
{
|
{
|
||||||
c = lasttype;
|
c = lasttype;
|
||||||
|
flagm = 1;
|
||||||
goto mbyte;
|
goto mbyte;
|
||||||
}
|
}
|
||||||
if(!lasttype && spc(type[*cp]))
|
if(!lasttype && spc(type[*cp]))
|
||||||
|
@ -415,6 +417,14 @@ int wc_count(Wc_t *wp, Sfio_t *fd, const char* file)
|
||||||
skip = (c&7);
|
skip = (c&7);
|
||||||
adjust += skip;
|
adjust += skip;
|
||||||
state = 0;
|
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)))
|
if(skip==2 && (cp[-1]&0xc)==0 && (state=(cp[-1]&0x3)))
|
||||||
oldc = *cp;
|
oldc = *cp;
|
||||||
else if(xspace && cp[-1]==0xc2)
|
else if(xspace && cp[-1]==0xc2)
|
||||||
|
|
Loading…
Reference in a new issue