[MPlayer-dev-eng] [PATCH] mp_msg - avoid having status line overwrite messages

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Jun 28 19:34:15 CEST 2010


On Mon, Jun 28, 2010 at 07:14:17PM +0200, Dan Oscarsson wrote:
> --- mp_msg.c.org	2010-06-12 17:33:15.855522967 +0200
> +++ mp_msg.c	2010-06-12 17:33:28.374523046 +0200
> @@ -188,6 +188,7 @@
>      char tmp[MSGSIZE_MAX];
>      FILE *stream = lev <= MSGL_WARN ? stderr : stdout;
>      static int header = 1;
> +    static int statusline = 0;
>  
>      if (!mp_msg_test(mod, lev)) return; // do not display
>      va_start(va, format);
> @@ -232,10 +233,14 @@
>      }
>  #endif
>  
> +    // if last output was status line, and not now,  move to new line first
> +    if (statusline && lev != MSGL_STATUS) fprintf(stream, "\n");
> +
>      if (header)
>          print_msg_module(stream, mod);
>      set_msg_color(stream, lev);
>      header = tmp[strlen(tmp)-1] == '\n' || tmp[strlen(tmp)-1] == '\r';
> +    statusline = tmp[strlen(tmp)-1] == '\r' && lev == MSGL_STATUS;

Why the check for '\r'? I'm quite unhappy about those strlen-usages, they
break quite badly if someone ever tries to print an empty string...



More information about the MPlayer-dev-eng mailing list