diff options
author | 2014-08-27 15:22:40 +0000 | |
---|---|---|
committer | 2014-08-27 15:22:40 +0000 | |
commit | 82328041b46184907d0e8ec060af0a72978d211d (patch) | |
tree | e5b07b3cc4d2a43ba02d2b48520050e92d958fb6 /usr.bin/diff/diffreg.c | |
parent | Implement table-driven option parsing that allows an application to (diff) | |
download | wireguard-openbsd-82328041b46184907d0e8ec060af0a72978d211d.tar.xz wireguard-openbsd-82328041b46184907d0e8ec060af0a72978d211d.zip |
Ensure diff -uw always produces valid output when one file doesn't end
with a newline. Issue reported by guenther@.
ok guenther@
Diffstat (limited to 'usr.bin/diff/diffreg.c')
-rw-r--r-- | usr.bin/diff/diffreg.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 14f0d17bf32..f949cd27c27 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.82 2012/07/08 15:48:56 stsp Exp $ */ +/* $OpenBSD: diffreg.c,v 1.83 2014/08/27 15:22:40 kspillner Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -778,10 +778,14 @@ check(FILE *f1, FILE *f2, int flags) * GNU diff ignores a missing newline * in one file for -b or -w. */ - if ((flags & (D_FOLDBLANKS|D_IGNOREBLANKS)) && - ((c == EOF && d == '\n') || - (c == '\n' && d == EOF))) { - break; + if (flags & (D_FOLDBLANKS|D_IGNOREBLANKS)) { + if (c == EOF && d == '\n') { + ctnew++; + break; + } else if (c == '\n' && d == EOF) { + ctold++; + break; + } } ctold++; ctnew++; |