stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r644666 - in /stdcxx/trunk: etc/config/src/EQUAL_CTYPE_MASK.cpp src/wctype.cpp
Date Fri, 04 Apr 2008 09:56:57 GMT
Author: faridz
Date: Fri Apr  4 02:56:53 2008
New Revision: 644666

URL: http://svn.apache.org/viewvc?rev=644666&view=rev
Log:
2008-04-04  Farid Zaripov  <farid_zaripov@epam.com>

	STDCXX-660
	*  etc/config/src/EQUAL_CTYPE_MASK.cpp: New file to check that ctype mask's
	for char and wchar_t are equal.
	* src/wctype.cpp [_RWSTD_NO_EQUAL_CTYPE_MASK] (__rw_classic_wide_tab): Static
	array with ctype mask's for wide characters.
	[_RWSTD_NO_EQUAL_CTYPE_MASK] (__rw_init_classic_wide_tab): New function to
	initialize __rw_classic_wide_tab array.
	[_RWSTD_NO_EQUAL_CTYPE_MASK] (ctype<wchar_t>::ctype): Initialize
	__rw_classic_wide_tab array exactly once using __rw_once().

Added:
    stdcxx/trunk/etc/config/src/EQUAL_CTYPE_MASK.cpp   (with props)
Modified:
    stdcxx/trunk/src/wctype.cpp

Added: stdcxx/trunk/etc/config/src/EQUAL_CTYPE_MASK.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/etc/config/src/EQUAL_CTYPE_MASK.cpp?rev=644666&view=auto
==============================================================================
--- stdcxx/trunk/etc/config/src/EQUAL_CTYPE_MASK.cpp (added)
+++ stdcxx/trunk/etc/config/src/EQUAL_CTYPE_MASK.cpp Fri Apr  4 02:56:53 2008
@@ -0,0 +1,97 @@
+// checking that ctype mask's for char and wchar_t are equal
+
+/***************************************************************************
+ *
+ * Licensed to the Apache Software  Foundation (ASF) under one or more
+ * contributor  license agreements.  See  the NOTICE  file distributed
+ * with  this  work  for  additional information  regarding  copyright
+ * ownership.   The ASF  licenses this  file to  you under  the Apache
+ * License, Version  2.0 (the  License); you may  not use  this file
+ * except in  compliance with the License.   You may obtain  a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the  License is distributed on an  "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
+ * implied.   See  the License  for  the  specific language  governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1999-2007 Rogue Wave Software, Inc.
+ * 
+ **************************************************************************/
+
+#include "config.h"
+
+#include <locale.h>
+#include <ctype.h>
+
+#ifndef _RWSTD_NO_WCTYPE_H
+#  include <wctype.h>
+#endif
+
+int main ()
+{
+    setlocale (LC_ALL, "C");
+
+    for (int i = 0; i < 256; ++i) {
+
+#ifndef _RWSTD_NO_ISWSPACE
+        if (!!isspace (i)  != !!iswspace (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWPRINT
+        if (!!isprint (i)  != !!iswprint (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWCNTRL
+        if (!!iscntrl (i)  != !!iswcntrl (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWUPPER
+        if (!!isupper (i)  != !!iswupper (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWLOWER
+        if (!!islower (i)  != !!iswlower (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWALPHA
+        if (!!isalpha (i)  != !!iswalpha (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWDIGIT
+        if (!!isdigit (i)  != !!iswdigit (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWPUNCT
+        if (!!ispunct (i)  != !!iswpunct (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWXDIGIT
+        if (!!isxdigit (i) != !!iswxdigit (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWALNUM
+        if (!!isalnum (i)  != !!iswalnum (i))
+            return 1;
+#endif
+
+#ifndef _RWSTD_NO_ISWGRAPH
+        if (!!isgraph (i)  != !!iswgraph (i))
+            return 1;
+#endif
+    }
+
+    return 0;
+}

Propchange: stdcxx/trunk/etc/config/src/EQUAL_CTYPE_MASK.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: stdcxx/trunk/etc/config/src/EQUAL_CTYPE_MASK.cpp
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: stdcxx/trunk/src/wctype.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/src/wctype.cpp?rev=644666&r1=644665&r2=644666&view=diff
==============================================================================
--- stdcxx/trunk/src/wctype.cpp (original)
+++ stdcxx/trunk/src/wctype.cpp Fri Apr  4 02:56:53 2008
@@ -51,6 +51,9 @@
 #include "setlocale.h"
 #include "use_facet.h"
 
+#ifdef _RWSTD_NO_EQUAL_CTYPE_MASK
+#  include "once.h"   // for __rw_once()
+#endif   // _RWSTD_NO_EQUAL_CTYPE_MASK
 
 // utf8 encoding maximum size
 #undef  _UTF8_MB_CUR_MAX
@@ -368,6 +371,47 @@
 
 #endif   // 0/1
 
+#ifdef _RWSTD_NO_EQUAL_CTYPE_MASK
+
+// table of wide character classes
+static _STD::ctype_base::mask
+__rw_classic_wide_tab [_STD::ctype<char>::table_size];
+
+// init-once flag for the classic wide tab
+static __rw_once_t
+__rw_classic_wide_tab_once_init = _RWSTD_ONCE_INIT;
+
+extern "C" {
+
+// one-time initializer for the classic wide_tab
+static void
+__rw_init_classic_wide_tab ()
+{
+#  ifdef _RWSTDDEBUG
+
+    static int init;
+
+    // paranoid check: verify that one-time initialization works
+    _RWSTD_ASSERT (0 == init);
+
+    ++init;
+
+#  endif   // _RWSTDDEBUG
+
+    // init the classic wide tab
+    wchar_t wc_array [_STD::ctype<char>::table_size];
+
+    for (wchar_t wc = 0; wc < _STD::ctype<char>::table_size; ++wc)
+        wc_array [wc] = wc;
+
+    __rw_get_mask (0, wc_array, wc_array + _STD::ctype<char>::table_size,
+                   __rw_all, __rw_classic_wide_tab, false, false, "C");
+}
+
+}   // extern "C"
+
+#endif   // _RWSTD_NO_EQUAL_CTYPE_MASK
+
 }   // namespace __rw
 
 
@@ -380,7 +424,15 @@
 ctype<wchar_t>::ctype (_RWSTD_SIZE_T ref)
     : _RW::__rw_facet (ref)
 {
+#ifndef _RWSTD_NO_EQUAL_CTYPE_MASK
     _C_mask_tab  = _RW::__rw_classic_tab;
+#else
+    // initialize classic wide tab exactly once
+    _RW::__rw_once (&_RW::__rw_classic_wide_tab_once_init,
+                    _RW::__rw_init_classic_wide_tab);
+
+    _C_mask_tab  = _RW::__rw_classic_wide_tab;
+#endif
     _C_upper_tab = _RWSTD_CONST_CAST (_UChar*, _RW::__rw_upper_tab);
     _C_lower_tab = _RWSTD_CONST_CAST (_UChar*, _RW::__rw_lower_tab);
     _C_delete_it = false;
@@ -554,7 +606,7 @@
 
 ctype_byname<wchar_t>::
 ctype_byname (const char *name, _RWSTD_SIZE_T refs)
-    : ctype<wchar_t>(refs), _C_cvtimpl (0), _C_cvtsize (0)
+    : ctype<wchar_t> (refs), _C_cvtimpl (0), _C_cvtsize (0)
 {
     this->_C_set_name (name, _C_namebuf, sizeof _C_namebuf);
 



Mime
View raw message