Hiltjo Posthuma:

> > @@ -75,19 +74,8 @@ cookie_load(void)
> >     if (fp == NULL)
> >             err(1, "cannot open cookie file %s", cookiefile);
> >     date = time(NULL);
> > -   lbuf = NULL;
> > -   while ((line = fgetln(fp, &len)) != NULL) {
> > -           if (line[len - 1] == '\n') {
> > -                   line[len - 1] = '\0';
> > -                   --len;
> > -           } else {
> > -                   if ((lbuf = malloc(len + 1)) == NULL)
> > -                           err(1, NULL);
> > -                   memcpy(lbuf, line, len);
> > -                   lbuf[len] = '\0';
> > -                   line = lbuf;
> > -           }
> > -           line[strcspn(line, "\r")] = '\0';
> > +   while (getline(&line, &linesize, fp) != -1) {
> > +           line[strcspn(line, "\r\n")] = '\0';
> >  
> 
> getline returns the number of characters read including the delimeter. This
> size could be used to '\0' terminate the string instead of a strcspn() call.

A strcspn() call is already there.

-- 
Christian "naddy" Weisgerber                          [email protected]

Reply via email to