public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: "Pétur Runólfsson" <peturr02@ru.is> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: RE: libstdc++/9875: filebuf doesn't handle codecvt::encoding() > 1 Date: Mon, 03 Mar 2003 18:46:00 -0000 [thread overview] Message-ID: <20030303184601.20434.qmail@sources.redhat.com> (raw) The following reply was made to PR libstdc++/9875; it has been noted by GNATS. From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is> To: "Paolo Carlini" <pcarlini@unitus.it> Cc: <paolo@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org> 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(); }
next reply other threads:[~2003-03-03 18:46 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-03-03 18:46 Pétur Runólfsson [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-03-03 11:06 Paolo Carlini 2003-03-03 10:56 Pétur Runólfsson 2003-03-01 10:44 paolo 2003-02-28 22:55 paolo 2003-02-27 10:36 peturr02
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20030303184601.20434.qmail@sources.redhat.com \ --to=peturr02@ru.is \ --cc=gcc-prs@gcc.gnu.org \ --cc=paolo@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).