stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r289329 - /incubator/stdcxx/trunk/src/wcodecvt.cpp
Date Thu, 15 Sep 2005 22:33:57 GMT
Author: sebor
Date: Thu Sep 15 15:33:51 2005
New Revision: 289329

URL: http://svn.apache.org/viewcvs?rev=289329&view=rev
Log:
2005-09-15  Martin Sebor  <sebor@roguewave.com>

	STDCXX-21
	* wcodecvt.cpp (__rw_libstd_do_out): Converted each character
	to unsigned long before comparing its value against the surrogate
	pair ranges in order to silence gcc warning on Cygwin (where
	sizeof(wchar_t) == 2): comparison is always true due to limited
	range of data type.

Modified:
    incubator/stdcxx/trunk/src/wcodecvt.cpp

Modified: incubator/stdcxx/trunk/src/wcodecvt.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/src/wcodecvt.cpp?rev=289329&r1=289328&r2=289329&view=diff
==============================================================================
--- incubator/stdcxx/trunk/src/wcodecvt.cpp (original)
+++ incubator/stdcxx/trunk/src/wcodecvt.cpp Thu Sep 15 15:33:51 2005
@@ -2,7 +2,7 @@
  *
  * wcodecvt.cpp - definition of codecvt<wchar_t, char, mbstate_t> members
  *
- * $Id: //stdlib/dev/source/stdlib/wcodecvt.cpp#23 $
+ * $Id$
  *
  ***************************************************************************
  *
@@ -832,12 +832,27 @@
         }
 
         if (flags & __rw_strict) {
+
             // in strict mode check wide character for validity
             // (i.e., diagnose surrogate pairs as illegal)
-            if (   wchar_t (0xd800) <= *from_next
-                && wchar_t (0xdfff) >= *from_next
-                || wchar_t (0xfffe) <= *from_next
-                && wchar_t (0xffff) >= *from_next) {
+
+#  if _RWSTD_WCHAR_T_SIZE == _RWSTD_CHAR_SIZE
+            typedef unsigned char WIntT;
+#  elif _RWSTD_WCHAR_T_SIZE == _RWSTD_SHRT_SIZE
+            typedef unsigned short WIntT;
+#  elif _RWSTD_WCHAR_T_SIZE ==_RWSTD_INT_SIZE
+            typedef unsigned int WIntT;
+#  elif _RWSTD_WCHAR_T_SIZE ==_RWSTD_LLONG_SIZE
+            typedef unsigned _RWSTD_LONG_LONG WIntT;
+#  else
+            typedef unsigned long WIntT;
+#  endif
+
+            // convert wchar_t to an unsigned integer safe for comaprison
+            const unsigned long wi = _RWSTD_STATIC_CAST (WIntT, *from_next);
+
+            if (   WIntT (0xd800U) <= wi && wi <= WIntT (0xdfffU)
+                || WIntT (0xfffeU) <= wi && wi <= WIntT (0xffffU)) {
                 res = _V3_LOCALE::codecvt_base::error;
                 break;
             }



Mime
View raw message