diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 2001-08-19 16:30:44 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 2001-08-19 16:30:44 +0000 |
commit | 41c454051895b81c6262a6f5e7bb5d0fa7359e29 (patch) | |
tree | 110c2f4228805e3636a3a27b9aa5241d6d4b45cd /games/primes/primes.c | |
parent | 7350e599af5d56defed88c7468a2f08bda5dfd27 (diff) |
remove extraneous newline from error output; accept trailing whitespace
elsewhere. Similar to PR/2014 for factor(6).
Diffstat (limited to 'games/primes/primes.c')
-rw-r--r-- | games/primes/primes.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/games/primes/primes.c b/games/primes/primes.c index aa2f85fffba..5fe68f1d8df 100644 --- a/games/primes/primes.c +++ b/games/primes/primes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: primes.c,v 1.7 1999/09/26 05:30:38 pjanzen Exp $ */ +/* $OpenBSD: primes.c,v 1.8 2001/08/19 16:30:43 pjanzen Exp $ */ /* $NetBSD: primes.c,v 1.5 1995/04/24 12:24:47 cgd Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)primes.c 8.5 (Berkeley) 5/10/95"; #else -static char rcsid[] = "$OpenBSD: primes.c,v 1.7 1999/09/26 05:30:38 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: primes.c,v 1.8 2001/08/19 16:30:43 pjanzen Exp $"; #endif #endif /* not lint */ @@ -206,8 +206,10 @@ read_num_buf() err(1, "stdin"); exit(0); } + if (*(p = buf + strlen(buf) - 1) == '\n') + *p = '\0'; for (p = buf; isblank(*p); ++p); - if (*p == '\n' || *p == '\0') + if (*p == '\0') continue; if (*p == '-') errx(1, "negative numbers aren't permitted."); @@ -215,7 +217,8 @@ read_num_buf() val = strtoul(buf, &p, 10); if (errno) err(1, "%s", buf); - if (*p != '\n') + for (; isblank(*p); ++p); + if (*p != '\0') errx(1, "%s: illegal numeric format.", buf); return (val); } |