Skip to content

Stream::readBytesUntil() with non-ASCII terminator #7053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions hardware/arduino/avr/cores/arduino/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ long Stream::parseInt(LookaheadMode lookahead, char ignore)
return 0; // zero returned if timeout

do{
if(c == ignore)
if((char)c == ignore)
; // ignore this character
else if(c == '-')
isNegative = true;
Expand All @@ -148,7 +148,7 @@ long Stream::parseInt(LookaheadMode lookahead, char ignore)
read(); // consume the character we got with peek
c = timedPeek();
}
while( (c >= '0' && c <= '9') || c == ignore );
while( (c >= '0' && c <= '9') || (char)c == ignore );

if(isNegative)
value = -value;
Expand All @@ -170,7 +170,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
return 0; // zero returned if timeout

do{
if(c == ignore)
if((char)c == ignore)
; // ignore
else if(c == '-')
isNegative = true;
Expand All @@ -184,7 +184,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
read(); // consume the character we got with peek
c = timedPeek();
}
while( (c >= '0' && c <= '9') || (c == '.' && !isFraction) || c == ignore );
while( (c >= '0' && c <= '9') || (c == '.' && !isFraction) || (char)c == ignore );

if(isNegative)
value = -value;
Expand Down Expand Up @@ -222,7 +222,7 @@ size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
size_t index = 0;
while (index < length) {
int c = timedRead();
if (c < 0 || c == terminator) break;
if (c < 0 || (char)c == terminator) break;
*buffer++ = (char)c;
index++;
}
Expand All @@ -245,7 +245,7 @@ String Stream::readStringUntil(char terminator)
{
String ret;
int c = timedRead();
while (c >= 0 && c != terminator)
while (c >= 0 && (char)c != terminator)
{
ret += (char)c;
c = timedRead();
Expand All @@ -268,7 +268,7 @@ int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {

for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
// the simple case is if we match, deal with that first.
if (c == t->str[t->index]) {
if ((char)c == t->str[t->index]) {
if (++t->index == t->len)
return t - targets;
else
Expand All @@ -286,7 +286,7 @@ int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {
do {
--t->index;
// first check if current char works against the new current index
if (c != t->str[t->index])
if ((char)c != t->str[t->index])
continue;

// if it's the only char then we're good, nothing more to check
Expand Down