delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/02/07/04:34:36

Date: Sun, 7 Feb 1999 11:30:49 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: DJ Delorie <dj AT delorie DOT com>
cc: djgpp-workers AT delorie DOT com, Matecka Lubomir <matecka AT hron DOT fei DOT tuke DOT sk>
Subject: Re: [matecka AT hron DOT fei DOT tuke DOT sk: 'putc' problem]
In-Reply-To: <199902031624.LAA25599@envy.delorie.com>
Message-ID: <Pine.SUN.3.91.990207112942.15342D-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

> there is some problem with 'putc' in djgpp v2.01. it should only return
> EOF when error occured, but it also returns EOF (= -1) when first
> character sent to created file is 0xff

This is because the character is not casted to unsigned char in the
call to _flsbuf.  To be corrected in the next release.

If you have library sources, then apply the following patch to the
file include/libc/file.h, recompile putc.c (and fputc.c), put them
into libc.a, and the problem should go away.

*** include/libc/file.h~0	Sun Sep  7 21:08:12 1997
--- include/libc/file.h	Sat Feb  6 11:10:46 1999
***************
*** 49,55 ****
        p->_cnt--;
        return((unsigned char)(*(p->_ptr++)=(unsigned char)x));
     }
!    return(_flsbuf(x,p));
  }
  
  static __inline__ int __is_text_file(FILE *const p)
--- 49,55 ----
        p->_cnt--;
        return((unsigned char)(*(p->_ptr++)=(unsigned char)x));
     }
!    return(_flsbuf((unsigned char)x,p));
  }
  
  static __inline__ int __is_text_file(FILE *const p)

- Raw text -


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