sub PROLOG{

}

sub POSTLOG{

}

sub BBL{
my($xx);
$xx=shift(@_);
$xx=~s/\.bib/\.bbl/;
return($xx);
}

######################################

sub format_author{ 
my($xyx);
$xyx=shift(@_);
&main::string_name_field(\${${$xyx}}{"author"},"Y");
}

sub format_editors{ # first_initial~last_name
my($xyx);
$xyx=shift(@_);
&main::string_name_field(\${${$xyx}}{"editor"},"Y");
}

sub format_pages{
my($xyx);
$xyx=shift(@_);
%item=%{${$xyx}};
${${$xyx}}{"pages"}=~s/--/-/;
}

sub format_name_string{
my(@names,$str,$ii);
$str=shift(@_);
@names=@{$str};
$str="";
for($ii=0;$ii<=$#names;$ii++){
  $str.=$names[$ii++]." ";
  $str.=$names[$ii++]." ";
  $str.=$names[$ii++].", ";
  $str.=$names[$ii]."¥";
  }
$str=~s/  / /g;$str=~s/, +¥/¥/g;$str=~s/¥$//;
$ii=rindex($str,'¥');
if($ii>0) {substr($str,$ii,1)=" and ";}
$str=~s/¥/, /g;
$str=~s/ ,/,/;$str=~s/ +/ /;
return($str);
}

###################################

sub output_ARTICLE{
my(%item,@names,$ii,$str);
%item=%{shift(@_)};
@names=@{$item{"author"}};
$str=&format_name_string(\@names);
print main::OUT "\\bibitem\{";
print main::OUT $item{"bib_entry"},"\}\n";
print main::OUT $str,",\n";
###
print main::OUT "\{\\sl ",$item{"title"},"\\\/\},\n";
print main::OUT $item{"journal"};
if( $item{"volume"} ne "" ) {print main::OUT " \{\\bf ",$item{"volume"},"\}";}
print main::OUT " (",$item{"year"},")";
if($item{"pages"} ne "" ){print main::OUT " ",$item{"pages"};}
print main::OUT ".\n\n";
}


sub output_BOOK{
my(%item,@names,$ii,$str);
%item=%{shift(@_)};
@names=@{$item{"author"}};
$str=&format_name_string(\@names);
print main::OUT "\\bibitem\{";
print main::OUT $item{"bib_entry"},"\}\n";
print main::OUT $str,",\n";
###
print main::OUT "\`\`",$item{"title"},"\'\'";
if( $item{"series"} ne "" ) {print main::OUT ",\n",$item{"series"};
  if( $item{"volume"} ne "" ) {print main::OUT " \{\\bf ",$item{"volume"},"\}";}
  }
if( $item{"publisher"} ne "" ) {print main::OUT ",\n",$item{"publisher"};
  if( $item{"address"} ne "" ) {print main::OUT ", ",$item{"address"};}
  }
print main::OUT "\n(",$item{"year"},")";
if($item{"pages"} ne "" ){print main::OUT " ",$item{"pages"};}
print main::OUT ".\n\n";
}

sub output_INCOLLECTION{
output_INPROCEEDINGS(@_);
}

sub output_INPROCEEDINGS{
my(%item,@names,$ii,$str);
%item=%{shift(@_)};
@names=@{$item{"author"}};
$str=&format_name_string(\@names);
print main::OUT "\\bibitem\{";
print main::OUT $item{"bib_entry"},"\}\n";
print main::OUT $str,",\n";
###
print main::OUT "\{\\sl ",$item{"title"},"\\\/\},\n";
print main::OUT "\`\`",$item{"booktitle"},"\'\'";
if( $item{"editors"} ne "") {print main::OUT ",\n(Ed. by: ",$item{"editors"},")";}
if( $item{"series"} ne "" ) {print main::OUT ",\n",$item{"series"};
  if( $item{"volume"} ne "" ) {print main::OUT " \{\\bf ",$item{"volume"},"\}";}
  }
if( $item{"publisher"} ne "" ) {print main::OUT ",\n",$item{"publisher"};
  if( $item{"address"} ne "" ) {print main::OUT ", ",$item{"address"};}
  }
print main::OUT "\n(",$item{"year"},")";
if($item{"pages"} ne "" ){print main::OUT " ",$item{"pages"};}
print main::OUT ".\n\n";
}