Re: [PATCH v4 01/11] argv_array: offer to split a string by whitespace
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 24, 2018, 02:38 UTC
- Message-ID
- <xmqqefj572gt.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <xmqq8t9d8kvm.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
>
>> +void argv_array_split(struct argv_array *array, const char *to_split)
>> +{
>> + while (isspace(*to_split))
>> + to_split++;
>> + for (;;) {
>> + const char *p = to_split;
>> +
>> + if (!*p)
>> + break;
>> +
>> + while (*p && !isspace(*p))
>> + p++;
>> + argv_array_push_nodup(array, xstrndup(to_split, p - to_split));
>
> Can *p be '\0' at this point?My thinko. We do want to stop on NUL even though our isspace() says NUL is not a space. And using while (isspace(*p)) below without checking for NUL also makes sense.
Sorry for the noise.