diff options
author | axtloss <axtlos@disroot.org> | 2024-10-17 23:48:47 +0200 |
---|---|---|
committer | axtloss <axtlos@disroot.org> | 2024-10-17 23:48:47 +0200 |
commit | 68bfb3b1322691d75a57432b9ebaa21d3b702a6b (patch) | |
tree | 13d68b9bc354feefc30871a35e3d0199c60228b0 /src/extstring.c | |
parent | 7f0fc08c05142f9f70cb05a4b1b1d6f0b1a3279b (diff) | |
download | extlib-main.tar.gz extlib-main.tar.bz2 |
Diffstat (limited to 'src/extstring.c')
-rw-r--r-- | src/extstring.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/extstring.c b/src/extstring.c index 685db4f..0a88a55 100644 --- a/src/extstring.c +++ b/src/extstring.c @@ -155,14 +155,11 @@ strfmt (char *s, struct style fmt) size_t sqnc_size = strlen ("\e[0m") + strlen (s)+1; char *escape_sqnc = strdup (""); if (fmt.color > 0) { - char *clrbase = malloc (strlen ("\e[38;5;m")+4); - sprintf (clrbase, "\e[%d;5;%dm", fmt.background ? 48 : 38, fmt.color); - char *tmp_sqnc = malloc (sqnc_size + strlen (clrbase)); - sqnc_size += strlen (clrbase); - sprintf (tmp_sqnc, "%s%s", escape_sqnc, clrbase); + char *tmp_sqnc = malloc (sqnc_size + strlen ("\e[38;5;m")+4); + sqnc_size += strlen ("\e[38;5;m")+4; + sprintf (tmp_sqnc, "%s\e[%d;5;%dm", escape_sqnc, fmt.background ? 48 : 38, fmt.color); free (escape_sqnc); escape_sqnc = tmp_sqnc; - free (clrbase); } if ((fmt.styles & BOLD)) |