Stream.cpp bug?

johnnyfp

Well-known member
Hi,

I think I found a bug in the teensy3 Stream.cpp code? Specifying a max will never be matched as the length is not recalculated or iterated after every add to the str variable. I've added what's needed in the below if you want it this way or I can make a pull request, but need to be careful as I have all my Foofy Teensy code in my local repo as well which may get included in the request.

Code:
String Stream::readString(size_t max)
{
	String str;
	size_t length = str.length();
	while (length < max) {
		int c = timedRead();
		if (c < 0) {
			setReadError();
			break;	// timeout
		}
		if (c == 0) break;
		str += (char)c;
               [COLOR="#AAAA22"] length++;//Needed[/COLOR]
               [COLOR="#AA1111"] //or length = str.length();[/COLOR]
	}
	return str;
}
 
Back
Top