| 1 |
#!/usr/local/bin/perl -w |
| 2 |
use IO::File; |
| 3 |
|
| 4 |
while (<>) |
| 5 |
{ |
| 6 |
last if /^static int perl_init()/; |
| 7 |
print; |
| 8 |
} |
| 9 |
|
| 10 |
my @head = ($_); |
| 11 |
|
| 12 |
while (<>) |
| 13 |
{ |
| 14 |
push(@head,$_); |
| 15 |
last if /^\t+dTHR/; |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
my $name = 0; |
| 20 |
my $count = 0; |
| 21 |
new_chunk(); |
| 22 |
|
| 23 |
sub new_chunk |
| 24 |
{ |
| 25 |
print "}\n\n" if $count; |
| 26 |
++$name; |
| 27 |
print "static void Chunk_$name (void)\n{\n"; |
| 28 |
push(@head,"\tChunk_$name();\n"); |
| 29 |
$count = 0; |
| 30 |
} |
| 31 |
|
| 32 |
while (<>) |
| 33 |
{ |
| 34 |
last if /^\s+return/; |
| 35 |
print; |
| 36 |
$count++; |
| 37 |
if (/^\t+\{/) |
| 38 |
{ |
| 39 |
while (<>) |
| 40 |
{ |
| 41 |
print; |
| 42 |
$count++; |
| 43 |
last if /^\t+\}/; |
| 44 |
} |
| 45 |
} |
| 46 |
new_chunk() if $count > 150; |
| 47 |
} |
| 48 |
|
| 49 |
print "}\n\n" if $count; |
| 50 |
|
| 51 |
while (@head) |
| 52 |
{ |
| 53 |
print shift(@head); |
| 54 |
} |
| 55 |
print; |
| 56 |
|
| 57 |
while (<>) |
| 58 |
{ |
| 59 |
print; |
| 60 |
} |
| 61 |
|
| 62 |
warn "$. lines\n"; |