Changeset 4041 for zzuf/trunk/src


Ignore:
Timestamp:
Nov 26, 2009, 2:13:58 AM (11 years ago)
Author:
Sam Hocevar
Message:

Use fseeko64() everywhere when possible, instead of potential 32-bit versions.

File:
1 edited

Legend:

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

    r4032 r4041  
    2929#elif defined HAVE___FILBUF || defined HAVE___SRGET || defined HAVE___UFLOW
    3030#   define HAVE_BSD_STDIO
     31#endif
     32
     33/* Define the best ftell() clone */
     34#if defined HAVE_FTELLO64
     35#   define MYFTELL ftello64
     36#elif defined HAVE___FTELLO64
     37#   define MYFTELL __ftello64
     38#elif defined HAVE_FTELLO
     39#   define MYFTELL ftello
     40#else
     41#   define MYFTELL ftell
    3142#endif
    3243
     
    296307
    297308#if defined HAVE_DARWIN_STDIO /* Don't fuzz or seek if we have __srefill() */
    298 #   define FSEEK_FUZZ(myftell)
    299 #else
    300 #   define FSEEK_FUZZ(myftell) \
     309#   define FSEEK_FUZZ()
     310#else
     311#   define FSEEK_FUZZ() \
    301312        if(ret == 0) \
    302313        { \
     
    305316            { \
    306317                case SEEK_END: \
    307                     offset = myftell(stream); \
     318                    offset = MYFTELL(stream); \
    308319                    /* fall through */ \
    309320                case SEEK_SET: \
     
    317328#endif
    318329
    319 #define FSEEK(myfseek, myftell) \
     330#define FSEEK(myfseek) \
    320331    do \
    321332    { \
     
    331342        debug("%s([%i], %lli, %i) = %i", __func__, \
    332343              fd, (long long int)offset, whence, ret); \
    333         FSEEK_FUZZ(myftell) \
     344        FSEEK_FUZZ() \
    334345        DEBUG_STREAM("new", stream); \
    335346    } while(0)
     
    337348int NEW(fseek)(FILE *stream, long offset, int whence)
    338349{
    339     int ret; FSEEK(fseek, ftell); return ret;
     350    int ret; FSEEK(fseek); return ret;
    340351}
    341352
     
    343354int NEW(fseeko)(FILE *stream, off_t offset, int whence)
    344355{
    345     int ret; FSEEK(fseeko, ftello); return ret;
     356    int ret; FSEEK(fseeko); return ret;
    346357}
    347358#endif
     
    350361int NEW(fseeko64)(FILE *stream, off64_t offset, int whence)
    351362{
    352     int ret; FSEEK(fseeko64, ftello64); return ret;
     363    int ret; FSEEK(fseeko64); return ret;
    353364}
    354365#endif
     
    357368int NEW(__fseeko64)(FILE *stream, off64_t offset, int whence)
    358369{
    359     int ret; FSEEK(__fseeko64, ftello); return ret;
     370    int ret; FSEEK(__fseeko64); return ret;
    360371}
    361372#endif
     
    462473    do \
    463474    { \
    464         int64_t newpos = ftell(stream); \
     475        int64_t newpos = MYFTELL(stream); \
    465476        /* XXX: the number of bytes read is not ret * size, because \
    466477         * a partial read may have advanced the stream pointer. However, \
     
    515526            return ORIG(myfread)(ptr, size, nmemb, stream); \
    516527        DEBUG_STREAM("old", stream); \
    517         oldpos = ftell(stream); \
     528        oldpos = MYFTELL(stream); \
    518529        _zz_lock(fd); \
    519530        ret = ORIG(myfread)(ptr, size, nmemb, stream); \
Note: See TracChangeset for help on using the changeset viewer.