From 3eaab07b0b7384eace11c48bedd62bae265220ee Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 28 Jul 2019 20:28:04 +0300 Subject: [PATCH] top_evil_rs.py: remove comments before counting For example, constants.rs is completely safe now, but has "free()" in the comments. --- src/top_evil_rs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/top_evil_rs.py b/src/top_evil_rs.py index 21a4820cc..0128f400d 100755 --- a/src/top_evil_rs.py +++ b/src/top_evil_rs.py @@ -2,12 +2,14 @@ import os +import re if __name__ == "__main__": filestats = [] for fn in os.listdir(): if fn.endswith(".rs"): s = open(fn).read() + s = re.sub(r'(?m)///.*$', '', s) # remove comments unsafe = s.count("unsafe") free = s.count("free(") gotoblocks = s.count("current_block =")