]> granicus.if.org Git - procps-ng/commitdiff
top: make 'utf8_justify' independent of non-utf8 logic
authorJim Warner <james.warner@comcast.net>
Fri, 6 Oct 2017 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Sat, 14 Oct 2017 10:48:00 +0000 (21:48 +1100)
By eliminating the call to 'fmtmk', the 'utf8_justify'
function could more easily be used in libproc someday.

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index 1830803d589215f14d0f4ab98c3bee1b1e8d863b..178db183e5235929d7c3e96178cf6a19d37a1ecf 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -545,11 +545,11 @@ static int utf8_embody (const char *str, int width) {
 static const char *utf8_justify (const char *str, int width, int justr) {
    static char l_fmt[]  = "%-*.*s%s", r_fmt[] = "%*.*s%s";
    static char buf[SCREENMAX];
-   const char *p;
+   char tmp[SCREENMAX];
 
-   p = fmtmk("%.*s", utf8_embody(str, width), str);
-   width += utf8_delta(p);
-   snprintf(buf, sizeof(buf), justr ? r_fmt : l_fmt, width, width, p, COLPADSTR);
+   snprintf(tmp, sizeof(tmp), "%.*s", utf8_embody(str, width), str);
+   width += utf8_delta(tmp);
+   snprintf(buf, sizeof(buf), justr ? r_fmt : l_fmt, width, width, tmp, COLPADSTR);
    return buf;
 } // end: utf8_justify