diff --git a/.gitignore b/.gitignore index 8748efe..8a48e02 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,10 @@ semantics # CodeHawk-C local configuration file ConfigLocal.py +# Ocaml binaries +chc/bin/*/canalyzer +chc/bin/*/parseFile + # Emacs *.py~ *.rst~ diff --git a/chc/cmdline/ParseManager.py b/chc/cmdline/ParseManager.py index d899cbb..ff1d095 100644 --- a/chc/cmdline/ParseManager.py +++ b/chc/cmdline/ParseManager.py @@ -6,7 +6,7 @@ # # Copyright (c) 2017-2020 Kestrel Technology LLC # Copyright (c) 2020-2022 Henny B. Sipma -# Copyright (c) 2023-2024 Aarno Labs LLC +# Copyright (c) 2023-2025 Aarno Labs LLC # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -290,11 +290,8 @@ def preprocess_file_with_gcc( def get_file_length(self, fname: str) -> int: """Return the number of lines in named file.""" - - with open(fname) as f: - for i, l in enumerate(f): - pass - return i + 1 + with open(fname, 'rb') as f: + return sum(1 for _ in f) def normalize_filename(self, filename: str) -> str: """Make filename relative to project directory (if in project @@ -456,8 +453,8 @@ def parse_with_ccommands( returncode = subprocess.call(command) print("\n" + ("-" * 80) + "\n\n") else: - returncopde = ( - subprocess.call(command, stdout=open(os.devnull, "w"))) + returncode = subprocess.call(command, stdout=open(os.devnull, "w")) + if returncode == 1: print("\n" + ("*" * 80)) print("Parsing error in " + cfilename)