diff options
author | Neil Moore <neil@s-z.org> | 2014-05-03 01:41:26 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2014-05-03 01:41:26 -0400 |
commit | c0af4134ef13c309b8fa84fa44aad751aa297de6 (patch) | |
tree | 12ec966e951c095ef5baeccce156f6fa6b3a40c6 /crawl-ref/source/util | |
parent | 57c744dcba1df6e4ae983c0040fd91de84314047 (diff) | |
download | crawl-ref-c0af4134ef13c309b8fa84fa44aad751aa297de6.tar.gz crawl-ref-c0af4134ef13c309b8fa84fa44aad751aa297de6.zip |
Add a comment to util/unbrace.
With a regexp to match things that need braces. Unfortunately, there are
some false positives, and we can't tell where the braces are supposed to go.
Diffstat (limited to 'crawl-ref/source/util')
-rwxr-xr-x | crawl-ref/source/util/unbrace | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crawl-ref/source/util/unbrace b/crawl-ref/source/util/unbrace index ac73a24fa2..9febd6dc62 100755 --- a/crawl-ref/source/util/unbrace +++ b/crawl-ref/source/util/unbrace @@ -26,6 +26,27 @@ for $f (@files) # Eliminate braces around one-line blocks. s&^( +(?:if|while|for|do|else)\b[^\n]*)\n +{\n( *[^/ }][^\n]*)\n +}$&$1\n$2&msg; + # Something like the following should match multi-line flow-control statements + # with missing braces, but: + # 1. it's slow (for example, on beam.cc); + # 2. it has false positives at the end of do-while loops; and + # 3. it's not clear how to determine where to put the braces. + # + # /( # Save multi-line statement with missing braces in \1. + # # Save indent of first line in \2 + # ^(\s+) (?:if|while|for|do|else)\b .*\n + # + # # Second line: not flow-control, greater indent. + # \2 \s+ (?! \s | (?:if|while|for|do|else)\b) .*\n + # + # # One or more lines of greater indent than the first. + # (?: \2 \s+ .*\n)+ + # ) + # # Next line falls outside the indentation of the first line: it has + # # either a smaller indent, or the same indent then a non-brace. + # (?! \2 [\s{]) + # /mgx; # No /s ! + # return is not a function, eliminate totally enclosing parentheses. # This part handles parenthese-less payloads. while (/^( *)return \(([^()]+)\);/sm) |