#41 *Fixed a locale issue.
This commit is contained in:
parent
1094cadc55
commit
dbd7acdc9d
@ -161,14 +161,6 @@ extern "C" {
|
|||||||
# define _LAMBDA_NAME_MAX_LENGTH 32
|
# define _LAMBDA_NAME_MAX_LENGTH 32
|
||||||
#endif /* _LAMBDA_NAME_MAX_LENGTH */
|
#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 */
|
/* Helper */
|
||||||
#ifdef MB_COMPACT_MODE
|
#ifdef MB_COMPACT_MODE
|
||||||
# define _PACK1 : 1
|
# define _PACK1 : 1
|
||||||
@ -4888,18 +4880,12 @@ static mb_input_func_t _get_inputer(mb_interpreter_t* s) {
|
|||||||
/* Print a string */
|
/* Print a string */
|
||||||
static void _print_string(mb_interpreter_t* s, _object_t* obj) {
|
static void _print_string(mb_interpreter_t* s, _object_t* obj) {
|
||||||
#if defined MB_CP_VC && defined MB_ENABLE_UNICODE
|
#if defined MB_CP_VC && defined MB_ENABLE_UNICODE
|
||||||
#if _LOCALIZATION_USEING
|
|
||||||
char* loc = 0;
|
|
||||||
#endif /* _LOCALIZATION_USEING */
|
|
||||||
char* str = 0;
|
char* str = 0;
|
||||||
_dynamic_buffer_t buf;
|
_dynamic_buffer_t buf;
|
||||||
size_t lbuf = 0;
|
size_t lbuf = 0;
|
||||||
|
|
||||||
mb_assert(s && obj);
|
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;
|
str = obj->data.string ? obj->data.string : MB_NULL_STRING;
|
||||||
_INIT_BUF(buf);
|
_INIT_BUF(buf);
|
||||||
while((lbuf = (size_t)mb_bytes_to_wchar(str, &_WCHAR_BUF_PTR(buf), _WCHARS_OF_BUF(buf))) > _WCHARS_OF_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));
|
_get_printer(s)("%ls", _WCHAR_BUF_PTR(buf));
|
||||||
_DISPOSE_BUF(buf);
|
_DISPOSE_BUF(buf);
|
||||||
#if _LOCALIZATION_USEING
|
|
||||||
setlocale(LC_ALL, loc);
|
|
||||||
#endif /* _LOCALIZATION_USEING */
|
|
||||||
#else /* MB_CP_VC && MB_ENABLE_UNICODE */
|
#else /* MB_CP_VC && MB_ENABLE_UNICODE */
|
||||||
mb_assert(s && obj);
|
mb_assert(s && obj);
|
||||||
|
|
||||||
|
@ -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
|
#if defined MB_CP_VC && defined MB_ENABLE_UNICODE
|
||||||
wchar_t wstr[16];
|
wchar_t wstr[16];
|
||||||
wchar_t* wstrp = wstr;
|
wchar_t* wstrp = wstr;
|
||||||
char* loc = setlocale(LC_ALL, "");
|
|
||||||
_bytes_to_wchar(ln, &wstrp, countof(wstr));
|
_bytes_to_wchar(ln, &wstrp, countof(wstr));
|
||||||
_printf(nl ? "%ld]%ls\n" : "%ld]%ls", l, wstrp);
|
_printf(nl ? "%ld]%ls\n" : "%ld]%ls", l, wstrp);
|
||||||
if(wstrp != wstr)
|
if(wstrp != wstr)
|
||||||
free(wstrp);
|
free(wstrp);
|
||||||
setlocale(LC_ALL, loc);
|
|
||||||
#else /* MB_CP_VC && MB_ENABLE_UNICODE */
|
#else /* MB_CP_VC && MB_ENABLE_UNICODE */
|
||||||
_printf(nl ? "%ld]%s\n" : "%ld]%s", l, ln);
|
_printf(nl ? "%ld]%s\n" : "%ld]%s", l, ln);
|
||||||
#endif /* MB_CP_VC && MB_ENABLE_UNICODE */
|
#endif /* MB_CP_VC && MB_ENABLE_UNICODE */
|
||||||
@ -1514,6 +1512,10 @@ static void _on_startup(void) {
|
|||||||
srand((unsigned)_ticks());
|
srand((unsigned)_ticks());
|
||||||
#endif /* _HAS_TICKS */
|
#endif /* _HAS_TICKS */
|
||||||
|
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
|
setlocale(LC_NUMERIC, "C");
|
||||||
|
setlocale(LC_TIME, "C");
|
||||||
|
|
||||||
mb_init();
|
mb_init();
|
||||||
|
|
||||||
mb_open(&bas);
|
mb_open(&bas);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user