Skip to content

Commit

Permalink
Stream String readStringUntil() default to allow unlimited length
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulStoffregen committed Feb 21, 2023
1 parent 348413f commit 4a75d04
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions teensy3/Stream.cpp
Expand Up @@ -261,7 +261,7 @@ String Stream::readString(size_t max)
{
String str;
size_t length = 0;
while (length < max) {
while (length < max || !max) {
int c = timedRead();
if (c < 0) {
setReadError();
Expand All @@ -278,7 +278,7 @@ String Stream::readStringUntil(char terminator, size_t max)
{
String str;
size_t length = 0;
while (length < max) {
while (length < max || !max) {
int c = timedRead();
if (c < 0) {
setReadError();
Expand Down
4 changes: 2 additions & 2 deletions teensy3/Stream.h
Expand Up @@ -56,8 +56,8 @@ class Stream : public Print
size_t readBytes(uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
size_t readBytesUntil(char terminator, char *buffer, size_t length);
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
String readString(size_t max = 120);
String readStringUntil(char terminator, size_t max = 120);
String readString(size_t max = 0 /* 0 means unlimited length */);
String readStringUntil(char terminator, size_t max = 0 /* 0 means unlimited length */);
int getReadError() { return read_error; }
void clearReadError() { setReadError(0); }
protected:
Expand Down
4 changes: 2 additions & 2 deletions teensy4/Stream.cpp
Expand Up @@ -262,7 +262,7 @@ String Stream::readString(size_t max)
{
String str;
size_t length = 0;
while (length < max) {
while (length < max || !max) {
int c = timedRead();
if (c < 0) {
setReadError();
Expand All @@ -279,7 +279,7 @@ String Stream::readStringUntil(char terminator, size_t max)
{
String str;
size_t length = 0;
while (length < max) {
while (length < max || !max) {
int c = timedRead();
if (c < 0) {
setReadError();
Expand Down
4 changes: 2 additions & 2 deletions teensy4/Stream.h
Expand Up @@ -56,8 +56,8 @@ class Stream : public Print
size_t readBytes(uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
size_t readBytesUntil(char terminator, char *buffer, size_t length);
size_t readBytesUntil(char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
String readString(size_t max = 120);
String readStringUntil(char terminator, size_t max = 120);
String readString(size_t max = 0 /* 0 means unlimited length */);
String readStringUntil(char terminator, size_t max = 0 /* 0 means unlimited length */);
int getReadError() { return read_error; }
void clearReadError() { setReadError(0); }
protected:
Expand Down

0 comments on commit 4a75d04

Please sign in to comment.