delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2013/07/18/12:23:50

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Date: Thu, 18 Jul 2013 19:23:15 +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: <201307180459.r6I4xWxV010383@envy.delorie.com>
X-012-Sender: halo1 AT inter DOT net DOT il
To: djgpp-workers AT delorie DOT com
Message-id: <83a9lj25xo.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>
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: Thu, 18 Jul 2013 00:59:32 -0400
> From: DJ Delorie <dj AT delorie DOT com>
> 
> I looked in the code and didn't see anything where we specifically set
> the error flag, other than read() failing.  So, it looks like this is
> a DOS thing - that file just isn't readable.

We could set the flag ourselves, just like we do now with returning
EOF (in filbuf.c):

  if ((f->_flag&_IOREAD) == 0)
    return EOF;

We could also set the _IOERR flag at that spot, if we decide that to
be TRT.

> But I couldn't find anything in the posix/ansi specs that said what
> conditions cause errors, just that if errors happen ferror() says so.

Right, same here.  So this is basically our decision: do we want the
undefined behavior in this case be "bug-compatible" to what the other
libraries do?

- Raw text -


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