aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/WString.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cores/arduino/WString.cpp')
-rw-r--r--cores/arduino/WString.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp
index f90cef0..3e81331 100644
--- a/cores/arduino/WString.cpp
+++ b/cores/arduino/WString.cpp
@@ -498,7 +498,7 @@ int String::lastIndexOf( char theChar ) const
return lastIndexOf(theChar, len - 1);
}
-int String::lastIndexOf(char ch, int fromIndex) const
+int String::lastIndexOf(char ch, unsigned int fromIndex) const
{
if (fromIndex >= len || fromIndex < 0) return -1;
char tempchar = buffer[fromIndex + 1];
@@ -514,7 +514,7 @@ int String::lastIndexOf(const String &s2) const
return lastIndexOf(s2, len - s2.len);
}
-int String::lastIndexOf(const String &s2, int fromIndex) const
+int String::lastIndexOf(const String &s2, unsigned int fromIndex) const
{
if (s2.len == 0 || len == 0 || s2.len > len || fromIndex < 0) return -1;
if (fromIndex >= len) fromIndex = len - 1;
@@ -522,7 +522,7 @@ int String::lastIndexOf(const String &s2, int fromIndex) const
for (char *p = buffer; p <= buffer + fromIndex; p++) {
p = strstr(p, s2.buffer);
if (!p) break;
- if (p - buffer <= fromIndex) found = p - buffer;
+ if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer;
}
return found;
}
@@ -593,7 +593,7 @@ void String::replace(const String& find, const String& replace)
if (size == len) return;
if (size > capacity && !changeBuffer(size)) return; // XXX: tell user!
int index = len - 1;
- while ((index = lastIndexOf(find, index)) >= 0) {
+ while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
readFrom = buffer + index + find.len;
memmove(readFrom + diff, readFrom, len - (readFrom - buffer));
len += diff;