File: renamer.rb

package info (click to toggle)
genometools 1.6.1%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 50,412 kB
  • sloc: ansic: 271,241; ruby: 30,339; python: 4,880; sh: 3,193; makefile: 1,194; perl: 219; pascal: 159; haskell: 37; sed: 5
file content (33 lines) | stat: -rwxr-xr-x 989 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env ruby

funcs = `nm lib/libgtunstable.so | egrep '^[^ ]{8} T [^g][^t][^_]' | egrep -v '^[^ ]{8} T (XML|md5|zError|zcalloc|zcfree|zlibCompileFlags|zlibVersion|lua|inflate|deflate|crc32|fsetkey|fencrypt|compress|adler32|_fini|_init|Xml)'`.split(/\n/)

funcs = funcs.collect { |f| f.split[2]}.sort{|a,b| b.length <=> a.length}

puts "#{funcs.length} functions to process"

funcs.each do |f|
  (funcs - [f]).each do |f2|
    if f.include?(f2) then
      puts "function list is not prefix-free: #{f} <-> #{f2}"
      #exit
    end
  end
end

funcs.each do |funcname|
  puts funcname
  files = `fgrep -Rl #{funcname} src/*`
  files.each_line do |file|
    fullpath = File.join(`pwd`.chomp,file).chomp
    puts fullpath
    buffer = ''
    File.open(fullpath) do |infile|
      buffer = infile.read
    end
    buffer.gsub!(/(^| |\(|\)|,)(([*!]+)?)#{funcname}([^;])/, "\\1\\2gt_#{funcname}\\4")
    File.open(fullpath, 'w') do |outfile|
      outfile.write(buffer)
    end
  end
end