Skip to content

Instantly share code, notes, and snippets.

@kivikakk
Last active September 11, 2018 05:31
Show Gist options
  • Save kivikakk/27f36e2857de1af4f65c49196cd781a1 to your computer and use it in GitHub Desktop.
Save kivikakk/27f36e2857de1af4f65c49196cd781a1 to your computer and use it in GitHub Desktop.
extract and dedup suppressions in valgrind suppressions files
#!/usr/bin/env ruby
# frozen_string_literal: true
def parse_suppressions(data)
state = :idle
current = nil
result = []
data.lines.each do |line|
case state
when :idle
if line == "{\n"
current = []
state = :suppression
end
when :suppression
if line == "}\n"
result << current
current = nil
state = :idle
else
current << line
end
end
end
result
end
all = []
ARGV.each do |a|
all.concat parse_suppressions(File.read(a))
end
all.sort!
all.uniq!
all.each do |s|
puts '{'
puts s
puts '}'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment