X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fposix%2Ffunctions%2F_PDCLIB%2F_PDCLIB_stdinit.c;h=0e562c6a6df8db48f1075fd749f0abf2f05b14ce;hb=b3d54170225e25557110b8c74f236b5e84254c26;hp=3f479f53889860e466e359f368e33171f53b5db1;hpb=ed01ab8d9fcc47f6a4089ef72a73ef7a084d1ed3;p=pdclib.old diff --git a/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c b/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c index 3f479f5..0e562c6 100644 --- a/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c +++ b/platform/posix/functions/_PDCLIB/_PDCLIB_stdinit.c @@ -18,6 +18,7 @@ #ifndef REGTEST #include <_PDCLIB_io.h> #include <_PDCLIB_locale.h> +#include <_PDCLIB_clocale.h> #include /* In a POSIX system, stdin / stdout / stderr are equivalent to the (int) file @@ -79,14 +80,6 @@ FILE * stdout = &_PDCLIB_sout; FILE * stderr = &_PDCLIB_serr; tss_t _PDCLIB_locale_tss; -/* Todo: Better solution than this! */ -__attribute__((constructor)) void init_stdio(void) -{ - tss_create(&_PDCLIB_locale_tss, (tss_dtor_t) freelocale); - mtx_init(&stdin->lock, mtx_recursive); - mtx_init(&stdout->lock, mtx_recursive); - mtx_init(&stderr->lock, mtx_recursive); -} /* FIXME: This approach is a possible attack vector. */ FILE * _PDCLIB_filelist = &_PDCLIB_sin; @@ -356,38 +349,35 @@ _PDCLIB_ctype_t global_ctype[] = { { 0x00, 0xFF, 0xFF, 0xFF } }; -static struct lconv global_lconv = { - /* decimal_point */ (char *)".", - /* thousands_sep */ (char *)"", - /* grouping */ (char *)"", - /* mon_decimal_point */ (char *)"", - /* mon_thousands_sep */ (char *)"", - /* mon_grouping */ (char *)"", - /* positive_sign */ (char *)"", - /* negative_sign */ (char *)"", - /* currency_symbol */ (char *)"", - /* int_curr_symbol */ (char *)"", - /* frac_digits */ CHAR_MAX, - /* p_cs_precedes */ CHAR_MAX, - /* n_cs_precedes */ CHAR_MAX, - /* p_sep_by_space */ CHAR_MAX, - /* n_sep_by_space */ CHAR_MAX, - /* p_sign_posn */ CHAR_MAX, - /* n_sign_posn */ CHAR_MAX, - /* int_frac_digits */ CHAR_MAX, - /* int_p_cs_precedes */ CHAR_MAX, - /* int_n_cs_precedes */ CHAR_MAX, - /* int_p_sep_by_space */ CHAR_MAX, - /* int_n_sep_by_space */ CHAR_MAX, - /* int_p_sign_posn */ CHAR_MAX, - /* int_n_sign_posn */ CHAR_MAX, -}; - extern struct _PDCLIB_charcodec _PDCLIB_ascii_codec; -struct _PDCLIB_locale _PDCLIB_global_locale -= { +struct _PDCLIB_locale _PDCLIB_global_locale = { ._Codec = &_PDCLIB_ascii_codec, - ._Conv = &global_lconv, + ._Conv = { + /* decimal_point */ (char *)".", + /* thousands_sep */ (char *)"", + /* grouping */ (char *)"", + /* mon_decimal_point */ (char *)"", + /* mon_thousands_sep */ (char *)"", + /* mon_grouping */ (char *)"", + /* positive_sign */ (char *)"", + /* negative_sign */ (char *)"", + /* currency_symbol */ (char *)"", + /* int_curr_symbol */ (char *)"", + /* frac_digits */ CHAR_MAX, + /* p_cs_precedes */ CHAR_MAX, + /* n_cs_precedes */ CHAR_MAX, + /* p_sep_by_space */ CHAR_MAX, + /* n_sep_by_space */ CHAR_MAX, + /* p_sign_posn */ CHAR_MAX, + /* n_sign_posn */ CHAR_MAX, + /* int_frac_digits */ CHAR_MAX, + /* int_p_cs_precedes */ CHAR_MAX, + /* int_n_cs_precedes */ CHAR_MAX, + /* int_p_sep_by_space */ CHAR_MAX, + /* int_n_sep_by_space */ CHAR_MAX, + /* int_p_sign_posn */ CHAR_MAX, + /* int_n_sign_posn */ CHAR_MAX, + }, ._CType = &global_ctype[1], ._ErrnoStr = { /* no error */ (char *)"", @@ -397,6 +387,16 @@ struct _PDCLIB_locale _PDCLIB_global_locale }, }; +/* Todo: Better solution than this! */ +__attribute__((constructor)) void init_stdio(void) +{ + _PDCLIB_initclocale( &_PDCLIB_global_locale ); + tss_create(&_PDCLIB_locale_tss, (tss_dtor_t) freelocale); + mtx_init(&stdin->lock, mtx_recursive); + mtx_init(&stdout->lock, mtx_recursive); + mtx_init(&stderr->lock, mtx_recursive); +} + #endif #ifdef TEST