Skip to content

Commit 2d05b54

Browse files
committed
Standardize on "color" to match what the flag has always been called
1 parent 44a5c4b commit 2d05b54

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

docs/content/3.manual/v1.3/manual.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ sections:
107107
will result in more compact output by instead putting each
108108
JSON object on a single line.
109109
110-
* `--colour-output` / `-C` and `--monochrome-output` / `-M`:
110+
* `--color-output` / `-C` and `--monochrome-output` / `-M`:
111111
112112
By default, jq outputs colored JSON if writing to a
113113
terminal. You can force it to produce color even if writing to

docs/content/3.manual/v1.4/manual.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ sections:
128128
will result in more compact output by instead putting each
129129
JSON object on a single line.
130130
131-
* `--colour-output` / `-C` and `--monochrome-output` / `-M`:
131+
* `--color-output` / `-C` and `--monochrome-output` / `-M`:
132132
133133
By default, jq outputs colored JSON if writing to a
134134
terminal. You can force it to produce color even if writing to

jq_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata) {
157157
printf(" for test at line number %u: %s\n", lineno, prog);
158158
pass = 0;
159159
}
160-
jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOUR|JV_PRINT_REFCOUNT));
160+
jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR|JV_PRINT_REFCOUNT));
161161
jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string)));
162162
assert(jv_equal(jv_copy(expected), jv_copy(reparsed)));
163163
jv_free(as_string);

