diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2007-02-21 03:53:33 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2007-02-21 03:53:33 +0000 |
commit | 6a13437e9b409624604d242ffd9ee25ad6044bf2 (patch) | |
tree | f9d1d211df387878d22b0d5ea075cab0511cada4 | |
parent | 65e3861d22f0095c30e36c5cf96c217b97366f1d (diff) |
- Pass full buffer size to fgets.
- No need to initialize buffer.
- Spacing.
Based on diff from Charles Longeau <chl at tuxfamily dot org> long ago.
OK moritz@.
-rw-r--r-- | games/hack/hack.pager.c | 8 | ||||
-rw-r--r-- | usr.sbin/fdformat/fdformat.c | 7 |
2 files changed, 7 insertions, 8 deletions
diff --git a/games/hack/hack.pager.c b/games/hack/hack.pager.c index 9210f410edb..74ce3e2d0ec 100644 --- a/games/hack/hack.pager.c +++ b/games/hack/hack.pager.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hack.pager.c,v 1.11 2005/05/01 02:43:12 djm Exp $ */ +/* $OpenBSD: hack.pager.c,v 1.12 2007/02/21 03:53:32 ray Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -62,7 +62,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: hack.pager.c,v 1.11 2005/05/01 02:43:12 djm Exp $"; +static const char rcsid[] = "$OpenBSD: hack.pager.c,v 1.12 2007/02/21 03:53:32 ray Exp $"; #endif /* not lint */ /* This file contains the command routine dowhatis() and a pager. */ @@ -142,8 +142,8 @@ page_more(FILE *fp, int strip) set_pager(0); bufr = (char *) alloc((unsigned) CO); - bufr[CO-1] = 0; - while(fgets(bufr,CO-1,fp) && (!strip || *bufr == '\t') && !got_intrup){ + while (fgets(bufr, CO, fp) && (!strip || *bufr == '\t') && + !got_intrup) { ep = strchr(bufr, '\n'); if(ep) *ep = 0; diff --git a/usr.sbin/fdformat/fdformat.c b/usr.sbin/fdformat/fdformat.c index 7919958f183..a2935634f0d 100644 --- a/usr.sbin/fdformat/fdformat.c +++ b/usr.sbin/fdformat/fdformat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdformat.c,v 1.16 2007/02/19 21:32:35 jmc Exp $ */ +/* $OpenBSD: fdformat.c,v 1.17 2007/02/21 03:53:32 ray Exp $ */ /* * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden @@ -158,12 +158,11 @@ usage(void) static int yes(void) { - char reply [256], *p; + char reply[256], *p; - reply[sizeof(reply)-1] = 0; for (;;) { fflush(stdout); - if (! fgets (reply, sizeof(reply)-1, stdin)) + if (!fgets(reply, sizeof(reply), stdin)) return (0); for (p=reply; *p==' ' || *p=='\t'; ++p) continue; |