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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/os.h ('k') | vm/os_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/os.h" 5 #include "vm/os.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <limits.h> 8 #include <limits.h>
9 #include <time.h> 9 #include <time.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) { 155 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) {
156 int retval = vsnprintf(str, size, format, args); 156 int retval = vsnprintf(str, size, format, args);
157 if (retval < 0) { 157 if (retval < 0) {
158 FATAL1("Fatal error in OS::VSNPrint with format '%s'", format); 158 FATAL1("Fatal error in OS::VSNPrint with format '%s'", format);
159 } 159 }
160 return retval; 160 return retval;
161 } 161 }
162 162
163 163
164 bool OS::StringToInteger(const char* str, int64_t* value) { 164 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:
165 ASSERT(str != NULL && strlen(str) > 0 && value != NULL); 165 ASSERT(str != NULL && strlen(str) > 0 && value != NULL);
166 bool negative_value = false;
167 int32_t base = 10; 166 int32_t base = 10;
167 char* endptr;
168 int i = 0;
168 if (str[0] == '-') { 169 if (str[0] == '-') {
169 negative_value = true; 170 i = 1;
170 str += 1;
171 } 171 }
172 if ((str[0] == '0') && (str[1] == 'x' || str[1] == 'X') && (str[2] != '\0')) { 172 if ((str[i] == '0') &&
173 (str[i + 1] == 'x' || str[i + 1] == 'X') &&
174 (str[i + 2] != '\0')) {
173 base = 16; 175 base = 16;
174 } 176 }
175 errno = 0; 177 errno = 0;
176 *value = strtoll(str, NULL, base); 178 *value = strtoll(str, &endptr, base);
177 if (errno == 0) { 179 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 |
178 if (negative_value) { 180 return false;
179 *value = -(*value);
180 }
181 return true;
182 } 181 }
183 return false; 182 return true;
184 } 183 }
185 184
186 185
187 void OS::PrintErr(const char* format, ...) { 186 void OS::PrintErr(const char* format, ...) {
188 va_list args; 187 va_list args;
189 va_start(args, format); 188 va_start(args, format);
190 VFPrint(stderr, format, args); 189 VFPrint(stderr, format, args);
191 va_end(args); 190 va_end(args);
192 } 191 }
193 192
(...skipping 15 matching lines...) Expand all
209 void OS::Abort() { 208 void OS::Abort() {
210 abort(); 209 abort();
211 } 210 }
212 211
213 212
214 void OS::Exit(int code) { 213 void OS::Exit(int code) {
215 exit(code); 214 exit(code);
216 } 215 }
217 216
218 } // namespace dart 217 } // namespace dart
OLDNEW
« 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