RE: [PATCH] MSVC has non-standard prototype of the wcstok()

2007-12-12 Thread Farid Zaripov
 -Original Message-
 From: Martin Sebor [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, December 12, 2007 8:53 AM
 To: stdcxx-dev@incubator.apache.org
 Subject: Re: [PATCH] MSVC has non-standard prototype of the wcstok()

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.
 
 But there is a mechanism to check for signatures too, isn't there?
 Could we use it to detect this or are you saying even this is 
 not enough?

  This mechanism checks the signatures in header files, but incorrect
wcstok() will be found in libc.

config.h:
---
#define _RWSTD_NO_WCSTOK
// #define _RWSTD_NO_WCSTOK_IN_LIBC
---

Farid.


Re: [PATCH] MSVC has non-standard prototype of the wcstok()

2007-12-12 Thread Martin Sebor

Farid Zaripov wrote:

-Original Message-
From: Martin Sebor [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 12, 2007 8:53 AM

To: stdcxx-dev@incubator.apache.org
Subject: Re: [PATCH] MSVC has non-standard prototype of the wcstok()


  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.

But there is a mechanism to check for signatures too, isn't there?
Could we use it to detect this or are you saying even this is 
not enough?


  This mechanism checks the signatures in header files, but incorrect
wcstok() will be found in libc.


I see. Well, there's nothing we can do about that. I guess we'll have
to live with the compiler-specific #ifdefs in our code. I tell you, if
it weren't for Microsoft porting would be so boring... ;-)

Martin



config.h:
---
#define _RWSTD_NO_WCSTOK
// #define _RWSTD_NO_WCSTOK_IN_LIBC
---

Farid.





Re: [PATCH] MSVC has non-standard prototype of the wcstok()

2007-12-12 Thread William A. Rowe, Jr.

Martin Sebor wrote:


I see. Well, there's nothing we can do about that. I guess we'll have
to live with the compiler-specific #ifdefs in our code. I tell you, if
it weren't for Microsoft porting would be so boring... ;-)


C'mon - you can't say that aix CC and hpux aCC don't provide endless
hours of amusement, too :)



Re: [PATCH] MSVC has non-standard prototype of the wcstok()

2007-12-11 Thread Martin Sebor


Farid Zaripov-2 wrote:
 
   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.
 
 

But there is a mechanism to check for signatures too, isn't there?
Could we use it to detect this or are you saying even this is not
enough?

Martin



 
   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.
 
 

-- 
View this message in context: 
http://www.nabble.com/-PATCH--MSVC-has-non-standard-prototype-of-the-wcstok%28%29-tp13857994p14289929.html
Sent from the stdcxx-dev mailing list archive at Nabble.com.