File: lua-releng

package info (click to toggle)
lua-nginx-redis-connector 0.06-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, buster, sid, trixie
  • size: 136 kB
  • sloc: makefile: 118; perl: 47
file content (63 lines) | stat: -rwxr-xr-x 2,097 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env perl

use strict;
use warnings;

sub file_contains ($$);

my $version;
for my $file (map glob, qw{ *.lua lib/*.lua lib/*/*.lua lib/*/*/*.lua lib/*/*/*/*.lua lib/*/*/*/*/*.lua }) {
    # Check the sanity of each .lua file
    open my $in, $file or
        die "ERROR: Can't open $file for reading: $!\n";
    my $found_ver;
    while (<$in>) {
        my ($ver, $skipping);
        if (/(?x) (?:_VERSION) \s* = .*? ([\d\.]*\d+) (.*? SKIP)?/) {
            my $orig_ver = $ver = $1;
            $found_ver = 1;
            #        $skipping = $2;
            $ver =~ s{^(\d+)\.(\d{3})(\d{3})$}{join '.', int($1), int($2), int($3)}e;
            warn "$file: $orig_ver ($ver)\n";

        } elsif (/(?x) (?:_VERSION) \s* = \s* ([a-zA-Z_]\S*)/) {
            warn "$file: $1\n";
            $found_ver = 1;
            last;
        }

        if ($ver and $version and !$skipping) {
            if ($version ne $ver) {
                #    die "$file: $ver != $version\n";
            }
        } elsif ($ver and !$version) {
            $version = $ver;
        }
    }
    if (!$found_ver) {
        warn "WARNING: No \"_VERSION\" or \"version\" field found in `$file`.\n";
    }
    close $in;

    #print "Checking use of Lua global variables in file $file ...\n";
    system("luac5.1 -p -l $file | grep ETGLOBAL | grep -vE '(require|type|tostring|error|ngx|ndk|jit|setmetatable|getmetatable|string|table|io|os|print|tonumber|math|pcall|xpcall|unpack|pairs|ipairs|assert|module|package|coroutine|[gs]etfenv|next|select|rawset|rawget|debug)\$'");
    #file_contains($file, "attempt to write to undeclared variable");
    system("grep -H -n -E --color '.{120}' $file");
}

sub file_contains ($$) {
    my ($file, $regex) = @_;
    open my $in, $file
        or die "Cannot open $file fo reading: $!\n";
    my $content = do { local $/; <$in> };
    close $in;
    #print "$content";
    return scalar ($content =~ /$regex/);
}

if (-d 't') {
    for my $file (map glob, qw{ t/*.t t/*/*.t t/*/*/*.t }) {
        system(qq{grep -H -n --color -E '\\--- ?(ONLY|LAST)' $file});
    }
}