mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 10:37:13 +02:00
Fix incorrect line order when converting from INO to CPP and pointer is used
This commit is contained in:
@ -146,6 +146,8 @@ class InoToCPPConverter(object):
|
|||||||
|
|
||||||
def _get_total_lines(self, contents):
|
def _get_total_lines(self, contents):
|
||||||
total = 0
|
total = 0
|
||||||
|
if contents.endswith("\n"):
|
||||||
|
contents = contents[:-1]
|
||||||
for line in contents.split("\n")[::-1]:
|
for line in contents.split("\n")[::-1]:
|
||||||
linenum = self._parse_preproc_line_num(line)
|
linenum = self._parse_preproc_line_num(line)
|
||||||
if linenum is not None:
|
if linenum is not None:
|
||||||
@ -164,7 +166,7 @@ class InoToCPPConverter(object):
|
|||||||
("|".join(prototype_names)),
|
("|".join(prototype_names)),
|
||||||
contents[:split_pos], re.M)
|
contents[:split_pos], re.M)
|
||||||
if match_ptrs:
|
if match_ptrs:
|
||||||
split_pos = contents.rfind("\n", 0, match_ptrs.start())
|
split_pos = contents.rfind("\n", 0, match_ptrs.start()) + 1
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
result.append(contents[:split_pos].strip())
|
result.append(contents[:split_pos].strip())
|
||||||
|
@ -40,6 +40,8 @@ void myFunction(struct Item *item) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#warning "Line number is 43"
|
||||||
|
|
||||||
void fooCallback(){
|
void fooCallback(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,8 @@ def test_warning_line(clirunner, validate_cliresult):
|
|||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
assert ('basic.ino:16:14: warning: #warning "Line number is 16"' in
|
assert ('basic.ino:16:14: warning: #warning "Line number is 16"' in
|
||||||
result.output)
|
result.output)
|
||||||
|
assert ('basic.ino:43:2: warning: #warning "Line number is 43"' in
|
||||||
|
result.output)
|
||||||
result = clirunner.invoke(
|
result = clirunner.invoke(
|
||||||
cmd_ci, [join(INOTEST_DIR, "strmultilines"), "-b", "uno"])
|
cmd_ci, [join(INOTEST_DIR, "strmultilines"), "-b", "uno"])
|
||||||
validate_cliresult(result)
|
validate_cliresult(result)
|
||||||
|
Reference in New Issue
Block a user