#!/usr/local/bin/perl
# List specific section(s) of Sun Unbundled Patch list
# Works like grep -- lists all matching sections

if (scalar(@ARGV) == 0) {
    $program = (split(/\//,$0))[-1];
    print STDERR "Usage: $program product [file ...]\n";
    exit 1;
}

$piece=shift(@ARGV);

my $last;

while (<>) {
    while (! /Patches for.*\W$piece\W.*Last update: /i) {
	$last=$_;
	exit unless ($_=<>);
    }
    if (/Patches for.*\W$piece\W.*Last update: /i) {
	print $last;
	print;
	$_=<>;
	print;
	while (($_=<>) && (! /^\*/)) {
	    print;
	}
	$last=$_;
    }
}
