summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2008-06-19 18:29:07 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2008-06-19 18:29:07 +0000
commit0fa09dc5d4739d4dc334ab186486a4a58448fd6f (patch)
treeecfeb10b45a837e9bac5654c4053ea2140c01212 /usr.bin
parent4fb2746cc04b6a1c03640d23b283155822e98a58 (diff)
do not print spurious whitespace when reading from stdin;
from Bernd Ahlers with a twist from me; ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/wc/wc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c
index bbfc7909964..e2b3e5b2346 100644
--- a/usr.bin/wc/wc.c
+++ b/usr.bin/wc/wc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wc.c,v 1.11 2005/10/19 21:49:02 espie Exp $ */
+/* $OpenBSD: wc.c,v 1.12 2008/06/19 18:29:06 otto Exp $ */
/*
* Copyright (c) 1980, 1987, 1991, 1993
@@ -39,7 +39,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)wc.c 8.2 (Berkeley) 5/2/95";
#else
-static char rcsid[] = "$OpenBSD: wc.c,v 1.11 2005/10/19 21:49:02 espie Exp $";
+static char rcsid[] = "$OpenBSD: wc.c,v 1.12 2008/06/19 18:29:06 otto Exp $";
#endif
#endif /* not lint */
@@ -224,7 +224,7 @@ cnt(char *file)
}
}
- print_counts(linect, wordct, charct, file ? file : "");
+ print_counts(linect, wordct, charct, file);
/*
* Don't bother checking doline, doword, or dochar -- speeds
@@ -263,5 +263,8 @@ print_counts(int64_t lines, int64_t words, int64_t chars, char *name)
if (dochar)
format_and_print((long long)chars);
- (void)printf(" %s\n", name);
+ if (name)
+ (void)printf(" %s\n", name);
+ else
+ (void)printf("\n");
}