mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-12 19:16:40 +07:00
perf lib: Introduce rtrim
Remove the trailing whitespaces. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-8bxozh5lyixgjmziqaxo9675@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
e078ba14df
commit
cb1a28a0cb
@ -313,3 +313,25 @@ int strtailcmp(const char *s1, const char *s2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* rtrim - Removes trailing whitespace from @s.
|
||||
* @s: The string to be stripped.
|
||||
*
|
||||
* Note that the first trailing whitespace is replaced with a %NUL-terminator
|
||||
* in the given string @s. Returns @s.
|
||||
*/
|
||||
char *rtrim(char *s)
|
||||
{
|
||||
size_t size = strlen(s);
|
||||
char *end;
|
||||
|
||||
if (!size)
|
||||
return s;
|
||||
|
||||
end = s + size - 1;
|
||||
while (end >= s && isspace(*end))
|
||||
end--;
|
||||
*(end + 1) = '\0';
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -264,4 +264,6 @@ bool is_power_of_2(unsigned long n)
|
||||
|
||||
size_t hex_width(u64 v);
|
||||
|
||||
char *rtrim(char *s);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user