ref: 3cce2df50df508019c1e511625f13832965ef28a
parent: 09888b185535fa9441accbf7b811974acd6bdeb8
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Feb 17 05:57:35 EST 2017
[libc] Add setlocale()
--- /dev/null
+++ b/libc/include/locale.h
@@ -1,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
--- 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
--- /dev/null
+++ b/libc/src/setlocale.c
@@ -1,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;
+}