[Top][All Lists]

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

Re: Emacs regexp scan (Sep 29)

From: Paul Eggert
Subject: Re: Emacs regexp scan (Sep 29)
Date: Sat, 5 Oct 2019 11:52:19 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 10/5/19 9:59 AM, Lars Ingebrigtsen wrote:
what's so special about regexps that "[-+]" has to be mass-rewritten
as "[+-]"?

There's no mass rewriting here. I changed regexps near other (more-complicated) regexps that didn't put "-" at the end, regexps that were in fact incorrect evidently due to their authors' confusion. Using a consistent style in a trouble-prone area can help avoid future bugs when someone changes that code in the future.

If you add regexps to Emacs in the future, I suggest putting literal "-" at the end of bracket expressions, since that's the style recommended in the manual for a solid technical reason, namely to avoid all-too-common confusion in this area that causes real bugs. That is why the regexp scanner flags these "-" instances: it finds real bugs, some of which were fixed in the most-recent patch in this area. Of course there's a cost-benefit analysis to doing lint checking like this. In this particular case, the number of actual bugs and the simplicity of pacifying the lint checker mean that the benefits of using the checker outweigh the cost.

That being said, there's no pressing need to go through all the Emacs code and rewrite [-+] to [+-], just as there's no pressing need to go through all the Emacs code and remove the useless and distracting "register" keyword.

reply via email to

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