Re: Bug in UStr find and Replace

"kaczoroj" <[email protected]> Fri, 10 Mar 2006 21:41:58 -0000
Newsgroups gmane.comp.version-control.cvs.gui.devel
Message-ID <[email protected]>
Guy,

> I like the idea of using a constant.  Would you suggest defining 
> it within UStr itself, so that to use it from outside the class 
> you would say something like UStr::NOT_FOUND?

Make it UStr::npos for similarity with std::basic_string::npos. It 
will make it more standard-look-alike ;)

Note that there is also rfind to be fixed accordingly. To make sure 
that we find all parts in the code just change name to Find() and 
ReverseFind() and let the compiler find it for you. Since it's a 
critical change it's better to break compilation and make sure all 
places using the code are reviewed. We can make it back later on when 
sorting out string classes.

Best Regards,
Jerzy

--- In [email protected], Guy Rouillier <guyr-ml1@...> wrote:
>
> Jens Miltner wrote:
> >> Changing the not-found value to -1 (minus one) fixes it for me, 
but I
> >> have no idea what this breaks in other parts of the code.  Of 
course,
> >> any code depending on this behavior is by definition broken 
itself.
> > 
> > Searching for 'find' in the sources should reveal usage, so we 
should  
> > be able to verify the behavior.
> 
> So the theory goes ;).  "Replace" is feasible, since the use of that 
> word with a capital "R" is limited.  Unfortunately, "find" is used 
in 
> many other contexts, so grepping on "find" produces a large number 
of hits.
> 
> > While you're at it, why not define a constant for 'not found' - 
that  
> > way, the behavior is clearer from the source code as well.
> 
> I like the idea of using a constant.  Would you suggest defining it 
> within UStr itself, so that to use it from outside the class you 
would 
> say something like UStr::NOT_FOUND?
> 
> -- 
> Guy Rouillier
>






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/cvsgui-dev/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/