delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2013/07/20/02:54:35

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Date: Sat, 20 Jul 2013 09:53:50 +0300
From: Eli Zaretskii <eliz AT gnu DOT org>
Subject: Re: Set _IOERR if the file stream has been opened in wrong mode.
In-reply-to: <51E9D758.8000209@gmx.de>
X-012-Sender: halo1 AT inter DOT net DOT il
To: djgpp-workers AT delorie DOT com
Message-id: <838v11zpq9.fsf@gnu.org>
References: <51E5D0C6 DOT 1060404 AT gmx DOT de> <83y5951a79 DOT fsf AT gnu DOT org> <51E702E0 DOT 3010809 AT gmx DOT de> <83fvvc1t0x DOT fsf AT gnu DOT org> <8738rcsdik DOT fsf AT uwakimon DOT sk DOT tsukuba DOT ac DOT jp> <201307180459 DOT r6I4xWxV010383 AT envy DOT delorie DOT com> <51E9D758 DOT 8000209 AT gmx DOT de>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Date: Sat, 20 Jul 2013 02:18:32 +0200
> From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
> 
> As can be seen djgpp sets _IOEOF were appropriate and this can be checked
> using feof() but it does not set _IOERR under the conditions described in
> previous mails.  Below there is a new small patch that fixes the issue as
> suggested, this time in _filbuf for fread an fgets and in _flsbuf for
> fwrite and fputs.

Go ahead and commit it (with changes indicated below).  Thanks.

> +@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

> +@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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019