aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/include/stdlib.h2
-rw-r--r--libc/stdlib.c14
2 files changed, 16 insertions, 0 deletions
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 95c7915..f55f0f5 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -22,6 +22,8 @@ int abs(int);
void *malloc(size_t);
int snprintf(char*, int, const char*, ...);
void assert_fail(const char*, const char*, int);
+int toupper(int);
+int tolower(int);
#define assert(x) if(!(x))assert_fail(__func__, __FILE__, __LINE__);
diff --git a/libc/stdlib.c b/libc/stdlib.c
index 4301618..d1d357e 100644
--- a/libc/stdlib.c
+++ b/libc/stdlib.c
@@ -161,3 +161,17 @@ void assert_fail(const char *func, const char *file, int line)
printf("\nAssertion failed in function %s in file %s, line %d\n", func, file, line);
panic("assertion failed!\n");
}
+
+int toupper(int ch)
+{
+ if('a' <= ch && ch <= 'z')
+ return ch ^ (1<<5);
+ return ch;
+}
+
+int tolower(int ch)
+{
+ if('A' <= ch && ch <= 'Z')
+ return ch ^ (1<<5);
+ return ch;
+}