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

Side by Side Diff: vm/symbols.cc

Issue 11419259: Fix bug in Utf8::CodePointCount which was causing some strings with latin1 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « vm/object_test.cc ('k') | vm/unicode.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/symbols.h" 5 #include "vm/symbols.h"
6 6
7 #include "vm/isolate.h" 7 #include "vm/isolate.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/raw_object.h" 10 #include "vm/raw_object.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 ASSERT(symbol_table.At(index) == String::null()); 95 ASSERT(symbol_table.At(index) == String::null());
96 InsertIntoSymbolTable(symbol_table, str, index); 96 InsertIntoSymbolTable(symbol_table, str, index);
97 } 97 }
98 98
99 99
100 RawString* Symbols::New(const char* str) { 100 RawString* Symbols::New(const char* str) {
101 ASSERT(str != NULL); 101 ASSERT(str != NULL);
102 Utf8::Type type; 102 Utf8::Type type;
103 intptr_t str_len = strlen(str); 103 intptr_t str_len = strlen(str);
104 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(str); 104 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(str);
105 intptr_t len = Utf8::CodePointCount(utf8_array, str_len, &type); 105 intptr_t len = Utf8::CodeUnitCount(utf8_array, str_len, &type);
106 Zone* zone = Isolate::Current()->current_zone(); 106 Zone* zone = Isolate::Current()->current_zone();
107 if (len == 0) { 107 if (len == 0) {
108 return Symbols::New(reinterpret_cast<uint8_t*>(NULL), 0); 108 return Symbols::New(reinterpret_cast<uint8_t*>(NULL), 0);
109 } 109 }
110 if (type == Utf8::kLatin1) { 110 if (type == Utf8::kLatin1) {
111 uint8_t* characters = zone->Alloc<uint8_t>(len); 111 uint8_t* characters = zone->Alloc<uint8_t>(len);
112 Utf8::DecodeToLatin1(utf8_array, str_len, characters, len); 112 Utf8::DecodeToLatin1(utf8_array, str_len, characters, len);
113 return New(characters, len); 113 return New(characters, len);
114 } 114 }
115 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary)); 115 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary));
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 323 }
324 324
325 325
326 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { 326 RawObject* Symbols::GetVMSymbol(intptr_t object_id) {
327 ASSERT(IsVMSymbolId(object_id)); 327 ASSERT(IsVMSymbolId(object_id));
328 intptr_t i = (object_id - kMaxPredefinedObjectIds); 328 intptr_t i = (object_id - kMaxPredefinedObjectIds);
329 return (i > 0 && i < Symbols::kMaxId) ? predefined_[i] : Object::null(); 329 return (i > 0 && i < Symbols::kMaxId) ? predefined_[i] : Object::null();
330 } 330 }
331 331
332 } // namespace dart 332 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object_test.cc ('k') | vm/unicode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698