locale_facets_nonio.tcc 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834
  1. // Locale support -*- C++ -*-
  2. // Copyright (C) 2007-2022 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file bits/locale_facets_nonio.tcc
  21. * This is an internal header file, included by other library headers.
  22. * Do not attempt to use it directly. @headername{locale}
  23. */
  24. #ifndef _LOCALE_FACETS_NONIO_TCC
  25. #define _LOCALE_FACETS_NONIO_TCC 1
  26. #pragma GCC system_header
  27. namespace std _GLIBCXX_VISIBILITY(default)
  28. {
  29. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  30. template<typename _CharT, bool _Intl>
  31. struct __use_cache<__moneypunct_cache<_CharT, _Intl> >
  32. {
  33. const __moneypunct_cache<_CharT, _Intl>*
  34. operator() (const locale& __loc) const
  35. {
  36. const size_t __i = moneypunct<_CharT, _Intl>::id._M_id();
  37. const locale::facet** __caches = __loc._M_impl->_M_caches;
  38. if (!__caches[__i])
  39. {
  40. __moneypunct_cache<_CharT, _Intl>* __tmp = 0;
  41. __try
  42. {
  43. __tmp = new __moneypunct_cache<_CharT, _Intl>;
  44. __tmp->_M_cache(__loc);
  45. }
  46. __catch(...)
  47. {
  48. delete __tmp;
  49. __throw_exception_again;
  50. }
  51. __loc._M_impl->_M_install_cache(__tmp, __i);
  52. }
  53. return static_cast<
  54. const __moneypunct_cache<_CharT, _Intl>*>(__caches[__i]);
  55. }
  56. };
  57. template<typename _CharT, bool _Intl>
  58. void
  59. __moneypunct_cache<_CharT, _Intl>::_M_cache(const locale& __loc)
  60. {
  61. const moneypunct<_CharT, _Intl>& __mp =
  62. use_facet<moneypunct<_CharT, _Intl> >(__loc);
  63. struct _Scoped_str
  64. {
  65. size_t _M_len;
  66. _CharT* _M_str;
  67. explicit
  68. _Scoped_str(const basic_string<_CharT>& __str)
  69. : _M_len(__str.size()), _M_str(new _CharT[_M_len])
  70. { __str.copy(_M_str, _M_len); }
  71. ~_Scoped_str() { delete[] _M_str; }
  72. void
  73. _M_release(const _CharT*& __p, size_t& __n)
  74. {
  75. __p = _M_str;
  76. __n = _M_len;
  77. _M_str = 0;
  78. }
  79. };
  80. _Scoped_str __curr_symbol(__mp.curr_symbol());
  81. _Scoped_str __positive_sign(__mp.positive_sign());
  82. _Scoped_str __negative_sign(__mp.negative_sign());
  83. const string& __g = __mp.grouping();
  84. const size_t __g_size = __g.size();
  85. char* const __grouping = new char[__g_size];
  86. __g.copy(__grouping, __g_size);
  87. // All allocations succeeded without throwing, OK to modify *this now.
  88. _M_grouping = __grouping;
  89. _M_grouping_size = __g_size;
  90. _M_use_grouping = (__g_size
  91. && static_cast<signed char>(__grouping[0]) > 0
  92. && (__grouping[0]
  93. != __gnu_cxx::__numeric_traits<char>::__max));
  94. _M_decimal_point = __mp.decimal_point();
  95. _M_thousands_sep = __mp.thousands_sep();
  96. __curr_symbol._M_release(_M_curr_symbol, _M_curr_symbol_size);
  97. __positive_sign._M_release(_M_positive_sign, _M_positive_sign_size);
  98. __negative_sign._M_release(_M_negative_sign, _M_negative_sign_size);
  99. _M_frac_digits = __mp.frac_digits();
  100. _M_pos_format = __mp.pos_format();
  101. _M_neg_format = __mp.neg_format();
  102. const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
  103. __ct.widen(money_base::_S_atoms,
  104. money_base::_S_atoms + money_base::_S_end, _M_atoms);
  105. _M_allocated = true;
  106. }
  107. _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
  108. template<typename _CharT, typename _InIter>
  109. template<bool _Intl>
  110. _InIter
  111. money_get<_CharT, _InIter>::
  112. _M_extract(iter_type __beg, iter_type __end, ios_base& __io,
  113. ios_base::iostate& __err, string& __units) const
  114. {
  115. typedef char_traits<_CharT> __traits_type;
  116. typedef typename string_type::size_type size_type;
  117. typedef money_base::part part;
  118. typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
  119. const locale& __loc = __io._M_getloc();
  120. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  121. __use_cache<__cache_type> __uc;
  122. const __cache_type* __lc = __uc(__loc);
  123. const char_type* __lit = __lc->_M_atoms;
  124. // Deduced sign.
  125. bool __negative = false;
  126. // Sign size.
  127. size_type __sign_size = 0;
  128. // True if sign is mandatory.
  129. const bool __mandatory_sign = (__lc->_M_positive_sign_size
  130. && __lc->_M_negative_sign_size);
  131. // String of grouping info from thousands_sep plucked from __units.
  132. string __grouping_tmp;
  133. if (__lc->_M_use_grouping)
  134. __grouping_tmp.reserve(32);
  135. // Last position before the decimal point.
  136. int __last_pos = 0;
  137. // Separator positions, then, possibly, fractional digits.
  138. int __n = 0;
  139. // If input iterator is in a valid state.
  140. bool __testvalid = true;
  141. // Flag marking when a decimal point is found.
  142. bool __testdecfound = false;
  143. // The tentative returned string is stored here.
  144. string __res;
  145. __res.reserve(32);
  146. const char_type* __lit_zero = __lit + money_base::_S_zero;
  147. const money_base::pattern __p = __lc->_M_neg_format;
  148. for (int __i = 0; __i < 4 && __testvalid; ++__i)
  149. {
  150. const part __which = static_cast<part>(__p.field[__i]);
  151. switch (__which)
  152. {
  153. case money_base::symbol:
  154. // According to 22.2.6.1.2, p2, symbol is required
  155. // if (__io.flags() & ios_base::showbase), otherwise
  156. // is optional and consumed only if other characters
  157. // are needed to complete the format.
  158. if (__io.flags() & ios_base::showbase || __sign_size > 1
  159. || __i == 0
  160. || (__i == 1 && (__mandatory_sign
  161. || (static_cast<part>(__p.field[0])
  162. == money_base::sign)
  163. || (static_cast<part>(__p.field[2])
  164. == money_base::space)))
  165. || (__i == 2 && ((static_cast<part>(__p.field[3])
  166. == money_base::value)
  167. || (__mandatory_sign
  168. && (static_cast<part>(__p.field[3])
  169. == money_base::sign)))))
  170. {
  171. const size_type __len = __lc->_M_curr_symbol_size;
  172. size_type __j = 0;
  173. for (; __beg != __end && __j < __len
  174. && *__beg == __lc->_M_curr_symbol[__j];
  175. ++__beg, (void)++__j);
  176. if (__j != __len
  177. && (__j || __io.flags() & ios_base::showbase))
  178. __testvalid = false;
  179. }
  180. break;
  181. case money_base::sign:
  182. // Sign might not exist, or be more than one character long.
  183. if (__lc->_M_positive_sign_size && __beg != __end
  184. && *__beg == __lc->_M_positive_sign[0])
  185. {
  186. __sign_size = __lc->_M_positive_sign_size;
  187. ++__beg;
  188. }
  189. else if (__lc->_M_negative_sign_size && __beg != __end
  190. && *__beg == __lc->_M_negative_sign[0])
  191. {
  192. __negative = true;
  193. __sign_size = __lc->_M_negative_sign_size;
  194. ++__beg;
  195. }
  196. else if (__lc->_M_positive_sign_size
  197. && !__lc->_M_negative_sign_size)
  198. // "... if no sign is detected, the result is given the sign
  199. // that corresponds to the source of the empty string"
  200. __negative = true;
  201. else if (__mandatory_sign)
  202. __testvalid = false;
  203. break;
  204. case money_base::value:
  205. // Extract digits, remove and stash away the
  206. // grouping of found thousands separators.
  207. for (; __beg != __end; ++__beg)
  208. {
  209. const char_type __c = *__beg;
  210. const char_type* __q = __traits_type::find(__lit_zero,
  211. 10, __c);
  212. if (__q != 0)
  213. {
  214. __res += money_base::_S_atoms[__q - __lit];
  215. ++__n;
  216. }
  217. else if (__c == __lc->_M_decimal_point
  218. && !__testdecfound)
  219. {
  220. if (__lc->_M_frac_digits <= 0)
  221. break;
  222. __last_pos = __n;
  223. __n = 0;
  224. __testdecfound = true;
  225. }
  226. else if (__lc->_M_use_grouping
  227. && __c == __lc->_M_thousands_sep
  228. && !__testdecfound)
  229. {
  230. if (__n)
  231. {
  232. // Mark position for later analysis.
  233. __grouping_tmp += static_cast<char>(__n);
  234. __n = 0;
  235. }
  236. else
  237. {
  238. __testvalid = false;
  239. break;
  240. }
  241. }
  242. else
  243. break;
  244. }
  245. if (__res.empty())
  246. __testvalid = false;
  247. break;
  248. case money_base::space:
  249. // At least one space is required.
  250. if (__beg != __end && __ctype.is(ctype_base::space, *__beg))
  251. ++__beg;
  252. else
  253. __testvalid = false;
  254. // fallthrough
  255. case money_base::none:
  256. // Only if not at the end of the pattern.
  257. if (__i != 3)
  258. for (; __beg != __end
  259. && __ctype.is(ctype_base::space, *__beg); ++__beg);
  260. break;
  261. }
  262. }
  263. // Need to get the rest of the sign characters, if they exist.
  264. if (__sign_size > 1 && __testvalid)
  265. {
  266. const char_type* __sign = __negative ? __lc->_M_negative_sign
  267. : __lc->_M_positive_sign;
  268. size_type __i = 1;
  269. for (; __beg != __end && __i < __sign_size
  270. && *__beg == __sign[__i]; ++__beg, (void)++__i);
  271. if (__i != __sign_size)
  272. __testvalid = false;
  273. }
  274. if (__testvalid)
  275. {
  276. // Strip leading zeros.
  277. if (__res.size() > 1)
  278. {
  279. const size_type __first = __res.find_first_not_of('0');
  280. const bool __only_zeros = __first == string::npos;
  281. if (__first)
  282. __res.erase(0, __only_zeros ? __res.size() - 1 : __first);
  283. }
  284. // 22.2.6.1.2, p4
  285. if (__negative && __res[0] != '0')
  286. __res.insert(__res.begin(), '-');
  287. // Test for grouping fidelity.
  288. if (__grouping_tmp.size())
  289. {
  290. // Add the ending grouping.
  291. __grouping_tmp += static_cast<char>(__testdecfound ? __last_pos
  292. : __n);
  293. if (!std::__verify_grouping(__lc->_M_grouping,
  294. __lc->_M_grouping_size,
  295. __grouping_tmp))
  296. __err |= ios_base::failbit;
  297. }
  298. // Iff not enough digits were supplied after the decimal-point.
  299. if (__testdecfound && __n != __lc->_M_frac_digits)
  300. __testvalid = false;
  301. }
  302. // Iff valid sequence is not recognized.
  303. if (!__testvalid)
  304. __err |= ios_base::failbit;
  305. else
  306. __units.swap(__res);
  307. // Iff no more characters are available.
  308. if (__beg == __end)
  309. __err |= ios_base::eofbit;
  310. return __beg;
  311. }
  312. #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
  313. && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__)
  314. template<typename _CharT, typename _InIter>
  315. _InIter
  316. money_get<_CharT, _InIter>::
  317. __do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
  318. ios_base::iostate& __err, double& __units) const
  319. {
  320. string __str;
  321. __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
  322. : _M_extract<false>(__beg, __end, __io, __err, __str);
  323. std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
  324. return __beg;
  325. }
  326. #endif
  327. template<typename _CharT, typename _InIter>
  328. _InIter
  329. money_get<_CharT, _InIter>::
  330. do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
  331. ios_base::iostate& __err, long double& __units) const
  332. {
  333. string __str;
  334. __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
  335. : _M_extract<false>(__beg, __end, __io, __err, __str);
  336. std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
  337. return __beg;
  338. }
  339. template<typename _CharT, typename _InIter>
  340. _InIter
  341. money_get<_CharT, _InIter>::
  342. do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
  343. ios_base::iostate& __err, string_type& __digits) const
  344. {
  345. typedef typename string::size_type size_type;
  346. const locale& __loc = __io._M_getloc();
  347. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  348. string __str;
  349. __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
  350. : _M_extract<false>(__beg, __end, __io, __err, __str);
  351. const size_type __len = __str.size();
  352. if (__len)
  353. {
  354. __digits.resize(__len);
  355. __ctype.widen(__str.data(), __str.data() + __len, &__digits[0]);
  356. }
  357. return __beg;
  358. }
  359. #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
  360. && defined __LONG_DOUBLE_IEEE128__
  361. template<typename _CharT, typename _InIter>
  362. _InIter
  363. money_get<_CharT, _InIter>::
  364. __do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io,
  365. ios_base::iostate& __err, __ibm128& __units) const
  366. {
  367. string __str;
  368. __beg = __intl ? _M_extract<true>(__beg, __end, __io, __err, __str)
  369. : _M_extract<false>(__beg, __end, __io, __err, __str);
  370. std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale());
  371. return __beg;
  372. }
  373. #endif
  374. template<typename _CharT, typename _OutIter>
  375. template<bool _Intl>
  376. _OutIter
  377. money_put<_CharT, _OutIter>::
  378. _M_insert(iter_type __s, ios_base& __io, char_type __fill,
  379. const string_type& __digits) const
  380. {
  381. typedef typename string_type::size_type size_type;
  382. typedef money_base::part part;
  383. typedef __moneypunct_cache<_CharT, _Intl> __cache_type;
  384. const locale& __loc = __io._M_getloc();
  385. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  386. __use_cache<__cache_type> __uc;
  387. const __cache_type* __lc = __uc(__loc);
  388. const char_type* __lit = __lc->_M_atoms;
  389. // Determine if negative or positive formats are to be used, and
  390. // discard leading negative_sign if it is present.
  391. const char_type* __beg = __digits.data();
  392. money_base::pattern __p;
  393. const char_type* __sign;
  394. size_type __sign_size;
  395. if (!(*__beg == __lit[money_base::_S_minus]))
  396. {
  397. __p = __lc->_M_pos_format;
  398. __sign = __lc->_M_positive_sign;
  399. __sign_size = __lc->_M_positive_sign_size;
  400. }
  401. else
  402. {
  403. __p = __lc->_M_neg_format;
  404. __sign = __lc->_M_negative_sign;
  405. __sign_size = __lc->_M_negative_sign_size;
  406. if (__digits.size())
  407. ++__beg;
  408. }
  409. // Look for valid numbers in the ctype facet within input digits.
  410. size_type __len = __ctype.scan_not(ctype_base::digit, __beg,
  411. __beg + __digits.size()) - __beg;
  412. if (__len)
  413. {
  414. // Assume valid input, and attempt to format.
  415. // Break down input numbers into base components, as follows:
  416. // final_value = grouped units + (decimal point) + (digits)
  417. string_type __value;
  418. __value.reserve(2 * __len);
  419. // Add thousands separators to non-decimal digits, per
  420. // grouping rules.
  421. long __paddec = __len - __lc->_M_frac_digits;
  422. if (__paddec > 0)
  423. {
  424. if (__lc->_M_frac_digits < 0)
  425. __paddec = __len;
  426. if (__lc->_M_grouping_size)
  427. {
  428. __value.assign(2 * __paddec, char_type());
  429. _CharT* __vend =
  430. std::__add_grouping(&__value[0], __lc->_M_thousands_sep,
  431. __lc->_M_grouping,
  432. __lc->_M_grouping_size,
  433. __beg, __beg + __paddec);
  434. __value.erase(__vend - &__value[0]);
  435. }
  436. else
  437. __value.assign(__beg, __paddec);
  438. }
  439. // Deal with decimal point, decimal digits.
  440. if (__lc->_M_frac_digits > 0)
  441. {
  442. __value += __lc->_M_decimal_point;
  443. if (__paddec >= 0)
  444. __value.append(__beg + __paddec, __lc->_M_frac_digits);
  445. else
  446. {
  447. // Have to pad zeros in the decimal position.
  448. __value.append(-__paddec, __lit[money_base::_S_zero]);
  449. __value.append(__beg, __len);
  450. }
  451. }
  452. // Calculate length of resulting string.
  453. const ios_base::fmtflags __f = __io.flags()
  454. & ios_base::adjustfield;
  455. __len = __value.size() + __sign_size;
  456. __len += ((__io.flags() & ios_base::showbase)
  457. ? __lc->_M_curr_symbol_size : 0);
  458. string_type __res;
  459. __res.reserve(2 * __len);
  460. const size_type __width = static_cast<size_type>(__io.width());
  461. const bool __testipad = (__f == ios_base::internal
  462. && __len < __width);
  463. // Fit formatted digits into the required pattern.
  464. for (int __i = 0; __i < 4; ++__i)
  465. {
  466. const part __which = static_cast<part>(__p.field[__i]);
  467. switch (__which)
  468. {
  469. case money_base::symbol:
  470. if (__io.flags() & ios_base::showbase)
  471. __res.append(__lc->_M_curr_symbol,
  472. __lc->_M_curr_symbol_size);
  473. break;
  474. case money_base::sign:
  475. // Sign might not exist, or be more than one
  476. // character long. In that case, add in the rest
  477. // below.
  478. if (__sign_size)
  479. __res += __sign[0];
  480. break;
  481. case money_base::value:
  482. __res += __value;
  483. break;
  484. case money_base::space:
  485. // At least one space is required, but if internal
  486. // formatting is required, an arbitrary number of
  487. // fill spaces will be necessary.
  488. if (__testipad)
  489. __res.append(__width - __len, __fill);
  490. else
  491. __res += __fill;
  492. break;
  493. case money_base::none:
  494. if (__testipad)
  495. __res.append(__width - __len, __fill);
  496. break;
  497. }
  498. }
  499. // Special case of multi-part sign parts.
  500. if (__sign_size > 1)
  501. __res.append(__sign + 1, __sign_size - 1);
  502. // Pad, if still necessary.
  503. __len = __res.size();
  504. if (__width > __len)
  505. {
  506. if (__f == ios_base::left)
  507. // After.
  508. __res.append(__width - __len, __fill);
  509. else
  510. // Before.
  511. __res.insert(0, __width - __len, __fill);
  512. __len = __width;
  513. }
  514. // Write resulting, fully-formatted string to output iterator.
  515. __s = std::__write(__s, __res.data(), __len);
  516. }
  517. __io.width(0);
  518. return __s;
  519. }
  520. #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \
  521. && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__)
  522. template<typename _CharT, typename _OutIter>
  523. _OutIter
  524. money_put<_CharT, _OutIter>::
  525. __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
  526. double __units) const
  527. { return this->do_put(__s, __intl, __io, __fill, (long double) __units); }
  528. #endif
  529. template<typename _CharT, typename _OutIter>
  530. _OutIter
  531. money_put<_CharT, _OutIter>::
  532. do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
  533. long double __units) const
  534. {
  535. const locale __loc = __io.getloc();
  536. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  537. #if _GLIBCXX_USE_C99_STDIO
  538. // First try a buffer perhaps big enough.
  539. int __cs_size = 64;
  540. char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
  541. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  542. // 328. Bad sprintf format modifier in money_put<>::do_put()
  543. int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
  544. "%.*Lf", 0, __units);
  545. // If the buffer was not large enough, try again with the correct size.
  546. if (__len >= __cs_size)
  547. {
  548. __cs_size = __len + 1;
  549. __cs = static_cast<char*>(__builtin_alloca(__cs_size));
  550. __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size,
  551. "%.*Lf", 0, __units);
  552. }
  553. #else
  554. // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'.
  555. const int __cs_size =
  556. __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 3;
  557. char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
  558. int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf",
  559. 0, __units);
  560. #endif
  561. string_type __digits(__len, char_type());
  562. __ctype.widen(__cs, __cs + __len, &__digits[0]);
  563. return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
  564. : _M_insert<false>(__s, __io, __fill, __digits);
  565. }
  566. template<typename _CharT, typename _OutIter>
  567. _OutIter
  568. money_put<_CharT, _OutIter>::
  569. do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
  570. const string_type& __digits) const
  571. { return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
  572. : _M_insert<false>(__s, __io, __fill, __digits); }
  573. #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \
  574. && defined __LONG_DOUBLE_IEEE128__
  575. extern "C"
  576. __typeof__(__builtin_snprintf) __glibcxx_snprintfibm128 __asm__("snprintf");
  577. template<typename _CharT, typename _OutIter>
  578. _OutIter
  579. money_put<_CharT, _OutIter>::
  580. __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
  581. __ibm128 __units) const
  582. {
  583. const locale __loc = __io.getloc();
  584. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  585. // First try a buffer perhaps big enough.
  586. int __cs_size = 64;
  587. char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
  588. const __c_locale __old = __gnu_cxx::__uselocale(_S_get_c_locale());
  589. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  590. // 328. Bad sprintf format modifier in money_put<>::do_put()
  591. int __len = __glibcxx_snprintfibm128(__cs, __cs_size, "%.*Lf", 0,
  592. __units);
  593. // If the buffer was not large enough, try again with the correct size.
  594. if (__len >= __cs_size)
  595. {
  596. __cs_size = __len + 1;
  597. __cs = static_cast<char*>(__builtin_alloca(__cs_size));
  598. __len = __glibcxx_snprintfibm128(__cs, __cs_size, "%.*Lf", 0,
  599. __units);
  600. }
  601. __gnu_cxx::__uselocale(__old);
  602. string_type __digits(__len, char_type());
  603. __ctype.widen(__cs, __cs + __len, &__digits[0]);
  604. return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
  605. : _M_insert<false>(__s, __io, __fill, __digits);
  606. }
  607. #endif
  608. _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
  609. // NB: Not especially useful. Without an ios_base object or some
  610. // kind of locale reference, we are left clawing at the air where
  611. // the side of the mountain used to be...
  612. template<typename _CharT, typename _InIter>
  613. time_base::dateorder
  614. time_get<_CharT, _InIter>::do_date_order() const
  615. { return time_base::no_order; }
  616. // Expand a strptime format string and parse it. E.g., do_get_date() may
  617. // pass %m/%d/%Y => extracted characters.
  618. template<typename _CharT, typename _InIter>
  619. _InIter
  620. time_get<_CharT, _InIter>::
  621. _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
  622. ios_base::iostate& __err, tm* __tm,
  623. const _CharT* __format,
  624. __time_get_state &__state) const
  625. {
  626. const locale& __loc = __io._M_getloc();
  627. const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
  628. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  629. const size_t __len = char_traits<_CharT>::length(__format);
  630. ios_base::iostate __tmperr = ios_base::goodbit;
  631. size_t __i = 0;
  632. for (; __beg != __end && __i < __len && !__tmperr; ++__i)
  633. {
  634. if (__ctype.narrow(__format[__i], 0) == '%')
  635. {
  636. // Verify valid formatting code, attempt to extract.
  637. char __c = __ctype.narrow(__format[++__i], 0);
  638. int __mem = 0;
  639. if (__c == 'E' || __c == 'O')
  640. __c = __ctype.narrow(__format[++__i], 0);
  641. switch (__c)
  642. {
  643. const char* __cs;
  644. _CharT __wcs[10];
  645. case 'a':
  646. case 'A':
  647. // Weekday name (possibly abbreviated) [tm_wday]
  648. const char_type* __days[14];
  649. __tp._M_days(&__days[0]);
  650. __tp._M_days_abbreviated(&__days[7]);
  651. __beg = _M_extract_name(__beg, __end, __mem, __days,
  652. 14, __io, __tmperr);
  653. if (!__tmperr)
  654. {
  655. __tm->tm_wday = __mem % 7;
  656. __state._M_have_wday = 1;
  657. }
  658. break;
  659. case 'h':
  660. case 'b':
  661. case 'B':
  662. // Month name (possibly abbreviated) [tm_mon]
  663. const char_type* __months[24];
  664. __tp._M_months(&__months[0]);
  665. __tp._M_months_abbreviated(&__months[12]);
  666. __beg = _M_extract_name(__beg, __end, __mem,
  667. __months, 24, __io, __tmperr);
  668. if (!__tmperr)
  669. {
  670. __tm->tm_mon = __mem % 12;
  671. __state._M_have_mon = 1;
  672. __state._M_want_xday = 1;
  673. }
  674. break;
  675. case 'c':
  676. // Default time and date representation.
  677. const char_type* __dt[2];
  678. __tp._M_date_time_formats(__dt);
  679. __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
  680. __tm, __dt[0], __state);
  681. if (!__tmperr)
  682. __state._M_want_xday = 1;
  683. break;
  684. case 'C':
  685. // Century.
  686. __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
  687. __io, __tmperr);
  688. if (!__tmperr)
  689. {
  690. __state._M_century = __mem;
  691. __state._M_have_century = 1;
  692. __state._M_want_xday = 1;
  693. }
  694. break;
  695. case 'd':
  696. case 'e':
  697. // Day [1, 31]. [tm_mday]
  698. if (__ctype.is(ctype_base::space, *__beg))
  699. ++__beg;
  700. __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
  701. __io, __tmperr);
  702. if (!__tmperr)
  703. {
  704. __tm->tm_mday = __mem;
  705. __state._M_have_mday = 1;
  706. __state._M_want_xday = 1;
  707. }
  708. break;
  709. case 'D':
  710. // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
  711. __cs = "%m/%d/%y";
  712. __ctype.widen(__cs, __cs + 9, __wcs);
  713. __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
  714. __tm, __wcs, __state);
  715. if (!__tmperr)
  716. __state._M_want_xday = 1;
  717. break;
  718. case 'H':
  719. // Hour [00, 23]. [tm_hour]
  720. __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
  721. __io, __tmperr);
  722. if (!__tmperr)
  723. {
  724. __tm->tm_hour = __mem;
  725. __state._M_have_I = 0;
  726. }
  727. break;
  728. case 'I':
  729. // Hour [01, 12]. [tm_hour]
  730. __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
  731. __io, __tmperr);
  732. if (!__tmperr)
  733. {
  734. __tm->tm_hour = __mem % 12;
  735. __state._M_have_I = 1;
  736. }
  737. break;
  738. case 'j':
  739. // Day number of year.
  740. __beg = _M_extract_num(__beg, __end, __mem, 1, 366, 3,
  741. __io, __tmperr);
  742. if (!__tmperr)
  743. {
  744. __tm->tm_yday = __mem - 1;
  745. __state._M_have_yday = 1;
  746. }
  747. break;
  748. case 'm':
  749. // Month [01, 12]. [tm_mon]
  750. __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
  751. __io, __tmperr);
  752. if (!__tmperr)
  753. {
  754. __tm->tm_mon = __mem - 1;
  755. __state._M_have_mon = 1;
  756. }
  757. break;
  758. case 'M':
  759. // Minute [00, 59]. [tm_min]
  760. __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
  761. __io, __tmperr);
  762. if (!__tmperr)
  763. __tm->tm_min = __mem;
  764. break;
  765. case 'n':
  766. case 't':
  767. while (__beg != __end
  768. && __ctype.is(ctype_base::space, *__beg))
  769. ++__beg;
  770. break;
  771. case 'p':
  772. // Locale's a.m. or p.m.
  773. const char_type* __ampm[2];
  774. __tp._M_am_pm(&__ampm[0]);
  775. if (!__ampm[0][0] || !__ampm[1][0])
  776. break;
  777. __beg = _M_extract_name(__beg, __end, __mem, __ampm,
  778. 2, __io, __tmperr);
  779. if (!__tmperr && __mem)
  780. __state._M_is_pm = 1;
  781. break;
  782. case 'r':
  783. // Locale's 12-hour clock time format (in C %I:%M:%S %p).
  784. const char_type* __ampm_format;
  785. __tp._M_am_pm_format(&__ampm_format);
  786. __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
  787. __tm, __ampm_format, __state);
  788. break;
  789. case 'R':
  790. // Equivalent to (%H:%M).
  791. __cs = "%H:%M";
  792. __ctype.widen(__cs, __cs + 6, __wcs);
  793. __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
  794. __tm, __wcs, __state);
  795. break;
  796. case 'S':
  797. // Seconds. [tm_sec]
  798. // [00, 60] in C99 (one leap-second), [00, 61] in C89.
  799. #if _GLIBCXX_USE_C99
  800. __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
  801. #else
  802. __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
  803. #endif
  804. __io, __tmperr);
  805. if (!__tmperr)
  806. __tm->tm_sec = __mem;
  807. break;
  808. case 'T':
  809. // Equivalent to (%H:%M:%S).
  810. __cs = "%H:%M:%S";
  811. __ctype.widen(__cs, __cs + 9, __wcs);
  812. __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
  813. __tm, __wcs, __state);
  814. break;
  815. case 'U':
  816. // Week number of the year (Sunday as first day of week).
  817. __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
  818. __io, __tmperr);
  819. if (!__tmperr)
  820. {
  821. __state._M_week_no = __mem;
  822. __state._M_have_uweek = 1;
  823. }
  824. break;
  825. case 'w':
  826. // Weekday [tm_wday]
  827. __beg = _M_extract_num(__beg, __end, __mem, 0, 6, 1,
  828. __io, __tmperr);
  829. if (!__tmperr)
  830. {
  831. __tm->tm_wday = __mem;
  832. __state._M_have_wday = 1;
  833. }
  834. break;
  835. case 'W':
  836. // Week number of the year (Monday as first day of week).
  837. __beg = _M_extract_num(__beg, __end, __mem, 0, 53, 2,
  838. __io, __tmperr);
  839. if (!__tmperr)
  840. {
  841. __state._M_week_no = __mem;
  842. __state._M_have_wweek = 1;
  843. }
  844. break;
  845. case 'x':
  846. // Locale's date.
  847. const char_type* __dates[2];
  848. __tp._M_date_formats(__dates);
  849. __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
  850. __tm, __dates[0], __state);
  851. break;
  852. case 'X':
  853. // Locale's time.
  854. const char_type* __times[2];
  855. __tp._M_time_formats(__times);
  856. __beg = _M_extract_via_format(__beg, __end, __io, __tmperr,
  857. __tm, __times[0], __state);
  858. break;
  859. case 'y':
  860. // The last 2 digits of year.
  861. __beg = _M_extract_num(__beg, __end, __mem, 0, 99, 2,
  862. __io, __tmperr);
  863. if (!__tmperr)
  864. {
  865. __state._M_want_century = 1;
  866. __state._M_want_xday = 1;
  867. // As an extension, if the 2 digits are followed by
  868. // 1-2 further digits, treat it like %Y.
  869. __c = 0;
  870. if (__beg != __end)
  871. __c = __ctype.narrow(*__beg, '*');
  872. if (__c >= '0' && __c <= '9')
  873. {
  874. ++__beg;
  875. __mem = __mem * 10 + (__c - '0');
  876. if (__beg != __end)
  877. {
  878. __c = __ctype.narrow(*__beg, '*');
  879. if (__c >= '0' && __c <= '9')
  880. {
  881. ++__beg;
  882. __mem = __mem * 10 + (__c - '0');
  883. }
  884. }
  885. __mem -= 1900;
  886. __state._M_want_century = 0;
  887. }
  888. // Otherwise, as per POSIX 2008, 00-68 is 2000-2068,
  889. // while 69-99 is 1969-1999.
  890. else if (__mem < 69)
  891. __mem += 100;
  892. __tm->tm_year = __mem;
  893. }
  894. break;
  895. case 'Y':
  896. // Year.
  897. __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4,
  898. __io, __tmperr);
  899. if (!__tmperr)
  900. {
  901. __tm->tm_year = __mem - 1900;
  902. __state._M_want_century = 0;
  903. __state._M_want_xday = 1;
  904. }
  905. break;
  906. case 'Z':
  907. // Timezone info.
  908. if (__ctype.is(ctype_base::upper, *__beg))
  909. {
  910. int __tmp;
  911. __beg = _M_extract_name(__beg, __end, __tmp,
  912. __timepunct_cache<_CharT>::_S_timezones,
  913. 14, __io, __tmperr);
  914. // GMT requires special effort.
  915. if (__beg != __end && !__tmperr && __tmp == 0
  916. && (*__beg == __ctype.widen('-')
  917. || *__beg == __ctype.widen('+')))
  918. {
  919. __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2,
  920. __io, __tmperr);
  921. __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2,
  922. __io, __tmperr);
  923. }
  924. }
  925. else
  926. __tmperr |= ios_base::failbit;
  927. break;
  928. case '%':
  929. if (*__beg == __ctype.widen('%'))
  930. ++__beg;
  931. else
  932. __tmperr |= ios_base::failbit;
  933. break;
  934. default:
  935. // Not recognized.
  936. __tmperr |= ios_base::failbit;
  937. }
  938. }
  939. else if (__ctype.is(ctype_base::space, __format[__i]))
  940. {
  941. // Skip any whitespace.
  942. while (__beg != __end
  943. && __ctype.is(ctype_base::space, *__beg))
  944. ++__beg;
  945. }
  946. else
  947. {
  948. // Verify format and input match, extract and discard.
  949. // TODO real case-insensitive comparison
  950. if (__ctype.tolower(__format[__i]) == __ctype.tolower(*__beg)
  951. || __ctype.toupper(__format[__i]) == __ctype.toupper(*__beg))
  952. ++__beg;
  953. else
  954. __tmperr |= ios_base::failbit;
  955. }
  956. }
  957. if (__tmperr || __i != __len)
  958. __err |= ios_base::failbit;
  959. return __beg;
  960. }
  961. template<typename _CharT, typename _InIter>
  962. _InIter
  963. time_get<_CharT, _InIter>::
  964. _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io,
  965. ios_base::iostate& __err, tm* __tm,
  966. const _CharT* __format) const
  967. {
  968. __time_get_state __state = __time_get_state();
  969. return _M_extract_via_format(__beg, __end, __io, __err, __tm,
  970. __format, __state);
  971. }
  972. template<typename _CharT, typename _InIter>
  973. _InIter
  974. time_get<_CharT, _InIter>::
  975. _M_extract_num(iter_type __beg, iter_type __end, int& __member,
  976. int __min, int __max, size_t __len,
  977. ios_base& __io, ios_base::iostate& __err) const
  978. {
  979. const locale& __loc = __io._M_getloc();
  980. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  981. size_t __i = 0;
  982. int __value = 0;
  983. for (; __beg != __end && __i < __len; ++__beg, (void)++__i)
  984. {
  985. const char __c = __ctype.narrow(*__beg, '*');
  986. if (__c >= '0' && __c <= '9')
  987. {
  988. __value = __value * 10 + (__c - '0');
  989. if (__value > __max)
  990. break;
  991. }
  992. else
  993. break;
  994. }
  995. if (__i && __value >= __min && __value <= __max)
  996. __member = __value;
  997. else
  998. __err |= ios_base::failbit;
  999. return __beg;
  1000. }
  1001. // Assumptions:
  1002. // All elements in __names are unique, except if __indexlen is
  1003. // even __names in the first half could be the same as corresponding
  1004. // __names in the second half (May is abbreviated as May). Some __names
  1005. // elements could be prefixes of other __names elements.
  1006. template<typename _CharT, typename _InIter>
  1007. _InIter
  1008. time_get<_CharT, _InIter>::
  1009. _M_extract_name(iter_type __beg, iter_type __end, int& __member,
  1010. const _CharT** __names, size_t __indexlen,
  1011. ios_base& __io, ios_base::iostate& __err) const
  1012. {
  1013. typedef char_traits<_CharT> __traits_type;
  1014. const locale& __loc = __io._M_getloc();
  1015. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  1016. size_t* __matches
  1017. = static_cast<size_t*>(__builtin_alloca(2 * sizeof(size_t)
  1018. * __indexlen));
  1019. size_t* __lengths = __matches + __indexlen;
  1020. size_t __nmatches = 0;
  1021. size_t __pos = 0;
  1022. bool __testvalid = true;
  1023. const char_type* __name;
  1024. bool __begupdated = false;
  1025. // Look for initial matches.
  1026. if (__beg != __end)
  1027. {
  1028. const char_type __c = *__beg;
  1029. // TODO real case-insensitive comparison
  1030. const char_type __cl = __ctype.tolower(__c);
  1031. const char_type __cu = __ctype.toupper(__c);
  1032. for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
  1033. if (__cl == __ctype.tolower(__names[__i1][0])
  1034. || __cu == __ctype.toupper(__names[__i1][0]))
  1035. {
  1036. __lengths[__nmatches]
  1037. = __traits_type::length(__names[__i1]);
  1038. __matches[__nmatches++] = __i1;
  1039. }
  1040. }
  1041. while (__nmatches > 1)
  1042. {
  1043. // Find smallest matching string.
  1044. size_t __minlen = __lengths[0];
  1045. for (size_t __i2 = 1; __i2 < __nmatches; ++__i2)
  1046. __minlen = std::min(__minlen, __lengths[__i2]);
  1047. ++__pos;
  1048. ++__beg;
  1049. if (__pos == __minlen)
  1050. {
  1051. // If some match has remaining length of 0,
  1052. // need to decide if any match with remaining
  1053. // length non-zero matches the next character.
  1054. // If so, remove all matches with remaining length
  1055. // 0 from consideration, otherwise keep only matches
  1056. // with remaining length 0.
  1057. bool __match_longer = false;
  1058. if (__beg != __end)
  1059. {
  1060. // TODO real case-insensitive comparison
  1061. const char_type __cl = __ctype.tolower(*__beg);
  1062. const char_type __cu = __ctype.toupper(*__beg);
  1063. for (size_t __i3 = 0; __i3 < __nmatches; ++__i3)
  1064. {
  1065. __name = __names[__matches[__i3]];
  1066. if (__lengths[__i3] > __pos
  1067. && (__ctype.tolower(__name[__pos]) == __cl
  1068. || __ctype.toupper(__name[__pos]) == __cu))
  1069. {
  1070. __match_longer = true;
  1071. break;
  1072. }
  1073. }
  1074. }
  1075. for (size_t __i4 = 0; __i4 < __nmatches;)
  1076. if (__match_longer == (__lengths[__i4] == __pos))
  1077. {
  1078. __matches[__i4] = __matches[--__nmatches];
  1079. __lengths[__i4] = __lengths[__nmatches];
  1080. }
  1081. else
  1082. ++__i4;
  1083. if (__match_longer)
  1084. {
  1085. __minlen = __lengths[0];
  1086. for (size_t __i5 = 1; __i5 < __nmatches; ++__i5)
  1087. __minlen = std::min(__minlen, __lengths[__i5]);
  1088. }
  1089. else
  1090. {
  1091. // Deal with May being full as well as abbreviated month
  1092. // name. Pick the smaller index.
  1093. if (__nmatches == 2 && (__indexlen & 1) == 0)
  1094. {
  1095. if (__matches[0] < __indexlen / 2)
  1096. {
  1097. if (__matches[1] == __matches[0] + __indexlen / 2)
  1098. __nmatches = 1;
  1099. }
  1100. else if (__matches[1] == __matches[0] - __indexlen / 2)
  1101. {
  1102. __matches[0] = __matches[1];
  1103. __lengths[0] = __lengths[1];
  1104. __nmatches = 1;
  1105. }
  1106. }
  1107. __begupdated = true;
  1108. break;
  1109. }
  1110. }
  1111. if (__pos < __minlen && __beg != __end)
  1112. {
  1113. // TODO real case-insensitive comparison
  1114. const char_type __cl = __ctype.tolower(*__beg);
  1115. const char_type __cu = __ctype.toupper(*__beg);
  1116. for (size_t __i6 = 0; __i6 < __nmatches;)
  1117. {
  1118. __name = __names[__matches[__i6]];
  1119. if (__ctype.tolower(__name[__pos]) != __cl
  1120. && __ctype.toupper(__name[__pos]) != __cu)
  1121. {
  1122. __matches[__i6] = __matches[--__nmatches];
  1123. __lengths[__i6] = __lengths[__nmatches];
  1124. }
  1125. else
  1126. ++__i6;
  1127. }
  1128. }
  1129. else
  1130. break;
  1131. }
  1132. if (__nmatches == 1)
  1133. {
  1134. // Make sure found name is completely extracted.
  1135. if (!__begupdated)
  1136. {
  1137. ++__beg;
  1138. ++__pos;
  1139. }
  1140. __name = __names[__matches[0]];
  1141. const size_t __len = __lengths[0];
  1142. while (__pos < __len
  1143. && __beg != __end
  1144. // TODO real case-insensitive comparison
  1145. && (__ctype.tolower(__name[__pos]) == __ctype.tolower(*__beg)
  1146. || (__ctype.toupper(__name[__pos])
  1147. == __ctype.toupper(*__beg))))
  1148. ++__beg, (void)++__pos;
  1149. if (__len == __pos)
  1150. __member = __matches[0];
  1151. else
  1152. __testvalid = false;
  1153. }
  1154. else
  1155. __testvalid = false;
  1156. if (!__testvalid)
  1157. __err |= ios_base::failbit;
  1158. return __beg;
  1159. }
  1160. template<typename _CharT, typename _InIter>
  1161. _InIter
  1162. time_get<_CharT, _InIter>::
  1163. _M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member,
  1164. const _CharT** __names, size_t __indexlen,
  1165. ios_base& __io, ios_base::iostate& __err) const
  1166. {
  1167. typedef char_traits<_CharT> __traits_type;
  1168. const locale& __loc = __io._M_getloc();
  1169. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  1170. int* __matches = static_cast<int*>(__builtin_alloca(2 * sizeof(int)
  1171. * __indexlen));
  1172. size_t __nmatches = 0;
  1173. size_t* __matches_lengths = 0;
  1174. size_t __pos = 0;
  1175. if (__beg != __end)
  1176. {
  1177. const char_type __c = *__beg;
  1178. for (size_t __i = 0; __i < 2 * __indexlen; ++__i)
  1179. if (__c == __names[__i][0]
  1180. || __c == __ctype.toupper(__names[__i][0]))
  1181. __matches[__nmatches++] = __i;
  1182. }
  1183. if (__nmatches)
  1184. {
  1185. ++__beg;
  1186. ++__pos;
  1187. __matches_lengths
  1188. = static_cast<size_t*>(__builtin_alloca(sizeof(size_t)
  1189. * __nmatches));
  1190. for (size_t __i = 0; __i < __nmatches; ++__i)
  1191. __matches_lengths[__i]
  1192. = __traits_type::length(__names[__matches[__i]]);
  1193. }
  1194. for (; __beg != __end; ++__beg, (void)++__pos)
  1195. {
  1196. size_t __nskipped = 0;
  1197. const char_type __c = *__beg;
  1198. for (size_t __i = 0; __i < __nmatches;)
  1199. {
  1200. const char_type* __name = __names[__matches[__i]];
  1201. if (__pos >= __matches_lengths[__i])
  1202. ++__nskipped, ++__i;
  1203. else if (!(__name[__pos] == __c))
  1204. {
  1205. --__nmatches;
  1206. __matches[__i] = __matches[__nmatches];
  1207. __matches_lengths[__i] = __matches_lengths[__nmatches];
  1208. }
  1209. else
  1210. ++__i;
  1211. }
  1212. if (__nskipped == __nmatches)
  1213. break;
  1214. }
  1215. if ((__nmatches == 1 && __matches_lengths[0] == __pos)
  1216. || (__nmatches == 2 && (__matches_lengths[0] == __pos
  1217. || __matches_lengths[1] == __pos)))
  1218. __member = (__matches[0] >= (int)__indexlen
  1219. ? __matches[0] - (int)__indexlen : __matches[0]);
  1220. else
  1221. __err |= ios_base::failbit;
  1222. return __beg;
  1223. }
  1224. template<typename _CharT, typename _InIter>
  1225. _InIter
  1226. time_get<_CharT, _InIter>::
  1227. do_get_time(iter_type __beg, iter_type __end, ios_base& __io,
  1228. ios_base::iostate& __err, tm* __tm) const
  1229. {
  1230. const locale& __loc = __io._M_getloc();
  1231. const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
  1232. const char_type* __times[2];
  1233. __tp._M_time_formats(__times);
  1234. __time_get_state __state = __time_get_state();
  1235. __beg = _M_extract_via_format(__beg, __end, __io, __err,
  1236. __tm, __times[0], __state);
  1237. __state._M_finalize_state(__tm);
  1238. if (__beg == __end)
  1239. __err |= ios_base::eofbit;
  1240. return __beg;
  1241. }
  1242. template<typename _CharT, typename _InIter>
  1243. _InIter
  1244. time_get<_CharT, _InIter>::
  1245. do_get_date(iter_type __beg, iter_type __end, ios_base& __io,
  1246. ios_base::iostate& __err, tm* __tm) const
  1247. {
  1248. const locale& __loc = __io._M_getloc();
  1249. const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
  1250. const char_type* __dates[2];
  1251. __tp._M_date_formats(__dates);
  1252. __time_get_state __state = __time_get_state();
  1253. __beg = _M_extract_via_format(__beg, __end, __io, __err,
  1254. __tm, __dates[0], __state);
  1255. __state._M_finalize_state(__tm);
  1256. if (__beg == __end)
  1257. __err |= ios_base::eofbit;
  1258. return __beg;
  1259. }
  1260. template<typename _CharT, typename _InIter>
  1261. _InIter
  1262. time_get<_CharT, _InIter>::
  1263. do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io,
  1264. ios_base::iostate& __err, tm* __tm) const
  1265. {
  1266. const locale& __loc = __io._M_getloc();
  1267. const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
  1268. const char_type* __days[14];
  1269. __tp._M_days_abbreviated(__days);
  1270. __tp._M_days(__days + 7);
  1271. int __tmpwday;
  1272. ios_base::iostate __tmperr = ios_base::goodbit;
  1273. __beg = _M_extract_wday_or_month(__beg, __end, __tmpwday, __days, 7,
  1274. __io, __tmperr);
  1275. if (!__tmperr)
  1276. __tm->tm_wday = __tmpwday;
  1277. else
  1278. __err |= ios_base::failbit;
  1279. if (__beg == __end)
  1280. __err |= ios_base::eofbit;
  1281. return __beg;
  1282. }
  1283. template<typename _CharT, typename _InIter>
  1284. _InIter
  1285. time_get<_CharT, _InIter>::
  1286. do_get_monthname(iter_type __beg, iter_type __end,
  1287. ios_base& __io, ios_base::iostate& __err, tm* __tm) const
  1288. {
  1289. const locale& __loc = __io._M_getloc();
  1290. const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
  1291. const char_type* __months[24];
  1292. __tp._M_months_abbreviated(__months);
  1293. __tp._M_months(__months + 12);
  1294. int __tmpmon;
  1295. ios_base::iostate __tmperr = ios_base::goodbit;
  1296. __beg = _M_extract_wday_or_month(__beg, __end, __tmpmon, __months, 12,
  1297. __io, __tmperr);
  1298. if (!__tmperr)
  1299. __tm->tm_mon = __tmpmon;
  1300. else
  1301. __err |= ios_base::failbit;
  1302. if (__beg == __end)
  1303. __err |= ios_base::eofbit;
  1304. return __beg;
  1305. }
  1306. template<typename _CharT, typename _InIter>
  1307. _InIter
  1308. time_get<_CharT, _InIter>::
  1309. do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
  1310. ios_base::iostate& __err, tm* __tm) const
  1311. {
  1312. int __tmpyear;
  1313. ios_base::iostate __tmperr = ios_base::goodbit;
  1314. const locale& __loc = __io._M_getloc();
  1315. const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
  1316. __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 99, 2,
  1317. __io, __tmperr);
  1318. if (!__tmperr)
  1319. {
  1320. char __c = 0;
  1321. if (__beg != __end)
  1322. __c = __ctype.narrow(*__beg, '*');
  1323. // For 1-2 digit year, assume 69-99 is 1969-1999, 0-68 is 2000-2068.
  1324. // For 3-4 digit year, use it as year.
  1325. // __tm->tm_year needs year - 1900 though.
  1326. if (__c >= '0' && __c <= '9')
  1327. {
  1328. ++__beg;
  1329. __tmpyear = __tmpyear * 10 + (__c - '0');
  1330. if (__beg != __end)
  1331. {
  1332. __c = __ctype.narrow(*__beg, '*');
  1333. if (__c >= '0' && __c <= '9')
  1334. {
  1335. ++__beg;
  1336. __tmpyear = __tmpyear * 10 + (__c - '0');
  1337. }
  1338. }
  1339. __tmpyear -= 1900;
  1340. }
  1341. else if (__tmpyear < 69)
  1342. __tmpyear += 100;
  1343. __tm->tm_year = __tmpyear;
  1344. }
  1345. else
  1346. __err |= ios_base::failbit;
  1347. if (__beg == __end)
  1348. __err |= ios_base::eofbit;
  1349. return __beg;
  1350. }
  1351. #if __cplusplus >= 201103L
  1352. template<typename _CharT, typename _InIter>
  1353. inline
  1354. _InIter
  1355. time_get<_CharT, _InIter>::
  1356. get(iter_type __s, iter_type __end, ios_base& __io,
  1357. ios_base::iostate& __err, tm* __tm, const char_type* __fmt,
  1358. const char_type* __fmtend) const
  1359. {
  1360. const locale& __loc = __io._M_getloc();
  1361. ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
  1362. __err = ios_base::goodbit;
  1363. bool __use_state = false;
  1364. #if __GNUC__ >= 5 && !defined(__clang__)
  1365. #pragma GCC diagnostic push
  1366. #pragma GCC diagnostic ignored "-Wpmf-conversions"
  1367. // Nasty hack. The C++ standard mandates that get invokes the do_get
  1368. // virtual method, but unfortunately at least without an ABI change
  1369. // for the facets we can't keep state across the different do_get
  1370. // calls. So e.g. if __fmt is "%p %I:%M:%S", we can't handle it
  1371. // properly, because we first handle the %p am/pm specifier and only
  1372. // later the 12-hour format specifier.
  1373. if ((void*)(this->*(&time_get::do_get)) == (void*)(&time_get::do_get))
  1374. __use_state = true;
  1375. #pragma GCC diagnostic pop
  1376. #endif
  1377. __time_get_state __state = __time_get_state();
  1378. while (__fmt != __fmtend &&
  1379. __err == ios_base::goodbit)
  1380. {
  1381. if (__s == __end)
  1382. {
  1383. __err = ios_base::eofbit | ios_base::failbit;
  1384. break;
  1385. }
  1386. else if (__ctype.narrow(*__fmt, 0) == '%')
  1387. {
  1388. const char_type* __fmt_start = __fmt;
  1389. char __format;
  1390. char __mod = 0;
  1391. if (++__fmt == __fmtend)
  1392. {
  1393. __err = ios_base::failbit;
  1394. break;
  1395. }
  1396. const char __c = __ctype.narrow(*__fmt, 0);
  1397. if (__c != 'E' && __c != 'O')
  1398. __format = __c;
  1399. else if (++__fmt != __fmtend)
  1400. {
  1401. __mod = __c;
  1402. __format = __ctype.narrow(*__fmt, 0);
  1403. }
  1404. else
  1405. {
  1406. __err = ios_base::failbit;
  1407. break;
  1408. }
  1409. if (__use_state)
  1410. {
  1411. char_type __new_fmt[4];
  1412. __new_fmt[0] = __fmt_start[0];
  1413. __new_fmt[1] = __fmt_start[1];
  1414. if (__mod)
  1415. {
  1416. __new_fmt[2] = __fmt_start[2];
  1417. __new_fmt[3] = char_type();
  1418. }
  1419. else
  1420. __new_fmt[2] = char_type();
  1421. __s = _M_extract_via_format(__s, __end, __io, __err, __tm,
  1422. __new_fmt, __state);
  1423. if (__s == __end)
  1424. __err |= ios_base::eofbit;
  1425. }
  1426. else
  1427. __s = this->do_get(__s, __end, __io, __err, __tm, __format,
  1428. __mod);
  1429. ++__fmt;
  1430. }
  1431. else if (__ctype.is(ctype_base::space, *__fmt))
  1432. {
  1433. ++__fmt;
  1434. while (__fmt != __fmtend &&
  1435. __ctype.is(ctype_base::space, *__fmt))
  1436. ++__fmt;
  1437. while (__s != __end &&
  1438. __ctype.is(ctype_base::space, *__s))
  1439. ++__s;
  1440. }
  1441. // TODO real case-insensitive comparison
  1442. else if (__ctype.tolower(*__s) == __ctype.tolower(*__fmt) ||
  1443. __ctype.toupper(*__s) == __ctype.toupper(*__fmt))
  1444. {
  1445. ++__s;
  1446. ++__fmt;
  1447. }
  1448. else
  1449. {
  1450. __err = ios_base::failbit;
  1451. break;
  1452. }
  1453. }
  1454. if (__use_state)
  1455. __state._M_finalize_state(__tm);
  1456. return __s;
  1457. }
  1458. template<typename _CharT, typename _InIter>
  1459. inline
  1460. _InIter
  1461. time_get<_CharT, _InIter>::
  1462. do_get(iter_type __beg, iter_type __end, ios_base& __io,
  1463. ios_base::iostate& __err, tm* __tm,
  1464. char __format, char __mod) const
  1465. {
  1466. const locale& __loc = __io._M_getloc();
  1467. ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
  1468. __err = ios_base::goodbit;
  1469. char_type __fmt[4];
  1470. __fmt[0] = __ctype.widen('%');
  1471. if (!__mod)
  1472. {
  1473. __fmt[1] = __format;
  1474. __fmt[2] = char_type();
  1475. }
  1476. else
  1477. {
  1478. __fmt[1] = __mod;
  1479. __fmt[2] = __format;
  1480. __fmt[3] = char_type();
  1481. }
  1482. __time_get_state __state = __time_get_state();
  1483. __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt,
  1484. __state);
  1485. __state._M_finalize_state(__tm);
  1486. if (__beg == __end)
  1487. __err |= ios_base::eofbit;
  1488. return __beg;
  1489. }
  1490. #endif // __cplusplus >= 201103L
  1491. template<typename _CharT, typename _OutIter>
  1492. _OutIter
  1493. time_put<_CharT, _OutIter>::
  1494. put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm,
  1495. const _CharT* __beg, const _CharT* __end) const
  1496. {
  1497. const locale& __loc = __io._M_getloc();
  1498. ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
  1499. for (; __beg != __end; ++__beg)
  1500. if (__ctype.narrow(*__beg, 0) != '%')
  1501. {
  1502. *__s = *__beg;
  1503. ++__s;
  1504. }
  1505. else if (++__beg != __end)
  1506. {
  1507. char __format;
  1508. char __mod = 0;
  1509. const char __c = __ctype.narrow(*__beg, 0);
  1510. if (__c != 'E' && __c != 'O')
  1511. __format = __c;
  1512. else if (++__beg != __end)
  1513. {
  1514. __mod = __c;
  1515. __format = __ctype.narrow(*__beg, 0);
  1516. }
  1517. else
  1518. break;
  1519. __s = this->do_put(__s, __io, __fill, __tm, __format, __mod);
  1520. }
  1521. else
  1522. break;
  1523. return __s;
  1524. }
  1525. template<typename _CharT, typename _OutIter>
  1526. _OutIter
  1527. time_put<_CharT, _OutIter>::
  1528. do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm,
  1529. char __format, char __mod) const
  1530. {
  1531. const locale& __loc = __io._M_getloc();
  1532. ctype<_CharT> const& __ctype = use_facet<ctype<_CharT> >(__loc);
  1533. __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
  1534. // NB: This size is arbitrary. Should this be a data member,
  1535. // initialized at construction?
  1536. const size_t __maxlen = 128;
  1537. char_type __res[__maxlen];
  1538. // NB: In IEE 1003.1-200x, and perhaps other locale models, it
  1539. // is possible that the format character will be longer than one
  1540. // character. Possibilities include 'E' or 'O' followed by a
  1541. // format character: if __mod is not the default argument, assume
  1542. // it's a valid modifier.
  1543. char_type __fmt[4];
  1544. __fmt[0] = __ctype.widen('%');
  1545. if (!__mod)
  1546. {
  1547. __fmt[1] = __format;
  1548. __fmt[2] = char_type();
  1549. }
  1550. else
  1551. {
  1552. __fmt[1] = __mod;
  1553. __fmt[2] = __format;
  1554. __fmt[3] = char_type();
  1555. }
  1556. __tp._M_put(__res, __maxlen, __fmt, __tm);
  1557. // Write resulting, fully-formatted string to output iterator.
  1558. return std::__write(__s, __res, char_traits<char_type>::length(__res));
  1559. }
  1560. // Inhibit implicit instantiations for required instantiations,
  1561. // which are defined via explicit instantiations elsewhere.
  1562. #if _GLIBCXX_EXTERN_TEMPLATE
  1563. extern template class moneypunct<char, false>;
  1564. extern template class moneypunct<char, true>;
  1565. extern template class moneypunct_byname<char, false>;
  1566. extern template class moneypunct_byname<char, true>;
  1567. extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get<char>;
  1568. extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put<char>;
  1569. extern template class __timepunct<char>;
  1570. extern template class time_put<char>;
  1571. extern template class time_put_byname<char>;
  1572. extern template class time_get<char>;
  1573. extern template class time_get_byname<char>;
  1574. extern template class messages<char>;
  1575. extern template class messages_byname<char>;
  1576. extern template
  1577. const moneypunct<char, true>&
  1578. use_facet<moneypunct<char, true> >(const locale&);
  1579. extern template
  1580. const moneypunct<char, false>&
  1581. use_facet<moneypunct<char, false> >(const locale&);
  1582. extern template
  1583. const money_put<char>&
  1584. use_facet<money_put<char> >(const locale&);
  1585. extern template
  1586. const money_get<char>&
  1587. use_facet<money_get<char> >(const locale&);
  1588. extern template
  1589. const __timepunct<char>&
  1590. use_facet<__timepunct<char> >(const locale&);
  1591. extern template
  1592. const time_put<char>&
  1593. use_facet<time_put<char> >(const locale&);
  1594. extern template
  1595. const time_get<char>&
  1596. use_facet<time_get<char> >(const locale&);
  1597. extern template
  1598. const messages<char>&
  1599. use_facet<messages<char> >(const locale&);
  1600. extern template
  1601. bool
  1602. has_facet<moneypunct<char> >(const locale&);
  1603. extern template
  1604. bool
  1605. has_facet<money_put<char> >(const locale&);
  1606. extern template
  1607. bool
  1608. has_facet<money_get<char> >(const locale&);
  1609. extern template
  1610. bool
  1611. has_facet<__timepunct<char> >(const locale&);
  1612. extern template
  1613. bool
  1614. has_facet<time_put<char> >(const locale&);
  1615. extern template
  1616. bool
  1617. has_facet<time_get<char> >(const locale&);
  1618. extern template
  1619. bool
  1620. has_facet<messages<char> >(const locale&);
  1621. #ifdef _GLIBCXX_USE_WCHAR_T
  1622. extern template class moneypunct<wchar_t, false>;
  1623. extern template class moneypunct<wchar_t, true>;
  1624. extern template class moneypunct_byname<wchar_t, false>;
  1625. extern template class moneypunct_byname<wchar_t, true>;
  1626. extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get<wchar_t>;
  1627. extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put<wchar_t>;
  1628. extern template class __timepunct<wchar_t>;
  1629. extern template class time_put<wchar_t>;
  1630. extern template class time_put_byname<wchar_t>;
  1631. extern template class time_get<wchar_t>;
  1632. extern template class time_get_byname<wchar_t>;
  1633. extern template class messages<wchar_t>;
  1634. extern template class messages_byname<wchar_t>;
  1635. extern template
  1636. const moneypunct<wchar_t, true>&
  1637. use_facet<moneypunct<wchar_t, true> >(const locale&);
  1638. extern template
  1639. const moneypunct<wchar_t, false>&
  1640. use_facet<moneypunct<wchar_t, false> >(const locale&);
  1641. extern template
  1642. const money_put<wchar_t>&
  1643. use_facet<money_put<wchar_t> >(const locale&);
  1644. extern template
  1645. const money_get<wchar_t>&
  1646. use_facet<money_get<wchar_t> >(const locale&);
  1647. extern template
  1648. const __timepunct<wchar_t>&
  1649. use_facet<__timepunct<wchar_t> >(const locale&);
  1650. extern template
  1651. const time_put<wchar_t>&
  1652. use_facet<time_put<wchar_t> >(const locale&);
  1653. extern template
  1654. const time_get<wchar_t>&
  1655. use_facet<time_get<wchar_t> >(const locale&);
  1656. extern template
  1657. const messages<wchar_t>&
  1658. use_facet<messages<wchar_t> >(const locale&);
  1659. extern template
  1660. bool
  1661. has_facet<moneypunct<wchar_t> >(const locale&);
  1662. extern template
  1663. bool
  1664. has_facet<money_put<wchar_t> >(const locale&);
  1665. extern template
  1666. bool
  1667. has_facet<money_get<wchar_t> >(const locale&);
  1668. extern template
  1669. bool
  1670. has_facet<__timepunct<wchar_t> >(const locale&);
  1671. extern template
  1672. bool
  1673. has_facet<time_put<wchar_t> >(const locale&);
  1674. extern template
  1675. bool
  1676. has_facet<time_get<wchar_t> >(const locale&);
  1677. extern template
  1678. bool
  1679. has_facet<messages<wchar_t> >(const locale&);
  1680. #endif
  1681. #endif
  1682. _GLIBCXX_END_NAMESPACE_VERSION
  1683. } // namespace std
  1684. #endif