SHLWAPI: implement PathIsValidChar{A,W}

Hans Leidekker hans at it.vu.nl
Mon Jan 31 03:09:34 CST 2005


On Sunday 30 January 2005 22:29, Juan Lang wrote:

> Hi Hans, it looks like from values 0x7e onward the character class is
> always PATH_CHAR_CLASS_OTHER_VALID.  If you like, for clarity you can fill
> in the value through 0x7f, but having a lookup table beyond this isn't
> necessary.

Yes I contemplated that but then you reintroduce a conditional in
the ascii case ( if (c > 0x7e) ), which somewhat defeats the purpose
of using a lookup table.

> Also, that means the data type can be unsigned char, not DWORD.

I don't understand you, char class values are DWORD. Do you
mean that, given the number of class values, you could squeeze
them into an unsigned char? Again, then you would have to do more
computation, right? The quest was for speed, not so much for space.

> +BOOL WINAPI PathIsValidCharW( WCHAR c, DWORD class )
> +{
> +    if (c > 0xff) return PATH_CHAR_CLASS_OTHER_VALID;
> +    return PathIsValidCharAW( (unsigned char)c, class );
> +}
>
> But for values of c greater than 0xff, you do not mask.  This may be
> deliberate, I don't know, but it doesn't look correct.

It's deliberate and correct. PATH_CHAR_CLASS_OTHER_VALID *is* a mask so I
do return the same value in both cases. Also remember that the return
type is a BOOL so we could return TRUE everywhere but I chose to mimic
Windows here and return a masked value. The tests show this is the case.

> p.s. Have you added me to your spam list yet? ;)

Of course not! I welcome every opportunity to learn. Thanks for your
constructive criticism.

 -Hans



More information about the wine-devel mailing list