File tree 2 files changed +9
-9
lines changed
2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -58,16 +58,16 @@ int Stream::timedPeek() {
58
58
59
59
// returns peek of the next digit in the stream or -1 if timeout
60
60
// discards non-numeric characters
61
- int Stream::peekNextDigit () {
61
+ int Stream::peekNextDigit (bool detectDecimal ) {
62
62
int c;
63
63
while (1 ) {
64
64
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 == ' .' ) ) {
70
69
return c;
70
+ }
71
71
read (); // discard non-numeric
72
72
}
73
73
}
@@ -141,7 +141,7 @@ long Stream::parseInt(char skipChar) {
141
141
long value = 0 ;
142
142
int c;
143
143
144
- c = peekNextDigit ();
144
+ c = peekNextDigit (false );
145
145
// ignore non numeric leading characters
146
146
if (c < 0 )
147
147
return 0 ; // zero returned if timeout
@@ -176,7 +176,7 @@ float Stream::parseFloat(char skipChar) {
176
176
int c;
177
177
float fraction = 1 .0f ;
178
178
179
- c = peekNextDigit ();
179
+ c = peekNextDigit (true );
180
180
// ignore non numeric leading characters
181
181
if (c < 0 )
182
182
return 0 ; // zero returned if timeout
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ class Stream: public Print {
53
53
unsigned long _startMillis; // used for timeout measurement
54
54
int timedRead (); // private method to read stream with timeout
55
55
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
57
57
58
58
public:
59
59
virtual int available () = 0;
You can’t perform that action at this time.
0 commit comments