Skip to content

Commit

Permalink
3.3.32 - hotfix for regression in variable recognition in function de…
Browse files Browse the repository at this point in the history
…cl/proto
  • Loading branch information
N01ch committed Aug 31, 2021
1 parent 4dec8bf commit be1819a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 12 deletions.
2 changes: 1 addition & 1 deletion norminette/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "3.3.31"
__version__ = "3.3.32"
__name__ = "norminette"
__author__ = "42"
__author__email__ = "[email protected]"
16 changes: 8 additions & 8 deletions norminette/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
"VOLATILE",
"EXTERN",
"INLINE",
"RESTRICT" "SIGNED",
"RESTRICT",
"SIGNED",
"UNSIGNED",
]

Expand Down Expand Up @@ -375,14 +376,13 @@ def check_type_specifier(self, pos, user_def_type=False, nl=False):
i += 1
#i = self.skip_ws(i)
return True, i + 1
tmp = i
while self.check_token(tmp, types + whitespaces + ["MULT", "BWISE_AND"]) is True:
tmp += 1
tmp2 = self.skip_misc_specifier(tmp, nl=nl)
if tmp2 == tmp:
return True, i + 1
while self.check_token(i, types + whitespaces + ["MULT", "BWISE_AND"]) is True:
i += 1
tmp = self.skip_misc_specifier(i, nl=nl)
if tmp == i:
return True, i - 1
else:
return True, tmp2
return True, tmp

