Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 1999 |
michael@0 | 3 | * Silicon Graphics Computer Systems, Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Copyright (c) 1999 |
michael@0 | 6 | * Boris Fomitchev |
michael@0 | 7 | * |
michael@0 | 8 | * This material is provided "as is", with absolutely no warranty expressed |
michael@0 | 9 | * or implied. Any use is at your own risk. |
michael@0 | 10 | * |
michael@0 | 11 | * Permission to use or copy this software for any purpose is hereby granted |
michael@0 | 12 | * without fee, provided the above notices are retained on all copies. |
michael@0 | 13 | * Permission to modify the code and to distribute modified code is granted, |
michael@0 | 14 | * provided the above notices are retained, and a notice that the code was |
michael@0 | 15 | * modified is included with the above copyright notice. |
michael@0 | 16 | * |
michael@0 | 17 | */ |
michael@0 | 18 | #include "stlport_prefix.h" |
michael@0 | 19 | |
michael@0 | 20 | #include <locale> |
michael@0 | 21 | #include <algorithm> |
michael@0 | 22 | |
michael@0 | 23 | _STLP_BEGIN_NAMESPACE |
michael@0 | 24 | |
michael@0 | 25 | //---------------------------------------------------------------------- |
michael@0 | 26 | // codecvt<char, char, mbstate_t> |
michael@0 | 27 | |
michael@0 | 28 | codecvt<char, char, mbstate_t>::~codecvt() {} |
michael@0 | 29 | |
michael@0 | 30 | int codecvt<char, char, mbstate_t>::do_length(state_type&, |
michael@0 | 31 | const char* from, |
michael@0 | 32 | const char* end, |
michael@0 | 33 | size_t mx) const |
michael@0 | 34 | { return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); } |
michael@0 | 35 | |
michael@0 | 36 | int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW |
michael@0 | 37 | { return 1; } |
michael@0 | 38 | |
michael@0 | 39 | bool |
michael@0 | 40 | codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW |
michael@0 | 41 | { return true; } |
michael@0 | 42 | |
michael@0 | 43 | int |
michael@0 | 44 | codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW |
michael@0 | 45 | { return 1; } |
michael@0 | 46 | |
michael@0 | 47 | codecvt_base::result |
michael@0 | 48 | codecvt<char, char, mbstate_t>::do_unshift(state_type& /* __state */, |
michael@0 | 49 | char* __to, |
michael@0 | 50 | char* /* __to_limit */, |
michael@0 | 51 | char*& __to_next) const |
michael@0 | 52 | { __to_next = __to; return noconv; } |
michael@0 | 53 | |
michael@0 | 54 | codecvt_base::result |
michael@0 | 55 | codecvt<char, char, mbstate_t>::do_in (state_type& /* __state */ , |
michael@0 | 56 | const char* __from, |
michael@0 | 57 | const char* /* __from_end */, |
michael@0 | 58 | const char*& __from_next, |
michael@0 | 59 | char* __to, |
michael@0 | 60 | char* /* __to_end */, |
michael@0 | 61 | char*& __to_next) const |
michael@0 | 62 | { __from_next = __from; __to_next = __to; return noconv; } |
michael@0 | 63 | |
michael@0 | 64 | codecvt_base::result |
michael@0 | 65 | codecvt<char, char, mbstate_t>::do_out(state_type& /* __state */, |
michael@0 | 66 | const char* __from, |
michael@0 | 67 | const char* /* __from_end */, |
michael@0 | 68 | const char*& __from_next, |
michael@0 | 69 | char* __to, |
michael@0 | 70 | char* /* __to_limit */, |
michael@0 | 71 | char*& __to_next) const |
michael@0 | 72 | { __from_next = __from; __to_next = __to; return noconv; } |
michael@0 | 73 | |
michael@0 | 74 | |
michael@0 | 75 | #if !defined (_STLP_NO_WCHAR_T) |
michael@0 | 76 | //---------------------------------------------------------------------- |
michael@0 | 77 | // codecvt<wchar_t, char, mbstate_t> |
michael@0 | 78 | |
michael@0 | 79 | codecvt<wchar_t, char, mbstate_t>::~codecvt() {} |
michael@0 | 80 | |
michael@0 | 81 | |
michael@0 | 82 | codecvt<wchar_t, char, mbstate_t>::result |
michael@0 | 83 | codecvt<wchar_t, char, mbstate_t>::do_out(state_type& /* state */, |
michael@0 | 84 | const intern_type* from, |
michael@0 | 85 | const intern_type* from_end, |
michael@0 | 86 | const intern_type*& from_next, |
michael@0 | 87 | extern_type* to, |
michael@0 | 88 | extern_type* to_limit, |
michael@0 | 89 | extern_type*& to_next) const { |
michael@0 | 90 | ptrdiff_t len = (min) (from_end - from, to_limit - to); |
michael@0 | 91 | copy(from, from + len, to); |
michael@0 | 92 | from_next = from + len; |
michael@0 | 93 | to_next = to + len; |
michael@0 | 94 | return ok; |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | codecvt<wchar_t, char, mbstate_t>::result |
michael@0 | 98 | codecvt<wchar_t, char, mbstate_t>::do_in (state_type& /* state */, |
michael@0 | 99 | const extern_type* from, |
michael@0 | 100 | const extern_type* from_end, |
michael@0 | 101 | const extern_type*& from_next, |
michael@0 | 102 | intern_type* to, |
michael@0 | 103 | intern_type* to_limit, |
michael@0 | 104 | intern_type*& to_next) const { |
michael@0 | 105 | ptrdiff_t len = (min) (from_end - from, to_limit - to); |
michael@0 | 106 | copy(__REINTERPRET_CAST(const unsigned char*, from), |
michael@0 | 107 | __REINTERPRET_CAST(const unsigned char*, from) + len, to); |
michael@0 | 108 | from_next = from + len; |
michael@0 | 109 | to_next = to + len; |
michael@0 | 110 | return ok; |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | codecvt<wchar_t, char, mbstate_t>::result |
michael@0 | 114 | codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& /* state */, |
michael@0 | 115 | extern_type* to, |
michael@0 | 116 | extern_type* , |
michael@0 | 117 | extern_type*& to_next) const { |
michael@0 | 118 | to_next = to; |
michael@0 | 119 | return noconv; |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW |
michael@0 | 123 | { return 1; } |
michael@0 | 124 | |
michael@0 | 125 | bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW |
michael@0 | 126 | { return true; } |
michael@0 | 127 | |
michael@0 | 128 | int codecvt<wchar_t, char, mbstate_t>::do_length(state_type&, |
michael@0 | 129 | const extern_type* from, |
michael@0 | 130 | const extern_type* end, |
michael@0 | 131 | size_t mx) const |
michael@0 | 132 | { return (int)(min) ((size_t) (end - from), mx); } |
michael@0 | 133 | |
michael@0 | 134 | int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW |
michael@0 | 135 | { return 1; } |
michael@0 | 136 | #endif /* wchar_t */ |
michael@0 | 137 | |
michael@0 | 138 | _STLP_END_NAMESPACE |
michael@0 | 139 | |
michael@0 | 140 | // Local Variables: |
michael@0 | 141 | // mode:C++ |
michael@0 | 142 | // End: |
michael@0 | 143 |