X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Ffreadptr.c;h=e7d57b433acb1c52b85b4b5032d7d1930f099266;hb=46380c372f75d7a8609c6646e48099a9b84f7ec2;hp=02b79e1e18df19f745f4051975fb205f89c59729;hpb=569eba622c635a2bd19408ff284cf07804012c54;p=gnulib.git diff --git a/lib/freadptr.c b/lib/freadptr.c index 02b79e1e1..e7d57b433 100644 --- a/lib/freadptr.c +++ b/lib/freadptr.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ freadptr (FILE *fp, size_t *sizep) size_t size; /* Keep this code in sync with freadahead! */ -#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */ +#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ if (fp->_IO_write_ptr > fp->_IO_write_base) return NULL; size = fp->_IO_read_end - fp->_IO_read_ptr; @@ -37,14 +37,14 @@ freadptr (FILE *fp, size_t *sizep) return NULL; *sizep = size; return (const char *) fp->_IO_read_ptr; -#elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */ - if ((fp->_flags & __SWR) != 0 || fp->_r < 0) +#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ + if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0) return NULL; - size = fp->_r; + size = fp_->_r; if (size == 0) return NULL; *sizep = size; - return (const char *) fp->_p; + return (const char *) fp_->_p; #elif defined __EMX__ /* emx+gcc */ if ((fp->_flags & _IOWRT) != 0) return NULL; @@ -56,7 +56,7 @@ freadptr (FILE *fp, size_t *sizep) abort (); *sizep = fp->_rcount; return fp->_ptr; -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */ +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ if ((fp_->_flag & _IOWRT) != 0) return NULL; size = fp_->_cnt; @@ -85,6 +85,18 @@ freadptr (FILE *fp, size_t *sizep) return NULL; *sizep = size; return (const char *) fp->_Next; +#elif defined __MINT__ /* Atari FreeMiNT */ + if (!fp->__mode.__read) + return NULL; + size = fp->__get_limit - fp->__bufp; + if (size == 0) + return NULL; + *sizep = size; + return fp->__bufp; +#elif defined SLOW_BUT_NO_HACKS /* users can define this */ + /* This implementation is correct on any ANSI C platform. It is just + awfully slow. */ + return NULL; #else #error "Please port gnulib freadptr.c to your platform! Look at the definition of fflush, fread, getc, getc_unlocked on your system, then report this to bug-gnulib." #endif