Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Gautier committed Mar 4, 2017
2 parents 86a1f96 + 8d3c0d6 commit c0a7e86
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
28 changes: 13 additions & 15 deletions betty-style.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3833,21 +3833,6 @@ sub process {

# check number of functions
# and number of lines per function
if ($line =~ /(})/g) {
$inscope -= $#-;
if ($inscope == 0) {
$funclines = 0;
}
}

if ($inscope >= 1) {
$funclines++;
if ($funclines > $max_func_length) {
WARN("FUNCTIONS",
"More than $max_func_length lines in a function\n");
}
}

if ($line =~ /({)/g) {
$inscope += $#-;
if ($prevline =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Ident|\(\*\s*$Ident\))\s*)\(/s && $inscope == 1) {
Expand All @@ -3869,6 +3854,19 @@ sub process {
}
}
}
if ($line =~ /(})/g) {
$inscope -= $#-;
}

if ($inscope >= 1) {
$funclines++;
if ($funclines > $max_func_length + 1) {
WARN("FUNCTIONS",
"More than $max_func_length lines in a function\n");
}
} else {
$funclines = 0;
}

# open braces for enum, union and struct go on the same line.
# if ($line =~ /^.\s*{/ &&
Expand Down
19 changes: 19 additions & 0 deletions tests/style/variables/variables1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>

int test;

/**
* main - Entry point
*
* Return: Always 0 (Success)
*/
int main(void)
{
int i;
int j;
int arr = {1, 2, 3};
int k;

putchar('\n');
return (0);
}
2 changes: 2 additions & 0 deletions tests/style/variables/variables1.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/style/variables/variables1.c:3: ERROR: global variables are not allowed
total: 1 errors, 0 warnings, 19 lines checked

0 comments on commit c0a7e86

Please sign in to comment.