diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2020-03-22 00:12:21 -0700 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2020-03-22 00:37:31 -0700 |
commit | 57119dd561418c917b885db5f5af7f129a96d1ec (patch) | |
tree | a76be1c70bd4ac3a9fc1c36a0bddebae0301cc17 /tool | |
parent | 0bed561f6a8cd5696b182ae361e2bbbfe9fa6df1 (diff) | |
download | ruby-57119dd561418c917b885db5f5af7f129a96d1ec.tar.gz |
Expand tabs for rb_mjit_header.h
I can't live without this when using gdb or perf report.
See also: [Misc #16112]
Diffstat (limited to 'tool')
-rw-r--r-- | tool/run_without_tabs.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tool/run_without_tabs.rb b/tool/run_without_tabs.rb new file mode 100644 index 0000000000..0ac21f90ce --- /dev/null +++ b/tool/run_without_tabs.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true +# This is a script to run a command in ARGV, expanding tabs in some files +# included by vm.c to normalize indentation of MJIT header. +# +# Note that preprocessor of GCC converts a hard tab to one spaces, where +# we expect it to be shown as 8 spaces. To obviate this script, we need +# to convert all tabs to spaces in these files. + +require 'fileutils' + +srcdir = File.expand_path('..', __dir__) +targets = Dir.glob(File.join(srcdir, 'vm*.*')) +sources = {} +mtimes = {} + +targets.each do |target| + sources[target] = File.read(target) + mtimes[target] = File.mtime(target) + + expanded = sources[target].gsub(/^\t+/) { |tab| ' ' * 8 * tab.length } + if sources[target] == expanded + puts "#{target.dump} has no hard tab indentation. This should be ignored in tool/run_without_tabs.rb." + end + File.write(target, expanded) + FileUtils.touch(target, mtime: mtimes[target]) +end + +result = system(*ARGV) + +targets.each do |target| + File.write(target, sources.fetch(target)) + FileUtils.touch(target, mtime: mtimes.fetch(target)) +end + +exit result |