_ismbc* fourth try

Greg Turner gmturner007 at ameritech.net
Sun Nov 17 04:28:37 CST 2002


yet more implemented this time.

LICENSE: X11

CHANGELOG:

* 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-17 04:15:01.000000000 -0600
@@ -548,30 +548,124 @@
   return 0;
 }
 
+int MSVCRT_ismbc_via_wc(unsigned int ch, DWORD ct_ctype, WORD chartype)
+{ 
+  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 > 0xffff) {
+    ERR("ch == %x too big", ch);
+    return 0;
+  }
+
+  if (ch <= 0xff) {
+    mbch[0] = ch;
+    n_chars = 1;
+  } else {
+    mbch[0] = (ch >> 8) & 0xff;
+    mbch[1] = ch & 0xff;
+    n_chars = 2;
+  }
+
+  if (!MultiByteToWideChar(cp, 0, mbch, n_chars, &chW, 1)) {
+    WARN("MultiByteToWideChar failed on %x\n", ch);
+    return 0;
+  }
+  if (!GetStringTypeW(ct_ctype, &chW, 1, &ctype)) {
+    WARN("GetStringTypeW failed on %x\n", ch);
+    return 0;
+  }
+  return ((ctype & chartype) != 0);
+}
+
 /*********************************************************************
  *              _ismbcdigit(MSVCRT.@)
  */
 int _ismbcdigit(unsigned int ch)
 {
-  if (ch <0x100)
-    return isdigit(ch);
-  else
-    {
-      FIXME("Handle MBC chars\n");
-      return 0;
-    }
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE1, C1_DIGIT);
+}
+
+/*********************************************************************
+ *              _ismbcgraph(MSVCRT.@)
+ */
+int _ismbcgraph(unsigned int ch)
+{
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE1, 
+    C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_ALPHA);
+}
+
+/*********************************************************************
+ *              _ismbcalpha (MSVCRT.@)
+ */
+int _ismbcalpha(unsigned int ch)
+{
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE1, C1_ALPHA);
+}
+
+/*********************************************************************
+ *              _ismbclower (MSVCRT.@)
+ */
+int _ismbclower(unsigned int ch)
+{
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE1, C1_UPPER);
+}
+
+/*********************************************************************
+ *              _ismbcupper (MSVCRT.@)
+ */
+int _ismbcupper(unsigned int ch)
+{
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE1, C1_LOWER);
+}
+
+/*********************************************************************
+ *              _ismbcsymbol(MSVCRT.@)
+ */
+int _ismbcsymbol(unsigned int ch)
+{
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE3, C3_SYMBOL);
+}
+
+/*********************************************************************
+ *              _ismbcalnum (MSVCRT.@)
+ */
+int _ismbcalnum(unsigned int ch)
+{
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE1, C1_ALPHA | C1_DIGIT);
 }
 
 /*********************************************************************
  *              _ismbcspace (MSVCRT.@)
  */
-int _ismbcspace(unsigned int c)
+int _ismbcspace(unsigned int ch)
 {
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE1, C1_SPACE);
+}
 
-  if (c<0x100)
-    return isspace(c);
-  FIXME("%c\n",c);
-  return 0;
+/*********************************************************************
+ *              _ismbcprint (MSVCRT.@)
+ */
+int _ismbcprint(unsigned int ch)
+{
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE1,
+    C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_ALPHA | C1_SPACE);
+}
+
+/*********************************************************************
+ *              _ismbcpunct(MSVCRT.@)
+ */
+int _ismbcpunct(unsigned int ch)
+{
+  return MSVCRT_ismbc_via_wc(ch, CT_CTYPE1, C1_PUNCT);
 }
 
 /*********************************************************************
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-17 04:19:08.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)
-@ stub _ismbcprint #(long)
-@ stub _ismbcpunct #(long)
+@ cdecl _ismbclower(long) _ismbclower
+@ cdecl _ismbcprint(long) _ismbcprint
+@ cdecl _ismbcpunct(long) _ismbcpunct
 @ 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