commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alessandro Gallotta (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LANG-1213) ordinalIndexOf may skip first occurrence when searched string is longer than 1 char
Date Thu, 17 Mar 2016 10:29:33 GMT

     [ https://issues.apache.org/jira/browse/LANG-1213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alessandro Gallotta updated LANG-1213:
--------------------------------------
    Description: 
The method
{code:java}
private static int ordinalIndexOf(final CharSequence str, final CharSequence searchStr, final
int ordinal, final boolean lastIndex) 
{code}
[source | https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/StringUtils.html]
at the line
{code:java}
1028                index = CharSequenceUtils.indexOf(str, searchStr, index + searchStr.length());
{code}
is using as starting index for search the _index+searchStr.length()_ .In case where the _searchStr_
is a single character, the first run will start from index
{code:java}
-1+1 = 0
{code}
if the _searchStr_ is long N, it will start at N-1 index and if _str_ contains the _searchStr_
before N-1 it will miss it

  was:
The method
{code:java}
private static int ordinalIndexOf(final CharSequence str, final CharSequence searchStr, final
int ordinal, final boolean lastIndex) 
{code}
at the line
{code:java}
1028                index = CharSequenceUtils.indexOf(str, searchStr, index + searchStr.length());
{code}
is using as starting index for search the _index+searchStr.length()_ .In case where the _searchStr_
is a single character, the first run will start from index
{code:java}
-1+1 = 0
{code}
if the _searchStr_ is long N, it will start at N-1 index and if _str_ contains the _searchStr_
before N-1 it will miss it


> ordinalIndexOf may skip first occurrence when searched string is longer than 1 char
> -----------------------------------------------------------------------------------
>
>                 Key: LANG-1213
>                 URL: https://issues.apache.org/jira/browse/LANG-1213
>             Project: Commons Lang
>          Issue Type: Bug
>            Reporter: Alessandro Gallotta
>
> The method
> {code:java}
> private static int ordinalIndexOf(final CharSequence str, final CharSequence searchStr,
final int ordinal, final boolean lastIndex) 
> {code}
> [source | https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/StringUtils.html]
> at the line
> {code:java}
> 1028                index = CharSequenceUtils.indexOf(str, searchStr, index + searchStr.length());
> {code}
> is using as starting index for search the _index+searchStr.length()_ .In case where the
_searchStr_ is a single character, the first run will start from index
> {code:java}
> -1+1 = 0
> {code}
> if the _searchStr_ is long N, it will start at N-1 index and if _str_ contains the _searchStr_
before N-1 it will miss it



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message