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:
Zbigniew Jędrzejewski-Szmek
2017-11-12 16:25:54 +01:00
committed by GitHub
11 changed files with 49 additions and 32 deletions
+8
View File
@@ -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);
}