Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 68046 invoked from network); 13 Jun 2006 18:44:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Jun 2006 18:44:24 -0000 Received: (qmail 51007 invoked by uid 500); 13 Jun 2006 18:44:19 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 50953 invoked by uid 500); 13 Jun 2006 18:44:18 -0000 Mailing-List: contact stdcxx-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-commits@incubator.apache.org Received: (qmail 50885 invoked by uid 99); 13 Jun 2006 18:44:18 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 11:44:18 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 11:44:14 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 415B81A983A; Tue, 13 Jun 2006 11:43:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r413946 - in /incubator/stdcxx/trunk/tests: include/rw_char.h src/char.cpp Date: Tue, 13 Jun 2006 18:43:53 -0000 To: stdcxx-commits@incubator.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060613184354.415B81A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: sebor Date: Tue Jun 13 11:43:53 2006 New Revision: 413946 URL: http://svn.apache.org/viewvc?rev=413946&view=rev Log: 2006-06-13 Martin Sebor * rw_char.h (UserTraits): Removed the definition of the primary template and replaced it with definitions of the two required specializations (on char and wchar_t) to avoid Sun C++ 5.8 bugs described at http://issues.apache.org/jira/browse/STDCXX-177. (TraitsMemFunc): Moved from the primary template to file scope and renamed from TraitsFun. * char.cpp: Same. Modified: incubator/stdcxx/trunk/tests/include/rw_char.h incubator/stdcxx/trunk/tests/src/char.cpp Modified: incubator/stdcxx/trunk/tests/include/rw_char.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/include/rw_char.h?rev=413946&r1=413945&r2=413946&view=diff ============================================================================== --- incubator/stdcxx/trunk/tests/include/rw_char.h (original) +++ incubator/stdcxx/trunk/tests/include/rw_char.h Tue Jun 13 11:43:53 2006 @@ -172,116 +172,80 @@ }; -// user-defined character traits +// user-defined character traits template +// (declared but not defined) template -struct UserTraits: std::char_traits +struct UserTraits; + + +struct TraitsMemFunc { - typedef std::char_traits Base; - typedef typename Base::char_type char_type; - typedef typename Base::int_type int_type; - - struct MemFun { - enum { - assign, eq, lt, compare, length, find, copy, move, - assign2, not_eof, to_char_type, to_int_type, eq_int_type, - eof, - n_funs - }; + enum { + assign, eq, lt, compare, length, find, copy, move, + assign2, not_eof, to_char_type, to_int_type, eq_int_type, + eof, + n_funs }; +}; - static _RWSTD_SIZE_T n_calls_ [MemFun::n_funs]; + +// required specialization on char +_RWSTD_SPECIALIZED_CLASS +struct _TEST_EXPORT UserTraits: std::char_traits +{ + typedef std::char_traits Base; + typedef Base::char_type char_type; + typedef Base::int_type int_type; + typedef TraitsMemFunc MemFun; // avoid any dependency on the library typedef int off_type; // std::streamoff typedef int state_type; // std::mbstate_t typedef std::fpos pos_type; // std::fpos - // accesses to the char_type::f member may trigger a SIGBUS - // on some architectures (e.g., PA or SPARC) if the member - // isn't appropriately aligned - static void - assign (char_type &dst, const char_type &src) { - ++n_calls_ [MemFun::assign]; - Base::assign (dst, src); - } - - static bool - eq (const char_type &ch1, const char_type &ch2) { - ++n_calls_ [MemFun::eq]; - return Base::eq (ch1, ch2); - } - - static bool - lt (const char_type &ch1, const char_type &ch2) { - ++n_calls_ [MemFun::lt]; - return Base::lt (ch1, ch2); - } + assign (char_type&, const char_type&); + + static bool + eq (const char_type&, const char_type&); + + static bool + lt (const char_type&, const char_type&); static int - compare (const char_type *s1, const char_type *s2, _RWSTD_SIZE_T n) { - ++n_calls_ [MemFun::compare]; - return Base::compare (s1, s2, n); - } + compare (const char_type*, const char_type*, _RWSTD_SIZE_T); static _RWSTD_SIZE_T - length (const char_type *s) { - ++n_calls_ [MemFun::length]; - return Base::length (s); - } + length (const char_type*); static const char_type* - find (const char_type *s, _RWSTD_SIZE_T n, const char_type &ch) { - ++n_calls_ [MemFun::find]; - return Base::find (s, n, ch); - } + find (const char_type*, _RWSTD_SIZE_T, const char_type&); static char_type* - copy (char_type *dst, const char_type *src, _RWSTD_SIZE_T n) { - ++n_calls_ [MemFun::copy]; - return Base::copy (dst, src, n); - } + copy (char_type*, const char_type*, _RWSTD_SIZE_T); static char_type* - move (char_type *dst, const char_type *src, _RWSTD_SIZE_T n) { - ++n_calls_ [MemFun::move]; - return Base::move (dst, src, n); - } + move (char_type*, const char_type*, _RWSTD_SIZE_T); static char_type* - assign (char_type *s, _RWSTD_SIZE_T n, char_type ch) { - ++n_calls_ [MemFun::assign]; - return Base::assign (s, n, ch); - } + assign (char_type*, _RWSTD_SIZE_T, char_type); static int_type - not_eof (const int_type &i) { - ++n_calls_ [MemFun::not_eof]; - return eof () == i ? ~i : i; - } + not_eof (const int_type&); static char_type - to_char_type (const int_type &i) { - ++n_calls_ [MemFun::to_char_type]; - return Base::to_char_type (i); - } + to_char_type (const int_type&); static int_type - to_int_type (const char_type &ch) { - ++n_calls_ [MemFun::to_int_type]; - return Base::to_int_type (ch); - } + to_int_type (const char_type&); static bool - eq_int_type (const int_type &i1, const int_type &i2) { - ++n_calls_ [MemFun::eq_int_type]; - return Base::eq_int_type (i1, i2); - } + eq_int_type (const int_type&, const int_type&); static int_type - eof () { - return eof_; - } + eof (); + + static _RWSTD_SIZE_T n_calls_ []; static int_type eof_; @@ -294,28 +258,83 @@ }; -template -_RWSTD_SIZE_T -UserTraits::n_calls_ [ /* UserTraits::MemFun::n_funs */]; +#ifndef _RWSTD_NO_WCHAR_T -template -typename UserTraits::int_type -UserTraits::eof_ = std::char_traits::eof (); +// required specialization on wchar_t +_RWSTD_SPECIALIZED_CLASS +struct _TEST_EXPORT UserTraits: std::char_traits +{ + typedef std::char_traits Base; + typedef Base::char_type char_type; + typedef Base::int_type int_type; + typedef TraitsMemFunc MemFun; + + // avoid any dependency on the library + typedef int off_type; // std::streamoff + typedef int state_type; // std::mbstate_t + typedef std::fpos pos_type; // std::fpos + + static void + assign (char_type&, const char_type&); + + static bool + eq (const char_type&, const char_type&); + + static bool + lt (const char_type&, const char_type&); + + static int + compare (const char_type*, const char_type*, _RWSTD_SIZE_T); + + static _RWSTD_SIZE_T + length (const char_type*); + + static const char_type* + find (const char_type*, _RWSTD_SIZE_T, const char_type&); + + static char_type* + copy (char_type*, const char_type*, _RWSTD_SIZE_T); + + static char_type* + move (char_type*, const char_type*, _RWSTD_SIZE_T); + + static char_type* + assign (char_type*, _RWSTD_SIZE_T, char_type); + + static int_type + not_eof (const int_type&); + + static char_type + to_char_type (const int_type&); + + static int_type + to_int_type (const char_type&); + + static bool + eq_int_type (const int_type&, const int_type&); + + static int_type + eof (); + + static _RWSTD_SIZE_T n_calls_ []; + + static int_type eof_; + +private: + + // not defined to detect bad assumptions made by the library + UserTraits (); + ~UserTraits (); + void operator= (UserTraits&); +}; + +#endif // _RWSTD_NO_WCHAR_T _RWSTD_SPECIALIZED_CLASS struct _TEST_EXPORT UserTraits // user-defined character traits { - struct MemFun { - enum { - assign, eq, lt, compare, length, find, copy, move, - assign2, not_eof, to_char_type, to_int_type, eq_int_type, - eof, - n_funs - }; - }; - - static _RWSTD_SIZE_T n_calls_ []; + typedef TraitsMemFunc MemFun; typedef UserChar char_type; typedef UserInt int_type; @@ -361,6 +380,8 @@ static bool eq_int_type (const int_type&, const int_type&); static int_type eof (); + + static _RWSTD_SIZE_T n_calls_ []; private: Modified: incubator/stdcxx/trunk/tests/src/char.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/char.cpp?rev=413946&r1=413945&r2=413946&view=diff ============================================================================== --- incubator/stdcxx/trunk/tests/src/char.cpp (original) +++ incubator/stdcxx/trunk/tests/src/char.cpp Tue Jun 13 11:43:53 2006 @@ -41,6 +41,266 @@ typedef unsigned char UChar; +void UserTraits:: +assign (char_type &dst, const char_type &src) +{ + ++n_calls_ [MemFun::assign]; + Base::assign (dst, src); +} + + +bool UserTraits:: +eq (const char_type &ch1, const char_type &ch2) +{ + ++n_calls_ [MemFun::eq]; + return Base::eq (ch1, ch2); +} + + +bool UserTraits:: +lt (const char_type &ch1, const char_type &ch2) +{ + ++n_calls_ [MemFun::lt]; + return Base::lt (ch1, ch2); +} + + +int UserTraits:: +compare (const char_type *s1, const char_type *s2, size_t n) +{ + ++n_calls_ [MemFun::compare]; + return Base::compare (s1, s2, n); +} + + +size_t UserTraits:: +length (const char_type *s) +{ + ++n_calls_ [MemFun::length]; + return Base::length (s); +} + + +const UserTraits::char_type* +UserTraits:: +find (const char_type *s, size_t n, const char_type &ch) +{ + ++n_calls_ [MemFun::find]; + return Base::find (s, n, ch); +} + + +UserTraits::char_type* +UserTraits:: +copy (char_type *dst, const char_type *src, size_t n) +{ + ++n_calls_ [MemFun::copy]; + return Base::copy (dst, src, n); +} + + +UserTraits::char_type* +UserTraits:: +move (char_type *dst, const char_type *src, size_t n) +{ + ++n_calls_ [MemFun::move]; + return Base::move (dst, src, n); +} + + +UserTraits::char_type* +UserTraits:: +assign (char_type *s, size_t n, char_type ch) +{ + ++n_calls_ [MemFun::assign]; + return Base::assign (s, n, ch); +} + + +UserTraits::int_type +UserTraits:: +not_eof (const int_type &i) +{ + ++n_calls_ [MemFun::not_eof]; + return eof () == i ? ~i : i; +} + + +UserTraits::char_type +UserTraits:: +to_char_type (const int_type &i) +{ + ++n_calls_ [MemFun::to_char_type]; + return Base::to_char_type (i); +} + + +UserTraits::int_type +UserTraits:: +to_int_type (const char_type &ch) +{ + ++n_calls_ [MemFun::to_int_type]; + return Base::to_int_type (ch); +} + + +bool UserTraits:: +eq_int_type (const int_type &i1, const int_type &i2) +{ + ++n_calls_ [MemFun::eq_int_type]; + return Base::eq_int_type (i1, i2); +} + + +UserTraits::int_type +UserTraits:: +eof () +{ + return eof_; +} + + +size_t UserTraits:: +n_calls_ [UserTraits::MemFun::n_funs]; + + +UserTraits::int_type +UserTraits:: +eof_ = std::char_traits::eof (); + + +#ifndef _RWSTD_NO_WCHAR_T + +void UserTraits:: +assign (char_type &dst, const char_type &src) +{ + ++n_calls_ [MemFun::assign]; + Base::assign (dst, src); +} + + +bool UserTraits:: +eq (const char_type &ch1, const char_type &ch2) +{ + ++n_calls_ [MemFun::eq]; + return Base::eq (ch1, ch2); +} + + +bool UserTraits:: +lt (const char_type &ch1, const char_type &ch2) +{ + ++n_calls_ [MemFun::lt]; + return Base::lt (ch1, ch2); +} + + +int UserTraits:: +compare (const char_type *s1, const char_type *s2, size_t n) +{ + ++n_calls_ [MemFun::compare]; + return Base::compare (s1, s2, n); +} + + +size_t UserTraits:: +length (const char_type *s) +{ + ++n_calls_ [MemFun::length]; + return Base::length (s); +} + + +const UserTraits::char_type* +UserTraits:: +find (const char_type *s, size_t n, const char_type &ch) +{ + ++n_calls_ [MemFun::find]; + return Base::find (s, n, ch); +} + + +UserTraits::char_type* +UserTraits:: +copy (char_type *dst, const char_type *src, size_t n) +{ + ++n_calls_ [MemFun::copy]; + return Base::copy (dst, src, n); +} + + +UserTraits::char_type* +UserTraits:: +move (char_type *dst, const char_type *src, size_t n) +{ + ++n_calls_ [MemFun::move]; + return Base::move (dst, src, n); +} + + +UserTraits::char_type* +UserTraits:: +assign (char_type *s, size_t n, char_type ch) +{ + ++n_calls_ [MemFun::assign]; + return Base::assign (s, n, ch); +} + + +UserTraits::int_type +UserTraits:: +not_eof (const int_type &i) +{ + ++n_calls_ [MemFun::not_eof]; + return eof () == i ? ~i : i; +} + + +UserTraits::char_type +UserTraits:: +to_char_type (const int_type &i) +{ + ++n_calls_ [MemFun::to_char_type]; + return Base::to_char_type (i); +} + + +UserTraits::int_type +UserTraits:: +to_int_type (const char_type &ch) +{ + ++n_calls_ [MemFun::to_int_type]; + return Base::to_int_type (ch); +} + + +bool UserTraits:: +eq_int_type (const int_type &i1, const int_type &i2) +{ + ++n_calls_ [MemFun::eq_int_type]; + return Base::eq_int_type (i1, i2); +} + + +UserTraits::int_type +UserTraits:: +eof () +{ + return eof_; +} + + +size_t UserTraits:: +n_calls_ [UserTraits::MemFun::n_funs]; + + +UserTraits::int_type +UserTraits:: +eof_ = std::char_traits::eof (); + +#endif // _RWSTD_NO_WCHAR_T + + size_t UserTraits:: n_calls_ [UserTraits::MemFun::n_funs];