Skip to content

Commit c52ac25

Browse files
committed
multi comment a bug here in c multi comment
1 parent 54fc423 commit c52ac25

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

burness/0007/1.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//123
2+
3+
4+
5+
132
6+
7+
8+
123
9+
//123

burness/0007/Program_lines_stat.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
# 建字典,保存对应的程序语言和后缀、单行注释符、多行注释符
1010
import 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

1717
def 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']

0 commit comments

Comments
 (0)