diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-08-15 16:51:45 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-08-15 16:52:34 -0400 |
commit | 9749af08293d16f3d5faedea371fdd3699f2adf2 (patch) | |
tree | 3ea0cfdad551b976aca81a5ea2344a116c8f778e /src/color.c | |
parent | 50dd5af226853d8d7201c7478d13f773cfd1479e (diff) | |
download | bfs-9749af08293d16f3d5faedea371fdd3699f2adf2.tar.xz |
expr: Tell expressions what kind of expression they are
Diffstat (limited to 'src/color.c')
-rw-r--r-- | src/color.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/color.c b/src/color.c index 052de69..db90f9c 100644 --- a/src/color.c +++ b/src/color.c @@ -1136,14 +1136,20 @@ static int print_expr(CFILE *cfile, const struct bfs_expr *expr, bool verbose, i return -1; } - if (bfs_expr_is_parent(expr)) { - if (cbuff(cfile, "${red}%pq${rs}", expr->argv[0]) < 0) { - return -1; - } - } else { - if (cbuff(cfile, "${blu}%pq${rs}", expr->argv[0]) < 0) { - return -1; - } + int ret; + switch (expr->kind) { + case BFS_FLAG: + ret = cbuff(cfile, "${cyn}%pq${rs}", expr->argv[0]); + break; + case BFS_OPERATOR: + ret = cbuff(cfile, "${red}%pq${rs}", expr->argv[0]); + break; + default: + ret = cbuff(cfile, "${blu}%pq${rs}", expr->argv[0]); + break; + } + if (ret < 0) { + return -1; } for (size_t i = 1; i < expr->argc; ++i) { |