aboutsummaryrefslogtreecommitdiffstats
path: root/tools/bootconfig/include/linux/string.h
blob: 8267af75153ac25c1fe6e3c011605d84777ef56b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _SKC_LINUX_STRING_H
#define _SKC_LINUX_STRING_H

#include <string.h>

/* Copied from lib/string.c */
static inline char *skip_spaces(const char *str)
{
	while (isspace(*str))
		++str;
	return (char *)str;
}

static inline char *strim(char *s)
{
	size_t size;
	char *end;

	size = strlen(s);
	if (!size)
		return s;

	end = s + size - 1;
	while (end >= s && isspace(*end))
		end--;
	*(end + 1) = '\0';

	return skip_spaces(s);
}

#endif