[GRASS-dev] select issue with wingrass
Moritz Lennert
mlennert at club.worldonline.be
Mon Nov 19 05:01:28 EST 2007
On 19/11/07 02:49, Glynn Clements wrote:
> Moritz Lennert wrote:
>
>> > Ah; the reason it's been working so far is that both lib/gis/gui.tcl
>> > and gui/tcltk/gis.m/gm.tcl set them, e.g.:
>> >
>> > if {[catch {set env(GISDBASE) [exec g.gisenv get=GISDBASE]} error]} {
>> >
>> > Any other code which uses select.tcl will need to do likewise.
>> >
>> > Use of env() is less than ideal (there's already enough confusion
>> > between GRASS variables and environment variables), but using separate
>> > variables would require changing a lot of "global" statements.
>>
>> Changing above line to
>>
>> if {[catch {set env(GISDBASE) [exec g.dirseps -g [exec g.gisenv get=GISDBASE]]} error]} {
>>
>> in lib/gis/gui.tcl seems to work for me. Can I commit ?
>>
>> Should I also change this in gui/tcltk/gis.m/gm.tcl ?
>
> Have you tried "file normalize"? If that works, it's preferable to
> spawning g.dirseps.
>
I actually did try it (thought I had written that, but I guess it was
too late for my brain). I don't think file normalize is what we need.
Apparently, when confronted with a path name it doesn't recognize it
"normalizes" it by appending it to the path of pwd:
so
C:\>tclsh
% file normalize c:\grassdata
C:/GRASSDATA
but
C:\TEST>tclsh
% file normalize c:\grassdata
c:/TEST/grassdata
% file normalize c:/grassdata
C:/GRASSDATA
This might explain why the select window works with
GISDBASE=c:\grassdata when pwd is c:\.
BTW, I think I have found the culprit for having c:\grassdata in the
.grassrc6 file: it seems to be the text mode startup. It does not
transform c:\grassdata into c:/grassdata before writing .grassrc6 as
does the tcltk startup.
Could this be the problem (I don't really understand what it does in
detail). It's from lib/init/set_data.c (line 125ff):
#ifdef __MINGW32__
if (*gisdbase == '/')
{
char tmp[200], *p;
sprintf(tmp, "%s", getenv("WD"));
for(p=tmp+strlen(tmp); --p>=tmp && *p=='\\';);
for(; --p>=tmp && *p!='\\';);
for(; --p>=tmp && *p=='\\';);
*(p+1) = 0;
for(p=tmp; *p; p++)
if(*p == '\\')
*p = '/';
strcat(tmp, gisdbase);
strcpy(gisdbase, tmp);
}
if (!gisdbase[1] || gisdbase[1] != ':')
#else
Moritz
More information about the grass-dev
mailing list