Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ryochack
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryochack/af640f2865d3f9ff9057 to your computer and use it in GitHub Desktop.
Save ryochack/af640f2865d3f9ff9057 to your computer and use it in GitHub Desktop.
#!/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