Merging r37048, r37051, r37052, r37055 from the-real-msvc branch
[reactos.git] / reactos / lib / sdk / crt / string / ctype.c
index c9a542f..7818357 100644 (file)
@@ -1,8 +1,28 @@
 #include <string.h>
+#undef __MINGW_IMPORT
+#define __MINGW_IMPORT
 #include <ctype.h>
 
 #undef _pctype
 
+/* MS's CRT header defines all that, and we actually implement that */
+#undef iswalnum
+#undef __isascii
+#undef iswascii
+#undef __iscsym
+#undef __iscsymf
+#undef iswalpha
+#undef iswcntrl
+#undef iswdigit
+#undef iswgraph
+#undef iswprint
+#undef iswpunct
+#undef iswlower
+#undef iswupper
+#undef iswspace
+#undef iswxdigit
+#undef __toascii
+
 #define upalpha ('A' - 'a')
 
 
@@ -266,13 +286,13 @@ unsigned short _ctype[] = {
        0                       /* 0xff */
 };
 
-unsigned short *_pctype = _ctype + 1;
-unsigned short *_pwctype = _ctype + 1;
+const unsigned short *_pctype = _ctype + 1;
+const unsigned short *_pwctype = _ctype + 1;
 
 /*
  * @implemented
  */
-unsigned short **__p__pctype(void)
+const unsigned short **__p__pctype(void)
 {
    return &_pctype;
 }
@@ -280,7 +300,7 @@ unsigned short **__p__pctype(void)
 /*
  * @implemented
  */
-unsigned short **__p__pwctype(void)
+const unsigned short **__p__pwctype(void)
 {
    return &_pwctype;
 }
@@ -361,7 +381,7 @@ int iscntrl(int c)
  */
 int __iscsym(int c)
 {
-   return(isalnum(c)||(c == '_'));
+   return (c < 127 && (isalnum(c) || (c == '_')));
 }
 
 /*
@@ -369,7 +389,7 @@ int __iscsym(int c)
  */
 int __iscsymf(int c)
 {
-   return(isalpha(c)||(c == '_'));
+   return (c < 127 && (isalpha(c) || (c == '_')));
 }
 
 /*
@@ -571,7 +591,7 @@ int toupper(int c)
 /*
  * @implemented
  */
-wchar_t towlower(wchar_t c)
+wint_t towlower(wint_t c)
 {
    if (iswctype (c, _UPPER))
        return (c - upalpha);
@@ -581,7 +601,7 @@ wchar_t towlower(wchar_t c)
 /*
  * @implemented
  */
-wchar_t towupper(wchar_t c)
+wint_t towupper(wint_t c)
 {
    if (iswctype (c, _LOWER))
       return (c + upalpha);