OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2806 lines
90 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../uclibc/pkg_patch/gcc/200-uclibc-locale.patch
  5. # Copyright (C) 2009 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. --- gcc/libstdc++-v3/acinclude.m4
  17. +++ gcc/libstdc++-v3/acinclude.m4
  18. @@ -1369,7 +1369,7 @@
  19. AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
  20. GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
  21. [use MODEL for target locale package],
  22. - [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
  23. + [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
  24. # Deal with gettext issues. Default to not using it (=no) until we detect
  25. # support for it later. Let the user turn it off via --e/d, but let that
  26. @@ -1385,6 +1385,9 @@
  27. # Default to "generic".
  28. if test $enable_clocale_flag = auto; then
  29. case ${target_os} in
  30. + *-uclibc*)
  31. + enable_clocale_flag=uclibc
  32. + ;;
  33. linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
  34. AC_EGREP_CPP([_GLIBCXX_ok], [
  35. #include <features.h>
  36. @@ -1528,6 +1531,40 @@
  37. CTIME_CC=config/locale/generic/time_members.cc
  38. CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
  39. ;;
  40. + uclibc)
  41. + AC_MSG_RESULT(uclibc)
  42. +
  43. + # Declare intention to use gettext, and add support for specific
  44. + # languages.
  45. + # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
  46. + ALL_LINGUAS="de fr"
  47. +
  48. + # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
  49. + AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
  50. + if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
  51. + USE_NLS=yes
  52. + fi
  53. + # Export the build objects.
  54. + for ling in $ALL_LINGUAS; do \
  55. + glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
  56. + glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
  57. + done
  58. + AC_SUBST(glibcxx_MOFILES)
  59. + AC_SUBST(glibcxx_POFILES)
  60. +
  61. + CLOCALE_H=config/locale/uclibc/c_locale.h
  62. + CLOCALE_CC=config/locale/uclibc/c_locale.cc
  63. + CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
  64. + CCOLLATE_CC=config/locale/uclibc/collate_members.cc
  65. + CCTYPE_CC=config/locale/uclibc/ctype_members.cc
  66. + CMESSAGES_H=config/locale/uclibc/messages_members.h
  67. + CMESSAGES_CC=config/locale/uclibc/messages_members.cc
  68. + CMONEY_CC=config/locale/uclibc/monetary_members.cc
  69. + CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
  70. + CTIME_H=config/locale/uclibc/time_members.h
  71. + CTIME_CC=config/locale/uclibc/time_members.cc
  72. + CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
  73. + ;;
  74. esac
  75. # This is where the testsuite looks for locale catalogs, using the
  76. --- gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
  77. +++ gcc/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
  78. @@ -0,0 +1,63 @@
  79. +// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
  80. +
  81. +// Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
  82. +//
  83. +// This file is part of the GNU ISO C++ Library. This library is free
  84. +// software; you can redistribute it and/or modify it under the
  85. +// terms of the GNU General Public License as published by the
  86. +// Free Software Foundation; either version 2, or (at your option)
  87. +// any later version.
  88. +
  89. +// This library is distributed in the hope that it will be useful,
  90. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  91. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  92. +// GNU General Public License for more details.
  93. +
  94. +// You should have received a copy of the GNU General Public License along
  95. +// with this library; see the file COPYING. If not, write to the Free
  96. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  97. +// USA.
  98. +
  99. +// As a special exception, you may use this file as part of a free software
  100. +// library without restriction. Specifically, if other files instantiate
  101. +// templates or use macros or inline functions from this file, or you compile
  102. +// this file and link it with other files to produce an executable, this
  103. +// file does not by itself cause the resulting executable to be covered by
  104. +// the GNU General Public License. This exception does not however
  105. +// invalidate any other reasons why the executable file might be covered by
  106. +// the GNU General Public License.
  107. +
  108. +// Written by Jakub Jelinek <jakub@redhat.com>
  109. +
  110. +#include <bits/c++config.h>
  111. +#include <clocale>
  112. +
  113. +#ifdef __UCLIBC_MJN3_ONLY__
  114. +#warning clean this up
  115. +#endif
  116. +
  117. +#ifdef __UCLIBC_HAS_XLOCALE__
  118. +
  119. +extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
  120. +extern "C" __typeof(strcoll_l) __strcoll_l;
  121. +extern "C" __typeof(strftime_l) __strftime_l;
  122. +extern "C" __typeof(strtod_l) __strtod_l;
  123. +extern "C" __typeof(strtof_l) __strtof_l;
  124. +extern "C" __typeof(strtold_l) __strtold_l;
  125. +extern "C" __typeof(strxfrm_l) __strxfrm_l;
  126. +extern "C" __typeof(newlocale) __newlocale;
  127. +extern "C" __typeof(freelocale) __freelocale;
  128. +extern "C" __typeof(duplocale) __duplocale;
  129. +extern "C" __typeof(uselocale) __uselocale;
  130. +
  131. +#ifdef _GLIBCXX_USE_WCHAR_T
  132. +extern "C" __typeof(iswctype_l) __iswctype_l;
  133. +extern "C" __typeof(towlower_l) __towlower_l;
  134. +extern "C" __typeof(towupper_l) __towupper_l;
  135. +extern "C" __typeof(wcscoll_l) __wcscoll_l;
  136. +extern "C" __typeof(wcsftime_l) __wcsftime_l;
  137. +extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
  138. +extern "C" __typeof(wctype_l) __wctype_l;
  139. +#endif
  140. +
  141. +#endif // GLIBC 2.3 and later
  142. --- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
  143. +++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc
  144. @@ -0,0 +1,160 @@
  145. +// Wrapper for underlying C-language localization -*- C++ -*-
  146. +
  147. +// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  148. +//
  149. +// This file is part of the GNU ISO C++ Library. This library is free
  150. +// software; you can redistribute it and/or modify it under the
  151. +// terms of the GNU General Public License as published by the
  152. +// Free Software Foundation; either version 2, or (at your option)
  153. +// any later version.
  154. +
  155. +// This library is distributed in the hope that it will be useful,
  156. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  157. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  158. +// GNU General Public License for more details.
  159. +
  160. +// You should have received a copy of the GNU General Public License along
  161. +// with this library; see the file COPYING. If not, write to the Free
  162. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  163. +// USA.
  164. +
  165. +// As a special exception, you may use this file as part of a free software
  166. +// library without restriction. Specifically, if other files instantiate
  167. +// templates or use macros or inline functions from this file, or you compile
  168. +// this file and link it with other files to produce an executable, this
  169. +// file does not by itself cause the resulting executable to be covered by
  170. +// the GNU General Public License. This exception does not however
  171. +// invalidate any other reasons why the executable file might be covered by
  172. +// the GNU General Public License.
  173. +
  174. +//
  175. +// ISO C++ 14882: 22.8 Standard locale categories.
  176. +//
  177. +
  178. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  179. +
  180. +#include <cerrno> // For errno
  181. +#include <locale>
  182. +#include <stdexcept>
  183. +#include <langinfo.h>
  184. +#include <bits/c++locale_internal.h>
  185. +
  186. +#ifndef __UCLIBC_HAS_XLOCALE__
  187. +#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
  188. +#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
  189. +#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
  190. +#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
  191. +#define __strtof_l(S, E, L) strtof((S), (E))
  192. +#define __strtod_l(S, E, L) strtod((S), (E))
  193. +#define __strtold_l(S, E, L) strtold((S), (E))
  194. +#warning should dummy __newlocale check for C|POSIX ?
  195. +#define __newlocale(a, b, c) NULL
  196. +#define __freelocale(a) ((void)0)
  197. +#define __duplocale(a) __c_locale()
  198. +#endif
  199. +
  200. +namespace std
  201. +{
  202. + template<>
  203. + void
  204. + __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
  205. + const __c_locale& __cloc)
  206. + {
  207. + if (!(__err & ios_base::failbit))
  208. + {
  209. + char* __sanity;
  210. + errno = 0;
  211. + float __f = __strtof_l(__s, &__sanity, __cloc);
  212. + if (__sanity != __s && errno != ERANGE)
  213. + __v = __f;
  214. + else
  215. + __err |= ios_base::failbit;
  216. + }
  217. + }
  218. +
  219. + template<>
  220. + void
  221. + __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
  222. + const __c_locale& __cloc)
  223. + {
  224. + if (!(__err & ios_base::failbit))
  225. + {
  226. + char* __sanity;
  227. + errno = 0;
  228. + double __d = __strtod_l(__s, &__sanity, __cloc);
  229. + if (__sanity != __s && errno != ERANGE)
  230. + __v = __d;
  231. + else
  232. + __err |= ios_base::failbit;
  233. + }
  234. + }
  235. +
  236. + template<>
  237. + void
  238. + __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
  239. + const __c_locale& __cloc)
  240. + {
  241. + if (!(__err & ios_base::failbit))
  242. + {
  243. + char* __sanity;
  244. + errno = 0;
  245. + long double __ld = __strtold_l(__s, &__sanity, __cloc);
  246. + if (__sanity != __s && errno != ERANGE)
  247. + __v = __ld;
  248. + else
  249. + __err |= ios_base::failbit;
  250. + }
  251. + }
  252. +
  253. + void
  254. + locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
  255. + __c_locale __old)
  256. + {
  257. + __cloc = __newlocale(1 << LC_ALL, __s, __old);
  258. +#ifdef __UCLIBC_HAS_XLOCALE__
  259. + if (!__cloc)
  260. + {
  261. + // This named locale is not supported by the underlying OS.
  262. + __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
  263. + "name not valid"));
  264. + }
  265. +#endif
  266. + }
  267. +
  268. + void
  269. + locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
  270. + {
  271. + if (_S_get_c_locale() != __cloc)
  272. + __freelocale(__cloc);
  273. + }
  274. +
  275. + __c_locale
  276. + locale::facet::_S_clone_c_locale(__c_locale& __cloc)
  277. + { return __duplocale(__cloc); }
  278. +} // namespace std
  279. +
  280. +namespace __gnu_cxx
  281. +{
  282. + const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
  283. + {
  284. + "LC_CTYPE",
  285. + "LC_NUMERIC",
  286. + "LC_TIME",
  287. + "LC_COLLATE",
  288. + "LC_MONETARY",
  289. + "LC_MESSAGES",
  290. +#if _GLIBCXX_NUM_CATEGORIES != 0
  291. + "LC_PAPER",
  292. + "LC_NAME",
  293. + "LC_ADDRESS",
  294. + "LC_TELEPHONE",
  295. + "LC_MEASUREMENT",
  296. + "LC_IDENTIFICATION"
  297. +#endif
  298. + };
  299. +}
  300. +
  301. +namespace std
  302. +{
  303. + const char* const* const locale::_S_categories = __gnu_cxx::category_names;
  304. +} // namespace std
  305. --- gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
  306. +++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.h
  307. @@ -0,0 +1,117 @@
  308. +// Wrapper for underlying C-language localization -*- C++ -*-
  309. +
  310. +// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
  311. +//
  312. +// This file is part of the GNU ISO C++ Library. This library is free
  313. +// software; you can redistribute it and/or modify it under the
  314. +// terms of the GNU General Public License as published by the
  315. +// Free Software Foundation; either version 2, or (at your option)
  316. +// any later version.
  317. +
  318. +// This library is distributed in the hope that it will be useful,
  319. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  320. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  321. +// GNU General Public License for more details.
  322. +
  323. +// You should have received a copy of the GNU General Public License along
  324. +// with this library; see the file COPYING. If not, write to the Free
  325. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  326. +// USA.
  327. +
  328. +// As a special exception, you may use this file as part of a free software
  329. +// library without restriction. Specifically, if other files instantiate
  330. +// templates or use macros or inline functions from this file, or you compile
  331. +// this file and link it with other files to produce an executable, this
  332. +// file does not by itself cause the resulting executable to be covered by
  333. +// the GNU General Public License. This exception does not however
  334. +// invalidate any other reasons why the executable file might be covered by
  335. +// the GNU General Public License.
  336. +
  337. +//
  338. +// ISO C++ 14882: 22.8 Standard locale categories.
  339. +//
  340. +
  341. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  342. +
  343. +#ifndef _C_LOCALE_H
  344. +#define _C_LOCALE_H 1
  345. +
  346. +#pragma GCC system_header
  347. +
  348. +#include <cstring> // get std::strlen
  349. +#include <cstdio> // get std::snprintf or std::sprintf
  350. +#include <clocale>
  351. +#include <langinfo.h> // For codecvt
  352. +#ifdef __UCLIBC_MJN3_ONLY__
  353. +#warning fix this
  354. +#endif
  355. +#ifdef __UCLIBC_HAS_LOCALE__
  356. +#include <iconv.h> // For codecvt using iconv, iconv_t
  357. +#endif
  358. +#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
  359. +#include <libintl.h> // For messages
  360. +#endif
  361. +
  362. +#ifdef __UCLIBC_MJN3_ONLY__
  363. +#warning what is _GLIBCXX_C_LOCALE_GNU for
  364. +#endif
  365. +#define _GLIBCXX_C_LOCALE_GNU 1
  366. +
  367. +#ifdef __UCLIBC_MJN3_ONLY__
  368. +#warning fix categories
  369. +#endif
  370. +// #define _GLIBCXX_NUM_CATEGORIES 6
  371. +#define _GLIBCXX_NUM_CATEGORIES 0
  372. +
  373. +#ifdef __UCLIBC_HAS_XLOCALE__
  374. +namespace __gnu_cxx
  375. +{
  376. + extern "C" __typeof(uselocale) __uselocale;
  377. +}
  378. +#endif
  379. +
  380. +namespace std
  381. +{
  382. +#ifdef __UCLIBC_HAS_XLOCALE__
  383. + typedef __locale_t __c_locale;
  384. +#else
  385. + typedef int* __c_locale;
  386. +#endif
  387. +
  388. + // Convert numeric value of type _Tv to string and return length of
  389. + // string. If snprintf is available use it, otherwise fall back to
  390. + // the unsafe sprintf which, in general, can be dangerous and should
  391. + // be avoided.
  392. + template<typename _Tv>
  393. + int
  394. + __convert_from_v(char* __out,
  395. + const int __size __attribute__ ((__unused__)),
  396. + const char* __fmt,
  397. +#ifdef __UCLIBC_HAS_XCLOCALE__
  398. + _Tv __v, const __c_locale& __cloc, int __prec)
  399. + {
  400. + __c_locale __old = __gnu_cxx::__uselocale(__cloc);
  401. +#else
  402. + _Tv __v, const __c_locale&, int __prec)
  403. + {
  404. +# ifdef __UCLIBC_HAS_LOCALE__
  405. + char* __old = std::setlocale(LC_ALL, NULL);
  406. + char* __sav = new char[std::strlen(__old) + 1];
  407. + std::strcpy(__sav, __old);
  408. + std::setlocale(LC_ALL, "C");
  409. +# endif
  410. +#endif
  411. +
  412. + const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
  413. +
  414. +#ifdef __UCLIBC_HAS_XCLOCALE__
  415. + __gnu_cxx::__uselocale(__old);
  416. +#elif defined __UCLIBC_HAS_LOCALE__
  417. + std::setlocale(LC_ALL, __sav);
  418. + delete [] __sav;
  419. +#endif
  420. + return __ret;
  421. + }
  422. +}
  423. +
  424. +#endif
  425. --- gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
  426. +++ gcc/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
  427. @@ -0,0 +1,306 @@
  428. +// std::codecvt implementation details, GNU version -*- C++ -*-
  429. +
  430. +// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
  431. +//
  432. +// This file is part of the GNU ISO C++ Library. This library is free
  433. +// software; you can redistribute it and/or modify it under the
  434. +// terms of the GNU General Public License as published by the
  435. +// Free Software Foundation; either version 2, or (at your option)
  436. +// any later version.
  437. +
  438. +// This library is distributed in the hope that it will be useful,
  439. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  440. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  441. +// GNU General Public License for more details.
  442. +
  443. +// You should have received a copy of the GNU General Public License along
  444. +// with this library; see the file COPYING. If not, write to the Free
  445. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  446. +// USA.
  447. +
  448. +// As a special exception, you may use this file as part of a free software
  449. +// library without restriction. Specifically, if other files instantiate
  450. +// templates or use macros or inline functions from this file, or you compile
  451. +// this file and link it with other files to produce an executable, this
  452. +// file does not by itself cause the resulting executable to be covered by
  453. +// the GNU General Public License. This exception does not however
  454. +// invalidate any other reasons why the executable file might be covered by
  455. +// the GNU General Public License.
  456. +
  457. +//
  458. +// ISO C++ 14882: 22.2.1.5 - Template class codecvt
  459. +//
  460. +
  461. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  462. +
  463. +#include <locale>
  464. +#include <bits/c++locale_internal.h>
  465. +
  466. +namespace std
  467. +{
  468. + // Specializations.
  469. +#ifdef _GLIBCXX_USE_WCHAR_T
  470. + codecvt_base::result
  471. + codecvt<wchar_t, char, mbstate_t>::
  472. + do_out(state_type& __state, const intern_type* __from,
  473. + const intern_type* __from_end, const intern_type*& __from_next,
  474. + extern_type* __to, extern_type* __to_end,
  475. + extern_type*& __to_next) const
  476. + {
  477. + result __ret = ok;
  478. + state_type __tmp_state(__state);
  479. +
  480. +#ifdef __UCLIBC_HAS_XLOCALE__
  481. + __c_locale __old = __uselocale(_M_c_locale_codecvt);
  482. +#endif
  483. +
  484. + // wcsnrtombs is *very* fast but stops if encounters NUL characters:
  485. + // in case we fall back to wcrtomb and then continue, in a loop.
  486. + // NB: wcsnrtombs is a GNU extension
  487. + for (__from_next = __from, __to_next = __to;
  488. + __from_next < __from_end && __to_next < __to_end
  489. + && __ret == ok;)
  490. + {
  491. + const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
  492. + __from_end - __from_next);
  493. + if (!__from_chunk_end)
  494. + __from_chunk_end = __from_end;
  495. +
  496. + __from = __from_next;
  497. + const size_t __conv = wcsnrtombs(__to_next, &__from_next,
  498. + __from_chunk_end - __from_next,
  499. + __to_end - __to_next, &__state);
  500. + if (__conv == static_cast<size_t>(-1))
  501. + {
  502. + // In case of error, in order to stop at the exact place we
  503. + // have to start again from the beginning with a series of
  504. + // wcrtomb.
  505. + for (; __from < __from_next; ++__from)
  506. + __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
  507. + __state = __tmp_state;
  508. + __ret = error;
  509. + }
  510. + else if (__from_next && __from_next < __from_chunk_end)
  511. + {
  512. + __to_next += __conv;
  513. + __ret = partial;
  514. + }
  515. + else
  516. + {
  517. + __from_next = __from_chunk_end;
  518. + __to_next += __conv;
  519. + }
  520. +
  521. + if (__from_next < __from_end && __ret == ok)
  522. + {
  523. + extern_type __buf[MB_LEN_MAX];
  524. + __tmp_state = __state;
  525. + const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
  526. + if (__conv > static_cast<size_t>(__to_end - __to_next))
  527. + __ret = partial;
  528. + else
  529. + {
  530. + memcpy(__to_next, __buf, __conv);
  531. + __state = __tmp_state;
  532. + __to_next += __conv;
  533. + ++__from_next;
  534. + }
  535. + }
  536. + }
  537. +
  538. +#ifdef __UCLIBC_HAS_XLOCALE__
  539. + __uselocale(__old);
  540. +#endif
  541. +
  542. + return __ret;
  543. + }
  544. +
  545. + codecvt_base::result
  546. + codecvt<wchar_t, char, mbstate_t>::
  547. + do_in(state_type& __state, const extern_type* __from,
  548. + const extern_type* __from_end, const extern_type*& __from_next,
  549. + intern_type* __to, intern_type* __to_end,
  550. + intern_type*& __to_next) const
  551. + {
  552. + result __ret = ok;
  553. + state_type __tmp_state(__state);
  554. +
  555. +#ifdef __UCLIBC_HAS_XLOCALE__
  556. + __c_locale __old = __uselocale(_M_c_locale_codecvt);
  557. +#endif
  558. +
  559. + // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
  560. + // in case we store a L'\0' and then continue, in a loop.
  561. + // NB: mbsnrtowcs is a GNU extension
  562. + for (__from_next = __from, __to_next = __to;
  563. + __from_next < __from_end && __to_next < __to_end
  564. + && __ret == ok;)
  565. + {
  566. + const extern_type* __from_chunk_end;
  567. + __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
  568. + __from_end
  569. + - __from_next));
  570. + if (!__from_chunk_end)
  571. + __from_chunk_end = __from_end;
  572. +
  573. + __from = __from_next;
  574. + size_t __conv = mbsnrtowcs(__to_next, &__from_next,
  575. + __from_chunk_end - __from_next,
  576. + __to_end - __to_next, &__state);
  577. + if (__conv == static_cast<size_t>(-1))
  578. + {
  579. + // In case of error, in order to stop at the exact place we
  580. + // have to start again from the beginning with a series of
  581. + // mbrtowc.
  582. + for (;; ++__to_next, __from += __conv)
  583. + {
  584. + __conv = mbrtowc(__to_next, __from, __from_end - __from,
  585. + &__tmp_state);
  586. + if (__conv == static_cast<size_t>(-1)
  587. + || __conv == static_cast<size_t>(-2))
  588. + break;
  589. + }
  590. + __from_next = __from;
  591. + __state = __tmp_state;
  592. + __ret = error;
  593. + }
  594. + else if (__from_next && __from_next < __from_chunk_end)
  595. + {
  596. + // It is unclear what to return in this case (see DR 382).
  597. + __to_next += __conv;
  598. + __ret = partial;
  599. + }
  600. + else
  601. + {
  602. + __from_next = __from_chunk_end;
  603. + __to_next += __conv;
  604. + }
  605. +
  606. + if (__from_next < __from_end && __ret == ok)
  607. + {
  608. + if (__to_next < __to_end)
  609. + {
  610. + // XXX Probably wrong for stateful encodings
  611. + __tmp_state = __state;
  612. + ++__from_next;
  613. + *__to_next++ = L'\0';
  614. + }
  615. + else
  616. + __ret = partial;
  617. + }
  618. + }
  619. +
  620. +#ifdef __UCLIBC_HAS_XLOCALE__
  621. + __uselocale(__old);
  622. +#endif
  623. +
  624. + return __ret;
  625. + }
  626. +
  627. + int
  628. + codecvt<wchar_t, char, mbstate_t>::
  629. + do_encoding() const throw()
  630. + {
  631. + // XXX This implementation assumes that the encoding is
  632. + // stateless and is either single-byte or variable-width.
  633. + int __ret = 0;
  634. +#ifdef __UCLIBC_HAS_XLOCALE__
  635. + __c_locale __old = __uselocale(_M_c_locale_codecvt);
  636. +#endif
  637. + if (MB_CUR_MAX == 1)
  638. + __ret = 1;
  639. +#ifdef __UCLIBC_HAS_XLOCALE__
  640. + __uselocale(__old);
  641. +#endif
  642. + return __ret;
  643. + }
  644. +
  645. + int
  646. + codecvt<wchar_t, char, mbstate_t>::
  647. + do_max_length() const throw()
  648. + {
  649. +#ifdef __UCLIBC_HAS_XLOCALE__
  650. + __c_locale __old = __uselocale(_M_c_locale_codecvt);
  651. +#endif
  652. + // XXX Probably wrong for stateful encodings.
  653. + int __ret = MB_CUR_MAX;
  654. +#ifdef __UCLIBC_HAS_XLOCALE__
  655. + __uselocale(__old);
  656. +#endif
  657. + return __ret;
  658. + }
  659. +
  660. + int
  661. + codecvt<wchar_t, char, mbstate_t>::
  662. + do_length(state_type& __state, const extern_type* __from,
  663. + const extern_type* __end, size_t __max) const
  664. + {
  665. + int __ret = 0;
  666. + state_type __tmp_state(__state);
  667. +
  668. +#ifdef __UCLIBC_HAS_XLOCALE__
  669. + __c_locale __old = __uselocale(_M_c_locale_codecvt);
  670. +#endif
  671. +
  672. + // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
  673. + // in case we advance past it and then continue, in a loop.
  674. + // NB: mbsnrtowcs is a GNU extension
  675. +
  676. + // A dummy internal buffer is needed in order for mbsnrtocws to consider
  677. + // its fourth parameter (it wouldn't with NULL as first parameter).
  678. + wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
  679. + * __max));
  680. + while (__from < __end && __max)
  681. + {
  682. + const extern_type* __from_chunk_end;
  683. + __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
  684. + __end
  685. + - __from));
  686. + if (!__from_chunk_end)
  687. + __from_chunk_end = __end;
  688. +
  689. + const extern_type* __tmp_from = __from;
  690. + size_t __conv = mbsnrtowcs(__to, &__from,
  691. + __from_chunk_end - __from,
  692. + __max, &__state);
  693. + if (__conv == static_cast<size_t>(-1))
  694. + {
  695. + // In case of error, in order to stop at the exact place we
  696. + // have to start again from the beginning with a series of
  697. + // mbrtowc.
  698. + for (__from = __tmp_from;; __from += __conv)
  699. + {
  700. + __conv = mbrtowc(NULL, __from, __end - __from,
  701. + &__tmp_state);
  702. + if (__conv == static_cast<size_t>(-1)
  703. + || __conv == static_cast<size_t>(-2))
  704. + break;
  705. + }
  706. + __state = __tmp_state;
  707. + __ret += __from - __tmp_from;
  708. + break;
  709. + }
  710. + if (!__from)
  711. + __from = __from_chunk_end;
  712. +
  713. + __ret += __from - __tmp_from;
  714. + __max -= __conv;
  715. +
  716. + if (__from < __end && __max)
  717. + {
  718. + // XXX Probably wrong for stateful encodings
  719. + __tmp_state = __state;
  720. + ++__from;
  721. + ++__ret;
  722. + --__max;
  723. + }
  724. + }
  725. +
  726. +#ifdef __UCLIBC_HAS_XLOCALE__
  727. + __uselocale(__old);
  728. +#endif
  729. +
  730. + return __ret;
  731. + }
  732. +#endif
  733. +}
  734. --- gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
  735. +++ gcc/libstdc++-v3/config/locale/uclibc/collate_members.cc
  736. @@ -0,0 +1,80 @@
  737. +// std::collate implementation details, GNU version -*- C++ -*-
  738. +
  739. +// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  740. +//
  741. +// This file is part of the GNU ISO C++ Library. This library is free
  742. +// software; you can redistribute it and/or modify it under the
  743. +// terms of the GNU General Public License as published by the
  744. +// Free Software Foundation; either version 2, or (at your option)
  745. +// any later version.
  746. +
  747. +// This library is distributed in the hope that it will be useful,
  748. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  749. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  750. +// GNU General Public License for more details.
  751. +
  752. +// You should have received a copy of the GNU General Public License along
  753. +// with this library; see the file COPYING. If not, write to the Free
  754. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  755. +// USA.
  756. +
  757. +// As a special exception, you may use this file as part of a free software
  758. +// library without restriction. Specifically, if other files instantiate
  759. +// templates or use macros or inline functions from this file, or you compile
  760. +// this file and link it with other files to produce an executable, this
  761. +// file does not by itself cause the resulting executable to be covered by
  762. +// the GNU General Public License. This exception does not however
  763. +// invalidate any other reasons why the executable file might be covered by
  764. +// the GNU General Public License.
  765. +
  766. +//
  767. +// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
  768. +//
  769. +
  770. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  771. +
  772. +#include <locale>
  773. +#include <bits/c++locale_internal.h>
  774. +
  775. +#ifndef __UCLIBC_HAS_XLOCALE__
  776. +#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
  777. +#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
  778. +#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
  779. +#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
  780. +#endif
  781. +
  782. +namespace std
  783. +{
  784. + // These are basically extensions to char_traits, and perhaps should
  785. + // be put there instead of here.
  786. + template<>
  787. + int
  788. + collate<char>::_M_compare(const char* __one, const char* __two) const
  789. + {
  790. + int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
  791. + return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
  792. + }
  793. +
  794. + template<>
  795. + size_t
  796. + collate<char>::_M_transform(char* __to, const char* __from,
  797. + size_t __n) const
  798. + { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
  799. +
  800. +#ifdef _GLIBCXX_USE_WCHAR_T
  801. + template<>
  802. + int
  803. + collate<wchar_t>::_M_compare(const wchar_t* __one,
  804. + const wchar_t* __two) const
  805. + {
  806. + int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
  807. + return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
  808. + }
  809. +
  810. + template<>
  811. + size_t
  812. + collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
  813. + size_t __n) const
  814. + { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
  815. +#endif
  816. +}
  817. --- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
  818. +++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc
  819. @@ -0,0 +1,300 @@
  820. +// std::ctype implementation details, GNU version -*- C++ -*-
  821. +
  822. +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  823. +//
  824. +// This file is part of the GNU ISO C++ Library. This library is free
  825. +// software; you can redistribute it and/or modify it under the
  826. +// terms of the GNU General Public License as published by the
  827. +// Free Software Foundation; either version 2, or (at your option)
  828. +// any later version.
  829. +
  830. +// This library is distributed in the hope that it will be useful,
  831. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  832. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  833. +// GNU General Public License for more details.
  834. +
  835. +// You should have received a copy of the GNU General Public License along
  836. +// with this library; see the file COPYING. If not, write to the Free
  837. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  838. +// USA.
  839. +
  840. +// As a special exception, you may use this file as part of a free software
  841. +// library without restriction. Specifically, if other files instantiate
  842. +// templates or use macros or inline functions from this file, or you compile
  843. +// this file and link it with other files to produce an executable, this
  844. +// file does not by itself cause the resulting executable to be covered by
  845. +// the GNU General Public License. This exception does not however
  846. +// invalidate any other reasons why the executable file might be covered by
  847. +// the GNU General Public License.
  848. +
  849. +//
  850. +// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
  851. +//
  852. +
  853. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  854. +
  855. +#define _LIBC
  856. +#include <locale>
  857. +#undef _LIBC
  858. +#include <bits/c++locale_internal.h>
  859. +
  860. +#ifndef __UCLIBC_HAS_XLOCALE__
  861. +#define __wctype_l(S, L) wctype((S))
  862. +#define __towupper_l(C, L) towupper((C))
  863. +#define __towlower_l(C, L) towlower((C))
  864. +#define __iswctype_l(C, M, L) iswctype((C), (M))
  865. +#endif
  866. +
  867. +namespace std
  868. +{
  869. + // NB: The other ctype<char> specializations are in src/locale.cc and
  870. + // various /config/os/* files.
  871. + template<>
  872. + ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
  873. + : ctype<char>(0, false, __refs)
  874. + {
  875. + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
  876. + {
  877. + this->_S_destroy_c_locale(this->_M_c_locale_ctype);
  878. + this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
  879. +#ifdef __UCLIBC_HAS_XLOCALE__
  880. + this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
  881. + this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
  882. + this->_M_table = this->_M_c_locale_ctype->__ctype_b;
  883. +#endif
  884. + }
  885. + }
  886. +
  887. +#ifdef _GLIBCXX_USE_WCHAR_T
  888. + ctype<wchar_t>::__wmask_type
  889. + ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
  890. + {
  891. + __wmask_type __ret;
  892. + switch (__m)
  893. + {
  894. + case space:
  895. + __ret = __wctype_l("space", _M_c_locale_ctype);
  896. + break;
  897. + case print:
  898. + __ret = __wctype_l("print", _M_c_locale_ctype);
  899. + break;
  900. + case cntrl:
  901. + __ret = __wctype_l("cntrl", _M_c_locale_ctype);
  902. + break;
  903. + case upper:
  904. + __ret = __wctype_l("upper", _M_c_locale_ctype);
  905. + break;
  906. + case lower:
  907. + __ret = __wctype_l("lower", _M_c_locale_ctype);
  908. + break;
  909. + case alpha:
  910. + __ret = __wctype_l("alpha", _M_c_locale_ctype);
  911. + break;
  912. + case digit:
  913. + __ret = __wctype_l("digit", _M_c_locale_ctype);
  914. + break;
  915. + case punct:
  916. + __ret = __wctype_l("punct", _M_c_locale_ctype);
  917. + break;
  918. + case xdigit:
  919. + __ret = __wctype_l("xdigit", _M_c_locale_ctype);
  920. + break;
  921. + case alnum:
  922. + __ret = __wctype_l("alnum", _M_c_locale_ctype);
  923. + break;
  924. + case graph:
  925. + __ret = __wctype_l("graph", _M_c_locale_ctype);
  926. + break;
  927. + default:
  928. + __ret = __wmask_type();
  929. + }
  930. + return __ret;
  931. + }
  932. +
  933. + wchar_t
  934. + ctype<wchar_t>::do_toupper(wchar_t __c) const
  935. + { return __towupper_l(__c, _M_c_locale_ctype); }
  936. +
  937. + const wchar_t*
  938. + ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
  939. + {
  940. + while (__lo < __hi)
  941. + {
  942. + *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
  943. + ++__lo;
  944. + }
  945. + return __hi;
  946. + }
  947. +
  948. + wchar_t
  949. + ctype<wchar_t>::do_tolower(wchar_t __c) const
  950. + { return __towlower_l(__c, _M_c_locale_ctype); }
  951. +
  952. + const wchar_t*
  953. + ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
  954. + {
  955. + while (__lo < __hi)
  956. + {
  957. + *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
  958. + ++__lo;
  959. + }
  960. + return __hi;
  961. + }
  962. +
  963. + bool
  964. + ctype<wchar_t>::
  965. + do_is(mask __m, wchar_t __c) const
  966. + {
  967. + // Highest bitmask in ctype_base == 10, but extra in "C"
  968. + // library for blank.
  969. + bool __ret = false;
  970. + const size_t __bitmasksize = 11;
  971. + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
  972. + if (__m & _M_bit[__bitcur]
  973. + && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
  974. + {
  975. + __ret = true;
  976. + break;
  977. + }
  978. + return __ret;
  979. + }
  980. +
  981. + const wchar_t*
  982. + ctype<wchar_t>::
  983. + do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
  984. + {
  985. + for (; __lo < __hi; ++__vec, ++__lo)
  986. + {
  987. + // Highest bitmask in ctype_base == 10, but extra in "C"
  988. + // library for blank.
  989. + const size_t __bitmasksize = 11;
  990. + mask __m = 0;
  991. + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
  992. + if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
  993. + __m |= _M_bit[__bitcur];
  994. + *__vec = __m;
  995. + }
  996. + return __hi;
  997. + }
  998. +
  999. + const wchar_t*
  1000. + ctype<wchar_t>::
  1001. + do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
  1002. + {
  1003. + while (__lo < __hi && !this->do_is(__m, *__lo))
  1004. + ++__lo;
  1005. + return __lo;
  1006. + }
  1007. +
  1008. + const wchar_t*
  1009. + ctype<wchar_t>::
  1010. + do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
  1011. + {
  1012. + while (__lo < __hi && this->do_is(__m, *__lo) != 0)
  1013. + ++__lo;
  1014. + return __lo;
  1015. + }
  1016. +
  1017. + wchar_t
  1018. + ctype<wchar_t>::
  1019. + do_widen(char __c) const
  1020. + { return _M_widen[static_cast<unsigned char>(__c)]; }
  1021. +
  1022. + const char*
  1023. + ctype<wchar_t>::
  1024. + do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
  1025. + {
  1026. + while (__lo < __hi)
  1027. + {
  1028. + *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
  1029. + ++__lo;
  1030. + ++__dest;
  1031. + }
  1032. + return __hi;
  1033. + }
  1034. +
  1035. + char
  1036. + ctype<wchar_t>::
  1037. + do_narrow(wchar_t __wc, char __dfault) const
  1038. + {
  1039. + if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
  1040. + return _M_narrow[__wc];
  1041. +#ifdef __UCLIBC_HAS_XLOCALE__
  1042. + __c_locale __old = __uselocale(_M_c_locale_ctype);
  1043. +#endif
  1044. + const int __c = wctob(__wc);
  1045. +#ifdef __UCLIBC_HAS_XLOCALE__
  1046. + __uselocale(__old);
  1047. +#endif
  1048. + return (__c == EOF ? __dfault : static_cast<char>(__c));
  1049. + }
  1050. +
  1051. + const wchar_t*
  1052. + ctype<wchar_t>::
  1053. + do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
  1054. + char* __dest) const
  1055. + {
  1056. +#ifdef __UCLIBC_HAS_XLOCALE__
  1057. + __c_locale __old = __uselocale(_M_c_locale_ctype);
  1058. +#endif
  1059. + if (_M_narrow_ok)
  1060. + while (__lo < __hi)
  1061. + {
  1062. + if (*__lo >= 0 && *__lo < 128)
  1063. + *__dest = _M_narrow[*__lo];
  1064. + else
  1065. + {
  1066. + const int __c = wctob(*__lo);
  1067. + *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
  1068. + }
  1069. + ++__lo;
  1070. + ++__dest;
  1071. + }
  1072. + else
  1073. + while (__lo < __hi)
  1074. + {
  1075. + const int __c = wctob(*__lo);
  1076. + *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
  1077. + ++__lo;
  1078. + ++__dest;
  1079. + }
  1080. +#ifdef __UCLIBC_HAS_XLOCALE__
  1081. + __uselocale(__old);
  1082. +#endif
  1083. + return __hi;
  1084. + }
  1085. +
  1086. + void
  1087. + ctype<wchar_t>::_M_initialize_ctype()
  1088. + {
  1089. +#ifdef __UCLIBC_HAS_XLOCALE__
  1090. + __c_locale __old = __uselocale(_M_c_locale_ctype);
  1091. +#endif
  1092. + wint_t __i;
  1093. + for (__i = 0; __i < 128; ++__i)
  1094. + {
  1095. + const int __c = wctob(__i);
  1096. + if (__c == EOF)
  1097. + break;
  1098. + else
  1099. + _M_narrow[__i] = static_cast<char>(__c);
  1100. + }
  1101. + if (__i == 128)
  1102. + _M_narrow_ok = true;
  1103. + else
  1104. + _M_narrow_ok = false;
  1105. + for (size_t __j = 0;
  1106. + __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
  1107. + _M_widen[__j] = btowc(__j);
  1108. +
  1109. + for (size_t __k = 0; __k <= 11; ++__k)
  1110. + {
  1111. + _M_bit[__k] = static_cast<mask>(_ISbit(__k));
  1112. + _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
  1113. + }
  1114. +#ifdef __UCLIBC_HAS_XLOCALE__
  1115. + __uselocale(__old);
  1116. +#endif
  1117. + }
  1118. +#endif // _GLIBCXX_USE_WCHAR_T
  1119. +}
  1120. --- gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
  1121. +++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.cc
  1122. @@ -0,0 +1,100 @@
  1123. +// std::messages implementation details, GNU version -*- C++ -*-
  1124. +
  1125. +// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  1126. +//
  1127. +// This file is part of the GNU ISO C++ Library. This library is free
  1128. +// software; you can redistribute it and/or modify it under the
  1129. +// terms of the GNU General Public License as published by the
  1130. +// Free Software Foundation; either version 2, or (at your option)
  1131. +// any later version.
  1132. +
  1133. +// This library is distributed in the hope that it will be useful,
  1134. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  1135. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1136. +// GNU General Public License for more details.
  1137. +
  1138. +// You should have received a copy of the GNU General Public License along
  1139. +// with this library; see the file COPYING. If not, write to the Free
  1140. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  1141. +// USA.
  1142. +
  1143. +// As a special exception, you may use this file as part of a free software
  1144. +// library without restriction. Specifically, if other files instantiate
  1145. +// templates or use macros or inline functions from this file, or you compile
  1146. +// this file and link it with other files to produce an executable, this
  1147. +// file does not by itself cause the resulting executable to be covered by
  1148. +// the GNU General Public License. This exception does not however
  1149. +// invalidate any other reasons why the executable file might be covered by
  1150. +// the GNU General Public License.
  1151. +
  1152. +//
  1153. +// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
  1154. +//
  1155. +
  1156. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  1157. +
  1158. +#include <locale>
  1159. +#include <bits/c++locale_internal.h>
  1160. +
  1161. +#ifdef __UCLIBC_MJN3_ONLY__
  1162. +#warning fix gettext stuff
  1163. +#endif
  1164. +#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
  1165. +extern "C" char *__dcgettext(const char *domainname,
  1166. + const char *msgid, int category);
  1167. +#undef gettext
  1168. +#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
  1169. +#else
  1170. +#undef gettext
  1171. +#define gettext(msgid) (msgid)
  1172. +#endif
  1173. +
  1174. +namespace std
  1175. +{
  1176. + // Specializations.
  1177. + template<>
  1178. + string
  1179. + messages<char>::do_get(catalog, int, int, const string& __dfault) const
  1180. + {
  1181. +#ifdef __UCLIBC_HAS_XLOCALE__
  1182. + __c_locale __old = __uselocale(_M_c_locale_messages);
  1183. + const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
  1184. + __uselocale(__old);
  1185. + return string(__msg);
  1186. +#elif defined __UCLIBC_HAS_LOCALE__
  1187. + char* __old = strdup(setlocale(LC_ALL, NULL));
  1188. + setlocale(LC_ALL, _M_name_messages);
  1189. + const char* __msg = gettext(__dfault.c_str());
  1190. + setlocale(LC_ALL, __old);
  1191. + free(__old);
  1192. + return string(__msg);
  1193. +#else
  1194. + const char* __msg = gettext(__dfault.c_str());
  1195. + return string(__msg);
  1196. +#endif
  1197. + }
  1198. +
  1199. +#ifdef _GLIBCXX_USE_WCHAR_T
  1200. + template<>
  1201. + wstring
  1202. + messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
  1203. + {
  1204. +# ifdef __UCLIBC_HAS_XLOCALE__
  1205. + __c_locale __old = __uselocale(_M_c_locale_messages);
  1206. + char* __msg = gettext(_M_convert_to_char(__dfault));
  1207. + __uselocale(__old);
  1208. + return _M_convert_from_char(__msg);
  1209. +# elif defined __UCLIBC_HAS_LOCALE__
  1210. + char* __old = strdup(setlocale(LC_ALL, NULL));
  1211. + setlocale(LC_ALL, _M_name_messages);
  1212. + char* __msg = gettext(_M_convert_to_char(__dfault));
  1213. + setlocale(LC_ALL, __old);
  1214. + free(__old);
  1215. + return _M_convert_from_char(__msg);
  1216. +# else
  1217. + char* __msg = gettext(_M_convert_to_char(__dfault));
  1218. + return _M_convert_from_char(__msg);
  1219. +# endif
  1220. + }
  1221. +#endif
  1222. +}
  1223. --- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
  1224. +++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h
  1225. @@ -0,0 +1,118 @@
  1226. +// std::messages implementation details, GNU version -*- C++ -*-
  1227. +
  1228. +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  1229. +//
  1230. +// This file is part of the GNU ISO C++ Library. This library is free
  1231. +// software; you can redistribute it and/or modify it under the
  1232. +// terms of the GNU General Public License as published by the
  1233. +// Free Software Foundation; either version 2, or (at your option)
  1234. +// any later version.
  1235. +
  1236. +// This library is distributed in the hope that it will be useful,
  1237. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  1238. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1239. +// GNU General Public License for more details.
  1240. +
  1241. +// You should have received a copy of the GNU General Public License along
  1242. +// with this library; see the file COPYING. If not, write to the Free
  1243. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  1244. +// USA.
  1245. +
  1246. +// As a special exception, you may use this file as part of a free software
  1247. +// library without restriction. Specifically, if other files instantiate
  1248. +// templates or use macros or inline functions from this file, or you compile
  1249. +// this file and link it with other files to produce an executable, this
  1250. +// file does not by itself cause the resulting executable to be covered by
  1251. +// the GNU General Public License. This exception does not however
  1252. +// invalidate any other reasons why the executable file might be covered by
  1253. +// the GNU General Public License.
  1254. +
  1255. +//
  1256. +// ISO C++ 14882: 22.2.7.1.2 messages functions
  1257. +//
  1258. +
  1259. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  1260. +
  1261. +#ifdef __UCLIBC_MJN3_ONLY__
  1262. +#warning fix prototypes for *textdomain funcs
  1263. +#endif
  1264. +#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
  1265. +extern "C" char *__textdomain(const char *domainname);
  1266. +extern "C" char *__bindtextdomain(const char *domainname,
  1267. + const char *dirname);
  1268. +#else
  1269. +#undef __textdomain
  1270. +#undef __bindtextdomain
  1271. +#define __textdomain(D) ((void)0)
  1272. +#define __bindtextdomain(D,P) ((void)0)
  1273. +#endif
  1274. +
  1275. + // Non-virtual member functions.
  1276. + template<typename _CharT>
  1277. + messages<_CharT>::messages(size_t __refs)
  1278. + : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
  1279. + _M_name_messages(_S_get_c_name())
  1280. + { }
  1281. +
  1282. + template<typename _CharT>
  1283. + messages<_CharT>::messages(__c_locale __cloc, const char* __s,
  1284. + size_t __refs)
  1285. + : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
  1286. + _M_name_messages(__s)
  1287. + {
  1288. + char* __tmp = new char[std::strlen(__s) + 1];
  1289. + std::strcpy(__tmp, __s);
  1290. + _M_name_messages = __tmp;
  1291. + }
  1292. +
  1293. + template<typename _CharT>
  1294. + typename messages<_CharT>::catalog
  1295. + messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
  1296. + const char* __dir) const
  1297. + {
  1298. + __bindtextdomain(__s.c_str(), __dir);
  1299. + return this->do_open(__s, __loc);
  1300. + }
  1301. +
  1302. + // Virtual member functions.
  1303. + template<typename _CharT>
  1304. + messages<_CharT>::~messages()
  1305. + {
  1306. + if (_M_name_messages != _S_get_c_name())
  1307. + delete [] _M_name_messages;
  1308. + _S_destroy_c_locale(_M_c_locale_messages);
  1309. + }
  1310. +
  1311. + template<typename _CharT>
  1312. + typename messages<_CharT>::catalog
  1313. + messages<_CharT>::do_open(const basic_string<char>& __s,
  1314. + const locale&) const
  1315. + {
  1316. + // No error checking is done, assume the catalog exists and can
  1317. + // be used.
  1318. + __textdomain(__s.c_str());
  1319. + return 0;
  1320. + }
  1321. +
  1322. + template<typename _CharT>
  1323. + void
  1324. + messages<_CharT>::do_close(catalog) const
  1325. + { }
  1326. +
  1327. + // messages_byname
  1328. + template<typename _CharT>
  1329. + messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
  1330. + : messages<_CharT>(__refs)
  1331. + {
  1332. + if (this->_M_name_messages != locale::facet::_S_get_c_name())
  1333. + delete [] this->_M_name_messages;
  1334. + char* __tmp = new char[std::strlen(__s) + 1];
  1335. + std::strcpy(__tmp, __s);
  1336. + this->_M_name_messages = __tmp;
  1337. +
  1338. + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
  1339. + {
  1340. + this->_S_destroy_c_locale(this->_M_c_locale_messages);
  1341. + this->_S_create_c_locale(this->_M_c_locale_messages, __s);
  1342. + }
  1343. + }
  1344. --- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
  1345. +++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc
  1346. @@ -0,0 +1,692 @@
  1347. +// std::moneypunct implementation details, GNU version -*- C++ -*-
  1348. +
  1349. +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  1350. +//
  1351. +// This file is part of the GNU ISO C++ Library. This library is free
  1352. +// software; you can redistribute it and/or modify it under the
  1353. +// terms of the GNU General Public License as published by the
  1354. +// Free Software Foundation; either version 2, or (at your option)
  1355. +// any later version.
  1356. +
  1357. +// This library is distributed in the hope that it will be useful,
  1358. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  1359. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1360. +// GNU General Public License for more details.
  1361. +
  1362. +// You should have received a copy of the GNU General Public License along
  1363. +// with this library; see the file COPYING. If not, write to the Free
  1364. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  1365. +// USA.
  1366. +
  1367. +// As a special exception, you may use this file as part of a free software
  1368. +// library without restriction. Specifically, if other files instantiate
  1369. +// templates or use macros or inline functions from this file, or you compile
  1370. +// this file and link it with other files to produce an executable, this
  1371. +// file does not by itself cause the resulting executable to be covered by
  1372. +// the GNU General Public License. This exception does not however
  1373. +// invalidate any other reasons why the executable file might be covered by
  1374. +// the GNU General Public License.
  1375. +
  1376. +//
  1377. +// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
  1378. +//
  1379. +
  1380. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  1381. +
  1382. +#define _LIBC
  1383. +#include <locale>
  1384. +#undef _LIBC
  1385. +#include <bits/c++locale_internal.h>
  1386. +
  1387. +#ifdef __UCLIBC_MJN3_ONLY__
  1388. +#warning optimize this for uclibc
  1389. +#warning tailor for stub locale support
  1390. +#endif
  1391. +
  1392. +#ifndef __UCLIBC_HAS_XLOCALE__
  1393. +#define __nl_langinfo_l(N, L) nl_langinfo((N))
  1394. +#endif
  1395. +
  1396. +namespace std
  1397. +{
  1398. + // Construct and return valid pattern consisting of some combination of:
  1399. + // space none symbol sign value
  1400. + money_base::pattern
  1401. + money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
  1402. + {
  1403. + pattern __ret;
  1404. +
  1405. + // This insanely complicated routine attempts to construct a valid
  1406. + // pattern for use with monyepunct. A couple of invariants:
  1407. +
  1408. + // if (__precedes) symbol -> value
  1409. + // else value -> symbol
  1410. +
  1411. + // if (__space) space
  1412. + // else none
  1413. +
  1414. + // none == never first
  1415. + // space never first or last
  1416. +
  1417. + // Any elegant implementations of this are welcome.
  1418. + switch (__posn)
  1419. + {
  1420. + case 0:
  1421. + case 1:
  1422. + // 1 The sign precedes the value and symbol.
  1423. + __ret.field[0] = sign;
  1424. + if (__space)
  1425. + {
  1426. + // Pattern starts with sign.
  1427. + if (__precedes)
  1428. + {
  1429. + __ret.field[1] = symbol;
  1430. + __ret.field[3] = value;
  1431. + }
  1432. + else
  1433. + {
  1434. + __ret.field[1] = value;
  1435. + __ret.field[3] = symbol;
  1436. + }
  1437. + __ret.field[2] = space;
  1438. + }
  1439. + else
  1440. + {
  1441. + // Pattern starts with sign and ends with none.
  1442. + if (__precedes)
  1443. + {
  1444. + __ret.field[1] = symbol;
  1445. + __ret.field[2] = value;
  1446. + }
  1447. + else
  1448. + {
  1449. + __ret.field[1] = value;
  1450. + __ret.field[2] = symbol;
  1451. + }
  1452. + __ret.field[3] = none;
  1453. + }
  1454. + break;
  1455. + case 2:
  1456. + // 2 The sign follows the value and symbol.
  1457. + if (__space)
  1458. + {
  1459. + // Pattern either ends with sign.
  1460. + if (__precedes)
  1461. + {
  1462. + __ret.field[0] = symbol;
  1463. + __ret.field[2] = value;
  1464. + }
  1465. + else
  1466. + {
  1467. + __ret.field[0] = value;
  1468. + __ret.field[2] = symbol;
  1469. + }
  1470. + __ret.field[1] = space;
  1471. + __ret.field[3] = sign;
  1472. + }
  1473. + else
  1474. + {
  1475. + // Pattern ends with sign then none.
  1476. + if (__precedes)
  1477. + {
  1478. + __ret.field[0] = symbol;
  1479. + __ret.field[1] = value;
  1480. + }
  1481. + else
  1482. + {
  1483. + __ret.field[0] = value;
  1484. + __ret.field[1] = symbol;
  1485. + }
  1486. + __ret.field[2] = sign;
  1487. + __ret.field[3] = none;
  1488. + }
  1489. + break;
  1490. + case 3:
  1491. + // 3 The sign immediately precedes the symbol.
  1492. + if (__precedes)
  1493. + {
  1494. + __ret.field[0] = sign;
  1495. + __ret.field[1] = symbol;
  1496. + if (__space)
  1497. + {
  1498. + __ret.field[2] = space;
  1499. + __ret.field[3] = value;
  1500. + }
  1501. + else
  1502. + {
  1503. + __ret.field[2] = value;
  1504. + __ret.field[3] = none;
  1505. + }
  1506. + }
  1507. + else
  1508. + {
  1509. + __ret.field[0] = value;
  1510. + if (__space)
  1511. + {
  1512. + __ret.field[1] = space;
  1513. + __ret.field[2] = sign;
  1514. + __ret.field[3] = symbol;
  1515. + }
  1516. + else
  1517. + {
  1518. + __ret.field[1] = sign;
  1519. + __ret.field[2] = symbol;
  1520. + __ret.field[3] = none;
  1521. + }
  1522. + }
  1523. + break;
  1524. + case 4:
  1525. + // 4 The sign immediately follows the symbol.
  1526. + if (__precedes)
  1527. + {
  1528. + __ret.field[0] = symbol;
  1529. + __ret.field[1] = sign;
  1530. + if (__space)
  1531. + {
  1532. + __ret.field[2] = space;
  1533. + __ret.field[3] = value;
  1534. + }
  1535. + else
  1536. + {
  1537. + __ret.field[2] = value;
  1538. + __ret.field[3] = none;
  1539. + }
  1540. + }
  1541. + else
  1542. + {
  1543. + __ret.field[0] = value;
  1544. + if (__space)
  1545. + {
  1546. + __ret.field[1] = space;
  1547. + __ret.field[2] = symbol;
  1548. + __ret.field[3] = sign;
  1549. + }
  1550. + else
  1551. + {
  1552. + __ret.field[1] = symbol;
  1553. + __ret.field[2] = sign;
  1554. + __ret.field[3] = none;
  1555. + }
  1556. + }
  1557. + break;
  1558. + default:
  1559. + ;
  1560. + }
  1561. + return __ret;
  1562. + }
  1563. +
  1564. + template<>
  1565. + void
  1566. + moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
  1567. + const char*)
  1568. + {
  1569. + if (!_M_data)
  1570. + _M_data = new __moneypunct_cache<char, true>;
  1571. +
  1572. + if (!__cloc)
  1573. + {
  1574. + // "C" locale
  1575. + _M_data->_M_decimal_point = '.';
  1576. + _M_data->_M_thousands_sep = ',';
  1577. + _M_data->_M_grouping = "";
  1578. + _M_data->_M_grouping_size = 0;
  1579. + _M_data->_M_curr_symbol = "";
  1580. + _M_data->_M_curr_symbol_size = 0;
  1581. + _M_data->_M_positive_sign = "";
  1582. + _M_data->_M_positive_sign_size = 0;
  1583. + _M_data->_M_negative_sign = "";
  1584. + _M_data->_M_negative_sign_size = 0;
  1585. + _M_data->_M_frac_digits = 0;
  1586. + _M_data->_M_pos_format = money_base::_S_default_pattern;
  1587. + _M_data->_M_neg_format = money_base::_S_default_pattern;
  1588. +
  1589. + for (size_t __i = 0; __i < money_base::_S_end; ++__i)
  1590. + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
  1591. + }
  1592. + else
  1593. + {
  1594. + // Named locale.
  1595. + _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
  1596. + __cloc));
  1597. + _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
  1598. + __cloc));
  1599. + _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
  1600. + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  1601. + _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
  1602. + _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
  1603. +
  1604. + char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
  1605. + if (!__nposn)
  1606. + _M_data->_M_negative_sign = "()";
  1607. + else
  1608. + _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
  1609. + __cloc);
  1610. + _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
  1611. +
  1612. + // _Intl == true
  1613. + _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
  1614. + _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
  1615. + _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
  1616. + __cloc));
  1617. + char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
  1618. + char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
  1619. + char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
  1620. + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
  1621. + __pposn);
  1622. + char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
  1623. + char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
  1624. + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
  1625. + __nposn);
  1626. + }
  1627. + }
  1628. +
  1629. + template<>
  1630. + void
  1631. + moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
  1632. + const char*)
  1633. + {
  1634. + if (!_M_data)
  1635. + _M_data = new __moneypunct_cache<char, false>;
  1636. +
  1637. + if (!__cloc)
  1638. + {
  1639. + // "C" locale
  1640. + _M_data->_M_decimal_point = '.';
  1641. + _M_data->_M_thousands_sep = ',';
  1642. + _M_data->_M_grouping = "";
  1643. + _M_data->_M_grouping_size = 0;
  1644. + _M_data->_M_curr_symbol = "";
  1645. + _M_data->_M_curr_symbol_size = 0;
  1646. + _M_data->_M_positive_sign = "";
  1647. + _M_data->_M_positive_sign_size = 0;
  1648. + _M_data->_M_negative_sign = "";
  1649. + _M_data->_M_negative_sign_size = 0;
  1650. + _M_data->_M_frac_digits = 0;
  1651. + _M_data->_M_pos_format = money_base::_S_default_pattern;
  1652. + _M_data->_M_neg_format = money_base::_S_default_pattern;
  1653. +
  1654. + for (size_t __i = 0; __i < money_base::_S_end; ++__i)
  1655. + _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
  1656. + }
  1657. + else
  1658. + {
  1659. + // Named locale.
  1660. + _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
  1661. + __cloc));
  1662. + _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
  1663. + __cloc));
  1664. + _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
  1665. + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  1666. + _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
  1667. + _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
  1668. +
  1669. + char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
  1670. + if (!__nposn)
  1671. + _M_data->_M_negative_sign = "()";
  1672. + else
  1673. + _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
  1674. + __cloc);
  1675. + _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
  1676. +
  1677. + // _Intl == false
  1678. + _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
  1679. + _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
  1680. + _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
  1681. + char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
  1682. + char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
  1683. + char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
  1684. + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
  1685. + __pposn);
  1686. + char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
  1687. + char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
  1688. + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
  1689. + __nposn);
  1690. + }
  1691. + }
  1692. +
  1693. + template<>
  1694. + moneypunct<char, true>::~moneypunct()
  1695. + { delete _M_data; }
  1696. +
  1697. + template<>
  1698. + moneypunct<char, false>::~moneypunct()
  1699. + { delete _M_data; }
  1700. +
  1701. +#ifdef _GLIBCXX_USE_WCHAR_T
  1702. + template<>
  1703. + void
  1704. + moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
  1705. +#ifdef __UCLIBC_HAS_XLOCALE__
  1706. + const char*)
  1707. +#else
  1708. + const char* __name)
  1709. +#endif
  1710. + {
  1711. + if (!_M_data)
  1712. + _M_data = new __moneypunct_cache<wchar_t, true>;
  1713. +
  1714. + if (!__cloc)
  1715. + {
  1716. + // "C" locale
  1717. + _M_data->_M_decimal_point = L'.';
  1718. + _M_data->_M_thousands_sep = L',';
  1719. + _M_data->_M_grouping = "";
  1720. + _M_data->_M_grouping_size = 0;
  1721. + _M_data->_M_curr_symbol = L"";
  1722. + _M_data->_M_curr_symbol_size = 0;
  1723. + _M_data->_M_positive_sign = L"";
  1724. + _M_data->_M_positive_sign_size = 0;
  1725. + _M_data->_M_negative_sign = L"";
  1726. + _M_data->_M_negative_sign_size = 0;
  1727. + _M_data->_M_frac_digits = 0;
  1728. + _M_data->_M_pos_format = money_base::_S_default_pattern;
  1729. + _M_data->_M_neg_format = money_base::_S_default_pattern;
  1730. +
  1731. + // Use ctype::widen code without the facet...
  1732. + for (size_t __i = 0; __i < money_base::_S_end; ++__i)
  1733. + _M_data->_M_atoms[__i] =
  1734. + static_cast<wchar_t>(money_base::_S_atoms[__i]);
  1735. + }
  1736. + else
  1737. + {
  1738. + // Named locale.
  1739. +#ifdef __UCLIBC_HAS_XLOCALE__
  1740. + __c_locale __old = __uselocale(__cloc);
  1741. +#else
  1742. + // Switch to named locale so that mbsrtowcs will work.
  1743. + char* __old = strdup(setlocale(LC_ALL, NULL));
  1744. + setlocale(LC_ALL, __name);
  1745. +#endif
  1746. +
  1747. +#ifdef __UCLIBC_MJN3_ONLY__
  1748. +#warning fix this... should be monetary
  1749. +#endif
  1750. +#ifdef __UCLIBC__
  1751. +# ifdef __UCLIBC_HAS_XLOCALE__
  1752. + _M_data->_M_decimal_point = __cloc->decimal_point_wc;
  1753. + _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
  1754. +# else
  1755. + _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
  1756. + _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
  1757. +# endif
  1758. +#else
  1759. + union { char *__s; wchar_t __w; } __u;
  1760. + __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
  1761. + _M_data->_M_decimal_point = __u.__w;
  1762. +
  1763. + __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
  1764. + _M_data->_M_thousands_sep = __u.__w;
  1765. +#endif
  1766. + _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
  1767. + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  1768. +
  1769. + const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
  1770. + const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
  1771. + const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
  1772. +
  1773. + wchar_t* __wcs_ps = 0;
  1774. + wchar_t* __wcs_ns = 0;
  1775. + const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
  1776. + try
  1777. + {
  1778. + mbstate_t __state;
  1779. + size_t __len = strlen(__cpossign);
  1780. + if (__len)
  1781. + {
  1782. + ++__len;
  1783. + memset(&__state, 0, sizeof(mbstate_t));
  1784. + __wcs_ps = new wchar_t[__len];
  1785. + mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
  1786. + _M_data->_M_positive_sign = __wcs_ps;
  1787. + }
  1788. + else
  1789. + _M_data->_M_positive_sign = L"";
  1790. + _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
  1791. +
  1792. + __len = strlen(__cnegsign);
  1793. + if (!__nposn)
  1794. + _M_data->_M_negative_sign = L"()";
  1795. + else if (__len)
  1796. + {
  1797. + ++__len;
  1798. + memset(&__state, 0, sizeof(mbstate_t));
  1799. + __wcs_ns = new wchar_t[__len];
  1800. + mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
  1801. + _M_data->_M_negative_sign = __wcs_ns;
  1802. + }
  1803. + else
  1804. + _M_data->_M_negative_sign = L"";
  1805. + _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
  1806. +
  1807. + // _Intl == true.
  1808. + __len = strlen(__ccurr);
  1809. + if (__len)
  1810. + {
  1811. + ++__len;
  1812. + memset(&__state, 0, sizeof(mbstate_t));
  1813. + wchar_t* __wcs = new wchar_t[__len];
  1814. + mbsrtowcs(__wcs, &__ccurr, __len, &__state);
  1815. + _M_data->_M_curr_symbol = __wcs;
  1816. + }
  1817. + else
  1818. + _M_data->_M_curr_symbol = L"";
  1819. + _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
  1820. + }
  1821. + catch (...)
  1822. + {
  1823. + delete _M_data;
  1824. + _M_data = 0;
  1825. + delete __wcs_ps;
  1826. + delete __wcs_ns;
  1827. +#ifdef __UCLIBC_HAS_XLOCALE__
  1828. + __uselocale(__old);
  1829. +#else
  1830. + setlocale(LC_ALL, __old);
  1831. + free(__old);
  1832. +#endif
  1833. + __throw_exception_again;
  1834. + }
  1835. +
  1836. + _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
  1837. + __cloc));
  1838. + char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
  1839. + char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
  1840. + char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
  1841. + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
  1842. + __pposn);
  1843. + char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
  1844. + char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
  1845. + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
  1846. + __nposn);
  1847. +
  1848. +#ifdef __UCLIBC_HAS_XLOCALE__
  1849. + __uselocale(__old);
  1850. +#else
  1851. + setlocale(LC_ALL, __old);
  1852. + free(__old);
  1853. +#endif
  1854. + }
  1855. + }
  1856. +
  1857. + template<>
  1858. + void
  1859. + moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
  1860. +#ifdef __UCLIBC_HAS_XLOCALE__
  1861. + const char*)
  1862. +#else
  1863. + const char* __name)
  1864. +#endif
  1865. + {
  1866. + if (!_M_data)
  1867. + _M_data = new __moneypunct_cache<wchar_t, false>;
  1868. +
  1869. + if (!__cloc)
  1870. + {
  1871. + // "C" locale
  1872. + _M_data->_M_decimal_point = L'.';
  1873. + _M_data->_M_thousands_sep = L',';
  1874. + _M_data->_M_grouping = "";
  1875. + _M_data->_M_grouping_size = 0;
  1876. + _M_data->_M_curr_symbol = L"";
  1877. + _M_data->_M_curr_symbol_size = 0;
  1878. + _M_data->_M_positive_sign = L"";
  1879. + _M_data->_M_positive_sign_size = 0;
  1880. + _M_data->_M_negative_sign = L"";
  1881. + _M_data->_M_negative_sign_size = 0;
  1882. + _M_data->_M_frac_digits = 0;
  1883. + _M_data->_M_pos_format = money_base::_S_default_pattern;
  1884. + _M_data->_M_neg_format = money_base::_S_default_pattern;
  1885. +
  1886. + // Use ctype::widen code without the facet...
  1887. + for (size_t __i = 0; __i < money_base::_S_end; ++__i)
  1888. + _M_data->_M_atoms[__i] =
  1889. + static_cast<wchar_t>(money_base::_S_atoms[__i]);
  1890. + }
  1891. + else
  1892. + {
  1893. + // Named locale.
  1894. +#ifdef __UCLIBC_HAS_XLOCALE__
  1895. + __c_locale __old = __uselocale(__cloc);
  1896. +#else
  1897. + // Switch to named locale so that mbsrtowcs will work.
  1898. + char* __old = strdup(setlocale(LC_ALL, NULL));
  1899. + setlocale(LC_ALL, __name);
  1900. +#endif
  1901. +
  1902. +#ifdef __UCLIBC_MJN3_ONLY__
  1903. +#warning fix this... should be monetary
  1904. +#endif
  1905. +#ifdef __UCLIBC__
  1906. +# ifdef __UCLIBC_HAS_XLOCALE__
  1907. + _M_data->_M_decimal_point = __cloc->decimal_point_wc;
  1908. + _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
  1909. +# else
  1910. + _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
  1911. + _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
  1912. +# endif
  1913. +#else
  1914. + union { char *__s; wchar_t __w; } __u;
  1915. + __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
  1916. + _M_data->_M_decimal_point = __u.__w;
  1917. +
  1918. + __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
  1919. + _M_data->_M_thousands_sep = __u.__w;
  1920. +#endif
  1921. + _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
  1922. + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  1923. +
  1924. + const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
  1925. + const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
  1926. + const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
  1927. +
  1928. + wchar_t* __wcs_ps = 0;
  1929. + wchar_t* __wcs_ns = 0;
  1930. + const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
  1931. + try
  1932. + {
  1933. + mbstate_t __state;
  1934. + size_t __len;
  1935. + __len = strlen(__cpossign);
  1936. + if (__len)
  1937. + {
  1938. + ++__len;
  1939. + memset(&__state, 0, sizeof(mbstate_t));
  1940. + __wcs_ps = new wchar_t[__len];
  1941. + mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
  1942. + _M_data->_M_positive_sign = __wcs_ps;
  1943. + }
  1944. + else
  1945. + _M_data->_M_positive_sign = L"";
  1946. + _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
  1947. +
  1948. + __len = strlen(__cnegsign);
  1949. + if (!__nposn)
  1950. + _M_data->_M_negative_sign = L"()";
  1951. + else if (__len)
  1952. + {
  1953. + ++__len;
  1954. + memset(&__state, 0, sizeof(mbstate_t));
  1955. + __wcs_ns = new wchar_t[__len];
  1956. + mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
  1957. + _M_data->_M_negative_sign = __wcs_ns;
  1958. + }
  1959. + else
  1960. + _M_data->_M_negative_sign = L"";
  1961. + _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
  1962. +
  1963. + // _Intl == true.
  1964. + __len = strlen(__ccurr);
  1965. + if (__len)
  1966. + {
  1967. + ++__len;
  1968. + memset(&__state, 0, sizeof(mbstate_t));
  1969. + wchar_t* __wcs = new wchar_t[__len];
  1970. + mbsrtowcs(__wcs, &__ccurr, __len, &__state);
  1971. + _M_data->_M_curr_symbol = __wcs;
  1972. + }
  1973. + else
  1974. + _M_data->_M_curr_symbol = L"";
  1975. + _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
  1976. + }
  1977. + catch (...)
  1978. + {
  1979. + delete _M_data;
  1980. + _M_data = 0;
  1981. + delete __wcs_ps;
  1982. + delete __wcs_ns;
  1983. +#ifdef __UCLIBC_HAS_XLOCALE__
  1984. + __uselocale(__old);
  1985. +#else
  1986. + setlocale(LC_ALL, __old);
  1987. + free(__old);
  1988. +#endif
  1989. + __throw_exception_again;
  1990. + }
  1991. +
  1992. + _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
  1993. + char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
  1994. + char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
  1995. + char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
  1996. + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
  1997. + __pposn);
  1998. + char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
  1999. + char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
  2000. + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
  2001. + __nposn);
  2002. +
  2003. +#ifdef __UCLIBC_HAS_XLOCALE__
  2004. + __uselocale(__old);
  2005. +#else
  2006. + setlocale(LC_ALL, __old);
  2007. + free(__old);
  2008. +#endif
  2009. + }
  2010. + }
  2011. +
  2012. + template<>
  2013. + moneypunct<wchar_t, true>::~moneypunct()
  2014. + {
  2015. + if (_M_data->_M_positive_sign_size)
  2016. + delete [] _M_data->_M_positive_sign;
  2017. + if (_M_data->_M_negative_sign_size
  2018. + && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
  2019. + delete [] _M_data->_M_negative_sign;
  2020. + if (_M_data->_M_curr_symbol_size)
  2021. + delete [] _M_data->_M_curr_symbol;
  2022. + delete _M_data;
  2023. + }
  2024. +
  2025. + template<>
  2026. + moneypunct<wchar_t, false>::~moneypunct()
  2027. + {
  2028. + if (_M_data->_M_positive_sign_size)
  2029. + delete [] _M_data->_M_positive_sign;
  2030. + if (_M_data->_M_negative_sign_size
  2031. + && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
  2032. + delete [] _M_data->_M_negative_sign;
  2033. + if (_M_data->_M_curr_symbol_size)
  2034. + delete [] _M_data->_M_curr_symbol;
  2035. + delete _M_data;
  2036. + }
  2037. +#endif
  2038. +}
  2039. --- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
  2040. +++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc
  2041. @@ -0,0 +1,160 @@
  2042. +// std::numpunct implementation details, GNU version -*- C++ -*-
  2043. +
  2044. +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  2045. +//
  2046. +// This file is part of the GNU ISO C++ Library. This library is free
  2047. +// software; you can redistribute it and/or modify it under the
  2048. +// terms of the GNU General Public License as published by the
  2049. +// Free Software Foundation; either version 2, or (at your option)
  2050. +// any later version.
  2051. +
  2052. +// This library is distributed in the hope that it will be useful,
  2053. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2054. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2055. +// GNU General Public License for more details.
  2056. +
  2057. +// You should have received a copy of the GNU General Public License along
  2058. +// with this library; see the file COPYING. If not, write to the Free
  2059. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2060. +// USA.
  2061. +
  2062. +// As a special exception, you may use this file as part of a free software
  2063. +// library without restriction. Specifically, if other files instantiate
  2064. +// templates or use macros or inline functions from this file, or you compile
  2065. +// this file and link it with other files to produce an executable, this
  2066. +// file does not by itself cause the resulting executable to be covered by
  2067. +// the GNU General Public License. This exception does not however
  2068. +// invalidate any other reasons why the executable file might be covered by
  2069. +// the GNU General Public License.
  2070. +
  2071. +//
  2072. +// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
  2073. +//
  2074. +
  2075. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  2076. +
  2077. +#define _LIBC
  2078. +#include <locale>
  2079. +#undef _LIBC
  2080. +#include <bits/c++locale_internal.h>
  2081. +
  2082. +#ifdef __UCLIBC_MJN3_ONLY__
  2083. +#warning tailor for stub locale support
  2084. +#endif
  2085. +#ifndef __UCLIBC_HAS_XLOCALE__
  2086. +#define __nl_langinfo_l(N, L) nl_langinfo((N))
  2087. +#endif
  2088. +
  2089. +namespace std
  2090. +{
  2091. + template<>
  2092. + void
  2093. + numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
  2094. + {
  2095. + if (!_M_data)
  2096. + _M_data = new __numpunct_cache<char>;
  2097. +
  2098. + if (!__cloc)
  2099. + {
  2100. + // "C" locale
  2101. + _M_data->_M_grouping = "";
  2102. + _M_data->_M_grouping_size = 0;
  2103. + _M_data->_M_use_grouping = false;
  2104. +
  2105. + _M_data->_M_decimal_point = '.';
  2106. + _M_data->_M_thousands_sep = ',';
  2107. +
  2108. + for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
  2109. + _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
  2110. +
  2111. + for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
  2112. + _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
  2113. + }
  2114. + else
  2115. + {
  2116. + // Named locale.
  2117. + _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
  2118. + __cloc));
  2119. + _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
  2120. + __cloc));
  2121. +
  2122. + // Check for NULL, which implies no grouping.
  2123. + if (_M_data->_M_thousands_sep == '\0')
  2124. + _M_data->_M_grouping = "";
  2125. + else
  2126. + _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
  2127. + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  2128. + }
  2129. +
  2130. + // NB: There is no way to extact this info from posix locales.
  2131. + // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
  2132. + _M_data->_M_truename = "true";
  2133. + _M_data->_M_truename_size = 4;
  2134. + // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
  2135. + _M_data->_M_falsename = "false";
  2136. + _M_data->_M_falsename_size = 5;
  2137. + }
  2138. +
  2139. + template<>
  2140. + numpunct<char>::~numpunct()
  2141. + { delete _M_data; }
  2142. +
  2143. +#ifdef _GLIBCXX_USE_WCHAR_T
  2144. + template<>
  2145. + void
  2146. + numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
  2147. + {
  2148. + if (!_M_data)
  2149. + _M_data = new __numpunct_cache<wchar_t>;
  2150. +
  2151. + if (!__cloc)
  2152. + {
  2153. + // "C" locale
  2154. + _M_data->_M_grouping = "";
  2155. + _M_data->_M_grouping_size = 0;
  2156. + _M_data->_M_use_grouping = false;
  2157. +
  2158. + _M_data->_M_decimal_point = L'.';
  2159. + _M_data->_M_thousands_sep = L',';
  2160. +
  2161. + // Use ctype::widen code without the facet...
  2162. + for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
  2163. + _M_data->_M_atoms_out[__i] =
  2164. + static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
  2165. +
  2166. + for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
  2167. + _M_data->_M_atoms_in[__j] =
  2168. + static_cast<wchar_t>(__num_base::_S_atoms_in[__j]);
  2169. + }
  2170. + else
  2171. + {
  2172. + // Named locale.
  2173. + // NB: In the GNU model wchar_t is always 32 bit wide.
  2174. + union { char *__s; wchar_t __w; } __u;
  2175. + __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
  2176. + _M_data->_M_decimal_point = __u.__w;
  2177. +
  2178. + __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
  2179. + _M_data->_M_thousands_sep = __u.__w;
  2180. +
  2181. + if (_M_data->_M_thousands_sep == L'\0')
  2182. + _M_data->_M_grouping = "";
  2183. + else
  2184. + _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
  2185. + _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
  2186. + }
  2187. +
  2188. + // NB: There is no way to extact this info from posix locales.
  2189. + // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
  2190. + _M_data->_M_truename = L"true";
  2191. + _M_data->_M_truename_size = 4;
  2192. + // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
  2193. + _M_data->_M_falsename = L"false";
  2194. + _M_data->_M_falsename_size = 5;
  2195. + }
  2196. +
  2197. + template<>
  2198. + numpunct<wchar_t>::~numpunct()
  2199. + { delete _M_data; }
  2200. + #endif
  2201. +}
  2202. --- gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
  2203. +++ gcc/libstdc++-v3/config/locale/uclibc/time_members.cc
  2204. @@ -0,0 +1,406 @@
  2205. +// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
  2206. +
  2207. +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  2208. +//
  2209. +// This file is part of the GNU ISO C++ Library. This library is free
  2210. +// software; you can redistribute it and/or modify it under the
  2211. +// terms of the GNU General Public License as published by the
  2212. +// Free Software Foundation; either version 2, or (at your option)
  2213. +// any later version.
  2214. +
  2215. +// This library is distributed in the hope that it will be useful,
  2216. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2217. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2218. +// GNU General Public License for more details.
  2219. +
  2220. +// You should have received a copy of the GNU General Public License along
  2221. +// with this library; see the file COPYING. If not, write to the Free
  2222. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2223. +// USA.
  2224. +
  2225. +// As a special exception, you may use this file as part of a free software
  2226. +// library without restriction. Specifically, if other files instantiate
  2227. +// templates or use macros or inline functions from this file, or you compile
  2228. +// this file and link it with other files to produce an executable, this
  2229. +// file does not by itself cause the resulting executable to be covered by
  2230. +// the GNU General Public License. This exception does not however
  2231. +// invalidate any other reasons why the executable file might be covered by
  2232. +// the GNU General Public License.
  2233. +
  2234. +//
  2235. +// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
  2236. +// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
  2237. +//
  2238. +
  2239. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  2240. +
  2241. +#include <locale>
  2242. +#include <bits/c++locale_internal.h>
  2243. +
  2244. +#ifdef __UCLIBC_MJN3_ONLY__
  2245. +#warning tailor for stub locale support
  2246. +#endif
  2247. +#ifndef __UCLIBC_HAS_XLOCALE__
  2248. +#define __nl_langinfo_l(N, L) nl_langinfo((N))
  2249. +#endif
  2250. +
  2251. +namespace std
  2252. +{
  2253. + template<>
  2254. + void
  2255. + __timepunct<char>::
  2256. + _M_put(char* __s, size_t __maxlen, const char* __format,
  2257. + const tm* __tm) const
  2258. + {
  2259. +#ifdef __UCLIBC_HAS_XLOCALE__
  2260. + const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
  2261. + _M_c_locale_timepunct);
  2262. +#else
  2263. + char* __old = strdup(setlocale(LC_ALL, NULL));
  2264. + setlocale(LC_ALL, _M_name_timepunct);
  2265. + const size_t __len = strftime(__s, __maxlen, __format, __tm);
  2266. + setlocale(LC_ALL, __old);
  2267. + free(__old);
  2268. +#endif
  2269. + // Make sure __s is null terminated.
  2270. + if (__len == 0)
  2271. + __s[0] = '\0';
  2272. + }
  2273. +
  2274. + template<>
  2275. + void
  2276. + __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
  2277. + {
  2278. + if (!_M_data)
  2279. + _M_data = new __timepunct_cache<char>;
  2280. +
  2281. + if (!__cloc)
  2282. + {
  2283. + // "C" locale
  2284. + _M_c_locale_timepunct = _S_get_c_locale();
  2285. +
  2286. + _M_data->_M_date_format = "%m/%d/%y";
  2287. + _M_data->_M_date_era_format = "%m/%d/%y";
  2288. + _M_data->_M_time_format = "%H:%M:%S";
  2289. + _M_data->_M_time_era_format = "%H:%M:%S";
  2290. + _M_data->_M_date_time_format = "";
  2291. + _M_data->_M_date_time_era_format = "";
  2292. + _M_data->_M_am = "AM";
  2293. + _M_data->_M_pm = "PM";
  2294. + _M_data->_M_am_pm_format = "";
  2295. +
  2296. + // Day names, starting with "C"'s Sunday.
  2297. + _M_data->_M_day1 = "Sunday";
  2298. + _M_data->_M_day2 = "Monday";
  2299. + _M_data->_M_day3 = "Tuesday";
  2300. + _M_data->_M_day4 = "Wednesday";
  2301. + _M_data->_M_day5 = "Thursday";
  2302. + _M_data->_M_day6 = "Friday";
  2303. + _M_data->_M_day7 = "Saturday";
  2304. +
  2305. + // Abbreviated day names, starting with "C"'s Sun.
  2306. + _M_data->_M_aday1 = "Sun";
  2307. + _M_data->_M_aday2 = "Mon";
  2308. + _M_data->_M_aday3 = "Tue";
  2309. + _M_data->_M_aday4 = "Wed";
  2310. + _M_data->_M_aday5 = "Thu";
  2311. + _M_data->_M_aday6 = "Fri";
  2312. + _M_data->_M_aday7 = "Sat";
  2313. +
  2314. + // Month names, starting with "C"'s January.
  2315. + _M_data->_M_month01 = "January";
  2316. + _M_data->_M_month02 = "February";
  2317. + _M_data->_M_month03 = "March";
  2318. + _M_data->_M_month04 = "April";
  2319. + _M_data->_M_month05 = "May";
  2320. + _M_data->_M_month06 = "June";
  2321. + _M_data->_M_month07 = "July";
  2322. + _M_data->_M_month08 = "August";
  2323. + _M_data->_M_month09 = "September";
  2324. + _M_data->_M_month10 = "October";
  2325. + _M_data->_M_month11 = "November";
  2326. + _M_data->_M_month12 = "December";
  2327. +
  2328. + // Abbreviated month names, starting with "C"'s Jan.
  2329. + _M_data->_M_amonth01 = "Jan";
  2330. + _M_data->_M_amonth02 = "Feb";
  2331. + _M_data->_M_amonth03 = "Mar";
  2332. + _M_data->_M_amonth04 = "Apr";
  2333. + _M_data->_M_amonth05 = "May";
  2334. + _M_data->_M_amonth06 = "Jun";
  2335. + _M_data->_M_amonth07 = "Jul";
  2336. + _M_data->_M_amonth08 = "Aug";
  2337. + _M_data->_M_amonth09 = "Sep";
  2338. + _M_data->_M_amonth10 = "Oct";
  2339. + _M_data->_M_amonth11 = "Nov";
  2340. + _M_data->_M_amonth12 = "Dec";
  2341. + }
  2342. + else
  2343. + {
  2344. + _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
  2345. +
  2346. + _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
  2347. + _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
  2348. + _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
  2349. + _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
  2350. + _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
  2351. + _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
  2352. + __cloc);
  2353. + _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
  2354. + _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
  2355. + _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
  2356. +
  2357. + // Day names, starting with "C"'s Sunday.
  2358. + _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
  2359. + _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
  2360. + _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
  2361. + _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
  2362. + _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
  2363. + _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
  2364. + _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
  2365. +
  2366. + // Abbreviated day names, starting with "C"'s Sun.
  2367. + _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
  2368. + _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
  2369. + _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
  2370. + _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
  2371. + _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
  2372. + _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
  2373. + _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
  2374. +
  2375. + // Month names, starting with "C"'s January.
  2376. + _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
  2377. + _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
  2378. + _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
  2379. + _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
  2380. + _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
  2381. + _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
  2382. + _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
  2383. + _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
  2384. + _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
  2385. + _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
  2386. + _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
  2387. + _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
  2388. +
  2389. + // Abbreviated month names, starting with "C"'s Jan.
  2390. + _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
  2391. + _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
  2392. + _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
  2393. + _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
  2394. + _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
  2395. + _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
  2396. + _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
  2397. + _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
  2398. + _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
  2399. + _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
  2400. + _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
  2401. + _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
  2402. + }
  2403. + }
  2404. +
  2405. +#ifdef _GLIBCXX_USE_WCHAR_T
  2406. + template<>
  2407. + void
  2408. + __timepunct<wchar_t>::
  2409. + _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
  2410. + const tm* __tm) const
  2411. + {
  2412. +#ifdef __UCLIBC_HAS_XLOCALE__
  2413. + __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
  2414. + const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
  2415. + _M_c_locale_timepunct);
  2416. +#else
  2417. + char* __old = strdup(setlocale(LC_ALL, NULL));
  2418. + setlocale(LC_ALL, _M_name_timepunct);
  2419. + const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
  2420. + setlocale(LC_ALL, __old);
  2421. + free(__old);
  2422. +#endif
  2423. + // Make sure __s is null terminated.
  2424. + if (__len == 0)
  2425. + __s[0] = L'\0';
  2426. + }
  2427. +
  2428. + template<>
  2429. + void
  2430. + __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
  2431. + {
  2432. + if (!_M_data)
  2433. + _M_data = new __timepunct_cache<wchar_t>;
  2434. +
  2435. +#warning wide time stuff
  2436. +// if (!__cloc)
  2437. + {
  2438. + // "C" locale
  2439. + _M_c_locale_timepunct = _S_get_c_locale();
  2440. +
  2441. + _M_data->_M_date_format = L"%m/%d/%y";
  2442. + _M_data->_M_date_era_format = L"%m/%d/%y";
  2443. + _M_data->_M_time_format = L"%H:%M:%S";
  2444. + _M_data->_M_time_era_format = L"%H:%M:%S";
  2445. + _M_data->_M_date_time_format = L"";
  2446. + _M_data->_M_date_time_era_format = L"";
  2447. + _M_data->_M_am = L"AM";
  2448. + _M_data->_M_pm = L"PM";
  2449. + _M_data->_M_am_pm_format = L"";
  2450. +
  2451. + // Day names, starting with "C"'s Sunday.
  2452. + _M_data->_M_day1 = L"Sunday";
  2453. + _M_data->_M_day2 = L"Monday";
  2454. + _M_data->_M_day3 = L"Tuesday";
  2455. + _M_data->_M_day4 = L"Wednesday";
  2456. + _M_data->_M_day5 = L"Thursday";
  2457. + _M_data->_M_day6 = L"Friday";
  2458. + _M_data->_M_day7 = L"Saturday";
  2459. +
  2460. + // Abbreviated day names, starting with "C"'s Sun.
  2461. + _M_data->_M_aday1 = L"Sun";
  2462. + _M_data->_M_aday2 = L"Mon";
  2463. + _M_data->_M_aday3 = L"Tue";
  2464. + _M_data->_M_aday4 = L"Wed";
  2465. + _M_data->_M_aday5 = L"Thu";
  2466. + _M_data->_M_aday6 = L"Fri";
  2467. + _M_data->_M_aday7 = L"Sat";
  2468. +
  2469. + // Month names, starting with "C"'s January.
  2470. + _M_data->_M_month01 = L"January";
  2471. + _M_data->_M_month02 = L"February";
  2472. + _M_data->_M_month03 = L"March";
  2473. + _M_data->_M_month04 = L"April";
  2474. + _M_data->_M_month05 = L"May";
  2475. + _M_data->_M_month06 = L"June";
  2476. + _M_data->_M_month07 = L"July";
  2477. + _M_data->_M_month08 = L"August";
  2478. + _M_data->_M_month09 = L"September";
  2479. + _M_data->_M_month10 = L"October";
  2480. + _M_data->_M_month11 = L"November";
  2481. + _M_data->_M_month12 = L"December";
  2482. +
  2483. + // Abbreviated month names, starting with "C"'s Jan.
  2484. + _M_data->_M_amonth01 = L"Jan";
  2485. + _M_data->_M_amonth02 = L"Feb";
  2486. + _M_data->_M_amonth03 = L"Mar";
  2487. + _M_data->_M_amonth04 = L"Apr";
  2488. + _M_data->_M_amonth05 = L"May";
  2489. + _M_data->_M_amonth06 = L"Jun";
  2490. + _M_data->_M_amonth07 = L"Jul";
  2491. + _M_data->_M_amonth08 = L"Aug";
  2492. + _M_data->_M_amonth09 = L"Sep";
  2493. + _M_data->_M_amonth10 = L"Oct";
  2494. + _M_data->_M_amonth11 = L"Nov";
  2495. + _M_data->_M_amonth12 = L"Dec";
  2496. + }
  2497. +#if 0
  2498. + else
  2499. + {
  2500. + _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
  2501. +
  2502. + union { char *__s; wchar_t *__w; } __u;
  2503. +
  2504. + __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
  2505. + _M_data->_M_date_format = __u.__w;
  2506. + __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
  2507. + _M_data->_M_date_era_format = __u.__w;
  2508. + __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
  2509. + _M_data->_M_time_format = __u.__w;
  2510. + __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
  2511. + _M_data->_M_time_era_format = __u.__w;
  2512. + __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
  2513. + _M_data->_M_date_time_format = __u.__w;
  2514. + __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
  2515. + _M_data->_M_date_time_era_format = __u.__w;
  2516. + __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
  2517. + _M_data->_M_am = __u.__w;
  2518. + __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
  2519. + _M_data->_M_pm = __u.__w;
  2520. + __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
  2521. + _M_data->_M_am_pm_format = __u.__w;
  2522. +
  2523. + // Day names, starting with "C"'s Sunday.
  2524. + __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
  2525. + _M_data->_M_day1 = __u.__w;
  2526. + __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
  2527. + _M_data->_M_day2 = __u.__w;
  2528. + __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
  2529. + _M_data->_M_day3 = __u.__w;
  2530. + __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
  2531. + _M_data->_M_day4 = __u.__w;
  2532. + __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
  2533. + _M_data->_M_day5 = __u.__w;
  2534. + __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
  2535. + _M_data->_M_day6 = __u.__w;
  2536. + __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
  2537. + _M_data->_M_day7 = __u.__w;
  2538. +
  2539. + // Abbreviated day names, starting with "C"'s Sun.
  2540. + __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
  2541. + _M_data->_M_aday1 = __u.__w;
  2542. + __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
  2543. + _M_data->_M_aday2 = __u.__w;
  2544. + __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
  2545. + _M_data->_M_aday3 = __u.__w;
  2546. + __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
  2547. + _M_data->_M_aday4 = __u.__w;
  2548. + __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
  2549. + _M_data->_M_aday5 = __u.__w;
  2550. + __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
  2551. + _M_data->_M_aday6 = __u.__w;
  2552. + __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
  2553. + _M_data->_M_aday7 = __u.__w;
  2554. +
  2555. + // Month names, starting with "C"'s January.
  2556. + __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
  2557. + _M_data->_M_month01 = __u.__w;
  2558. + __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
  2559. + _M_data->_M_month02 = __u.__w;
  2560. + __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
  2561. + _M_data->_M_month03 = __u.__w;
  2562. + __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
  2563. + _M_data->_M_month04 = __u.__w;
  2564. + __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
  2565. + _M_data->_M_month05 = __u.__w;
  2566. + __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
  2567. + _M_data->_M_month06 = __u.__w;
  2568. + __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
  2569. + _M_data->_M_month07 = __u.__w;
  2570. + __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
  2571. + _M_data->_M_month08 = __u.__w;
  2572. + __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
  2573. + _M_data->_M_month09 = __u.__w;
  2574. + __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
  2575. + _M_data->_M_month10 = __u.__w;
  2576. + __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
  2577. + _M_data->_M_month11 = __u.__w;
  2578. + __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
  2579. + _M_data->_M_month12 = __u.__w;
  2580. +
  2581. + // Abbreviated month names, starting with "C"'s Jan.
  2582. + __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
  2583. + _M_data->_M_amonth01 = __u.__w;
  2584. + __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
  2585. + _M_data->_M_amonth02 = __u.__w;
  2586. + __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
  2587. + _M_data->_M_amonth03 = __u.__w;
  2588. + __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
  2589. + _M_data->_M_amonth04 = __u.__w;
  2590. + __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
  2591. + _M_data->_M_amonth05 = __u.__w;
  2592. + __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
  2593. + _M_data->_M_amonth06 = __u.__w;
  2594. + __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
  2595. + _M_data->_M_amonth07 = __u.__w;
  2596. + __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
  2597. + _M_data->_M_amonth08 = __u.__w;
  2598. + __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
  2599. + _M_data->_M_amonth09 = __u.__w;
  2600. + __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
  2601. + _M_data->_M_amonth10 = __u.__w;
  2602. + __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
  2603. + _M_data->_M_amonth11 = __u.__w;
  2604. + __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
  2605. + _M_data->_M_amonth12 = __u.__w;
  2606. + }
  2607. +#endif // 0
  2608. + }
  2609. +#endif
  2610. +}
  2611. --- gcc/libstdc++-v3/config/locale/uclibc/time_members.h
  2612. +++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h
  2613. @@ -0,0 +1,68 @@
  2614. +// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
  2615. +
  2616. +// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  2617. +//
  2618. +// This file is part of the GNU ISO C++ Library. This library is free
  2619. +// software; you can redistribute it and/or modify it under the
  2620. +// terms of the GNU General Public License as published by the
  2621. +// Free Software Foundation; either version 2, or (at your option)
  2622. +// any later version.
  2623. +
  2624. +// This library is distributed in the hope that it will be useful,
  2625. +// but WITHOUT ANY WARRANTY; without even the implied warranty of
  2626. +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2627. +// GNU General Public License for more details.
  2628. +
  2629. +// You should have received a copy of the GNU General Public License along
  2630. +// with this library; see the file COPYING. If not, write to the Free
  2631. +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  2632. +// USA.
  2633. +
  2634. +// As a special exception, you may use this file as part of a free software
  2635. +// library without restriction. Specifically, if other files instantiate
  2636. +// templates or use macros or inline functions from this file, or you compile
  2637. +// this file and link it with other files to produce an executable, this
  2638. +// file does not by itself cause the resulting executable to be covered by
  2639. +// the GNU General Public License. This exception does not however
  2640. +// invalidate any other reasons why the executable file might be covered by
  2641. +// the GNU General Public License.
  2642. +
  2643. +//
  2644. +// ISO C++ 14882: 22.2.5.1.2 - time_get functions
  2645. +// ISO C++ 14882: 22.2.5.3.2 - time_put functions
  2646. +//
  2647. +
  2648. +// Written by Benjamin Kosnik <bkoz@redhat.com>
  2649. +
  2650. + template<typename _CharT>
  2651. + __timepunct<_CharT>::__timepunct(size_t __refs)
  2652. + : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
  2653. + _M_name_timepunct(_S_get_c_name())
  2654. + { _M_initialize_timepunct(); }
  2655. +
  2656. + template<typename _CharT>
  2657. + __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
  2658. + : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
  2659. + _M_name_timepunct(_S_get_c_name())
  2660. + { _M_initialize_timepunct(); }
  2661. +
  2662. + template<typename _CharT>
  2663. + __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
  2664. + size_t __refs)
  2665. + : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
  2666. + _M_name_timepunct(__s)
  2667. + {
  2668. + char* __tmp = new char[std::strlen(__s) + 1];
  2669. + std::strcpy(__tmp, __s);
  2670. + _M_name_timepunct = __tmp;
  2671. + _M_initialize_timepunct(__cloc);
  2672. + }
  2673. +
  2674. + template<typename _CharT>
  2675. + __timepunct<_CharT>::~__timepunct()
  2676. + {
  2677. + if (_M_name_timepunct != _S_get_c_name())
  2678. + delete [] _M_name_timepunct;
  2679. + delete _M_data;
  2680. + _S_destroy_c_locale(_M_c_locale_timepunct);
  2681. + }
  2682. --- gcc/libstdc++-v3/configure
  2683. +++ gcc/libstdc++-v3/configure
  2684. @@ -5764,7 +5764,7 @@
  2685. enableval="$enable_clocale"
  2686. case "$enableval" in
  2687. - generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
  2688. + generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
  2689. *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable clocale" >&5
  2690. echo "$as_me: error: Unknown argument to enable/disable clocale" >&2;}
  2691. { (exit 1); exit 1; }; } ;;
  2692. @@ -5789,6 +5789,9 @@
  2693. # Default to "generic".
  2694. if test $enable_clocale_flag = auto; then
  2695. case ${target_os} in
  2696. + linux-uclibc*)
  2697. + enable_clocale_flag=uclibc
  2698. + ;;
  2699. linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
  2700. cat >conftest.$ac_ext <<_ACEOF
  2701. /* confdefs.h. */
  2702. @@ -6019,6 +6022,76 @@
  2703. CTIME_CC=config/locale/generic/time_members.cc
  2704. CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
  2705. ;;
  2706. + uclibc)
  2707. + echo "$as_me:$LINENO: result: uclibc" >&5
  2708. +echo "${ECHO_T}uclibc" >&6
  2709. +
  2710. + # Declare intention to use gettext, and add support for specific
  2711. + # languages.
  2712. + # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
  2713. + ALL_LINGUAS="de fr"
  2714. +
  2715. + # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
  2716. + # Extract the first word of "msgfmt", so it can be a program name with args.
  2717. +set dummy msgfmt; ac_word=$2
  2718. +echo "$as_me:$LINENO: checking for $ac_word" >&5
  2719. +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
  2720. +if test "${ac_cv_prog_check_msgfmt+set}" = set; then
  2721. + echo $ECHO_N "(cached) $ECHO_C" >&6
  2722. +else
  2723. + if test -n "$check_msgfmt"; then
  2724. + ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
  2725. +else
  2726. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  2727. +for as_dir in $PATH
  2728. +do
  2729. + IFS=$as_save_IFS
  2730. + test -z "$as_dir" && as_dir=.
  2731. + for ac_exec_ext in '' $ac_executable_extensions; do
  2732. + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
  2733. + ac_cv_prog_check_msgfmt="yes"
  2734. + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
  2735. + break 2
  2736. + fi
  2737. +done
  2738. +done
  2739. +
  2740. + test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
  2741. +fi
  2742. +fi
  2743. +check_msgfmt=$ac_cv_prog_check_msgfmt
  2744. +if test -n "$check_msgfmt"; then
  2745. + echo "$as_me:$LINENO: result: $check_msgfmt" >&5
  2746. +echo "${ECHO_T}$check_msgfmt" >&6
  2747. +else
  2748. + echo "$as_me:$LINENO: result: no" >&5
  2749. +echo "${ECHO_T}no" >&6
  2750. +fi
  2751. +
  2752. + if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
  2753. + USE_NLS=yes
  2754. + fi
  2755. + # Export the build objects.
  2756. + for ling in $ALL_LINGUAS; do \
  2757. + glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
  2758. + glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
  2759. + done
  2760. +
  2761. +
  2762. +
  2763. + CLOCALE_H=config/locale/uclibc/c_locale.h
  2764. + CLOCALE_CC=config/locale/uclibc/c_locale.cc
  2765. + CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
  2766. + CCOLLATE_CC=config/locale/uclibc/collate_members.cc
  2767. + CCTYPE_CC=config/locale/uclibc/ctype_members.cc
  2768. + CMESSAGES_H=config/locale/uclibc/messages_members.h
  2769. + CMESSAGES_CC=config/locale/uclibc/messages_members.cc
  2770. + CMONEY_CC=config/locale/uclibc/monetary_members.cc
  2771. + CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
  2772. + CTIME_H=config/locale/uclibc/time_members.h
  2773. + CTIME_CC=config/locale/uclibc/time_members.cc
  2774. + CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
  2775. + ;;
  2776. esac
  2777. # This is where the testsuite looks for locale catalogs, using the
  2778. --- gcc/libstdc++-v3/include/c_compatibility/wchar.h
  2779. +++ gcc/libstdc++-v3/include/c_compatibility/wchar.h
  2780. @@ -101,7 +101,9 @@
  2781. using std::wmemcpy;
  2782. using std::wmemmove;
  2783. using std::wmemset;
  2784. +#if _GLIBCXX_HAVE_WCSFTIME
  2785. using std::wcsftime;
  2786. +#endif
  2787. #if _GLIBCXX_USE_C99
  2788. using std::wcstold;
  2789. --- gcc/libstdc++-v3/include/c_std/std_cwchar.h
  2790. +++ gcc/libstdc++-v3/include/c_std/std_cwchar.h
  2791. @@ -182,7 +182,9 @@
  2792. using ::wcscoll;
  2793. using ::wcscpy;
  2794. using ::wcscspn;
  2795. +#if _GLIBCXX_HAVE_WCSFTIME
  2796. using ::wcsftime;
  2797. +#endif
  2798. using ::wcslen;
  2799. using ::wcsncat;
  2800. using ::wcsncmp;