File tree 1 file changed +6
-5
lines changed
hardware/arduino/sam/cores/arduino
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -621,7 +621,7 @@ String String::substring(unsigned int left, unsigned int right) const
621
621
left = temp;
622
622
}
623
623
String out;
624
- if (left > len) return out;
624
+ if (left >= len) return out;
625
625
if (right > len) right = len;
626
626
char temp = buffer[right]; // save the replaced character
627
627
buffer[right] = ' \0 ' ;
@@ -686,15 +686,16 @@ void String::replace(const String& find, const String& replace)
686
686
}
687
687
688
688
void String::remove (unsigned int index){
689
- if (index >= len) { return ; }
690
- int count = len - index ;
691
- remove (index , count);
689
+ // Pass the biggest integer as the count. The remove method
690
+ // below will take care of truncating it at the end of the
691
+ // string.
692
+ remove (index , (unsigned int )-1 );
692
693
}
693
694
694
695
void String::remove (unsigned int index, unsigned int count){
695
696
if (index >= len) { return ; }
696
697
if (count <= 0 ) { return ; }
697
- if (index + count > len) { count = len - index ; }
698
+ if (count > len - index ) { count = len - index ; }
698
699
char *writeTo = buffer + index ;
699
700
len = len - count;
700
701
strncpy (writeTo, buffer + index + count,len - index );
You can’t perform that action at this time.
0 commit comments