commit - b72f51ffc39028023059fc994542565691b669fa
commit + ed9312f04bcebc7aee4f7e7d96d6ec467cb9bb66
blob - 0531fabe30530664069034f1c3166fe9d18a6e54
blob + 79d9633bdaa73ce679a74c04294b35271c5374f7
--- lib/diff_atomize_text.c
+++ lib/diff_atomize_text.c
r = fread(buf, sizeof(char), sizeof(buf), d->root->f);
if (r == 0 && ferror(d->root->f))
return errno;
- if (r == 1 && buf[0] == '\n' )
+ if (r > 0 && buf[0] == '\n')
line_end++;
}
/* When not at the end of data, the line ending char ('\r' or
* '\n') must follow */
- if (line_end < end)
+ if (line_end < end && *line_end == '\r')
line_end++;
- /* If that was an '\r', also pull in any following '\n' */
- if (line_end < end - 1 && line_end[0] == '\r' &&
- line_end[1] == '\n')
+ if (line_end < end && *line_end == '\n')
line_end++;
/* Record the found line as diff atom */