Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -117,13 +117,18 @@ /* Look if there's a line or \0 in our cache */ if (cache != NULL) { for (i = 0; i < cache_len; i++) { if (OF_UNLIKELY(cache[i] == '\n' || cache[i] == '\0')) { + ret_len = i; + + if (i > 0 && cache[i - 1] == '\r') + ret_len--; + ret = [OFString stringWithCString: cache encoding: encoding - length: i]; + length: ret_len]; tmp = [self allocMemoryWithSize: cache_len - i - 1]; memcpy(tmp, cache + i + 1, cache_len - i - 1); @@ -142,14 +147,19 @@ @try { for (;;) { if ([self atEndOfStreamWithoutCache]) { if (cache == NULL) return nil; + + ret_len = cache_len; + + if (ret_len > 0 && cache[ret_len - 1] == '\r') + ret_len--; ret = [OFString stringWithCString: cache encoding: encoding - length: cache_len]; + length: ret_len]; [self freeMemory: cache]; cache = NULL; cache_len = 0; @@ -168,10 +178,14 @@ allocMemoryWithSize: ret_len]; if (cache != NULL) memcpy(ret_c, cache, cache_len); memcpy(ret_c + cache_len, tmp, i); + + if (ret_len > 0 && + ret_c[ret_len - 1] == '\r') + ret_len--; @try { ret = [OFString stringWithCString: ret_c encoding: encoding