int FindNextEOL ()
{
char c = '\0';
for (; pos < decoded_count; pos++) {
c = decoded_buffer [pos];
if (c == '\n') {
pos++;
int res = (foundCR) ? (pos - 2) : (pos - 1);
if (res < 0)
res = 0; // if a new buffer starts with a \n and there was a \r at
// the end of the previous one, we get here.
foundCR = false;
return res;
} else if (foundCR) {
foundCR = false;
return pos - 1;
}
foundCR = (c == '\r');
}
return -1;
}