[dpdk-dev] [PATCH] kvargs: trim spaces at the beginning and end of key and values

Stephen Hemminger stephen at networkplumber.org
Thu May 16 18:36:55 CEST 2019


On Wed, 15 May 2019 22:41:07 -0700
Mesut Ali Ergin <mesut.a.ergin at intel.com> wrote:

> +/* trim leading and trailing spaces */
> +static char *
> +trim_space(char *str)
> +{
> +	char *start, *end;
> +
> +	for (start = str; *start; start++) {
> +		if (!isspace((unsigned char) start[0]))
> +			break;
> +	}
> +
> +	for (end = start + strlen(start); end > start + 1; end--) {
> +		if (!isspace((unsigned char) end[-1]))
> +			break;
> +	}
> +

Why not use existing string functions like strspn?


More information about the dev mailing list