]> Devi Nivas Git - cs3210-lab0.git/commitdiff
tweaks
authorrsc <rsc>
Fri, 8 Sep 2006 14:40:59 +0000 (14:40 +0000)
committerrsc <rsc>
Fri, 8 Sep 2006 14:40:59 +0000 (14:40 +0000)
runoff
runoff1

diff --git a/runoff b/runoff
index 6ee8225e4972afc3e599cc993d67e3ec80efca23..46c63d1f822238d7b5ae8234ea26456ca0082b12 100755 (executable)
--- a/runoff
+++ b/runoff
@@ -10,7 +10,7 @@ pad()
 
 # create formatted (numbered) files
 mkdir -p fmt
-rm fmt/*
+rm -f fmt/*
 cp README fmt
 files=`grep -v '^#' runoff.list | awk '{print $1}'`
 n=99
diff --git a/runoff1 b/runoff1
index ed29ea509032acc90eca6290a1de13accc340649..68e4565c516490878887c91aa04a49bacd024434 100755 (executable)
--- a/runoff1
+++ b/runoff1
@@ -1,6 +1,11 @@
 #!/usr/bin/perl
 
 $n = 0;
+$v = 0;
+if($ARGV[0] eq "-v") {
+       $v = 1;
+       shift @ARGV;
+}
 if($ARGV[0] eq "-n") {
        $n = $ARGV[1];
        shift @ARGV;
@@ -38,12 +43,13 @@ for($i=0; $i<@lines; ){
                $breaksize = 15;  # 15 lines to get to function
                for($j=$i; $j<$i+50 && $j < @lines; $j++){
                        if($lines[$j] =~ /PAGEBREAK:\s*([0-9]+)/){
-                               $breaksize = int($2);
+                               $breaksize = $1;
                                $breakbefore = $j;
                                $lines[$j] = "";
                        }
                        if($lines[$j] =~ /^};?$/){
                                $breakbefore = $j+1;
+                               $breaksize = 15;
                        }
                        if($lines[$j] =~ /^{$/){
                                $sawbrace = 1;
@@ -59,9 +65,12 @@ for($i=0; $i<@lines; ){
                if($j<@lines && $lines[$j] =~ /^$/){
                        $lastblank = $j;
                }
-               
+
                # 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($v){
+                               print STDERR "breakbefore $breakbefore i $i breaksize $breaksize\n";
+                       }
                        $breakbefore = $lastblank;
                        $breaksize = 5;  # only 5 lines to get to blank line
                }