delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/03/04:34:02

Message-ID: <31899BE4.7159@public1.guangzhou.gd.cn>
Date: Fri, 03 May 1996 14:38:44 +0900
From: Wang TianXing <gztxwang AT public1 DOT guangzhou DOT gd DOT cn>
Organization: No Organization
MIME-Version: 1.0
To: nate <nate AT mill2 DOT MillComm DOT COM>
CC: djgpp AT delorie DOT com
Subject: Re: gxx bug? binary files
References: <Pine DOT 3 DOT 89 DOT 9605021840 DOT A16218-0100000 AT mill2 DOT MillComm DOT COM>

nate wrote:
> 
> > [snip]
> >
> > >   //modify temp_person (make it 66) and write it back to object 50 in file
> > >     temp_file.open(FILE_NAME, ios::in|ios::out|ios::binary|ios::nocreate);
> >
> > Change that line to:
> >
> >     temp_file.open(FILE_NAME, ios::in|ios::out|ios::app|ios::binary);
> >
> > libg++ 2.7.1 truncates the file when it sees 'out' without 'app'.  And,
> > 'nocreate' is neither a standard thing nor a promise that the file will
> > not be truncated.
> 
> Thanks for your response, I just tried your idea.  Unfortunately, this
> APPENDS the file (as one might expect) and fails to update the file in
> the positing that I am trying to update.  It seems silly that libg++
> 2.7.1 would include such a serious error.  I'm off to search for DJGPP
> libg++ version 2.7.2, if you know if it exists, please inform me.  thanks..

Sorry, I overlooked something.  I think the only workaround might be to change
the source code 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 rebuild the libiostr.a.  Warning: this is also an untested one. :)


Regards,
Wang TianXing


- Raw text -


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