From 39e469443ee88264d31e931bbf76dccf40f82b01 Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Sat, 7 Oct 2023 19:52:15 +0200 Subject: [PATCH] clanup this one also --- src/cmds.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/cmds.c b/src/cmds.c index 44ccf76b6..47923b2ef 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -2605,30 +2605,21 @@ char *stripmasktype(int x) static char *stripmaskname(int x) { - static char s[161]; - int i = 0; + static char s[128]; + int i; - s[i] = 0; - if (x & STRIP_COLOR) - i += my_strcpy(s + i, "color, "); - if (x & STRIP_BOLD) - i += my_strcpy(s + i, "bold, "); - if (x & STRIP_REVERSE) - i += my_strcpy(s + i, "reverse, "); - if (x & STRIP_UNDERLINE) - i += my_strcpy(s + i, "underline, "); - if (x & STRIP_ANSI) - i += my_strcpy(s + i, "ansi, "); - if (x & STRIP_BELLS) - i += my_strcpy(s + i, "bells, "); - if (x & STRIP_ORDINARY) - i += my_strcpy(s + i, "ordinary, "); - if (x & STRIP_ITALICS) - i += my_strcpy(s + i, "italics, "); - if (!i) - strcpy(s, "none"); - else + if ((i = snprintf(s, sizeof s, "%s%s%s%s%s%s%s%s", + (x & STRIP_COLOR) ? "color, " : "", + (x & STRIP_BOLD) ? "bold, " : "", + (x & STRIP_REVERSE) ? "reverse, " : "", + (x & STRIP_UNDERLINE) ? "underline, " : "", + (x & STRIP_ANSI) ? "ansi, " : "", + (x & STRIP_BELLS) ? "bells, " : "", + (x & STRIP_ORDINARY) ? "ordinary, " : "", + (x & STRIP_ITALICS) ? "italics, " : ""))) s[i - 2] = 0; + else + strcpy(s, "none"); return s; }