mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
perf tools: Move ltrim() to util/string.c
As we have ltrim() implementation in builtin-script.c move it to the more generic location of util/string.c so that it can be used from other places. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Feng Tang <feng.tang@intel.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1358845787-1350-14-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
15268138e3
commit
08aa9cce6b
3 changed files with 19 additions and 12 deletions
|
@ -331,6 +331,24 @@ char *strxfrchar(char *s, char from, char to)
|
|||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* ltrim - Removes leading whitespace from @s.
|
||||
* @s: The string to be stripped.
|
||||
*
|
||||
* Return pointer to the first non-whitespace character in @s.
|
||||
*/
|
||||
char *ltrim(char *s)
|
||||
{
|
||||
int len = strlen(s);
|
||||
|
||||
while (len && isspace(*s)) {
|
||||
len--;
|
||||
s++;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* rtrim - Removes trailing whitespace from @s.
|
||||
* @s: The string to be stripped.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue