bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mingw-users] More patch 2.5.9 hacking


From: Eli Zaretskii
Subject: Re: [Mingw-users] More patch 2.5.9 hacking
Date: Fri, 24 Oct 2003 16:40:59 +0200

> From: Benjamin Riefenstahl <address@hidden>
> Date: Thu, 23 Oct 2003 12:52:15 +0200
> 
> The test case that was presented on mingw-users for that runtime
> problem did have CRLF at most lines and LF at one.

Text-mode I/O ought to have handled this.  It does in the DJGPP port.

Perhaps the problem is that fseek/ftell that MinGW uses don't work
well in text mode.  The DJGPP library has special code to handle this,
so this problem doesn't happen there.

> You are either on Unix or on DOS/Windows, and the runtime only needs
> to handle the native convention.

I don't think I understand this.  ``Normal'' C code is written with
the Unix EOL format in mind, so it assumes a single \n at the end of
each line.  Text-mode I/O was invented to make this happen
automagically on DOS/Windows platforms.

Unfortunately, most implementations of text I/O didn't go far enough
and didn't make sure that fseek/ftell work well in text mode.  So
programs that rely on the fact that ftell's results are consistent
with counts of characters returned by, say, getc, will generally break
on Windows.

The solution is to fix the library function or to use binary I/O (and
remove the \r characters manually) or to replace fseek/ftell with
equivalent code.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]