delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/17/00:19:45

Message-ID: <319BC3B9.297A@public1.guangzhou.gd.cn>
Date: Fri, 17 May 1996 09:09:29 +0900
From: Wang TianXing <gztxwang AT public1 DOT guangzhou DOT gd DOT cn>
Organization: No Organization
MIME-Version: 1.0
To: Dieter Demerre <Dieter DOT Demerre AT cs DOT kuleuven DOT ac DOT be>
CC: djgpp AT delorie DOT com
Subject: Re: bug in fstream ? (V2) for in-out files ?
References: <319746C1 DOT 41C67EA6 AT cs DOT kuleuven DOT ac DOT be>

Dieter Demerre wrote:
> 
> A couple of months ago I installed DJGPP for I wanted to compile
> my program with it.  Just last weekend I found that not all objects
> behave like they do in BC3.1.
> I hereby include my testprogram (partly)  that tries to read from
> a file but also write to it.
> 
> I find that whenever I open the file to write in it, the file is
> renewed, while this is NOT done in Borland C++ nor in
> the C++ compiler we have here on the VAX- and ALPHA-machines.
> 
> Did I do anything wrong ?

Yes, you were right.  The libraries are buggy.  This problem popped
up a few days ago.  The solution is to change the following lines in
\djgpp\gnu\libgplus.271\libio\filebuf.cc:
 
  if ((mode & (int)ios::trunc) ||
      ((!(mode & (int)ios::app)) && (mode & (int)ios::out)))
    posix_mode |= O_TRUNC;
 
to:
 
  if ((mode & (int)ios::trunc) ||
      ((!(mode & int(ios::app|ios::in))) && (mode & (int)ios::out)))
    posix_mode |= O_TRUNC;

and update libgpp.a, libiostr.a, and libstdcx.a.

---
Wang TianXing


- Raw text -


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