delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/12/26/04:59:33

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <c159f9ab0712260152m1f7e7d95m633468367551470d@mail.gmail.com>
Date: Wed, 26 Dec 2007 10:52:27 +0100
From: "Juan Jose Garcia-Ripoll" <jjgarcia AT users DOT sourceforge DOT net>
To: cygwin AT cygwin DOT com, "ECL Mailing list" <ecls-list AT lists DOT sourceforge DOT net>
Subject: Lost characters with fputc/putc
MIME-Version: 1.0
X-Google-Sender-Auth: f5642adc9a18e214
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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/

- Raw text -


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