X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Ffreadptr.c;h=26c66edebb0771e92c93fec9334b80a5f1708434;hb=7ef6c64e210ac0979d7e8ac69bc5b5208c2405ab;hp=3abe58e6398de83ad116e0d5c7daf283591780ed;hpb=81fe603b84b9ab4565593f0b38b30274dbb73980;p=gnulib.git diff --git a/lib/freadptr.c b/lib/freadptr.c index 3abe58e63..26c66edeb 100644 --- a/lib/freadptr.c +++ b/lib/freadptr.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2014 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 @@ -37,7 +37,7 @@ freadptr (FILE *fp, size_t *sizep) return NULL; *sizep = size; return (const char *) fp->_IO_read_ptr; -#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ +#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0) return NULL; size = fp_->_r; @@ -56,7 +56,15 @@ 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 __minix /* Minix */ + if ((fp_->_flags & _IOWRITING) != 0) + return NULL; + size = fp_->_count; + if (size == 0) + return NULL; + *sizep = size; + return (const char *) fp_->_ptr; +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ if ((fp_->_flag & _IOWRT) != 0) return NULL; size = fp_->_cnt; @@ -93,6 +101,13 @@ freadptr (FILE *fp, size_t *sizep) return NULL; *sizep = size; return fp->__bufp; +#elif defined EPLAN9 /* Plan9 */ + if (fp->state == 4 /* WR */) + return NULL; + if (fp->rp >= fp->wp) + return NULL; + *sizep = fp->wp - fp->rp; + return fp->rp; #elif defined SLOW_BUT_NO_HACKS /* users can define this */ /* This implementation is correct on any ANSI C platform. It is just awfully slow. */