aboutsummaryrefslogtreecommitdiff
path: root/libc/ctype
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-07-02 15:36:20 +1000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-07-02 15:36:20 +1000
commit1d880992fd8c8457a2d990ac6622cfd58fb1b261 (patch)
treec4c843b12e96b5612c315db5a23c5da1a900618c /libc/ctype
downloadskiboot-1d880992fd8c8457a2d990ac6622cfd58fb1b261.zip
skiboot-1d880992fd8c8457a2d990ac6622cfd58fb1b261.tar.gz
skiboot-1d880992fd8c8457a2d990ac6622cfd58fb1b261.tar.bz2
Initial commit of Open Source release
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'libc/ctype')
-rw-r--r--libc/ctype/Makefile.inc19
-rw-r--r--libc/ctype/isdigit.c26
-rw-r--r--libc/ctype/isprint.c19
-rw-r--r--libc/ctype/isspace.c30
-rw-r--r--libc/ctype/isxdigit.c22
-rw-r--r--libc/ctype/tolower.c19
-rw-r--r--libc/ctype/toupper.c21
7 files changed, 156 insertions, 0 deletions
diff --git a/libc/ctype/Makefile.inc b/libc/ctype/Makefile.inc
new file mode 100644
index 0000000..da78c98
--- /dev/null
+++ b/libc/ctype/Makefile.inc
@@ -0,0 +1,19 @@
+# *****************************************************************************
+# * Copyright (c) 2004, 2008 IBM Corporation
+# * All rights reserved.
+# * This program and the accompanying materials
+# * are made available under the terms of the BSD License
+# * which accompanies this distribution, and is available at
+# * http://www.opensource.org/licenses/bsd-license.php
+# *
+# * Contributors:
+# * IBM Corporation - initial implementation
+# ****************************************************************************/
+
+SUBDIRS += $(LIBCDIR)/ctype
+
+CTYPE_OBJS = isdigit.o isprint.o isspace.o isxdigit.o tolower.o toupper.o
+
+CTYPE = $(LIBCDIR)/ctype/built-in.o
+$(CTYPE): $(CTYPE_OBJS:%=$(LIBCDIR)/ctype/%)
+
diff --git a/libc/ctype/isdigit.c b/libc/ctype/isdigit.c
new file mode 100644
index 0000000..68cd4eb
--- /dev/null
+++ b/libc/ctype/isdigit.c
@@ -0,0 +1,26 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#include <compiler.h>
+#include <ctype.h>
+
+int __attrconst isdigit(int ch)
+{
+ switch (ch) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ return 1;
+
+ default:
+ return 0;
+ }
+}
diff --git a/libc/ctype/isprint.c b/libc/ctype/isprint.c
new file mode 100644
index 0000000..0a7c94c
--- /dev/null
+++ b/libc/ctype/isprint.c
@@ -0,0 +1,19 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#include <compiler.h>
+#include <ctype.h>
+
+int __attrconst isprint(int ch)
+{
+ return (ch >= 32 && ch < 127);
+}
diff --git a/libc/ctype/isspace.c b/libc/ctype/isspace.c
new file mode 100644
index 0000000..f9fa36a
--- /dev/null
+++ b/libc/ctype/isspace.c
@@ -0,0 +1,30 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#include <compiler.h>
+#include <ctype.h>
+
+int __attrconst isspace(int ch)
+{
+ switch (ch) {
+ case ' ':
+ case '\f':
+ case '\n':
+ case '\r':
+ case '\t':
+ case '\v':
+ return 1;
+
+ default:
+ return 0;
+ }
+}
diff --git a/libc/ctype/isxdigit.c b/libc/ctype/isxdigit.c
new file mode 100644
index 0000000..d3c7388
--- /dev/null
+++ b/libc/ctype/isxdigit.c
@@ -0,0 +1,22 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#include <compiler.h>
+#include <ctype.h>
+
+int __attrconst isxdigit(int ch)
+{
+ return (
+ (ch >= '0' && ch <= '9') |
+ (ch >= 'A' && ch <= 'F') |
+ (ch >= 'a' && ch <= 'f') );
+}
diff --git a/libc/ctype/tolower.c b/libc/ctype/tolower.c
new file mode 100644
index 0000000..398a1eb
--- /dev/null
+++ b/libc/ctype/tolower.c
@@ -0,0 +1,19 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#include <compiler.h>
+#include <ctype.h>
+
+int __attrconst tolower(int c)
+{
+ return (((c >= 'A') && (c <= 'Z')) ? (c - 'A' + 'a' ) : c);
+}
diff --git a/libc/ctype/toupper.c b/libc/ctype/toupper.c
new file mode 100644
index 0000000..6b52363
--- /dev/null
+++ b/libc/ctype/toupper.c
@@ -0,0 +1,21 @@
+/******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation
+ * All rights reserved.
+ * This program and the accompanying materials
+ * are made available under the terms of the BSD License
+ * which accompanies this distribution, and is available at
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * IBM Corporation - initial implementation
+ *****************************************************************************/
+
+#include <compiler.h>
+#include "ctype.h"
+
+int __attrconst toupper (int cha)
+{
+ if((cha >= 'a') && (cha <= 'z'))
+ return(cha - 'a' + 'A');
+ return(cha);
+}