Ticket #1137: codingstd_outdent.patch

File codingstd_outdent.patch, 1.7 KB (added by plobsing, 12 years ago)
  • t/codingstd/c_indent.t

     
    188188            # 
    189189            # The indentation of the previous line is not considered. 
    190190            # Check sanity by verifying that the indentation of the current line 
    191             # is divisible by four. 
    192             if ( $indent % 4 && 
    193                 !$state{in_comment} && 
    194                 $state{prev_last_char} eq ';' 
    195             ) { 
    196                 push @c_indent => "$path:$state{line_cnt}\n" 
    197                     . "    apparent non-4 space indenting ($indent space" 
    198                     . ( $indent == 1 ? '' : 's' ) . ")\n"; 
    199                 $c_failed{"$path\n"} = 1; 
     191            # is divisible by four, unless it should be outdented by 2. 
     192            if ($line =~ m{: (?:\s* /\* .*? \*/)? $}x) { 
     193                if ( $indent % 4 != 2 && 
     194                    !$state{in_comment} && 
     195                    $state{prev_last_char} eq ';' 
     196                ) { 
     197                    push @c_indent => "$path:$state{line_cnt}\n" 
     198                        . "    apprent non-2 space outdenting ($indent spaces)\n"; 
     199                    $c_failed{"$path\n"} = 1 
     200                } 
     201            } else { 
     202                if ( $indent % 4 && 
     203                    !$state{in_comment} && 
     204                    $state{prev_last_char} eq ';' 
     205                ) { 
     206                    push @c_indent => "$path:$state{line_cnt}\n" 
     207                        . "    apparent non-4 space indenting ($indent space" 
     208                        . ( $indent == 1 ? '' : 's' ) . ")\n"; 
     209                    $c_failed{"$path\n"} = 1; 
     210                } 
    200211            } 
    201212        } 
    202213    }