jv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int jv_get_refcnt(jv);
163163
enum jv_print_flags {
164164
JV_PRINT_PRETTY = 1,
165165
JV_PRINT_ASCII = 2,
166-
JV_PRINT_COLOUR = 4,
166+
JV_PRINT_COLOR = 4,
167167
JV_PRINT_SORTED = 8,
168168
JV_PRINT_INVALID = 16,
169169
JV_PRINT_REFCOUNT = 32,

jv_print.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
#define COL(c) (ESC "[" c "m")
1818
#define COLRESET (ESC "[0m")
1919

20-
// Colour table. See https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
20+
// Color table. See https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
2121
// for how to choose these.
22-
static const jv_kind colour_kinds[] =
22+
static const jv_kind color_kinds[] =
2323
{JV_KIND_NULL, JV_KIND_FALSE, JV_KIND_TRUE, JV_KIND_NUMBER,
2424
JV_KIND_STRING, JV_KIND_ARRAY, JV_KIND_OBJECT};
25-
static const char* const colours[] =
25+
static const char* const colors[] =
2626
{COL("1;30"), COL("0;39"), COL("0;39"), COL("0;39"),
2727
COL("0;32"), COL("1;39"), COL("1;39")};
28-
#define FIELD_COLOUR COL("34;1")
28+
#define FIELD_COLOR COL("34;1")
2929

3030
static void put_buf(const char *s, int len, FILE *fout, jv *strout, int is_tty) {
3131
if (strout) {
@@ -139,13 +139,13 @@ static void put_refcnt(struct dtoa_context* C, int refcnt, FILE *F, jv* S, int T
139139

140140
static void jv_dump_term(struct dtoa_context* C, jv x, int flags, int indent, FILE* F, jv* S) {
141141
char buf[JVP_DTOA_FMT_MAX_LEN];
142-
const char* colour = 0;
142+
const char* color = 0;
143143
double refcnt = (flags & JV_PRINT_REFCOUNT) ? jv_get_refcnt(x) - 1 : -1;
144-
if (flags & JV_PRINT_COLOUR) {
145-
for (unsigned i=0; i<sizeof(colour_kinds)/sizeof(colour_kinds[0]); i++) {
146-
if (jv_get_kind(x) == colour_kinds[i]) {
147-
colour = colours[i];
148-
put_str(colour, F, S, flags & JV_PRINT_ISATTY);
144+
if (flags & JV_PRINT_COLOR) {
145+
for (unsigned i=0; i<sizeof(color_kinds)/sizeof(color_kinds[0]); i++) {
146+
if (jv_get_kind(x) == color_kinds[i]) {
147+
color = colors[i];
148+
put_str(color, F, S, flags & JV_PRINT_ISATTY);
149149
break;
150150
}
151151
}
@@ -213,13 +213,13 @@ static void jv_dump_term(struct dtoa_context* C, jv x, int flags, int indent, FI
213213
}
214214
}
215215
jv_dump_term(C, elem, flags, indent + 1, F, S);
216-
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
216+
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
217217
}
218218
if (flags & JV_PRINT_PRETTY) {
219219
put_char('\n', F, S, flags & JV_PRINT_ISATTY);
220220
put_indent(indent, flags, F, S, flags & JV_PRINT_ISATTY);
221221
}
222-
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
222+
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
223223
put_char(']', F, S, flags & JV_PRINT_ISATTY);
224224
if (flags & JV_PRINT_REFCOUNT)
225225
put_refcnt(C, refcnt, F, S, flags & JV_PRINT_ISATTY);
@@ -272,33 +272,33 @@ static void jv_dump_term(struct dtoa_context* C, jv x, int flags, int indent, FI
272272
put_str(",", F, S, flags & JV_PRINT_ISATTY);
273273
}
274274
}
275-
if (colour) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
275+
if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
276276

277277
first = 0;
278-
if (colour) put_str(FIELD_COLOUR, F, S, flags & JV_PRINT_ISATTY);
278+
if (color) put_str(FIELD_COLOR, F, S, flags & JV_PRINT_ISATTY);
279279
jvp_dump_string(key, flags & JV_PRINT_ASCII, F, S, flags & JV_PRINT_ISATTY);
280280
jv_free(key);
281-
if (colour) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
281+
if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
282282

283-
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
283+
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
284284
put_str((flags & JV_PRINT_PRETTY) ? ": " : ":", F, S, flags & JV_PRINT_ISATTY);
285-
if (colour) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
285+
if (color) put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
286286

287287
jv_dump_term(C, value, flags, indent + 1, F, S);
288-
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
288+
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
289289
}
290290
if (flags & JV_PRINT_PRETTY) {
291291
put_char('\n', F, S, flags & JV_PRINT_ISATTY);
292292
put_indent(indent, flags, F, S, flags & JV_PRINT_ISATTY);
293293
}
294-
if (colour) put_str(colour, F, S, flags & JV_PRINT_ISATTY);
294+
if (color) put_str(color, F, S, flags & JV_PRINT_ISATTY);
295295
put_char('}', F, S, flags & JV_PRINT_ISATTY);
296296
if (flags & JV_PRINT_REFCOUNT)
297297
put_refcnt(C, refcnt, F, S, flags & JV_PRINT_ISATTY);
298298
}
299299
}
300300
jv_free(x);
301-
if (colour) {
301+
if (color) {
302302
put_str(COLRESET, F, S, flags & JV_PRINT_ISATTY);
303303
}
304304
}
@@ -317,7 +317,7 @@ void jv_dump(jv x, int flags) {
317317
/* This one is nice for use in debuggers */
318318
void jv_show(jv x, int flags) {
319319
if (flags == -1)
320-
flags = JV_PRINT_PRETTY | JV_PRINT_COLOUR | JV_PRINT_INDENT_FLAGS(2);
320+
flags = JV_PRINT_PRETTY | JV_PRINT_COLOR | JV_PRINT_INDENT_FLAGS(2);
321321
jv_dumpf(jv_copy(x), stderr, flags | JV_PRINT_INVALID);
322322
fflush(stderr);
323323
}

main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ enum {
104104
PROVIDE_NULL = 4,
105105
RAW_OUTPUT = 8,
106106
ASCII_OUTPUT = 32,
107-
COLOUR_OUTPUT = 64,
108-
NO_COLOUR_OUTPUT = 128,
107+
COLOR_OUTPUT = 64,
108+
NO_COLOR_OUTPUT = 128,
109109
SORTED_OUTPUT = 256,
110110
FROM_FILE = 512,
111111
RAW_NO_LF = 1024,
@@ -256,11 +256,11 @@ int main(int argc, char* argv[]) {
256256
if (!short_opts) continue;
257257
}
258258
if (isoption(argv[i], 'C', "color-output", &short_opts)) {
259-
options |= COLOUR_OUTPUT;
259+
options |= COLOR_OUTPUT;
260260
if (!short_opts) continue;
261261
}
262262
if (isoption(argv[i], 'M', "monochrome-output", &short_opts)) {
263-
options |= NO_COLOUR_OUTPUT;
263+
options |= NO_COLOR_OUTPUT;
264264
if (!short_opts) continue;
265265
}
266266
if (isoption(argv[i], 'a', "ascii-output", &short_opts)) {
@@ -426,15 +426,15 @@ int main(int argc, char* argv[]) {
426426
if (isatty(fileno(stdout))) {
427427
dumpopts |= JV_PRINT_ISATTY;
428428
#ifndef WIN32
429-
/* Disable colour by default on Windows builds as Windows
429+
/* Disable color by default on Windows builds as Windows
430430
terminals tend not to display it correctly */
431-
dumpopts |= JV_PRINT_COLOUR;
431+
dumpopts |= JV_PRINT_COLOR;
432432
#endif
433433
}
434434
if (options & SORTED_OUTPUT) dumpopts |= JV_PRINT_SORTED;
435435
if (options & ASCII_OUTPUT) dumpopts |= JV_PRINT_ASCII;
436-
if (options & COLOUR_OUTPUT) dumpopts |= JV_PRINT_COLOUR;
437-
if (options & NO_COLOUR_OUTPUT) dumpopts &= ~JV_PRINT_COLOUR;
436+
if (options & COLOR_OUTPUT) dumpopts |= JV_PRINT_COLOR;
437+
if (options & NO_COLOR_OUTPUT) dumpopts &= ~JV_PRINT_COLOR;
438438

439439
if (jv_get_kind(lib_search_paths) == JV_KIND_NULL) {
440440
// Default search path list

0 commit comments

Comments
 (0)