From dbd7acdc9d71f533e7066366aaff940a7bc3b1d9 Mon Sep 17 00:00:00 2001 From: Wang Renxin Date: Fri, 12 Mar 2021 13:46:00 +0800 Subject: [PATCH] #41 *Fixed a locale issue. --- core/my_basic.c | 17 ----------------- shell/main.c | 6 ++++-- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/core/my_basic.c b/core/my_basic.c index 63b8d27..6eb26c8 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -161,14 +161,6 @@ extern "C" { # define _LAMBDA_NAME_MAX_LENGTH 32 #endif /* _LAMBDA_NAME_MAX_LENGTH */ -/* Localization specifier */ -#ifndef _LOCALIZATION_USEING -# define _LOCALIZATION_USEING 1 -#endif /* _LOCALIZATION_USEING */ -#ifndef _LOCALIZATION_STR -# define _LOCALIZATION_STR "" -#endif /* _LOCALIZATION_STR */ - /* Helper */ #ifdef MB_COMPACT_MODE # define _PACK1 : 1 @@ -4888,18 +4880,12 @@ static mb_input_func_t _get_inputer(mb_interpreter_t* s) { /* Print a string */ static void _print_string(mb_interpreter_t* s, _object_t* obj) { #if defined MB_CP_VC && defined MB_ENABLE_UNICODE -#if _LOCALIZATION_USEING - char* loc = 0; -#endif /* _LOCALIZATION_USEING */ char* str = 0; _dynamic_buffer_t buf; size_t lbuf = 0; mb_assert(s && obj); -#if _LOCALIZATION_USEING - loc = setlocale(LC_ALL, _LOCALIZATION_STR); -#endif /* _LOCALIZATION_USEING */ str = obj->data.string ? obj->data.string : MB_NULL_STRING; _INIT_BUF(buf); while((lbuf = (size_t)mb_bytes_to_wchar(str, &_WCHAR_BUF_PTR(buf), _WCHARS_OF_BUF(buf))) > _WCHARS_OF_BUF(buf)) { @@ -4907,9 +4893,6 @@ static void _print_string(mb_interpreter_t* s, _object_t* obj) { } _get_printer(s)("%ls", _WCHAR_BUF_PTR(buf)); _DISPOSE_BUF(buf); -#if _LOCALIZATION_USEING - setlocale(LC_ALL, loc); -#endif /* _LOCALIZATION_USEING */ #else /* MB_CP_VC && MB_ENABLE_UNICODE */ mb_assert(s && obj); diff --git a/shell/main.c b/shell/main.c index 2c2ab2c..14f5722 100755 --- a/shell/main.c +++ b/shell/main.c @@ -784,12 +784,10 @@ static void _list_one_line(bool_t nl, long l, const char* ln) { #if defined MB_CP_VC && defined MB_ENABLE_UNICODE wchar_t wstr[16]; wchar_t* wstrp = wstr; - char* loc = setlocale(LC_ALL, ""); _bytes_to_wchar(ln, &wstrp, countof(wstr)); _printf(nl ? "%ld]%ls\n" : "%ld]%ls", l, wstrp); if(wstrp != wstr) free(wstrp); - setlocale(LC_ALL, loc); #else /* MB_CP_VC && MB_ENABLE_UNICODE */ _printf(nl ? "%ld]%s\n" : "%ld]%s", l, ln); #endif /* MB_CP_VC && MB_ENABLE_UNICODE */ @@ -1514,6 +1512,10 @@ static void _on_startup(void) { srand((unsigned)_ticks()); #endif /* _HAS_TICKS */ + setlocale(LC_ALL, ""); + setlocale(LC_NUMERIC, "C"); + setlocale(LC_TIME, "C"); + mb_init(); mb_open(&bas);