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

Ergin, Mesut A mesut.a.ergin at intel.com
Thu May 16 22:55:10 CEST 2019



> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Thursday, May 16, 2019 9:37 AM
> To: Ergin, Mesut A <mesut.a.ergin at intel.com>
> Cc: olivier.matz at 6wind.com; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] kvargs: trim spaces at the beginning and end of
> key and values
> 
> 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?

Had no particular reason not to use strspn. This was in use/tested in two apps shipping already, and I took the easy route. I could modify if you think it will be better.


More information about the dev mailing list