fixed annoying error in _buffer_is_binary() which returned false sometimes even when the input were in fact binary. This fixes those 2 annoying unittests which failed from time to time.

This commit is contained in:
git@daemon.de
2014-02-17 17:03:55 +01:00
parent 3f03f97992
commit 1afb5cc3d7
5 changed files with 52 additions and 31 deletions

View File

@@ -24,7 +24,9 @@
size_t _buffer_is_binary(unsigned char *buf, size_t len) {
size_t pos;
for (pos=0; pos<len; ++pos) {
/* start at 1, to circumvent returning 0 if we find a match at position 0,
which would lead the caller to believe the buffer is not binary */
for (pos=1; pos<len; ++pos) {
if(buf[pos] == '\0' || (buf[pos] != '\r' && buf[pos] != '\n' && isprint(buf[pos]) == 0)) {
break;
}