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:
commit
5c1701dd6d
@ -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, "...]");
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user