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

Unified Diff: vm/os_linux.cc

Issue 10792019: Address some leftover review comments from previous CL. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | « vm/os.h ('k') | vm/os_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/os_linux.cc
===================================================================
--- vm/os_linux.cc (revision 9676)
+++ vm/os_linux.cc (working copy)
@@ -161,26 +161,25 @@
}
-bool OS::StringToInteger(const char* str, int64_t* value) {
+bool OS::StringToInt64(const char* str, int64_t* value) {
cshapiro 2012/07/17 18:02:23 Much better name, thank you!
siva 2012/07/17 20:59:49 Anything to keep you happy :-) On 2012/07/17 18:
ASSERT(str != NULL && strlen(str) > 0 && value != NULL);
- bool negative_value = false;
int32_t base = 10;
+ char* endptr;
+ int i = 0;
if (str[0] == '-') {
- negative_value = true;
- str += 1;
+ i = 1;
}
- if ((str[0] == '0') && (str[1] == 'x' || str[1] == 'X') && (str[2] != '\0')) {
+ if ((str[i] == '0') &&
+ (str[i + 1] == 'x' || str[i + 1] == 'X') &&
+ (str[i + 2] != '\0')) {
base = 16;
}
errno = 0;
- *value = strtoll(str, NULL, base);
- if (errno == 0) {
- if (negative_value) {
- *value = -(*value);
- }
- return true;
+ *value = strtoll(str, &endptr, base);
+ if (errno != 0 || endptr == str || *endptr != 0) {
cshapiro 2012/07/17 18:02:23 You could just return the result of the disjunctio
siva 2012/07/17 20:59:49 it would be return !(errno != 0 || endptr == str |
+ return false;
}
- return false;
+ return true;
}
« no previous file with comments | « vm/os.h ('k') | vm/os_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698