incubator-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 21.strings.capacity
Date Fri, 10 Mar 2006 15:22:23 GMT
The linker error disappears, thanks!

But, unfortunately, the problems with UserTraits members occurred:

1) char.cpp, line 132, the copy() member function:
...
for (size_t i = 0; i != n; dst [i] = src [i]);
...

This is the endless loop. I think it should be changed to something like
this:
...
for (size_t i = 0; i != n; dst [i] = src [i++]);
...

2) char.cpp, line 146, the move() member function:
...
for (; n--; dst [n] = src [n]);
...

This code doesn't work properly. E.g. move when
dst = "abc", src = "bc", n = 2, dst and src points to the same string,
results in "cc", but "bc" is expected.

I use the following code instead:
...
if (dst < src) {
    while (n--)
        *dst++ = *src++;
}
else {
    for (dst += n, src += n; n--; )
        *--dst = *--src;
}
...


Thanks,
Anton Pevtsov


-----Original Message-----
From: Martin Sebor [mailto:sebor@roguewave.com] 
Sent: Friday, March 10, 2006 05:47
To: stdcxx-dev@incubator.apache.org
Subject: Re: test for 21.strings.capacity


Martin Sebor wrote:
> Anton Pevtsov wrote:
> 
>> I add the UserChar case into the test for 21.strings.capacity and 
>> finally got the following linker error:
>>
> [...]
> 
>>
>> What do you think about this?
> 
> 
> Looks like I forgot to define the function (or rather move its 
> definition from rw_char.h to char.cpp in rev 384082: 
> http://svn.apache.org/viewcvs.cgi?rev=384082&view=rev). Let me fix it.

> Sorry again.

I believe I fixed this and the other problem with UserTraits
in the following commit:
   http://svn.apache.org/viewcvs?rev=384635&view=rev

I also made some enhancements to the UserTraits class here:
   http://svn.apache.org/viewcvs?rev=384680&view=rev

Most notable is the counting of calls to member functions to allow our
tests to verify that they are called as required. I started writing a
test for the class but I'm not done with it yet. The test already
revealed a couple of issues with some of the members that I fixed but
it's possible that some still remain. I'll be OOTO tomorrow so if you
run into any problems I'll fix them over the weekend.

Martin

Mime
View raw message