PageRenderTime 11ms CodeModel.GetById 8ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Tools/WAD/Wad/wadhandler.pl

#
Perl | 36 lines | 35 code | 1 blank | 0 comment | 5 complexity | 8984e0adc8981ff71c325b4bbbe66567 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1package libwadpl;
 2sub wad_handler_traceback {
 3    package DB;
 4    my $es = "";
 5    ($pack,$file,$line) = caller(1);
 6
 7    for ($i = 2; ($p,$f,$l,$s,$h,$w,$e,$r) = caller($i); $i++) {
 8        @a = ();
 9        for $arg (@args) {
10            $_ = "$arg";
11            s/([\'\\])/\\$1/g;
12            s/([^\0]*)/'$1'/
13              unless /^(?: -?[\d.]+ | \*[\w:]* )$/x;
14            s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
15            s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
16            push(@a, $_);
17        }
18        $w = $w ? '@ = ' : '$ = ';
19        $a = $h ? '(' . join(', ', @a) . ')' : '';
20        $e =~ s/\n\s*\;\s*\Z// if $e;
21        $e =~ s/[\\\']/\\$1/g if $e;
22        if ($r) {
23            $s = "require '$e'";
24        } elsif (defined $r) {
25            $s = "eval '$e'";
26        } elsif ($s eq '(eval)') {
27            $s = "eval {...}";
28        }
29        $f = "file `$f'" unless $f eq '-e';
30        $mess = "$w$s$a called from $f line $l\n";
31	$es = $mess . $es;
32
33    }
34    $es = "Signal at $file line $line\n" . $es;
35    return $es;
36}