Commit 08aa9cce authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

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: default avatarNamhyung 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 15268138
...@@ -909,18 +909,6 @@ static const char *ends_with(const char *str, const char *suffix) ...@@ -909,18 +909,6 @@ static const char *ends_with(const char *str, const char *suffix)
return NULL; return NULL;
} }
static char *ltrim(char *str)
{
int len = strlen(str);
while (len && isspace(*str)) {
len--;
str++;
}
return str;
}
static int read_script_info(struct script_desc *desc, const char *filename) static int read_script_info(struct script_desc *desc, const char *filename)
{ {
char line[BUFSIZ], *p; char line[BUFSIZ], *p;
......
...@@ -331,6 +331,24 @@ char *strxfrchar(char *s, char from, char to) ...@@ -331,6 +331,24 @@ char *strxfrchar(char *s, char from, char to)
return s; 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. * rtrim - Removes trailing whitespace from @s.
* @s: The string to be stripped. * @s: The string to be stripped.
......
...@@ -265,6 +265,7 @@ bool is_power_of_2(unsigned long n) ...@@ -265,6 +265,7 @@ bool is_power_of_2(unsigned long n)
size_t hex_width(u64 v); size_t hex_width(u64 v);
int hex2u64(const char *ptr, u64 *val); int hex2u64(const char *ptr, u64 *val);
char *ltrim(char *s);
char *rtrim(char *s); char *rtrim(char *s);
void dump_stack(void); void dump_stack(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment