Further corrections to the logging layer in runtime.

This commit is contained in:
Graydon Hoare
2011-01-14 16:01:43 -08:00
parent 5b9eda4a41
commit d55bee4417
4 changed files with 8 additions and 6 deletions

View File

@@ -114,7 +114,8 @@ append_string(char *buffer, const char *format, ...) {
if (buffer != NULL && format) {
va_list args;
va_start(args, format);
vsprintf(buffer + strlen(buffer), format, args);
size_t off = strlen(buffer);
vsnprintf(buffer + off, BUF_BYTES - off, format, args);
va_end(args);
}
return buffer;
@@ -127,7 +128,8 @@ append_string(char *buffer, rust_log::ansi_color color,
append_string(buffer, "\x1b%s", _foreground_colors[color]);
va_list args;
va_start(args, format);
vsprintf(buffer + strlen(buffer), format, args);
size_t off = strlen(buffer);
vsnprintf(buffer + off, BUF_BYTES - off, format, args);
va_end(args);
append_string(buffer, "\x1b[0m");
}
@@ -193,7 +195,7 @@ rust_log::trace_ln(rust_task *task, ansi_color color,
uint32_t type_bits, char *message) {
if (is_tracing(type_bits)) {
if (_use_colors) {
char buffer[512] = "";
char buffer[BUF_BYTES] = "";
append_string(buffer, color, "%s", message);
trace_ln(task, buffer);
} else {