File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -58,16 +58,16 @@ int Stream::timedPeek() {
5858
5959// returns peek of the next digit in the stream or -1 if timeout
6060// discards non-numeric characters
61- int Stream::peekNextDigit () {
61+ int Stream::peekNextDigit (bool detectDecimal ) {
6262 int c;
6363 while (1 ) {
6464 c = timedPeek ();
65- if (c < 0 )
66- return c; // timeout
67- if (c == ' -' )
68- return c;
69- if (c >= ' 0' && c <= ' 9' )
65+ if ( c < 0 || // timeout
66+ c == ' -' ||
67+ ( c >= ' 0' && c <= ' 9' ) ||
68+ ( detectDecimal && c == ' .' ) ) {
7069 return c;
70+ }
7171 read (); // discard non-numeric
7272 }
7373}
@@ -141,7 +141,7 @@ long Stream::parseInt(char skipChar) {
141141 long value = 0 ;
142142 int c;
143143
144- c = peekNextDigit ();
144+ c = peekNextDigit (false );
145145 // ignore non numeric leading characters
146146 if (c < 0 )
147147 return 0 ; // zero returned if timeout
@@ -176,7 +176,7 @@ float Stream::parseFloat(char skipChar) {
176176 int c;
177177 float fraction = 1 .0f ;
178178
179- c = peekNextDigit ();
179+ c = peekNextDigit (true );
180180 // ignore non numeric leading characters
181181 if (c < 0 )
182182 return 0 ; // zero returned if timeout
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ class Stream: public Print {
5353 unsigned long _startMillis; // used for timeout measurement
5454 int timedRead (); // private method to read stream with timeout
5555 int timedPeek (); // private method to peek stream with timeout
56- int peekNextDigit (); // returns the next numeric digit in the stream or -1 if timeout
56+ int peekNextDigit (bool detectDecimal = false ); // returns the next numeric digit in the stream or -1 if timeout
5757
5858 public:
5959 virtual int available () = 0;
You can’t perform that action at this time.
0 commit comments