diff options
author | 2009-06-01 13:04:59 +0000 | |
---|---|---|
committer | 2009-06-01 13:04:59 +0000 | |
commit | cf03695a25481fcb9c3cefd7f3348f2d8639b14a (patch) | |
tree | c9f3411cdbe1a33d624949f92ea84fd822f4d91c | |
parent | Simplify newline stripping after fgets. (diff) | |
download | wireguard-openbsd-cf03695a25481fcb9c3cefd7f3348f2d8639b14a.tar.xz wireguard-openbsd-cf03695a25481fcb9c3cefd7f3348f2d8639b14a.zip |
Don't assume there will be a newline after calling fgets.
OK millert
-rw-r--r-- | games/atc/main.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/games/atc/main.c b/games/atc/main.c index 335ff78240b..456ec1f0750 100644 --- a/games/atc/main.c +++ b/games/atc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.19 2007/09/14 14:29:20 chl Exp $ */ +/* $OpenBSD: main.c,v 1.20 2009/06/01 13:04:59 ray Exp $ */ /* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */ /*- @@ -52,7 +52,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.19 2007/09/14 14:29:20 chl Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.20 2009/06/01 13:04:59 ray Exp $"; #endif #endif /* not lint */ @@ -338,7 +338,8 @@ list_games(void) } puts("available games:"); while (fgets(line, sizeof(line), fp) != NULL) { - printf(" %s", line); + line[strcspn(line, "\n")] = '\0'; + printf(" %s\n", line); num_games++; } fclose(fp); |