[GRASS-dev] Re: [GRASS-user] g.xlist/g.xremove addons (C version of g.mlist/g.mremove)

Glynn Clements glynn at gclements.plus.com
Sun Sep 7 16:21:28 EDT 2008


Hamish wrote:

> > Or we can make the C versions use basic REs for -r and add e.g. 
> > -e for extended REs.
> 
> I think it would be better to offer just one regex flag.

With the existing scripts, -r uses basic regexps, so making the C
versions use extended regexps instead would break compatibility. But
extended regexps offer important additional functionality, (|, +, and
?) which cannot be replicated using only basic regexps.

Note that the "basic" regexps provided by regcomp() are those provided
by sed. grep provides an intermediate form, where \|, \+ and \? 
provide the same functionality as |, + and ? in extended regexps, but
without significantly breaking compatibility (|, + and ? are ordinary
characters in basic REs, so you wouldn't ordinarily escape them).

If regcomp()'s basic REs provided the grep extensions, there wouldn't
be any real need to support extended REs, as the two differ only in
syntax (i.e. whether characters need to be escaped with \ to gain
their special meaning or to lose it).

But they don't. So it's a choice between:

a) omitting useful functionality (-r uses basic REs),
b) breaking compatibility (-r uses extended REs), or
c) providing both compatibility (-r) and functionality (-e).

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


More information about the grass-dev mailing list