This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deprecate spaces/comments in some regex tokens
authorKarl Williamson <public@khwilliamson.com>
Tue, 23 Apr 2013 19:39:35 +0000 (13:39 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 2 May 2013 19:39:00 +0000 (13:39 -0600)
commit000947ada5b027f394ee63b5166df8c06b64a74e
treee6b3d6d7078fea713cdde8a314b7ea3adbb25298
parenteb5682978c85adb0d49e6aef177310cfe054d2aa
Deprecate spaces/comments in some regex tokens

This commit deprecates having space/comments between the first two
characters of regular expression forms '(*VERB:ARG)' and '(?...)'.
That is, the '(' should be immediately be followed by the '*' or '?'.
Previously, things like:

   qr/((?# This is a comment in the middle of a token)?:foo)/

were silently accepted.

The problem is that during regex parsing, the '(' is seen, and the input
pointer advanced, skipping comments and, under /x, white space, without
regard to whether the left parenthesis is part of a bigger token or not.
S_reg() handles the parsing of what comes next in the input, and it
just assumes that the first character it sees is the one that
immediately followed the input parenthesis.

Since the parenthesis may or may not be a part of a bigger token, and
the current structure of handling things, I don't see an elegant way to
fix this.  What I did is flag the single call to S_reg() where this
could be an issue, and have S_reg check for for adjacency if the
parenthesis is part of a bigger token, and if so, warn if not-adjacent.
pod/perldiag.pod
pod/perlre.pod
regcomp.c
t/re/reg_mesg.t