The ps program generally supports multi-byte sequences
in strings representing user and group names. However,
should a multi-byte sequence span the maximum width of
a column, the '+' inserted by ps to signify truncation
will corrupt that sequence, misaligning the text line.
Unfortunately, there's insufficient info returned from
the escape_str function (who calls escape_str_utf8) to
provide a robust response. So, this commit will revert
to the old standby of displaying a number when the '+'
character would've corrupted that multi-byte sequence.
Signed-off-by: Jim Warner <james.warner@comcast.net>
if(len <= (int)max_rightward)
return len; /* returns number of cells */
- len = max_rightward-1;
- outbuf[len++] = '+';
- outbuf[len] = 0;
- return len;
+ // only use '+' when not on a multi-byte char, else show uid
+ if ((unsigned)outbuf[max_rightward-1] < 127) {
+ len = max_rightward-1;
+ outbuf[len++] = '+';
+ outbuf[len] = 0;
+ return len;
+ }
}
return snprintf(outbuf, COLWID, "%u", u);
}