Changeset 4032 for zzuf


Ignore:
Timestamp:
Nov 25, 2009, 1:42:32 AM (10 years ago)
Author:
Sam Hocevar
Message:

Minor refactoring in lib-stream.c.

File:
1 edited

Legend:

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

    r4029 r4032  
    2626/* Define if stdio operations use *only* the refill mechanism */
    2727#if defined HAVE___SREFILL
    28 #   define REFILL_ONLY_STDIO
     28#   define HAVE_DARWIN_STDIO
     29#elif defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
     30#   define HAVE_BSD_STDIO
    2931#endif
    3032
     
    162164static inline uint8_t *get_stream_ptr(FILE *stream)
    163165{
    164 #if defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
     166#if defined HAVE_BSD_STDIO
    165167    return (uint8_t *)stream->FILE_PTR;
    166168#else
     
    171173static inline int get_stream_off(FILE *stream)
    172174{
    173 #if defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
     175#if defined HAVE_BSD_STDIO
    174176    return (int)((uint8_t *)stream->FILE_PTR - (uint8_t *)stream->FILE_BASE);
    175177#else
     
    182184#if defined HAVE_GLIBC_FP
    183185    return (int)((uint8_t *)stream->FILE_CNT - (uint8_t *)stream->FILE_PTR);
    184 #elif defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
     186#elif defined HAVE_BSD_STDIO
    185187    return stream->FILE_CNT;
    186188#else
     
    197199 */
    198200
    199 #if defined REFILL_ONLY_STDIO /* Fuzz fp if we have __srefill() */
     201#if defined HAVE_DARWIN_STDIO /* Fuzz fp if we have __srefill() */
    200202#   define FOPEN_FUZZ() \
    201203    _zz_fuzz(fd, get_stream_ptr(ret), get_stream_cnt(ret))
     
    293295 */
    294296
    295 #if defined REFILL_ONLY_STDIO /* Don't fuzz or seek if we have __srefill() */
     297#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
    296298#   define FSEEK_FUZZ(myftell)
    297299#else
     
    417419    debug("%s([%i])", __func__, fd);
    418420
    419 #if defined REFILL_ONLY_STDIO /* Don't fuzz or seek if we have __srefill() */
     421#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
    420422#else
    421423    /* FIXME: check what happens when rewind()ing a pipe */
     
    431433 * __srget or __uflow, and store it in already_fuzzed. If these functions
    432434 * are not available, do nothing. */
    433 #if defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
     435#if defined HAVE_BSD_STDIO
    434436#   define FREAD_PREFUZZ(fd, oldpos) \
    435437    do \
     
    449451 * have __srefill, we just do nothing because that function is the only
    450452 * one that actually fuzzes things. */
    451 #if defined REFILL_ONLY_STDIO
     453#if defined HAVE_DARWIN_STDIO
    452454#   define FREAD_FUZZ(fd, oldpos) \
    453455    do \
     
    539541 */
    540542
    541 #if defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
     543#if defined HAVE_BSD_STDIO
    542544#   define FGETC_PREFUZZ already_fuzzed = _zz_getfuzzed(fd);
    543545#else
     
    545547#endif
    546548
    547 #if defined REFILL_ONLY_STDIO /* Don't fuzz or seek if we have __srefill() */
     549#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
    548550#   define FGETC_FUZZ
    549551#else
     
    631633 */
    632634
    633 #if defined REFILL_ONLY_STDIO /* Don't fuzz or seek if we have __srefill() */
     635#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
    634636#   define FGETS_FUZZ(myfgets, myfgetc) \
    635637        _zz_lock(fd); \
     
    722724        fuzz->upos = _zz_getpos(fd) - 1;
    723725        fuzz->uchar = c;
    724 #if defined REFILL_ONLY_STDIO /* Don't fuzz or seek if we have __srefill() */
     726#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
    725727#else
    726728        _zz_addpos(fd, -1);
     
    853855{
    854856    char *ret;
    855 #if defined REFILL_ONLY_STDIO /* Don't fuzz or seek if we have __srefill() */
     857#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
    856858#else
    857859    struct fuzz *fuzz;
     
    867869
    868870    DEBUG_STREAM("old", stream);
    869 #if defined REFILL_ONLY_STDIO /* Don't fuzz or seek if we have __srefill() */
     871#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
    870872    _zz_lock(fd);
    871873    ret = ORIG(fgetln)(stream, len);
     
    910912 */
    911913
    912 #if defined HAVE___SREFILL || defined HAVE___FILBUF || defined HAVE___SRGET
     914#if defined HAVE___UFLOW
     915#   define REFILL_RETURNS_INT 0
     916#else
    913917#   define REFILL_RETURNS_INT 1
    914 #elif defined HAVE___UFLOW
    915 #   define REFILL_RETURNS_INT 0
    916918#endif
    917919
Note: See TracChangeset for help on using the changeset viewer.