You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2007/06/08 17:30:36 UTC

svn commit: r545533 - /incubator/stdcxx/trunk/include/sstream

Author: faridz
Date: Fri Jun  8 08:30:35 2007
New Revision: 545533

URL: http://svn.apache.org/viewvc?view=rev&rev=545533
Log:
2007-06-08 Farid Zaripov <Fa...@epam.com>

	STDCXX-427
	* sstream (str): Function updated according to 27.7.1.2, p1

Modified:
    incubator/stdcxx/trunk/include/sstream

Modified: incubator/stdcxx/trunk/include/sstream
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/sstream?view=diff&rev=545533&r1=545532&r2=545533
==============================================================================
--- incubator/stdcxx/trunk/include/sstream (original)
+++ incubator/stdcxx/trunk/include/sstream Fri Jun  8 08:30:35 2007
@@ -125,9 +125,22 @@
     virtual ~basic_stringbuf ();
     
     _C_string_type str () const {
-        const _RWSTD_SIZE_T __slen = (this->egptr () < this->pptr () ?
-            this->pptr () : this->egptr ()) - this->pbase ();
-        return _C_string_type (this->_C_buffer, __slen);
+        const char_type * first_ = 0;
+        const char_type * last_ = 0;
+
+        if (this->_C_is_out ()) {
+            // in out only or in|out mode
+            first_ = this->pbase ();
+            last_ = this->egptr () < this->pptr () ?
+                this->pptr () : this->egptr ();
+        }
+        else if (this->_C_is_in ()) {
+            // in in only mode
+            first_ = this->eback ();
+            last_ = this->egptr ();
+        }
+
+        return _C_string_type (first_, last_ - first_);
     }
 
 #ifdef _RWSTD_NO_EXT_STRINGBUF_STR



RE: svn commit: r545533 - /incubator/stdcxx/trunk/include/sstream

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Friday, June 08, 2007 7:51 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r545533 - 
> /incubator/stdcxx/trunk/include/sstream
> 

[...]

> first_ and last_ are not reserved names -- names of local 
> variables in library headers (including .cc files) must be in 
> the private namespace reserved to the implementation, such 
> as, __first and __last. You might want to add the names 
> first_ and last_ to the 17.names.cpp test to help us catch 
> this mistake in the future (and I really need to fix valarray 
> so that the test compiles!)
> 
> Also, since the function has grown quite a bit it needs to be 
> moved outside of the enclosing template. It looks small 
> enough that it can stay inline (i.e., still defined in the header).

  Done: http://svn.apache.org/viewvc?view=rev&rev=546535

Farid.

Re: svn commit: r545533 - /incubator/stdcxx/trunk/include/sstream

Posted by Martin Sebor <se...@roguewave.com>.
faridz@apache.org wrote:
> Author: faridz
> Date: Fri Jun  8 08:30:35 2007
> New Revision: 545533
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=545533
> Log:
> 2007-06-08 Farid Zaripov <Fa...@epam.com>
> 
> 	STDCXX-427
> 	* sstream (str): Function updated according to 27.7.1.2, p1
> 
> Modified:
>     incubator/stdcxx/trunk/include/sstream
> 
> Modified: incubator/stdcxx/trunk/include/sstream
> URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/sstream?view=diff&rev=545533&r1=545532&r2=545533
> ==============================================================================
> --- incubator/stdcxx/trunk/include/sstream (original)
> +++ incubator/stdcxx/trunk/include/sstream Fri Jun  8 08:30:35 2007
> @@ -125,9 +125,22 @@
>      virtual ~basic_stringbuf ();
>      
>      _C_string_type str () const {
> -        const _RWSTD_SIZE_T __slen = (this->egptr () < this->pptr () ?
> -            this->pptr () : this->egptr ()) - this->pbase ();
> -        return _C_string_type (this->_C_buffer, __slen);
> +        const char_type * first_ = 0;
> +        const char_type * last_ = 0;

first_ and last_ are not reserved names -- names of local variables
in library headers (including .cc files) must be in the private
namespace reserved to the implementation, such as, __first and
__last. You might want to add the names first_ and last_ to the
17.names.cpp test to help us catch this mistake in the future
(and I really need to fix valarray so that the test compiles!)

Also, since the function has grown quite a bit it needs to be moved
outside of the enclosing template. It looks small enough that it
can stay inline (i.e., still defined in the header).

Martin

> +
> +        if (this->_C_is_out ()) {
> +            // in out only or in|out mode
> +            first_ = this->pbase ();
> +            last_ = this->egptr () < this->pptr () ?
> +                this->pptr () : this->egptr ();
> +        }
> +        else if (this->_C_is_in ()) {
> +            // in in only mode
> +            first_ = this->eback ();
> +            last_ = this->egptr ();
> +        }
> +
> +        return _C_string_type (first_, last_ - first_);
>      }
>  
>  #ifdef _RWSTD_NO_EXT_STRINGBUF_STR
> 
>