Skip to content

Instantly share code, notes, and snippets.

@henryscala
Created January 5, 2018 08:29
Show Gist options
  • Save henryscala/f2941c54dd10b6b0c7ffd228a2193561 to your computer and use it in GitHub Desktop.
Save henryscala/f2941c54dd10b6b0c7ffd228a2193561 to your computer and use it in GitHub Desktop.
a one-off script for cpp check result analysis
#!/usr/bin/env julia
function usage_exit()
println("$PROGRAM_FILE <cpp-check-result-file-name>")
exit()
end
#if length(ARGS) != 1
# usage_exit()
#end
#result_file_name=ARGS[1]
result_file_name="cpp_check_result_file_x.txt"
output_file_name="out.txt"
println("cpp check result file name is $result_file_name")
file=open(result_file_name)
lines = readlines(file)
close(file)
println("total lines $(length(lines))")
struct Entry
file_name
line_no
id
severity
msg
end
file_name_pattern = r"file=\"([^\"]*)\""
line_no_pattern = r"line=\"([^\"]*)\""
id_pattern = r"id=\"([^\"]*)\""
severity_pattern = r"severity=\"([^\"]*)\""
msg_pattern = r"msg=\"(.*)" #it is different with other patterns
function line_to_entry(line)
m=match(file_name_pattern,line)
file_name = m[1]
m=match(line_no_pattern,line)
line_no = m[1]
m=match(id_pattern,line)
id = m[1]
m=match(severity_pattern,line)
severity = m[1]
m=match(msg_pattern,line)
msg = m[1]
Entry(file_name, line_no, id, severity, msg)
end
entries = []
for line in lines
entry = line_to_entry(line)
push!(entries,entry)
end
println("total entries: $(length(entries))")
println("result put to $output_file_name")
file=open(output_file_name,"w")
for entry in entries
line = join([entry.file_name, entry.line_no, entry.id, entry.severity, entry.msg], "|")
write(file,"$line \n")
end
close(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment