journalctl: add --truncate-newline option

This commit is contained in:
zhmylove
2022-08-30 18:50:19 +03:00
committed by Lennart Poettering
parent 9a109e7cd6
commit 61cecfa0d8
8 changed files with 57 additions and 14 deletions

View File

@@ -170,10 +170,15 @@ char *delete_trailing_chars(char *s, const char *bad) {
return s;
}
char *truncate_nl(char *s) {
char *truncate_nl_full(char *s, size_t *ret_len) {
size_t n;
assert(s);
s[strcspn(s, NEWLINE)] = 0;
n = strcspn(s, NEWLINE);
s[n] = '\0';
if (ret_len)
*ret_len = n;
return s;
}