Last active
September 11, 2018 05:31
-
-
Save kivikakk/27f36e2857de1af4f65c49196cd781a1 to your computer and use it in GitHub Desktop.
extract and dedup suppressions in valgrind suppressions files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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