]>
Commit | Line | Data |
---|---|---|
c099f5df | 1 | // Locale support (codecvt) -*- C++ -*- |
2 | ||
fbd26352 | 3 | // Copyright (C) 2000-2019 Free Software Foundation, Inc. |
c099f5df | 4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
6bc9506f | 8 | // Free Software Foundation; either version 3, or (at your option) |
c099f5df | 9 | // any later version. |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
6bc9506f | 16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
c099f5df | 24 | |
25 | // | |
26 | // ISO C++ 14882: 22.2.1.5 Template class codecvt | |
27 | // | |
28 | ||
4d292396 | 29 | // Written by Benjamin Kosnik <bkoz@redhat.com> |
c099f5df | 30 | |
4102e044 | 31 | /** @file ext/codecvt_specializations.h |
4d292396 | 32 | * This file is a GNU extension to the Standard C++ Library. |
81e48263 | 33 | */ |
34 | ||
4102e044 | 35 | #ifndef _EXT_CODECVT_SPECIALIZATIONS_H |
36 | #define _EXT_CODECVT_SPECIALIZATIONS_H 1 | |
37 | ||
6f257318 | 38 | #include <bits/c++config.h> |
4102e044 | 39 | #include <locale> |
40 | #include <iconv.h> | |
41 | ||
2948dd21 | 42 | namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) |
43 | { | |
44 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
ae6a4ce9 | 45 | _GLIBCXX_BEGIN_NAMESPACE_CXX11 |
1069247d | 46 | |
4a77b438 | 47 | /// Extension to use iconv for dealing with character encodings. |
fdc7233f | 48 | // This includes conversions and comparisons between various character |
a0bda314 | 49 | // sets. This object encapsulates data that may need to be shared between |
50 | // char_traits, codecvt and ctype. | |
0fe0648d | 51 | class encoding_state |
c099f5df | 52 | { |
53 | public: | |
54 | // Types: | |
55 | // NB: A conversion descriptor subsumes and enhances the | |
56 | // functionality of a simple state type such as mbstate_t. | |
4d292396 | 57 | typedef iconv_t descriptor_type; |
c099f5df | 58 | |
59 | protected: | |
c099f5df | 60 | // Name of internal character set encoding. |
4d292396 | 61 | std::string _M_int_enc; |
62 | ||
c099f5df | 63 | // Name of external character set encoding. |
4d292396 | 64 | std::string _M_ext_enc; |
c099f5df | 65 | |
66 | // Conversion descriptor between external encoding to internal encoding. | |
4d292396 | 67 | descriptor_type _M_in_desc; |
68 | ||
c099f5df | 69 | // Conversion descriptor between internal encoding to external encoding. |
4d292396 | 70 | descriptor_type _M_out_desc; |
c099f5df | 71 | |
4d292396 | 72 | // The byte-order marker for the external encoding, if necessary. |
c099f5df | 73 | int _M_ext_bom; |
74 | ||
4d292396 | 75 | // The byte-order marker for the internal encoding, if necessary. |
c099f5df | 76 | int _M_int_bom; |
77 | ||
4d292396 | 78 | // Number of external bytes needed to construct one complete |
79 | // character in the internal encoding. | |
80 | // NB: -1 indicates variable, or stateful, encodings. | |
81 | int _M_bytes; | |
a0bda314 | 82 | |
4d292396 | 83 | public: |
84 | explicit | |
85 | encoding_state() | |
86 | : _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0), _M_bytes(0) | |
87 | { } | |
88 | ||
89 | explicit | |
90 | encoding_state(const char* __int, const char* __ext, | |
91 | int __ibom = 0, int __ebom = 0, int __bytes = 1) | |
92 | : _M_int_enc(__int), _M_ext_enc(__ext), _M_in_desc(0), _M_out_desc(0), | |
93 | _M_ext_bom(__ebom), _M_int_bom(__ibom), _M_bytes(__bytes) | |
94 | { init(); } | |
c099f5df | 95 | |
96 | // 21.1.2 traits typedefs | |
97 | // p4 | |
98 | // typedef STATE_T state_type | |
99 | // requires: state_type shall meet the requirements of | |
100 | // CopyConstructible types (20.1.3) | |
9fc1117c | 101 | // NB: This does not preserve the actual state of the conversion |
640f7913 | 102 | // descriptor member, but it does duplicate the encoding |
103 | // information. | |
4d292396 | 104 | encoding_state(const encoding_state& __obj) : _M_in_desc(0), _M_out_desc(0) |
105 | { construct(__obj); } | |
c099f5df | 106 | |
a0bda314 | 107 | // Need assignment operator as well. |
4d292396 | 108 | encoding_state& |
109 | operator=(const encoding_state& __obj) | |
a0bda314 | 110 | { |
4d292396 | 111 | construct(__obj); |
441e8e10 | 112 | return *this; |
a0bda314 | 113 | } |
114 | ||
4d292396 | 115 | ~encoding_state() |
116 | { destroy(); } | |
c099f5df | 117 | |
4d292396 | 118 | bool |
119 | good() const throw() | |
120 | { | |
1eac4749 | 121 | const descriptor_type __err = (iconv_t)(-1); |
4d292396 | 122 | bool __test = _M_in_desc && _M_in_desc != __err; |
123 | __test &= _M_out_desc && _M_out_desc != __err; | |
124 | return __test; | |
125 | } | |
126 | ||
127 | int | |
128 | character_ratio() const | |
129 | { return _M_bytes; } | |
130 | ||
131 | const std::string | |
132 | internal_encoding() const | |
133 | { return _M_int_enc; } | |
134 | ||
135 | int | |
136 | internal_bom() const | |
137 | { return _M_int_bom; } | |
138 | ||
139 | const std::string | |
140 | external_encoding() const | |
141 | { return _M_ext_enc; } | |
142 | ||
143 | int | |
144 | external_bom() const | |
145 | { return _M_ext_bom; } | |
146 | ||
147 | const descriptor_type& | |
148 | in_descriptor() const | |
149 | { return _M_in_desc; } | |
150 | ||
151 | const descriptor_type& | |
152 | out_descriptor() const | |
153 | { return _M_out_desc; } | |
154 | ||
155 | protected: | |
c099f5df | 156 | void |
4d292396 | 157 | init() |
c099f5df | 158 | { |
1eac4749 | 159 | const descriptor_type __err = (iconv_t)(-1); |
4d292396 | 160 | const bool __have_encodings = _M_int_enc.size() && _M_ext_enc.size(); |
161 | if (!_M_in_desc && __have_encodings) | |
a0bda314 | 162 | { |
4d292396 | 163 | _M_in_desc = iconv_open(_M_int_enc.c_str(), _M_ext_enc.c_str()); |
a0bda314 | 164 | if (_M_in_desc == __err) |
4d292396 | 165 | std::__throw_runtime_error(__N("encoding_state::_M_init " |
166 | "creating iconv input descriptor failed")); | |
a0bda314 | 167 | } |
4d292396 | 168 | if (!_M_out_desc && __have_encodings) |
a0bda314 | 169 | { |
4d292396 | 170 | _M_out_desc = iconv_open(_M_ext_enc.c_str(), _M_int_enc.c_str()); |
a0bda314 | 171 | if (_M_out_desc == __err) |
4d292396 | 172 | std::__throw_runtime_error(__N("encoding_state::_M_init " |
5ed189cb | 173 | "creating iconv output descriptor failed")); |
a0bda314 | 174 | } |
c099f5df | 175 | } |
176 | ||
640f7913 | 177 | void |
4d292396 | 178 | construct(const encoding_state& __obj) |
640f7913 | 179 | { |
4d292396 | 180 | destroy(); |
181 | _M_int_enc = __obj._M_int_enc; | |
182 | _M_ext_enc = __obj._M_ext_enc; | |
183 | _M_ext_bom = __obj._M_ext_bom; | |
184 | _M_int_bom = __obj._M_int_bom; | |
185 | _M_bytes = __obj._M_bytes; | |
186 | init(); | |
187 | } | |
188 | ||
189 | void | |
190 | destroy() throw() | |
191 | { | |
1eac4749 | 192 | const descriptor_type __err = (iconv_t)(-1); |
640f7913 | 193 | if (_M_in_desc && _M_in_desc != __err) |
194 | { | |
195 | iconv_close(_M_in_desc); | |
196 | _M_in_desc = 0; | |
197 | } | |
198 | if (_M_out_desc && _M_out_desc != __err) | |
199 | { | |
200 | iconv_close(_M_out_desc); | |
201 | _M_out_desc = 0; | |
202 | } | |
203 | } | |
4d292396 | 204 | }; |
640f7913 | 205 | |
4a77b438 | 206 | /// encoding_char_traits |
4d292396 | 207 | // Custom traits type with encoding_state for the state type, and the |
208 | // associated fpos<encoding_state> for the position type, all other | |
209 | // bits equivalent to the required char_traits instantiations. | |
210 | template<typename _CharT> | |
0fe0648d | 211 | struct encoding_char_traits |
29898472 | 212 | : public std::char_traits<_CharT> |
4d292396 | 213 | { |
214 | typedef encoding_state state_type; | |
215 | typedef typename std::fpos<state_type> pos_type; | |
216 | }; | |
a0bda314 | 217 | |
0fe0648d | 218 | _GLIBCXX_END_NAMESPACE_CXX11 |
ae6a4ce9 | 219 | _GLIBCXX_END_NAMESPACE_VERSION |
2948dd21 | 220 | } // namespace |
1069247d | 221 | |
222 | ||
2948dd21 | 223 | namespace std _GLIBCXX_VISIBILITY(default) |
224 | { | |
225 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
1069247d | 226 | |
4d292396 | 227 | using __gnu_cxx::encoding_state; |
c099f5df | 228 | |
4a77b438 | 229 | /// codecvt<InternT, _ExternT, encoding_state> specialization. |
81e48263 | 230 | // This partial specialization takes advantage of iconv to provide |
231 | // code conversions between a large number of character encodings. | |
c099f5df | 232 | template<typename _InternT, typename _ExternT> |
4d292396 | 233 | class codecvt<_InternT, _ExternT, encoding_state> |
234 | : public __codecvt_abstract_base<_InternT, _ExternT, encoding_state> | |
c099f5df | 235 | { |
236 | public: | |
237 | // Types: | |
238 | typedef codecvt_base::result result; | |
239 | typedef _InternT intern_type; | |
240 | typedef _ExternT extern_type; | |
4d292396 | 241 | typedef __gnu_cxx::encoding_state state_type; |
242 | typedef state_type::descriptor_type descriptor_type; | |
c099f5df | 243 | |
244 | // Data Members: | |
245 | static locale::id id; | |
246 | ||
247 | explicit | |
248 | codecvt(size_t __refs = 0) | |
249 | : __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs) | |
250 | { } | |
251 | ||
252 | explicit | |
4d292396 | 253 | codecvt(state_type& __enc, size_t __refs = 0) |
c099f5df | 254 | : __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs) |
255 | { } | |
256 | ||
4d292396 | 257 | protected: |
c099f5df | 258 | virtual |
259 | ~codecvt() { } | |
260 | ||
261 | virtual result | |
262 | do_out(state_type& __state, const intern_type* __from, | |
263 | const intern_type* __from_end, const intern_type*& __from_next, | |
264 | extern_type* __to, extern_type* __to_end, | |
265 | extern_type*& __to_next) const; | |
266 | ||
267 | virtual result | |
268 | do_unshift(state_type& __state, extern_type* __to, | |
269 | extern_type* __to_end, extern_type*& __to_next) const; | |
270 | ||
271 | virtual result | |
272 | do_in(state_type& __state, const extern_type* __from, | |
273 | const extern_type* __from_end, const extern_type*& __from_next, | |
274 | intern_type* __to, intern_type* __to_end, | |
275 | intern_type*& __to_next) const; | |
276 | ||
277 | virtual int | |
278 | do_encoding() const throw(); | |
279 | ||
280 | virtual bool | |
281 | do_always_noconv() const throw(); | |
282 | ||
283 | virtual int | |
4229b2e4 | 284 | do_length(state_type&, const extern_type* __from, |
c099f5df | 285 | const extern_type* __end, size_t __max) const; |
286 | ||
287 | virtual int | |
288 | do_max_length() const throw(); | |
289 | }; | |
290 | ||
291 | template<typename _InternT, typename _ExternT> | |
292 | locale::id | |
4d292396 | 293 | codecvt<_InternT, _ExternT, encoding_state>::id; |
c099f5df | 294 | |
295 | // This adaptor works around the signature problems of the second | |
296 | // argument to iconv(): SUSv2 and others use 'const char**', but glibc 2.2 | |
16b3694c | 297 | // uses 'char**', which matches the POSIX 1003.1-2001 standard. |
298 | // Using this adaptor, g++ will do the work for us. | |
5d87d34c | 299 | template<typename _Tp> |
c099f5df | 300 | inline size_t |
5d87d34c | 301 | __iconv_adaptor(size_t(*__func)(iconv_t, _Tp, size_t*, char**, size_t*), |
16b3694c | 302 | iconv_t __cd, char** __inbuf, size_t* __inbytes, |
303 | char** __outbuf, size_t* __outbytes) | |
5d87d34c | 304 | { return __func(__cd, (_Tp)__inbuf, __inbytes, __outbuf, __outbytes); } |
c099f5df | 305 | |
306 | template<typename _InternT, typename _ExternT> | |
307 | codecvt_base::result | |
4d292396 | 308 | codecvt<_InternT, _ExternT, encoding_state>:: |
c099f5df | 309 | do_out(state_type& __state, const intern_type* __from, |
310 | const intern_type* __from_end, const intern_type*& __from_next, | |
311 | extern_type* __to, extern_type* __to_end, | |
312 | extern_type*& __to_next) const | |
313 | { | |
954ad420 | 314 | result __ret = codecvt_base::error; |
4d292396 | 315 | if (__state.good()) |
c099f5df | 316 | { |
4d292396 | 317 | const descriptor_type& __desc = __state.out_descriptor(); |
41b32fc1 | 318 | const size_t __fmultiple = sizeof(intern_type); |
16b3694c | 319 | size_t __fbytes = __fmultiple * (__from_end - __from); |
41b32fc1 | 320 | const size_t __tmultiple = sizeof(extern_type); |
16b3694c | 321 | size_t __tbytes = __tmultiple * (__to_end - __to); |
c099f5df | 322 | |
323 | // Argument list for iconv specifies a byte sequence. Thus, | |
324 | // all to/from arrays must be brutally casted to char*. | |
325 | char* __cto = reinterpret_cast<char*>(__to); | |
326 | char* __cfrom; | |
327 | size_t __conv; | |
328 | ||
329 | // Some encodings need a byte order marker as the first item | |
330 | // in the byte stream, to designate endian-ness. The default | |
331 | // value for the byte order marker is NULL, so if this is | |
332 | // the case, it's not necessary and we can just go on our | |
333 | // merry way. | |
4d292396 | 334 | int __int_bom = __state.internal_bom(); |
c099f5df | 335 | if (__int_bom) |
336 | { | |
337 | size_t __size = __from_end - __from; | |
5c3f9fb7 | 338 | intern_type* __cfixed = static_cast<intern_type*> |
339 | (__builtin_alloca(sizeof(intern_type) * (__size + 1))); | |
c099f5df | 340 | __cfixed[0] = static_cast<intern_type>(__int_bom); |
341 | char_traits<intern_type>::copy(__cfixed + 1, __from, __size); | |
342 | __cfrom = reinterpret_cast<char*>(__cfixed); | |
4d292396 | 343 | __conv = __iconv_adaptor(iconv, __desc, &__cfrom, |
16b3694c | 344 | &__fbytes, &__cto, &__tbytes); |
c099f5df | 345 | } |
346 | else | |
347 | { | |
348 | intern_type* __cfixed = const_cast<intern_type*>(__from); | |
349 | __cfrom = reinterpret_cast<char*>(__cfixed); | |
4d292396 | 350 | __conv = __iconv_adaptor(iconv, __desc, &__cfrom, &__fbytes, |
16b3694c | 351 | &__cto, &__tbytes); |
c099f5df | 352 | } |
353 | ||
354 | if (__conv != size_t(-1)) | |
355 | { | |
356 | __from_next = reinterpret_cast<const intern_type*>(__cfrom); | |
357 | __to_next = reinterpret_cast<extern_type*>(__cto); | |
954ad420 | 358 | __ret = codecvt_base::ok; |
c099f5df | 359 | } |
360 | else | |
361 | { | |
16b3694c | 362 | if (__fbytes < __fmultiple * (__from_end - __from)) |
c099f5df | 363 | { |
364 | __from_next = reinterpret_cast<const intern_type*>(__cfrom); | |
365 | __to_next = reinterpret_cast<extern_type*>(__cto); | |
954ad420 | 366 | __ret = codecvt_base::partial; |
c099f5df | 367 | } |
368 | else | |
954ad420 | 369 | __ret = codecvt_base::error; |
c099f5df | 370 | } |
371 | } | |
372 | return __ret; | |
373 | } | |
374 | ||
375 | template<typename _InternT, typename _ExternT> | |
376 | codecvt_base::result | |
4d292396 | 377 | codecvt<_InternT, _ExternT, encoding_state>:: |
c099f5df | 378 | do_unshift(state_type& __state, extern_type* __to, |
379 | extern_type* __to_end, extern_type*& __to_next) const | |
380 | { | |
954ad420 | 381 | result __ret = codecvt_base::error; |
4d292396 | 382 | if (__state.good()) |
c099f5df | 383 | { |
4d292396 | 384 | const descriptor_type& __desc = __state.in_descriptor(); |
41b32fc1 | 385 | const size_t __tmultiple = sizeof(intern_type); |
c099f5df | 386 | size_t __tlen = __tmultiple * (__to_end - __to); |
387 | ||
388 | // Argument list for iconv specifies a byte sequence. Thus, | |
389 | // all to/from arrays must be brutally casted to char*. | |
390 | char* __cto = reinterpret_cast<char*>(__to); | |
e4bb1925 | 391 | size_t __conv = __iconv_adaptor(iconv,__desc, 0, 0, |
c099f5df | 392 | &__cto, &__tlen); |
393 | ||
394 | if (__conv != size_t(-1)) | |
395 | { | |
396 | __to_next = reinterpret_cast<extern_type*>(__cto); | |
397 | if (__tlen == __tmultiple * (__to_end - __to)) | |
954ad420 | 398 | __ret = codecvt_base::noconv; |
c099f5df | 399 | else if (__tlen == 0) |
954ad420 | 400 | __ret = codecvt_base::ok; |
c099f5df | 401 | else |
954ad420 | 402 | __ret = codecvt_base::partial; |
c099f5df | 403 | } |
404 | else | |
954ad420 | 405 | __ret = codecvt_base::error; |
c099f5df | 406 | } |
407 | return __ret; | |
408 | } | |
409 | ||
410 | template<typename _InternT, typename _ExternT> | |
411 | codecvt_base::result | |
4d292396 | 412 | codecvt<_InternT, _ExternT, encoding_state>:: |
c099f5df | 413 | do_in(state_type& __state, const extern_type* __from, |
414 | const extern_type* __from_end, const extern_type*& __from_next, | |
415 | intern_type* __to, intern_type* __to_end, | |
416 | intern_type*& __to_next) const | |
417 | { | |
954ad420 | 418 | result __ret = codecvt_base::error; |
4d292396 | 419 | if (__state.good()) |
c099f5df | 420 | { |
4d292396 | 421 | const descriptor_type& __desc = __state.in_descriptor(); |
41b32fc1 | 422 | const size_t __fmultiple = sizeof(extern_type); |
c099f5df | 423 | size_t __flen = __fmultiple * (__from_end - __from); |
41b32fc1 | 424 | const size_t __tmultiple = sizeof(intern_type); |
c099f5df | 425 | size_t __tlen = __tmultiple * (__to_end - __to); |
426 | ||
427 | // Argument list for iconv specifies a byte sequence. Thus, | |
428 | // all to/from arrays must be brutally casted to char*. | |
429 | char* __cto = reinterpret_cast<char*>(__to); | |
430 | char* __cfrom; | |
431 | size_t __conv; | |
432 | ||
433 | // Some encodings need a byte order marker as the first item | |
434 | // in the byte stream, to designate endian-ness. The default | |
435 | // value for the byte order marker is NULL, so if this is | |
436 | // the case, it's not necessary and we can just go on our | |
437 | // merry way. | |
4d292396 | 438 | int __ext_bom = __state.external_bom(); |
c099f5df | 439 | if (__ext_bom) |
440 | { | |
441 | size_t __size = __from_end - __from; | |
5c3f9fb7 | 442 | extern_type* __cfixed = static_cast<extern_type*> |
443 | (__builtin_alloca(sizeof(extern_type) * (__size + 1))); | |
c099f5df | 444 | __cfixed[0] = static_cast<extern_type>(__ext_bom); |
445 | char_traits<extern_type>::copy(__cfixed + 1, __from, __size); | |
446 | __cfrom = reinterpret_cast<char*>(__cfixed); | |
4d292396 | 447 | __conv = __iconv_adaptor(iconv, __desc, &__cfrom, |
c099f5df | 448 | &__flen, &__cto, &__tlen); |
449 | } | |
450 | else | |
451 | { | |
452 | extern_type* __cfixed = const_cast<extern_type*>(__from); | |
453 | __cfrom = reinterpret_cast<char*>(__cfixed); | |
4d292396 | 454 | __conv = __iconv_adaptor(iconv, __desc, &__cfrom, |
c099f5df | 455 | &__flen, &__cto, &__tlen); |
456 | } | |
457 | ||
458 | ||
459 | if (__conv != size_t(-1)) | |
460 | { | |
461 | __from_next = reinterpret_cast<const extern_type*>(__cfrom); | |
462 | __to_next = reinterpret_cast<intern_type*>(__cto); | |
954ad420 | 463 | __ret = codecvt_base::ok; |
c099f5df | 464 | } |
465 | else | |
466 | { | |
467 | if (__flen < static_cast<size_t>(__from_end - __from)) | |
468 | { | |
469 | __from_next = reinterpret_cast<const extern_type*>(__cfrom); | |
470 | __to_next = reinterpret_cast<intern_type*>(__cto); | |
954ad420 | 471 | __ret = codecvt_base::partial; |
c099f5df | 472 | } |
473 | else | |
954ad420 | 474 | __ret = codecvt_base::error; |
c099f5df | 475 | } |
476 | } | |
477 | return __ret; | |
478 | } | |
479 | ||
480 | template<typename _InternT, typename _ExternT> | |
481 | int | |
4d292396 | 482 | codecvt<_InternT, _ExternT, encoding_state>:: |
c099f5df | 483 | do_encoding() const throw() |
16b3694c | 484 | { |
485 | int __ret = 0; | |
486 | if (sizeof(_ExternT) <= sizeof(_InternT)) | |
4d292396 | 487 | __ret = sizeof(_InternT) / sizeof(_ExternT); |
16b3694c | 488 | return __ret; |
489 | } | |
c099f5df | 490 | |
491 | template<typename _InternT, typename _ExternT> | |
492 | bool | |
4d292396 | 493 | codecvt<_InternT, _ExternT, encoding_state>:: |
c099f5df | 494 | do_always_noconv() const throw() |
495 | { return false; } | |
496 | ||
497 | template<typename _InternT, typename _ExternT> | |
498 | int | |
4d292396 | 499 | codecvt<_InternT, _ExternT, encoding_state>:: |
4229b2e4 | 500 | do_length(state_type&, const extern_type* __from, |
c099f5df | 501 | const extern_type* __end, size_t __max) const |
805e22b2 | 502 | { return std::min(__max, static_cast<size_t>(__end - __from)); } |
c099f5df | 503 | |
e6829c6a | 504 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
505 | // 74. Garbled text for codecvt::do_max_length | |
c099f5df | 506 | template<typename _InternT, typename _ExternT> |
507 | int | |
4d292396 | 508 | codecvt<_InternT, _ExternT, encoding_state>:: |
c099f5df | 509 | do_max_length() const throw() |
510 | { return 1; } | |
1069247d | 511 | |
2948dd21 | 512 | _GLIBCXX_END_NAMESPACE_VERSION |
513 | } // namespace | |
e6829c6a | 514 | |
4102e044 | 515 | #endif |