[GRASS-dev] Re: [bug #5218] (grass) wingrass: creating new
location from startup screen with projection values fails
Hamish
hamish_nospam at yahoo.com
Tue Oct 24 23:53:09 EDT 2006
Glynn Clements wrote:
>
> Moritz Lennert wrote:
>
> > So, IIUC, this should work with cmd.exe which allows pdcurses code, but
> > it doesn't and fails with:
> >
> > > The procedure crashes after entering
>
> > > the one-line description of the new location with an error
> > > message: "the syntax of the command is not correct. LOCATION (test)
> > > NOT created" (translated from French).
> >
> > So, if this is not a pdcurses issue, what could be the problem ?
>
> make_location() uses system() with Unix commands:
>
> sprintf (buf, "mkdir '%s'/'%s'", gisdbase, location_name);
> if(system(buf)) return 0;
> sprintf (buf, "mkdir '%s'/'%s'/'%s'", gisdbase, location_name, mapset);
> if(system(buf)) return 0;
>
> [snip]
>
> sprintf (buf, "echo '%s' > '%s'/'%s'/'%s'/MYNAME", myname, gisdbase, location_name, mapset);
> system(buf);
>
> On a native Windows version, system() will use cmd.exe to execute
> commands, not /bin/sh.
>
> Windows has native versions of mkdir and echo. The native mkdir won't
> like being passed Unix filenames, as it treats / as indicating
> options:
>
> C:\>mkdir /foo
> The syntax of the command is incorrect.
>
> Fortunately, this bug shoud be quite simple to fix: use the mkdir()
> function rather than using system() to run the mkdir command. Could
> someone try the attached patch?
>
> Unfortunately, GRASS has a lot of this sort of stuff - using system()
> to run commands rather than using functions; probably because the
> author knew about the command but didn't know about the function. I've
> even seen system("rm ...") used to delete files.
>
> Finding (and fixing) all of the Unix-specific system() calls will be a
> large part of getting a native Windows version of GRASS to work.
grass63$ grep -rI mkdir * | grep sprintf
gem/reg_entries.c: sprintf ( str, "mkdir --verbose %s/etc/dm/gem-entries ; cp -vf ../entries-gisman %s/etc/dm/gem-entries/%s ; \
gem/reg_entries.c: sprintf ( str, "mkdir %s/etc/dm/gem-entries &> %s ; cp -f ../entries-gisman %s/etc/dm/gem-entries/%s &> %s ; \
gem/reg_entries.c: sprintf ( str, "mkdir --verbose -p %s/etc/gm/Xtns ; cp -fv ../entries-gisman2 %s/etc/gm/Xtns/%s.gem ; ",
gem/reg_entries.c: sprintf ( str, "mkdir -p %s/etc/gm/Xtns ; cp -f ../entries-gisman2 %s/etc/gm/Xtns/%s.gem ; ",
lib/init/mke_loc.c: sprintf (buf, "mkdir '%s'/'%s'", gisdbase, location_name);
lib/init/mke_loc.c: sprintf (buf, "mkdir '%s'/'%s'/'%s'", gisdbase, location_name, mapset);
lib/init/mke_mapset.c: sprintf(buffer,"mkdir '%s'/'%s'",location, mapset) ;
$ grep -rI mkdir * | grep system
raster/r.le/r.le.setup/main.c: G_system("mkdir r.le.para");
raster/r.le/r.le.patch/main.c: G_system("mkdir r.le.out");
raster/r.le/r.le.pixel/main.c: G_system("mkdir r.le.out");
Hamish
More information about the grass-dev
mailing list