]> granicus.if.org Git - jq/commitdiff
Don't enable coloured output by default on Windows.
authorStephen Dolan <mu@netsoc.tcd.ie>
Thu, 20 Dec 2012 12:16:22 +0000 (12:16 +0000)
committerStephen Dolan <mu@netsoc.tcd.ie>
Thu, 20 Dec 2012 12:16:22 +0000 (12:16 +0000)
Makefile
main.c

index cbaf5040ca410e332d8e7692f555a4e0a254b71d..cd0fb32155f0c970a2eeed8ab18936aa7f4610fe 100644 (file)
--- 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 711d03ad8f2c4044b3ace8d2238f89b965618c1b..0ab0f3cac9dd81c87c0720deafef480dab6dbf10 100644 (file)
--- 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;