top: make 'utf8_justify' independent of non-utf8 logic
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>
This commit is contained in:
parent
ac76afee36
commit
0f5d503103
@ -706,11 +706,11 @@ static int utf8_embody (const char *str, int width) {
|
|||||||
static const char *utf8_justify (const char *str, int width, int justr) {
|
static const char *utf8_justify (const char *str, int width, int justr) {
|
||||||
static char l_fmt[] = "%-*.*s%s", r_fmt[] = "%*.*s%s";
|
static char l_fmt[] = "%-*.*s%s", r_fmt[] = "%*.*s%s";
|
||||||
static char buf[SCREENMAX];
|
static char buf[SCREENMAX];
|
||||||
const char *p;
|
char tmp[SCREENMAX];
|
||||||
|
|
||||||
p = fmtmk("%.*s", utf8_embody(str, width), str);
|
snprintf(tmp, sizeof(tmp), "%.*s", utf8_embody(str, width), str);
|
||||||
width += utf8_delta(p);
|
width += utf8_delta(tmp);
|
||||||
snprintf(buf, sizeof(buf), justr ? r_fmt : l_fmt, width, width, p, COLPADSTR);
|
snprintf(buf, sizeof(buf), justr ? r_fmt : l_fmt, width, width, tmp, COLPADSTR);
|
||||||
return buf;
|
return buf;
|
||||||
} // end: utf8_justify
|
} // end: utf8_justify
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user