Re: [PATCH v4 01/11] argv_array: offer to split a string by whitespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Johannes Schindelin <johannes.schindelin@xxxxxx> 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.






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux