Re: [PATCH] bootconfig: do not put quotes on cmdline items unless necessary

From: Rasmus Villemoes
Date: Thu Mar 07 2024 - 03:18:29 EST


On 07/03/2024 09.10, Rasmus Villemoes wrote:

>>> +static int has_space(const char *v)
>>> +{
>>> + for (; *v; v++)
>>> + if (isspace(*v))
>>> + return 1;
>>> + return 0;
>>> +}
>>
>> Do we already have something which does this?
>
> Well, 'value[strcspn(value, " \t\r\n")] ? "\"" : ""' would be a
> oneliner, but not particularly readable. Also that list of characters
> doesn't necessarily match isspace(), see below.

I didn't look close enough. We do have strpbrk(), so strpbrk(value, "
\t\r\n") ? .. : .. , but that still leaves the question of just what set
of characters to search for. But there's no harm in just making it "
\t\n\v\f\r\xa0" except it requires a comment saying "these are precisely
the isspace() characters in the kernel's ctype".

Rasmus