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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 } | 1605 } |
1599 | 1606 |
1600 *index = result; | 1607 *index = result; |
1601 return true; | 1608 return true; |
1602 } | 1609 } |
1603 | 1610 |
1604 | 1611 |
1605 } } // namespace v8::internal | 1612 } } // namespace v8::internal |
1606 | 1613 |
1607 #endif // V8_UTILS_H_ | 1614 #endif // V8_UTILS_H_ |
OLD | NEW |