On Mon, Aug 10, 2015 at 05:12:54PM +0000, David Holland wrote:
> On Sun, Aug 09, 2015 at 01:06:30AM +0200, Aymeric Vincent wrote:
>  > David Holland <dholland-sourcechan...@netbsd.org> writes:
>  > 
>  > >  > Fix bracket expressions by moving '-' to the end of them. GNU awk 
> choked.
>  > >
>  > > Front is safer. fwiw.
>  > 
>  > OK, I moved them to the front, together with '_' because it felt awkward
>  > to separate the separators. Out of curiosity, is it "safer" just because
>  > it is more robust to future additions to the expression or is it
>  > actually "safer" even if the expression is left as is?
> 
> It's safer in the sense that a broken regexp parser is unlikely to
> accidentally treat the first character of a character set as the
> middle - in a range; but if the last character is - it might interpret
> the second-last character, the -, and closing ] as a range, with
> unfortunate results. It is not very likely; but stranger things have
> happened, and it doesn't help that regexp tools have a long-standing
> culture of not complaining about invalid regexp syntax.
> 
> anyway it's a very minor point.

It is also less likely to go wrong when someone adds another character.

        David

-- 
David Laight: da...@l8s.co.uk

Reply via email to