On 10 Jan 2003 at 9:58, Frank Heckenbach wrote:
What exactly is the difference?
See:
ftp://ftp3.sourceforge.net/pub/sourceforge/mingw/gcc-3.2.1-20021201-3-src.diff.gz
The Mingw patches change xm-mingw32.h to define DIR_SEPARATOR as "/", i.e., a forward slash instead of the Windows-standard backslash, and then modify gcc.c to convert the resulting forward slashes to backslashes in the "execute" function. The problem is that while WinNT/2K/XP treat forward and backslashes interchangeably, Win9x/ME do not. So an unmodified GPC+Mingw build uses "/" as DIR_SEPARATOR but does not have the patches to gcc.c carried over to gpc.c, and so passes forward slashes to Windows to execute gpc1, as, etc. This fails under Win9x/ME.
Can you add `WriteLn (FileHandle (f^))' there to see what happens?
Given:
repeat New (f); Reset (f^, ParamStr (1)); WriteLn (FileHandle (f^)) until FileHandle (f^) >= 8;
...the program outputs "0" forever.
On 10 Jan 2003 at 16:21, Prof. A Olowofoyeku wrote:
In gcc-2.95.3.x, xm-mingw32.h contained these entries:
/* Even though we support "/", allow "" since everybody tests both. */ #ifdef TARGET_W9x /* This kludge must go, once we can get '/' to work on W9x */ #define DIR_SEPARATOR_2 '/' #define DIR_SEPARATOR '\' #else #define DIR_SEPARATOR '/' #define DIR_SEPARATOR_2 '\' #endif
Originally, xm-mingw32.h defined DIR_SEPARATOR as "\", i.e., a backslash. This is correct for the platform. However, as the Chief noted, this was subsequently changed to "/" for WinNT/2K/XP, while leaving "\" for Win9x/ME. This is very odd, because the directory separator has always been (and is today) a backslash on all versions of Windows. Moreover, why use a backslash on 9x/ME while using a forward slash on NT/2K/XP? The backslash will work on both sets of systems, so why go to the trouble of defining it differently for different Windows systems?
Finally, the current gcc-3.2.1 Mingw version defines DIR_SEPARATOR as "/" for all versions of Windows but then patches gcc.c to convert forward slashes to backslashes in "execute". Why do this instead of defining as "\" and being done with it?
I have no knowledge of the rationale, but I will point out that because NT/2K/XP treat backslashes and forward slashes equivalently, it is possible to have two different file paths refer to the same file, e.g., \dir\file and /dir/file would refer to the same file. There are places within gcc.c that determine if two paths are equivalent by doing a "strcmp", which would obviously fail with the above equivalence. See, for example, the 'g' case within "do_spec_1" and note the comment about 32 lines thereafter.
It appears as though the latest Mingw patches attempt to produce canonical file paths by always using forward slashes, i.e., so that "strcmp" would properly indicate equivalence. Then, to work around the 9x/ME behavior, forward slashes are converted to backslashes in "execute".
So, the suggestion I gave earlier would have worked if you added "-DTARGET_W9x" to the CFLAGS when compiling.
...And if I had been building with gcc-2.95.x. ;-)
However, removing the earlier entries seems to indicate that the Mingw guys consider that the Win9x problem has been solved.
It's "solved" in two parts: a change in xm-mingw32.h to use "/" as the DIR_SEPARATOR, and a change to gcc.c to change forward slashes to backslashes in "execute". It's the second part of this change that is not being picked up in gpc.c.
A short term solution would be to reverse the entries in xm-mingw32.h....
That allows GPC to execute gpc1, as, etc., but at the expense of "strcmp" failing for potentially equivalent file paths. As I noted, I don't know the ramifications of this, but I presume that the Mingw folks made the change for a reason other than pure perversity. ;-)
-- Dave