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: RE: svn commit: r387687 - in /incubator/stdcxx/trunk/tests: include/rw_char.h self/0.char.cpp src/char.cpp
Date Thu, 23 Mar 2006 16:16:16 GMT
Martin, the problem may occurred when someone call rw_narrow without the
string length specified:

#include <rw_printf.h>  
#include <rw_char.h>    

void main (int argc, char* argv[])
{
    char test[] = "ab\0cd";
    rw_printf ("source string   : %{/*.*Gs}\n", 1, 5, test);

    UserChar wtest [10];
    rw_widen (wtest, test, 5);
    rw_printf ("after rw_widen  : %{/*.*Gs}\n", int (sizeof UserChar),
5, wtest);

    char res [10];
    rw_narrow (res, wtest);
    rw_printf ("after rw_narrow : %{s}\n", res);
}

You can see the following output:

source string   : "ab\0cd"
after rw_widen  : "ab\0cd"
after rw_narrow : "ab"		<-- here we lost the rest symbols
following '\0' in the middle of the string

Actually this is not important in tests because we always know the array
length. But is this behaviour of rw_narrow expected?


Thanks,
Anton Pevtsov


-----Original Message-----
From: Martin Sebor [mailto:sebor@roguewave.com] 
Sent: Wednesday, March 22, 2006 20:21
To: stdcxx-dev@incubator.apache.org
Subject: Re: svn commit: r387687 - in /incubator/stdcxx/trunk/tests:
include/rw_char.h self/0.char.cpp src/char.cpp


Anton Pevtsov wrote:
> Oops, I've mixed eos and eof in my question. The correct version here:
> 
> 1. Current UserChar version uses pair 0, 0 as eos(). At the same time 
> rw_widen sets .f = 0 and .c = <given char>. This results in the 
> possible output problems with strings containing the '\0' symbol. It 
> may be interpreted as UserChars::eos and the length in rw_match may be

> calculated incorrectly.

I'm not sure I completely understand the problem, or that you saw my
response to your first question:
http://mail-archives.apache.org/mod_mbox/incubator-stdcxx-dev/200603.mbo
x/%3c4421730B.5000100@roguewave.com%3e

Could you put together a small test case demonstrating the problem?

Thanks
Martin

Mime
View raw message