commit 3e07be687a8be2c7feaacbf3d9b4e1f53bfa93e8
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Fri Feb 17 10:57:35 2017 +0100
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Fri Feb 17 10:57:59 2017 +0100

    [libc] Add setlocale()

diff --git a/libc/include/locale.h b/libc/include/locale.h
new file mode 100644
index 0000000..8c41bc3
--- /dev/null
+++ b/libc/include/locale.h
@@ -0,0 +1,14 @@
+
+#ifndef _LOCALE_H
+#define _LOCALE_H
+
+#define LC_ALL      0
+#define LC_COLLATE  1
+#define LC_CTYPE    2
+#define LC_MONETARY 3
+#define LC_NUMERIC  4
+#define LC_TIME     5
+
+extern char *setlocale(int category, const char *locale);
+
+#endif
diff --git a/libc/src/Makefile b/libc/src/Makefile
index e4a51b7..f5b3a61 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
@@ -3,7 +3,8 @@
 
 LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
           strrchr.o strcat.o strncpy.o strncat.o strcoll.o \
-          memset.o memcpy.o memmove.o memcmp.o memchr.o
+          memset.o memcpy.o memmove.o memcmp.o memchr.o \
+          setlocale.o
 
 all: libc.a
 
diff --git a/libc/src/setlocale.c b/libc/src/setlocale.c
new file mode 100644
index 0000000..09fd5d4
--- /dev/null
+++ b/libc/src/setlocale.c
@@ -0,0 +1,16 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <locale.h>
+
+char *
+setlocale(int category, const char *locale)
+{
+       if (category > LC_TIME || category < LC_ALL)
+               return NULL;
+       if (!locale ||
+           locale[0] == '\0' ||
+           locale[0] == 'C' && locale[1] == '\0') {
+               return "C";
+       }
+       return NULL;
+}

Reply via email to