plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

tref (358B)


      1 awk '
      2 BEGIN{
      3 	print ".nr Rp 1"	# supress ... Rx lines
      4 	first=1
      5 }
      6 
      7 #these come first
      8 $1=="..." && $2=="Rx"{
      9 	ref[$4] = $3
     10 	next
     11 }
     12 
     13 first {
     14 	printf(".lf %d %s\n", 1, inputfile)
     15 	lineoffset=NR-1
     16 	first=0
     17 }
     18 
     19 $1==".Rf"{
     20 	if($2 in ref)
     21 		$2=ref[$2]
     22 	else
     23 		printf("tref: %s:%d: no ref for %s\n",
     24 			inputfile, NR-lineoffset, $2) >"/dev/stderr"
     25 }
     26 
     27 {
     28 	print
     29 }
     30 
     31 ' $*