File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
hardware/arduino/avr/cores/arduino Expand file tree Collapse file tree 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
619619 left = temp;
620620 }
621621 String out;
622- if (left > len) return out;
622+ if (left >= len) return out;
623623 if (right > len) right = len;
624624 char temp = buffer[right]; // save the replaced character
625625 buffer[right] = ' \0 ' ;
@@ -684,15 +684,16 @@ void String::replace(const String& find, const String& replace)
684684}
685685
686686void 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 );
690691}
691692
692693void String::remove (unsigned int index, unsigned int count){
693694 if (index >= len) { return ; }
694695 if (count <= 0 ) { return ; }
695- if (index + count > len) { count = len - index; }
696+ if (count > len - index ) { count = len - index; }
696697 char *writeTo = buffer + index;
697698 len = len - count;
698699 strncpy (writeTo, buffer + index + count,len - index);
You can’t perform that action at this time.
0 commit comments