diff --git a/norminette/rules/is_func_declaration.py b/norminette/rules/is_func_declaration.py index 387a4e6f..8d784a7b 100644 --- a/norminette/rules/is_func_declaration.py +++ b/norminette/rules/is_func_declaration.py @@ -200,6 +200,10 @@ def check_func_format(self, context): i = context.skip_nest(i) i += 1 i = context.skip_ws(i, nl=True) + while context.check_token(i, "LBRACKET"): + i = context.skip_nest(i) + i += 1 + i = context.skip_ws(i, nl=True) while context.check_token(i, "IDENTIFIER") is True and context.peek_token(i).value == "__attribute__": i += 1 i = context.skip_ws(i) @@ -216,7 +220,6 @@ def run(self, context): """ if type(context.scope) is not GlobalScope: return False, 0 - ret, read = self.check_func_format(context) if ret is False: return False, 0 diff --git a/norminette/tests/rules/test_file_210923.c b/norminette/tests/rules/test_file_210923.c index 44e20e26..7666ec25 100644 --- a/norminette/tests/rules/test_file_210923.c +++ b/norminette/tests/rules/test_file_210923.c @@ -78,4 +78,30 @@ int main(void) t_int * restrict d = 1; t_int * restrict e = 1; t_int * restrict f = 1; -} \ No newline at end of file +} + +int (*open_pipe(int nb_of_cmd))[2] +{ + int i; + t_pipe pipe_fd; + + pipe_fd = malloc(sizeof(int [2]) * (nb_of_cmd - 1)); + if (error_catch(pipe_fd == 0, "system", "fail to malloc pipe table")) + return (NULL); + i = 0; + while (i < nb_of_cmd - 1) + { + if (error_catch(pipe(pipe_fd[i++]) == -1, "system", + "fail to open pipe")) + { + while (--i) + { + close(pipe_fd[i][0]); + close(pipe_fd[i][1]); + } + free(pipe_fd); + return (NULL); + } + } + return (pipe_fd); +} diff --git a/norminette/tests/rules/test_file_210923.out b/norminette/tests/rules/test_file_210923.out index 8004af75..87b78233 100644 --- a/norminette/tests/rules/test_file_210923.out +++ b/norminette/tests/rules/test_file_210923.out @@ -167,7 +167,58 @@ test_file_210923.c - IsVarDeclaration In "Function" from "GlobalScope" line 80": test_file_210923.c - IsBlockEnd In "Function" from "GlobalScope" line 81": - + +test_file_210923.c - IsEmptyLine In "GlobalScope" from "None" line 82": + +test_file_210923.c - IsFuncDeclaration In "GlobalScope" from "None" line 83": + +test_file_210923.c - IsBlockStart In "Function" from "GlobalScope" line 84": + +test_file_210923.c - IsVarDeclaration In "Function" from "GlobalScope" line 85": + +test_file_210923.c - IsVarDeclaration In "Function" from "GlobalScope" line 86": + +test_file_210923.c - IsEmptyLine In "Function" from "GlobalScope" line 87": + +test_file_210923.c - IsAssignation In "Function" from "GlobalScope" line 88": + +test_file_210923.c - IsControlStatement In "Function" from "GlobalScope" line 89": + +test_file_210923.c - IsExpressionStatement In "ControlStructure" from "Function" line 90": + +test_file_210923.c - IsAssignation In "Function" from "GlobalScope" line 91": + +test_file_210923.c - IsControlStatement In "Function" from "GlobalScope" line 92": + +test_file_210923.c - IsBlockStart In "ControlStructure" from "Function" line 93": + +test_file_210923.c - IsControlStatement In "ControlStructure" from "Function" line 94": + + +test_file_210923.c - IsBlockStart In "ControlStructure" from "ControlStructure" line 96": + +test_file_210923.c - IsControlStatement In "ControlStructure" from "ControlStructure" line 97": + +test_file_210923.c - IsBlockStart In "ControlStructure" from "ControlStructure" line 98": + +test_file_210923.c - IsFunctionCall In "ControlStructure" from "ControlStructure" line 99": + +test_file_210923.c - IsFunctionCall In "ControlStructure" from "ControlStructure" line 100": + +test_file_210923.c - IsBlockEnd In "ControlStructure" from "ControlStructure" line 101": + +test_file_210923.c - IsFunctionCall In "ControlStructure" from "ControlStructure" line 102": + +test_file_210923.c - IsExpressionStatement In "ControlStructure" from "ControlStructure" line 103": + +test_file_210923.c - IsBlockEnd In "ControlStructure" from "ControlStructure" line 104": + +test_file_210923.c - IsBlockEnd In "ControlStructure" from "Function" line 105": + +test_file_210923.c - IsExpressionStatement In "Function" from "GlobalScope" line 106": + +test_file_210923.c - IsBlockEnd In "Function" from "GlobalScope" line 107": + test_file_210923.c: Error! Error: INVALID_HEADER (line: 1, col: 1): Missing or invalid 42 header Error: MULT_ASSIGN_LINE (line: 6, col: 16): Multiple assignations on a single line @@ -208,4 +259,4 @@ Error: TOO_MANY_VARS_FUNC (line: 80, col: 1): Too many variables declaratio Error: SPACE_REPLACE_TAB (line: 80, col: 10): Found space when expecting tab Error: SPC_AFTER_POINTER (line: 80, col: 11): space after pointer Error: DECL_ASSIGN_LINE (line: 80, col: 24): Declaration and assignation on a single line -Error: BRACE_SHOULD_EOL (line: 81, col: 1): Expected newline after brace +Error: TOO_MANY_FUNCS (line: 83, col: 1): Too many functions in file