[GRASS-dev] Re: [GRASS-SVN] r46717 -
grass/branches/releasebranch_6_4/scripts/v.build.all
Glynn Clements
glynn at gclements.plus.com
Tue Jun 28 18:14:00 EDT 2011
Hamish wrote:
> > > CMD="v.build map=${VECT}@${MAPSET}"
> > > - g.message "$CMD"
> > > + g.message message="$CMD"
> > > $CMD
> > > done
> MNeteler:
> > ... is this a needed change?
> ...
> > Most are without this parameter...
>
> Needed in this case because the string contains a '=', which
> confuses the parser.
That should really be fixed in the parser. Even in 6.x, an option name
cannot contain a space.
In 6.x, the test for whether an argument is an option finds the first
'=' in the string and checks that the immediately preceding character
is alphanumeric.
static int is_option(const char *string)
{
const char *p = strchr(string, '=');
if (!p)
return 0;
if (p == string)
return 0;
p--;
if (!strchr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", *p))
return 0;
return 1;
}
In 7.0, the test uses strspn() to find the length of the prefix
consisting entirely of (lower-case) alphanumeric characters and
underscores, then checks that the following character is an '=' and
that the prefix doesn't begin or end with an underscore:
static int is_option(const char *string)
{
int n = strspn(string, "abcdefghijklmnopqrstuvwxyz0123456789_");
return n > 0 && string[n] == '=' && string[0] != '_' && string[n-1] != '_';
}
It would be simple to back-port the 7.0 version to 6.x. Compatibility
requires adding the upper-case characters, which are allowed in option
names in 6.x (e.g. r.terraflow's STREAM_DIR= option). Technically, the
check for a leading underscore should be removed, but I'm not sure
that actually matters.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list