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>
This commit is contained in:
parent
fffc12cc34
commit
fb33efd274
@ -455,17 +455,24 @@ class Scope(object):
|
|||||||
pattern = re.compile(r'\$\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?')
|
pattern = re.compile(r'\$\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?')
|
||||||
match = re.search(pattern, result)
|
match = re.search(pattern, result)
|
||||||
while match:
|
while match:
|
||||||
|
old_result = result
|
||||||
if match.group(0) == value:
|
if match.group(0) == value:
|
||||||
return self.expand(match.group(1), '')
|
return self.get(match.group(1), [])
|
||||||
else:
|
|
||||||
result = result[:match.start()] \
|
replacement = self.expand(match.group(1))
|
||||||
+ self.expandString(match.group(1)) \
|
replacement_str = replacement[0] if replacement else ''
|
||||||
+ result[match.end():]
|
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)
|
match = re.search(pattern, result)
|
||||||
return [result]
|
return [result]
|
||||||
|
|
||||||
def expand(self, key: str, default=None) -> typing.List[str]:
|
def expand(self, key: str) -> typing.List[str]:
|
||||||
value = self.get(key, default)
|
value = self.get(key, [])
|
||||||
result: typing.List[str] = []
|
result: typing.List[str] = []
|
||||||
assert isinstance(value, list)
|
assert isinstance(value, list)
|
||||||
for v in value:
|
for v in value:
|
||||||
|
Loading…
Reference in New Issue
Block a user