This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix undefined behaviour inconsistent for strtok
On 25/10/2016 11:19, Andreas Schwab wrote:
> On Okt 25 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
>
>> On 25/10/2016 10:57, Andreas Schwab wrote:
>>> On Okt 25 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
>>>
>>>> On 25/10/2016 09:31, Andreas Schwab wrote:
>>>>> On Okt 25 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
>>>>>
>>>>>> * string/strtok.c (strtok): Return null is previous input is also
>>>>>
>>>>> s/is/if/
>>>>>
>>>>>> diff --git a/string/strtok.c b/string/strtok.c
>>>>>> index 7a4574d..5c4b309 100644
>>>>>> --- a/string/strtok.c
>>>>>> +++ b/string/strtok.c
>>>>>> @@ -40,8 +40,8 @@ STRTOK (char *s, const char *delim)
>>>>>> {
>>>>>> char *token;
>>>>>>
>>>>>> - if (s == NULL)
>>>>>> - s = olds;
>>>>>> + if ((s == NULL) && ((s = olds) == NULL))
>>>>>
>>>>> Please avoid assignment in an expression. And the parens are redundant.
>>>>>
>>>>> Andreas.
>>>>>
>>>>
>>>> Right, with these fixes would it be acceptable?
>>>
>>> I don't see much point in supporting invalid use of strtok.
>>>
>>> Andreas.
>>>
>>
>> My point is just to add portability and align with other current
>> implementations.
>
> Has it ever be a problem in the past?
>
> Andreas.
>
None I am aware of, but regardless it is a effort to close down old
glibc bugs and keep the backlog under control.