aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/diff/diffreg.c
diff options
context:
space:
mode:
authorPiotr Pawel Stefaniak <pstef@FreeBSD.org>2021-08-22 16:05:59 +0000
committerPiotr Pawel Stefaniak <pstef@FreeBSD.org>2021-08-23 05:04:28 +0000
commitaf2f0164318455433db95adce07af829285b78ad (patch)
tree85f12c5848aaedf7638945515c3747291772c981 /usr.bin/diff/diffreg.c
parentddce862ad8594542e1fa1af9ffae7264e12ffd27 (diff)
Diffstat (limited to 'usr.bin/diff/diffreg.c')
-rw-r--r--usr.bin/diff/diffreg.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 651ec88df909..113b7b621256 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1273,7 +1273,16 @@ fetch(long *f, int a, int b, FILE *lb, int ch, int oldfile, int flags)
}
col = 0;
for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
- if ((c = getc(lb)) == EOF) {
+ c = getc(lb);
+ if (flags & D_STRIPCR && c == '\r') {
+ if ((c = getc(lb)) == '\n')
+ j++;
+ else {
+ ungetc(c, lb);
+ c = '\r';
+ }
+ }
+ if (c == EOF) {
if (diff_format == D_EDIT ||
diff_format == D_REVERSE ||
diff_format == D_NREVERSE)