From b1ed7910f008b82c202e31a24c3ef4e5bf41d5f6 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 19 Oct 2016 05:54:20 -1000 Subject: [PATCH] Allows c++ code to compile with or without CONFIG_LIBC_LOCALE and will generate a link error if CONFIG_LIBC_LOCALE is not defined and setlocale is referneced. With CONFIG_LIBC_LOCALE defined setlocale will act as if MB string is not supported and return "C" for POSIX. C and "" --- include/cxx/clocale | 3 +-- include/locale.h | 3 --- libc/locale/lib_setlocale.c | 5 +++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/cxx/clocale b/include/cxx/clocale index 39d691e484..154bf8040a 100644 --- a/include/cxx/clocale +++ b/include/cxx/clocale @@ -46,11 +46,10 @@ // Namespace //*************************************************************************** -#ifdef CONFIG_LIBC_LOCALE namespace std { using ::setlocale; + using ::localeconv; } -#endif #endif // __INCLUDE_CXX_CLOCALE diff --git a/include/locale.h b/include/locale.h index 501990dbaa..16923e4a3d 100644 --- a/include/locale.h +++ b/include/locale.h @@ -43,8 +43,6 @@ #include #include -#ifdef CONFIG_LIBC_LOCALE - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -109,5 +107,4 @@ FAR struct lconv *localeconv(void); } #endif -#endif /* CONFIG_LIBC_LOCALE */ #endif /* __INCLUDE_LOCALE_H */ diff --git a/libc/locale/lib_setlocale.c b/libc/locale/lib_setlocale.c index 335eda84e4..fbd621a110 100644 --- a/libc/locale/lib_setlocale.c +++ b/libc/locale/lib_setlocale.c @@ -43,6 +43,7 @@ #include #ifdef CONFIG_LIBC_LOCALE +#include /**************************************************************************** * Public Functions @@ -62,8 +63,8 @@ FAR char *setlocale(int category, FAR const char *locale) { - /* NULL indicates the the locale was not changed */ - return NULL; + return ((strcmp (locale, "POSIX") == 0 || strcmp (locale, "C") == 0 || + strcmp (locale, "") == 0) ? "C" : NULL); } #endif