home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-07 | 1.1 KB | 73 lines | [TEXT/MPS ] |
- Perl -Sx "{0}" {"Parameters"}
- Exit 0
-
- #!perl
-
- open(CONDITION, shift @ARGV) || die "Couldn't open condition";
-
- while (<CONDITION>) {
- $cond .= $_;
- }
-
- while (<>) {
- last if (/^Segment "%GlobalData"/);
- }
-
- $loop = <<'LOOP_HEAD' . $cond . <<'LOOP_TAIL';
- while (<>) {
- last unless (/\S/);
-
- ($name, $offset, $size, $rest) = /(\S+).*-\$(.*)\(A5\).*=\$(\S+)(.*)/;
-
- if ($rest =~ /file=\"([^"]+)\"/) {
- $file = $1;
- }
- LOOP_HEAD
- $begin = hex($offset);
- $end = $begin-hex($size);
-
- if (!defined $oldbegin) {
- $oldbegin = $begin;
- } elsif ($oldend ne $begin) {
- push(@begins, $oldbegin);
- push(@ends, $oldend);
- $oldbegin = $begin;
- }
- $oldend = $end;
- }
- LOOP_TAIL
-
- eval $loop;
-
- if (defined $oldbegin) {
- push(@begins, $oldbegin);
- push(@ends, $oldend);
- }
-
- @begins = sort {$b <=> $a} @begins;
- @ends = sort {$b <=> $a} @ends;
-
- print <<END_HEADER;
- type 'IRng' {
- wide array {
- longint;
- longint;
- };
- longint = 0;
- longint = 0;
- };
-
- resource 'IRng' (128) {
- {
- END_HEADER
-
- printf("\t\t%8d, ", shift @begins);
-
- while (($end = shift @ends) && ($begin = shift @begins)) {
- if ($end != $begin) {
- printf("%8d,\n\t\t%8d, ", $end, $begin);
- }
- }
-
- printf("%8d\n\t}\n};\n", $end);
-