aboutsummaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-08 11:59:45 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-08 11:59:45 +0000
commit110215a9a76594e808903af957f3273e3bc11a87 (patch)
tree36ffca48f1168e282af19e00d3909597a5573dff /libio
parent94e365c61202e2472c8aea42c7c95ce40f5b843c (diff)
downloadglibc-110215a9a76594e808903af957f3273e3bc11a87.zip
glibc-110215a9a76594e808903af957f3273e3bc11a87.tar.gz
glibc-110215a9a76594e808903af957f3273e3bc11a87.tar.bz2
Update.
1999-07-08 Andreas Schwab <schwab@suse.de> * libio/iofopncook.c (fopencookie): Set _fileno to -2. * libio/libioP.h (_IO_file_is_open): Only check for -1, not all negative numbers. * libio/fileops.c (_IO_new_file_close_it): Set _fileno to -1, not EOF. * libio/oldfileops.c (_IO_old_file_close_it): Likewise. 1999-07-08 Andreas Schwab <schwab@suse.de> * stdio-common/vfprintf.c (buffered_vfprintf): Initialize _mode. 1999-07-08 Andreas Schwab <schwab@suse.de> * libio/fileno.c: Return -1 instead of EOF and set errno if the stream is not a real file stream. 1999-07-08 Andreas Schwab <schwab@suse.de> * manual/charset.texi: Fix typos.
Diffstat (limited to 'libio')
-rw-r--r--libio/fileno.c7
-rw-r--r--libio/fileops.c2
-rw-r--r--libio/iofopncook.c5
-rw-r--r--libio/libioP.h4
-rw-r--r--libio/oldfileops.c2
5 files changed, 14 insertions, 6 deletions
diff --git a/libio/fileno.c b/libio/fileno.c
index 7ff93e6..92334f1 100644
--- a/libio/fileno.c
+++ b/libio/fileno.c
@@ -32,8 +32,11 @@ fileno (fp)
{
CHECK_FILE (fp, EOF);
- if (!(fp->_flags & _IO_IS_FILEBUF))
- return EOF;
+ if (!(fp->_flags & _IO_IS_FILEBUF) || _IO_fileno (fp) < 0)
+ {
+ __set_errno (EBADF);
+ return -1;
+ }
return _IO_fileno (fp);
}
diff --git a/libio/fileops.c b/libio/fileops.c
index 8d480ad..8ced77b 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -151,7 +151,7 @@ _IO_new_file_close_it (fp)
_IO_un_link (fp);
fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
- fp->_fileno = EOF;
+ fp->_fileno = -1;
fp->_offset = _IO_pos_BAD;
return close_status ? close_status : write_status;
diff --git a/libio/iofopncook.c b/libio/iofopncook.c
index 85ea35c..7b76826 100644
--- a/libio/iofopncook.c
+++ b/libio/iofopncook.c
@@ -167,5 +167,10 @@ fopencookie (cookie, mode, io_functions)
_IO_mask_flags (&new_f->cfile.__file, read_write,
_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
+ /* We use a negative number different from -1 for _fileno to mark that
+ this special stream is not associated with a real file, but still has
+ to be treated as such. */
+ new_f->cfile.__file._fileno = -2;
+
return &new_f->cfile.__file;
}
diff --git a/libio/libioP.h b/libio/libioP.h
index 775f445..64256a9 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -98,7 +98,7 @@ extern "C" {
#endif
/* The 'finish' function does any final cleaning up of an _IO_FILE object.
- It does not delete (free) it, but does everything else to finalize it/
+ It does not delete (free) it, but does everything else to finalize it.
It matches the streambuf::~streambuf virtual destructor. */
typedef void (*_IO_finish_t) __PMT ((_IO_FILE *, int)); /* finalize */
#define _IO_FINISH(FP) JUMP1 (__finish, FP, 0)
@@ -422,7 +422,7 @@ extern int _IO_file_stat __P ((_IO_FILE *, void *));
extern int _IO_file_close __P ((_IO_FILE *));
extern int _IO_file_underflow __P ((_IO_FILE *));
extern int _IO_file_overflow __P ((_IO_FILE *, int));
-#define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0)
+#define _IO_file_is_open(__fp) ((__fp)->_fileno != -1)
extern void _IO_file_init __P ((_IO_FILE *));
extern _IO_FILE* _IO_file_attach __P ((_IO_FILE *, int));
extern _IO_FILE* _IO_file_open __P ((_IO_FILE *, const char *, int, int,
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index d65c272..0244521 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -149,7 +149,7 @@ _IO_old_file_close_it (fp)
_IO_un_link (fp);
fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
- fp->_fileno = EOF;
+ fp->_fileno = -1;
fp->_old_offset = _IO_pos_BAD;
return close_status ? close_status : write_status;