diff options
author | Neil Moore <neil@s-z.org> | 2013-11-15 17:15:13 -0500 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-11-15 17:22:58 -0500 |
commit | b65bf4d5198c19095e3084a88983680df19ec5ee (patch) | |
tree | e02996cadfe2fb30ebd34192752432aed3988c71 /crawl-ref/source/util/unbrace | |
parent | 0de37655ef7d25310da16ed582987b21b138af47 (diff) | |
download | crawl-ref-b65bf4d5198c19095e3084a88983680df19ec5ee.tar.gz crawl-ref-b65bf4d5198c19095e3084a88983680df19ec5ee.zip |
Handle more return() forms in util/unbrace
In particular, we now handle cases where there was a second-level
parenthesis at the beginning or end of the outer parentheses, and
also where the outer parentheses contain more than one parenthesised
subexpression.
Also, take advantage of /x and format the RE a little more nicely.
Diffstat (limited to 'crawl-ref/source/util/unbrace')
-rwxr-xr-x | crawl-ref/source/util/unbrace | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crawl-ref/source/util/unbrace b/crawl-ref/source/util/unbrace index a0eb3981e8..7cff755dde 100755 --- a/crawl-ref/source/util/unbrace +++ b/crawl-ref/source/util/unbrace @@ -29,11 +29,17 @@ for $f (grep /\.(cc|h)$/, split /\n/, `git ls-files`) # return (x) where x contains parentheses. # Looks like no one told Larry Wall properties of regular expression, # including the part where they can't do arbitrarily nested parentheses. - while (/^(\ *)return\ \( ([^()]++) (\( (?: [^()]++ | (?3) )* \)) ([^()]++)\);/sxm) + while (/^(\s*)return\s+ + \(( + (?: [^()]*+ + (\( (?: [^()]++ | (?3) )* \)) + )+ + [^()]*+ + )\);/sxm) { my $prev = "$`$1return "; my $next = ";$'"; - my $cur = "$2$3$4"; + my $cur = "$2"; $cur =~ s/\n /\n/sg; $_ = "$prev$cur$next"; } |