(file)
| 117 | |
| 118 | |
| 119 | def doCFile(file): |
| 120 | count = 0 |
| 121 | f = open(file, 'r') |
| 122 | |
| 123 | incomment = False |
| 124 | |
| 125 | for line in f: |
| 126 | line = line.strip() |
| 127 | if incomment: |
| 128 | end = line.find('*/') |
| 129 | if end < 0: |
| 130 | continue |
| 131 | else: |
| 132 | incomment = False |
| 133 | line = line[end+2:] |
| 134 | if len(line) == 0: |
| 135 | continue |
| 136 | if line.startswith('//'): |
| 137 | continue |
| 138 | ind = line.find('/*') |
| 139 | if ind >= 0: |
| 140 | incomment = True |
| 141 | ind2 = line[ind+2:].find('*/') >= 0 |
| 142 | if ind2 >= 0: |
| 143 | incomment = False |
| 144 | if ind > 0 or ind2 < len(line)-2: |
| 145 | count += 1 |
| 146 | continue |
| 147 | count += 1 |
| 148 | return count |
| 149 | |
| 150 | |
| 151 | def doRegularFile(file, cmtStr): |
no test coverage detected