[RFC PATCH 6/9] msvcrt: Add _wctype table.

Jeff Smith whydoubt at gmail.com
Thu Jan 9 13:25:44 CST 2020


On Thu, Jan 9, 2020 at 12:32 PM Chip Davis <cdavis at codeweavers.com> wrote:
>
> January 9, 2020 12:55 AM, "Jeff Smith" <whydoubt at gmail.com> wrote:
>
> > diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
> > index 600c4db008..efb879a89d 100644
> > --- a/dlls/msvcrt/wcs.c
> > +++ b/dlls/msvcrt/wcs.c
> > @@ -40,6 +40,64 @@ static BOOL n_format_enabled = TRUE;
> >  #include "printf.h"
> >  #undef PRINTF_WIDE
> >
> > +/* Some abbreviations to make the following table readable */
> > +#define _C_ MSVCRT__CONTROL
> > +#define _S_ MSVCRT__SPACE
> > +#define _P_ MSVCRT__PUNCT
> > +#define _D_ MSVCRT__DIGIT
> > +#define _H_ MSVCRT__HEX
> > +#define _U_ MSVCRT__UPPER|0x100
> > +#define _L_ MSVCRT__LOWER|0x100
> > +#define _B_ MSVCRT__BLANK
> > +
> > +#if _MSVCR_VER==120
> > +#define _SUP_ _P_
> > +#else
> > +#define _SUP_ _P_|_D_
> > +#endif
> > +
> > +#if _MSVCR_VER>=120
> > +#define _B120_ 0
> > +#else
> > +#define _B120_ _B_
> > +#endif
> > +
> > +#if _MSVCR_VER>=140
> > +#define _S140_ _S_
> > +#define _C140_ _C_
> > +#define _L140_ _L_
> > +#else
> > +#define _S140_ 0
> > +#define _C140_ 0
> > +#define _L140_ 0
> > +#endif
> > +
> > +WORD MSVCRT__wctype [257] = {
> > +    0,
> > +    _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_C_|_B120_, _S_|_C_, _S_|_C_,
> > +      _S_|_C_, _S_|_C_, _C_, _C_,
> > +    _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
> > +    _S_|_B_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_,
> > +    _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_,
> > +    _D_|_H_, _D_|_H_, _P_, _P_, _P_, _P_, _P_, _P_,
> > +    _P_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_, _U_, _U_,
> > +      _U_, _U_, _U_, _U_, _U_, _U_,
> > +    _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _P_, _P_, _P_, _P_, _P_,
> > +    _P_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_, _L_, _L_, _L_,
> > +      _L_, _L_, _L_, _L_, _L_, _L_,
> > +    _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _P_, _P_, _P_, _P_, _C_,
> > +    _C_, _C_, _C_, _C_, _C_, _C_|_S140_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
> > +    _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
> > +    _S_|_B120_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_|_L140_, _P_,
> > +      _P_, _P_|_C140_, _P_, _P_,
> > +    _P_, _P_, _SUP_, _SUP_, _P_, _P_|_L140_, _P_, _P_, _P_, _SUP_, _P_|_L140_, _P_,
> > +      _P_, _P_, _P_, _P_,
> > +    _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_,
> > +    _U_, _U_, _U_, _U_, _U_, _U_, _U_, _P_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _L_,
> > +    _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_,
> > +    _L_, _L_, _L_, _L_, _L_, _L_, _L_, _P_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_
> > +};

Hi Chip,

> But wait, WEOF in msvcrt is not (wint_t)(-1) but (wint_t)0xffff. Passing WEOF to this array won't do what you think it does. Is this really what native has?

Also in msvcrt, the first parameter to iswctype is MSVCRT_wchar_t ...
defined as an unsigned short.  So I expected the values to be in the
range 0..65535

Yes, this table does match the native _wctype table, which I've seen 3
versions of: one for msvcrt40-msvcr110, one for msvcr120, and one for
ucrtbase.
Then _pwctype (or the return value from calling __pwctype_func) points
to the second entry of this table.
In the testing I've done, the lower portion follows the library (e.g.
msvcrt or msvcr120 or ucrtbase) vs the upper portion follows the OS
(e.g. Win10 or WinXP).

In my implementation, for values 0..255, iswctype will return the
value from the _pwctype table, for 256..65535 it will fall back to
wine_wctype_table (via get_char_typeW).

Thanks,
Jeff



More information about the wine-devel mailing list