some ismbc* functions: third try
Greg Turner
gmturner007 at ameritech.net
Sat Nov 16 20:38:16 CST 2002
totally untested, but it does compile, and seems logical
enough. while i was at it, i added a few more.
* dlls/msvcrt: mbcs.c, msvcrt.spec:
Greg Turner <gmturner007 at ameritech.net>
- implemented some ismbc* functions according to the
advice of Dmitry Timoshkov
--
gmt
"War is an ugly thing, but not the ugliest of things;
the decayed and degraded state of moral and patriotic
feeling which thinks that nothing is worth war is much
worse. A man who has nothing for which he is willing
to fight; nothing he cares about more than his own
personal safety; is a miserable creature who has no
chance of being free, unless made and kept so by the
exertions of better persons than himself."
-- John Stuart Mill
diff -ur -x CVS -x 'bigdif*' ../wine.test/dlls/msvcrt/mbcs.c ./dlls/msvcrt/mbcs.c
--- ../wine.test/dlls/msvcrt/mbcs.c 2002-11-13 08:34:00.000000000 -0600
+++ ./dlls/msvcrt/mbcs.c 2002-11-16 20:33:23.000000000 -0600
@@ -553,25 +553,231 @@
*/
int _ismbcdigit(unsigned int ch)
{
- if (ch <0x100)
- return isdigit(ch);
- else
- {
- FIXME("Handle MBC chars\n");
- return 0;
- }
+ WCHAR chW;
+ WORD ctype;
+ char mbch[2];
+ int n_chars;
+ int cp = MSVCRT_current_lc_all_cp;
+
+ if (cp < 0) {
+ ERR("disregarding negative codepage: -%d\n", -cp);
+ cp = CP_ACP;
+ }
+
+ if (ch < 256) {
+ mbch[0] = ch & 0xff;
+ n_chars = 1;
+ } else {
+ mbch[0] = (ch >> 8) & 0xff;
+ mbch[1] = ch & 0xff;
+ n_chars = 2;
+ }
+ MultiByteToWideChar(cp, 0, mbch, n_chars, &chW, 1);
+ GetStringTypeW(CT_CTYPE1, &chW, 1, &ctype);
+ return ((ctype & C1_DIGIT) != 0);
+}
+
+/*********************************************************************
+ * _ismbcgraph(MSVCRT.@)
+ */
+int _ismbcgraph(unsigned int ch)
+{
+ WCHAR chW;
+ WORD ctype;
+ char mbch[2];
+ int n_chars;
+ int cp = MSVCRT_current_lc_all_cp;
+
+ if (cp < 0) {
+ ERR("disregarding negative codepage: -%d\n", -cp);
+ cp = CP_ACP;
+ }
+
+ if (ch < 256) {
+ mbch[0] = ch & 0xff;
+ n_chars = 1;
+ } else {
+ mbch[0] = (ch >> 8) & 0xff;
+ mbch[1] = ch & 0xff;
+ n_chars = 2;
+ }
+ MultiByteToWideChar(cp, 0, mbch, n_chars, &chW, 1);
+ GetStringTypeW(CT_CTYPE1, &chW, 1, &ctype);
+ return ((ctype & (C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_ALPHA)) != 0);
+}
+
+/*********************************************************************
+ * _ismbcalpha (MSVCRT.@)
+ */
+int _ismbcalpha(unsigned int ch)
+{
+ WCHAR chW;
+ WORD ctype;
+ char mbch[2];
+ int n_chars;
+ int cp = MSVCRT_current_lc_all_cp;
+
+ if (cp < 0) {
+ ERR("disregarding negative codepage: -%d\n", -cp);
+ cp = CP_ACP;
+ }
+
+ if (ch < 256) {
+ mbch[0] = ch & 0xff;
+ n_chars = 1;
+ } else {
+ mbch[0] = (ch >> 8) & 0xff;
+ mbch[1] = ch & 0xff;
+ n_chars = 2;
+ }
+ MultiByteToWideChar(cp, 0, mbch, n_chars, &chW, 1);
+ GetStringTypeW(CT_CTYPE1, &chW, 1, &ctype);
+ return ((ctype & C1_ALPHA) != 0);
+}
+
+/*********************************************************************
+ * _ismbclower (MSVCRT.@)
+ */
+int _ismbclower(unsigned int ch)
+{
+ WCHAR chW;
+ WORD ctype;
+ char mbch[2];
+ int n_chars;
+ int cp = MSVCRT_current_lc_all_cp;
+
+ if (cp < 0) {
+ ERR("disregarding negative codepage: -%d\n", -cp);
+ cp = CP_ACP;
+ }
+
+ if (ch < 256) {
+ mbch[0] = ch & 0xff;
+ n_chars = 1;
+ } else {
+ mbch[0] = (ch >> 8) & 0xff;
+ mbch[1] = ch & 0xff;
+ n_chars = 2;
+ }
+ MultiByteToWideChar(cp, 0, mbch, n_chars, &chW, 1);
+ GetStringTypeW(CT_CTYPE1, &chW, 1, &ctype);
+ return ((ctype & C1_UPPER) != 0);
+}
+
+/*********************************************************************
+ * _ismbcupper (MSVCRT.@)
+ */
+int _ismbcupper(unsigned int ch)
+{
+ WCHAR chW;
+ WORD ctype;
+ char mbch[2];
+ int n_chars;
+ int cp = MSVCRT_current_lc_all_cp;
+
+ if (cp < 0) {
+ ERR("disregarding negative codepage: -%d\n", -cp);
+ cp = CP_ACP;
+ }
+
+ if (ch < 256) {
+ mbch[0] = ch & 0xff;
+ n_chars = 1;
+ } else {
+ mbch[0] = (ch >> 8) & 0xff;
+ mbch[1] = ch & 0xff;
+ n_chars = 2;
+ }
+ MultiByteToWideChar(cp, 0, mbch, n_chars, &chW, 1);
+ GetStringTypeW(CT_CTYPE1, &chW, 1, &ctype);
+ return ((ctype & C1_LOWER) != 0);
+}
+
+/*********************************************************************
+ * _ismbcsymbol(MSVCRT.@)
+ */
+int _ismbcsymbol(unsigned int ch)
+{
+ WCHAR chW;
+ WORD ctype;
+ char mbch[2];
+ int n_chars;
+ int cp = MSVCRT_current_lc_all_cp;
+
+ if (cp < 0) {
+ ERR("disregarding negative codepage: -%d\n", -cp);
+ cp = CP_ACP;
+ }
+
+ if (ch < 256) {
+ mbch[0] = ch & 0xff;
+ n_chars = 1;
+ } else {
+ mbch[0] = (ch >> 8) & 0xff;
+ mbch[1] = ch & 0xff;
+ n_chars = 2;
+ }
+ MultiByteToWideChar(cp, 0, mbch, n_chars, &chW, 1);
+ GetStringTypeW(CT_CTYPE3, &chW, 1, &ctype);
+ return ((ctype & C3_SYMBOL) != 0);
+}
+
+/*********************************************************************
+ * _ismbcalnum (MSVCRT.@)
+ */
+int _ismbcalnum(unsigned int ch)
+{
+ WCHAR chW;
+ WORD ctype;
+ char mbch[2];
+ int n_chars;
+ int cp = MSVCRT_current_lc_all_cp;
+
+ if (cp < 0) {
+ ERR("disregarding negative codepage: -%d\n", -cp);
+ cp = CP_ACP;
+ }
+
+ if (ch < 256) {
+ mbch[0] = ch & 0xff;
+ n_chars = 1;
+ } else {
+ mbch[0] = (ch >> 8) & 0xff;
+ mbch[1] = ch & 0xff;
+ n_chars = 2;
+ }
+ MultiByteToWideChar(cp, 0, mbch, n_chars, &chW, 1);
+ GetStringTypeW(CT_CTYPE1, &chW, 1, &ctype);
+ return ((ctype & (C1_ALPHA | C1_DIGIT)) != 0);
}
/*********************************************************************
* _ismbcspace (MSVCRT.@)
*/
-int _ismbcspace(unsigned int c)
+int _ismbcspace(unsigned int ch)
{
+ WCHAR chW;
+ WORD ctype;
+ char mbch[2];
+ int n_chars;
+ int cp = MSVCRT_current_lc_all_cp;
+
+ if (cp < 0) {
+ ERR("disregarding negative codepage: -%d\n", -cp);
+ cp = CP_ACP;
+ }
- if (c<0x100)
- return isspace(c);
- FIXME("%c\n",c);
- return 0;
+ if (ch < 256) {
+ mbch[0] = ch & 0xff;
+ n_chars = 1;
+ } else {
+ mbch[0] = (ch >> 8) & 0xff;
+ mbch[1] = ch & 0xff;
+ n_chars = 2;
+ }
+ MultiByteToWideChar(cp, 0, mbch, n_chars, &chW, 1);
+ GetStringTypeW(CT_CTYPE1, &chW, 1, &ctype);
+ return ((ctype & C1_SPACE) != 0);
}
/*********************************************************************
diff -ur -x CVS -x 'bigdif*' ../wine.test/dlls/msvcrt/msvcrt.spec ./dlls/msvcrt/msvcrt.spec
--- ../wine.test/dlls/msvcrt/msvcrt.spec 2002-11-13 08:34:00.000000000 -0600
+++ ./dlls/msvcrt/msvcrt.spec 2002-11-16 20:20:24.000000000 -0600
@@ -291,22 +291,22 @@
@ stub _ismbbprint #(long)
@ stub _ismbbpunct #(long)
@ cdecl _ismbbtrail(long) _ismbbtrail
-@ stub _ismbcalnum #(long)
-@ stub _ismbcalpha #(long)
+@ cdecl _ismbcalnum(long) _ismbcalnum
+@ cdecl _ismbcalpha(long) _ismbcalpha
@ cdecl _ismbcdigit(long) _ismbcdigit
-@ stub _ismbcgraph #(long)
+@ cdecl _ismbcgraph(long) _ismbcgraph
@ cdecl _ismbchira(long) _ismbchira
@ cdecl _ismbckata(long) _ismbckata
@ stub _ismbcl0 #(long)
@ stub _ismbcl1 #(long)
@ stub _ismbcl2 #(long)
@ stub _ismbclegal #(long)
-@ stub _ismbclower #(long)
+@ cdecl _ismbclower(long) _ismbclower
@ stub _ismbcprint #(long)
@ stub _ismbcpunct #(long)
@ cdecl _ismbcspace(long) _ismbcspace
-@ stub _ismbcsymbol #(long)
-@ stub _ismbcupper #(long)
+@ cdecl _ismbcsymbol(long) _ismbcsymbol
+@ cdecl _ismbcupper(long) _ismbcupper
@ cdecl _ismbslead(ptr ptr) _ismbslead
@ cdecl _ismbstrail(ptr ptr) _ismbstrail
@ cdecl _isnan( double ) _isnan
More information about the wine-patches
mailing list