Create a gist now

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
require "FileUtils"
def is_asm?(str)
return true if str =~ /\.s\b/i
return true if str =~ /\.asm\b/i
return false
end
def is_c?(str)
return true if str =~ /\.c\b/
return false
end
if __FILE__ == $0
exit(1) if ARGV[0].nil?
tags = ARGV[0]
tags_org = tags+".org"
FileUtils.mv(tags, tags_org)
dst = File.open(tags, "w")
File.open(tags_org, "r") do |src|
src.each_line do |rl|
rl.force_encoding('UTF-8')
m = rl.scrub('?')
dst.write(rl)
if is_asm?(m) && m =~ /^_(.+$)/
rl.slice!(0)
dst.write(rl)
elsif is_c?(m)
dst.write('_'.concat(rl))
end
end
end
dst.close()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment