OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_UTILS_H_ | 5 #ifndef V8_UTILS_H_ |
6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 #define FPRINTF_METHOD_CHECKING | 1157 #define FPRINTF_METHOD_CHECKING |
1158 #endif | 1158 #endif |
1159 | 1159 |
1160 // Our version of printf(). | 1160 // Our version of printf(). |
1161 void PRINTF_CHECKING PrintF(const char* format, ...); | 1161 void PRINTF_CHECKING PrintF(const char* format, ...); |
1162 void FPRINTF_CHECKING PrintF(FILE* out, const char* format, ...); | 1162 void FPRINTF_CHECKING PrintF(FILE* out, const char* format, ...); |
1163 | 1163 |
1164 // Prepends the current process ID to the output. | 1164 // Prepends the current process ID to the output. |
1165 void PRINTF_CHECKING PrintPID(const char* format, ...); | 1165 void PRINTF_CHECKING PrintPID(const char* format, ...); |
1166 | 1166 |
| 1167 // Safe formatting print. Ensures that str is always null-terminated. |
| 1168 // Returns the number of chars written, or -1 if output was truncated. |
| 1169 int FPRINTF_CHECKING SNPrintF(Vector<char> str, const char* format, ...); |
| 1170 int VSNPrintF(Vector<char> str, const char* format, va_list args); |
| 1171 |
| 1172 void StrNCpy(Vector<char> dest, const char* src, size_t n); |
| 1173 |
1167 // Our version of fflush. | 1174 // Our version of fflush. |
1168 void Flush(FILE* out); | 1175 void Flush(FILE* out); |
1169 | 1176 |
1170 inline void Flush() { | 1177 inline void Flush() { |
1171 Flush(stdout); | 1178 Flush(stdout); |
1172 } | 1179 } |
1173 | 1180 |
1174 | 1181 |
1175 // Read a line of characters after printing the prompt to stdout. The resulting | 1182 // Read a line of characters after printing the prompt to stdout. The resulting |
1176 // char* needs to be disposed off with DeleteArray by the caller. | 1183 // char* needs to be disposed off with DeleteArray by the caller. |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 // Add formatted contents like printf based on a va_list. | 1575 // Add formatted contents like printf based on a va_list. |
1569 void AddFormattedList(const char* format, va_list list); | 1576 void AddFormattedList(const char* format, va_list list); |
1570 private: | 1577 private: |
1571 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); | 1578 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); |
1572 }; | 1579 }; |
1573 | 1580 |
1574 | 1581 |
1575 } } // namespace v8::internal | 1582 } } // namespace v8::internal |
1576 | 1583 |
1577 #endif // V8_UTILS_H_ | 1584 #endif // V8_UTILS_H_ |
OLD | NEW |