From: Chip Salzenberg Date: Wed, 15 Jan 1997 19:24:00 +0000 (+1200) Subject: PATCH: AutoSplit X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=96bc026d9c645175facfed3d043c4a1db3284a10;p=p5sagit%2Fp5-mst-13.2.git PATCH: AutoSplit (this is the same change as commit bb8fceff88bc3fe9e820d0761f1b0451a870ac65, but as applied) --- diff --git a/lib/AutoSplit.pm b/lib/AutoSplit.pm index cc9de33..c1ff13a 100644 --- a/lib/AutoSplit.pm +++ b/lib/AutoSplit.pm @@ -248,7 +248,10 @@ sub autosplit_file{ open(OUT,">/dev/null") || open(OUT,">nla0:"); # avoid 'not opened' warning my(@subnames, %proto); + my @cache = (); + my $caching = 1; while () { + next if /^=\w/ .. /^=cut/; if (/^package ([\w:]+)\s*;/) { warn "package $1; in AutoSplit section ignored. Not currently supported."; } @@ -275,10 +278,26 @@ sub autosplit_file{ print OUT "# NOTE: Derived from $filename. ", "Changes made here will be lost.\n"; print OUT "package $package;\n\n"; + print OUT @cache; + @cache = (); + $caching = 0; + } + if($caching) { + push(@cache, $_) if @cache || /\S/; + } + else { + print OUT $_; + } + if(/^}/) { + if($caching) { + print OUT @cache; + @cache = (); + } + print OUT "\n"; + $caching = 1; } - print OUT $_; } - print OUT "1;\n"; + print OUT @cache,"1;\n"; close(OUT); close(IN);