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

Unified Diff: src/runtime.cc

Issue 7263: Fixed bug 114 (Closed)
Patch Set: Added some more tests and fixed an issue they revealed. Created 12 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-114.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index f3fb849de4dd81aad03cda7f96053aa8b822b2c5..0d9525d25b62a5b04278befb94f2faa7dbd98ea8 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -2132,7 +2132,8 @@ static Object* ConvertCase(Arguments args,
// We can assume that the string is not empty
uc32 current = buffer->GetNext();
while (i < length) {
- uc32 next = buffer->has_more() ? buffer->GetNext() : 0;
+ bool has_next = buffer->has_more();
+ uc32 next = has_next ? buffer->GetNext() : 0;
int char_length = mapping->get(current, next, chars);
if (char_length == 0) {
// The case conversion of this character is the character itself.
@@ -2156,12 +2157,17 @@ static Object* ConvertCase(Arguments args,
// "realloc" it and probably, in the vast majority of cases,
// extend the existing string to be able to hold the full
// result.
- int current_length = i + char_length + mapping->get(next, 0, chars);
+ int next_length = 0;
+ if (has_next) {
+ next_length = mapping->get(next, 0, chars);
Erik Corry 2008/10/14 09:01:53 Missing comment here to explain why 0 is OK.
+ if (next_length == 0) next_length = 1;
+ }
+ int current_length = i + char_length + next_length;
while (buffer->has_more()) {
current = buffer->GetNext();
int char_length = mapping->get(current, 0, chars);
if (char_length == 0) char_length = 1;
- current += char_length;
+ current_length += char_length;
}
length = current_length;
goto try_convert;
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-114.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698