This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Lost characters with fputc/putc


I am the maintainer of a free common lisp environment called ECL
(, 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 */
		if (fwrite(&c, 1, 1, fp) < 1) /* version B */

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.



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)

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]