OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 #ifdef V8_I18N_SUPPORT | 6 #ifdef V8_I18N_SUPPORT |
7 #include "src/runtime/runtime-utils.h" | 7 #include "src/runtime/runtime-utils.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 auto case_converter = is_to_upper ? u_strToUpper : u_strToLower; | 852 auto case_converter = is_to_upper ? u_strToUpper : u_strToLower; |
853 | 853 |
854 int32_t dest_length = src_length; | 854 int32_t dest_length = src_length; |
855 UErrorCode status; | 855 UErrorCode status; |
856 Handle<SeqTwoByteString> result; | 856 Handle<SeqTwoByteString> result; |
857 std::unique_ptr<uc16[]> sap; | 857 std::unique_ptr<uc16[]> sap; |
858 | 858 |
859 // This is not a real loop. It'll be executed only once (no overflow) or | 859 // This is not a real loop. It'll be executed only once (no overflow) or |
860 // twice (overflow). | 860 // twice (overflow). |
861 for (int i = 0; i < 2; ++i) { | 861 for (int i = 0; i < 2; ++i) { |
862 result = | 862 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
863 isolate->factory()->NewRawTwoByteString(dest_length).ToHandleChecked(); | 863 isolate, result, isolate->factory()->NewRawTwoByteString(dest_length)); |
864 DisallowHeapAllocation no_gc; | 864 DisallowHeapAllocation no_gc; |
865 String::FlatContent flat = s->GetFlatContent(); | 865 String::FlatContent flat = s->GetFlatContent(); |
866 const UChar* src = GetUCharBufferFromFlat(flat, &sap, src_length); | 866 const UChar* src = GetUCharBufferFromFlat(flat, &sap, src_length); |
867 status = U_ZERO_ERROR; | 867 status = U_ZERO_ERROR; |
868 dest_length = case_converter(reinterpret_cast<UChar*>(result->GetChars()), | 868 dest_length = case_converter(reinterpret_cast<UChar*>(result->GetChars()), |
869 dest_length, src, src_length, lang, &status); | 869 dest_length, src, src_length, lang, &status); |
870 if (status != U_BUFFER_OVERFLOW_ERROR) break; | 870 if (status != U_BUFFER_OVERFLOW_ERROR) break; |
871 } | 871 } |
872 | 872 |
873 // In most cases, the output will fill the destination buffer completely | 873 // In most cases, the output will fill the destination buffer completely |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 Handle<FixedArray> date_cache_version = | 1151 Handle<FixedArray> date_cache_version = |
1152 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 1152 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( |
1153 EternalHandles::DATE_CACHE_VERSION)); | 1153 EternalHandles::DATE_CACHE_VERSION)); |
1154 return date_cache_version->get(0); | 1154 return date_cache_version->get(0); |
1155 } | 1155 } |
1156 | 1156 |
1157 } // namespace internal | 1157 } // namespace internal |
1158 } // namespace v8 | 1158 } // namespace v8 |
1159 | 1159 |
1160 #endif // V8_I18N_SUPPORT | 1160 #endif // V8_I18N_SUPPORT |
OLD | NEW |