stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r442675 - in /incubator/stdcxx/trunk: include/sstream.cc tests/iostream/27.stringbuf.virtuals.cpp
Date Tue, 12 Sep 2006 19:03:36 GMT
Author: sebor
Date: Tue Sep 12 12:03:36 2006
New Revision: 442675

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

	* sstream.cc (str): Avoided setting (pptr() == epptr()) except in
	input mode as required (see lwg issue 562 for clarification). See
	also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29035.
	* stringbuf_virtuals.cpp (test_seekoff): Corrected tests exercising
	seeking on objects constructed in out mode so as not to assume that
	(pptr() == epptr()) holds after the construction of the stream (in
	fact, (pptr() == pbase()) is required to hold -- see lwg issue 562
	and this issue http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29035
	for more detail).

Modified:
    incubator/stdcxx/trunk/include/sstream.cc
    incubator/stdcxx/trunk/tests/iostream/27.stringbuf.virtuals.cpp

Modified: incubator/stdcxx/trunk/include/sstream.cc
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/sstream.cc?view=diff&rev=442675&r1=442674&r2=442675
==============================================================================
--- incubator/stdcxx/trunk/include/sstream.cc (original)
+++ incubator/stdcxx/trunk/include/sstream.cc Tue Sep 12 12:03:36 2006
@@ -6,22 +6,23 @@
  *
  ***************************************************************************
  *
- * Copyright 2006 The Apache Software Foundation or its licensors,
- * as applicable.
+ * 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
  *
- * 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
+ * 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.
+ * 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.
  *
  **************************************************************************/
 
@@ -111,7 +112,7 @@
 
         __buf = __alloc.allocate (__bufsize);
 
-        // take the ownsership of the allocated buffer
+        // take ownsership of the allocated buffer
         this->_C_own_buf (true);
     }
     else if (0 < __bufsize) {
@@ -120,7 +121,7 @@
         __bufsize = this->_C_bufsize;
     }
     else {
-        // 0 size and capacity, deallocate and reset all pointers
+        // zero size and capacity, deallocate and reset all pointers
         __buf     = 0;
         __bufsize = 0;
 
@@ -153,8 +154,12 @@
     if (this->_C_is_out ()) {
         this->setp (this->_C_buffer, this->_C_buffer + this->_C_bufsize);
 
-        if (__s != __buf || this->_C_state & (ios_base::app | ios_base::ate))
-            this->pbump (__slen);   // seek to end
+        if (   __s != __buf && this->_C_state & ios_base::in
+            || this->_C_state & (ios_base::app | ios_base::ate)) {
+            // in input or append/ate modes seek to end
+            // (see also lwg issue 562 for clarification)
+            this->pbump (__slen);
+        }
     }
 
     _RWSTD_ASSERT (this->_C_is_valid ());

Modified: incubator/stdcxx/trunk/tests/iostream/27.stringbuf.virtuals.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/iostream/27.stringbuf.virtuals.cpp?view=diff&rev=442675&r1=442674&r2=442675
==============================================================================
--- incubator/stdcxx/trunk/tests/iostream/27.stringbuf.virtuals.cpp (original)
+++ incubator/stdcxx/trunk/tests/iostream/27.stringbuf.virtuals.cpp Tue Sep 12 12:03:36 2006
@@ -6,23 +6,22 @@
  *
  ***************************************************************************
  *
- * Copyright 2006 The Apache Software Foundation or its licensors,
- * as applicable.
+ * 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
  *
- * Copyright 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
+ * 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.
- * 
+ * 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.
+ *
  **************************************************************************/
 
 #include <sstream>     // for stringbuf
@@ -1010,11 +1009,13 @@
     TEST (0,     in | out | ate, 0,  0, end, 0, NPOS, 0, 0, -1);
 
     // exercise seeking within the output sequence
-    TEST ("abc", out,            0,  0, cur, out,    3, 0, 0, MAYBE_1);
-    TEST ("abc", out,            0,  1, cur, out, NPOS, 0, 0, MAYBE_1);
-    TEST ("abc", out,            0, -1, cur, out,    2, 0, 0, MAYBE_1);
-    TEST ("abc", out,            0,  2, cur, out, NPOS, 0, 0, MAYBE_1);
-    TEST ("abc", out,            0,  3, cur, out, NPOS, 0, 0, MAYBE_1);
+    // (if (mode & in) == 0 then (pptr() == pbase()) is a postcondition
+    // of the constructor -- see also lwg issue 562)
+    TEST ("abc", out,            0,  0, cur, out,    0, 0, 0, MAYBE_1);
+    TEST ("abc", out,            0,  1, cur, out,    1, 0, 0, MAYBE_1);
+    TEST ("abc", out,            0, -1, cur, out, NPOS, 0, 0, MAYBE_1);
+    TEST ("abc", out,            0,  2, cur, out,    2, 0, 0, MAYBE_1);
+    TEST ("abc", out,            0,  3, cur, out,    3, 0, 0, MAYBE_1);
     TEST ("abc", out,            0,  4, cur, out, NPOS, 0, 0, MAYBE_1);
 
     // seek within the input sequence from the current position



Mime
View raw message