tech-userlevel archive

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

Re: pkgsrc RC scripts



On Mon, 19 Oct 2009, Robert Elz wrote:

>     Date:        Mon, 19 Oct 2009 15:13:14 +1300 (NZDT)
>     From:        Steven Drake <sdrake%xnet.co.nz@localhost>
> 
>    |  {
>    |          struct config_variable *var;
>    |          FILE *fp;
>    | -        char *line, *value;
>    | +        char *line, *value, *buf;
>    |          size_t len, var_len, i;
> 
> buf is never initialised, but is tested for NULL at the end.

The all code regarding buf is taken from the fgetln(3) manpage! 
(See: http://netbsd.gw.com/cgi-bin/man-cgi?fgetln )
so you'll have to ask it's author. 

> But it is also not really needed,

strchr(3) requires that the string end with \0, and in the odd case were the
last line of the file dosn't have an ending newline (it can happen) you would
be chopping off the last char.

>    | +                value=strchr(line, '=');
>    | +                if (value == NULL || *value != '=')
>    | +                        goto freebuf;
> 
> I don't understand the 
>       || *value != '='

Opps, think thats from an earlier version of the patch.

-- 
Steven


Home | Main Index | Thread Index | Old Index