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

View File

@ -17,6 +17,8 @@ PlatformIO 3.0
~~~~~~~~~~~~~~~~~~
* Project Generator: fixed a VSCode C/C++'s "Cannot find" warning when CPPPATH folder does not exist
* Fixed an "IndexError: list index out of range" for Arduino sketch preprocessor
(`issue #2268 <https://github.com/platformio/platformio-core/issues/2268>`_)
3.6.6 (2019-03-29)
~~~~~~~~~~~~~~~~~~

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(