/* * Get the lconv fields. */ static int __cdecl _get_lc_lconv ( struct lconv *l ) { int ret = 0; /* Currency is country--not language--dependent. NT work-around. */ LCID ctryid=MAKELCID(__lc_id[LC_MONETARY].wCountry, SORT_DEFAULT); if (l == NULL) return -1; ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SINTLSYMBOL, (void *)&l->int_curr_symbol); ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SCURRENCY, (void *)&l->currency_symbol); ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SMONDECIMALSEP, (void *)&l->mon_decimal_point); ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SMONTHOUSANDSEP, (void *)&l->mon_thousands_sep); ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SMONGROUPING, (void *)&l->mon_grouping); fix_grouping(l->mon_grouping); ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SPOSITIVESIGN, (void *)&l->positive_sign); ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SNEGATIVESIGN, (void *)&l->negative_sign); ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_IINTLCURRDIGITS, (void *)&l->int_frac_digits); ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_ICURRDIGITS, (void *)&l->frac_digits); ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_IPOSSYMPRECEDES, (void *)&l->p_cs_precedes); ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_IPOSSEPBYSPACE, (void *)&l->p_sep_by_space); ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_INEGSYMPRECEDES, (void *)&l->n_cs_precedes); ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_INEGSEPBYSPACE, (void *)&l->n_sep_by_space); ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_IPOSSIGNPOSN, (void *)&l->p_sign_posn); ret |= __getlocaleinfo(LC_INT_TYPE, ctryid, LOCALE_INEGSIGNPOSN, (void *)&l->n_sign_posn); return ret; }
int __cdecl __init_numeric ( void ) { #ifdef DLL_FOR_WIN32S #define dec_pnt (_GetPPD()->_ppd_dec_pnt) #define thous_sep (_GetPPD()->_ppd_thous_sep) #define grping (_GetPPD()->_ppd_grping) #else /* ndef DLL_FOR_WIN32S */ static char *dec_pnt = NULL; static char *thous_sep = NULL; static char *grping = NULL; #endif /* DLL_FOR_WIN32S */ int ret = 0; /* Numeric data is country--not language--dependent. NT work-around. */ LCID ctryid = MAKELCID(__lc_id[LC_NUMERIC].wCountry, SORT_DEFAULT); if (__lc_handle[LC_NUMERIC] != _CLOCALEHANDLE) { ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SDECIMAL, (void *)&dec_pnt); ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_STHOUSAND, (void *)&thous_sep); ret |= __getlocaleinfo(LC_STR_TYPE, ctryid, LOCALE_SGROUPING, (void *)&grping); fix_grouping(grping); if (ret) { _free_crt (dec_pnt); _free_crt (thous_sep); _free_crt (grping); dec_pnt = NULL; thous_sep = NULL; grping = NULL; return -1; } if (__lconv->decimal_point != __lconv_static_decimal) { _free_crt(__lconv->decimal_point); _free_crt(__lconv->thousands_sep); _free_crt(__lconv->grouping); } __lconv->decimal_point = dec_pnt; __lconv->thousands_sep = thous_sep; __lconv->grouping = grping; /* set global decimal point character */ *__decimal_point = *__lconv->decimal_point; __decimal_point_length = 1; return 0; } else { _free_crt (dec_pnt); _free_crt (thous_sep); _free_crt (grping); dec_pnt = NULL; thous_sep = NULL; grping = NULL; /* malloc them so we can free them */ if ((__lconv->decimal_point = _malloc_crt(2)) == NULL) return -1; strcpy(__lconv->decimal_point, "."); if ((__lconv->thousands_sep = _malloc_crt(2)) == NULL) return -1; __lconv->thousands_sep[0] = '\0'; if ((__lconv->grouping = _malloc_crt(2)) == NULL) return -1; __lconv->grouping[0] = '\0'; /* set global decimal point character */ *__decimal_point = *__lconv->decimal_point; __decimal_point_length = 1; return 0; } }
int __cdecl __init_monetary ( pthreadlocinfo ploci ) { struct lconv *lc; int ret; LCID ctryid; int *lc_refcount; int *lconv_mon_refcount = NULL; _locale_tstruct locinfo; locinfo.locinfo = ploci; locinfo.mbcinfo = 0; if ( (ploci->lc_handle[LC_MONETARY] != _CLOCALEHANDLE) || (ploci->lc_handle[LC_NUMERIC] != _CLOCALEHANDLE) ) { /* * Allocate structure filled with NULL pointers */ if ( (lc = (struct lconv *) _calloc_crt(1, sizeof(struct lconv))) == NULL ) return 1; /* * Allocate a new reference counter for the lconv structure */ if ( (lc_refcount = _malloc_crt(sizeof(int))) == NULL ) { _free_crt(lc); return 1; } *lc_refcount = 0; if ( ploci->lc_handle[LC_MONETARY] != _CLOCALEHANDLE ) { /* * Allocate a new reference counter for the numeric info */ if ( (lconv_mon_refcount = _malloc_crt(sizeof(int))) == NULL ) { _free_crt(lc); _free_crt(lc_refcount); return 1; } *lconv_mon_refcount = 0; /* * Currency is country--not language--dependent. NT * work-around. */ ctryid = MAKELCID(ploci->lc_id[LC_MONETARY].wCountry, SORT_DEFAULT); ret = 0; ret |= __getlocaleinfo(&locinfo, LC_STR_TYPE, ctryid, LOCALE_SINTLSYMBOL, (void *)&lc->int_curr_symbol ); ret |= __getlocaleinfo(&locinfo, LC_STR_TYPE, ctryid, LOCALE_SCURRENCY, (void *)&lc->currency_symbol ); ret |= __getlocaleinfo(&locinfo, LC_STR_TYPE, ctryid, LOCALE_SMONDECIMALSEP, (void *)&lc->mon_decimal_point ); ret |= __getlocaleinfo(&locinfo, LC_STR_TYPE, ctryid, LOCALE_SMONTHOUSANDSEP, (void *)&lc->mon_thousands_sep ); ret |= __getlocaleinfo(&locinfo, LC_STR_TYPE, ctryid, LOCALE_SMONGROUPING, (void *)&lc->mon_grouping ); ret |= __getlocaleinfo(&locinfo, LC_STR_TYPE, ctryid, LOCALE_SPOSITIVESIGN, (void *)&lc->positive_sign); ret |= __getlocaleinfo(&locinfo, LC_STR_TYPE, ctryid, LOCALE_SNEGATIVESIGN, (void *)&lc->negative_sign); ret |= __getlocaleinfo(&locinfo, LC_INT_TYPE, ctryid, LOCALE_IINTLCURRDIGITS, (void *)&lc->int_frac_digits); ret |= __getlocaleinfo(&locinfo, LC_INT_TYPE, ctryid, LOCALE_ICURRDIGITS, (void *)&lc->frac_digits); ret |= __getlocaleinfo(&locinfo, LC_INT_TYPE, ctryid, LOCALE_IPOSSYMPRECEDES, (void *)&lc->p_cs_precedes); ret |= __getlocaleinfo(&locinfo, LC_INT_TYPE, ctryid, LOCALE_IPOSSEPBYSPACE, (void *)&lc->p_sep_by_space); ret |= __getlocaleinfo(&locinfo, LC_INT_TYPE, ctryid, LOCALE_INEGSYMPRECEDES, (void *)&lc->n_cs_precedes); ret |= __getlocaleinfo(&locinfo, LC_INT_TYPE, ctryid, LOCALE_INEGSEPBYSPACE, (void *)&lc->n_sep_by_space); ret |= __getlocaleinfo(&locinfo, LC_INT_TYPE, ctryid, LOCALE_IPOSSIGNPOSN, (void *)&lc->p_sign_posn); ret |= __getlocaleinfo(&locinfo, LC_INT_TYPE, ctryid, LOCALE_INEGSIGNPOSN, (void *)&lc->n_sign_posn); if ( ret != 0 ) { __free_lconv_mon(lc); _free_crt(lc); _free_crt(lc_refcount); _free_crt(lconv_mon_refcount); return 1; } fix_grouping(lc->mon_grouping); } else { /* * C locale for monetary category (the numeric category fields, * which are NOT of the C locale, get fixed up below). Note * that __lconv_c is copied, rather than directly assigning * the fields of lc because of the uncertainty of the values of * the int_frac_digits,..., n_sign_posn fields (SCHAR_MAX or * UCHAR_MAX, depending on whether or a compliand was built * with -J. */ *lc = __lconv_c; } /* * Copy the numeric locale fields from the old struct */ lc->decimal_point = ploci->lconv->decimal_point; lc->thousands_sep = ploci->lconv->thousands_sep; lc->grouping = ploci->lconv->grouping; *lc_refcount = 1; if (lconv_mon_refcount) *lconv_mon_refcount = 1; } else { /* * C locale for BOTH monetary and numeric categories. */ lconv_mon_refcount = NULL; lc_refcount = NULL; lc = &__lconv_c; /* point to new one */ } if ( (ploci->lconv_mon_refcount != NULL) && (InterlockedDecrement(ploci->lconv_mon_refcount) == 0)) { _ASSERTE(ploci->lconv_mon_refcount > 0); } if ( (ploci->lconv_intl_refcount != NULL) && (InterlockedDecrement(ploci->lconv_intl_refcount) == 0)) { _free_crt(ploci->lconv); _free_crt(ploci->lconv_intl_refcount); } ploci->lconv_mon_refcount = lconv_mon_refcount; ploci->lconv_intl_refcount = lc_refcount; ploci->lconv = lc; /* point to new one */ return 0; }