Skip to content

Commit d6a7a23

Browse files
committed
lopper: correctly label compact (or sparse) nodes in --enhanced mode
Before this commit, the following device tree /dts-v1/; / { compact_label: compact_thing@0 { compatible = "baz"; }; less_compact_label: compact_thing@1 { compatible = "baz"; }; normal_label: compact_thing@2 { compatible = "baz"; }; sparse_label: compact_thing@3 { compatible = "baz"; }; }; ...resulted in mangled device-tree code (and hence a failing dtc invocation). By matching the "{" inside the regular expression, we no longer rely on whitespace as a marker for structure. Signed-off-by: Graeme Smecher <[email protected]>
1 parent 86b5ebb commit d6a7a23

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lopper/base.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -904,11 +904,8 @@ def _label_translate(text):
904904
"""private function used to match (and replace) labels in DTS files"""
905905
global lcount
906906
lcount = 0
907-
pattern2 = re.compile(
908-
r'^\s*?\w*?\s*?\:', re.DOTALL
909-
)
910907
pattern = re.compile(
911-
r'^\s*?(\w*?)\s*?\:(.*?)$', re.DOTALL | re.MULTILINE
908+
r'^\s*?(\w*?)\s*?\:([^{]*?)\s*\{', re.DOTALL | re.MULTILINE
912909
)
913910
return re.sub(pattern, lopper_base._label_replacer, text)
914911

0 commit comments

Comments
 (0)