ps: don't use '+' truncation indicator with multi-byte
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>
This commit is contained in:
parent
d2aa8009b5
commit
9ea0021070
11
ps/output.c
11
ps/output.c
@ -1022,10 +1022,13 @@ static int do_pr_name(char *restrict const outbuf, const char *restrict const na
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user