Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb1a28a0 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e078ba14
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -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;
}
+2 −0
Original line number Diff line number Diff line
@@ -264,4 +264,6 @@ bool is_power_of_2(unsigned long n)

size_t hex_width(u64 v);

char *rtrim(char *s);

#endif