X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: Date: Wed, 26 Dec 2007 10:52:27 +0100 From: "Juan Jose Garcia-Ripoll" To: cygwin AT cygwin DOT com, "ECL Mailing list" Subject: Lost characters with fputc/putc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: f5642adc9a18e214 Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hi, I am the maintainer of a free common lisp environment called ECL (http://ecls.sourceforge.net), which has been ported to cygwin long time ago. Recently I have noticed some problems with a code that basically does this - open a FILE with "w+b" - write a character to it - flush - close file The thing is that if I use fputc or putc to write the character, it is lost, while using fwrite() does just the right thing. I just show you the difference #if 1 if (fputc(c, fp) == EOF) /* version A */ io_error(strm); #else if (fwrite(&c, 1, 1, fp) < 1) /* version B */ io_error(strm); #endif No other file operation is performed on this file and I have not been able to simplify this to a smaller C program that shows this problem so far, but I am just comparing two big programs which only differ on these two lines. The same program just builds and runs fine on Linux, FreeBSD, OpenBSD, NetBSD, Mac OS X and Solaris, as well as with Mingw and MSVC, so I suspect there is something wrong with the cygwin port or the cygwin libraries exclusively. Help on solving this issue is most welcome. Otherwise I will simply have to abandon this port. Cheers, Juanjo P.S.: In case somebody wants to reproduce this, after building ECL with "./configure --prefix=$HOME" or something similar, and installing it, just do "ecl.exe -load file.lsp" where file.lsp contains the following lines. (si::system "rm -f foo") ; delete previous files (LET ((S (OPEN "foo" :direction :IO :if-does-not-exist :create))) (write-char #\h s) ; create a file foo with only a character (force-output s) (close s)) (si::system "cat foo; echo") ; type file to see whether character is present (si::system "ls -l foo*") -- Facultad de Fisicas, Universidad Complutense, Ciudad Universitaria s/n Madrid 28040 (Spain) http://juanjose.garciaripoll.googlepages.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/