#!/afs/athena/contrib/perl/perl

$fn1 = shift(@ARGV) || die;
$fn2 = shift(@ARGV) || die;

open(F1, $fn1);
open(F2, $fn2);

while (($l1=<F1>)&&($l2=<F2>)) {
    @a = split(/,/, $l1);
    @b = split(/,/, $l2);
    @res = ();

    while (@a && @b) {
	$ia = shift(@a);
	$ib = shift(@b);

	$sta = ($ia =~ /^\s*0x([0-9a-zA-Z]{1,2})\s*$/);  $nma=$1;
	$stb = ($ib =~ /^\s*0x([0-9a-zA-Z]{1,2})\s*$/);  $nmb=$1;

	die "inconsistency type 1" if ($sta != $stb);

	if ($sta) {
	    push(@res, sprintf("0x%2x",hex($nma) | hex($nmb)));
	} else {
	    push(@res, $ia);
	}
    }

    die "inconsistency type 2" if (@a || @b);
    print join(',' , @res);
}
