Re: [PATCH] Handle long lines properly

From: Willy Tarreau <w#1wt.eu>
Date: Mon, 29 Oct 2007 00:50:44 +0100


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.

Best regards,
Willy Received on 2007/10/29 00:50

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