summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-01 22:11:09 +0100
committerwm4 <wm4@nowhere>2016-03-01 22:11:09 +0100
commita5eef06225f17890a0f49dc4c797ff0a3171cdd0 (patch)
treefebcc2d361781323455e44e880d3dbb84c0a2cf8 /common
parent4e53272376c546bac2e5c73f7ebfe456162d3663 (diff)
downloadmpv-a5eef06225f17890a0f49dc4c797ff0a3171cdd0.tar.bz2
mpv-a5eef06225f17890a0f49dc4c797ff0a3171cdd0.tar.xz
msg: minor simplification
Instead of playing ugly tricks with the buffer to append a \r or \n to the text buffer, extend print_terminal_line() to print a second string.
Diffstat (limited to 'common')
-rw-r--r--common/msg.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/common/msg.c b/common/msg.c
index 065ef46620..29dd5abbf5 100644
--- a/common/msg.c
+++ b/common/msg.c
@@ -236,7 +236,8 @@ static bool test_terminal_level(struct mp_log *log, int lev)
!(lev == MSGL_STATUS && terminal_in_background());
}
-static void print_terminal_line(struct mp_log *log, int lev, char *text)
+static void print_terminal_line(struct mp_log *log, int lev,
+ char *text, char *trail)
{
if (!test_terminal_level(log, lev))
return;
@@ -265,7 +266,7 @@ static void print_terminal_line(struct mp_log *log, int lev, char *text)
}
}
- fprintf(stream, "%s", text);
+ fprintf(stream, "%s%s", text, trail);
if (root->color)
set_term_color(stream, -1);
@@ -373,7 +374,7 @@ void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va)
char *next = &end[1];
char saved = next[0];
next[0] = '\0';
- print_terminal_line(log, lev, text);
+ print_terminal_line(log, lev, text, "");
write_log_file(log, lev, text);
write_msg_to_buffers(log, lev, text);
next[0] = saved;
@@ -381,14 +382,8 @@ void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va)
}
if (lev == MSGL_STATUS) {
- if (text[0]) {
- len = strlen(text);
- if (len < max_len - 1) {
- text[len] = root->termosd ? '\r' : '\n';
- text[len + 1] = '\0';
- }
- print_terminal_line(log, lev, text);
- }
+ if (text[0])
+ print_terminal_line(log, lev, text, root->termosd ? "\r" : "\n");
} else {
int leftover = strlen(text);
memmove(root->buffer, text, leftover + 1);