X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=tty_subs.c;h=6b6e13423ee3fe5e2bc3ebd5aeb840b3b634d8d3;hb=HEAD;hp=a7ba68afa651d5e6b8866b0b6b51994202c7ac3e;hpb=636335dbb356165e1d3e7cf91c416696d8b93910;p=debian%2Fpax diff --git a/tty_subs.c b/tty_subs.c index a7ba68a..6b6e134 100644 --- a/tty_subs.c +++ b/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); }