bug-m4
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GNU m4 1.4.16] Shy groups in regular expressions


From: Eric Blake
Subject: Re: [GNU m4 1.4.16] Shy groups in regular expressions
Date: Mon, 12 Mar 2012 10:24:48 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1

On 03/11/2012 05:06 PM, Tim Landscheidt wrote:
> Hi,
> 
> the documentation for regexp says:
> 
> |  -- Builtin: regexp (STRING, REGEXP, [REPLACEMENT])
> |      Searches for REGEXP in STRING.  The syntax for regular expressions
> |      is the same as in GNU Emacs, which is similar to BRE, Basic
> |      Regular Expressions in POSIX.  *Note Syntax of Regular
> |      Expressions: (emacs)Regexps.  Support for ERE, Extended Regular
> |      Expressions is not available, but will be added in GNU M4 2.0.
> 
> |      [...]
> 
> However:
> 
> | address@hidden ~]$ m4
> | regexp(`abc', `\(b\)')
> | 1
> | regexp(`abc', `\(?:b\)')
> | -1
> | address@hidden ~]$
> 
> Emacs's documentation on "Backslash in Regular Expressions"
> that is linked from m4's info file doesn't seem to imply
> that shy groups were in fact ERE.  So is this a bug?

Thanks for the report.

Shy groups are not part of glibc's re_compile_pattern, and are therefore
not a part of GNU m4.  M4 is only using glibc's implementation with a
flags of 0, which happens to be emacs-compatible, and not extensions
such as shy groups that have later been added to just emacs beyond what
glibc provides.

If I could ever get more time to work on m4, there is a proposal for m4
2.0 to allow the user to have more control over which flavor of regex is
in use, rather than forcing things to glibc's re_compile_pattern with
the default flag settings.  It would be feasible to make m4 2.0 compile
against libpcre or other such extension mechanism, in order to also
allow for additional regex flavors with features such as shy groups.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]