Dekel Tsur <[EMAIL PROTECTED]> writes:
| On Wed, Jan 10, 2001 at 11:54:36AM +0100, Lars Gullik Bjønnes wrote:
| > Then I end up with something like:
| >
| > size_type const sz = rep->sz;
| > if (!sz) return npos;
| >
| > size_type ii = min(sz - 1, i);
| > for (int t = ii; t <= 0; --t) {
| ^^^ this should be t >= 0
|
| > if (rep->s[t] == c) return t;
| > }
| > return npos;
| >
| > Can you test it.
|
| This works, but I would write
|
| if (rep->sz < 1) return npos;
| size_type ii = min(rep->sz - 1, i);
| do {
| if (rep->s[ii] == c) return ii;
| } while (ii-- > 0);
| return npos;
I have never been very fond of do while, but this for version is not
overly pretty.
if (rep->sz == 0) return npos;
size_type ii = min(rep->sz - 1, i) + 1;
for (; ii--;)
if (rep->s[ii] == c) return ii;
return npos;
----
I think I prefere this, yours with a small minor change.
size_type const sz = rep->sz;
if (!sz) return npos;
size_type ii = min(sz - 1, i);
do {
if (rep->s[ii] == c) return ii;
} while (ii--);
return npos;
| And for lyxstring::rfind(lyxstring const & a, size_type) I would write
| if (rep->sz < a.length()) return npos;
| ...
|
| Actually, it appears that lyxstring::rfind(lyxstring const & a, size_type)
| is completely broken...
Possibly, but let's not change this now... we can wait until it bite
or fix1.
Lgb