Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/runtime/runtime-i18n.cc

Issue 2236393002: Revert of Throw when case mapping result > max string length (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/intl/general/case-mapping.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 862 result =
863 isolate, result, isolate->factory()->NewRawTwoByteString(dest_length)); 863 isolate->factory()->NewRawTwoByteString(dest_length).ToHandleChecked();
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
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
OLDNEW
« no previous file with comments | « no previous file | test/intl/general/case-mapping.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698