Skip to content

Commit 44b1b30

Browse files
authored
fix(IsFunctionCall): guard against EOF to avoid infinite loop on missing expected separator (42school#572)
* fix(IsFunctionCall): guard against EOF to avoid infinite loop on missing expected separator * test(rules_generator): add test for missing semicolon * fix(i18n): fix project version in .po files
1 parent 1923d74 commit 44b1b30

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

norminette/locale/en_US/LC_MESSAGES/norminette.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
msgid ""
77
msgstr ""
8-
"Project-Id-Version: 3.3.58\n"
8+
"Project-Id-Version: 3.3.59\n"
99
"Report-Msgid-Bugs-To: \n"
1010
"POT-Creation-Date: 2025-04-11 10:12-0300\n"
1111
"PO-Revision-Date: 2025-04-09 17:51-0300\n"

norminette/locale/pt_BR/LC_MESSAGES/norminette.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
msgid ""
77
msgstr ""
8-
"Project-Id-Version: 3.3.58\n"
8+
"Project-Id-Version: 3.3.59\n"
99
"Report-Msgid-Bugs-To: \n"
1010
"POT-Creation-Date: 2025-04-11 10:12-0300\n"
1111
"PO-Revision-Date: 2025-04-09 17:51-0300\n"

norminette/rules/is_function_call.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ def run(self, context):
128128
expected = "SEMI_COLON"
129129
else:
130130
expected = SEPARATORS
131-
while not context.check_token(i, expected):
131+
while context.peek_token(i) is not None and not context.check_token(i, expected):
132132
i += 1
133+
if context.peek_token(i) is None:
134+
return False, 0
133135
i += 1
134136
i = context.eol(i)
135137
return True, i
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void test(void)
2+
{
3+
foo(42)
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
test_missing_semi_after_call.c - IsFuncDeclaration In "GlobalScope" from "None" line 1":
2+
<VOID> <TAB> <IDENTIFIER=test> <LPARENTHESIS> <VOID> <RPARENTHESIS> <NEWLINE>
3+
test_missing_semi_after_call.c - IsBlockStart In "Function" from "GlobalScope" line 2":
4+
<LBRACE> <NEWLINE>
5+
test_missing_semi_after_call.c - IsDeclaration In "Function" from "GlobalScope" line 3":
6+
<TAB> <IDENTIFIER=foo> <LPARENTHESIS> <CONSTANT=42> <RPARENTHESIS> <NEWLINE>
7+
<RBRACE> <NEWLINE>
8+
test_missing_semi_after_call.c: Error!
9+
Error: INVALID_HEADER (line: 1, col: 1): Missing or invalid 42 header
10+
Error: TOO_FEW_TAB (line: 4, col: 1): Missing tabs for indent level

0 commit comments

Comments
 (0)