From 2d05b5475c98ab46494f193f234e97a7803ddace Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 16 Aug 2015 19:19:01 -0700 Subject: [PATCH] Standardize on "color" to match what the flag has always been called --- docs/content/3.manual/v1.3/manual.yml | 2 +- docs/content/3.manual/v1.4/manual.yml | 2 +- jq_test.c | 2 +- jv.h | 2 +- jv_print.c | 42 +++++++++++++-------------- main.c | 16 +++++----- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/content/3.manual/v1.3/manual.yml b/docs/content/3.manual/v1.3/manual.yml index 856d2150e2..aaedf37704 100644 --- a/docs/content/3.manual/v1.3/manual.yml +++ b/docs/content/3.manual/v1.3/manual.yml @@ -107,7 +107,7 @@ sections: will result in more compact output by instead putting each JSON object on a single line. - * `--colour-output` / `-C` and `--monochrome-output` / `-M`: + * `--color-output` / `-C` and `--monochrome-output` / `-M`: By default, jq outputs colored JSON if writing to a terminal. You can force it to produce color even if writing to diff --git a/docs/content/3.manual/v1.4/manual.yml b/docs/content/3.manual/v1.4/manual.yml index 8e4cc3c114..841764acc6 100644 --- a/docs/content/3.manual/v1.4/manual.yml +++ b/docs/content/3.manual/v1.4/manual.yml @@ -128,7 +128,7 @@ sections: will result in more compact output by instead putting each JSON object on a single line. - * `--colour-output` / `-C` and `--monochrome-output` / `-M`: + * `--color-output` / `-C` and `--monochrome-output` / `-M`: By default, jq outputs colored JSON if writing to a terminal. You can force it to produce color even if writing to diff --git a/jq_test.c b/jq_test.c index 2be745e3ef..7a396b9435 100644 --- a/jq_test.c +++ b/jq_test.c @@ -157,7 +157,7 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata) { printf(" for test at line number %u: %s\n", lineno, prog); pass = 0; } - jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOUR|JV_PRINT_REFCOUNT)); + jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR|JV_PRINT_REFCOUNT)); jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string))); assert(jv_equal(jv_copy(expected), jv_copy(reparsed))); jv_free(as_string); diff --git a/jv.h b/jv.h index 8aff7e34da..fd024f8024 100644 --- a/jv.h +++ b/jv.h @@ -163,7 +163,7 @@ int jv_get_refcnt(jv); enum jv_print_flags { JV_PRINT_PRETTY = 1, JV_PRINT_ASCII = 2, - JV_PRINT_COLOUR = 4, + JV_PRINT_COLOR = 4, JV_PRINT_SORTED = 8, JV_PRINT_INVALID = 16, JV_PRINT_REFCOUNT = 32, diff --git a/jv_print.c b/jv_print.c index 567c737a8c..c5a9e120ae 100644 --- a/jv_print.c +++ b/jv_print.c @@ -17,15 +17,15 @@ #define COL(c) (ESC "[" c "m") #define COLRESET (ESC "[0m") -// Colour table. See https://en.wikipedia.org/wiki/ANSI_escape_code#Colors +// Color table. See https://en.wikipedia.org/wiki/ANSI_escape_code#Colors // for how to choose these. -static const jv_kind colour_kinds[] = +static const jv_kind color_kinds[] = {JV_KIND_NULL, JV_KIND_FALSE, JV_KIND_TRUE, JV_KIND_NUMBER, JV_KIND_STRING, JV_KIND_ARRAY, JV_KIND_OBJECT}; -static const char* const colours[] = +static const char* const colors[] = {COL("1;30"), COL("0;39"), COL("0;39"), COL("0;39"), COL("0;32"), COL("1;39"), COL("1;39")}; -#define FIELD_COLOUR COL("34;1") +#define FIELD_COLOR COL("34;1") static void put_buf(const char *s, int len, FILE *fout, jv *strout, int is_tty) { if (strout) { @@ -139,13 +139,13 @@ static void put_refcnt(struct dtoa_context* C, int refcnt, FILE *F, jv* S, int T static void jv_dump_term(struct dtoa_context* C, jv x, int flags, int indent, FILE* F, jv* S) { char buf[JVP_DTOA_FMT_MAX_LEN]; - const char* colour = 0; + const char* color = 0; double refcnt = (flags & JV_PRINT_REFCOUNT) ? jv_get_refcnt(x) - 1 : -1; - if (flags & JV_PRINT_COLOUR) { - for (unsigned i=0; i