Fix incorrect line order when converting from INO to CPP and pointer is used

This commit is contained in:
Ivan Kravets
2016-09-09 18:49:58 +03:00
parent 39a787b0d1
commit a42cf4ebdd
3 changed files with 7 additions and 1 deletions

View File

@ -146,6 +146,8 @@ class InoToCPPConverter(object):
def _get_total_lines(self, contents):
total = 0
if contents.endswith("\n"):
contents = contents[:-1]
for line in contents.split("\n")[::-1]:
linenum = self._parse_preproc_line_num(line)
if linenum is not None:
@ -164,7 +166,7 @@ class InoToCPPConverter(object):
("|".join(prototype_names)),
contents[:split_pos], re.M)
if match_ptrs:
split_pos = contents.rfind("\n", 0, match_ptrs.start())
split_pos = contents.rfind("\n", 0, match_ptrs.start()) + 1
result = []
result.append(contents[:split_pos].strip())

View File

@ -40,6 +40,8 @@ void myFunction(struct Item *item) {
}
#warning "Line number is 43"
void fooCallback(){
}

View File

@ -42,6 +42,8 @@ def test_warning_line(clirunner, validate_cliresult):
validate_cliresult(result)
assert ('basic.ino:16:14: warning: #warning "Line number is 16"' in
result.output)
assert ('basic.ino:43:2: warning: #warning "Line number is 43"' in
result.output)
result = clirunner.invoke(
cmd_ci, [join(INOTEST_DIR, "strmultilines"), "-b", "uno"])
validate_cliresult(result)