Hi all!
This patch solves the problem of binary files read/write under win32.
Practically forces the c runtime to binary-mode file translation as
default.
It is not the cleanest way but it is simple.
More info at: http://www.mingw.org/MinGWiki/index.php/binary
Cheers,
Javier Yebrin
Javier A. Yebrin wrote:
Finally I've got most of grass modules compiled under Mingw/Msys. Then
started to test them (first the raster modules, of course), and found
some strange behaviour depending on the studied raster. I've used the
Spearfish database and ran r.sum for all the present rasters (using
spot.image to define the current region). These are the results(first
line the raster name, then the stdout or
stderr):
aspect
WARNING: Fail of initial read of compressed file [aspect in PERMANENT]
You may see that the response changes from one type of raster to
another, whether it is compresed or not. I'm trying to debug this
module at the moment...
In the meanwhile, do you have any ideas?
The usual reason for that error message on Windows is that something is
performing CRLF->LF conversion, which is inappropriate for a binary file.
ISTR that the MinGW runtime includes a function to enable/disable the
conversions. You need to ensure that all I/O is done without conversions.
Hi all!
This patch solves the problem of binary files read/write under win32.
Practically forces the c runtime to binary-mode file translation as default.
It is not the cleanest way but it is simple.
More info at: http://www.mingw.org/MinGWiki/index.php/binary
Cheers,
Javier Yebrin
Isn't it better to use 'b' as mode for fdopen?
Do I understand it correctly that text files on windows will be also written with LF only so that a mapset can be accessed from UNIX without problems?
Could it happen that also files which should be opened as text will be opened as binary? For example text input for modules.
Radim
Javier A. Yebrin wrote:
Finally I've got most of grass modules compiled under Mingw/Msys. Then started to test them (first the raster modules, of course), and found some strange behaviour depending on the studied raster. I've used the Spearfish database and ran r.sum for all the present rasters (using spot.image to define the current region). These are the results(first line the raster name, then the stdout or
stderr):
aspect
WARNING: Fail of initial read of compressed file [aspect in PERMANENT]
You may see that the response changes from one type of raster to another, whether it is compresed or not. I'm trying to debug this module at the moment...
In the meanwhile, do you have any ideas?
The usual reason for that error message on Windows is that something is
performing CRLF->LF conversion, which is inappropriate for a binary file.
ISTR that the MinGW runtime includes a function to enable/disable the
conversions. You need to ensure that all I/O is done without conversions.
> This patch solves the problem of binary files read/write under win32.
> Practically forces the c runtime to binary-mode file translation as
> default.
> It is not the cleanest way but it is simple.
> More info at: http://www.mingw.org/MinGWiki/index.php/binary
Isn't it better to use 'b' as mode for fdopen?
By default MinGW will perform EOL translation for files which are
accessed via the POSIX compatibility functions (open, read, write),
not just for the ANSI stdio functions.
Do I understand it correctly that text files on windows will be also
written with LF only so that a mapset can be accessed from UNIX without
problems?
Could it happen that also files which should be opened as text will be
opened as binary? For example text input for modules.
All files should be opened as binary on all platforms. GRASS should do
its own EOL translation where necessary, so that files created on
Windows will work on Unix.
Hi all!
This patch solves the problem of binary files read/write under win32.
Practically forces the c runtime to binary-mode file translation as default.
It is not the cleanest way but it is simple.
More info at: http://www.mingw.org/MinGWiki/index.php/binary
Cheers,
Javier Yebrin
I have submitted the patch to CVS HEAD.
Can you summarize what is currently working on Windows/MinGW?
-----Original Message-----
From: Radim Blazek [mailto:blazek@itc.it]
Sent: Monday, May 16, 2005 9:52 AM
To: Javier A. Yebrin
Cc: grass5@grass.itc.it
Subject: Re: [GRASS5] Libgrass_gis on Mingw - open.c patch
Javier A. Yebrin wrote:
> Hi all!
> This patch solves the problem of binary files read/write
under win32.
> Practically forces the c runtime to binary-mode file translation as
> default. It is not the cleanest way but it is simple.
> More info at: http://www.mingw.org/MinGWiki/index.php/binary
>
> Cheers,
>
> Javier Yebrin
I have submitted the patch to CVS HEAD.
Can you summarize what is currently working on Windows/MinGW?
Hi,
I'll send the build errors as soon I get my work organized. I've started
with some real testing and recompilation. The current module undergoing this
test is r.average, which is presenting some problems because of system calls
to r.stats and r.recode.
I'm thinking of writing the r.stats/recode modules as functions inside
r.average. Do you think this is feasable?
Javier
-----Original Message-----
From: Glynn Clements [mailto:glynn@gclements.plus.com]
Sent: Tuesday, May 17, 2005 6:01 PM
To: Javier A. Yebrin
Cc: 'Hamish'; grass5@grass.itc.it
Subject: RE: [GRASS5] Libgrass_gis on Mingw - open.c patch
Javier A. Yebrin wrote:
> > how about a list of what doesn't build?
> >
> Something like:
>
> r.digit
> r.out.png
> r.out.ppm3
> r.out.tiff
> r.random
> r.region
> r.resamp.rst
> r.surf.fractal
> r.surf.gauss
> r.surf.idw2
> r.surf.random
> r.terraflow
> r.timestamp
> r.to.vect
>
> Some of them will not work because they need a GUI
(r.digit). Others
> maybe because of wrong configure flags (r.out.***).
Can you provide the actual build errors for the above modules?
I'll send the build errors as soon I get my work organized. I've started
with some real testing and recompilation. The current module undergoing this
test is r.average, which is presenting some problems because of system calls
to r.stats and r.recode.
Does the Windows runtime not support system(), or is r.average using
Unix-specific features?
I'm thinking of writing the r.stats/recode modules as functions inside
r.average. Do you think this is feasable?
Not in all cases. GRASS modules need to be able to execute other
programs.
I have written some replacements for system() in lib/gis/spawn.c.
However, these haven't been tested yet, and are currently only
implemented for Unix.
Ultimately, all calls to system() should be replaced with an interface
which can reasonably be implemented on all common platforms. For
Windows, this would involve CreateProcess() (or possibly _spawnl(), as
is used in G_system() in lib/gis/system.c).
Even on Unix, system() isn't a particularly robust mechanism for
invoking other programs. Primarily because it uses the shell, which
performs complex translations on the argument.
On Fri, May 20, 2005 at 10:48:47PM +0100, Glynn Clements wrote:
Javier A. Yebrin wrote:
> I'll send the build errors as soon I get my work organized. I've started
> with some real testing and recompilation. The current module undergoing this
> test is r.average, which is presenting some problems because of system calls
> to r.stats and r.recode.
Does the Windows runtime not support system(), or is r.average using
Unix-specific features?
A question:
Is it wrong to use G_system() within r.average instead of system()?
> > I'll send the build errors as soon I get my work organized. I've started
> > with some real testing and recompilation. The current module undergoing this
> > test is r.average, which is presenting some problems because of system calls
> > to r.stats and r.recode.
>
> Does the Windows runtime not support system(), or is r.average using
> Unix-specific features?
A question:
Is it wrong to use G_system() within r.average instead of system()?
On Unix, G_system() appears to be almost identical to system(), except
that signal handling in the child is slightly different.
system() ignores SIGINT and SIGQUIT in the parent but leaves them
unchanged in the child, while G_system() ignores them in the parent
but restores them to SIG_DFL in the child.
This only makes a difference if the program has changed the way that
those signals are handled from the default behaviour.
So, using G_system() shouldn't affect anything on Unix. I have no idea
whether it will make matters better or worse on Windows.