greatbridf 2 лет назад
Родитель
Сommit
c4c0936a8f
3 измененных файлов с 44 добавлено и 0 удалено
  1. 1 0
      gblibc/CMakeLists.txt
  2. 18 0
      gblibc/include/ctype.h
  3. 25 0
      gblibc/src/ctype.c

+ 1 - 0
gblibc/CMakeLists.txt

@@ -11,6 +11,7 @@ add_library(gblibc STATIC
     src/wait.c
     src/assert.c
     src/dirent.c
+    src/ctype.c
 )
 
 file(GLOB_RECURSE GBLIBC_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include)

+ 18 - 0
gblibc/include/ctype.h

@@ -0,0 +1,18 @@
+#ifndef __GBLIBC_CTYPE_H_
+#define __GBLIBC_CTYPE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int islower(int c);
+int isupper(int c);
+
+int tolower(int c);
+int toupper(int c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

+ 25 - 0
gblibc/src/ctype.c

@@ -0,0 +1,25 @@
+#include <ctype.h>
+
+int islower(int c)
+{
+    return c >= 'a' && c <= 'z';
+}
+
+int isupper(int c)
+{
+    return c >= 'A' && c <= 'Z';
+}
+
+int tolower(int c)
+{
+    if (isupper(c))
+        return c - 'A' + 'a';
+    return c;
+}
+
+int toupper(int c)
+{
+    if (islower(c))
+        return c - 'a' + 'A';
+    return c;
+}