Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libkern Add ctype routines.



details:   https://anonhg.NetBSD.org/src/rev/1590f4976a4a
branches:  trunk
changeset: 508040:1590f4976a4a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Apr 05 04:38:06 2001 +0000

description:
Add ctype routines.

diffstat:

 sys/lib/libkern/libkern.h |  90 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 89 insertions(+), 1 deletions(-)

diffs (111 lines):

diff -r 12a430b22266 -r 1590f4976a4a sys/lib/libkern/libkern.h
--- a/sys/lib/libkern/libkern.h Thu Apr 05 04:37:43 2001 +0000
+++ b/sys/lib/libkern/libkern.h Thu Apr 05 04:38:06 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libkern.h,v 1.32 2000/11/01 19:37:18 thorpej Exp $     */
+/*     $NetBSD: libkern.h,v 1.33 2001/04/05 04:38:06 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -55,6 +55,16 @@
 LIBKERN_INLINE u_long ulmin __P((u_long, u_long)) __attribute__ ((unused));
 LIBKERN_INLINE int abs __P((int)) __attribute__ ((unused));
 
+LIBKERN_INLINE int isspace __P((int)) __attribute__((__unused__));
+LIBKERN_INLINE int isascii __P((int)) __attribute__((__unused__));
+LIBKERN_INLINE int isupper __P((int)) __attribute__((__unused__));
+LIBKERN_INLINE int islower __P((int)) __attribute__((__unused__));
+LIBKERN_INLINE int isalpha __P((int)) __attribute__((__unused__));
+LIBKERN_INLINE int isdigit __P((int)) __attribute__((__unused__));
+LIBKERN_INLINE int isxdigit __P((int)) __attribute__((__unused__));
+LIBKERN_INLINE int toupper __P((int)) __attribute__((__unused__));
+LIBKERN_INLINE int tolower __P((int)) __attribute__((__unused__));
+
 #ifdef LIBKERN_BODY
 LIBKERN_INLINE int
 imax(a, b)
@@ -111,6 +121,84 @@
 {
        return(j < 0 ? -j : j);
 }
+
+LIBKERN_INLINE int
+isspace(ch)
+       int ch;
+{
+
+       return (ch == ' ' || (ch >= '\t' && ch <= '\r'));
+}
+
+LIBKERN_INLINE int
+isascii(ch)
+       int ch;
+{
+
+       return ((ch & ~0x7f) == 0);
+}
+
+LIBKERN_INLINE int
+isupper(ch)
+       int ch;
+{
+
+       return (ch >= 'A' && ch <= 'Z');
+}
+
+LIBKERN_INLINE int
+islower(ch)
+       int ch;
+{
+
+       return (ch >= 'a' && ch <= 'z');
+}
+
+LIBKERN_INLINE int
+isalpha(ch)
+       int ch;
+{
+
+       return (isupper(ch) || islower(ch));
+}
+
+LIBKERN_INLINE int
+isdigit(ch)
+       int ch;
+{
+
+       return (ch >= '0' && ch <= '9');
+}
+
+LIBKERN_INLINE int
+isxdigit(ch)
+       int ch;
+{
+
+       return (isdigit(ch) ||
+           (ch >= 'A' && ch <= 'F') ||
+           (ch >= 'a' && ch <= 'f'));
+}
+
+LIBKERN_INLINE int
+toupper(ch)
+       int ch;
+{
+
+       if (islower(ch))
+               return (ch - 0x20);
+       return (ch);
+}
+
+LIBKERN_INLINE int
+tolower(ch)
+       int ch;
+{
+
+       if (isupper(ch))
+               return (ch + 0x20);
+       return (ch);
+}
 #endif
 
 #ifdef NDEBUG                                          /* tradition! */



Home | Main Index | Thread Index | Old Index