Skip to content

Commit c111d36

Browse files
committed
Merge branch 'master' into parsing
2 parents 9cfc6a0 + 5565f63 commit c111d36

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

.github/workflows/run_mypy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [pull_request, push]
55
jobs:
66
run_mypy:
77

8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
99

1010
steps:
1111
- uses: actions/checkout@v1

.github/workflows/run_pycodestyle.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [pull_request, push]
55
jobs:
66
run_pycodestyle:
77

8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
99

1010
steps:
1111
- uses: actions/checkout@v1

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ semantics
66
# CodeHawk-C local configuration file
77
ConfigLocal.py
88

9+
# Ocaml binaries
10+
chc/bin/*/canalyzer
11+
chc/bin/*/parseFile
12+
913
# Emacs
1014
*.py~
1115
*.rst~

chc/app/CApplication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# Copyright (c) 2017-2020 Kestrel Technology LLC
88
# Copyright (c) 2020-2022 Henny B. Sipma
9-
# Copyright (c) 2023-2024 Aarno Labs LLC
9+
# Copyright (c) 2023-2025 Aarno Labs LLC
1010
#
1111
# Permission is hereby granted, free of charge, to any person obtaining a copy
1212
# of this software and associated documentation files (the "Software"), to deal

chc/cmdline/ParseManager.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# Copyright (c) 2017-2020 Kestrel Technology LLC
88
# Copyright (c) 2020-2022 Henny B. Sipma
9-
# Copyright (c) 2023-2024 Aarno Labs LLC
9+
# Copyright (c) 2023-2025 Aarno Labs LLC
1010
#
1111
# Permission is hereby granted, free of charge, to any person obtaining a copy
1212
# of this software and associated documentation files (the "Software"), to deal
@@ -290,15 +290,8 @@ def preprocess_file_with_gcc(
290290

291291
def get_file_length(self, fname: str) -> int:
292292
"""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)
302295

303296
def normalize_filename(self, filename: str) -> str:
304297
"""Make filename relative to project directory (if in project
@@ -460,8 +453,8 @@ def parse_with_ccommands(
460453
returncode = subprocess.call(command)
461454
print("\n" + ("-" * 80) + "\n\n")
462455
else:
463-
returncopde = (
464-
subprocess.call(command, stdout=open(os.devnull, "w")))
456+
returncode = subprocess.call(command, stdout=open(os.devnull, "w"))
457+
465458
if returncode == 1:
466459
print("\n" + ("*" * 80))
467460
print("Parsing error in " + cfilename)

chc/cmdline/c_project/cprojectutil.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ def cproject_analyze_project(args: argparse.Namespace) -> NoReturn:
250250
loglevel: str = args.loglevel
251251
logfilename: Optional[str] = args.logfilename
252252
logfilemode: str = args.logfilemode
253+
excludefiles: List[str] = args.exclude
253254

254255
if not os.path.isdir(tgtpath):
255256
print_error(f"Target directory {tgtpath} not found")
@@ -273,7 +274,7 @@ def cproject_analyze_project(args: argparse.Namespace) -> NoReturn:
273274
exit(1)
274275

275276
capp = CApplication(
276-
projectpath, projectname, targetpath, contractpath)
277+
projectpath, projectname, targetpath, contractpath, excludefiles=excludefiles)
277278

278279
def save_xrefs(f: "CFile") -> None:
279280
capp.indexmanager.save_xrefs(
@@ -286,7 +287,7 @@ def save_xrefs(f: "CFile") -> None:
286287
linker.save_global_compinfos()
287288

288289
capp = CApplication(
289-
projectpath, projectname, targetpath, contractpath)
290+
projectpath, projectname, targetpath, contractpath, excludefiles=excludefiles)
290291

291292
am = AnalysisManager(capp, verbose=True)
292293

chc/cmdline/chkc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,9 @@ def parse() -> argparse.Namespace:
14161416
choices=["a", "w"],
14171417
default="a",
14181418
help="file mode for log file: append (a, default), or write (w)")
1419+
cprojectanalyze.add_argument("-x", "--exclude", action='append',
1420+
help="Exclude file from analysis. To exclude multiple files, use "
1421+
"this option for each file, e.g. -x dir1/f1.c, -x dir2/f2.c")
14191422
cprojectanalyze.set_defaults(func=P.cproject_analyze_project)
14201423

14211424
# --- report

0 commit comments

Comments
 (0)