Loading ...
Sorry, an error occurred while loading the content.
 

Re: [ploticus] Re: Output to stdout should always be binary on Win32

Expand Messages
  • Bjoern Hoehrmann
    ... Be sure to flush the file handle before you do that, otherwise buffered data would be (at least with MSVC++) processed using the new mode which would
    Message 1 of 4 , Dec 21, 2004
      * vfun_00 wrote:
      >I concur that the fix should be more isolated - if you follow the
      >second approach (modifying grgd.c), this inconsistency will not occur
      >because the file only seems to contain GD-related graphics code (PNG,
      >JPEG, GIF etc - no text output). I think adding another #ifdef
      >directive to that file just after "if( stricmp filename, "stdout" )!
      >=0 ) {...}" conditional should restore the text mode to stdout (this
      >is after the image is written out), which will completely localize
      >this change:
      >
      >#ifdef WIN32
      > else _setmode( _fileno( stdout ), _O_TEXT );
      >#endif /* WIN32 */

      Be sure to flush the file handle before you do that, otherwise buffered
      data would be (at least with MSVC++) processed using the new mode which
      would potentially corrupt the binary data. Calling fflush(stdout) should
      avoid that.
      --
      Björn Höhrmann · mailto:bjoern@... · http://bjoern.hoehrmann.de
      Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
      68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Your message has been successfully submitted and would be delivered to recipients shortly.