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_]*)\}?')
|
||||
match = re.search(pattern, result)
|
||||
while match:
|
||||
old_result = result
|
||||
if match.group(0) == value:
|
||||
return self.expand(match.group(1), '')
|
||||
else:
|
||||
return self.get(match.group(1), [])
|
||||
|
||||
replacement = self.expand(match.group(1))
|
||||
replacement_str = replacement[0] if replacement else ''
|
||||
result = result[:match.start()] \
|
||||
+ self.expandString(match.group(1)) \
|
||||
+ 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:
|
||||
|
Loading…
Reference in New Issue
Block a user