summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff/diffreg.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2006-02-16 08:15:05 +0000
committerotto <otto@openbsd.org>2006-02-16 08:15:05 +0000
commit8d981b0011332816f7aaa62238a8165c5a45cfbe (patch)
tree8fa6d032c5b48b7fdbd83401e78233c003dca626 /usr.bin/diff/diffreg.c
parentdelete a few double declarations; ok otto (diff)
downloadwireguard-openbsd-8d981b0011332816f7aaa62238a8165c5a45cfbe.tar.xz
wireguard-openbsd-8d981b0011332816f7aaa62238a8165c5a45cfbe.zip
Strip newline from lines used with -I, otherwise ^$ will match all
lines and ignore them all. With and ok jaredy@
Diffstat (limited to 'usr.bin/diff/diffreg.c')
-rw-r--r--usr.bin/diff/diffreg.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 2757ef06f53..86ab79e53df 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffreg.c,v 1.62 2005/01/13 08:27:45 otto Exp $ */
+/* $OpenBSD: diffreg.c,v 1.63 2006/02/16 08:15:05 otto Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -65,7 +65,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.62 2005/01/13 08:27:45 otto Exp $";
+static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.63 2006/02/16 08:15:05 otto Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -977,6 +977,8 @@ preadline(int fd, size_t len, off_t off)
line = emalloc(len + 1);
if ((nr = pread(fd, line, len, off)) < 0)
err(1, "preadline");
+ if (nr > 0 && line[nr-1] == '\n')
+ nr--;
line[nr] = '\0';
return (line);
}