commit 8d504b53f2bee4e17d49158a312294699094ed1e from: Omar Polo date: Tue Jul 26 13:29:04 2022 UTC sync files from diff.git ed9312f04bcebc7aee4f7e7d96d6ec467cb9bb66 commit - 2ed050c519e5d5706f53064a0e604533244ff969 commit + 8d504b53f2bee4e17d49158a312294699094ed1e blob - 0531fabe30530664069034f1c3166fe9d18a6e54 blob + 79d9633bdaa73ce679a74c04294b35271c5374f7 --- lib/diff_atomize_text.c +++ lib/diff_atomize_text.c @@ -92,7 +92,7 @@ diff_data_atomize_text_lines_fd(struct diff_data *d) 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++; } @@ -151,11 +151,9 @@ diff_data_atomize_text_lines_mmap(struct diff_data *d) /* 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 */