c_locale_glibc2.c
来自「stl的源码」· C语言 代码 · 共 706 行 · 第 1/2 页
C
706 行
#endifsize_t _WLocale_unshift(struct _Locale_codecvt *lcodecvt, mbstate_t *st, char *buf, size_t n, char ** next){ *next = buf; return 0; }/* Collate */int _Locale_strcmp(struct _Locale_collate * __loc, const char *s1, size_t n1, const char *s2, size_t n2) { int ret = 0; char buf1[64], buf2[64]; while (n1 > 0 || n2 > 0) { size_t bufsize1 = n1 < 63 ? n1 : 63; size_t bufsize2 = n2 < 63 ? n2 : 63; strncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0; strncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0; ret = strcoll_l(buf1, buf2, (locale_t)__loc); if (ret != 0) return ret; s1 += bufsize1; n1 -= bufsize1; s2 += bufsize2; n2 -= bufsize2; } return ret;}#if !defined (_STLP_NO_WCHAR_T)int _WLocale_strcmp(struct _Locale_collate *__loc, const wchar_t *s1, size_t n1, const wchar_t *s2, size_t n2) { int ret = 0; wchar_t buf1[64], buf2[64]; while (n1 > 0 || n2 > 0) { size_t bufsize1 = n1 < 63 ? n1 : 63; size_t bufsize2 = n2 < 63 ? n2 : 63; wcsncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0; wcsncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0; ret = wcscoll_l(buf1, buf2, (locale_t)__loc); if (ret != 0) return ret; s1 += bufsize1; n1 -= bufsize1; s2 += bufsize2; n2 -= bufsize2; } return ret;}#endifsize_t _Locale_strxfrm(struct _Locale_collate *__loc, char *dest, size_t dest_n, const char *src, size_t src_n ){ const char *real_src; char *buf = NULL; size_t result; if (src_n == 0) { if (dest != NULL) dest[0] = 0; return 0; } if (src[src_n] != 0) { buf = malloc(src_n + 1); strncpy(buf, src, src_n); buf[src_n] = 0; real_src = buf; } else real_src = src; result = strxfrm_l(dest, real_src, dest_n, (locale_t)__loc); if (buf != NULL) free(buf); return result;}# ifndef _STLP_NO_WCHAR_Tsize_t _WLocale_strxfrm( struct _Locale_collate *__loc, wchar_t *dest, size_t dest_n, const wchar_t *src, size_t src_n ){ const wchar_t *real_src; wchar_t *buf = NULL; size_t result; if (src_n == 0) { if (dest != NULL) dest[0] = 0; return 0; } if (src[src_n] != 0) { buf = malloc((src_n + 1) * sizeof(wchar_t)); wcsncpy(buf, src, src_n); buf[src_n] = 0; real_src = buf; } else real_src = src; result = wcsxfrm_l(dest, real_src, dest_n, (locale_t)__loc); if (buf != NULL) free(buf); return result;}# endif/* Numeric */char _Locale_decimal_point(struct _Locale_numeric *__loc){ return *(nl_langinfo_l(RADIXCHAR, (locale_t)__loc));}char _Locale_thousands_sep(struct _Locale_numeric *__loc){ return *(nl_langinfo_l(THOUSEP, (locale_t)__loc));}const char* _Locale_grouping(struct _Locale_numeric *__loc){ return (_Locale_thousands_sep(__loc) != 0 ) ? (nl_langinfo_l(GROUPING, (locale_t)__loc)) : _empty_str;}const char *_Locale_true(struct _Locale_numeric *__loc){ return nl_langinfo_l(YESSTR, (locale_t)__loc);}const char *_Locale_false(struct _Locale_numeric *__loc){ return nl_langinfo_l(NOSTR, (locale_t)__loc);}#ifndef _STLP_NO_WCHAR_Twchar_t _WLocale_decimal_point(struct _Locale_numeric *__loc){ return (wchar_t)_Locale_decimal_point(__loc); }wchar_t _WLocale_thousands_sep(struct _Locale_numeric *__loc){ return (wchar_t)_Locale_thousands_sep(__loc); }const wchar_t *_WLocale_true(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_true(__loc), buf, bufSize); }const wchar_t *_WLocale_false(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_false(__loc), buf, bufSize); }#endif/* Monetary */const char *_Locale_int_curr_symbol(struct _Locale_monetary *__loc){ return nl_langinfo_l(INT_CURR_SYMBOL, (locale_t)__loc);}const char *_Locale_currency_symbol(struct _Locale_monetary *__loc){ return nl_langinfo_l(CURRENCY_SYMBOL, (locale_t)__loc);}char _Locale_mon_decimal_point(struct _Locale_monetary * __loc){ return *(nl_langinfo_l(MON_DECIMAL_POINT,(locale_t)__loc));}char _Locale_mon_thousands_sep(struct _Locale_monetary *__loc){ return *(nl_langinfo_l(MON_THOUSANDS_SEP, (locale_t)__loc));}#ifndef _STLP_NO_WCHAR_Tconst wchar_t *_WLocale_int_curr_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_int_curr_symbol(__loc), buf, bufSize); }const wchar_t *_WLocale_currency_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_currency_symbol(__loc), buf, bufSize); }wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary * __loc){ return (wchar_t)_Locale_mon_decimal_point(__loc); }wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary * __loc){ return (wchar_t)_Locale_mon_thousands_sep(__loc); }const wchar_t *_WLocale_positive_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_positive_sign(__loc), buf, bufSize); }const wchar_t *_WLocale_negative_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_negative_sign(__loc), buf, bufSize); }#endifconst char *_Locale_mon_grouping(struct _Locale_monetary *__loc){ return (_Locale_mon_thousands_sep( __loc ) != 0 ) ? nl_langinfo_l(MON_GROUPING, (locale_t)__loc) : _empty_str;}const char *_Locale_positive_sign(struct _Locale_monetary *__loc){ return nl_langinfo_l(POSITIVE_SIGN, (locale_t)__loc);}const char *_Locale_negative_sign(struct _Locale_monetary *__loc){ return nl_langinfo_l(NEGATIVE_SIGN, (locale_t)__loc);}char _Locale_int_frac_digits(struct _Locale_monetary *__loc){ /* We are forced to manually handled the "C" locale for consistency with * the default implementation in STLport. */ const char* lname = ((locale_t)__loc)->__names[LC_MONETARY]; if (lname[0] == 'C' && lname[1] == 0) return 0; return *(nl_langinfo_l(INT_FRAC_DIGITS, (locale_t)__loc));}char _Locale_frac_digits(struct _Locale_monetary *__loc){ /* We are forced to manually handled the "C" locale for consistency with * the default implementation in STLport. */ const char* lname = ((locale_t)__loc)->__names[LC_MONETARY]; if (lname[0] == 'C' && lname[1] == 0) return 0; return *(nl_langinfo_l(FRAC_DIGITS, (locale_t)__loc));}/* 1 if currency_symbol precedes a positive value, 0 if succeeds */int _Locale_p_cs_precedes(struct _Locale_monetary *__loc){ return *(nl_langinfo_l(P_CS_PRECEDES, (locale_t)__loc));}/* 1 if a space separates currency_symbol from a positive value. */int _Locale_p_sep_by_space(struct _Locale_monetary *__loc){ return *(nl_langinfo_l(P_SEP_BY_SPACE, (locale_t)__loc));}/* * 0 Parentheses surround the quantity and currency_symbol * 1 The sign string precedes the quantity and currency_symbol * 2 The sign string succeeds the quantity and currency_symbol. * 3 The sign string immediately precedes the currency_symbol. * 4 The sign string immediately succeeds the currency_symbol. */int _Locale_p_sign_posn(struct _Locale_monetary *__loc){ return *(nl_langinfo_l(P_SIGN_POSN, (locale_t)__loc));}/* 1 if currency_symbol precedes a negative value, 0 if succeeds */int _Locale_n_cs_precedes(struct _Locale_monetary *__loc){ return *(nl_langinfo_l(N_CS_PRECEDES, (locale_t)__loc));}/* 1 if a space separates currency_symbol from a negative value. */int _Locale_n_sep_by_space(struct _Locale_monetary *__loc){ return *(nl_langinfo_l(N_SEP_BY_SPACE, (locale_t)__loc));}/* * 0 Parentheses surround the quantity and currency_symbol * 1 The sign string precedes the quantity and currency_symbol * 2 The sign string succeeds the quantity and currency_symbol. * 3 The sign string immediately precedes the currency_symbol. * 4 The sign string immediately succeeds the currency_symbol. */int _Locale_n_sign_posn(struct _Locale_monetary *__loc){ return *(nl_langinfo_l(N_SIGN_POSN, (locale_t)__loc));}/* Time */const char *_Locale_full_monthname(struct _Locale_time *__loc, int _m ){ return nl_langinfo_l(MON_1 + _m, (locale_t)__loc);}const char *_Locale_abbrev_monthname(struct _Locale_time *__loc, int _m ){ return nl_langinfo_l(ABMON_1 + _m, (locale_t)__loc);}const char *_Locale_full_dayofweek(struct _Locale_time *__loc, int _d ){ return nl_langinfo_l(DAY_1 + _d, (locale_t)__loc);}const char *_Locale_abbrev_dayofweek(struct _Locale_time *__loc, int _d ){ return nl_langinfo_l(ABDAY_1 + _d, (locale_t)__loc);}const char *_Locale_d_t_fmt(struct _Locale_time *__loc){ return nl_langinfo_l(D_T_FMT, (locale_t)__loc);}const char *_Locale_d_fmt(struct _Locale_time *__loc ){ return nl_langinfo_l(D_FMT, (locale_t)__loc);}const char *_Locale_t_fmt(struct _Locale_time *__loc ){ return nl_langinfo_l(T_FMT, (locale_t)__loc);}const char *_Locale_long_d_t_fmt(struct _Locale_time *__loc ){ return nl_langinfo_l(ERA_D_T_FMT, (locale_t)__loc);}const char *_Locale_long_d_fmt(struct _Locale_time *__loc ){ return nl_langinfo_l(ERA_D_FMT, (locale_t)__loc);}const char *_Locale_am_str(struct _Locale_time *__loc ){ return nl_langinfo_l(AM_STR, (locale_t)__loc);}const char *_Locale_pm_str(struct _Locale_time* __loc ){ return nl_langinfo_l(PM_STR, (locale_t)__loc);}#ifndef _STLP_NO_WCHAR_Tconst wchar_t *_WLocale_full_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_full_monthname(__loc, _m), buf, bufSize); }const wchar_t *_WLocale_abbrev_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_abbrev_monthname(__loc, _m), buf, bufSize); }const wchar_t *_WLocale_full_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_full_dayofweek(__loc, _d), buf, bufSize); }const wchar_t *_WLocale_abbrev_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_abbrev_dayofweek(__loc, _d), buf, bufSize); }const wchar_t *_WLocale_am_str(struct _Locale_time *__loc, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_am_str(__loc), buf, bufSize); }const wchar_t *_WLocale_pm_str(struct _Locale_time* __loc, wchar_t *buf, size_t bufSize){ return _ToWChar(_Locale_pm_str(__loc), buf, bufSize); }#endif/* Messages */nl_catd_type _Locale_catopen(struct _Locale_messages *__loc, const char *__cat_name ){ return catopen( __cat_name, NL_CAT_LOCALE );}void _Locale_catclose(struct _Locale_messages *__loc, nl_catd_type __cat ){ catclose( __cat );}const char *_Locale_catgets(struct _Locale_messages *__loc, nl_catd_type __cat, int __setid, int __msgid, const char *dfault){ return catgets( __cat, __setid, __msgid, dfault );}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?