Changeset 1567 for zzuf


Ignore:
Timestamp:
Jan 5, 2007, 5:03:04 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Fix fgetln(). The testsuite *almost* passes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/load-stream.c

    r1566 r1567  
    396396{
    397397    struct fuzz *fuzz;
    398     char *ret;
    399398    size_t i, size;
    400399    int fd;
     
    408407    fuzz = _zz_getfuzz(fd);
    409408
    410     for(i = size = 0; fuzz.tmp[i] != '\n'; i++)
     409    for(i = size = 0; ; i++)
    411410    {
    412411        int ch;
    413 
    414         if(i >= size)
    415             fuzz.tmp = realloc(fuzz.tmp, (size += 80));
    416412
    417413        _zz_disabled = 1;
     
    422418            break;
    423419
    424         fuzz.tmp[i] = (char)(unsigned char)ch;
    425         _zz_fuzz(fd, (uint8_t *)fuzz.tmp + i, 1); /* rather inefficient */
     420        if(i >= size)
     421            fuzz->tmp = realloc(fuzz->tmp, (size += 80));
     422
     423        fuzz->tmp[i] = (char)(unsigned char)ch;
     424        _zz_fuzz(fd, (uint8_t *)fuzz->tmp + i, 1); /* rather inefficient */
    426425        _zz_addpos(fd, 1);
     426
     427        if(ch == '\n')
     428            break;
    427429    }
    428430
    429     *len = size;
    430 
    431     debug("fgetln([%i], &%li) = %p", fd, (long int)*len, ret);
    432     return ret;
    433 }
    434 #endif
    435 
     431    *len = i;
     432
     433    debug("fgetln([%i], &%li) = %p", fd, (long int)*len, fuzz->tmp);
     434    return fuzz->tmp;
     435}
     436#endif
     437
Note: See TracChangeset for help on using the changeset viewer.