1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-18 10:04:04 +03:00

Merge pull request #9210 from poettering/use-delete-trailing-chars

make use of delete_trailing_chars() more
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-06-06 12:43:47 +02:00 committed by GitHub
commit 5c1701dd6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 19 deletions

View File

@ -258,15 +258,10 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char *
memcpy(ans, "[...]", max_length-1);
ans[max_length-1] = 0;
} else {
char *e;
t[max_length - 6] = 0;
/* Chop off final spaces */
e = strchr(t, 0);
while (e > t && isspace(e[-1]))
e--;
*e = 0;
delete_trailing_chars(t, WHITESPACE);
ans = strjoin("[", t, "...]");
}

View File

@ -269,23 +269,12 @@ char *strjoin_real(const char *x, ...) {
}
char *strstrip(char *s) {
char *e;
if (!s)
return NULL;
/* Drops trailing whitespace. Modifies the string in
* place. Returns pointer to first non-space character */
/* Drops trailing whitespace. Modifies the string in place. Returns pointer to first non-space character */
s += strspn(s, WHITESPACE);
for (e = strchr(s, 0); e > s; e --)
if (!strchr(WHITESPACE, e[-1]))
break;
*e = 0;
return s;
return delete_trailing_chars(skip_leading_chars(s, WHITESPACE), WHITESPACE);
}
char *delete_chars(char *s, const char *bad) {