stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Pevtsov" <Ant...@moscow.vdiweb.com>
Subject RE: test for lib.string.io
Date Thu, 29 Jun 2006 15:53:02 GMT
The updated 21.string.io test with required changes to the test driver
is here:
http://people.apache.org/~antonp/stdcxx06292006/

Martin, another question to your changes. There are the following code
(_ioinsert.cc, line 180):

            else {
                __err = _STD::ios_base::badbit;

#ifndef _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
                __strm.width (0);   // reset width only on success
#endif   // _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
            }

But it looks like here should be something like this:

            else {
                __err = _STD::ios_base::badbit;

#ifdef _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
                __strm.width (0);   // reset width unconditionally
#endif   // _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
            }

If I have not missed something...


Thanks,
Anton Pevtsov


-----Original Message-----
From: Martin Sebor [mailto:sebor@roguewave.com] 
Sent: Tuesday, June 28, 2006 04:13
To: stdcxx-dev@incubator.apache.org
Subject: Re: test for lib.string.io


Anton Pevtsov wrote:
> Martin, the changes look goog, but I have a question about 
> __rw_insert:
> 
> When macro _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE is defined the width(0)

> will be called only if __pad > 0. But pad can be <= 0 when len >= 
> width.

I see what you mean. This must pass:

   #include <cassert>
   #include <sstream>

   int main ()
   {
       std::ostringstream strm;
       strm.width (-1);
       strm << ' ';
       assert (0 == strm.width ());
   }

> 
> I propose to add '.' after "if (len < width)" to the comment:

Sounds good.

> 
[...]
> Also it may be useful to remove lines:
[...]
> and append these lines:
[...]
> What do you think about this?

Good catch, thanks! The changes you suggest are in the attached patch.

Btw., it was pointed out to me that the width test was still subtly
wrong WRT the currently mandated behavior for single character
inserters: they are specified to reset width before inserting any
characters. I fixed this bug in the test but I haven't yet fixed it in
the library. Since the single char inserters are implemented using the
same function as the array forms and since the array forms are supposed
to call width(0) after they're done inserting the fix would require
either adding a new overload of __rw_insert for the single-char
inserters or adding an argument to the array overload of __rw_insert()
as you suggested yesterday. I haven't decided which we should go with or
even if it's worth the trouble. I'm beginning to think that we might
just go with the proposed behavior and forget about strict conformance
here since the latter is inconsistent and would be a hassle to
implement.

Martin



-----Original Message-----
From: Anton Pevtsov [mailto:AntonP@moscow.vdiweb.com] 
Sent: Tuesday, June 27, 2006 19:44
To: stdcxx-dev@incubator.apache.org
Subject: RE: test for lib.string.io


Martin, the changes look goog, but I have a question about __rw_insert:

When macro _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE is defined the width(0)
will be called only if __pad > 0. But pad can be <= 0 when len >= width.

I propose to add '.' after "if (len < width)" to the comment:

-------------------
    // writes out max(len, width) characters, padding appropriately
    // (with the fill character) if (len < width)
    // calls width(0) if and only if the write has been successful
    // (i.e., will leave it unchanged if sputn fails or throws an
    // exception)
-------------------

because this comment may be treated as "if (len < width) calls width(0)
...".

Also it may be useful to remove lines:

-------------------
#else   // if defined (_RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE)
                __strm.width (0);   // reset width unconditionally
-------------------

and append these lines:

-------------------
#ifdef _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE
            __strm.width (0);   // reset width unconditionally
#endif   // _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE 
-------------------

right after:

-------------------
            else
                __err = _STD::ios_base::badbit;#ifdef 
-------------------

What do you think about this?


Thanks,
Anton Pevtsov


-----Original Message-----
From: Martin Sebor [mailto:sebor@roguewave.com] 
Sent: Tuesday, June 27, 2006 04:13
To: stdcxx-dev@incubator.apache.org
Subject: Re: test for lib.string.io


Anton Pevtsov wrote:
[...]
> The possible fix of the STDCXX-206 and STDCXX-205 is here 
> http://people.apache.org/~antonp/stdcxx06262006/lib/
> It required changes in several places:
[...]
> What do you think about this?

I'm still thinking about what the best way to deal with it is and
discussing it with others. I made similar changes last week and
implemented the proposed resolution I mentioned previously. I tested
them with an updated version of the width test (the original contained a
number of bugs that I fixed last Friday):
http://people.apache.org/~sebor/width_test.cpp

The changes are attached for your review. The new behavior is guarded by
the _RWSTD_NO_EXT_KEEP_WIDTH_ON_FAILURE macro. Defining the macro
disables the new behavior and enables the behavior required by the
current standard (except for the boolalpha part which is just a silly
mistake in the standard).

Martin

Mime
View raw message