[FFmpeg-devel] [PATCH] add colours to warnings and errors

Måns Rullgård mans
Mon Apr 26 04:02:32 CEST 2010


Michael Niedermayer <michaelni at gmx.at> writes:

> On Sun, Apr 25, 2010 at 10:40:19PM +0200, James Darnley wrote:
>> On 25 April 2010 20:29, Michael Niedermayer <michaelni at gmx.at> wrote:
>> >> ?log.c | ? 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
>> >> ?1 file changed, 71 insertions(+), 7 deletions(-)
>> >> bbd24cb9a7eb75393a8fb35fc3ca620a0edb0af7 ?colours.diff
>> >> Index: libavutil/log.c
>> >> ===================================================================
>> >> --- libavutil/log.c ? (revision 22960)
>> >> +++ libavutil/log.c ? (working copy)
>> >> @@ -24,6 +24,10 @@
>> >> ? * logging functions
>> >> ? */
>> >>
>> >> +#ifdef _WIN32
>> >> +#include <windows.h>
>> >> +#include <string.h>
>> >> +#endif
>> >> ?#include <unistd.h>
>> >> ?#include <stdlib.h>
>> >> ?#include "avutil.h"
>> >> @@ -34,24 +38,84 @@
>> >> ?#endif
>> >> ?int av_log_level = AV_LOG_INFO;
>> >>
>> >> +/* FIXME: On Windows isatty() returns true when ANSI color codes won't work.
>> >> +Some hack to detect output to other terminals would be good, fixing the other
>> >> +terminals would be better. One probable exception is when the user has
>> >> +ANSI.SYS loaded but the Windows API should then still work. */
>> >> +
>> >
>> >> +#if !HAVE_ISATTY
>> >> +#define isatty(2) 0
>> >> +#endif
>> >
>> > does HAVE_ISATTY && isatty(2) work? if so this is prefered over the ifdeffery
>> >
>> 
>> I've got no idea because I don't have a system without it.  But surely
>> if you don't have it trying to use isatty() will result in a compile
>> error.  I'm just moving your code about there (and adding a not).
>
> the compiler should optimize the call away, we use such code elsewhere.
> If you want to argue this violates ISO C then you have a point but
> its a point against using this anywhere not a point against this specific
> case.
> Thus as it stands please use it or start a thread asking us to remove it
> everywhere. The intermediate of using this trick at some places and not
> at others is surely a bad idea.

This only works if isatty() has a prototype in scope.  On a system
without this function, this will not be the case.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list