From: Stephen Dolan Date: Thu, 20 Dec 2012 12:16:22 +0000 (+0000) Subject: Don't enable coloured output by default on Windows. X-Git-Tag: jq-1.2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c85d8d8b4ef210c25f1c3492c7790e0ddbcb2c3b;p=jq Don't enable coloured output by default on Windows. --- diff --git a/Makefile b/Makefile index cbaf504..cd0fb32 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC=gcc -CFLAGS=-Wextra -Wall -Wno-missing-field-initializers -Wno-unused-parameter -std=gnu99 -ggdb -Wno-unused-function +CFLAGS=-Wextra -Wall -Wno-missing-field-initializers -Wno-unused-parameter -std=gnu99 -ggdb -Wno-unused-function $(EXTRA_CFLAGS) prefix=/usr/local mandir=$(prefix)/share/man @@ -50,8 +50,8 @@ build/osx64%: CC='i686-apple-darwin10-gcc -m64' # On Debian, you can get windows compilers in the # gcc-mingw-w64-i686 and gcc-mingw-w64-x86-64 packages. -build/win32%: CC='i686-w64-mingw32-gcc -m32' -build/win64%: CC='x86_64-w64-mingw32-gcc -m64' +build/win32%: CC='i686-w64-mingw32-gcc -m32' EXTRA_CFLAGS=-DJQ_DEFAULT_ENABLE_COLOR=0 +build/win64%: CC='x86_64-w64-mingw32-gcc -m64' EXTRA_CFLAGS=-DJQ_DEFAULT_ENABLE_COLOR=0 ALL_BINARIES=$(foreach platform, $(PLATFORMS), $(foreach binary, $(BINARIES), build/$(platform)/$(binary))) diff --git a/main.c b/main.c index 711d03a..0ab0f3c 100644 --- a/main.c +++ b/main.c @@ -69,7 +69,12 @@ static void process(jv value) { if ((options & RAW_OUTPUT) && jv_get_kind(result) == JV_KIND_STRING) { fwrite(jv_string_value(result), 1, jv_string_length(jv_copy(result)), stdout); } else { - int dumpopts = isatty(fileno(stdout)) ? JV_PRINT_COLOUR : 0; + int dumpopts; +#ifdef JQ_DEFAULT_ENABLE_COLOR + dumpopts = JQ_DEFAULT_ENABLE_COLOR ? JV_PRINT_COLOUR : 0; +#else + dumpopts = isatty(fileno(stdout)) ? JV_PRINT_COLOUR : 0; +#endif if (!(options & COMPACT_OUTPUT)) dumpopts |= JV_PRINT_PRETTY; if (options & ASCII_OUTPUT) dumpopts |= JV_PRINT_ASCII; if (options & COLOUR_OUTPUT) dumpopts |= JV_PRINT_COLOUR;