[gnoduino: 186/237] Bug fix in replace().
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnoduino: 186/237] Bug fix in replace().
- Date: Sat, 31 Mar 2012 20:30:28 +0000 (UTC)
commit 5dbe1f06e99fb886a55717e21b27e6092e03090f
Author: David A. Mellis <d mellis arduino cc>
Date: Tue Oct 25 11:15:14 2011 -0400
Bug fix in replace().
http://code.google.com/p/arduino/issues/detail?id=694
arduino/cores/arduino/WString.cpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/arduino/cores/arduino/WString.cpp b/arduino/cores/arduino/WString.cpp
index ad8d828..3e81331 100644
--- a/arduino/cores/arduino/WString.cpp
+++ b/arduino/cores/arduino/WString.cpp
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]