2 # This library is no longer being maintained, and is included for backward
3 # compatibility with Perl 4 programs which may require it.
4 # This legacy library is deprecated and will be removed in a future
8 # tchrist@convex.com (Tom Christiansen)
13 # &assert('$var > 10', $var, $othervar, @various_info);
15 # That is, if the first expression evals false, we blow up. The
16 # rest of the args, if any, are nice to know because they will
17 # be printed out by &panic, which is just the stack-backtrace
18 # routine shamelessly borrowed from the perl debugger.
21 &panic("ASSERTION BOTCHED: $_[$[]",$@) unless eval $_[$[];
29 print "\npanic: @_\n";
31 exit 1 if $] <= 4.003; # caller broken
33 # stack traceback gratefully borrowed from perl debugger
37 my ($p,$f,$l,$s,$h,$a,@a,@frames);
38 for ($i = 0; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
41 if (/^StB\000/ && length($_) == length($_main{'_main'})) {
42 $_ = sprintf("%s",$_);
46 s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
47 s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
48 s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
51 $w = $w ? '@ = ' : '$ = ';
52 $a = $h ? '(' . join(', ', @a) . ')' : '';
53 push(@frames, "$w&$s$a from file $f line $l\n");
55 for ($i=0; $i <= $#frames; $i++) {