OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 257 |
258 void StringBuilder::AddFormatted(const char* format, ...) { | 258 void StringBuilder::AddFormatted(const char* format, ...) { |
259 va_list arguments; | 259 va_list arguments; |
260 va_start(arguments, format); | 260 va_start(arguments, format); |
261 AddFormattedList(format, arguments); | 261 AddFormattedList(format, arguments); |
262 va_end(arguments); | 262 va_end(arguments); |
263 } | 263 } |
264 | 264 |
265 | 265 |
266 void StringBuilder::AddFormattedList(const char* format, va_list list) { | 266 void StringBuilder::AddFormattedList(const char* format, va_list list) { |
267 ASSERT(!is_finalized() && position_ < buffer_.length()); | 267 ASSERT(!is_finalized() && position_ <= buffer_.length()); |
268 int n = OS::VSNPrintF(buffer_ + position_, format, list); | 268 int n = OS::VSNPrintF(buffer_ + position_, format, list); |
269 if (n < 0 || n >= (buffer_.length() - position_)) { | 269 if (n < 0 || n >= (buffer_.length() - position_)) { |
270 position_ = buffer_.length(); | 270 position_ = buffer_.length(); |
271 } else { | 271 } else { |
272 position_ += n; | 272 position_ += n; |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 } } // namespace v8::internal | 276 } } // namespace v8::internal |
OLD | NEW |