Merge pull request #7301 from poettering/loginctl-ellipsize
Fix loginctl seat sysfs tree ellipsation logic. Simple reproducer: loginctl --full seat-status seat0|cat → after this PR, all lines are shown in full. Before, lines were ellipsized to terminal width.
This commit is contained in:
@@ -472,6 +472,10 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne
|
||||
|
||||
assert(s);
|
||||
assert(percent <= 100);
|
||||
|
||||
if (new_length == (size_t) -1)
|
||||
return strndup(s, old_length);
|
||||
|
||||
assert(new_length >= 3);
|
||||
|
||||
/* if no multibyte characters use ascii_ellipsize_mem for speed */
|
||||
@@ -539,6 +543,10 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne
|
||||
}
|
||||
|
||||
char *ellipsize(const char *s, size_t length, unsigned percent) {
|
||||
|
||||
if (length == (size_t) -1)
|
||||
return strdup(s);
|
||||
|
||||
return ellipsize_mem(s, strlen(s), length, percent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user