* Re: [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write
[not found] <je673e84m3.fsf@hawking.suse.de>
@ 1999-07-21 7:27 ` H.J. Lu
1999-07-21 7:33 ` Andreas Schwab
0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 1999-07-21 7:27 UTC (permalink / raw)
To: Andreas Schwab; +Cc: GNU C Library
>
> hjl@lucon.org (H.J. Lu) writes:
>
> |> How about this patch?
>
> I have already checked this in for libc-2.2. It doesn't change anything
> for fread anyway, only fgetc.
>
What do you mean by that? Have you tried my patch with your program?
--
H.J. Lu (hjl@gnu.org)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write
1999-07-21 7:27 ` [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write H.J. Lu
@ 1999-07-21 7:33 ` Andreas Schwab
1999-07-21 8:08 ` H.J. Lu
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 1999-07-21 7:33 UTC (permalink / raw)
To: H.J. Lu; +Cc: GNU C Library
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 554 bytes --]
hjl@lucon.org (H.J. Lu) writes:
|> >
|> > hjl@lucon.org (H.J. Lu) writes:
|> >
|> > |> How about this patch?
|> >
|> > I have already checked this in for libc-2.2. It doesn't change anything
|> > for fread anyway, only fgetc.
|> >
|>
|> What do you mean by that? Have you tried my patch with your program?
What do you mean with "your program"?
--
Andreas Schwab "And now for something
schwab@suse.de completely different."
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write
1999-07-21 7:33 ` Andreas Schwab
@ 1999-07-21 8:08 ` H.J. Lu
1999-07-21 9:00 ` Ulrich Drepper
0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 1999-07-21 8:08 UTC (permalink / raw)
To: Andreas Schwab; +Cc: GNU C Library
This patch should pass the test. The problem is _IO_file_xsgetn
and _IO_XXX_file_xsputn may call read/write directly.
--
H.J. Lu (hjl@gnu.org)
----
Wed Jul 21 08:03:47 1999 H.J. Lu <hjl@gnu.org>
* libio/fileops.c (_IO_new_file_underflow): Set the error flag
if fp is not opened for read.
* libio/oldfileops.c (_IO_old_file_underflow): Likewise.
* libio/fileops.c (_IO_new_file_xsputn): Set the error flag and
return 0 if f is not opened for write.
* libio/oldfileops.c (_IO_old_file_xsputn): Likewise.
* libio/fileops.c (_IO_file_xsgetn): Set the error flag and
return 0 if f is not opened for read.
Index: libio/fileops.c
===================================================================
RCS file: /work/cvs/gnu/glibc-2.1/libio/fileops.c,v
retrieving revision 1.10
diff -u -p -r1.10 fileops.c
--- libio/fileops.c 1999/05/01 22:41:30 1.10
+++ libio/fileops.c 1999/07/21 14:58:22
@@ -349,6 +349,7 @@ _IO_new_file_underflow (fp)
if (fp->_flags & _IO_NO_READS)
{
__set_errno (EBADF);
+ fp->_flags |= _IO_ERR_SEEN;
return EOF;
}
if (fp->_IO_read_ptr < fp->_IO_read_end)
@@ -745,6 +746,13 @@ _IO_new_file_xsputn (f, data, n)
int must_flush = 0;
_IO_size_t count;
+ if (f->_flags & _IO_NO_WRITES)
+ {
+ __set_errno (EBADF);
+ f->_flags |= _IO_ERR_SEEN;
+ return 0;
+ }
+
if (n <= 0)
return 0;
/* This is an optimized implementation.
@@ -833,6 +841,13 @@ _IO_file_xsgetn (fp, data, n)
register _IO_size_t want, have;
register _IO_ssize_t count;
register char *s = data;
+
+ if (fp->_flags & _IO_NO_READS)
+ {
+ __set_errno (EBADF);
+ fp->_flags |= _IO_ERR_SEEN;
+ return 0;
+ }
want = n;
Index: libio/oldfileops.c
===================================================================
RCS file: /work/cvs/gnu/glibc-2.1/libio/oldfileops.c,v
retrieving revision 1.2
diff -u -p -r1.2 oldfileops.c
--- libio/oldfileops.c 1999/05/01 22:41:30 1.2
+++ libio/oldfileops.c 1999/07/21 14:59:15
@@ -313,6 +313,7 @@ _IO_old_file_underflow (fp)
if (fp->_flags & _IO_NO_READS)
{
__set_errno (EBADF);
+ fp->_flags |= _IO_ERR_SEEN;
return EOF;
}
if (fp->_IO_read_ptr < fp->_IO_read_end)
@@ -668,6 +669,13 @@ _IO_old_file_xsputn (f, data, n)
int must_flush = 0;
_IO_size_t count;
+ if (f->_flags & _IO_NO_WRITES)
+ {
+ __set_errno (EBADF);
+ f->_flags |= _IO_ERR_SEEN;
+ return 0;
+ }
+
if (n <= 0)
return 0;
/* This is an optimized implementation.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write
1999-07-21 8:08 ` H.J. Lu
@ 1999-07-21 9:00 ` Ulrich Drepper
1999-07-21 9:45 ` Andreas Jaeger
0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Drepper @ 1999-07-21 9:00 UTC (permalink / raw)
To: H.J. Lu; +Cc: Andreas Schwab, GNU C Library
hjl@lucon.org (H.J. Lu) writes:
> This patch should pass the test. The problem is _IO_file_xsgetn
> and _IO_XXX_file_xsputn may call read/write directly.
This is not necessary. Don't add it.
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write
1999-07-21 9:00 ` Ulrich Drepper
@ 1999-07-21 9:45 ` Andreas Jaeger
1999-07-21 9:53 ` Andreas Schwab
1999-07-21 15:25 ` Ulrich Drepper
0 siblings, 2 replies; 7+ messages in thread
From: Andreas Jaeger @ 1999-07-21 9:45 UTC (permalink / raw)
To: GNU C Library
>>>>> Ulrich Drepper writes:
Uli> hjl@lucon.org (H.J. Lu) writes:
>> This patch should pass the test. The problem is _IO_file_xsgetn
>> and _IO_XXX_file_xsputn may call read/write directly.
Uli> This is not necessary. Don't add it.
Are you sure? Check the current Posix draft of the Austin Group for
fread/fgetc and fwrite/fputc. They explicitly mention EBADF for:
The filedescriptor underlying stream is not a valid file descriptor
open for reading (writing with fwrite/fputc).
But this is marked as a new addition.
Andreas
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write
1999-07-21 9:45 ` Andreas Jaeger
@ 1999-07-21 9:53 ` Andreas Schwab
1999-07-21 15:25 ` Ulrich Drepper
1 sibling, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 1999-07-21 9:53 UTC (permalink / raw)
To: GNU C Library
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 919 bytes --]
Andreas Jaeger <aj@arthur.rhein-neckar.de> writes:
|> >>>>> Ulrich Drepper writes:
|>
|> Uli> hjl@lucon.org (H.J. Lu) writes:
|> >> This patch should pass the test. The problem is _IO_file_xsgetn
|> >> and _IO_XXX_file_xsputn may call read/write directly.
|>
|> Uli> This is not necessary. Don't add it.
|>
|> Are you sure? Check the current Posix draft of the Austin Group for
|> fread/fgetc and fwrite/fputc. They explicitly mention EBADF for:
|>
|> The filedescriptor underlying stream is not a valid file descriptor
|> open for reading (writing with fwrite/fputc).
If you use std{in,out,err} then the underlying fd _is_ valid for both
read and write (until you change that with freopen).
Andreas.
--
Andreas Schwab "And now for something
schwab@suse.de completely different."
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write
1999-07-21 9:45 ` Andreas Jaeger
1999-07-21 9:53 ` Andreas Schwab
@ 1999-07-21 15:25 ` Ulrich Drepper
1 sibling, 0 replies; 7+ messages in thread
From: Ulrich Drepper @ 1999-07-21 15:25 UTC (permalink / raw)
To: GNU C Library
Andreas Jaeger <aj@arthur.rhein-neckar.de> writes:
> Are you sure? Check the current Posix draft of the Austin Group for
> fread/fgetc and fwrite/fputc. They explicitly mention EBADF for:
OK, it's nowadays referring to getc. (We are working through the XSH
stuff only tomorrow so I haven't read it). In this light the changes
should be added.
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1999-07-21 15:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <je673e84m3.fsf@hawking.suse.de>
1999-07-21 7:27 ` [Gurusamy Sarathy <gsar@activestate.com>] ferror() after fread() on a FILE* opened for write H.J. Lu
1999-07-21 7:33 ` Andreas Schwab
1999-07-21 8:08 ` H.J. Lu
1999-07-21 9:00 ` Ulrich Drepper
1999-07-21 9:45 ` Andreas Jaeger
1999-07-21 9:53 ` Andreas Schwab
1999-07-21 15:25 ` Ulrich Drepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).