From 9eac40222dd09b5cb95e2b0245d3f835e15d40fa Mon Sep 17 00:00:00 2001 From: Ricardo Baratto Date: Wed, 14 May 2025 20:42:35 -0400 Subject: [PATCH 1/3] fix typo in return code variable name --- chc/cmdline/ParseManager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chc/cmdline/ParseManager.py b/chc/cmdline/ParseManager.py index d899cbb..7c3daf6 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 @@ -456,8 +456,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) From 96ae7b3501df1733b4e20ec7003686956144be6c Mon Sep 17 00:00:00 2001 From: Ricardo Baratto Date: Wed, 14 May 2025 20:43:50 -0400 Subject: [PATCH 2/3] fix how we count line numbers if the file is not encoded properly, reading it as text will raise an exception. this opens the file in binary mode, and uses a more compact way to read the number of lines --- chc/cmdline/ParseManager.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/chc/cmdline/ParseManager.py b/chc/cmdline/ParseManager.py index 7c3daf6..ff1d095 100644 --- a/chc/cmdline/ParseManager.py +++ b/chc/cmdline/ParseManager.py @@ -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 From b9454e911ea6700a8e6f95f475c25f3926a4bdf7 Mon Sep 17 00:00:00 2001 From: Ricardo Baratto Date: Wed, 14 May 2025 20:46:21 -0400 Subject: [PATCH 3/3] have git ignore ocaml binaries --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) 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~