+2003-01-05 Paolo Carlini <pcarlini@unitus.it>
+
+ PR libstdc++/9168
+ * src/codecvt.cc
+ (codecvt<char, char, mbstate_t>::do_in, do_out):
+ Implement the resolution of DR19 (TC).
+ * testsuite/22_locale/codecvt_members_char_char.cc
+ (test01): Tweak.
+
2003-01-02 Jason Merrill <jason@redhat.com>
* config/cpu/i486/atomicity.h (__exchange_and_add, __atomic_add):
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{
- size_t __len = std::min(__from_end - __from, __to_end - __to);
- memcpy(__to, __from, __len);
+ // _GLIBCPP_RESOLVE_LIB_DEFECTS
+ // According to the resolution of DR19, "If returns noconv [...]
+ // there are no changes to the values in [to, to_limit)."
__from_next = __from;
__to_next = __to;
return noconv;
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
- {
- size_t __len = std::min(__from_end - __from, __to_end - __to);
- memcpy(__to, __from, __len);
+ {
+ // _GLIBCPP_RESOLVE_LIB_DEFECTS
+ // According to the resolution of DR19, "If returns noconv [...]
+ // there are no changes to the values in [to, to_limit)."
__from_next = __from;
__to_next = __to;
return noconv;
const char* from_next;
int size = 25;
char* c_arr = new char[size];
+ char* c_ref = new char[size];
char* to_next;
locale loc;
c_codecvt::state_type state;
const c_codecvt* cvt = &use_facet<c_codecvt>(loc);
+ // According to the resolution of DR19 (see also libstd++/9168), in
+ // case of degenerate conversion ('noconv'), "there are no changes to
+ // the values in [to, to_limit)."
+ memset(c_ref, 'X', size);
+
// in
+ memset(c_arr, 'X', size);
result r1 = cvt->in(state, c_lit, c_lit + size, from_next,
c_arr, c_arr + size, to_next);
VERIFY( r1 == codecvt_base::noconv );
- VERIFY( !strcmp(c_arr, c_lit) );
+ VERIFY( !memcmp(c_arr, c_ref, size) );
VERIFY( from_next == c_lit );
VERIFY( to_next == c_arr );
// out
+ memset(c_arr, 'X', size);
result r2 = cvt->out(state, c_lit, c_lit + size, from_next,
c_arr, c_arr + size, to_next);
VERIFY( r2 == codecvt_base::noconv );
- VERIFY( !strcmp(c_arr, c_lit) );
+ VERIFY( !memcmp(c_arr, c_ref, size) );
VERIFY( from_next == c_lit );
VERIFY( to_next == c_arr );
VERIFY( k == 1 );
delete [] c_arr;
+ delete [] c_ref;
}
// libstdc++/5280