Skip to content

Commit 646aaee

Browse files
authored
Specify negative substr length (#1274)
1 parent 767fe94 commit 646aaee

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/String.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,10 +1962,7 @@ String String::substr(int inFirst, Dynamic inLen) const
19621962
if (inFirst<0) inFirst = 0;
19631963
if (len<0)
19641964
{
1965-
len += length;
1966-
// This logic matches flash ....
1967-
if (inFirst + len >=length)
1968-
len = 0;
1965+
len = length + len - inFirst;
19691966
}
19701967

19711968
if (len<=0 || inFirst>=length)

0 commit comments

Comments
 (0)