Fix up tool/auto-style.rb

Do not clear the commit-wide flags per file.
This commit is contained in:
Nobuyoshi Nakada 2025-06-17 23:06:41 +09:00
parent 8faa32327b
commit c99cb62da8
No known key found for this signature in database
GPG key ID: 3582D74E1FEE4465

View file

@ -233,11 +233,10 @@ 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 = src != orig
indent0 = true if src.gsub!(/^\w+\([^(\n)]*?\)\K[ \t]*(?=\{$)/, "\n")
indent0 = true if src.gsub!(/^([ \t]*)\}\K[ \t]*(?=else\b)/, "\n" '\1')
indent0 = true if src.gsub!(/^[ \t]*\}\n\K\n+(?=[ \t]*else\b)/, '')
indent ||= indent0
end
if trailing0 or eofnewline0 or expandtab0 or indent0