File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 1+ //123
2+
3+
4+
5+ 132
6+
7+
8+ 123
9+ //123
Original file line number Diff line number Diff line change 99# 建字典,保存对应的程序语言和后缀、单行注释符、多行注释符
1010import pdb
1111# 扩展其他程序可以在这里加入
12- lan_postfix = {'python' :'.py' }
13- lan_comment = {'python' :'#' }
12+ lan_postfix = {'python' :'.py' , 'c' : '.c' }
13+ lan_comment = {'python' :'#' , 'c' : '//' }
1414# 解决多行注释 如python中的'''
15- multi_comment = {'python' :'\' \' \' ' }
15+ multi_comment = {'python' :'\' \' \' ' , 'c' : '/*' }
1616
1717def stat_lines (file_name ,file_type ):
1818 import re
@@ -23,6 +23,7 @@ def stat_lines(file_name,file_type):
2323 for line in f .readlines ():
2424 # pdb.set_trace()
2525 line_next = line .lstrip ()
26+ # fuck a bug here in c multi comment
2627 if line_next .startswith (multi_comment [file_type ]):
2728 is_comment = not is_comment
2829 if not is_comment :
@@ -46,7 +47,7 @@ def main():
4647 for file in os .listdir ('.' ):
4748 if file .endswith ('.c' ) or file .endswith ('.cpp' ):
4849 # c_stat应该是一个字典,keys包括comment,content,null_line
49- pdb .set_trace ()
50+ # pdb.set_trace()
5051 c_stat = stat_lines (file ,'c' )
5152 c_sum_stat ['comment' ]+= c_stat ['comment' ]
5253 c_sum_stat ['content' ]+= c_stat ['content' ]
You can’t perform that action at this time.
0 commit comments