200-uclibc-locale.patch 89 KB

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