Fix an "IndexError: list index out of range" for Arduino sketch preprocessor // Resolve #2268

This commit is contained in:
Ivan Kravets
2019-04-01 18:50:40 +03:00
parent c1d01dbe34
commit cf13ec4035
2 changed files with 6 additions and 3 deletions
+4 -3
View File
@@ -157,9 +157,7 @@ class InoToCPPConverter(object):
return total
def append_prototypes(self, contents):
prototypes = self._parse_prototypes(contents)
if not prototypes:
return contents
prototypes = self._parse_prototypes(contents) or []
# skip already declared prototypes
declared = set(
@@ -168,6 +166,9 @@ class InoToCPPConverter(object):
m for m in prototypes if m.group(1).strip() not in declared
]
if not prototypes:
return contents
prototype_names = set(m.group(3).strip() for m in prototypes)
split_pos = prototypes[0].start()
match_ptrs = re.search(