glusterfs

Форк
0
/
check_goto.pl 
44 строки · 1.2 Кб
1
#!/usr/bin/env perl
2

3
use strict;
4
use warnings;
5

6
my @ignore_labels = qw (TODO retry fetch_data again try_again sp_state_read_proghdr redo disabled_loop fd_alloc_try_again);
7
my @ignore_files  = qw (y.tab.c lex.c);
8
my @c_files;
9
my $line;
10
my @labels;
11
my $in_comments;
12

13
{
14
        local $" = "|";
15
        my $cmd = "find . -type f -name '*.c' | grep -vE '(@ignore_files)'";
16
        @c_files = `$cmd`;
17
}
18

19
foreach my $file (@c_files) {
20
        chomp ($file);
21
        open FD, $file or die ("Failed to read file $file: $!");
22
        @labels = ();
23
        $in_comments = 0;
24
        while ($line = <FD>) {
25
                chomp ($line);
26

27
                next if $line =~ /^\s*(#|\/\/)/;
28
                $in_comments = 1 if ($line =~ /\/\*/);
29
                $in_comments = 0 if ($line =~ /\*\//);
30

31
                next if $in_comments;
32
                if ($line =~ /^\s*(([a-zA-Z]|_)\w*)\s*:/) {
33
                        push (@labels, $1) unless grep (/$1/, @ignore_labels);
34
                }
35
                @labels = () if $line =~ /^}/;
36

37
                next unless @labels;
38
                if ($line =~ /^\s*goto\s*(\w+)/) {
39
                        print "$file:$.: $line\n" if grep /^$1$/, @labels;
40
                }
41
        }
42

43
        close FD;
44
}
45

46

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.