Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
| cxx makes a very resonable objection:
|
| cxx: Warning: ../../../lyx-devel/src/support/lyxstring.C, line 1031: pointless
| comparison of unsigned integer with zero
| for (size_type t = ii; t >= 0; --t) {
| ---------------------------------^
|
| What about returning npos if the string is empty?
What about using this:
int ii = min(rep->sz - 1, i);
for (int t = ii; t >= 0; --t) {
if (rep->s[t] == c) return t;
}
return npos;
Actually this will not work...
our npos is too big...
I don't like to special case rep->sz == 0, but it seems that will be
the easiest solution.
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) {
if (rep->s[t] == c) return t;
}
return npos;
This can still fail but only for strings that are _very_ large.
Can you test it.
Lgb