diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-02-11 17:46:31 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-02-11 17:15:58 +0000 |
commit | fb33efd2743933211455048aa111e4fc12e1e6a7 (patch) | |
tree | a2d856a3d780287c2504a82dc99d8f82530a73a7 /util | |
parent | fffc12cc34812ceb8104e78534bb0be338727765 (diff) |
CMake: pro2cmake.py: Do not go into infinite loop
Do not go into an infinite loop when replacing a variable with itself.
Change-Id: I2765b1c0c567753f26ca75e0533c1d193362b456
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
Diffstat (limited to 'util')
-rwxr-xr-x | util/cmake/pro2cmake.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 04e76635c0..13ee97cf00 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -455,17 +455,24 @@ class Scope(object): pattern = re.compile(r'\$\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?') match = re.search(pattern, result) while match: + old_result = result if match.group(0) == value: - return self.expand(match.group(1), '') - else: - result = result[:match.start()] \ - + self.expandString(match.group(1)) \ - + result[match.end():] + return self.get(match.group(1), []) + + replacement = self.expand(match.group(1)) + replacement_str = replacement[0] if replacement else '' + result = result[:match.start()] \ + + replacement_str \ + + result[match.end():] + + if result == old_result: + return result # Do not go into infinite loop + match = re.search(pattern, result) return [result] - def expand(self, key: str, default=None) -> typing.List[str]: - value = self.get(key, default) + def expand(self, key: str) -> typing.List[str]: + value = self.get(key, []) result: typing.List[str] = [] assert isinstance(value, list) for v in value: |