17
17
#define COL (c ) (ESC "[" c "m")
18
18
#define COLRESET (ESC "[0m")
19
19
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
21
21
// for how to choose these.
22
- static const jv_kind colour_kinds [] =
22
+ static const jv_kind color_kinds [] =
23
23
{JV_KIND_NULL , JV_KIND_FALSE , JV_KIND_TRUE , JV_KIND_NUMBER ,
24
24
JV_KIND_STRING , JV_KIND_ARRAY , JV_KIND_OBJECT };
25
- static const char * const colours [] =
25
+ static const char * const colors [] =
26
26
{COL ("1;30" ), COL ("0;39" ), COL ("0;39" ), COL ("0;39" ),
27
27
COL ("0;32" ), COL ("1;39" ), COL ("1;39" )};
28
- #define FIELD_COLOUR COL("34;1")
28
+ #define FIELD_COLOR COL("34;1")
29
29
30
30
static void put_buf (const char * s , int len , FILE * fout , jv * strout , int is_tty ) {
31
31
if (strout ) {
@@ -139,13 +139,13 @@ static void put_refcnt(struct dtoa_context* C, int refcnt, FILE *F, jv* S, int T
139
139
140
140
static void jv_dump_term (struct dtoa_context * C , jv x , int flags , int indent , FILE * F , jv * S ) {
141
141
char buf [JVP_DTOA_FMT_MAX_LEN ];
142
- const char * colour = 0 ;
142
+ const char * color = 0 ;
143
143
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 );
149
149
break ;
150
150
}
151
151
}
@@ -213,13 +213,13 @@ static void jv_dump_term(struct dtoa_context* C, jv x, int flags, int indent, FI
213
213
}
214
214
}
215
215
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 );
217
217
}
218
218
if (flags & JV_PRINT_PRETTY ) {
219
219
put_char ('\n' , F , S , flags & JV_PRINT_ISATTY );
220
220
put_indent (indent , flags , F , S , flags & JV_PRINT_ISATTY );
221
221
}
222
- if (colour ) put_str (colour , F , S , flags & JV_PRINT_ISATTY );
222
+ if (color ) put_str (color , F , S , flags & JV_PRINT_ISATTY );
223
223
put_char (']' , F , S , flags & JV_PRINT_ISATTY );
224
224
if (flags & JV_PRINT_REFCOUNT )
225
225
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
272
272
put_str ("," , F , S , flags & JV_PRINT_ISATTY );
273
273
}
274
274
}
275
- if (colour ) put_str (COLRESET , F , S , flags & JV_PRINT_ISATTY );
275
+ if (color ) put_str (COLRESET , F , S , flags & JV_PRINT_ISATTY );
276
276
277
277
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 );
279
279
jvp_dump_string (key , flags & JV_PRINT_ASCII , F , S , flags & JV_PRINT_ISATTY );
280
280
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 );
282
282
283
- if (colour ) put_str (colour , F , S , flags & JV_PRINT_ISATTY );
283
+ if (color ) put_str (color , F , S , flags & JV_PRINT_ISATTY );
284
284
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 );
286
286
287
287
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 );
289
289
}
290
290
if (flags & JV_PRINT_PRETTY ) {
291
291
put_char ('\n' , F , S , flags & JV_PRINT_ISATTY );
292
292
put_indent (indent , flags , F , S , flags & JV_PRINT_ISATTY );
293
293
}
294
- if (colour ) put_str (colour , F , S , flags & JV_PRINT_ISATTY );
294
+ if (color ) put_str (color , F , S , flags & JV_PRINT_ISATTY );
295
295
put_char ('}' , F , S , flags & JV_PRINT_ISATTY );
296
296
if (flags & JV_PRINT_REFCOUNT )
297
297
put_refcnt (C , refcnt , F , S , flags & JV_PRINT_ISATTY );
298
298
}
299
299
}
300
300
jv_free (x );
301
- if (colour ) {
301
+ if (color ) {
302
302
put_str (COLRESET , F , S , flags & JV_PRINT_ISATTY );
303
303
}
304
304
}
@@ -317,7 +317,7 @@ void jv_dump(jv x, int flags) {
317
317
/* This one is nice for use in debuggers */
318
318
void jv_show (jv x , int flags ) {
319
319
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 );
321
321
jv_dumpf (jv_copy (x ), stderr , flags | JV_PRINT_INVALID );
322
322
fflush (stderr );
323
323
}
0 commit comments