summaryrefslogtreecommitdiff
path: root/embed.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-09-21 16:31:41 +0100
committerNicholas Clark <nick@ccl4.org>2010-09-21 16:31:41 +0100
commit881a210041fba07d64572d6daacf57235c173fee (patch)
treeadaebda7e4a8cfd54d248d3126471c4c6816fbf4 /embed.pl
parenta4c2757fffb03ea5afbba9313f45bf9f5cb6490e (diff)
downloadperl-881a210041fba07d64572d6daacf57235c173fee.tar.gz
In embed.pl, read embed.fnc into an array, rather than seeking and rereading.
Diffstat (limited to 'embed.pl')
-rwxr-xr-xembed.pl39
1 files changed, 22 insertions, 17 deletions
diff --git a/embed.pl b/embed.pl
index 7c96be47a5..a69308c7c6 100755
--- a/embed.pl
+++ b/embed.pl
@@ -94,6 +94,26 @@ EOW
open IN, "embed.fnc" or die $!;
+my @embed;
+
+while (<IN>) {
+ chomp;
+ next if /^:/;
+ while (s|\\$||) {
+ $_ .= <IN>;
+ chomp;
+ }
+ s/\s+$//;
+ my @args;
+ if (/^\s*(#|$)/) {
+ @args = $_;
+ }
+ else {
+ @args = split /\s*\|\s*/, $_;
+ }
+ push @embed, \@args;
+}
+
# walk table providing an array of components in each line to
# subroutine, printing the result
sub walk_table (&@) {
@@ -111,23 +131,8 @@ sub walk_table (&@) {
$F = safer_open("$filename-new");
}
print $F $leader if $leader;
- seek IN, 0, 0; # so we may restart
- while (<IN>) {
- chomp;
- next if /^:/;
- while (s|\\$||) {
- $_ .= <IN>;
- chomp;
- }
- s/\s+$//;
- my @args;
- if (/^\s*(#|$)/) {
- @args = $_;
- }
- else {
- @args = split /\s*\|\s*/, $_;
- }
- my @outs = &{$function}(@args);
+ foreach (@embed) {
+ my @outs = &{$function}(@$_);
print $F @outs; # $function->(@args) is not 5.003
}
print $F $trailer if $trailer;