提交 fb6ddf3e 创建 作者: rsc's avatar rsc

tweaks

上级 66d46d69
...@@ -10,7 +10,7 @@ pad() ...@@ -10,7 +10,7 @@ pad()
# create formatted (numbered) files # create formatted (numbered) files
mkdir -p fmt mkdir -p fmt
rm fmt/* rm -f fmt/*
cp README fmt cp README fmt
files=`grep -v '^#' runoff.list | awk '{print $1}'` files=`grep -v '^#' runoff.list | awk '{print $1}'`
n=99 n=99
......
#!/usr/bin/perl #!/usr/bin/perl
$n = 0; $n = 0;
$v = 0;
if($ARGV[0] eq "-v") {
$v = 1;
shift @ARGV;
}
if($ARGV[0] eq "-n") { if($ARGV[0] eq "-n") {
$n = $ARGV[1]; $n = $ARGV[1];
shift @ARGV; shift @ARGV;
...@@ -38,12 +43,13 @@ for($i=0; $i<@lines; ){ ...@@ -38,12 +43,13 @@ for($i=0; $i<@lines; ){
$breaksize = 15; # 15 lines to get to function $breaksize = 15; # 15 lines to get to function
for($j=$i; $j<$i+50 && $j < @lines; $j++){ for($j=$i; $j<$i+50 && $j < @lines; $j++){
if($lines[$j] =~ /PAGEBREAK:\s*([0-9]+)/){ if($lines[$j] =~ /PAGEBREAK:\s*([0-9]+)/){
$breaksize = int($2); $breaksize = $1;
$breakbefore = $j; $breakbefore = $j;
$lines[$j] = ""; $lines[$j] = "";
} }
if($lines[$j] =~ /^};?$/){ if($lines[$j] =~ /^};?$/){
$breakbefore = $j+1; $breakbefore = $j+1;
$breaksize = 15;
} }
if($lines[$j] =~ /^{$/){ if($lines[$j] =~ /^{$/){
$sawbrace = 1; $sawbrace = 1;
...@@ -59,9 +65,12 @@ for($i=0; $i<@lines; ){ ...@@ -59,9 +65,12 @@ for($i=0; $i<@lines; ){
if($j<@lines && $lines[$j] =~ /^$/){ if($j<@lines && $lines[$j] =~ /^$/){
$lastblank = $j; $lastblank = $j;
} }
# If we are not putting enough on a page, try a blank line. # If we are not putting enough on a page, try a blank line.
if($breakbefore - $i < 50 - $breaksize && $lastblank > $breakbefore && $lastblank >= $i+50 - 5){ if($breakbefore - $i < 50 - $breaksize && $lastblank > $breakbefore && $lastblank >= $i+50 - 5){
if($v){
print STDERR "breakbefore $breakbefore i $i breaksize $breaksize\n";
}
$breakbefore = $lastblank; $breakbefore = $lastblank;
$breaksize = 5; # only 5 lines to get to blank line $breaksize = 5; # only 5 lines to get to blank line
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论