Re: Bug in UStr find and Replace
Jens Miltner <[email protected]> Fri, 10 Mar 2006 09:23:52 +0100
| Newsgroups | gmane.comp.version-control.cvs.gui.devel |
|---|---|
| Message-ID | <[email protected]> |
Am 10.03.2006 um 07:14 schrieb Guy Rouillier:
> As I was putting finishing touches on some code changes for gCvs, I
> stumbled across a bug in rf/UStr.cpp. In method
>
> int UStr::find(const char* thestr) const
>
> the statement
>
> return buf - m_str;
>
> evaluates to zero if thestr is at the beginning of the current string.
> But zero is defined by this function to mean "not found".
>
> 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.
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.
</jum>
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/