[FFmpeg-cvslog] r22946 - trunk/libavutil/log.c
Måns Rullgård
mans
Fri Apr 23 14:14:59 CEST 2010
James Darnley <james.darnley at gmail.com> writes:
> 2010/4/23 M?ns Rullg?rd <mans at mansr.com>:
>> A newline before the first 0 and normal indentation on those lines
>> would be nice too.
>
> Better?
>
> Index: libavutil/log.c
> ===================================================================
> --- libavutil/log.c (revision 22952)
> +++ libavutil/log.c (working copy)
> @@ -24,6 +24,9 @@
> * logging functions
> */
>
> +#ifdef _WIN32
> +#include <windows.h>
> +#endif
> #include <unistd.h>
> #include "avutil.h"
> #include "log.h"
> @@ -33,12 +36,36 @@
> #endif
> int av_log_level = AV_LOG_INFO;
>
> -#if (!HAVE_ISATTY) || defined(WIN32)
> +#if (!HAVE_ISATTY) || defined(_WIN32)
Useless ().
> #define isatty(s) 0
> #endif
>
> #undef fprintf
> static void colored_fputs(int color, const char *str){
> +#ifdef _WIN32
> + HANDLE console;
> + CONSOLE_SCREEN_BUFFER_INFO console_info;
> + int16_t attributes, win_color_conv[] = {
That table should be static const.
> + 0,
> + FOREGROUND_RED,
> + FOREGROUND_GREEN,
> + FOREGROUND_RED |FOREGROUND_GREEN,
> + FOREGROUND_BLUE,
> + FOREGROUND_RED |FOREGROUND_BLUE,
> + FOREGROUND_GREEN|FOREGROUND_BLUE,
> + FOREGROUND_RED |FOREGROUND_GREEN|FOREGROUND_BLUE };
Please put the closing } on a new line.
> + if ((color&15)==9) {
> + fputs(str, stderr);
> + return;
> + }
What's that all about?
> + console = GetStdHandle(STD_ERROR_HANDLE);
> + GetConsoleScreenBufferInfo(console, &console_info);
> + attributes = (console_info.wAttributes&0xF0) | win_color_conv[color&15];
> + attributes |= (console_info.wAttributes&BACKGROUND_INTENSITY)?0:FOREGROUND_INTENSITY;
> + SetConsoleTextAttribute(console, attributes);
> + fputs(str, stderr);
> + SetConsoleTextAttribute(console, console_info.wAttributes);
This slab of code is ugly.
How does this behave in a cygwin xterm?
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-cvslog
mailing list