aboutsummaryrefslogtreecommitdiff
path: root/bindgen
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2025-01-21 18:20:39 +0100
committerAndre Weissflog <floooh@gmail.com>2025-01-21 18:20:39 +0100
commit68e9694f2f51c527d54826b11acae4f940b767b8 (patch)
treef87ff58351707be829e12bba885b821b8de998ff /bindgen
parentcb11cc4465cc1d8c62fbd92c80c944a864ae233c (diff)
gen_ir.py: don't let python 'fix' line endings in input file
...otherwise the range values in the Clang ast-dump are off.
Diffstat (limited to 'bindgen')
-rw-r--r--bindgen/gen_ir.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/bindgen/gen_ir.py b/bindgen/gen_ir.py
index cbeea3e8..a01b239d 100644
--- a/bindgen/gen_ir.py
+++ b/bindgen/gen_ir.py
@@ -134,7 +134,11 @@ def gen(header_path, source_path, module, main_prefix, dep_prefixes, with_commen
outp['prefix'] = main_prefix
outp['dep_prefixes'] = dep_prefixes
outp['decls'] = []
- with open(header_path, 'r') as f:
+ # load string with original line endings (otherwise Clang's output ranges
+ # for comments are off)
+ # NOTE: that same problem might exist for non-ASCII characters,
+ # so don't use those in header files!
+ with open(header_path, mode='r', newline='') as f:
source = f.read()
first_comment = re.search(r"/\*(.*?)\*/", source, re.S).group(1)
if first_comment and "Project URL" in first_comment: