Mail Archives: djgpp-workers/2013/07/20/05:22:39
Am 20.07.2013 08:53, schrieb Eli Zaretskii:
> > +@findex fread AT r{, and setting @code{_flag} to @code{_IOERR} if stream has been opened with wrong mode}
> > +@findex fwrite AT r{, and setting @code{_flag} to @code{_IOERR} if stream has been opened with wrong mode}
> > +@findex fgets AT r{, and setting @code{_flag} to @code{_IOERR} if stream has been opened with wrong mode}
> > +@findex fputs AT r{, and setting @code{_flag} to @code{_IOERR} if stream has been opened with wrong mode}
>
> Such long index entries are not useful. I suggest something like
>
> @findex fputs AT r{, and } stream error condition
OK.
> > +@code{fread}, @code{fwrite}, @code{fgets} and @code{fputs} now check that the file stream has
> > +been opened in correct mode. If it is the wrong mode the file stream @code{_flag} flag will
> > +be set to @code{_IOERR} before aborting the operation.
>
> Here, you refer to internal variables and flags. It would be much
> better to mention the stream error condition, and say that it can be
> tested with ferror. Otherwise, only those who know the library
> internals will be able to understand the change.
OK.
I do not know if it is worth to clarify that this feature is not standard
mandated but only added for compatibility with the major open source c libraries.
I fear that there will be a new standard clarifying the issue before there
have been made a new djgpp release so that the comment would become obsolete
or the change must be reversed.
Regards,
Juan M. Guerrero
diff -aprNU3 djgpp.orig/src/docs/kb/wc204.txi djgpp/src/docs/kb/wc204.txi
--- djgpp.orig/src/docs/kb/wc204.txi 2013-03-23 11:54:58 +0000
+++ djgpp/src/docs/kb/wc204.txi 2013-07-20 10:35:44 +0000
@@ -1289,3 +1289,12 @@ members of @code{struct rlimit}.
The @acronym{C99} macros @code{isfinite}, @code{isinf}, @code{isnan}, @code{isnormal}, @code{isgreater},
@code{isgreaterequal}, @code{isless}, @code{islessequal}, @code{islessgreater} and @code{isunordered}
were added to comply with the @acronym{C99} standard.
+
+@findex fread AT r{, and stream error condition}
+@findex fwrite AT r{, and stream error condition}
+@findex fgets AT r{, and stream error condition}
+@findex fputs AT r{, and stream error condition}
+If a file stream has been opened in the wrong mode referring to the
+following input/output operation (e.g.: openning stream in read only mode
+and then writing to it) will trigger a stream error condition that will
+set an error indicator. This error indicator can be tested using @code{ferror}.
diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/filbuf.c djgpp/src/libc/ansi/stdio/filbuf.c
--- djgpp.orig/src/libc/ansi/stdio/filbuf.c 2013-07-16 18:00:12 +0000
+++ djgpp/src/libc/ansi/stdio/filbuf.c 2013-07-20 10:03:22 +0000
@@ -37,7 +37,11 @@ _filbuf(FILE *f)
f->_flag |= _IOREAD;
if (!(f->_flag & _IOREAD))
+ {
+ f->_flag |= _IOERR;
return EOF;
+ }
+
if (f->_flag & (_IOSTRG | _IOEOF))
return EOF;
f->_flag &= ~_IOUNGETC;
diff -aprNU3 djgpp.orig/src/libc/ansi/stdio/flsbuf.c djgpp/src/libc/ansi/stdio/flsbuf.c
--- djgpp.orig/src/libc/ansi/stdio/flsbuf.c 2013-07-16 18:00:14 +0000
+++ djgpp/src/libc/ansi/stdio/flsbuf.c 2013-07-20 10:03:22 +0000
@@ -31,7 +31,10 @@ _flsbuf(int c, FILE *f)
}
if (!(f->_flag & _IOWRT))
+ {
+ f->_flag |= _IOERR;
return EOF;
+ }
/* No-op for full string buffers */
if (f->_flag & _IOSTRG)
- Raw text -