Eric Sunshine <sunsh...@sunshineco.com> writes:

> On Mon, Jun 29, 2015 at 4:42 PM, Stefan Beller <sbel...@google.com> wrote:
>> On Sun, Jun 28, 2015 at 7:06 AM, Paul Tan <pyoka...@gmail.com> wrote:
>>> +/**
>>> + * Returns true if `str` consists of only whitespace, false otherwise.
>>> + */
>>> +static int str_isspace(const char *str)
>>> +{
>>> +       while (*str)
>>> +               if (!isspace(*(str)++))
>>> +                       return 0;
>> ...
>>     while (*str && !isspace(*(str)++))
>>         return 0;
> ...
> Ugh. Please don't break the logic with this strange and bogus transformation.
>
> If you really want it to read more idiomatically, try:
>
>     for (; *s; s++)
>         if (!isspace(*s))
>             return 0;

;-).

Regardless of the loop structure, I find

        *(str)++

especially ugly and confusing.  I'd understand if it were

        *(str++)

but the parentheses pair is unnecessary.

Not using any increment inside isspace(), like you showed, is the
most readable.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to