stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r418410 - in /incubator/stdcxx/trunk/include: streambuf streambuf.cc
Date Fri, 30 Jun 2006 22:57:02 GMT
Author: sebor
Date: Fri Jun 30 15:57:01 2006
New Revision: 418410

URL: http://svn.apache.org/viewvc?rev=418410&view=rev
Log:
2006-06-30  Martin Sebor  <sebor@roguewave.com>

	STDCXX-251
	* streambuf (uflow): Outlined and moved...
	* streambuf.cc (uflow): ...to here. Prevented undefined behavior
	caused by dereferencing gptr() when underflow() doesn't set up
	a non-empty pending sequence (i.e., when gptr() == 0 or when
	gptr() == egptr()).

Modified:
    incubator/stdcxx/trunk/include/streambuf
    incubator/stdcxx/trunk/include/streambuf.cc

Modified: incubator/stdcxx/trunk/include/streambuf
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/streambuf?rev=418410&r1=418409&r2=418410&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/streambuf (original)
+++ incubator/stdcxx/trunk/include/streambuf Fri Jun 30 15:57:01 2006
@@ -422,22 +422,6 @@
 template<class _CharT, class _Traits>
 inline _TYPENAME basic_streambuf<_CharT, _Traits>::int_type
 basic_streambuf<_CharT, _Traits>::
-uflow ()
-{
-    _RWSTD_ASSERT (_C_is_valid ());
-
-    if (_C_is_eof (underflow ()))
-        return traits_type::eof ();
-
-    _RWSTD_ASSERT (0 != _C_gptr);
-
-    return traits_type::to_int_type (*_C_gptr++);
-}
-
-
-template<class _CharT, class _Traits>
-inline _TYPENAME basic_streambuf<_CharT, _Traits>::int_type
-basic_streambuf<_CharT, _Traits>::
 sbumpc ()
 {
     _RWSTD_ASSERT (_C_is_valid ());

Modified: incubator/stdcxx/trunk/include/streambuf.cc
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/streambuf.cc?rev=418410&r1=418409&r2=418410&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/streambuf.cc (original)
+++ incubator/stdcxx/trunk/include/streambuf.cc Fri Jun 30 15:57:01 2006
@@ -7,16 +7,22 @@
  *
  ***************************************************************************
  *
- * 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.
+ * Copyright 2006 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Copyright 1994-2006 Rogue Wave Software.
+ *
+ * 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.
  * 
  **************************************************************************/
 
@@ -38,6 +44,26 @@
     _C_epptr (0)
 {
     // no op
+}
+
+
+template <class _CharT, class _Traits>
+_TYPENAME basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::
+uflow ()
+{
+    _RWSTD_ASSERT (_C_is_valid ());
+
+    const int_type __c = underflow ();
+
+    if (traits_type::eq_int_type (__c, traits_type::eof ()))
+        return traits_type::eof ();
+
+    // handle unbuffered input mode
+    if (_C_gptr < _C_egptr)
+        return traits_type::to_int_type (*_C_gptr++);
+
+    return __c;
 }
 
 



Mime
View raw message