Modified: incubator/stdcxx/branches/4.2.0/src/locale_eq.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/locale_eq.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/locale_eq.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/locale_eq.cpp Fri Sep 28 13:55:52 2007 @@ -30,8 +30,6 @@ #include -#ifndef _RWSTD_NO_V3_LOCALE - #include #include @@ -39,7 +37,7 @@ #include "locale_body.h" -_RWSTD_NAMESPACE (_V3_LOCALE) { +_RWSTD_NAMESPACE (std) { bool locale::operator== (const locale &rhs) const @@ -63,19 +61,24 @@ if (!_C_body->_C_n_usr_facets && !rhs._C_body->_C_n_usr_facets) { // in order to compare equal, both bodies must have the same - // sets of facets (some slots may still be uninitialized) + // sets of facets (some slots may still be uninitialized) and + // not have different names const bool eql = _C_body->_C_std_facet_bits == rhs._C_body->_C_std_facet_bits && _C_body->_C_byname_facet_bits == rhs._C_body->_C_byname_facet_bits && !memcmp (_C_body->_C_std_facets, rhs._C_body->_C_std_facets, - _C_body->_C_n_std_facets * sizeof *_C_body->_C_std_facets); + _C_body->_C_n_std_facets * sizeof *_C_body->_C_std_facets) + && !strcmp (_C_body->_C_name, rhs._C_body->_C_name); // at least some standard facets must have been replaced in order - // for two locale objects not to share the same body - _RWSTD_ASSERT ( _C_body->_C_std_facet_bits != _C_body->_C_all + // for two "equal" locale objects not to share the same body, or + // the locales' names must be different + _RWSTD_ASSERT ( eql + || _C_body->_C_std_facet_bits != _C_body->_C_all || rhs._C_body->_C_std_facet_bits != _C_body->_C_all || _C_body->_C_byname_facet_bits != _C_body->_C_all - || rhs._C_body->_C_byname_facet_bits != _C_body->_C_all); + || rhs._C_body->_C_byname_facet_bits != _C_body->_C_all + || strcmp (_C_body->_C_name, rhs._C_body->_C_name)); // facet bits of both objects must be the same if the two objects // share the exact same facets (otherwise the bits may or may not @@ -109,16 +112,38 @@ if (strcmp (_C_body->_C_name, rhs._C_body->_C_name)) return false; - _RWSTD_ASSERT (_C_body->_C_n_usr_facets == rhs._C_body->_C_n_usr_facets); + // highest valid index + const size_t maxinx = + rhs._C_body->_C_n_usr_facets + _RW::__rw_locale::_C_n_std_facets; // locales with the same (non-0) number of user-defined // facets compare equal iff all the facets are identical for (_RWSTD_SIZE_T i = 0; i != _C_body->_C_n_usr_facets; ++i) { - _RWSTD_ASSERT (_C_body->_C_usr_facets [i]); - _RWSTD_ASSERT (rhs._C_body->_C_usr_facets [i]); + const _RW::__rw_facet* const pf = _C_body->_C_usr_facets [i]; + + _RWSTD_ASSERT (0 != pf); + _RWSTD_ASSERT (0 != pf->_C_pid); + _RWSTD_ASSERT (0 != *pf->_C_pid); + + // if the facets at the same index aren't the same but their + // numeric id's are the locales are not equal; this check short + // circuits the linear lookup of the facet in rhs done below + if ( pf != rhs._C_body->_C_usr_facets [i] + && pf->_C_pid == rhs._C_body->_C_usr_facets [i]->_C_pid) + return false; + + // find the index of the facet in rhs if it's installed there + size_t inx = rhs._C_body->_C_get_facet_inx (*pf->_C_pid); + if (maxinx <= inx || inx < _RW::__rw_locale::_C_n_std_facets) + return false; + + // the index starts at _C_n_std_facets + inx -= _RW::__rw_locale::_C_n_std_facets; - if (_C_body->_C_usr_facets [i] != rhs._C_body->_C_usr_facets [i]) + // if the two facets aren't the same objects the locales aren't + // equal (since they may each behave differently) + if (pf != rhs._C_body->_C_usr_facets [inx]) return false; } @@ -126,7 +151,4 @@ } -} // namespace _V3_LOCALE - - -#endif // _RWSTD_NO_V3_LOCALE +} // namespace std Modified: incubator/stdcxx/branches/4.2.0/src/locale_global.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/locale_global.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/locale_global.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/locale_global.cpp Fri Sep 28 13:55:52 2007 @@ -30,8 +30,6 @@ #include -#ifndef _RWSTD_NO_V3_LOCALE - #include #include @@ -42,7 +40,7 @@ -_RWSTD_NAMESPACE (_V3_LOCALE) { +_RWSTD_NAMESPACE (std) { /* static */ locale locale::global (const locale &rhs) { @@ -72,7 +70,4 @@ } -} // namespace _V3_LOCALE - - -#endif // _RWSTD_NO_V3_LOCALE +} // namespace std Modified: incubator/stdcxx/branches/4.2.0/src/locale_name.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/locale_name.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/locale_name.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/locale_name.cpp Fri Sep 28 13:55:52 2007 @@ -30,8 +30,6 @@ #include -#ifndef _RWSTD_NO_V3_LOCALE - #include #include @@ -41,7 +39,7 @@ #include "locale_body.h" -_RWSTD_NAMESPACE (_V3_LOCALE) { +_RWSTD_NAMESPACE (std) { string locale::name () const { @@ -97,8 +95,4 @@ } -} // namespace _V3_LOCALE - - -#endif // _RWSTD_NO_V3_LOCALE - +} // namespace std Modified: incubator/stdcxx/branches/4.2.0/src/memattr.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/memattr.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/memattr.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/memattr.cpp Fri Sep 28 13:55:52 2007 @@ -23,7 +23,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2005-2006 Rogue Wave Software. + * Copyright 2005-2007 Rogue Wave Software, Inc. * **************************************************************************/ @@ -32,6 +32,10 @@ #include // for ENOMEM, errno #include // for memchr +#ifndef EFAULT +# define EFAULT 14 // Linux value +#endif // EFAULT + #ifdef __CYGWIN__ // use the Windows API on Cygwin # define _WIN32 @@ -43,6 +47,12 @@ # include # endif # include // for getpagesize(), sysconf() + +# if defined (_RWSTD_OS_LINUX) && !defined (__USE_BSD) + // needed for caddr_t, madvise, and MADV_WILLNEED +# define __USE_BSD +# endif // _RWSTD_OS_LINUX && !__USE_BSD + # include // for mincore() # include Modified: incubator/stdcxx/branches/4.2.0/src/messages.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/messages.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/messages.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/messages.cpp Fri Sep 28 13:55:52 2007 @@ -210,10 +210,9 @@ // Open a message catalog and assign and return a handle for it. -int -__rw_cat_open (const _STD::string &cat_name, const _STD::locale &loc) +int __rw_cat_open (const _STD::string &cat_name, const _STD::locale &loc) { - _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); + _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data); const nl_catd catd = catopen (cat_name.c_str (), NL_CAT_LOCALE); if (_RWSTD_BAD_CATD == catd) @@ -233,13 +232,12 @@ // Get message text from catalog. -const char* -__rw_get_message (int cat, int set_num, int msg_num) +const char* __rw_get_message (int cat, int set_num, int msg_num) { if (cat < 0) return 0; - _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); + _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data); __rw_open_cat_data *const pcat_data = __rw_manage_cat_data (cat, 0); @@ -261,10 +259,9 @@ // Get locale to be used for character translation for this message catalog. -const _STD::locale& -__rw_get_locale (int cat) +const _STD::locale& __rw_get_locale (int cat) { - _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); + _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data); _RWSTD_ASSERT (0 <= cat); __rw_open_cat_data* const pcat_data = __rw_manage_cat_data (cat, 0); @@ -276,10 +273,9 @@ // Close a catalog and release its handle. -void -__rw_cat_close (int cat) +void __rw_cat_close (int cat) { - _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); + _RWSTD_MT_CLASS_GUARD (__rw_open_cat_data); __rw_open_cat_data* const pcat_data = cat < 0 ? 0 : __rw_manage_cat_data (cat, 0); Modified: incubator/stdcxx/branches/4.2.0/src/num_get.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/num_get.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/num_get.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/num_get.cpp Fri Sep 28 13:55:52 2007 @@ -6,22 +6,23 @@ * *************************************************************************** * - * Copyright 2005-2006 The Apache Software Foundation or its licensors, - * as applicable. + * 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 * - * Copyright 2001-2006 Rogue Wave Software. - * - * Licensed 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 + * 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. + * 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 2001-2007 Rogue Wave Software, Inc. * **************************************************************************/ @@ -83,13 +84,23 @@ typedef unsigned char UChar; +extern "C" { + extern const float __rw_flt_infinity; extern const double __rw_dbl_infinity; + +#ifndef _RWSTD_NO_LONG_DOUBLE + extern const long double __rw_ldbl_infinity; +#endif // _RWSTD_NO_LONG_DOUBLE + +} // extern "C" + const char* -__rw_get_stdio_fmat (char buf [32], int type, unsigned fmtflags, int prec); +__rw_get_stdio_fmat (char buf [32], int type, unsigned fmtflags, + _STD::streamsize prec); // verifies that the `grps' array of size `ngrps' representing the @@ -419,7 +430,7 @@ val.ul = _RWSTD_UINT_MAX - val.ul + 1; } - *_RWSTD_STATIC_CAST (unsigned*, pval) = val.ul; + *_RWSTD_STATIC_CAST (unsigned*, pval) = unsigned (val.ul); break; case __rw_facet::_C_int: @@ -448,7 +459,7 @@ #endif // _RWSTD_UINT_MAX < _RWSTD_ULONG_MAX - *_RWSTD_STATIC_CAST (int*, pval) = val.l; + *_RWSTD_STATIC_CAST (int*, pval) = int (val.l); break; case __rw_facet::_C_ulong: Modified: incubator/stdcxx/branches/4.2.0/src/num_put.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/num_put.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/num_put.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/num_put.cpp Fri Sep 28 13:55:52 2007 @@ -22,16 +22,13 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 1994-2006 Rogue Wave Software. + * Copyright 2001-2006 Rogue Wave Software. * **************************************************************************/ #define _RWSTD_LIB_SRC - #include -#ifndef _RWSTD_NO_V3_LOCALE - #include // for numeric_limits #include // for snprintf() @@ -75,7 +72,8 @@ const char* -__rw_get_stdio_fmat (char buf [32], int type, unsigned fmtflags, int prec); +__rw_get_stdio_fmat (char buf [32], int type, unsigned fmtflags, + _STD::streamsize prec); #ifdef _RWSTD_LONG_LONG @@ -417,7 +415,7 @@ j = 0; do { - const int dig = (i >> (j * bits)) & basemask; + const int dig = int ((i >> (j * bits)) & basemask); _RWSTD_ASSERT (dig >= 0 && dig <= basemask); @@ -621,13 +619,23 @@ typedef unsigned char UChar; - if (43 /* '+' or '-' */ == __rw_digit_map [UChar (*beg)]) + // is there a sign? + bool sgn = false; + + if (43 /* '+' or '-' */ == __rw_digit_map [UChar (*beg)]) { + sgn = true; ++beg; + } const char* pstr; switch (__rw_digit_map [UChar (*beg)]) { - case 18 /* 'I' or 'i' */ : pstr = "iInNfF\0\0"; break; + + case 18 /* 'I' or 'i' */ : + pstr = "iInNfF\0\0"; + len = 3; + break; + case 23 /* 'N' or 'n' */ : { // distinguish between quiet and signaling NaN @@ -638,12 +646,18 @@ // AIX, output NaNQ and NaNS, respectively) const UChar last = __rw_digit_map [UChar (*(end - 1))]; - if (26 /* 'Q' or 'q' */ == last) + if (26 /* 'Q' or 'q' */ == last) { pstr = "nNaAnNqQ"; - else if (28 /* 'S' or 's' */ == last) + len = 4; + } + else if (28 /* 'S' or 's' */ == last) { pstr = "nNaAnNsS"; - else + len = 4; + } + else { pstr = "nNaAnN\0\0"; + len = 3; + } break; } @@ -657,9 +671,12 @@ beg [1] = pstr [cap + 2]; beg [2] = pstr [cap + 4]; beg [3] = pstr [cap + 6]; - beg [4] = '\0'; - end = beg + 3 + ('0' != beg [3]); + end = beg + 3 + ('\0' != beg [3]); + + // increase the length by one for the sign + if (sgn) + ++len; #endif // _WIN{32,64} @@ -900,6 +917,3 @@ } // namespace __rw - - -#endif // _V3_LOCALE Modified: incubator/stdcxx/branches/4.2.0/src/parisc/atomic-64.s URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/parisc/atomic-64.s?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/parisc/atomic-64.s (original) +++ incubator/stdcxx/branches/4.2.0/src/parisc/atomic-64.s Fri Sep 28 13:55:52 2007 @@ -1,27 +1,28 @@ /*************************************************************************** * - * atomic-64.s + * parisc/atomic-64.s * * $Id$ * *************************************************************************** * - * Copyright 2005-2006 The Apache Software Foundation or its licensors, - * as applicable. + * 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 * - * Copyright 2001-2006 Rogue Wave Software. - * - * Licensed 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 + * 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. + * 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 2001-2006 Rogue Wave Software. * **************************************************************************/ Modified: incubator/stdcxx/branches/4.2.0/src/parisc/atomic.s URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/parisc/atomic.s?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/parisc/atomic.s (original) +++ incubator/stdcxx/branches/4.2.0/src/parisc/atomic.s Fri Sep 28 13:55:52 2007 @@ -1,25 +1,30 @@ /***************************************************************************** * + * parisc/atomic.s + * * $Id$ * - * Copyright 2005-2006 The Apache Software Foundation or its licensors, - * as applicable. + ***************************************************************************** * - * Copyright 2002-2006 Rogue Wave Software. + * 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 * - * 2002 Copyright Hewlett-Packard Company + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed 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 + * 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. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Copyright 2002-2006 Rogue Wave Software. * - * 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. + * 2002 Copyright Hewlett-Packard Company * * Routines for atomic increment and decrement of int32_t values * Modified: incubator/stdcxx/branches/4.2.0/src/punct.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/punct.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/punct.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/punct.cpp Fri Sep 28 13:55:52 2007 @@ -22,7 +22,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2001-2006 Rogue Wave Software. + * Copyright 2001-2007 Rogue Wave Software, Inc. * **************************************************************************/ @@ -582,7 +582,8 @@ const char* -__rw_get_stdio_fmat (char buf [32], int type, unsigned fmtflags, int prec) +__rw_get_stdio_fmat (char buf [32], int type, unsigned fmtflags, + _STD::streamsize prec) { char *pbuf = buf; @@ -608,7 +609,7 @@ // 7.19.6.1, p5 of C99 specifies that, when given using the // asterisk, negative precision is treated the same as if // it were omitted; treat negative precision the same here - pbuf += sprintf (pbuf, ".%d", prec); + pbuf += sprintf (pbuf, ".%ld", long (prec)); } } else if (fmtflags & _RWSTD_IOS_SHOWBASE) Modified: incubator/stdcxx/branches/4.2.0/src/rwstderr.msg URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/rwstderr.msg?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/rwstderr.msg (original) +++ incubator/stdcxx/branches/4.2.0/src/rwstderr.msg Fri Sep 28 13:55:52 2007 @@ -1,4 +1,30 @@ -$set 1 Rogue Wave(R) C++ Standard Library Error Messages +$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +$ +$ $Id$ +$ +$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ +$ +$ 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 1994-2007 Rogue Wave Software, Inc. +$ +$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + +$set 1 Apache C++ Standard Library Error Messages 1 %s: %s: exception 2 %s: %s: unexpected exception 3 %s: %s: out of memory Modified: incubator/stdcxx/branches/4.2.0/src/rwstderr.rc URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/rwstderr.rc?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/rwstderr.rc (original) +++ incubator/stdcxx/branches/4.2.0/src/rwstderr.rc Fri Sep 28 13:55:52 2007 @@ -1,3 +1,31 @@ +/*********************************************************************** + * + * rwsterr.rc - Apache C++ Standard Library Error Messages + * + * $Id$ + * + *********************************************************************** + * + * 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 1994-2007 Rogue Wave Software, Inc. + * + ***********************************************************************/ + #define _RWSTD_NO_INCLUDES #include Modified: incubator/stdcxx/branches/4.2.0/src/sparc/atomic-64.s URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/sparc/atomic-64.s?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/sparc/atomic-64.s (original) +++ incubator/stdcxx/branches/4.2.0/src/sparc/atomic-64.s Fri Sep 28 13:55:52 2007 @@ -1,27 +1,28 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! -! atomic-64.s +! sparc/atomic-64.s ! ! $Id$ ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! -! Copyright 2005-2006 The Apache Software Foundation or its licensors, -! as applicable. +! 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 ! -! Copyright 2002-2006 Rogue Wave Software. -! -! Licensed 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 +! 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. +! 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 2002-2006 Rogue Wave Software. ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Modified: incubator/stdcxx/branches/4.2.0/src/sparc/atomic.s URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/sparc/atomic.s?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/sparc/atomic.s (original) +++ incubator/stdcxx/branches/4.2.0/src/sparc/atomic.s Fri Sep 28 13:55:52 2007 @@ -1,27 +1,28 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! -! atomic-sparc.s +! sparc/atomic.s ! ! $Id$ ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! -! Copyright 2005-2006 The Apache Software Foundation or its licensors, -! as applicable. +! 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 ! -! Copyright 2002-2006 Rogue Wave Software. -! -! Licensed 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 +! 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. +! 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 2002-2006 Rogue Wave Software. ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Modified: incubator/stdcxx/branches/4.2.0/src/time_get.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/time_get.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/time_get.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/time_get.cpp Fri Sep 28 13:55:52 2007 @@ -32,12 +32,6 @@ #include -#ifndef _RWSTD_NO_V3_LOCALE - - _RWSTD_NAMESPACE (__rw) { } // namespace __rw - - -#endif // _RWSTD_NO_V3_LOCALE Modified: incubator/stdcxx/branches/4.2.0/src/time_put.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/time_put.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/time_put.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/time_put.cpp Fri Sep 28 13:55:52 2007 @@ -92,7 +92,7 @@ // declare these for Linux glibc and SunOS extern int daylight; extern long int timezone; -extern void tzset (); +extern void tzset () _LIBC_THROWS (); } // extern "C" Modified: incubator/stdcxx/branches/4.2.0/src/use_facet.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/use_facet.h?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/use_facet.h (original) +++ incubator/stdcxx/branches/4.2.0/src/use_facet.h Fri Sep 28 13:55:52 2007 @@ -39,6 +39,13 @@ #include "access.h" +// helper macro _RWSTD_DEFINE_FACET_FACTORY() defines a facet factory +// function called to construct, on demand, objects of specializations +// of facet class templates +// _byname facets are constructed on the heap while ordinary facets +// are constructed in static memory for efficiency and to avoid leaks, +// and are not destroyed during program lifetime + #ifndef _RWSTD_NO_BYNAME_FACET // definition for facets that come in both forms, plain and _byname @@ -51,9 +58,11 @@ { \ __rw_facet* pfacet; \ if (name) { \ + /* construct a _byname facet on the heap */ \ pfacet = new _STD:: Facet ## _byname TArgs (name, ref); \ } \ else { \ + /* construct an ordinary facet in static memory */ \ static union { \ void *align_; \ char data_ [sizeof (__rw_ ## fid ## _facet)]; \ @@ -80,11 +89,12 @@ Linkage __rw_facet* \ __rw_ct_ ## fid (_RWSTD_SIZE_T ref, const char*) \ { \ + /* construct an ordinary facet in static memory */ \ static union { \ void *align_; \ char data_ [sizeof (__rw_ ## fid ## _facet)]; \ } f; \ - static __rw_facet *pf = \ + static __rw_facet* const pf = \ new (&f) __rw_ ## fid ## _facet (ref); \ /* set the pointer to the facet id */ \ __rw_access::_C_get_pid (*pf) = \ Modified: incubator/stdcxx/branches/4.2.0/src/wcodecvt.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/wcodecvt.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/wcodecvt.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/wcodecvt.cpp Fri Sep 28 13:55:52 2007 @@ -22,7 +22,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 2001-2006 Rogue Wave Software. + * Copyright 2001-2007 Rogue Wave Software, Inc. * **************************************************************************/ @@ -804,13 +804,13 @@ // in strict mode check wide character for validity // (i.e., diagnose surrogate pairs as illegal) -# if _RWSTD_WCHAR_T_SIZE == _RWSTD_CHAR_SIZE +# if _RWSTD_WCHAR_SIZE == _RWSTD_CHAR_SIZE typedef unsigned char WIntT; -# elif _RWSTD_WCHAR_T_SIZE == _RWSTD_SHRT_SIZE +# elif _RWSTD_WCHAR_SIZE == _RWSTD_SHRT_SIZE typedef unsigned short WIntT; -# elif _RWSTD_WCHAR_T_SIZE ==_RWSTD_INT_SIZE +# elif _RWSTD_WCHAR_SIZE ==_RWSTD_INT_SIZE typedef unsigned int WIntT; -# elif _RWSTD_WCHAR_T_SIZE ==_RWSTD_LLONG_SIZE +# elif _RWSTD_WCHAR_SIZE ==_RWSTD_LLONG_SIZE typedef unsigned _RWSTD_LONG_LONG WIntT; # else typedef unsigned long WIntT; @@ -1068,7 +1068,7 @@ } // namespace __rw -_RWSTD_NAMESPACE (_V3_LOCALE) { +_RWSTD_NAMESPACE (std) { _RW::__rw_facet_id codecvt::id; @@ -1082,6 +1082,31 @@ } +/* virtual */ bool +codecvt:: +do_always_noconv () const _THROWS (()) +{ + return false; // conversion always necessary +} + + +/* virtual */ int +codecvt:: +do_encoding () const _THROWS (()) +{ + // 22.2.1.5.2 p6 1(ext.) <=> 1(int.) + return 1; +} + + +/* virtual */ int +codecvt:: +do_max_length () const _THROWS (()) +{ + return 1; +} + + /* virtual */ codecvt_base::result codecvt:: do_out (state_type &state, @@ -1760,7 +1785,7 @@ #endif // _RWSTD_NO_WCHAR_T -} // namespace _V3_LOCALE +} // namespace std #ifndef _RWSTD_NO_WCHAR_T Modified: incubator/stdcxx/branches/4.2.0/src/wctype.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/src/wctype.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/src/wctype.cpp (original) +++ incubator/stdcxx/branches/4.2.0/src/wctype.cpp Fri Sep 28 13:55:52 2007 @@ -371,7 +371,7 @@ } // namespace __rw -_RWSTD_NAMESPACE (_V3_LOCALE) { +_RWSTD_NAMESPACE (std) { _RW::__rw_facet_id ctype::id; @@ -856,19 +856,19 @@ ctype_byname:: do_narrow (char_type c, char dfault) const { -#if _RWSTD_WCHAR_T_MIN < 0 +#if _RWSTD_WCHAR_MIN < 0 // wchar_t is a signed type if (c > L'\0' && c < SCHAR_MAX) return char (c); -#else // if _RWSTD_WCHAR_T_MIN >= 0 +#else // if _RWSTD_WCHAR_MIN >= 0 // wchar_t is an unsigned type if (c < SCHAR_MAX) return char (c); -#endif // _RWSTD_WCHAR_T_MIN +#endif // _RWSTD_WCHAR_MIN const _RW::__rw_codecvt_t* cvt = _RWSTD_STATIC_CAST(const _RW::__rw_codecvt_t*, _C_cvtimpl); @@ -898,11 +898,11 @@ } else { -#if _RWSTD_WCHAR_T_MIN < 0 +#if _RWSTD_WCHAR_MIN < 0 // For a signed wchar_t test if the character has a negative value if (c < 0) return dfault; -#endif // _RWSTD_WCHAR_T_MIN < 0 +#endif // _RWSTD_WCHAR_MIN < 0 // Look up narrow character value in database; be aware that there // is no way to know what the internal representation is for this @@ -918,12 +918,12 @@ char* ptmp = tmp; _RWSTD_SIZE_T utf8_sz = _RW::__rw_itoutf8 (c, tmp); -#if _RWSTD_WCHAR_T_MIN < 0 +#if _RWSTD_WCHAR_MIN < 0 // compute the invalid bit mask (the MSB set) - const wchar_t imask = wchar_t (~(_RWSTD_WCHAR_T_MAX)); + const wchar_t imask = wchar_t (~(_RWSTD_WCHAR_MAX)); #else - const wchar_t imask = wchar_t (~(_RWSTD_WCHAR_T_MAX >> 1)); -#endif // _RWSTD_WCHAR_T_MIN < 0 + const wchar_t imask = wchar_t (~(_RWSTD_WCHAR_MAX >> 1)); +#endif // _RWSTD_WCHAR_MIN < 0 typedef unsigned char UChar; @@ -931,7 +931,7 @@ wc = ptbl [UChar (*ptmp)]; while (wc & imask) { // check validity of the value - if (wc == (imask | _RWSTD_WCHAR_T_MAX)) + if (wc == (imask | _RWSTD_WCHAR_MAX)) return dfault; ptbl = tbl + 256 * (wc & (~imask)); @@ -1014,12 +1014,12 @@ } else { -#if _RWSTD_WCHAR_T_MIN < 0 +#if _RWSTD_WCHAR_MIN < 0 // compute the invalid bit mask (the MSB set) - const char_type imask = char_type (~(_RWSTD_WCHAR_T_MAX)); + const char_type imask = char_type (~(_RWSTD_WCHAR_MAX)); #else - const char_type imask = char_type (~(_RWSTD_WCHAR_T_MAX >> 1)); -#endif // _RWSTD_WCHAR_T_MIN < 0 + const char_type imask = char_type (~(_RWSTD_WCHAR_MAX >> 1)); +#endif // _RWSTD_WCHAR_MIN < 0 // Lookup the narrow character in the table; be aware that // the result of the lookup might be the index for another @@ -1051,7 +1051,7 @@ } -} // namespace _V3_LOCALE +} // namespace std _RWSTD_DEFINE_FACET_FACTORY (static, ctype, , wctype); Modified: incubator/stdcxx/branches/4.2.0/tests/containers/23.list.assign.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/containers/23.list.assign.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/containers/23.list.assign.cpp (original) +++ incubator/stdcxx/branches/4.2.0/tests/containers/23.list.assign.cpp Fri Sep 28 13:55:52 2007 @@ -246,9 +246,8 @@ operator() (List &lst, const ContainerTestCaseData& tdata) const { - const ContainerTestCase &tcase = tdata.tcase_; - - bool reverse_iter = ListIds::ReverseIterator == tdata.func_.iter_id_ + const bool reverse_iter = + ListIds::ReverseIterator == tdata.func_.iter_id_ || ListIds::ConstReverseIterator == tdata.func_.iter_id_; const std::size_t off = tdata.arglen_ - tdata.off2_ - tdata.ext2_; @@ -284,8 +283,8 @@ const ListVal* const beg = tdata.arg_ + tdata.off2_; const ListVal* const end = beg + tdata.ext2_; - const Iterator first = _RWSTD_CONST_CAST (const Iterator, beg); - const Iterator last = _RWSTD_CONST_CAST (const Iterator, end); + const Iterator first = _RWSTD_CONST_CAST (Iterator, beg); + const Iterator last = _RWSTD_CONST_CAST (Iterator, end); lst.assign (first, last); return lst; Modified: incubator/stdcxx/branches/4.2.0/tests/containers/23.list.insert.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/containers/23.list.insert.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/containers/23.list.insert.cpp (original) +++ incubator/stdcxx/branches/4.2.0/tests/containers/23.list.insert.cpp Fri Sep 28 13:55:52 2007 @@ -383,8 +383,6 @@ operator() (List &lst, const ContainerTestCaseData& tdata) const { - const ContainerTestCase &tcase = tdata.tcase_; - // create a pair of iterators into the list object being modified ListIter first1 (lst.begin ()); _rw_advance (first1, tdata.off1_); @@ -415,8 +413,6 @@ operator() (List &lst, const ContainerTestCaseData& tdata) const { - const ContainerTestCase &tcase = tdata.tcase_; - // create a pair of iterators into the list object being modified ListIter first1 (lst.begin ()); _rw_advance (first1, tdata.off1_); @@ -460,16 +456,14 @@ operator() (List& lst, const ContainerTestCaseData& tdata) const { - const ContainerTestCase &tcase = tdata.tcase_; - ListIter first1 (lst.begin ()); _rw_advance (first1, tdata.off1_); const ListVal* const beg = tdata.arg_ + tdata.off2_; const ListVal* const end = beg + tdata.ext2_; - const Iterator first2 = _RWSTD_CONST_CAST (const Iterator, beg); - const Iterator last2 = _RWSTD_CONST_CAST (const Iterator, end); + const Iterator first2 = _RWSTD_CONST_CAST (Iterator, beg); + const Iterator last2 = _RWSTD_CONST_CAST (Iterator, end); lst.insert (first1, first2, last2); return lst; Copied: incubator/stdcxx/branches/4.2.0/tests/containers/23.vector.allocator.cpp (from r580189, incubator/stdcxx/trunk/tests/containers/23.vector.allocator.cpp) URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/containers/23.vector.allocator.cpp?p2=incubator/stdcxx/branches/4.2.0/tests/containers/23.vector.allocator.cpp&p1=incubator/stdcxx/trunk/tests/containers/23.vector.allocator.cpp&r1=580189&r2=580483&rev=580483&view=diff ============================================================================== --- incubator/stdcxx/trunk/tests/containers/23.vector.allocator.cpp (original) +++ incubator/stdcxx/branches/4.2.0/tests/containers/23.vector.allocator.cpp Fri Sep 28 13:55:52 2007 @@ -5,7 +5,7 @@ * Test exercising vector specialized on a user-defined allocator * with a user-defined pointer type. * - * $Id:$ + * $Id$ * *************************************************************************** * Modified: incubator/stdcxx/branches/4.2.0/tests/include/rw_locale.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/include/rw_locale.h?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/include/rw_locale.h (original) +++ incubator/stdcxx/branches/4.2.0/tests/include/rw_locale.h Fri Sep 28 13:55:52 2007 @@ -1,27 +1,28 @@ /************************************************************************ * - * localedef.h - declarations of locale testsuite helpers + * rw_locale.h - declarations of locale testsuite helpers * * $Id$ * ************************************************************************ * - * Copyright 2005-2006 The Apache Software Foundation or its licensors, - * as applicable. + * 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 * - * Copyright 2001-2006 Rogue Wave Software. - * - * Licensed 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 + * 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. + * 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 2001-2006 Rogue Wave Software. * **************************************************************************/ @@ -36,11 +37,14 @@ _TEST_EXPORT char* -rw_locales (int = _UNUSED_CAT, const char* = 0); +rw_locales (int = _UNUSED_CAT, const char* = 0, bool = true); +// invokes the locale utility with the arguments specified by 'arg', +// redirecting its output to the file named by 'fname' if non-null +// returns the exit status of the utility _TEST_EXPORT int -rw_locale (const char *args, const char *fname); +rw_locale (const char* /* args */, const char* /* fname */); // creates a temporary directory and defines the RWSTD_LOCALE_ROOT @@ -53,6 +57,7 @@ _TEST_EXPORT const char* rw_set_locale_root (); + // invokes localedef to create a locale database named by the last argument, // if non-0, or in a directory specified by the RWSTD_LOCALE_ROOT environment // variable otherwise, if it is defined, otherwise in the current working @@ -64,6 +69,17 @@ rw_localedef (const char*, const char*, const char*, const char*); +// stores up to 'size' wide characters valid in the current locale +// in consecutive elements of the 'wbuf' buffer; if 'nbytes' is +// non-zero only wide characters with multibyte sequences of the +// specified length will be stored (as determined by mblen()) +// returns the number of elements stored +_TEST_EXPORT _RWSTD_SIZE_T +rw_get_wchars (wchar_t* /* wbuf */, + _RWSTD_SIZE_T /* size */, + int /* nbytes */ = 0); + + // an array of multibyte characters 1 to MB_LEN_MAX bytes in length typedef char rw_mbchar_array_t [_RWSTD_MB_LEN_MAX][_RWSTD_MB_LEN_MAX]; @@ -89,7 +105,28 @@ // directory // returns the name of the locale _TEST_EXPORT const char* -rw_create_locale (const char *charmap, const char *locale); +rw_create_locale (const char* /* charmap */, const char* /* locale */); + + +// NUL-separated list of locale names specified by the --locales +// command line option (set by the rw_opt_setlocales handler) +_TEST_EXPORT extern const char* const& +rw_opt_locales; + +// callback function invoked in response to the --locales= +// command line option to set the rw_opt_locales global variable to the +// NUL-separated list of locale names to exercise +_TEST_EXPORT int +rw_opt_setlocales (int, char*[]); + + +// creates message file and invokes gencat to create message catalog +// then removes the message file +// catalog is a '\0' separated list of strings, each of which representing +// a single message, and with a blank line separating one set from another +// returns 0 in success +_TEST_EXPORT int +rw_create_catalog (const char * /* catname */, const char * /* catalog */); #endif // RW_LOCALE_H_INCLUDED Modified: incubator/stdcxx/branches/4.2.0/tests/include/rw_streambuf.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/include/rw_streambuf.h?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/include/rw_streambuf.h (original) +++ incubator/stdcxx/branches/4.2.0/tests/include/rw_streambuf.h Fri Sep 28 13:55:52 2007 @@ -53,8 +53,7 @@ Sync = 0x0400, // bit OR-ed with MemFun bits Throw = 0x1000, - Failure = 0x2000, - Unknown = 0x4000 + Failure = 0x2000 }; static const char* const streambuf_func_names[] = { @@ -235,6 +234,10 @@ // set the fail and throw flags if (fail_set & Throw) { throw_set_ = fail_set & ~Throw; + + for (unsigned i = 0; i < 11; ++i) + if (throw_set_ & (1U << i)) + throw_when_ [i] = when; } else { fail_set_ = fail_set; @@ -281,6 +284,10 @@ // set the fail and throw flags if (fail_set & Throw) { throw_set_ = fail_set & ~Throw; + + for (unsigned i = 0; i < 11; ++i) + if (throw_set_ & (1U << i)) + throw_when_ [i] = when; } else { fail_set_ = fail_set; Modified: incubator/stdcxx/branches/4.2.0/tests/include/rw_thread.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/include/rw_thread.h?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/include/rw_thread.h (original) +++ incubator/stdcxx/branches/4.2.0/tests/include/rw_thread.h Fri Sep 28 13:55:52 2007 @@ -59,9 +59,11 @@ // create a pool of nthreads, passing each a successive element // of argarray as argument (if non-null) and filling the tidarray -// array with their id's; if tidarray is null, waits for all +// array with their id's; if (tidarray == 0), waits for all // threads to join and fills the aragarray with the result // returned from each thread +// if (nthreads == SIZE_MAX), sets nthreads to the positive result +// of rw_get_processors() plus 1, or to 2 otherwise // returns 0 on success, or a non-zero value indicating the thread // number that failed to create on error _TEST_EXPORT int @@ -70,6 +72,12 @@ rw_thread_attr_t* /* attr */, void* (*)(void*) /* thr_proc */, void** /* argarray */); + +// returns the number of logical processors/cores on the system, +// or -1 on error +_TEST_EXPORT int +rw_get_cpus (); + } // extern "C" Modified: incubator/stdcxx/branches/4.2.0/tests/include/testdefs.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/include/testdefs.h?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/include/testdefs.h (original) +++ incubator/stdcxx/branches/4.2.0/tests/include/testdefs.h Fri Sep 28 13:55:52 2007 @@ -6,22 +6,25 @@ * *************************************************************************** * - * Copyright 2005-2006 The Apache Software Foundation or its licensors, - * as applicable. - * - * Copyright 2003-2006 Rogue Wave Software. + * 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 * - * Licensed 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 + * 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. + * 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 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Copyright 2003-2007 Rogue Wave Software, Inc. * **************************************************************************/ @@ -31,6 +34,14 @@ #include +#ifdef _RWSTD_TEST_SRC + // #undef-ine the Compaq C++ macro #defined in response to + // the -std strict_ansi_errors compiler option in order to + // allow C++ extensions (such POSIX names) to be declared + // by C++ libc headers when building the test driver +# undef __PURE_CNAME +#endif // _RWSTD_TEST_SRC + #if (defined (_WIN32) || defined (_WIN64)) \ && (defined (RWDLL) || defined (_RWSHARED)) @@ -153,5 +164,13 @@ ((expr) ? (void)0 : _RW::__rw_assert_fail (#expr, __FILE__, __LINE__, 0)) #endif // _RWSTD_NO_PRETTY_FUNCTION, _RWSTD_NO_FUNC +// convenience macro to get number of elements in a c style array +#define RW_COUNT_OF(x) (sizeof(x) / sizeof(*x)) + +#if defined (__INTEL_COMPILER) && __INTEL_COMPILER <= 1000 + // disable warning #279: controlling expression is constant + // issued for the commonly used RW_ASSERT(!"not implemented") +# pragma warning (disable: 279) +#endif // Intel C++ 10.0 and prior #endif // RW_TESTDEFS_H_INCLUDED Modified: incubator/stdcxx/branches/4.2.0/tests/iostream/27.istream.manip.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/iostream/27.istream.manip.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/iostream/27.istream.manip.cpp (original) +++ incubator/stdcxx/branches/4.2.0/tests/iostream/27.istream.manip.cpp Fri Sep 28 13:55:52 2007 @@ -301,10 +301,9 @@ skipws, err_type, err_after); ////////////////////////////////////////////////////////////////// - // verify that gcount() correctly reflects the number of whitespace - // characters extracted from the stream + // verify that gcount() value not affected (27.6.1.4 p1) - rw_assert (extract == is.gcount (), 0, __LINE__, + rw_assert (0 == is.gcount (), 0, __LINE__, "%u. std::ws (basic_istream<%s, %s >&)." "gcount() == %d, got %d; whitespace is" " '%c', input is %{*Ac}, initial rdstate() = %{Is}, " @@ -321,7 +320,11 @@ // (i.e., the initial stream state), // except... std::ios_base::iostate expect_state = state; - if (!state && (white == cbuf [0] || !err_after)) { + if (state) { + // lwg 419 + expect_state |= std::ios_base::failbit; + } + else if (white == cbuf [0] || !err_after) { #ifndef _RWSTD_NO_EXCEPTIONS Modified: incubator/stdcxx/branches/4.2.0/tests/iostream/27.istream.unformatted.get.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/iostream/27.istream.unformatted.get.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/iostream/27.istream.unformatted.get.cpp (original) +++ incubator/stdcxx/branches/4.2.0/tests/iostream/27.istream.unformatted.get.cpp Fri Sep 28 13:55:52 2007 @@ -54,15 +54,14 @@ int nexpect, int rdstate, int exceptions, - MemFun caught) + int caught) { static const char* const exnames[] = { - "none", "std::ios_base::failure", "unknown exception" + "none", "std::ios_base::failure", + "streambuf_exception", "unknown exception" }; - const char* const caught_what = - caught < int (sizeof exnames / sizeof *exnames) ? - exnames [caught] : "streambuf_exception"; + const char* const caught_what = exnames [caught]; // verify that stream is in the expected state rw_assert (strm.rdstate () == rdstate, 0, lineno, @@ -71,13 +70,13 @@ __LINE__, cname, fun, rdstate, strm.rdstate ()); - if (sb.throw_set_ && sb.ncalls (sb.threw_) == sb.fail_when_ + 1) { + if (sb.throw_set_ && sb.ncalls (sb.threw_) == sb.fail_when_) { // verify that the same exception (and not ios_base::failure) // as the one thrown from basic_filebuf has been propagated // and caught when badbit is set in exceptions, and that no // exception has been thrown if exceptions is clear - if (exceptions & Bad && caught != sb.threw_) { + if (exceptions & Bad && caught != 2) { rw_assert (false, 0, lineno, "line %d: basic_istream<%s>::%s failed " @@ -100,7 +99,7 @@ // or that it increased exactly `fail_when_' const int actual = strm.gcount () - gcount; - rw_assert (!actual || actual == sb.fail_when_, 0, lineno, + rw_assert (!actual || actual == sb.fail_when_ - 1, 0, lineno, "line %d: basic_istream<%s>::%s changed " "gcount () from %d to %d after a failure; " "either no change from 0 expected, or " @@ -112,7 +111,7 @@ // verify that ios_base::failure has been thrown (and caught) // if badbit is set in exceptions - rw_assert (!(exceptions & strm.rdstate ()) || caught == Failure, + rw_assert (!(exceptions & strm.rdstate ()) || caught == 1, 0, lineno, "line %d: basic_istream<%s>::%s set %{Is} " "but failed to throw ios_base::failure " @@ -138,14 +137,14 @@ try { \ expr; \ } \ - catch (MemFun e) { \ - caught = e; \ - } \ catch (const std::ios_base::failure&) { \ - caught = Failure; \ + caught = 1; \ + } \ + catch (Exception& e) { \ + caught = ex_stream == e.id_ ? 2 : 3; \ } \ catch (...) { \ - caught = Unknown; \ + caught = 3; \ } (void)0 @@ -201,7 +200,7 @@ int_type got = Traits::eof (); - MemFun caught = None; + int caught = 0; TRY_GET (got = strm.get ()); @@ -252,21 +251,21 @@ TEST (T, "\x80", 1, 0x80, Good, Good, 0, -1); TEST (T, "\xff ", 2, 0xff, Good, Good, 0, -1); - TEST (T, "c", 1, eof, Eof | Fail, Good, Underflow, 0); - TEST (T, "d", 1, eof, Bad, Good, Underflow | Throw, 0); + TEST (T, "c", 1, eof, Eof | Fail, Good, Underflow, 1); + TEST (T, "d", 1, eof, Bad, Good, Underflow | Throw, 1); eof = 256; TEST (T, "", 0, eof, Eof | Fail, Good, 0, 0); TEST (T, "f", 1, 'f', Good, Good, 0, 0); - TEST (T, "g", 1, eof, Eof | Fail, Good, Underflow, 0); - TEST (T, "h", 1, eof, Bad, Good, Underflow | Throw, 0); + TEST (T, "g", 1, eof, Eof | Fail, Good, Underflow, 1); + TEST (T, "h", 1, eof, Bad, Good, Underflow | Throw, 1); eof = '\0'; TEST (T, "\0", 1, eof, Eof | Fail, Good, 0, -1); - TEST (T, "\1", 1, eof, Eof | Fail, Good, Underflow, 0); - TEST (T, "\2", 1, eof, Bad, Good, Underflow | Throw, 0); + TEST (T, "\1", 1, eof, Eof | Fail, Good, Underflow, 1); + TEST (T, "\2", 1, eof, Bad, Good, Underflow | Throw, 1); } /***********************************************************************/ @@ -311,7 +310,7 @@ charT got = charT (UChar (initval)); const charT val = charT (UChar (expectval)); - MemFun caught = None; + int caught = 0; TRY_GET (strm.get (got)); @@ -368,14 +367,14 @@ TEST (T, "2 ", 2, '\3', '2', Good, Good, 0, -1); TEST (T, " 3", 2, '\4', ' ', Good, Good, 0, -1); - TEST (T, "4", 1, '\5', '\5', Eof | Fail, Good, Underflow, 0); - TEST (T, "5", 1, '\6', '\6', Bad, Good, Underflow | Throw, 0); - TEST (T, "6", 1, '\7', '\6', Eof | Fail, Eof, Underflow, 0); - TEST (T, "7", 1, 'x', 'x', Eof | Fail, Fail, Underflow, 0); - TEST (T, "8", 1, 'y', 'y', Eof | Fail, Eof | Fail, Underflow, 0); - TEST (T, "9", 1, 'z', 'z', Eof | Fail, Eof | Fail | Bad, Underflow, 0); + TEST (T, "4", 1, '\5', '\5', Eof | Fail, Good, Underflow, 1); + TEST (T, "5", 1, '\6', '\6', Bad, Good, Underflow | Throw, 1); + TEST (T, "6", 1, '\7', '\6', Eof | Fail, Eof, Underflow, 1); + TEST (T, "7", 1, 'x', 'x', Eof | Fail, Fail, Underflow, 1); + TEST (T, "8", 1, 'y', 'y', Eof | Fail, Eof | Fail, Underflow, 1); + TEST (T, "9", 1, 'z', 'z', Eof | Fail, Eof | Fail | Bad, Underflow, 1); - TEST (T, "A", 1, 'a', 'a', Bad, Bad, Underflow | Throw, 0); + TEST (T, "A", 1, 'a', 'a', Bad, Bad, Underflow | Throw, 1); } /***********************************************************************/ @@ -440,7 +439,7 @@ typedef unsigned char UChar; - MemFun caught = None; + int caught = 0; charT got [MAXCHARS + 1]; Traits::assign (got, sizeof got / sizeof *got, charT ('\xfe')); @@ -521,23 +520,23 @@ // exercise the behavior on underflow() failure indicated // by returning traits_type::eof() - TEST (T, "78\n9", 4, 4, eof, 0, Eof | Fail, Good, Underflow, 0); - TEST (T, "78901", 5, 5, eof, 0, Eof | Fail, Eof, Underflow, 0); - TEST (T, "78902", 5, 5, eof, 0, Eof | Fail, Fail, Underflow, 0); - TEST (T, "78803", 5, 5, eof, 0, Eof | Fail, Eof | Fail, Underflow, 0); - TEST (T, "89\na", 4, 4, eof, 1, Eof, Good, Underflow, 1); - TEST (T, "9a\nb", 4, 4, eof, 2, Eof, Good, Underflow, 2); - TEST (T, "ab\nc", 4, 4, eof, 2, Good, Good, Underflow, 3); + TEST (T, "78\n9", 4, 4, eof, 0, Eof | Fail, Good, Underflow, 1); + TEST (T, "78901", 5, 5, eof, 0, Eof | Fail, Eof, Underflow, 1); + TEST (T, "78902", 5, 5, eof, 0, Eof | Fail, Fail, Underflow, 1); + TEST (T, "78803", 5, 5, eof, 0, Eof | Fail, Eof | Fail, Underflow, 1); + TEST (T, "89\na", 4, 4, eof, 1, Eof, Good, Underflow, 2); + TEST (T, "9a\nb", 4, 4, eof, 2, Eof, Good, Underflow, 3); + TEST (T, "ab\nc", 4, 4, eof, 2, Good, Good, Underflow, 4); // exercise the behavior on underflow() failure caused // by throwing an exception - TEST (T, "bc\nd", 4, 4, eof, 0, Bad, Good, Underflow | Throw, 0); - TEST (T, "cd\ne", 4, 4, eof, 1, Bad, Good, Underflow | Throw, 1); - TEST (T, "def\n", 4, 4, eof, 2, Bad, Good, Underflow | Throw, 2); - TEST (T, "efg\n", 4, 4, eof, 2, Bad, Bad, Underflow | Throw, 2); - TEST (T, "fgh\n", 4, 4, eof, 3, Good, Bad, Underflow | Throw, 3); - TEST (T, "ghij", 4, 4, eof, 3, Good, Bad, Underflow | Throw, 3); - TEST (T, "hijk", 4, 5, eof, 3, Bad, Bad, Underflow | Throw, 3); + TEST (T, "bc\nd", 4, 4, eof, 0, Bad, Good, Underflow | Throw, 1); + TEST (T, "cd\ne", 4, 4, eof, 1, Bad, Good, Underflow | Throw, 2); + TEST (T, "def\n", 4, 4, eof, 2, Bad, Good, Underflow | Throw, 3); + TEST (T, "efg\n", 4, 4, eof, 2, Bad, Bad, Underflow | Throw, 3); + TEST (T, "fgh\n", 4, 4, eof, 3, Good, Bad, Underflow | Throw, 4); + TEST (T, "ghij", 4, 4, eof, 3, Good, Bad, Underflow | Throw, 4); + TEST (T, "hijk", 4, 5, eof, 3, Bad, Bad, Underflow | Throw, 4); const std::streamsize N = std::streamsize (MAXCHARS); char *buf = new char [N]; @@ -631,7 +630,7 @@ typedef unsigned char UChar; - MemFun caught = None; + int caught = 0; Streambuf outbuf (strsize, out_failure, out_fail_when); @@ -714,27 +713,27 @@ TEST (T, "cd\0e", 4, '\0', 2, Good, Good, 0, 0); TEST (T, "def\0", 4, '\0', 3, Good, Good, 0, 0); - TEST (T, "efgh", 4, 'f', 0, Eof | Fail, Good, Underflow, 0); - TEST (T, "fghi", 4, 'g', 0, Eof | Fail, Eof, Underflow, 0); - TEST (T, "ghij", 4, 'h', 0, Eof | Fail, Fail, Underflow, 0); - TEST (T, "hijk", 4, 'i', 0, Eof | Fail, Eof | Fail, Underflow, 0); - - TEST (T, "ijkl", 4, 'k', 1, Eof, Good, Underflow, 1); - TEST (T, "jklm", 4, 'm', 2, Eof, Good, Underflow, 2); - - TEST (T, "klmn", 4, 'n', 2, Bad, Good, Underflow | Throw, 2); - TEST (T, "lmno", 4, 'o', 2, Bad, Bad, Underflow | Throw, 2); - - TEST (T, "EFGH", 4, 'F', 0, Fail, Good, Overflow, 0); - TEST (T, "FGHI", 4, 'G', 0, Fail, Eof, Overflow, 0); - TEST (T, "GHIJ", 4, 'H', 0, Fail, Fail, Overflow, 0); - TEST (T, "HIJK", 4, 'I', 0, Fail, Eof | Fail, Overflow, 0); + TEST (T, "efgh", 4, 'f', 0, Eof | Fail, Good, Underflow, 1); + TEST (T, "fghi", 4, 'g', 0, Eof | Fail, Eof, Underflow, 1); + TEST (T, "ghij", 4, 'h', 0, Eof | Fail, Fail, Underflow, 1); + TEST (T, "hijk", 4, 'i', 0, Eof | Fail, Eof | Fail, Underflow, 1); + + TEST (T, "ijkl", 4, 'k', 1, Eof, Good, Underflow, 2); + TEST (T, "jklm", 4, 'm', 2, Eof, Good, Underflow, 3); + + TEST (T, "klmn", 4, 'n', 2, Bad, Good, Underflow | Throw, 3); + TEST (T, "lmno", 4, 'o', 2, Bad, Bad, Underflow | Throw, 3); + + TEST (T, "EFGH", 4, 'F', 0, Fail, Good, Overflow, 1); + TEST (T, "FGHI", 4, 'G', 0, Fail, Eof, Overflow, 1); + TEST (T, "GHIJ", 4, 'H', 0, Fail, Fail, Overflow, 1); + TEST (T, "HIJK", 4, 'I', 0, Fail, Eof | Fail, Overflow, 1); - TEST (T, "IJKL", 4, 'K', 1, Fail, Good, Overflow, 1); - TEST (T, "JKLM", 4, 'M', 2, Fail, Good, Overflow, 2); + TEST (T, "IJKL", 4, 'K', 1, Fail, Good, Overflow, 2); + TEST (T, "JKLM", 4, 'M', 2, Fail, Good, Overflow, 3); - TEST (T, "KLMN", 4, 'N', 2, Fail, Good, Overflow | Throw, 2); - TEST (T, "LMNO", 4, 'O', 2, Fail, Bad, Overflow | Throw, 2); + TEST (T, "KLMN", 4, 'N', 2, Fail, Good, Overflow | Throw, 3); + TEST (T, "LMNO", 4, 'O', 2, Fail, Bad, Overflow | Throw, 3); rw_info (0, 0, 0, "27.6.1.3, p15 - std::basic_istream<%s>" "::get (basic_streambuf&)", cname); Modified: incubator/stdcxx/branches/4.2.0/tests/iostream/27.ostream.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/iostream/27.ostream.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/iostream/27.ostream.cpp (original) +++ incubator/stdcxx/branches/4.2.0/tests/iostream/27.ostream.cpp Fri Sep 28 13:55:52 2007 @@ -779,16 +779,19 @@ if (!tsb.throws_ && !tnp.throws_) { + bool pass; + +#ifdef _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE // verify that width(0) has been called (unless there are exceptions // involved, in which case it's unspecified whether width(0) has or // has not been called - bool pass = - !((!exceptions || !tsb.fails_ && !tnp.fails_) && os.width ()); + pass = !((!exceptions || !tsb.fails_ && !tnp.fails_) && os.width ()); rw_assert (pass, __FILE__, line1, "%d. std::basic_ostream<%s>::operator<<(%s = %{#lc})" ".width () == 0, got %d", line2, cname, tname, val, os.width ()); +#endif // _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE // verify that ios_base::failure has been thrown (and caught) // if badbit is set in exceptions @@ -1409,6 +1412,8 @@ } { + // exercise LWG issue 581: flush() not unformatted function + test_streambuf tsb (0); Ostream strm (&tsb); Modified: incubator/stdcxx/branches/4.2.0/tests/iostream/27.stringbuf.virtuals.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/iostream/27.stringbuf.virtuals.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/iostream/27.stringbuf.virtuals.cpp (original) +++ incubator/stdcxx/branches/4.2.0/tests/iostream/27.stringbuf.virtuals.cpp Fri Sep 28 13:55:52 2007 @@ -34,7 +34,7 @@ /**************************************************************************/ #undef EOF -#define EOF traits_eof +#define EOF (_RWSTD_INT_MIN + 2) #undef NOT_EOF #define NOT_EOF (_RWSTD_INT_MIN + 1) @@ -178,6 +178,12 @@ rw_note (0, 0, 0, "test on line %d disabled", line); return; } + + if (EOF == arg0) + arg0 = Traits::eof (); + + if (EOF == ret_expect) + ret_expect = Traits::eof (); // widen the source sequence into the (possibly wide) character buffer static charT wstr [4096]; Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.out.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.out.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.out.cpp (original) +++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.codecvt.out.cpp Fri Sep 28 13:55:52 2007 @@ -148,7 +148,7 @@ *mbchar = '\0'; } -#if 2 < _RWSTD_WCHAR_T_SIZE +#if 2 < _RWSTD_WCHAR_SIZE // if a multibyte character of the requested size is not found // in the low 64K range, try to find one using a random search Modified: incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.messages.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.messages.cpp?rev=580483&r1=580482&r2=580483&view=diff ============================================================================== --- incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.messages.cpp (original) +++ incubator/stdcxx/branches/4.2.0/tests/localization/22.locale.messages.cpp Fri Sep 28 13:55:52 2007 @@ -31,26 +31,20 @@ #include // for rw_test() #include // for rw_putenv() #include // for rw_nextfd() -#include // for rw_locales() +#include // for rw_locales(), rw_create_catalog() #include // for rw_system() -#ifndef _MSC_VER -# include // for cat operations -#endif - #include // for strlen() -#include // for getcwd(), getenv() -#include // for FILE, fopen(), fprintf() +#include // for getenv() +#include // for remove() #include // for LC_ALL #include // for mbsinit() - #ifndef _RWSTD_NO_NEW_HEADER -# include // for fileno() # if defined (_MSC_VER) # include // for _open() -# include +# include // for getcwd() # else # include # include @@ -260,75 +254,7 @@ } }; - -void generate_catalog (const char *msg_name, - const char* const text [MAX_SETS][MAX_MESSAGES]) -{ - std::FILE* const f = std::fopen (msg_name, "w"); - - if (!f) - return; - -#ifndef _WIN32 - - for (int i = 0; i < MAX_SETS; ++i) { - std::fprintf (f, "$set %d This is Set %d\n", i+1, i+1); - for (int j = 0; j < MAX_MESSAGES; ++j) { - std::fprintf (f, "%d %s\n", j + 1, text [i][j]); - } - } - -#else // if defined (_WIN32) - - std::fprintf (f, "STRINGTABLE\nBEGIN\n"); - for (int i = 0; i < MAX_SETS; ++i) { - for (int j = 0; j < MAX_MESSAGES; ++j) { - const int msgid = msg_id (i + 1, j + 1); - std::fprintf (f, "%d \"%s\"\n", msgid, text[i][j]); - } - } - - std::fprintf (f, "END\n"); - -#endif // _WIN32 - - std::fclose (f); - - char *cat_name = new char [std::strlen (msg_name) + 1]; - const char *dot = std::strrchr (msg_name, '.'); - std::strncpy (cat_name, msg_name, dot - msg_name); - *(cat_name + (dot - msg_name)) = '\0'; - -#ifndef _WIN32 - - rw_system ("gencat %s.cat %s", cat_name, msg_name); - -#else // if defined (_WIN32) - - char cpp_name [128]; - - std::sprintf (cpp_name, "%s.cpp", cat_name); - - std::FILE* const cpp_file = std::fopen (cpp_name, "w"); - std::fprintf (cpp_file, "void foo () { }"); - std::fclose (cpp_file); - - rw_system ( "rc -r %s.rc " - "&& cl -nologo -c %s" - "&& link -nologo /DLL /OUT:%s.dll %s.obj %s.res", - cat_name, - cpp_name, - cat_name, cat_name, cat_name); - - rw_system (SHELL_RM_F "%s %s.rc %s.res %s.obj", - cpp_name, cat_name, cat_name, cat_name); - -#endif // _WIN32 - - delete[] cat_name; - - std::remove (msg_name); -} +static std::string catalog; /***************************************************************************/ @@ -527,13 +453,23 @@ int fdcount [2]; int next_fd [2]; +#ifndef _WIN32 next_fd [0] = rw_nextfd (fdcount + 0); +#else + // don't test file descriptor leaking on Win32 to avoid + // invalid parameter error + // catalog functions not uses file descriptors + next_fd [0] = fdcount [0] = 0; +#endif rw_info (0, 0, __LINE__, "std::messages<%s>::open() and close() in locale(#%s)", cname, loc_name); - const std::locale loc (loc_name); + // construct a copy of the named locale or default + // when no name is specified + const std::locale loc = + loc_name ? std::locale (loc_name) : std::locale (); const std::messages& msgs = std::use_facet >(loc); @@ -548,7 +484,11 @@ close_catalog (msgs, cat, true, cname, __LINE__); // verify that no file descriptor has leaked +#ifndef _WIN32 next_fd [1] = rw_nextfd (fdcount + 1); +#else + next_fd [1] = fdcount [1] = 0; +#endif rw_assert (next_fd [1] == next_fd [0] && fdcount [0] == fdcount [1], 0, __LINE__, @@ -564,7 +504,10 @@ const char* const text[5][5], const char *cname) { - const std::locale loc (loc_name); + // construct a copy of the named locale or default + // when no name is specified + const std::locale loc = + loc_name ? std::locale (loc_name) : std::locale (); const std::messages& msgs = std::use_facet > (loc); @@ -584,9 +527,9 @@ typedef std::allocator Allocator; typedef std::basic_string String; - for (int setId = 1; setId < MAX_SETS; ++setId) { + for (int setId = 1; setId <= MAX_SETS; ++setId) { - for (int msgId = 1; msgId < MAX_MESSAGES; ++msgId) { + for (int msgId = 1; msgId <= MAX_MESSAGES; ++msgId) { const int id = msg_id (setId, msgId); const String got = msgs.get (cat, setId, id, def); @@ -771,16 +714,12 @@ std::sprintf (msg_name, "rwstdmessages_%d.rc", int (i)); #endif - generate_catalog (msg_name, messages); + rw_create_catalog (msg_name, catalog.c_str ()); const char* const dot = std::strrchr (msg_name, '.'); std::strncpy (catalog_names[i], msg_name, dot - msg_name); *(catalog_names[i] + (dot - msg_name)) = '\0'; -#ifdef _WIN32 - std::strcat (catalog_names[i], ".dll"); -#endif // _WIN32 - // open each catalog (expect success) cats [i] = open_catalog (msgs, catalog_names [i], loc, 0, cname, __LINE__); @@ -878,9 +817,16 @@ static int run_test (int, char*[]) { + for (int i = 0; i < MAX_SETS; ++i) { + for (int j = 0; j < MAX_MESSAGES; ++j) + catalog.append (messages [i][j], std::strlen (messages [i][j]) + 1); + + catalog.append (1, '\0'); + } + const char* const locname = find_named_locale (); - generate_catalog (MSG_NAME, messages); + rw_create_catalog (MSG_NAME, catalog.c_str ()); test_messages (char (), "char", locname);