diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2009-06-01 13:02:47 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2009-06-01 13:02:47 +0000 |
commit | d00ac1f33f08222b9e02144aa9d038d7cfd422c0 (patch) | |
tree | ee3e6278b3fa8c2fb423ee694ac3460998cd9bab /bin/pax | |
parent | 4d8d63dbad55e83e6e8a1354e2ed00ef54f6b0cd (diff) |
Simplify newline stripping after fgets.
OK millert
Diffstat (limited to 'bin/pax')
-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); } |