Ignore:
Timestamp:
Jan 27, 2007, 4:13:34 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Better ungetc() implementation. Now we don't need to care about the fuzzing method.
File:
1 edited

Legend:

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

    r1712 r1719  
    379379int NEW(ungetc)(int c, FILE *stream)
    380380{
    381     unsigned char ch = c;
    382381    int ret, fd;
    383382
     
    387386        return ORIG(ungetc)(c, stream);
    388387
    389 #if defined HAVE___SREFILL /* Don't fuzz or seek if we have __srefill() */
    390 #else
    391     _zz_addpos(fd, -1);
    392     _zz_fuzz(fd, &ch, 1);
    393 #endif
    394     _zz_lock(fd);
    395     ret = ORIG(ungetc)((int)ch, stream);
    396     _zz_unlock(fd);
    397 
    398     if(ret >= 0)
    399         ret = c;
    400 #if defined HAVE___SREFILL /* Don't fuzz or seek if we have __srefill() */
    401 #else
    402     else
    403         _zz_addpos(fd, 1); /* revert what we did */
    404 #endif
     388    _zz_lock(fd);
     389    ret = ORIG(ungetc)(c, stream);
     390    _zz_unlock(fd);
     391
     392    if(ret != EOF)
     393    {
     394        struct fuzz *fuzz = _zz_getfuzz(fd);
     395        fuzz->uflag = 1;
     396        fuzz->upos = _zz_getpos(fd) - 1;
     397        fuzz->uchar = c;
     398#if defined HAVE___SREFILL /* Don't fuzz or seek if we have __srefill() */
     399#else
     400        _zz_addpos(fd, -1);
     401#endif
     402    }
    405403
    406404    debug("%s(0x%02x, [%i]) = '%c'", __func__, c, fd, ret);
Note: See TracChangeset for help on using the changeset viewer.