Re: [PATCH] Handle long lines properly

From: Krzysztof Oledzki <ole#ans.pl>
Date: Thu, 1 Nov 2007 00:45:54 +0100 (CET)

On Mon, 29 Oct 2007, Willy Tarreau wrote:

> On Mon, Oct 29, 2007 at 12:46:53AM +0100, Krzysztof Oledzki wrote:

>>> OK, but then I'd like to avoid redoing strlen(line) a second time.
>>> We could then have something like this :
>>>
>>> end = line + strlen(line);
>>>
>>> + if ((end-line == sizeof(thisline)-1 && *(end-1) != '\n') {
>>
>> Redoing strlen(line) is only required in two situations:
>> - when a line was to long
>> - on the last, incorrectly termitaned, line
>>
>> Normally, such situations should not happen. I do not like doing to much
>> math on pointers but if you find it more effective - no problem, I can
>> change it. :)
>
> It's not much math on pointers here, because the assignment is done just
> on previous line, so it is by definition that end-line == strlen(line).
>

>>> Also, my initial fgets() in the while() is awful, it hides an assignment.
>>> Would you please assign 'line' inside the loop ? It seems like we could
>>> even declare it there, making code auditing easier.
>>
>> It seems there are more declarations that can be moved: end, args & arg.
>
> OK, I trust you on this.

Done. Sorry it took me so long, last three days were very busy thanks to my employer. ;)

Best regards,

                                 Krzysztof Olędzki Received on 2007/11/01 00:45

This archive was generated by hypermail 2.2.0 : 2007/11/04 19:21 CET