Martin Sebor wrote: [...] > The next step will be replacing the
ctype facet with the one in rw_ctype.h.
Here's a patch replacing the Ctype class defined in the test with the new UserCtype template from rw_ctype.h. The patch is against the current sources (as opposed to the patched sources that haven't been committed yet) so I'm posting it so as to avoid collisions. Martin
Index: /build/sebor/stdcxx/tests/strings/21.string.io.cpp =================================================================== --- /build/sebor/stdcxx/tests/strings/21.string.io.cpp (revision 422553) +++ /build/sebor/stdcxx/tests/strings/21.string.io.cpp (working copy) @@ -35,6 +35,7 @@ #include <driver.h> // for rw_test() #include <rw_allocator.h> // for UserAlloc #include <rw_char.h> // for rw_expand() +#include <rw_ctype.h> // for UserCtype #include <rw_new.h> // for bad_alloc, replacement operator new #include <rw_streambuf.h> // for MyStreambuf @@ -912,89 +913,6 @@ /**************************************************************************/ -class Ctype : public std::ctype<UserChar> -{ - typedef std::ctype<UserChar> Base; - -public: - - explicit Ctype(size_t refs = 0) : Base(refs) - { - } - -protected: - - virtual bool do_is (mask mask_val, UserChar ch) const - { - return std::use_facet<std::ctype<char> >(std::locale ()).is ( - mask_val, do_narrow (ch, char ())); - } - - virtual const UserChar* do_is (const UserChar* low, - const UserChar* high, mask* vec) const - { - const size_t size = high - low; - - char * buf = new char[size]; - - do_narrow (low, high, char (), buf); - - std::use_facet<std::ctype<char> >(std::locale ()).is ( - buf, buf + size, vec); - - delete[] buf; - - return high; - } - - virtual const UserChar* do_scan_is (mask mask_val, - const UserChar* low, - const UserChar* high) const - { - for (; low != high && !do_is (mask_val, *low); ++low) ; - return low; - } - - virtual const UserChar* do_scan_not (mask mask_val, - const UserChar* low, - const UserChar* high) const - { - for (; low != high && do_is (mask_val, *low); ++low) ; - return low; - } - - virtual UserChar do_widen (char ch) const - { - return make_char (ch, _RWSTD_STATIC_CAST (UserChar *, 0)); - } - - virtual const char* do_widen (const char* low, - const char* high, UserChar* dest) const - { - for (; low != high; ++low, ++dest) - *dest = do_widen (*low); - return low; - } - - virtual char do_narrow (UserChar ch, char /*dfault*/) const - { - char c[2]; - rw_narrow (c, &ch, 1); - return c[0]; - } - - virtual const UserChar* do_narrow (const UserChar* low, - const UserChar* high, - char dfault, char* dest) const - { - for (; low != high; ++low, ++dest) - *dest = do_narrow (*low, dfault); - return low; - } -}; - -/**************************************************************************/ - template <class charT, class Traits, class Allocator> void test_io (charT*, Traits*, Allocator*, const StringTestCaseData<charT> &tdata) @@ -1028,7 +946,7 @@ // (the facet's lifetime must exceed that of the locale in // which it is installed, which might include both the stream // and the stream's streambuf) - const Ctype ctyp (1); + const UserCtype<charT> ctyp (1); // construct streambuf objects to associate with each stream Streambuf inbuf (arg, arg_len, 0, -1);