def check_identifier(self, pos, nl=False):
"""
Expand Down
13 changes: 13 additions & 0 deletions norminette/tests/rules/integer_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,16 @@ int main(void)
__int64 hex_i64 = 0x4a44000000000020I64;
unsigned __int64 hex_ui64 = 0x8a44000000000040Ui64;
}

int main(long long i, long long int j, long int k, short short l, short short int m, short int n, long o, short p)
{
long long i;
long long int j;
long int k;
short short l;
short short int m;
short int n;
long o;
short p;
}

32 changes: 32 additions & 0 deletions norminette/tests/rules/integer_constants.out
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ Missing or invalid header. Header are being reintroduced as a mandatory part of
<TAB> <UNSIGNED> <SPACE> <IDENTIFIER=__int64> <TAB> <IDENTIFIER=hex_ui64> <SPACE> <ASSIGN> <SPACE> <CONSTANT=0x8a44000000000040U> <IDENTIFIER=i64> <SEMI_COLON> <NEWLINE>
integer_constants.c - IsBlockEnd In "Function" from "GlobalScope" line 27":
<RBRACE> <NEWLINE>
integer_constants.c - IsEmptyLine In "GlobalScope" from "None" line 28":
<NEWLINE>
integer_constants.c - IsFuncDeclaration In "GlobalScope" from "None" line 29":
<INT> <TAB> <IDENTIFIER=main> <LPARENTHESIS> <LONG> <SPACE> <LONG> <SPACE> <IDENTIFIER=i> <COMMA> <SPACE> <LONG> <SPACE> <LONG> <SPACE> <INT> <SPACE> <IDENTIFIER=j> <COMMA> <SPACE> <LONG> <SPACE> <INT> <SPACE> <IDENTIFIER=k> <COMMA> <SPACE> <SHORT> <SPACE> <SHORT> <SPACE> <IDENTIFIER=l> <COMMA> <SPACE> <SHORT> <SPACE> <SHORT> <SPACE> <INT> <SPACE> <IDENTIFIER=m> <COMMA> <SPACE> <SHORT> <SPACE> <INT> <SPACE> <IDENTIFIER=n> <COMMA> <SPACE> <LONG> <SPACE> <IDENTIFIER=o> <COMMA> <SPACE> <SHORT> <SPACE> <IDENTIFIER=p> <RPARENTHESIS> <NEWLINE>
integer_constants.c - IsBlockStart In "Function" from "GlobalScope" line 30":
<LBRACE> <NEWLINE>
integer_constants.c - IsVarDeclaration In "Function" from "GlobalScope" line 31":
<TAB> <LONG> <SPACE> <LONG> <TAB> <TAB> <IDENTIFIER=i> <SEMI_COLON> <NEWLINE>
integer_constants.c - IsVarDeclaration In "Function" from "GlobalScope" line 32":
<TAB> <LONG> <SPACE> <LONG> <SPACE> <INT> <TAB> <IDENTIFIER=j> <SEMI_COLON> <NEWLINE>
integer_constants.c - IsVarDeclaration In "Function" from "GlobalScope" line 33":
<TAB> <LONG> <SPACE> <INT> <TAB> <TAB> <IDENTIFIER=k> <SEMI_COLON> <NEWLINE>
integer_constants.c - IsVarDeclaration In "Function" from "GlobalScope" line 34":
<TAB> <SHORT> <SPACE> <SHORT> <TAB> <TAB> <IDENTIFIER=l> <SEMI_COLON> <NEWLINE>
integer_constants.c - IsVarDeclaration In "Function" from "GlobalScope" line 35":
<TAB> <SHORT> <SPACE> <SHORT> <SPACE> <INT> <TAB> <IDENTIFIER=m> <SEMI_COLON> <NEWLINE>
integer_constants.c - IsVarDeclaration In "Function" from "GlobalScope" line 36":
<TAB> <SHORT> <SPACE> <INT> <TAB> <TAB> <IDENTIFIER=n> <SEMI_COLON> <NEWLINE>
integer_constants.c - IsVarDeclaration In "Function" from "GlobalScope" line 37":
<TAB> <LONG> <TAB> <TAB> <TAB> <IDENTIFIER=o> <SEMI_COLON> <NEWLINE>
integer_constants.c - IsVarDeclaration In "Function" from "GlobalScope" line 38":
<TAB> <SHORT> <TAB> <TAB> <TAB> <IDENTIFIER=p> <SEMI_COLON> <NEWLINE>
integer_constants.c - IsBlockEnd In "Function" from "GlobalScope" line 39":
<RBRACE> <NEWLINE>
integer_constants.c - IsEmptyLine In "GlobalScope" from "None" line 40":
<NEWLINE>
integer_constants.c: Error!
Error: DECL_ASSIGN_LINE (line: 3, col: 33): Declaration and assignation on a single line
Error: DECL_ASSIGN_LINE (line: 4, col: 34): Declaration and assignation on a single line
Expand Down Expand Up @@ -97,3 +123,9 @@ Error: TOO_MANY_VARS_FUNC (line: 25, col: 1): Too many variables declaratio
Error: DECL_ASSIGN_LINE (line: 25, col: 33): Declaration and assignation on a single line
Error: TOO_MANY_VARS_FUNC (line: 26, col: 1): Too many variables declarations in a function
Error: DECL_ASSIGN_LINE (line: 26, col: 34): Declaration and assignation on a single line
Error: LINE_TOO_LONG (line: 29, col: 82): line too long
Error: TOO_MANY_ARGS (line: 29, col: 115): Function has more than 4 arguments
Error: TOO_MANY_VARS_FUNC (line: 36, col: 1): Too many variables declarations in a function
Error: TOO_MANY_VARS_FUNC (line: 37, col: 1): Too many variables declarations in a function
Error: TOO_MANY_VARS_FUNC (line: 38, col: 1): Too many variables declarations in a function
Error: EMPTY_LINE_EOF (line: 40, col: 1): Empty line at end of file
6 changes: 3 additions & 3 deletions norminette/tests/rules/long_test.out
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ Error: NL_AFTER_PREPROC (line: 18, col: 1): Preprocessor statement must b
Error: NO_ARGS_VOID (line: 18, col: 11): Empty function argument requires void
Error: RETURN_PARENTHESIS (line: 20, col: 12): Return value must be in parenthesis
Error: SPACE_BEFORE_FUNC (line: 23, col: 4): space before function name
Error: MISSING_IDENTIFIER (line: 23, col: 17): missing type qualifier or identifier in function arguments
Error: MISSING_IDENTIFIER (line: 23, col: 16): missing type qualifier or identifier in function arguments
Error: BRACE_NEWLINE (line: 23, col: 22): Expected newline before brace
Error: RETURN_PARENTHESIS (line: 24, col: 12): Return value must be in parenthesis
Error: TOO_MANY_INSTR (line: 24, col: 17): Too many instructions on a single line
Error: TOO_MANY_FUNCS (line: 26, col: 1): Too many functions in file
Error: MISSING_IDENTIFIER (line: 26, col: 29): missing type qualifier or identifier in function arguments
Error: MISSING_IDENTIFIER (line: 26, col: 28): missing type qualifier or identifier in function arguments
Error: TOO_MANY_FUNCS (line: 31, col: 1): Too many functions in file
Error: MISSING_IDENTIFIER (line: 31, col: 34): missing type qualifier or identifier in function arguments
Error: MISSING_IDENTIFIER (line: 31, col: 33): missing type qualifier or identifier in function arguments
Error: BRACE_NEWLINE (line: 31, col: 39): Expected newline before brace
Error: BRACE_SHOULD_EOL (line: 31, col: 40): Expected newline after brace
Error: TOO_FEW_TAB (line: 31, col: 41): Missing tabs for indent level
Expand Down

0 comments on commit be1819a

Please sign in to comment.