aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/Stream.cpp
diff options
context:
space:
mode:
authorZach Eveland <zeveland@blacklabel-development.com>2012-01-10 12:02:27 -0500
committerZach Eveland <zeveland@blacklabel-development.com>2012-01-10 12:02:27 -0500
commit989f672d345c71478102d9778d551c4637e88ab5 (patch)
treea194b4c486bf7e66827c6a343206be72df503047 /cores/arduino/Stream.cpp
parent28e9e122af24e63e84d5bcd2c619b76c490970fc (diff)
parentdd5bae59df6f1ba63083361ba284f364bc62b401 (diff)
Merge branch 'master' of github.com:arduino/Arduino into new-extension
Diffstat (limited to 'cores/arduino/Stream.cpp')
-rw-r--r--cores/arduino/Stream.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/cores/arduino/Stream.cpp b/cores/arduino/Stream.cpp
index 5fad8dd..3d5b905 100644
--- a/cores/arduino/Stream.cpp
+++ b/cores/arduino/Stream.cpp
@@ -99,25 +99,27 @@ bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t
size_t index = 0; // maximum target string length is 64k bytes!
size_t termIndex = 0;
int c;
-
+
if( *target == 0)
- return true; // return true if target is a null string
+ return true; // return true if target is a null string
while( (c = timedRead()) > 0){
+
+ if(c != target[index])
+ index = 0; // reset index if any char does not match
+
if( c == target[index]){
- //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
+ //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
if(++index >= targetLen){ // return true if all chars in the target match
return true;
}
}
- else{
- index = 0; // reset index if any char does not match
- }
+
if(termLen > 0 && c == terminator[termIndex]){
- if(++termIndex >= termLen)
- return false; // return false if terminate string found before target string
+ if(++termIndex >= termLen)
+ return false; // return false if terminate string found before target string
}
else
- termIndex = 0;
+ termIndex = 0;
}
return false;
}