Subject: Re: bug#10733: 24.0.93; w32 file truncation

From: Óscar Fuentes <[email-masked]>
Date: Mon, 06 Feb 2012 17:16:52 +0100

Óscar Fuentes <[email-masked]> writes:

> I bet it is a bug on the CRT (the stat call that retrieves the file
> size, to be precise). Maybe it is a MinGW thing.

No, it is an Emacs thing. `stat' is defined in lib-src/ntlib.c,
overriding the MSVCRT implementation, which accounts for symlinks, while
Emacs' does not.

Before the definition of `stat' on lib-src/ntlib.c there is this
comment:

/* We need this because nt/inc/sys/stat.h defines struct stat that is
   incompatible with the MS run-time libraries.  */

That looks like an understatement. Actually, we need our own stat
function and struct because the `struct stat' that Emacs uses is
incompatible with the one defined in MSVCRT, right?

The obvious fix does not seem difficult, although ugly and
verbose. OTOH, I'll like to remove the Emacs reimplementation of `stat',
but that looks more cumbersome. How much time we have until the release?

BTW, the obvious fix may require some care for not breaking Emacs
support on MS Windows versions prior to XP. We still support Windows 9x,
don't we?