Bug in String::indexOfAnyOf


#1

I think this is a bug in String::indexOfAnyOf:

    while (*t != 0)
        if (CharacterFunctions::indexOfChar (charactersToLookFor, *t++, ignoreCase) >= 0)
            return (int) (t - text->text);

When one of the charactersToLookFor is found, t is incremented before returning the result. The function thus returns the character index + 1.

The simple fix:

    while (*t != 0)
    {
        if (CharacterFunctions::indexOfChar (charactersToLookFor, *t, ignoreCase) >= 0)
            return (int) (t - text->text);
        ++t;
    }

regards,
Francis.


#2

wow - you’re quite right, I’m surprised I never came across that one before! Thanks, I’ll get a fix checked in asap.