From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17963 invoked by alias); 7 Mar 2003 19:56:00 -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 17949 invoked by uid 71); 7 Mar 2003 19:56:00 -0000 Date: Fri, 07 Mar 2003 19:56:00 -0000 Message-ID: <20030307195600.17948.qmail@sources.redhat.com> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Nathan Myers Subject: Re: libstdc++/9424: i/ostream::operator>>/<<(streambuf*) drops characters Reply-To: Nathan Myers X-SW-Source: 2003-03/txt/msg00366.txt.bz2 List-Id: The following reply was made to PR libstdc++/9424; it has been noted by GNATS. From: Nathan Myers To: libstdc++@gcc.gnu.org Cc: gcc-gnats@gcc.gnu.org Subject: Re: libstdc++/9424: i/ostream::operator>>/<<(streambuf*) drops characters Date: Fri, 7 Mar 2003 11:50:55 -0800 On Wed, Feb 26, 2003 at 09:27:32AM -0000, P?tur Run?lfsson wrote: > I believe the relevant quote is in 27.6.2.5.3 p7, bullet 2: > > inserting in the output sequence fails (in which case the > character to be inserted is not extracted); > > So correct code is "as if": > > int_type c = sbin->sgetc(); > while (c != traits_type::eof()) > { > if (sbout->sputc(c) == traits_type::eof()) > break; > c = sbin->snextc(); > } > > Of course, it should be OK to call sgetn if the function *knows* > that sputc won't fail (for example if epptr() - pptr() is big > enough). I wonder if this wouldn't be better implemented using sbumpc: > int_type c; > while ((c = sbin->sbumpc()) != traits_type::eof() && > (sbout->sputc(c) != traits_type::eof()) > {} I seem to recall that sbumpc() can be implemented more efficiently than snextc, although it's just possible I was smoking crack. Nathan Myers ncm-nospam@cantrip.org