diff options
author | Jean Boussier <[email protected]> | 2025-06-17 11:51:17 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-06-17 15:28:05 +0200 |
commit | 4cb0205f51c1c49270027c41f539e8d120a13b6c (patch) | |
tree | abb632452bafd4ec1d174bc10cb192879aa699ed | |
parent | 0933400f451813f08671dd02462f1a718e99d564 (diff) |
Handle false positives in tool/auto-style.rb
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13626
-rwxr-xr-x | tool/auto-style.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tool/auto-style.rb b/tool/auto-style.rb index 25055ace7d..7e66f376ec 100755 --- a/tool/auto-style.rb +++ b/tool/auto-style.rb @@ -233,10 +233,11 @@ edited_files = files.select do |f| if File.fnmatch?("*.[ch]", f, File::FNM_PATHNAME) && !DIFFERENT_STYLE_FILES.any? {|pat| File.fnmatch?(pat, f, File::FNM_PATHNAME)} + orig = src.dup src.gsub!(/^\w+\([^(\n)]*?\)\K[ \t]*(?=\{$)/, "\n") src.gsub!(/^([ \t]*)\}\K[ \t]*(?=else\b)/, "\n" '\1') src.gsub!(/^[ \t]*\}\n\K\n+(?=[ \t]*else\b)/, '') - indent = indent0 = true + indent = indent0 = src != orig end if trailing0 or eofnewline0 or expandtab0 or indent0 |