[Top][All Lists]

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

Re: More re odditie [Was: regular expressions that match nothing]

From: phs
Subject: Re: More re odditie [Was: regular expressions that match nothing]
Date: Thu, 16 May 2019 12:59:19 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Hi Mattias,

On 2019/05/16 11:29, Mattias Engdegård wrote:
> 16 maj 2019 kl. 08.57 skrev phs <address@hidden>:

> Actually this one is documented:
>   For historical compatibility, special characters are treated as ordinary
>   ones if they are in contexts where their special meanings make no sense.
>   For example, `*foo' treats `*' as ordinary since there is no preceding
>   expression on which the `*' can act.

I missed that. Thanks for pointing it out.

> and in any case the 'correct' behaviour would be to signal a syntax error, 
> not repeat the empty string.

I'd rather read `*' as meaning "repeat the empty string", as with
`\(\)*', but this is a matter of taste, and historical compatibility is
very important.

BTW, can your scans of regexps tell if this compatibility is relied on a
lot? It would be safe to replace `*' and `+' with `\*' and `\+' where
this happens.  I've just grep'ed quickly through the code and only
noticed a risky use of "+" (and "[..]") in the definition of `term-word'
in term.el

> Thanks for reporting it, and you are right, that's a (known) bug in rx.

When rx is fixed, I suggest we add the following extra tests (see patch)


Attachment: more-rx-tests.patch
Description: Text document

reply via email to

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