Skip to content

Commit 4b608d3

Browse files
authored
Update remove-comments.py
1 parent 3abd50d commit 4b608d3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/remove-comments.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ def removeComments(self, source):
9393
if not in_block:
9494
newline = []
9595
while i < len(line):
96-
if line[i:i+2] == '/*' and not in_block:
96+
if not in_block and i+1 < len(line) and line[i:i+2] == '/*':
9797
in_block = True
9898
i += 1
99-
elif line[i:i+2] == '*/' and in_block:
99+
elif in_block and i+1 < len(line) and line[i:i+2] == '*/':
100100
in_block = False
101101
i += 1
102-
elif not in_block and line[i:i+2] == '//':
102+
elif not in_block and i+1 < len(line) and line[i:i+2] == '//':
103103
break
104104
elif not in_block:
105105
newline.append(line[i])

0 commit comments

Comments
 (0)