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

Unified Diff: runtime/lib/bool.cc

Issue 54663002: Change int.fromEnvironment in VM to use same code as int.parse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change order for String/bool too. Add canonicalization. Created 7 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 | runtime/lib/integers.cc » ('j') | runtime/lib/integers.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/bool.cc
diff --git a/runtime/lib/bool.cc b/runtime/lib/bool.cc
index ae4af27f9301fc89a2c8af25a83f29f8bb46cd8b..30a69629d010887a433561b213b05406ec27a3c1 100644
--- a/runtime/lib/bool.cc
+++ b/runtime/lib/bool.cc
@@ -24,17 +24,17 @@ DEFINE_NATIVE_ENTRY(Bool_fromEnvironment, 3) {
Dart_EnvironmentCallback callback = isolate->environment_callback();
if (callback != NULL) {
Dart_Handle result = callback(Api::NewHandle(isolate, name.raw()));
- if (Dart_IsError(result)) {
+ if (Dart_IsString(result)) {
+ const char *chars;
+ Dart_StringToCString(result, &chars);
+ return (strcmp("true", chars) == 0)
+ ? Bool::True().raw() : Bool::False().raw();
+ } else if (Dart_IsError(result)) {
const Object& error =
Object::Handle(isolate, Api::UnwrapHandle(result));
Exceptions::ThrowArgumentError(
String::Handle(
String::New(Error::Cast(error).ToErrorCString())));
- } else if (Dart_IsString(result)) {
- const char *chars;
- Dart_StringToCString(result, &chars);
- return (strcmp("true", chars) == 0)
- ? Bool::True().raw() : Bool::False().raw();
} else if (!Dart_IsNull(result)) {
Exceptions::ThrowArgumentError(
String::Handle(String::New("Illegal environment value")));
« no previous file with comments | « no previous file | runtime/lib/integers.cc » ('j') | runtime/lib/integers.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698