incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <>
Subject Re: rw_match() bug
Date Tue, 27 Jun 2006 16:27:50 GMT
Anton Pevtsov wrote:
> Hmm, I've tried with several tests and your changes to char.cpp and I
> passed the tdata.reslen_ (the length of the expanded result string) as
> the third argument. But I'll verify this more deeply.

Well, yes, passing in the length of the expanded string will
work. The only thing with that approach is that the string
is processed twice: once to get its length and one more time
to do the comparison. Not a huge deal but it would be nice
not to have to do that. The one way I think this could be
done is by adding a special directive for the NUL ('\0')
character so that the size of the first string argument to
rw_match() is no longer necessary. That way we could invoke
rw_match (s1, s2, -1) on both strings since s1 wouldn't
contain any embedded NULs (they would be represented by


> Thanks,
> Anton Pevtsov
> -----Original Message-----
> From: Martin Sebor [] 
> Sent: Tuesday, June 27, 2006 19:51
> To:
> Subject: Re: rw_match() bug
> Anton Pevtsov wrote:
>>Ok, I see. There are no problems to switch the strings tests to using 
>>the (1) method. I think it will require changes in one line.
> Really? That's it? I thought it would take a lot more changes than that.
> All the test cases hardwire the size of each string and, AFAICS, that's
> what gets used as the last argument to rw_match(). What would we pass in
> instead? Passing in the size/length of the second string wouldn't be
> safe (since it could be longer than the first string due to a bug). I
> think the only safe thing to do would be to pass the length of expanded
> first string but that would either have to be hardcoded in each test
> case requiring changes to all the TEST macros, or computed. Or am I
> missing something?
> Martin
>>So I'll do it when the new version of the char.cpp will be ready.
>>Anton Pevtsov
>>-----Original Message-----
>>From: Martin Sebor []
>>Sent: Tuesday, June 27, 2006 04:40
>>Subject: Re: rw_match() bug
>>Martin Sebor wrote:
>>>Hmm. There are two possible interpretations of the third argument to
>>>1. it gives the maximum number of characters to compare (i.e.,
>>>  after all directives have been expanded)
>>>2. it denotes the number of characters in the first argument
>>>  (i.e., before the expansion of any directives).
>>>It looks like currently we do (2). I missed this and made changes to
>>>implement (1). Needless to say, even though my changes are "good", 
>>>they cause many failures in the test suite. I need to go back and 
>>>implement (1). It shouldn't be too hard but it means that I won't be 
>>>able to commit my changes tonight (what I have is attached so you can 
>>>see where I am).
>>OTOH, (1) seems to make more sense to me. What do you think? If you 
>>agree, how difficult do you think it would be to switch the string 
>>tests to using it instead of (2)?

View raw message