Skip to content

Commit c99cb62

Browse files
committed
Fix up tool/auto-style.rb
Do not clear the commit-wide flags per file.
1 parent 8faa323 commit c99cb62

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

tool/auto-style.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,10 @@ def with_clean_env
233233

234234
if File.fnmatch?("*.[ch]", f, File::FNM_PATHNAME) &&
235235
!DIFFERENT_STYLE_FILES.any? {|pat| File.fnmatch?(pat, f, File::FNM_PATHNAME)}
236-
orig = src.dup
237-
src.gsub!(/^\w+\([^(\n)]*?\)\K[ \t]*(?=\{$)/, "\n")
238-
src.gsub!(/^([ \t]*)\}\K[ \t]*(?=else\b)/, "\n" '\1')
239-
src.gsub!(/^[ \t]*\}\n\K\n+(?=[ \t]*else\b)/, '')
240-
indent = indent0 = src != orig
236+
indent0 = true if src.gsub!(/^\w+\([^(\n)]*?\)\K[ \t]*(?=\{$)/, "\n")
237+
indent0 = true if src.gsub!(/^([ \t]*)\}\K[ \t]*(?=else\b)/, "\n" '\1')
238+
indent0 = true if src.gsub!(/^[ \t]*\}\n\K\n+(?=[ \t]*else\b)/, '')
239+
indent ||= indent0
241240
end
242241

243242
if trailing0 or eofnewline0 or expandtab0 or indent0

0 commit comments

Comments
 (0)