Commit Graph

17 Commits

Author SHA1 Message Date
Cristian Maglie ad7ede5647 Fixed indentation in Stream.cpp, no code change 2015-04-21 18:10:32 +02:00
Cristian Maglie 9e2fdcc8f4 Fixed wrong bracket placement (see #3011) 2015-04-21 18:07:42 +02:00
Kristian Sloth Lauszus 82eb5692c6 Fixed: warning: comparison between signed and unsigned integer expressions 2015-04-21 00:08:11 +02:00
Kristian Sloth Lauszus 2398ef5260 Fixed: warning: suggest explicit braces to avoid ambiguous 'else' 2015-04-21 00:08:02 +02:00
Jim Leonard (Xuth) 8504a809dd Fix findUntil in Stream library
PR #2696 without timeout-related changes
2015-03-24 12:31:50 +01:00
Matt Robinson cd68a1c52c Cast empty string to char* to fix compiler warning
Stream::find(char *target) passes an empty terminator string to
Stream::findUntil(char *target, char *terminator) which caused a compiler
warning with the updated toolchain, so cast it to a char*.
2014-07-17 16:51:35 +01:00
Cristian Maglie fca64de387 Merge branch 'master' into HEAD 2014-06-13 10:29:12 +02:00
Amulya Kumar Sahoo 43a8a0f433 Fix of a bug
Stream::find(char *target) passes NULL as “terminator” to Stream::findUntil(char *target, char *terminator), which immediately dereferences it by passing it on to strlen():
 
bool Stream::find(char *target)
{
  return findUntil(target, NULL);
}
 
// as find but search ends if the terminator string is found
bool Stream::findUntil(char *target, char *terminator)
{
  return findUntil(target, strlen(target), terminator, strlen(terminator));
}
2014-05-30 11:44:50 +05:30
Matthijs Kooijman 53c0f1412d Don't store peeked characters in a char variable
peekNextDigit() returns an int, so it can return -1 in addition to all
256 possible bytes. By putting the result in a signe char, all bytes
over 128 will be interpreted as "no bytes available". Furthermore, it
seems that on SAM "char" is unsigned by default, causing the
"if (c < 0)" line a bit further down to always be false.

Using an int is more appropriate.

A different fix for this issue was suggested in #1399. This fix helps
towards #1728.
2014-02-19 16:09:30 +01:00
David A. Mellis b495294aa3 Adding readString() and readStringUntil() to Stream (Adrian McEwen).
This isn't necessarily a particularly efficient implementation (it
allocates memory one character at a time and so may lead to
fragmentation) but it seems to work.

http://code.google.com/p/arduino/issues/detail?id=454
2012-05-16 15:39:34 -04:00
David A. Mellis 3b962be273 Fixing findUntil() problem with repeated initial characters. (Jeffery.zksun)
http://code.google.com/p/arduino/issues/detail?id=768
2012-01-02 13:49:59 -05:00
David A. Mellis b86a613d99 readBytes() and readBytesUntil() handle zero bytes and return # of bytes read.
http://code.google.com/p/arduino/issues/detail?id=586
2011-11-19 16:23:19 -05:00
David A. Mellis 075bb009b9 Fixing warnings in Stream (Paul Stoffregen)
http://code.google.com/p/arduino/issues/detail?id=208
2011-10-02 09:44:21 -04:00
David A. Mellis 023ea285e1 Don't consume trailing char in parseInt() and parseFloat (Paul Stoffregen).
http://code.google.com/p/arduino/issues/detail?id=624
2011-09-09 16:24:47 -04:00
David A. Mellis 9bc7be0d9a Stream.readBytesUntil() now writes null terminator within length. 2011-08-18 15:13:47 -04:00
David A. Mellis 8dd6a40334 A few API changes to new Stream parsing functions.
Renamed readChars() -> readBytes(), readCharsUntil() -> readBytesUntil().
Changed timeouts to milliseconds from seconds; default from 5 to 1 seconds.
Removed readCharsBetween().
2011-08-17 14:16:47 -04:00
David A. Mellis 31ff05504f Integrating Stream searching & parsing (Michael Margolis)
This from Michael's TextFinder library, incorporated into the Stream class: find(), findUntil(), parseInt(), parseFloat(), readChars(), readCharsUntil(), readCharsBetween(), setTimeout().
2011-08-17 13:53:49 -04:00