diff options
| author | rsc <rsc> | 2006-09-08 13:53:18 +0000 | 
|---|---|---|
| committer | rsc <rsc> | 2006-09-08 13:53:18 +0000 | 
| commit | ec5783cbd2b52b3e566938fc8d07851e117005e2 (patch) | |
| tree | 2619051217bd26ce96ede00089e17c361792c835 /runoff | |
| parent | 72a590d9e50de4d361bb8f0f81e156abf5014f39 (diff) | |
| download | xv6-labs-ec5783cbd2b52b3e566938fc8d07851e117005e2.tar.gz xv6-labs-ec5783cbd2b52b3e566938fc8d07851e117005e2.tar.bz2 xv6-labs-ec5783cbd2b52b3e566938fc8d07851e117005e2.zip | |
runoff changes
Diffstat (limited to 'runoff')
| -rwxr-xr-x | runoff | 103 | 
1 files changed, 12 insertions, 91 deletions
| @@ -16,90 +16,7 @@ files=`grep -v '^#' runoff.list | awk '{print $1}'`  n=99  for i in $files  do -	perl -e '$n='$n';' -e '  -		$n = int(($n+49)/50)*50 - 1; - -		@lines = <>; -		foreach (@lines) { -			chomp; -			s/\s+$//; -			if(length() >= 75){ -				print "$ARGV[0]:$.: line too long"; -			} -		} -		@outlines = (); -		$nextout = 0; -		for($i=0; $i<@lines; ){ -			# Skip leading blank lines. -			$i++ while $i<@lines && $lines[$i] =~ /^$/; -			last if $i>=@lines; - -			# If the rest of the file fits, use the whole thing. -			if(@lines <= $i+50){ -				$breakbefore = @lines; -			}else{ -				# Find a good next page break; -				# Hope for end of function. -				# but settle for a blank line (but not first blank line -				# in function, which comes after variable declarations). -				$breakbefore = $i; -				$lastblank = $i; -				$sawbrace = 0; -				$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); -						$breakbefore = $j; -						$lines[$j] = ""; -					} -					if($lines[$j] =~ /^}$/){ -						$breakbefore = $j+1; -					} -					if($lines[$j] =~ /^{$/){ -						$sawbrace = 1; -					} -					if($lines[$j] =~ /^$/){ -						if($sawbrace){ -							$sawbrace = 0; -						}else{ -							$lastblank = $j; -						} -					} -				} -				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){ -					$breakbefore = $lastblank; -					$breaksize = 5;  # only 5 lines to get to blank line -				} - -				# If we are not putting enough on a page, force a full page. -				if($breakbefore - $i < 50 - $breaksize && $breakbefore != @lines){ -					$breakbefore = $i + 50; -					$breakbefore = @lines if @lines < $breakbefore; -				} - -				if($breakbefore < $i+2){ -					$breakbefore = $i+2; -				} -			} - -			# Emit the page. -			$i50 = $i + 50; -			for(; $i<$breakbefore; $i++){ -				printf "%04d %s\n", ++$n, $lines[$i]; -			} - -			# Finish page -			for($j=$i; $j<$i50; $j++){ -				printf "%04d \n", ++$n; -			} -		} -	' $i >fmt/$i - +	runoff1 -n $n $i >fmt/$i  	nn=`tail -1 fmt/$i | sed 's/ .*//; s/^0*//'`  	if [ "x$nn" != x ]; then  		n=$nn @@ -107,8 +24,9 @@ do  done  # create table of contents +cat toc.hdr >fmt/toc  pr -e8 -t runoff.list | awk ' -/^[a-z]/ { +/^[a-z0-9]/ {  	s=$0  	f="fmt/"$1  	getline<f @@ -119,7 +37,8 @@ pr -e8 -t runoff.list | awk '  }  {  	print -}' >fmt/toc +}' | pr -3 -t >>fmt/toc +cat toc.ftr >>fmt/toc  # make definition list  cd fmt @@ -197,13 +116,15 @@ awk '  # format the whole thing  ( -	pr -l60 -e8 README -	pr -l60 -h "table of contents" -e8 -2 toc -	pr -l60 -h "definitions" -2 t.defs | pad -	pr -l60 -h "cross-references" -2 refs | pad  +	../pr.pl README +	../pr.pl -h "table of contents" toc +	# pr -t -2 t.defs | ../pr.pl -h "definitions" | pad +	pr -t -l50 -2 refs | ../pr.pl -h "cross-references" | pad +	# pr.pl -h "definitions" -2 t.defs | pad +	# pr.pl -h "cross-references" -2 refs | pad   	for i in $files  	do -		cat $i | pr -l60 -e8 -h "xv6/$i" +		../pr.pl -h "xv6/$i" $i  	done  ) | mpage -m50t50b -o -bLetter -T -t -2 -FCourier -L60 >all.ps  grep Pages: all.ps | 
