diff options
Diffstat (limited to 'cores')
-rw-r--r-- | cores/arduino/Platform.h | 23 | ||||
-rw-r--r-- | cores/arduino/USBAPI.h | 32 | ||||
-rw-r--r-- | cores/arduino/WString.cpp | 11 |
3 files changed, 38 insertions, 28 deletions
diff --git a/cores/arduino/Platform.h b/cores/arduino/Platform.h deleted file mode 100644 index 8b8f742..0000000 --- a/cores/arduino/Platform.h +++ /dev/null @@ -1,23 +0,0 @@ - -#ifndef __PLATFORM_H__ -#define __PLATFORM_H__ - -#include <inttypes.h> -#include <avr/pgmspace.h> -#include <avr/eeprom.h> -#include <avr/interrupt.h> -#include <util/delay.h> - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned long u32; - -#include "Arduino.h" - -#if defined(USBCON) - #include "USBDesc.h" - #include "USBCore.h" - #include "USBAPI.h" -#endif /* if defined(USBCON) */ - -#endif diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h index 7d41ca0..2fab957 100644 --- a/cores/arduino/USBAPI.h +++ b/cores/arduino/USBAPI.h @@ -1,10 +1,42 @@ +/* + USBAPI.h + Copyright (c) 2005-2014 Arduino. All right reserved. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #ifndef __USBAPI__ #define __USBAPI__ +#include <inttypes.h> +#include <avr/pgmspace.h> +#include <avr/eeprom.h> +#include <avr/interrupt.h> +#include <util/delay.h> + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned long u32; + +#include "Arduino.h" + #if defined(USBCON) +#include "USBDesc.h" +#include "USBCore.h" + //================================================================================ //================================================================================ // USB diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index ed880ce..dcd469d 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -619,7 +619,7 @@ String String::substring(unsigned int left, unsigned int right) const left = temp; } String out; - if (left > len) return out; + if (left >= len) return out; if (right > len) right = len; char temp = buffer[right]; // save the replaced character buffer[right] = '\0'; @@ -684,15 +684,16 @@ void String::replace(const String& find, const String& replace) } void String::remove(unsigned int index){ - if (index >= len) { return; } - int count = len - index; - remove(index, count); + // Pass the biggest integer as the count. The remove method + // below will take care of truncating it at the end of the + // string. + remove(index, (unsigned int)-1); } void String::remove(unsigned int index, unsigned int count){ if (index >= len) { return; } if (count <= 0) { return; } - if (index + count > len) { count = len - index; } + if (count > len - index) { count = len - index; } char *writeTo = buffer + index; len = len - count; strncpy(writeTo, buffer + index + count,len - index); |