summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2007-03-22 18:35:08 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2007-03-22 18:35:08 +0000
commitf9e584fecc780db62419710ae151a2ae5233d695 (patch)
treee67b171666917333e77664030206f262404fa1cc /bin
parent52fb9a580b4c558cfea9160e8c05c4f8fce48fd3 (diff)
Fix handling of multiple stdin arguments in cooked mode, closes PR 5418.
From Johan Veenhuizen
Diffstat (limited to 'bin')
-rw-r--r--bin/cat/cat.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index 27e29ab6049..07f9d3c3899 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cat.c,v 1.17 2005/04/05 01:18:53 jaredy Exp $ */
+/* $OpenBSD: cat.c,v 1.18 2007/03/22 18:35:07 millert Exp $ */
/* $NetBSD: cat.c,v 1.11 1995/09/07 06:12:54 jtc Exp $ */
/*
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
#else
-static char rcsid[] = "$OpenBSD: cat.c,v 1.17 2005/04/05 01:18:53 jaredy Exp $";
+static char rcsid[] = "$OpenBSD: cat.c,v 1.18 2007/03/22 18:35:07 millert Exp $";
#endif
#endif /* not lint */
@@ -139,7 +139,9 @@ cook_args(char **argv)
filename = *argv++;
}
cook_buf(fp);
- if (fp != stdin)
+ if (fp == stdin)
+ clearerr(fp);
+ else
(void)fclose(fp);
} while (*argv);
}