From ba900f2ae3e6e91810ced3c1838afee0332f016b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 13 Dec 2002 23:16:39 +0000 Subject: Less stupid check for 7-bit ascii in toupper/tolower Remove useless check for EOF in isascii --- lib/libc/gen/isctype.c | 8 +++----- lib/libc/gen/tolower_.c | 4 ++-- lib/libc/gen/toupper_.c | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/isctype.c b/lib/libc/gen/isctype.c index 585fcef9d27..e6df7d94354 100644 --- a/lib/libc/gen/isctype.c +++ b/lib/libc/gen/isctype.c @@ -37,7 +37,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: isctype.c,v 1.4 2002/12/13 22:39:27 millert Exp $"; +static char rcsid[] = "$OpenBSD: isctype.c,v 1.5 2002/12/13 23:16:38 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #define _ANSI_LIBRARY @@ -167,9 +167,7 @@ int isascii(c) int c; { - if (c == EOF) - return(0); - return ((unsigned int)(c) <= 0177); + return ((unsigned int)c <= 0177); } #undef toascii @@ -177,7 +175,7 @@ int toascii(c) int c; { - return ((c) & 0177); + return (c & 0177); } #undef _toupper diff --git a/lib/libc/gen/tolower_.c b/lib/libc/gen/tolower_.c index 2e116613944..c74d1725fb2 100644 --- a/lib/libc/gen/tolower_.c +++ b/lib/libc/gen/tolower_.c @@ -4,7 +4,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: tolower_.c,v 1.5 2002/12/13 22:39:27 millert Exp $"; +static char rcsid[] = "$OpenBSD: tolower_.c,v 1.6 2002/12/13 23:16:38 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #define _ANSI_LIBRARY @@ -54,7 +54,7 @@ int tolower(c) int c; { - if (c != (c & 0177)) + if ((unsigned int)c > 0177) return(c); return((_tolower_tab_ + 1)[c]); } diff --git a/lib/libc/gen/toupper_.c b/lib/libc/gen/toupper_.c index d5e9b98dcf7..fa2fc4fd996 100644 --- a/lib/libc/gen/toupper_.c +++ b/lib/libc/gen/toupper_.c @@ -4,7 +4,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: toupper_.c,v 1.5 2002/12/13 22:39:27 millert Exp $"; +static char rcsid[] = "$OpenBSD: toupper_.c,v 1.6 2002/12/13 23:16:38 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #define _ANSI_LIBRARY @@ -54,7 +54,7 @@ int toupper(c) int c; { - if (c != (c & 0177)) + if ((unsigned int)c > 0177) return(c); return((_toupper_tab_ + 1)[c]); } -- cgit v1.2.3