stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: svn commit: r387687 - in /incubator/stdcxx/trunk/tests: include/rw_char.h self/0.char.cpp src/char.cpp
Date Wed, 22 Mar 2006 15:53:47 GMT
Anton Pevtsov wrote:
> Martin, I've tried to use new directive in the copy test, but faced with
> problems:
> 
> 1. Current UserChar version uses pair 0, 0 as eof(). At the same time
> rw_widen sets f = 0 and c = <given char>. This results in the output
> problems with strings containig the '\0' symbol. It is interpreted as
> UserChars::eof and the length in rw_match is calculated incorrectly.
> Maybe, we'll use the pair -1, 0 for eof, or change rw_widen to
> initialize .f with any non-zero value?

Do you mean UserTraits::eof() or UserChar::eos()? (End Of File vs
End Of String.)

We could change the former but we can't do anything about the latter.
It's a requirement that char_type() be all zeros.

> 2. Suppose we want to display a string without eof symbol at the end. 
> I think it is necessary to provide the string length in this case (it is
> impossible to calculate it because we know nothing about the symbol past
> the end of the given array). 
> What directive can be used for this purpose? I tried '.' and '#' with
> %{/Gs} but with no luck. 
> It would be nice to have ability to specify element size, number of
> "characters" in the array and the array as three parameters used with
> one formatting directive.

But that exactly what "%{/*.*Gs}" does. The first asterisk denotes
the element width and the second one is the number of elements in
the array.

See lines 835 and 836 in the test:

         +-- formatting directive
         |              +-- elememnt width in bytes
         |              |        +-- number of elements in array
         |              |        |  +-- array of UserChar elements
         |              |        |  |            +-- formatted output
         |              |        |  |            |
         V              V        V  V            V
   TEST (">%{/*.*Gs}<", usrsize, 2, US ("abc"),  ">\"ab\"<");
   TEST (">%{/*.*Gs}<", usrsize, 3, US ("x\0z"), ">\"x\\0z\"<");

Martin

Mime
View raw message