Index: vm/os_linux.cc |
=================================================================== |
--- vm/os_linux.cc (revision 9601) |
+++ vm/os_linux.cc (working copy) |
@@ -161,6 +161,29 @@ |
} |
+bool OS::StringToInteger(const char* str, int64_t* value) { |
+ ASSERT(str != NULL && strlen(str) > 0 && value != NULL); |
+ bool negative_value = false; |
+ int32_t base = 10; |
+ if (str[0] == '-') { |
+ negative_value = true; |
+ str += 1; |
+ } |
+ if ((str[0] == '0') && (str[1] == 'x' || str[1] == 'X') && (str[2] != '\0')) { |
+ base = 16; |
+ } |
+ errno = 0; |
+ *value = strtoll(str, NULL, base); |
sra1
2012/07/12 20:12:15
There is a bug here with the minimum value.
Since
siva
2012/07/16 19:45:47
Addressed this in a new CL.
On 2012/07/12 20:12:1
|
+ if (errno == 0) { |
+ if (negative_value) { |
+ *value = -(*value); |
+ } |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+ |
void OS::PrintErr(const char* format, ...) { |
va_list args; |
va_start(args, format); |