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


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/


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