From 1f8c7135d25e61359c69d1b88e5832ee47986e73 Mon Sep 17 00:00:00 2001 From: Cristian Maglie <c.maglie@arduino.cc> Date: Fri, 21 Nov 2014 16:17:44 +0100 Subject: [PATCH] Fixed warning in Stream.cpp --- cores/arduino/Stream.cpp | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/cores/arduino/Stream.cpp b/cores/arduino/Stream.cpp index 823ea43f..9c581bee 100644 --- a/cores/arduino/Stream.cpp +++ b/cores/arduino/Stream.cpp @@ -1,20 +1,24 @@ /* - Copyright (c) 2014 Arduino. All right reserved. + Stream.cpp - adds parsing methods to Stream class + Copyright (c) 2008 David A. Mellis. 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 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. + 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 -*/ + 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 + + Created July 2011 + parsing functions based on TextFinder library by Michael Margolis + */ #include "Arduino.h" #include "Stream.h" @@ -71,7 +75,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi // find returns true if the target string is found bool Stream::find(char *target) { - return findUntil(target, ""); + return findUntil(target, (char*)""); } // reads data from the stream until the target string of given length is found @@ -95,21 +99,21 @@ 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 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); if(++index >= targetLen){ // return true if all chars in the target match return true; } } - + if(termLen > 0 && c == terminator[termIndex]){ if(++termIndex >= termLen) return false; // return false if terminate string found before target string -- GitLab