Changeset 1591 for zzuf


Ignore:
Timestamp:
Jan 6, 2007, 10:38:33 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Cleaned up code.
File:
1 edited

Legend:

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

    r1588 r1591  
    186186size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
    187187{
    188     long int pos;
     188    long int pos, newpos;
    189189    size_t ret;
    190190    int fd;
     
    202202    debug("fread(%p, %li, %li, [%i]) = %li",
    203203          ptr, (long int)size, (long int)nmemb, fd, (long int)ret);
    204     if(ret >= 0)
     204
     205    /* XXX: the number of bytes read is not ret * size, because
     206     * a partial read may have advanced the stream pointer. However,
     207     * when reading from a pipe ftell() will return 0, and ret * size
     208     * is then better than nothing. */
     209    newpos = ftell(stream);
     210    if(newpos <= 0)
     211        newpos = ret * size;
     212    if(newpos != pos)
    205213    {
    206         /* XXX: the number of bytes read is not ret * size, because
    207          * a partial read may have advanced the stream pointer. However,
    208          * when reading from a pipe ftell() will return 0, and ret * size
    209          * is then better than nothing. */
    210         long int newpos = ftell(stream);
    211         if(newpos <= 0)
    212             newpos = ret * size;
    213         if(newpos != pos)
    214         {
    215             _zz_fuzz(fd, ptr, newpos - pos);
    216             _zz_setpos(fd, newpos);
    217         }
     214        _zz_fuzz(fd, ptr, newpos - pos);
     215        _zz_setpos(fd, newpos);
    218216    }
     217
    219218    return ret;
    220219}
Note: See TracChangeset for help on using the changeset viewer.