Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 75590 invoked from network); 6 Feb 2007 02:28:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Feb 2007 02:28:15 -0000 Received: (qmail 20251 invoked by uid 500); 6 Feb 2007 02:28:22 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 20230 invoked by uid 500); 6 Feb 2007 02:28:22 -0000 Mailing-List: contact stdcxx-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-commits@incubator.apache.org Received: (qmail 20219 invoked by uid 99); 6 Feb 2007 02:28:22 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Feb 2007 18:28:22 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Feb 2007 18:28:14 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 561F91A981A; Mon, 5 Feb 2007 18:27:54 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r503960 - /incubator/stdcxx/trunk/include/istream.cc Date: Tue, 06 Feb 2007 02:27:54 -0000 To: stdcxx-commits@incubator.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070206022754.561F91A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sebor Date: Mon Feb 5 18:27:53 2007 New Revision: 503960 URL: http://svn.apache.org/viewvc?view=rev&rev=503960 Log: 2007-02-05 Martin Sebor STDCXX-230 STDCXX-329 * istream.cc (__rw_extract): Added comment. (_C_ipfx): Avoided resetting gcount(). (_C_ipfx): Guarded body in a try/catch block and set badbit when an exception occurs. [_RWSTD_NO_OPTIMIZE_SPEED](_C_ipfx): Removed conditionally compiled block (and instead used the "optimized" branch unconditionally). (_C_get, read, readsome, get, getline, operator>>): Explicitly reset gcount. Modified: incubator/stdcxx/trunk/include/istream.cc Modified: incubator/stdcxx/trunk/include/istream.cc URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/istream.cc?view=diff&rev=503960&r1=503959&r2=503960 ============================================================================== --- incubator/stdcxx/trunk/include/istream.cc (original) +++ incubator/stdcxx/trunk/include/istream.cc Mon Feb 5 18:27:53 2007 @@ -1,21 +1,28 @@ /*************************************************************************** * - * istream.cc - istream definitions + * istream.cc - definitions of basic_istream members * * $Id$ * *************************************************************************** * - * Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave - * Software division. Licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0. Unless required by - * applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - * CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under - * the License. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + * + * Copyright 1994-2006 Rogue Wave Software. * **************************************************************************/ @@ -36,7 +43,7 @@ _STD::ios_base::iostate __err = _STD::ios_base::goodbit; - // eat leading whitespace + // eat leading whitespace, catching exceptions from sentry const _TYPENAME _STD::basic_istream<_CharT, _Traits>::sentry __ipfx (__strm /* , noskipws = false */); @@ -72,10 +79,14 @@ // called after any failed extraction (even formatted) reports 0 // and always count _all_ extracted characters - _C_gcount = 0; + if (ios_base::goodbit != this->rdstate ()) { + this->setstate (ios_base::failbit); + return *this; + } - if (ios_base::goodbit == this->rdstate ()) { + ios_base::iostate __state = ios_base::goodbit; + _TRY { if (this->tie ()) this->tie ()->flush (); @@ -92,8 +103,6 @@ const ctype &__ctp = _USE_FACET (ctype, this->getloc ()); -#ifndef _RWSTD_NO_OPTIMIZE_SPEED - for ( ; ; ) { const char_type* const __gptr = __rdbuf->gptr (); @@ -106,8 +115,6 @@ __ctp.scan_not (__ctp.space, __gptr, __egptr) - __gptr; - _C_gcount += __nskip; - __rdbuf->gbump (__nskip); if (__nskip < __egptr - __gptr) @@ -118,7 +125,7 @@ const int_type __c (__rdbuf->sgetc ()); if (traits_type::eq_int_type (__c, traits_type::eof ())) { - this->setstate (__errbits); + __state = __errbits; break; } @@ -127,40 +134,16 @@ break; __rdbuf->sbumpc (); - - // increment gcount only _after_ sbumpc() but _before_ - // the subsequent call to sgetc() to correctly reflect - // the number of extracted characters in the presence - // of exceptions thrown from streambuf virtuals - ++_C_gcount; - } - } - -#else // if defined (_RWSTD_NO_OPTIMIZE_SPEED) - - // increment gcount only _after_ sbumpc() but _before_ - // the subsequent call to sgetc() to correctly reflect - // the number of extracted characters in the presence - // of exceptions thrown from streambuf virtuals - for (; ; __rdbuf->sbumpc (), ++_C_gcount) { - - const int_type __c (__rdbuf->sgetc ()); - - if (traits_type::eq_int_type (__c, traits_type::eof ())) { - this->setstate (__errbits); - break; } - - if (!__ctp.is (__ctp.space, traits_type::to_char_type (__c))) - break; } - -#endif // _RWSTD_NO_OPTIMIZE_SPEED - } } - else if (!__noskipws) - this->setstate (ios_base::failbit); + _CATCH (...) { + this->setstate (ios_base::badbit | _RW::__rw_rethrow); + } + + if (__state) + this->setstate (__state); return *this; } @@ -228,7 +211,9 @@ const sentry __ipfx (*this, true /* noskipws */); - if (__ipfx) { + if (__ipfx) { + + _C_gcount = 0; _TRY { for ( ; ; ) { @@ -317,6 +302,8 @@ // 27.6.1.2.1, p1 and 27.6.1.3, p1: proceed iff sentry is okay if (__ipfx) { + _C_gcount = 0; + // read at most n - 1 characters when null-terminating while (__n) { @@ -386,6 +373,8 @@ // 27.6.1.2.1, p1 and 27.6.1.3, p1: proceed iff sentry is okay if (__ipfx) { + _C_gcount = 0; + streamsize __nread = 0; _TRY { @@ -419,6 +408,8 @@ if (__ipfx) { + _C_gcount = 0; + streamsize __nread = 0; _TRY { @@ -577,6 +568,8 @@ if (__ipfx) { + _C_gcount = 0; + _TRY { basic_streambuf* const __rdbuf = @@ -678,6 +671,8 @@ ios_base::iostate __err = ios_base::goodbit; if (__ipfx) { + + _C_gcount = 0; basic_streambuf* const __rdbuf = this->rdbuf ();