Index: vm/os_linux.cc |
=================================================================== |
--- vm/os_linux.cc (revision 9558) |
+++ vm/os_linux.cc (working copy) |
@@ -161,6 +161,30 @@ |
} |
+bool OS::Strtoll(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 ((strlen(str) > 2) && (str[0] == '0') && |
sra1
2012/07/11 21:46:43
strlen scan not necessary since the conditions gua
siva
2012/07/12 18:28:23
Done.
|
+ (str[1] == 'x' || str[1] == 'X')) { |
+ base = 16; |
+ } |
+ errno = 0; |
+ *value = strtoll(str, NULL, base); |
sra1
2012/07/11 21:46:43
You should pass in &endptr and verify endptr != st
siva
2012/07/12 18:28:23
I am not sure I understand the value of this addit
sra1
2012/07/12 20:12:15
You don't get ERANGE or EINVAL for trailing junk.
siva
2012/07/16 19:45:47
Good point, I have addressed this in a different C
|
+ 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); |