stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Farid_Zari...@epam.com>
Subject [PATCH] MSVC has non-standard prototype of the wcstok()
Date Tue, 20 Nov 2007 14:25:01 GMT
  The all MSVC has the non-standard prototype of the wcstok():

wchar_t* wcstok(wchar_t*, const wchar_t*);


  The prototype from C standard:
wchar_t* wcstok(wchar_t*, const wchar_t*, wchar_t**);


  Since the configure script performs checking only names and doesn't
checking the correct prototype, the _RWSTD_NO_WCSTOK macro is
not defined in config.h. As a result the 21.cwchar.cpp test asserts on
"wcstok() not declared".

  However the MSVC 8 and later has the wcstok_s() function with the
prototype similar to the standard wcstok():

wchar_t* wcstok_s(wchar_t* _Str, const wchar_t* _Delim, wchar_t **
_Context);


  I've propose the following changes:

  ChangeLog:
  * rw/_config_msvcrt.h: #define _RWSTD_NO_WCSTOK and
_RWSTD_NO_WCSTOK_IN_LIBC
  macros since the MSVC has the non-standard prototype of the wcstok().
  * ansi/cwchar [_MSC_VER >= 1400]: Define inline wcstok() function
using wcstok_s().
  #undefine _RWSTD_NO_WCSTOK and _RWSTD_NO_WCSTOK_IN_LIBC macros.


Index: include/ansi/cwchar
===================================================================
--- include/ansi/cwchar	(revision 596338)
+++ include/ansi/cwchar	(working copy)
@@ -1074,6 +1074,22 @@
 using ::wcstok;
 
 #  undef _RWSTD_NO_WCSTOK
+#elif defined (_MSC_VER) && 1400 <= _MSC_VER
+
+}   // namespace std
+
+/* extern "C++" */ inline wchar_t*
+wcstok (wchar_t* __s1, const wchar_t* __s2, wchar_t** __ptr)
+{
+    return wcstok_s (__s1, __s2, __ptr);
+}
+
+namespace std {
+
+using ::wcstok;
+
+#  undef _RWSTD_NO_WCSTOK
+#  undef _RWSTD_NO_WCSTOK_IN_LIBC
 #endif   // _RWSTD_NO_WCSTOK[_IN_LIBC]
 
 #ifndef _RWSTD_NO_WCSTOL
Index: include/rw/_config-msvcrt.h
===================================================================
--- include/rw/_config-msvcrt.h	(revision 596338)
+++ include/rw/_config-msvcrt.h	(working copy)
@@ -54,6 +54,15 @@
 #  define _RWSTD_NO_DEPRECATED_C_HEADERS
 #endif   // _RWSTD_NO_DEPRECATED_C_HEADERS
 
+#ifndef _RWSTD_NO_WCSTOK
+// MSVC CRT has incorrect prototype of the wcstok()
+#  define _RWSTD_NO_WCSTOK
+#endif   // _RWSTD_NO_WCSTOK
+
+#ifndef _RWSTD_NO_WCSTOK_IN_LIBC
+#  define _RWSTD_NO_WCSTOK_IN_LIBC
+#endif   // _RWSTD_NO_WCSTOK_IN_LIBC
+
    // operator new and delete is not reliably replaceable across
    // shared library boundaries, which includes the shared library
    // version of the language support library

Farid.

Mime
View raw message