[hackers] [scc] [libc] Add setlocale() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 17 Feb 2017 10:58:05 +0100 (CET)

commit 3e07be687a8be2c7feaacbf3d9b4e1f53bfa93e8
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Feb 17 10:57:35 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
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
_AT_@ -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
_AT_@ -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
_AT_@ -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;
+}
Received on Fri Feb 17 2017 - 10:58:05 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 17 2017 - 11:01:15 CET