0013-eglibc-Forward-port-cross-locale-generation-support.patch 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. From 2c6449014151a4bcd4b253b2acc920f0b3d6b13f Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Wed, 18 Mar 2015 01:33:49 +0000
  4. Subject: [PATCH] eglibc: Forward port cross locale generation support
  5. Upstream-Status: Pending
  6. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  7. ---
  8. locale/Makefile | 3 +-
  9. locale/catnames.c | 46 +++++++++++++++++++++++++++
  10. locale/localeinfo.h | 2 +-
  11. locale/programs/charmap-dir.c | 6 ++++
  12. locale/programs/ld-collate.c | 17 +++++-----
  13. locale/programs/ld-ctype.c | 27 ++++++++--------
  14. locale/programs/ld-time.c | 31 ++++++++++++------
  15. locale/programs/linereader.c | 2 +-
  16. locale/programs/localedef.c | 8 +++++
  17. locale/programs/locfile.c | 5 ++-
  18. locale/programs/locfile.h | 59 +++++++++++++++++++++++++++++++++--
  19. locale/setlocale.c | 29 -----------------
  20. 12 files changed, 167 insertions(+), 68 deletions(-)
  21. create mode 100644 locale/catnames.c
  22. diff --git a/locale/Makefile b/locale/Makefile
  23. index eb55750496..b0461ac4b9 100644
  24. --- a/locale/Makefile
  25. +++ b/locale/Makefile
  26. @@ -26,7 +26,8 @@ headers = langinfo.h locale.h bits/locale.h \
  27. bits/types/locale_t.h bits/types/__locale_t.h
  28. routines = setlocale findlocale loadlocale loadarchive \
  29. localeconv nl_langinfo nl_langinfo_l mb_cur_max \
  30. - newlocale duplocale freelocale uselocale
  31. + newlocale duplocale freelocale uselocale \
  32. + catnames
  33. tests = tst-C-locale tst-locname tst-duplocale
  34. tests-container = tst-localedef-path-norm
  35. categories = ctype messages monetary numeric time paper name \
  36. diff --git a/locale/catnames.c b/locale/catnames.c
  37. new file mode 100644
  38. index 0000000000..538f3f5edb
  39. --- /dev/null
  40. +++ b/locale/catnames.c
  41. @@ -0,0 +1,46 @@
  42. +/* Copyright (C) 2006 Free Software Foundation, Inc.
  43. + This file is part of the GNU C Library.
  44. +
  45. + The GNU C Library is free software; you can redistribute it and/or
  46. + modify it under the terms of the GNU Lesser General Public
  47. + License as published by the Free Software Foundation; either
  48. + version 2.1 of the License, or (at your option) any later version.
  49. +
  50. + The GNU C Library is distributed in the hope that it will be useful,
  51. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  52. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  53. + Lesser General Public License for more details.
  54. +
  55. + You should have received a copy of the GNU Lesser General Public
  56. + License along with the GNU C Library; if not, write to the Free
  57. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  58. + 02111-1307 USA. */
  59. +
  60. +#include "localeinfo.h"
  61. +
  62. +/* Define an array of category names (also the environment variable names). */
  63. +const struct catnamestr_t _nl_category_names attribute_hidden =
  64. + {
  65. +#define DEFINE_CATEGORY(category, category_name, items, a) \
  66. + category_name,
  67. +#include "categories.def"
  68. +#undef DEFINE_CATEGORY
  69. + };
  70. +
  71. +const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden =
  72. + {
  73. +#define DEFINE_CATEGORY(category, category_name, items, a) \
  74. + [category] = offsetof (struct catnamestr_t, CATNAMEMF (__LINE__)),
  75. +#include "categories.def"
  76. +#undef DEFINE_CATEGORY
  77. + };
  78. +
  79. +/* An array of their lengths, for convenience. */
  80. +const uint8_t _nl_category_name_sizes[] attribute_hidden =
  81. + {
  82. +#define DEFINE_CATEGORY(category, category_name, items, a) \
  83. + [category] = sizeof (category_name) - 1,
  84. +#include "categories.def"
  85. +#undef DEFINE_CATEGORY
  86. + [LC_ALL] = sizeof ("LC_ALL") - 1
  87. + };
  88. diff --git a/locale/localeinfo.h b/locale/localeinfo.h
  89. index 3dc26272a0..b667d32c23 100644
  90. --- a/locale/localeinfo.h
  91. +++ b/locale/localeinfo.h
  92. @@ -246,7 +246,7 @@ __libc_tsd_define (extern, locale_t, LOCALE)
  93. unused. We can manage this playing some tricks with weak references.
  94. But with thread-local locale settings, it becomes quite ungainly unless
  95. we can use __thread variables. So only in that case do we attempt this. */
  96. -#ifndef SHARED
  97. +#if !defined SHARED && !defined IN_GLIBC_LOCALEDEF
  98. # include <tls.h>
  99. # define NL_CURRENT_INDIRECT 1
  100. #endif
  101. diff --git a/locale/programs/charmap-dir.c b/locale/programs/charmap-dir.c
  102. index 396a0d76c0..91f4a765ee 100644
  103. --- a/locale/programs/charmap-dir.c
  104. +++ b/locale/programs/charmap-dir.c
  105. @@ -18,7 +18,9 @@
  106. #include <errno.h>
  107. #include <fcntl.h>
  108. #include <libintl.h>
  109. +#ifndef NO_UNCOMPRESS
  110. #include <spawn.h>
  111. +#endif
  112. #include <stdio.h>
  113. #include <stdlib.h>
  114. #include <string.h>
  115. @@ -154,6 +156,7 @@ charmap_closedir (CHARMAP_DIR *cdir)
  116. return closedir (dir);
  117. }
  118. +#ifndef NO_UNCOMPRESS
  119. /* Creates a subprocess decompressing the given pathname, and returns
  120. a stream reading its output (the decompressed data). */
  121. static
  122. @@ -202,6 +205,7 @@ fopen_uncompressed (const char *pathname, const char *compressor)
  123. }
  124. return NULL;
  125. }
  126. +#endif
  127. /* Opens a charmap for reading, given its name (not an alias name). */
  128. FILE *
  129. @@ -224,6 +228,7 @@ charmap_open (const char *directory, const char *name)
  130. if (stream != NULL)
  131. return stream;
  132. +#ifndef NO_UNCOMPRESS
  133. memcpy (p, ".gz", 4);
  134. stream = fopen_uncompressed (pathname, "gzip");
  135. if (stream != NULL)
  136. @@ -233,6 +238,7 @@ charmap_open (const char *directory, const char *name)
  137. stream = fopen_uncompressed (pathname, "bzip2");
  138. if (stream != NULL)
  139. return stream;
  140. +#endif
  141. return NULL;
  142. }
  143. diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
  144. index 992814491d..da4dde4663 100644
  145. --- a/locale/programs/ld-collate.c
  146. +++ b/locale/programs/ld-collate.c
  147. @@ -352,7 +352,7 @@ new_element (struct locale_collate_t *collate, const char *mbs, size_t mbslen,
  148. }
  149. if (wcs != NULL)
  150. {
  151. - size_t nwcs = wcslen ((wchar_t *) wcs);
  152. + size_t nwcs = wcslen_uint32 (wcs);
  153. uint32_t zero = 0;
  154. /* Handle <U0000> as a single character. */
  155. if (nwcs == 0)
  156. @@ -1776,8 +1776,7 @@ symbol `%s' has the same encoding as"), (*eptr)->name);
  157. if ((*eptr)->nwcs == runp->nwcs)
  158. {
  159. - int c = wmemcmp ((wchar_t *) (*eptr)->wcs,
  160. - (wchar_t *) runp->wcs, runp->nwcs);
  161. + int c = wmemcmp_uint32 ((*eptr)->wcs, runp->wcs, runp->nwcs);
  162. if (c == 0)
  163. {
  164. @@ -2004,9 +2003,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp)
  165. one consecutive entry. */
  166. if (runp->wcnext != NULL
  167. && runp->nwcs == runp->wcnext->nwcs
  168. - && wmemcmp ((wchar_t *) runp->wcs,
  169. - (wchar_t *)runp->wcnext->wcs,
  170. - runp->nwcs - 1) == 0
  171. + && wmemcmp_uint32 (runp->wcs,
  172. + runp->wcnext->wcs,
  173. + runp->nwcs - 1) == 0
  174. && (runp->wcs[runp->nwcs - 1]
  175. == runp->wcnext->wcs[runp->nwcs - 1] + 1))
  176. {
  177. @@ -2030,9 +2029,9 @@ add_to_tablewc (uint32_t ch, struct element_t *runp)
  178. runp = runp->wcnext;
  179. while (runp->wcnext != NULL
  180. && runp->nwcs == runp->wcnext->nwcs
  181. - && wmemcmp ((wchar_t *) runp->wcs,
  182. - (wchar_t *)runp->wcnext->wcs,
  183. - runp->nwcs - 1) == 0
  184. + && wmemcmp_uint32 (runp->wcs,
  185. + runp->wcnext->wcs,
  186. + runp->nwcs - 1) == 0
  187. && (runp->wcs[runp->nwcs - 1]
  188. == runp->wcnext->wcs[runp->nwcs - 1] + 1));
  189. diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
  190. index c6749dbd82..ac99777925 100644
  191. --- a/locale/programs/ld-ctype.c
  192. +++ b/locale/programs/ld-ctype.c
  193. @@ -914,7 +914,7 @@ ctype_output (struct localedef_t *locale, const struct charmap_t *charmap,
  194. allocate_arrays (ctype, charmap, ctype->repertoire);
  195. default_missing_len = (ctype->default_missing
  196. - ? wcslen ((wchar_t *) ctype->default_missing)
  197. + ? wcslen_uint32 (ctype->default_missing)
  198. : 0);
  199. init_locale_data (&file, nelems);
  200. @@ -1926,7 +1926,7 @@ read_translit_entry (struct linereader *ldfile, struct locale_ctype_t *ctype,
  201. ignore = 1;
  202. else
  203. /* This value is usable. */
  204. - obstack_grow (ob, to_wstr, wcslen ((wchar_t *) to_wstr) * 4);
  205. + obstack_grow (ob, to_wstr, wcslen_uint32 (to_wstr) * 4);
  206. first = 0;
  207. }
  208. @@ -2460,8 +2460,8 @@ with character code range values one must use the absolute ellipsis `...'"));
  209. }
  210. handle_tok_digit:
  211. - class_bit = _ISwdigit;
  212. - class256_bit = _ISdigit;
  213. + class_bit = BITw (tok_digit);
  214. + class256_bit = BIT (tok_digit);
  215. handle_digits = 1;
  216. goto read_charclass;
  217. @@ -3876,8 +3876,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
  218. while (idx < number)
  219. {
  220. - int res = wcscmp ((const wchar_t *) sorted[idx]->from,
  221. - (const wchar_t *) runp->from);
  222. + int res = wcscmp_uint32 (sorted[idx]->from, runp->from);
  223. if (res == 0)
  224. {
  225. replace = 1;
  226. @@ -3914,11 +3913,11 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
  227. for (size_t cnt = 0; cnt < number; ++cnt)
  228. {
  229. struct translit_to_t *srunp;
  230. - from_len += wcslen ((const wchar_t *) sorted[cnt]->from) + 1;
  231. + from_len += wcslen_uint32 (sorted[cnt]->from) + 1;
  232. srunp = sorted[cnt]->to;
  233. while (srunp != NULL)
  234. {
  235. - to_len += wcslen ((const wchar_t *) srunp->str) + 1;
  236. + to_len += wcslen_uint32 (srunp->str) + 1;
  237. srunp = srunp->next;
  238. }
  239. /* Plus one for the extra NUL character marking the end of
  240. @@ -3942,18 +3941,18 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
  241. ctype->translit_from_idx[cnt] = from_len;
  242. ctype->translit_to_idx[cnt] = to_len;
  243. - len = wcslen ((const wchar_t *) sorted[cnt]->from) + 1;
  244. - wmemcpy ((wchar_t *) &ctype->translit_from_tbl[from_len],
  245. - (const wchar_t *) sorted[cnt]->from, len);
  246. + len = wcslen_uint32 (sorted[cnt]->from) + 1;
  247. + wmemcpy_uint32 (&ctype->translit_from_tbl[from_len],
  248. + sorted[cnt]->from, len);
  249. from_len += len;
  250. ctype->translit_to_idx[cnt] = to_len;
  251. srunp = sorted[cnt]->to;
  252. while (srunp != NULL)
  253. {
  254. - len = wcslen ((const wchar_t *) srunp->str) + 1;
  255. - wmemcpy ((wchar_t *) &ctype->translit_to_tbl[to_len],
  256. - (const wchar_t *) srunp->str, len);
  257. + len = wcslen_uint32 (srunp->str) + 1;
  258. + wmemcpy_uint32 (&ctype->translit_to_tbl[to_len],
  259. + srunp->str, len);
  260. to_len += len;
  261. srunp = srunp->next;
  262. }
  263. diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c
  264. index b58fecfcee..a4d70e0780 100644
  265. --- a/locale/programs/ld-time.c
  266. +++ b/locale/programs/ld-time.c
  267. @@ -219,8 +219,10 @@ No definition for %s category found"), "LC_TIME");
  268. }
  269. else
  270. {
  271. + static const uint32_t wt_fmt_ampm[]
  272. + = { '%','I',':','%','M',':','%','S',' ','%','p',0 };
  273. time->t_fmt_ampm = "%I:%M:%S %p";
  274. - time->wt_fmt_ampm = (const uint32_t *) L"%I:%M:%S %p";
  275. + time->wt_fmt_ampm = wt_fmt_ampm;
  276. }
  277. }
  278. @@ -230,7 +232,7 @@ No definition for %s category found"), "LC_TIME");
  279. const int days_per_month[12] = { 31, 29, 31, 30, 31, 30,
  280. 31, 31, 30, 31 ,30, 31 };
  281. size_t idx;
  282. - wchar_t *wstr;
  283. + uint32_t *wstr;
  284. time->era_entries =
  285. (struct era_data *) xmalloc (time->num_era
  286. @@ -456,18 +458,18 @@ No definition for %s category found"), "LC_TIME");
  287. }
  288. /* Now generate the wide character name and format. */
  289. - wstr = wcschr ((wchar_t *) time->wera[idx], L':');/* end direction */
  290. - wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end offset */
  291. - wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end start */
  292. - wstr = wstr ? wcschr (wstr + 1, L':') : NULL; /* end end */
  293. + wstr = wcschr_uint32 (time->wera[idx], L':'); /* end direction */
  294. + wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end offset */
  295. + wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end start */
  296. + wstr = wstr ? wcschr_uint32 (wstr + 1, L':') : NULL; /* end end */
  297. if (wstr != NULL)
  298. {
  299. - time->era_entries[idx].wname = (uint32_t *) wstr + 1;
  300. - wstr = wcschr (wstr + 1, L':'); /* end name */
  301. + time->era_entries[idx].wname = wstr + 1;
  302. + wstr = wcschr_uint32 (wstr + 1, L':'); /* end name */
  303. if (wstr != NULL)
  304. {
  305. *wstr = L'\0';
  306. - time->era_entries[idx].wformat = (uint32_t *) wstr + 1;
  307. + time->era_entries[idx].wformat = wstr + 1;
  308. }
  309. else
  310. time->era_entries[idx].wname =
  311. @@ -526,7 +528,16 @@ No definition for %s category found"), "LC_TIME");
  312. if (time->date_fmt == NULL)
  313. time->date_fmt = "%a %b %e %H:%M:%S %Z %Y";
  314. if (time->wdate_fmt == NULL)
  315. - time->wdate_fmt = (const uint32_t *) L"%a %b %e %H:%M:%S %Z %Y";
  316. + {
  317. + static const uint32_t wdate_fmt[] =
  318. + { '%','a',' ',
  319. + '%','b',' ',
  320. + '%','e',' ',
  321. + '%','H',':','%','M',':','%','S',' ',
  322. + '%','Z',' ',
  323. + '%','Y',0 };
  324. + time->wdate_fmt = wdate_fmt;
  325. + }
  326. }
  327. diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c
  328. index 0460074a0c..31a7151f66 100644
  329. --- a/locale/programs/linereader.c
  330. +++ b/locale/programs/linereader.c
  331. @@ -776,7 +776,7 @@ get_string (struct linereader *lr, const struct charmap_t *charmap,
  332. {
  333. int return_widestr = lr->return_widestr;
  334. struct lr_buffer lrb;
  335. - wchar_t *buf2 = NULL;
  336. + uint32_t *buf2 = NULL;
  337. lr_buffer_init (&lrb);
  338. diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
  339. index 35a092a111..94712bf114 100644
  340. --- a/locale/programs/localedef.c
  341. +++ b/locale/programs/localedef.c
  342. @@ -108,6 +108,7 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
  343. #define OPT_NO_WARN 402
  344. #define OPT_WARN 403
  345. #define OPT_NO_HARD_LINKS 404
  346. +#define OPT_UINT32_ALIGN 405
  347. /* Definitions of arguments for argp functions. */
  348. static const struct argp_option options[] =
  349. @@ -152,6 +153,8 @@ static const struct argp_option options[] =
  350. N_("Generate little-endian output") },
  351. { "big-endian", OPT_BIG_ENDIAN, NULL, 0,
  352. N_("Generate big-endian output") },
  353. + { "uint32-align", OPT_UINT32_ALIGN, "ALIGNMENT", 0,
  354. + N_("Set the target's uint32_t alignment in bytes (default 4)") },
  355. { NULL, 0, NULL, 0, NULL }
  356. };
  357. @@ -242,12 +245,14 @@ main (int argc, char *argv[])
  358. ctype locale. (P1003.2 4.35.5.2) */
  359. setlocale (LC_CTYPE, "POSIX");
  360. +#ifndef NO_SYSCONF
  361. /* Look whether the system really allows locale definitions. POSIX
  362. defines error code 3 for this situation so I think it must be
  363. a fatal error (see P1003.2 4.35.8). */
  364. if (sysconf (_SC_2_LOCALEDEF) < 0)
  365. record_error (3, 0, _("\
  366. FATAL: system does not define `_POSIX2_LOCALEDEF'"));
  367. +#endif
  368. /* Process charmap file. */
  369. charmap = charmap_read (charmap_file, verbose, 1, be_quiet, 1);
  370. @@ -399,6 +404,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
  371. /* Do not hard link to other locales. */
  372. hard_links = false;
  373. break;
  374. + case OPT_UINT32_ALIGN:
  375. + uint32_align_mask = strtol (arg, NULL, 0) - 1;
  376. + break;
  377. case 'c':
  378. force_output = 1;
  379. break;
  380. diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c
  381. index 8fa74dce60..8d5aca6d9e 100644
  382. --- a/locale/programs/locfile.c
  383. +++ b/locale/programs/locfile.c
  384. @@ -543,6 +543,9 @@ compare_files (const char *filename1, const char *filename2, size_t size,
  385. machine running localedef. */
  386. bool swap_endianness_p;
  387. +/* The target's value of __align__(uint32_t) - 1. */
  388. +unsigned int uint32_align_mask = 3;
  389. +
  390. /* When called outside a start_locale_structure/end_locale_structure
  391. or start_locale_prelude/end_locale_prelude block, record that the
  392. next byte in FILE's obstack will be the first byte of a new element.
  393. @@ -620,7 +623,7 @@ add_locale_string (struct locale_file *file, const char *string)
  394. void
  395. add_locale_wstring (struct locale_file *file, const uint32_t *string)
  396. {
  397. - add_locale_uint32_array (file, string, wcslen ((const wchar_t *) string) + 1);
  398. + add_locale_uint32_array (file, string, wcslen_uint32 (string) + 1);
  399. }
  400. /* Record that FILE's next element is the 32-bit integer VALUE. */
  401. diff --git a/locale/programs/locfile.h b/locale/programs/locfile.h
  402. index 57b2211e2f..e9498c6c7e 100644
  403. --- a/locale/programs/locfile.h
  404. +++ b/locale/programs/locfile.h
  405. @@ -70,6 +70,8 @@ extern void write_all_categories (struct localedef_t *definitions,
  406. extern bool swap_endianness_p;
  407. +extern unsigned int uint32_align_mask;
  408. +
  409. /* Change the output to be big-endian if BIG_ENDIAN is true and
  410. little-endian otherwise. */
  411. static inline void
  412. @@ -88,7 +90,8 @@ maybe_swap_uint32 (uint32_t value)
  413. }
  414. /* Likewise, but munge an array of N uint32_ts starting at ARRAY. */
  415. -static inline void
  416. +static void
  417. +__attribute__ ((unused))
  418. maybe_swap_uint32_array (uint32_t *array, size_t n)
  419. {
  420. if (swap_endianness_p)
  421. @@ -98,7 +101,8 @@ maybe_swap_uint32_array (uint32_t *array, size_t n)
  422. /* Like maybe_swap_uint32_array, but the array of N elements is at
  423. the end of OBSTACK's current object. */
  424. -static inline void
  425. +static void
  426. +__attribute__ ((unused))
  427. maybe_swap_uint32_obstack (struct obstack *obstack, size_t n)
  428. {
  429. maybe_swap_uint32_array ((uint32_t *) obstack_next_free (obstack) - n, n);
  430. @@ -275,4 +279,55 @@ extern void identification_output (struct localedef_t *locale,
  431. const struct charmap_t *charmap,
  432. const char *output_path);
  433. +static size_t wcslen_uint32 (const uint32_t *str) __attribute__ ((unused));
  434. +static uint32_t * wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused));
  435. +static uint32_t * wcschr_uint32 (const uint32_t *s, uint32_t ch) __attribute__ ((unused));
  436. +static int wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2) __attribute__ ((unused));
  437. +static int wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n) __attribute__ ((unused));
  438. +
  439. +static size_t
  440. +wcslen_uint32 (const uint32_t *str)
  441. +{
  442. + size_t len = 0;
  443. + while (str[len] != 0)
  444. + len++;
  445. + return len;
  446. +}
  447. +
  448. +static int
  449. +wmemcmp_uint32 (const uint32_t *s1, const uint32_t *s2, size_t n)
  450. +{
  451. + while (n-- != 0)
  452. + {
  453. + int diff = *s1++ - *s2++;
  454. + if (diff != 0)
  455. + return diff;
  456. + }
  457. + return 0;
  458. +}
  459. +
  460. +static int
  461. +wcscmp_uint32 (const uint32_t *s1, const uint32_t *s2)
  462. +{
  463. + while (*s1 != 0 && *s1 == *s2)
  464. + s1++, s2++;
  465. + return *s1 - *s2;
  466. +}
  467. +
  468. +static uint32_t *
  469. +wmemcpy_uint32 (uint32_t *s1, const uint32_t *s2, size_t n)
  470. +{
  471. + return memcpy (s1, s2, n * sizeof (uint32_t));
  472. +}
  473. +
  474. +static uint32_t *
  475. +wcschr_uint32 (const uint32_t *s, uint32_t ch)
  476. +{
  477. + do
  478. + if (*s == ch)
  479. + return (uint32_t *) s;
  480. + while (*s++ != 0);
  481. + return 0;
  482. +}
  483. +
  484. #endif /* locfile.h */
  485. diff --git a/locale/setlocale.c b/locale/setlocale.c
  486. index 56c14d8533..6aac00503e 100644
  487. --- a/locale/setlocale.c
  488. +++ b/locale/setlocale.c
  489. @@ -63,35 +63,6 @@ static char *const _nl_current_used[] =
  490. #endif
  491. -
  492. -/* Define an array of category names (also the environment variable names). */
  493. -const struct catnamestr_t _nl_category_names attribute_hidden =
  494. - {
  495. -#define DEFINE_CATEGORY(category, category_name, items, a) \
  496. - category_name,
  497. -#include "categories.def"
  498. -#undef DEFINE_CATEGORY
  499. - };
  500. -
  501. -const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden =
  502. - {
  503. -#define DEFINE_CATEGORY(category, category_name, items, a) \
  504. - [category] = offsetof (struct catnamestr_t, CATNAMEMF (__LINE__)),
  505. -#include "categories.def"
  506. -#undef DEFINE_CATEGORY
  507. - };
  508. -
  509. -/* An array of their lengths, for convenience. */
  510. -const uint8_t _nl_category_name_sizes[] attribute_hidden =
  511. - {
  512. -#define DEFINE_CATEGORY(category, category_name, items, a) \
  513. - [category] = sizeof (category_name) - 1,
  514. -#include "categories.def"
  515. -#undef DEFINE_CATEGORY
  516. - [LC_ALL] = sizeof ("LC_ALL") - 1
  517. - };
  518. -
  519. -
  520. #ifdef NL_CURRENT_INDIRECT
  521. # define WEAK_POSTLOAD(postload) weak_extern (postload)
  522. #else