|
6 | 6 | # |
7 | 7 | # Copyright (c) 2017-2020 Kestrel Technology LLC |
8 | 8 | # Copyright (c) 2020-2022 Henny B. Sipma |
9 | | -# Copyright (c) 2023-2024 Aarno Labs LLC |
| 9 | +# Copyright (c) 2023-2025 Aarno Labs LLC |
10 | 10 | # |
11 | 11 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
12 | 12 | # of this software and associated documentation files (the "Software"), to deal |
@@ -290,15 +290,8 @@ def preprocess_file_with_gcc( |
290 | 290 |
|
291 | 291 | def get_file_length(self, fname: str) -> int: |
292 | 292 | """Return the number of lines in named file.""" |
293 | | - |
294 | | - with open(fname) as f: |
295 | | - try: |
296 | | - for i, _l in enumerate(f): |
297 | | - pass |
298 | | - except UnicodeDecodeError as e: |
299 | | - chklogger.logger.warning("Unable to read %s: %s", fname, str(e)) |
300 | | - i = -1 |
301 | | - return i + 1 |
| 293 | + with open(fname, 'rb') as f: |
| 294 | + return sum(1 for _ in f) |
302 | 295 |
|
303 | 296 | def normalize_filename(self, filename: str) -> str: |
304 | 297 | """Make filename relative to project directory (if in project |
@@ -460,8 +453,8 @@ def parse_with_ccommands( |
460 | 453 | returncode = subprocess.call(command) |
461 | 454 | print("\n" + ("-" * 80) + "\n\n") |
462 | 455 | else: |
463 | | - returncopde = ( |
464 | | - subprocess.call(command, stdout=open(os.devnull, "w"))) |
| 456 | + returncode = subprocess.call(command, stdout=open(os.devnull, "w")) |
| 457 | + |
465 | 458 | if returncode == 1: |
466 | 459 | print("\n" + ("*" * 80)) |
467 | 460 | print("Parsing error in " + cfilename) |
|
0 commit comments