File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
hardware/arduino/sam/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 @@ -621,7 +621,7 @@ String String::substring(unsigned int left, unsigned int right) const
621621 left = temp;
622622 }
623623 String out;
624- if (left > len) return out;
624+ if (left >= len) return out;
625625 if (right > len) right = len;
626626 char temp = buffer[right]; // save the replaced character
627627 buffer[right] = ' \0 ' ;
@@ -686,15 +686,16 @@ void String::replace(const String& find, const String& replace)
686686}
687687
688688void 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 );
692693}
693694
694695void String::remove (unsigned int index, unsigned int count){
695696 if (index >= len) { return ; }
696697 if (count <= 0 ) { return ; }
697- if (index + count > len) { count = len - index; }
698+ if (count > len - index ) { count = len - index; }
698699 char *writeTo = buffer + index;
699700 len = len - count;
700701 strncpy (writeTo, buffer + index + count,len - index);
You can’t perform that action at this time.
0 commit comments