home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
qtawk
/
toc.exp
< prev
next >
Wrap
Text File
|
1990-04-23
|
1KB
|
42 lines
# QTAwk utility to create line oriented Table-of-Contents
#
BEGIN {
dots = copies(".",78);
print "Contents";
print overlay(overlay(dots,"Para. #/Title",1)," Line",74);
# set regular expression for looking for paragraph numbering
# un-comment regular expression desired for paragraph numbering utilized
ldr = "SECTION";
# para_num = /^([1-9]{_d}?\.)+{_d}{_d}?{_w}{_w}?/;
# para_num = /^({ldr} [1-9]\.|([1-9]{_d}?\.)+{_d}{_d}?){_w}{_w}/;
para_num = /^{_w}+([1-9]{_d}?\.)+{_d}{_d}?{_w}{2,3}/;
}
# search for start line sline == 0 unless set on command line
FNR < sline { next; }
# search for final line tline == 0 unless set on command line
FNR > tline { endfile; }
# print input line number to let user know of activity
{
fprint("stderr",FNR);
}
# find line with numbered paragraph
para_num {
hdr = $$0;
jj = gsub(/\./,"",hdr);
oline = strim($$0) " ";
for ( i = 2 ; i <= NF ; i++ ) {
oline ∩= $i ' ';
if ( $i ~~ /\.$/ ) break;
}
if ( length(oline) > 60 ) oline = substr(oline,1,60);
if ( jj == 1 ) print "";
else oline = copies(" ",2*(jj-1)) ∩ oline;
line = sprintf("%4u",FNR + line_off);
print overlay(overlay(dots,oline,1),line,75);
}