summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-12-13 23:16:39 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-12-13 23:16:39 +0000
commitba900f2ae3e6e91810ced3c1838afee0332f016b (patch)
treec77761b4c78a61307edd9c183f415d4bf555d1b3
parentf5810ab510bb5a455d9a8f4c469962383b15b487 (diff)
Less stupid check for 7-bit ascii in toupper/tolower
Remove useless check for EOF in isascii
-rw-r--r--include/ctype.h10
-rw-r--r--lib/libc/gen/isctype.c8
-rw-r--r--lib/libc/gen/tolower_.c4
-rw-r--r--lib/libc/gen/toupper_.c4
4 files changed, 11 insertions, 15 deletions
diff --git a/include/ctype.h b/include/ctype.h
index f9640f58224..1845aa1e978 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ctype.h,v 1.6 2002/12/13 22:39:27 millert Exp $ */
+/* $OpenBSD: ctype.h,v 1.7 2002/12/13 23:16:38 millert Exp $ */
/* $NetBSD: ctype.h,v 1.14 1994/10/26 00:55:47 cgd Exp $ */
/*
@@ -166,14 +166,14 @@ static __inline int isxdigit(int c)
static __inline int tolower(int c)
{
- if (c != (c & 0177))
+ if ((unsigned int)c > 0177)
return (c);
return ((_tolower_tab_ + 1)[c]);
}
static __inline int toupper(int c)
{
- if (c != (c & 0177))
+ if ((unsigned int)c > 0177)
return (c);
return ((_toupper_tab_ + 1)[c]);
}
@@ -186,9 +186,7 @@ static __inline int isblank(int c)
static __inline int isascii(int c)
{
- if (c == EOF)
- return (0);
- return ((unsigned int)(c) <= 0177);
+ return ((unsigned int)c <= 0177);
}
static __inline int toascii(int c)
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]);
}