Avoid using isspace()/isdigit() for WCHARs.

Hans Leidekker hans at codeweavers.com
Thu May 18 06:24:12 CDT 2017


On Thu, 2017-05-18 at 10:11 +0000, Hugh McMaster wrote:
> On Thursday, 18 May 2017 6:16 PM, Hans Leidekker wrote:
> > +/*
> > +** WCHAR safe version of isdigit()
> > +*/
> > +static inline int isDigit(WCHAR c)
> > +{
> > +    return c >= '0' && c <= '9';
> > +}
> > +
> > +/*
> > +** WCHAR safe version of isspace(), except '\r'
> > +*/
> > +static inline int isSpace(WCHAR c)
> > +{
> > +    return c == ' ' || c == '\t' || c == '\n' || c == '\f';
> > +}
> 
> Why not just use Wine's inbuilt inline functions? isdigitW() and isspaceW() are in wine/unicode.h, which is already included in msi/tokenize.c.

Look at how isspace was used:

@@ -199,7 +214,7 @@ int sqliteGetToken(const WCHAR *z, int *tokenType, int *skip){
   *skip = 0;
   switch( *z ){
     case ' ': case '\t': case '\n': case '\f':
-      for(i=1; isspace(z[i]) && z[i] != '\r'; i++){}
+      for(i=1; isSpace(z[i]); i++){}

It's expected to handle a repetition of whitespace (modulo '\r') as defined by the
case statement, not the wider range covered by isspaceW.





More information about the wine-devel mailing list