delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/02/26/23:01:34

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <403EB43C.9948956C@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Why can't I use freopen here?
References: <403E69B9 DOT 1054A239 AT yahoo DOT com> <200402270109 DOT i1R19jZN010621 AT envy DOT delorie DOT com>
Lines: 31
Date: Fri, 27 Feb 2004 03:46:05 GMT
NNTP-Posting-Host: 12.76.132.100
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc04-news.ops.worldnet.att.net 1077853565 12.76.132.100 (Fri, 27 Feb 2004 03:46:05 GMT)
NNTP-Posting-Date: Fri, 27 Feb 2004 03:46:05 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

DJ Delorie wrote:
> 
> >    if (!(freopen(NULL, "rb", stdin))) {
> 
> > fails.  The objective is to be able to read past 0x1a EOF markers
> > in the file.  Line endings are of no concern.  Why does it fail?
> 
> It fails because the path you specified is NULL.  That is not legal.
> 
> Use setmode(0, O_BINARY) to change stdin to binary.
> 
> But please read the info page on setmode() before using it.

I based using that on the following N869 passage:

  [#3]  If  filename  is  a null pointer, the freopen function
  attempts to change the mode of the stream to that  specified
  by  mode,  as  if  the name of the file currently associated
  with the stream had been used.  It is implementation-defined
  which changes of mode are permitted (if any), and under what
  circumstances.

which appears to offer an out for failure to execute.  Obviously
setmode() is not portable.  Since I am a nut for portability I
will attempt to maneuver the files otherwise.

-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!

- Raw text -


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