From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20451 invoked by alias); 3 Mar 2003 18:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 20437 invoked by uid 71); 3 Mar 2003 18:46:01 -0000 Date: Mon, 03 Mar 2003 18:46:00 -0000 Message-ID: <20030303184601.20434.qmail@sources.redhat.com> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= Subject: RE: libstdc++/9875: filebuf doesn't handle codecvt::encoding() > 1 Reply-To: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= X-SW-Source: 2003-03/txt/msg00106.txt.bz2 List-Id: The following reply was made to PR libstdc++/9875; it has been noted by GNATS. From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= To: "Paolo Carlini" Cc: , , Subject: RE: libstdc++/9875: filebuf doesn't handle codecvt::encoding() > 1 Date: Mon, 3 Mar 2003 18:38:27 -0000 > >> The underflow bits are still missing, however. Are you > >> willing to provide some tests for it too? > >> =20 > >> > >Will do. > > > Thanks P=E9tur. > By the way, I would appreciate also some actual ;) tests for=20 > overflow,=20 > since those > present in the PR didn't really lead to overflow for the default 8192=20 > chars wide buffer. > (temporarily I have added some using setbuf to shorten the buffer) These are a bit hairy, but that is by design. The seekoff in _M_really_overflow is only called when _M_filepos !=3D _M_out_beg which only happens when switching modes, and the seekoff in _M_underflow_common only happens when _M_in_cur !=3D _M_filepos, which never happens when underflow is called from any public members of streambuf or filebuf. Petur void test4() { using namespace std; // overflow locale loc (locale::classic(), new Cvt); wfilebuf fb1; fb1.pubimbue(loc); fb1.open("tmp", ios_base::out | ios_base::trunc); fb1.sputn(L"0123456789", 10); fb1.close(); wfilebuf fb2; fb2.pubimbue(loc); fb2.open("tmp", ios_base::in | ios_base::out); fb2.sgetc(); =09 int written =3D 0; for (int i =3D 0; i < BUFSIZ; ++i) written +=3D fb2.sputn(L"abc", 3); fb2.close(); wfilebuf fb3; fb3.pubimbue(loc); fb3.open("tmp", ios_base::in); for (int j =3D 0; j < BUFSIZ; ++j) { wchar_t buf[] =3D L"xxx\n"; int n =3D fb3.sgetn(buf, 3); assert(n =3D=3D 3); fputws(buf, stderr); assert(!wmemcmp(buf, L"abc", 3)); } =09 fb3.close(); } class Buf : public std::wfilebuf { public: int_type pub_underflow() { return underflow(); } }; void test5() { using namespace std; // underflow const wchar_t* strlit =3D L"0123456789"; locale loc (locale::classic(), new Cvt); wfilebuf fb1; fb1.pubimbue(loc); fb1.open("tmp", ios_base::out | ios_base::trunc); fb1.sputn(strlit, 10); fb1.close(); Buf fb2; fb2.pubimbue(loc); fb2.open("tmp", ios_base::in); for (int i =3D 0; i < 10; ++i) { assert(fb2.pub_underflow() =3D=3D strlit[i]); fb2.sbumpc(); } fb2.close(); }