scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 0f9d9414cad0c192b62d0c8839fdb7b48692de77
parent 33e066699ac30dd5ce4b1fbffe3c87bb663338ff
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 17 Feb 2017 10:57:35 +0100

[libc] Add setlocale()

Diffstat:
Alibc/include/locale.h | 14++++++++++++++
Mlibc/src/Makefile | 3++-
Alibc/src/setlocale.c | 16++++++++++++++++
3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/libc/include/locale.h 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 @@ -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 @@ -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; +}