I tried to write a small test case and realized that there is no input that leads to a wrong token.
substCount is only used to decide how large the original input was, because some suffixes are only stripped if the token has a minimum length.
if ( ( buffer.length() + substCount > 5 ) &&
buffer.substring( buffer.length() - 2, buffer.length() ).equals( "nd" ) )
buffer.delete( buffer.length() - 2, buffer.length() );
However, every substitution leaves at least one character. For the bug to take effect, there has to be a substitution before the one that sets substCount to 2 (instead of incrementing it by 2).
So we have
- 2 characters that where left by the (at least 2) substitutions
- the suffix "nd"
- substCount, which was set to 2
That sums up to 6 , which is greater than 5
The other conditions that check on substCount work the same, except they check for greater than 4.
Therefore, there is no token that triggers any wrong behaviour.
Still, I think the typo should be fixed, because it might be copied to a place where it has an effect.