X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Ffreadahead.c;h=27f5c9579fabd968332edbe029a639adcf841999;hb=620ece7758e453efebf7f52a1ab9fc1c49a5020c;hp=2dcf81c3054127683a4bd8ba3389837115fa84b7;hpb=a2b445a2c93224ca2999ad3a7aa6b4b2a752e7a0;p=gnulib.git diff --git a/lib/freadahead.c b/lib/freadahead.c index 2dcf81c30..27f5c9579 100644 --- a/lib/freadahead.c +++ b/lib/freadahead.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 @@ -25,12 +25,12 @@ size_t freadahead (FILE *fp) { -#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 0; return (fp->_IO_read_end - fp->_IO_read_ptr) - + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base : - 0); + + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base : + 0); #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0) return 0; @@ -38,7 +38,7 @@ freadahead (FILE *fp) return __sreadahead (fp); # else return fp_->_r - + (HASUB (fp) ? fp_->_ur : 0); + + (HASUB (fp) ? fp_->_ur : 0); # endif #elif defined __EMX__ /* emx+gcc */ if ((fp->_flags & _IOWRT) != 0) @@ -48,7 +48,7 @@ freadahead (FILE *fp) /* equivalent to (fp->_ungetc_count == 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount) */ return (fp->_rcount > 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount); -#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 0; return fp_->_cnt; @@ -57,7 +57,7 @@ freadahead (FILE *fp) if (fp->__modeflags & __FLAG_WRITING) return 0; return (fp->__bufread - fp->__bufpos) - + (fp->__modeflags & __FLAG_UNGOT ? 1 : 0); + + (fp->__modeflags & __FLAG_UNGOT ? 1 : 0); # else return 0; # endif @@ -67,9 +67,15 @@ freadahead (FILE *fp) /* fp->_Buf <= fp->_Next <= fp->_Rend, and fp->_Rend may be overridden by fp->_Rsave. */ return ((fp->_Rsave ? fp->_Rsave : fp->_Rend) - fp->_Next) - + (fp->_Mode & 0x4000 /* _MBYTE */ - ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback - : 0); + + (fp->_Mode & 0x4000 /* _MBYTE */ + ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback + : 0); +#elif defined __MINT__ /* Atari FreeMiNT */ + if (!fp->__mode.__read) + return 0; + return (fp->__pushed_back + ? fp->__get_limit - fp->__pushback_bufp + 1 + : fp->__get_limit - fp->__bufp); #elif defined SLOW_BUT_NO_HACKS /* users can define this */ abort (); return 0;