runoff fixes

This commit is contained in:
rsc 2006-09-06 19:43:59 +00:00
parent 2a55cc5501
commit 26dfb4c80d

91
runoff
View file

@ -42,44 +42,50 @@ pr -e8 -t runoff.list | awk '
# make definition list # make definition list
cd fmt cd fmt
awk ' perl -e '
/^[0-9]+ [A-Za-z0-9_]+ .*[A-Za-z0-9_].*;/ { while(<>) {
s=$0; chomp;
sub(/\[.*/, "", s);
sub(/\(.*/, "", s); s!//.*!!;
sub(/ *=.*/, "", s); s!/\*([^*]|[*][^/])*\*/!!g;
sub(/.* \**/, "", s); s!\s! !g;
sub(/;.*/, "", s); s! +$!!;
print $1, s
} # look for declarations like char* x;
$2=="#define" { if (/^[0-9]+ typedef .* u(int|short|long|char);/) {
if($3 ~ /\(/){ next;
sub(/\(.*/, "", $3); print $1, $3
} else {
s = ""
for(i=4; i<=NF; i++){
s = s $i
}
print $1, $3, s
} }
} if (/^[0-9]+ extern/) {
$2=="enum" { inenum = 1; v=-1; } next;
$2 == "};" { inenum = 0; } }
inenum && $2 ~ /^[A-Z][a-zA-Z0-9_]+$/ { if (/^[0-9]+ struct [a-zA-Z0-9_]+;/) {
if($3 == "="){ next;
s = "" }
for(i=4; i<=NF; i++){ if (/\(/) {
s = s " " $i next;
} }
sub(/,$/, "", s);
sub(/^ /, "", s); if (/^([0-9]+) (((static|struct|extern|union|enum) +)*([A-Za-z0-9_]+))( .*)? +([A-Za-z_][A-Za-z0-9_]*)[,;]/) {
v = s;
}else print "$1 $7\n"
v++; }
print $1, $2, v;
} elsif (/^([0-9]+) #define +([A-za-z0-9_]+) +?\(.*/) {
$2=="struct" && $3 ~ /^[A-Z][a-zA-Z0-9_]+$/ { print "$1 $2\n"
print $1, $3; }
elsif (/^([0-9]+) #define +([A-Za-z0-9_]+) +([^ ]+)$/) {
print "$1 $2 $3\n";
}
elsif (/^([0-9]+) #define +([A-Za-z0-9_]+)/) {
print "$1 $2\n";
}
elsif(/^([0-9]+) (enum|struct|union) +([A-Za-z0-9_]+) +{/){
print "$1 $3\n";
}
# TODO: enum members
} }
' $files >defs ' $files >defs
@ -110,12 +116,15 @@ awk '
# format the whole thing # format the whole thing
( (
pr -l60 -e4 README pr -l60 -e8 README
pr -l60 -e4 toc pr -l60 -e8 -2 toc
pr -l60 -h "definitions" -2 t.defs | pad pr -l60 -h "definitions" -2 t.defs | pad
pr -l60 -h "cross-references" -2 refs | pad pr -l60 -h "cross-references" -2 refs | pad
pr -l60 -e4 $files for i in $files
) | mpage -m50t50b -o -bLetter -t -2 -FCourier -L60 >all.ps do
cat $i | pr -l60 -e8 -h "xv6/$i"
done
) | mpage -m50t50b -o -bLetter -T -t -2 -FCourier -L60 >all.ps
grep Pages: all.ps grep Pages: all.ps
# if we have the nice font, use it # if we have the nice font, use it