Eric Lemings wrote:
This _RWSTD_UWCHAR_INT_T type macro is added just to silence
compiler warnings?
Not just for that, but that is what it's being used for so far.
Is `unsigned wchar_t` a legitimate type?
No, but there is a notion of an "underlying integer type" for
wchar_t which is an integer type other than wchar_t with the
same size, alignment requirement, and signedness as wchar_t.
The new _RWSTD_UWCHAR_INT_T type is an unsigned form of this
underlying integer type.
Just wondering if they might not be a slightly more elegant
solution...
I couldn't think of one but if you have an idea for how to
do this better I'd be interested in hearing it.
Martin
Brad.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, April 18, 2008 12:31 PM
To: [EMAIL PROTECTED]
Subject: svn commit: r649646 - in /stdcxx/trunk/include:
loc/_ctype.h rw/_defs.h
Author: faridz
Date: Fri Apr 18 11:30:47 2008
New Revision: 649646
URL: http://svn.apache.org/viewvc?rev=649646&view=rev
Log:
2008-04-18 Farid Zaripov <[EMAIL PROTECTED]>
* include/rw/_defs.h: #define new general purpose
config macro _RWSTD_UWCHAR_INT_T.
* include/loc/_ctype.h (narrow): Cast __c to
_RWSTD_UWCHAR_INT_T to avoid warnings
about signed/unsigned comparisons.
Modified:
stdcxx/trunk/include/loc/_ctype.h
stdcxx/trunk/include/rw/_defs.h
Modified: stdcxx/trunk/include/loc/_ctype.h
URL:
http://svn.apache.org/viewvc/stdcxx/trunk/include/loc/_ctype.h
?rev=649646&r1=649645&r2=649646&view=diff
==============================================================
================
--- stdcxx/trunk/include/loc/_ctype.h (original)
+++ stdcxx/trunk/include/loc/_ctype.h Fri Apr 18 11:30:47 2008
@@ -541,21 +541,20 @@
inline char
ctype<wchar_t>::narrow (char_type __c, char __dfault) const
{
+ const _RWSTD_SIZE_T __inx = _RWSTD_STATIC_CAST
(_RWSTD_UWCHAR_INT_T, __c);
+
// optimize away all but the first call to the virtual do_widen()
- if ( 0 <= __c
- && __c < sizeof _C_narrow_tab / sizeof *_C_narrow_tab
- && _C_narrow_tab [__c])
- return _C_narrow_tab [__c];
+ if ( __inx < sizeof _C_narrow_tab / sizeof *_C_narrow_tab
+ && _C_narrow_tab [__inx])
+ return _C_narrow_tab [__inx];
// template argument provided to work around an HP aCC
bug (PR #27087)
ctype<wchar_t>* const __self = _RWSTD_CONST_CAST
(ctype<wchar_t>*, this);
const char __ch = do_narrow (__c, __dfault);
- if ( 0 <= __c
- && __c < sizeof _C_narrow_tab / sizeof *_C_narrow_tab
- && __ch != __dfault)
- __self->_C_narrow_tab [__c] = __ch;
+ if (__inx < sizeof _C_narrow_tab / sizeof *_C_narrow_tab
&& __ch != __dfault)
+ __self->_C_narrow_tab [__inx] = __ch;
return __ch;
}
Modified: stdcxx/trunk/include/rw/_defs.h
URL:
http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_defs.h?r
ev=649646&r1=649645&r2=649646&view=diff
==============================================================
================
--- stdcxx/trunk/include/rw/_defs.h (original)
+++ stdcxx/trunk/include/rw/_defs.h Fri Apr 18 11:30:47 2008
@@ -1269,6 +1269,20 @@
#endif // _RWSTD_SSIZE_T
+// _RWSTD_UWCHAR_INT_T is "unsigned wchar_t"
+#ifndef _RWSTD_UWCHAR_INT_T
+# if _RWSTD_CHAR_SIZE == _RWSTD_WCHAR_SIZE
+# define _RWSTD_UWCHAR_INT_T unsigned char
+# elif _RWSTD_SHRT_SIZE == _RWSTD_WCHAR_SIZE
+# define _RWSTD_UWCHAR_INT_T unsigned short
+# elif _RWSTD_INT_SIZE == _RWSTD_WCHAR_SIZE
+# define _RWSTD_UWCHAR_INT_T unsigned int
+# else
+# define _RWSTD_UWCHAR_INT_T _RWSTD_SIZE_T
+# endif
+#endif // _RWSTD_UWCHAR_INT_T
+
+
#if defined(SNI)
# define _RWSTD_USING_SNI(name) _USING(__SNI::name)
# if defined(_RWSTD_STRICT_ANSI)