From 50a431e11af116da27f42e4fab1e748189203709 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 6 Jan 2023 11:21:14 +0100 Subject: [PATCH 1/2] ice: add ANSI output with Green and Red colors --- src/ice/candpair.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ice/candpair.c b/src/ice/candpair.c index d095ca71a..33e67a4d2 100644 --- a/src/ice/candpair.c +++ b/src/ice/candpair.c @@ -428,6 +428,7 @@ int icem_candpair_debug(struct re_printf *pf, const struct ice_candpair *cp) int icem_candpairs_debug(struct re_printf *pf, const struct list *list) { struct le *le; + bool ansi_output = true; int err; if (!list) @@ -439,10 +440,25 @@ int icem_candpairs_debug(struct re_printf *pf, const struct list *list) const struct ice_candpair *cp = le->data; bool is_selected = (cp == cp->comp->cp_sel); + bool ansi = false; + + if (ansi_output) { + if (cp->state == ICE_CANDPAIR_SUCCEEDED) { + err |= re_hprintf(pf, "\x1b[32m"); + ansi = true; + } + else if (cp->err || cp->scode) { + err |= re_hprintf(pf, "\x1b[31m"); + ansi = true; + } + } err = re_hprintf(pf, " %c %H\n", is_selected ? '*' : ' ', icem_candpair_debug, cp); + + if (ansi) + err |= re_hprintf(pf, "\x1b[;m"); } return err; From 3851834d4dd49a9d3e1baeb2b765efa935b33a9f Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 6 Jan 2023 11:27:41 +0100 Subject: [PATCH 2/2] ice: fix clang analyze --- src/ice/candpair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ice/candpair.c b/src/ice/candpair.c index 33e67a4d2..37b0f5762 100644 --- a/src/ice/candpair.c +++ b/src/ice/candpair.c @@ -453,9 +453,9 @@ int icem_candpairs_debug(struct re_printf *pf, const struct list *list) } } - err = re_hprintf(pf, " %c %H\n", - is_selected ? '*' : ' ', - icem_candpair_debug, cp); + err |= re_hprintf(pf, " %c %H\n", + is_selected ? '*' : ' ', + icem_candpair_debug, cp); if (ansi) err |= re_hprintf(pf, "\x1b[;m");