[GRASS-dev] Re: testing native winGRASS

Glynn Clements glynn at gclements.plus.com
Fri May 18 14:13:44 EDT 2007


Glynn Clements wrote:

> > >> general/g.mapsets/set_path.c:65:    if (system (command) == 0)
> > >> strcpy (command, "g.mapsets -p mapset=") & other strcat calls
> > > 
> > > 	sprintf(mapset_arg, "mapset=%s", mapset)
> > > 	G_spawn("g.mapsets", "g.mapsets", "-p", mapset_arg, <other args>, NULL);
> > 
> > As the different strcat calls are embedded in if-then checks, I imagine 
> > that we have to keep these checks and construct an array of <other args> ?
> 
> Ah. That will need to wait until G_spawn_ex() has been extended (or
> has a G_vspawn_ex() version).

I've added G_vspawn_ex(), which takes an argument array as
"const char **" instead of a variable-length argument list.

	extern int G_vspawn_ex(const char *command, const char **args);

The args array needs to be terminated by a NULL pointer.

You can also use SF_ARGVEC to embed an argument array in the middle of
an argument list or array, e.g.:

	const char *other_args[..];

	G_spawn_ex("g.mapsets", "g.mapsets", "-p", mapset_arg, SF_ARGVEC, other_args, NULL);

G_vspawn_ex(cmd, args) is essentially equivalent to:

	G_spawn_ex(cmd, SF_ARGVEC, args, NULL)

Also, the argument processing has been separated from the actual
spawning, so it should be easier to implement the MinGW version.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list