locale.in.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /* A POSIX <locale.h>.
  2. Copyright (C) 2007-2023 Free Software Foundation, Inc.
  3. This file is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as
  5. published by the Free Software Foundation; either version 2.1 of the
  6. License, or (at your option) any later version.
  7. This file is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  13. #if __GNUC__ >= 3
  14. @PRAGMA_SYSTEM_HEADER@
  15. #endif
  16. @PRAGMA_COLUMNS@
  17. #if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
  18. || defined _GL_ALREADY_INCLUDING_LOCALE_H
  19. /* Special invocation convention:
  20. - Inside mingw header files,
  21. - To handle Solaris header files (through Solaris 10) when combined
  22. with gettext's libintl.h. */
  23. #@INCLUDE_NEXT@ @NEXT_LOCALE_H@
  24. #else
  25. /* Normal invocation convention. */
  26. #ifndef _@GUARD_PREFIX@_LOCALE_H
  27. #define _GL_ALREADY_INCLUDING_LOCALE_H
  28. /* The include_next requires a split double-inclusion guard. */
  29. #@INCLUDE_NEXT@ @NEXT_LOCALE_H@
  30. #undef _GL_ALREADY_INCLUDING_LOCALE_H
  31. #ifndef _@GUARD_PREFIX@_LOCALE_H
  32. #define _@GUARD_PREFIX@_LOCALE_H
  33. /* NetBSD 5.0 mis-defines NULL. */
  34. #include <stddef.h>
  35. /* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
  36. #if @HAVE_XLOCALE_H@
  37. # include <xlocale.h>
  38. #endif
  39. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  40. /* The definition of _GL_ARG_NONNULL is copied here. */
  41. /* The definition of _GL_WARN_ON_USE is copied here. */
  42. /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
  43. On systems that don't define it, use the same value as GNU libintl. */
  44. #if !defined LC_MESSAGES
  45. # define LC_MESSAGES 1729
  46. #endif
  47. /* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and
  48. int_n_*. Instead of overriding 'struct lconv', merely define these member
  49. names as macros. This avoids trouble in C++ mode. */
  50. #if defined _MSC_VER
  51. # define int_p_cs_precedes p_cs_precedes
  52. # define int_p_sign_posn p_sign_posn
  53. # define int_p_sep_by_space p_sep_by_space
  54. # define int_n_cs_precedes n_cs_precedes
  55. # define int_n_sign_posn n_sign_posn
  56. # define int_n_sep_by_space n_sep_by_space
  57. #endif
  58. /* Bionic libc's 'struct lconv' is just a dummy. */
  59. #if @REPLACE_STRUCT_LCONV@
  60. # define lconv rpl_lconv
  61. struct lconv
  62. {
  63. /* All 'char *' are actually 'const char *'. */
  64. /* Members that depend on the LC_NUMERIC category of the locale. See
  65. <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
  66. /* Symbol used as decimal point. */
  67. char *decimal_point;
  68. /* Symbol used to separate groups of digits to the left of the decimal
  69. point. */
  70. char *thousands_sep;
  71. /* Definition of the size of groups of digits to the left of the decimal
  72. point. */
  73. char *grouping;
  74. /* Members that depend on the LC_MONETARY category of the locale. See
  75. <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
  76. /* Symbol used as decimal point. */
  77. char *mon_decimal_point;
  78. /* Symbol used to separate groups of digits to the left of the decimal
  79. point. */
  80. char *mon_thousands_sep;
  81. /* Definition of the size of groups of digits to the left of the decimal
  82. point. */
  83. char *mon_grouping;
  84. /* Sign used to indicate a value >= 0. */
  85. char *positive_sign;
  86. /* Sign used to indicate a value < 0. */
  87. char *negative_sign;
  88. /* For formatting local currency. */
  89. /* Currency symbol (3 characters) followed by separator (1 character). */
  90. char *currency_symbol;
  91. /* Number of digits after the decimal point. */
  92. char frac_digits;
  93. /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
  94. comes after the number. */
  95. char p_cs_precedes;
  96. /* For values >= 0: Position of the sign. */
  97. char p_sign_posn;
  98. /* For values >= 0: Placement of spaces between currency symbol, sign, and
  99. number. */
  100. char p_sep_by_space;
  101. /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
  102. comes after the number. */
  103. char n_cs_precedes;
  104. /* For values < 0: Position of the sign. */
  105. char n_sign_posn;
  106. /* For values < 0: Placement of spaces between currency symbol, sign, and
  107. number. */
  108. char n_sep_by_space;
  109. /* For formatting international currency. */
  110. /* Currency symbol (3 characters) followed by separator (1 character). */
  111. char *int_curr_symbol;
  112. /* Number of digits after the decimal point. */
  113. char int_frac_digits;
  114. /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
  115. comes after the number. */
  116. char int_p_cs_precedes;
  117. /* For values >= 0: Position of the sign. */
  118. char int_p_sign_posn;
  119. /* For values >= 0: Placement of spaces between currency symbol, sign, and
  120. number. */
  121. char int_p_sep_by_space;
  122. /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
  123. comes after the number. */
  124. char int_n_cs_precedes;
  125. /* For values < 0: Position of the sign. */
  126. char int_n_sign_posn;
  127. /* For values < 0: Placement of spaces between currency symbol, sign, and
  128. number. */
  129. char int_n_sep_by_space;
  130. };
  131. #endif
  132. #if @GNULIB_LOCALECONV@
  133. # if @REPLACE_LOCALECONV@
  134. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  135. # undef localeconv
  136. # define localeconv rpl_localeconv
  137. # endif
  138. _GL_FUNCDECL_RPL (localeconv, struct lconv *, (void));
  139. _GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
  140. # else
  141. _GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
  142. # endif
  143. # if __GLIBC__ >= 2
  144. _GL_CXXALIASWARN (localeconv);
  145. # endif
  146. #elif @REPLACE_STRUCT_LCONV@
  147. # undef localeconv
  148. # define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
  149. #elif defined GNULIB_POSIXCHECK
  150. # undef localeconv
  151. # if HAVE_RAW_DECL_LOCALECONV
  152. _GL_WARN_ON_USE (localeconv,
  153. "localeconv returns too few information on some platforms - "
  154. "use gnulib module localeconv for portability");
  155. # endif
  156. #endif
  157. #if @GNULIB_SETLOCALE@
  158. # if @REPLACE_SETLOCALE@
  159. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  160. # undef setlocale
  161. # define setlocale rpl_setlocale
  162. # define GNULIB_defined_setlocale 1
  163. # endif
  164. _GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale));
  165. _GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
  166. # else
  167. _GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
  168. # endif
  169. # if __GLIBC__ >= 2
  170. _GL_CXXALIASWARN (setlocale);
  171. # endif
  172. #elif defined GNULIB_POSIXCHECK
  173. # undef setlocale
  174. # if HAVE_RAW_DECL_SETLOCALE
  175. _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
  176. "use gnulib module setlocale for portability");
  177. # endif
  178. #endif
  179. #if @GNULIB_SETLOCALE_NULL@
  180. /* Included here for convenience. */
  181. # include "setlocale_null.h"
  182. #endif
  183. #if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_NEWLOCALE@)
  184. # if @REPLACE_NEWLOCALE@
  185. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  186. # undef newlocale
  187. # define newlocale rpl_newlocale
  188. # define GNULIB_defined_newlocale 1
  189. # endif
  190. _GL_FUNCDECL_RPL (newlocale, locale_t,
  191. (int category_mask, const char *name, locale_t base)
  192. _GL_ARG_NONNULL ((2)));
  193. _GL_CXXALIAS_RPL (newlocale, locale_t,
  194. (int category_mask, const char *name, locale_t base));
  195. # else
  196. # if @HAVE_NEWLOCALE@
  197. _GL_CXXALIAS_SYS (newlocale, locale_t,
  198. (int category_mask, const char *name, locale_t base));
  199. # endif
  200. # endif
  201. # if @HAVE_NEWLOCALE@
  202. _GL_CXXALIASWARN (newlocale);
  203. # endif
  204. # if @HAVE_NEWLOCALE@ || @REPLACE_NEWLOCALE@
  205. # ifndef HAVE_WORKING_NEWLOCALE
  206. # define HAVE_WORKING_NEWLOCALE 1
  207. # endif
  208. # endif
  209. #elif defined GNULIB_POSIXCHECK
  210. # undef newlocale
  211. # if HAVE_RAW_DECL_NEWLOCALE
  212. _GL_WARN_ON_USE (newlocale, "newlocale is not portable");
  213. # endif
  214. #endif
  215. #if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@)
  216. # if @REPLACE_DUPLOCALE@
  217. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  218. # undef duplocale
  219. # define duplocale rpl_duplocale
  220. # define GNULIB_defined_duplocale 1
  221. # endif
  222. _GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1)));
  223. _GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
  224. # else
  225. # if @HAVE_DUPLOCALE@
  226. _GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
  227. # endif
  228. # endif
  229. # if @HAVE_DUPLOCALE@
  230. _GL_CXXALIASWARN (duplocale);
  231. # endif
  232. # if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@
  233. # ifndef HAVE_WORKING_DUPLOCALE
  234. # define HAVE_WORKING_DUPLOCALE 1
  235. # endif
  236. # endif
  237. #elif defined GNULIB_POSIXCHECK
  238. # undef duplocale
  239. # if HAVE_RAW_DECL_DUPLOCALE
  240. _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
  241. "use gnulib module duplocale for portability");
  242. # endif
  243. #endif
  244. #if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_FREELOCALE@)
  245. # if @REPLACE_FREELOCALE@
  246. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  247. # undef freelocale
  248. # define freelocale rpl_freelocale
  249. # define GNULIB_defined_freelocale 1
  250. # endif
  251. _GL_FUNCDECL_RPL (freelocale, void, (locale_t locale) _GL_ARG_NONNULL ((1)));
  252. _GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
  253. # else
  254. # if @HAVE_FREELOCALE@
  255. /* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is
  256. int. */
  257. _GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale));
  258. # endif
  259. # endif
  260. # if @HAVE_FREELOCALE@
  261. _GL_CXXALIASWARN (freelocale);
  262. # endif
  263. #elif defined GNULIB_POSIXCHECK
  264. # undef freelocale
  265. # if HAVE_RAW_DECL_FREELOCALE
  266. _GL_WARN_ON_USE (freelocale, "freelocale is not portable");
  267. # endif
  268. #endif
  269. #endif /* _@GUARD_PREFIX@_LOCALE_H */
  270. #endif /* _@GUARD_PREFIX@_LOCALE_H */
  271. #endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */