5 branchTaken0
, branchNot0
= 0,0
10 if sys
.argv
[1] == '-b':
14 if sys
.argv
[1] == '-f':
18 def show(name
, none
, some
):
21 print name
, none
, some
, "%.02f"%(100*(float(some
)/(some
+none
)))
24 file_args
= sys
.argv
[1:]
28 files
.extend(os
.path
.join(fn
, f
) for f
in os
.listdir(fn
))
33 none
= some
= branchTaken
= branchNot
= 0
35 for line
in open(fn
, 'r'):
36 m
= re
.match(r
'^[^:]*:([^:]*):(.*)', line
)
38 body
= m
.group(2).rstrip()
39 lineno
= m
.group(1).strip()
43 m
= re
.match(r
'^([A-Za-z_][A-Za-z0-9_]*)(?:, *)?\(', body
)
45 inFunc
= "%s:%s %s" %(fn
,lineno
,m
.group(1))
48 show(inFunc
, none
, some
)
51 if re
.match(r
'^ *###', line
):
53 elif re
.match(r
'^ *\d', line
):
56 m
= re
.match(r
'^branch.*taken (\d+)%', line
)
58 if int(m
.group(1)) == 0:
65 branchTaken0
+= branchTaken
66 branchNot0
+= branchNot
70 if branchTaken
or branchNot
:
71 show(fn
, branchNot
, branchTaken
)
77 if branchTaken0
or branchNot0
:
78 show("TOTAL", branchNot0
, branchTaken0
)
81 show("TOTAL", none0
, some0
)