diff options
author | 2009-06-01 13:02:46 +0000 | |
---|---|---|
committer | 2009-06-01 13:02:46 +0000 | |
commit | 2241ca229b71bc612d9846577ce68a6d498af1ba (patch) | |
tree | 4d67d24a13d9af0958d6d6c025d9663c6b452eae | |
parent | I forgot to apply the End Of Command token for async xfers. Maybe that (diff) | |
download | wireguard-openbsd-2241ca229b71bc612d9846577ce68a6d498af1ba.tar.xz wireguard-openbsd-2241ca229b71bc612d9846577ce68a6d498af1ba.zip |
Simplify newline stripping after fgets.
OK millert
-rw-r--r-- | bin/pax/tty_subs.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/bin/pax/tty_subs.c b/bin/pax/tty_subs.c index a7ba68afa65..6b6e13423ee 100644 --- a/bin/pax/tty_subs.c +++ b/bin/pax/tty_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_subs.c,v 1.12 2003/06/02 23:32:09 millert Exp $ */ +/* $OpenBSD: tty_subs.c,v 1.13 2009/06/01 13:02:46 ray Exp $ */ /* $NetBSD: tty_subs.c,v 1.5 1995/03/21 09:07:52 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static const char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94"; #else -static const char rcsid[] = "$OpenBSD: tty_subs.c,v 1.12 2003/06/02 23:32:09 millert Exp $"; +static const char rcsid[] = "$OpenBSD: tty_subs.c,v 1.13 2009/06/01 13:02:46 ray Exp $"; #endif #endif /* not lint */ @@ -123,17 +123,13 @@ tty_prnt(const char *fmt, ...) int tty_read(char *str, int len) { - char *pt; - - if ((--len <= 0) || (ttyinf == NULL) || (fgets(str,len,ttyinf) == NULL)) + if (ttyinf == NULL || fgets(str, len, ttyinf) == NULL) return(-1); - *(str + len) = '\0'; /* * strip off that trailing newline */ - if ((pt = strchr(str, '\n')) != NULL) - *pt = '\0'; + str[strcspn(str, "\n")] = '\0'; return(0); } |