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

Side by Side Diff: runtime/vm/os_win.cc

Issue 10037018: Fix OS::VSNPrint to make it behave similar to linux and macos versions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « no previous file | no next file » | 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 <time.h> 7 #include <time.h>
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 int OS::SNPrint(char* str, size_t size, const char* format, ...) { 154 int OS::SNPrint(char* str, size_t size, const char* format, ...) {
155 va_list args; 155 va_list args;
156 va_start(args, format); 156 va_start(args, format);
157 int retval = VSNPrint(str, size, format, args); 157 int retval = VSNPrint(str, size, format, args);
158 va_end(args); 158 va_end(args);
159 return retval; 159 return retval;
160 } 160 }
161 161
162 162
163 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) { 163 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) {
164 if (str == NULL || size == 0) {
165 return _vscprintf(format, args);
166 }
164 int written =_vsnprintf(str, size, format, args); 167 int written =_vsnprintf(str, size, format, args);
168 if (written < 0) {
169 // _vsnprintf returns -1 if the number of characters to be written is
170 // larger than 'size', so we call _vscprintf which returns the number
171 // of characters that would have been written.
172 written = _vscprintf(format, args);
173 }
165 // Make sure to zero-terminate the string if the output was 174 // Make sure to zero-terminate the string if the output was
166 // truncated or if there was an error. 175 // truncated or if there was an error.
167 if (written < 0 || written >= size) { 176 if (written >= size) {
168 if (size > 0) { 177 if (size > 0) {
hausner 2012/04/10 20:40:04 The size > 0 check is no longer necessary since we
siva 2012/04/10 20:42:25 Done.
169 str[size - 1] = '\0'; 178 str[size - 1] = '\0';
170 } 179 }
171 } 180 }
172 return written; 181 return written;
173 } 182 }
174 183
175 184
176 void OS::PrintErr(const char* format, ...) { 185 void OS::PrintErr(const char* format, ...) {
177 va_list args; 186 va_list args;
178 va_start(args, format); 187 va_start(args, format);
(...skipping 21 matching lines...) Expand all
200 void OS::Abort() { 209 void OS::Abort() {
201 abort(); 210 abort();
202 } 211 }
203 212
204 213
205 void OS::Exit(int code) { 214 void OS::Exit(int code) {
206 exit(code); 215 exit(code);
207 } 216 }
208 217
209 } // namespace dart 218 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698