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