mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-01 03:47:23 +03:00
Fixing findUntil() problem with repeated initial characters. (Jeffery.zksun)
http://code.google.com/p/arduino/issues/detail?id=768
This commit is contained in:
@ -103,15 +103,17 @@ bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t
|
|||||||
if( *target == 0)
|
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){
|
while( (c = timedRead()) > 0){
|
||||||
|
|
||||||
|
if(c != target[index])
|
||||||
|
index = 0; // reset index if any char does not match
|
||||||
|
|
||||||
if( c == target[index]){
|
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
|
if(++index >= targetLen){ // return true if all chars in the target match
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
index = 0; // reset index if any char does not match
|
|
||||||
}
|
|
||||||
if(termLen > 0 && c == terminator[termIndex]){
|
if(termLen > 0 && c == terminator[termIndex]){
|
||||||
if(++termIndex >= termLen)
|
if(++termIndex >= termLen)
|
||||||
return false; // return false if terminate string found before target string
|
return false; // return false if terminate string found before target string
|
||||||
|
Reference in New Issue
Block a user