# Create a table of the form: compname title

BEGIN {
   print "titles"
}

/^component / {
   comp = $2
   size = 0
   next
}

/^instarch / {
   instarch = $2
   next
}

/^size / {
   if ( $3 != "" ) {
      if ($3 == instarch) {
         size = $2
      }
   } else {
      size = $2
   }
   next
}

/^title / {
   rawtitle = substr($0, 6);
   if (instarch != "") {
      title = sprintf(rawtitle, instarch)
   } else {
      title = rawtitle
   }
   if (size == 0) {
      print  comp " " title
   } else {
      print  comp " " title " (" size " megabytes)"
   }
}

END {
   print "endtitles"
}
